feat: Prayer integration — zero-token grind loop offloading#16
Open
Savolent wants to merge 1 commit intovcarl:mainfrom
Open
feat: Prayer integration — zero-token grind loop offloading#16Savolent wants to merge 1 commit intovcarl:mainfrom
Savolent wants to merge 1 commit intovcarl:mainfrom
Conversation
Add PrayerManager and PrayerClient to @roci/core for offloading repetitive game action sequences to a local .NET companion service (github.com/Savolent/Prayer) running PrayerLang scripts. - packages/core/src/prayer/prayer-client.ts: HTTP client for the Prayer backend (session lifecycle, snapshot polling, long-poll state change, script execution, LLM repair, route/stats endpoints) - packages/core/src/prayer/prayer-manager.ts: Per-agent session lifecycle manager. Supports session persistence via file (survives harness restarts), PRAYER_SET/PRAYER_END block parsing, halt detection, full-state resume summaries with cargo/arbitrage/mission context, and optional local-LLM script repair - packages/core/src/index.ts: Export PrayerManager, PrayerClient, parsePrayerScript, buildPrayerSummary and all related types - README.md: Add Optional Prayer section with setup instructions When Prayer is active the state machine skips body turns and polls instead. Claude resumes on halt (cargo full, fuel low, combat threat, script end) and receives a structured grind summary for replanning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
PrayerManagerandPrayerClientto@roci/corefor offloading repetitive, deterministic action sequences to Prayer — a local .NET companion service that runs PrayerLang scripts with zero LLM tokens.The idea: body turns are expensive (Claude API tokens) and slow (subprocess overhead). For known sequences — mining loops, sell runs, refuel routes — the agent emits a
PRAYER_SET:\n...\nPRAYER_ENDblock. The harness picks this up, hands it to Prayer, and polls for halts. Claude only resumes when something interesting happens (cargo full, fuel low, combat, script end), at which point it receives a rich grind summary and plans next steps.New files:
packages/core/src/prayer/prayer-client.ts— HTTP client for the Prayer backend. Session lifecycle, snapshot polling, long-poll state change detection, script execution, route/stats queries, local-LLM script repair endpoint.packages/core/src/prayer/prayer-manager.ts— Per-agent session manager:PrayerManager.create(baseUrl, csprojPath?)— health-checks; optionally starts Prayer viadotnet runensureSession(agentId, username, password, sessionFile?)— session persistence via file survives harness restartsstartScript(agentId, script)— hands PrayerLang script to backendpollOnce / pollWithLongPoll— efficient halt detectiongetFullStateForResume— cargo, credits, missions, arbitrage, memory log for brain contextparsePrayerScript(output)/buildPrayerSummary(result, fullState)— parse agent output, format resume contextUpdated:
packages/core/src/index.ts— exportsPrayerManager,PrayerClient,parsePrayerScript,buildPrayerSummaryand all related typesREADME.md— Prayer setup instructions with link to https://github.com/Savolent/PrayerPrayer is not included
The .NET service itself lives at Savolent/Prayer. This PR only adds the client library and manager. Prayer is entirely optional — if
PrayerManager.create()returns null (service not running, no csprojPath), the harness falls back to normal body turns with no behavior change.Test plan
PrayerManager.create(url)returns null when Prayer is not running and no csprojPath givenensureSessionreads persisted session file on restart, validates it, falls back to new session if staleparsePrayerScriptextracts script fromPRAYER_SET:\n...\nPRAYER_ENDcorrectlybuildPrayerSummaryformats cargo, credits, mission, and grind log into readable context🤖 Generated with Claude Code