Skip to content

Epic] agent runtime — local lightweight#354

Closed
clintjeff2 wants to merge 10 commits into
Bitcoindefi:mainfrom
clintjeff2:EPIC]-Agent-Runtime-—-local-lightweight

Hidden character warning

The head ref may contain hidden characters: "EPIC]-Agent-Runtime-\u2014-local-lightweight"
Closed

Epic] agent runtime — local lightweight#354
clintjeff2 wants to merge 10 commits into
Bitcoindefi:mainfrom
clintjeff2:EPIC]-Agent-Runtime-—-local-lightweight

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Provide a simple local CLI to register and run lightweight agents that can appear on the canvas and emit heartbeats.
  • Ensure registered runtime agents survive server restarts by persisting the registry to disk.
  • Surface real runtime agents alongside cloud agents in the admin/canvas API and use registry metadata when executing tasks.

Description

  • Add a lightweight CLI bin/open-stellar.mjs that implements open-stellar agent start --name <name> --district <district> to register an agent at /api/agents, optionally run a tiny local health endpoint, and send periodic heartbeats.
  • Expose the CLI via package.json bin entry and rename package to open-stellar.
  • Persist registered agent manifests to a JSON DB file at .open-stellar/agents-registry.json (configurable via OPEN_STELLAR_AGENT_DB_PATH) by enhancing lib/agent-registry.ts to loadPersistedAgents() and persistAgents() and to persist on register/update/deregister/reset.
  • Include registered runtime agents in the admin agent payload by converting registry entries into canvas MoltbotAgent shapes in app/api/admin/agents/route.ts.
  • Use registry metadata to resolve runtime agent identity when executing tasks via POST /api/agents/:id/task by reading getRegisteredAgent() in app/api/agents/[id]/task/route.ts.

Testing

  • Ran node bin/open-stellar.mjs --help to validate CLI usage output and it succeeded.
  • Ran targeted unit tests with npx vitest run lib/agent-runtime/executor.test.ts lib/reputation/reputation-store.test.ts and both test files passed.
  • Ran npx tsc --noEmit which failed due to existing unrelated repo TypeScript issues (preexisting task drain typing, missing @wagmi/connectors types, and an existing promise/result shape mismatch), so typecheck was not fully green in this branch.

Closes #17

clintjeff2 and others added 9 commits June 27, 2026 07:38
…time

Add local agent runtime CLI and persisted agent registry
…y rating

This change adds `isAuthorized` checks to multiple API routes that were previously unprotected.
It also updates the test suite to include the required authorization headers.
Targeted routes include:
- /api/agents (POST)
- /api/agents/[id] (DELETE)
- /api/agents/[id]/capabilities (GET, PUT)
- /api/agents/[id]/task (GET, POST)
- /api/agents/[id]/tasks (POST, DELETE)
- /api/agents/[id]/tasks/drain (POST)
- /api/agents/[id]/xp/history (GET)
- /api/agents/[id]/rate-limit/status (GET)
- /api/admin/runs (GET, POST)
- /api/quests/[id]/subtasks (POST)
- /api/quests/[id]/subtasks/[subtaskId] (PATCH)

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…357804302716282

Fix SonarCloud Security Rating failure by securing API endpoints
- Replace Math.random() with crypto.randomInt in bin/open-stellar.mjs for better security rating.
- Use top-level await instead of promise chain in bin/open-stellar.mjs.
- Fix unescaped apostrophe in app/offline/page.tsx.
- Fix @typescript-eslint/ban-ts-comment and no-unsafe-declaration-merging in lib/passport/validator-client.ts.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…648995182642

Resolve SonarCloud Quality Gate and CI failures
- Replaced `window` with `globalThis` in `lib/passport/validator-client.ts` to align with modern standards and fix SonarCloud warning.
- Sanitized error messages in `bin/open-stellar.mjs` by removing carriage returns and newlines to prevent log injection vulnerabilities.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…0745808081075458573

Fix SonarCloud Quality Gate failures
@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli , please review and merge.

@leocagli

Copy link
Copy Markdown
Collaborator

Hi @clintjeff2 — a heads-up on this PR (and it's the same across all 10 of your open PRs): the required "Typecheck, tests, build, and guards" check is failing, so none of them can merge. SonarCloud Code Analysis passes, so it's not a code-quality issue — it's a TypeScript / test / build error.

To reproduce and fix locally:

pnpm install
pnpm typecheck   # see the exact TS errors
pnpm build

Since it fails on all your PRs identically, the likely cause is a shared issue (a branch off an out-of-date base, or a common type/import error). Fixing that and pushing should turn them green. Happy to help pinpoint it if you paste the pnpm typecheck output. 🙏

@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli , check this out. Let me know if this meets the standard. Because the typechecks and all goes here well.

@leocagli

Copy link
Copy Markdown
Collaborator

Closing as part of a security cleanup. Every one of your 9 open PRs (#354 #355 #356 #357 #359 #360 #361 #363 #364) edits lib/passport/validator-client.ts — the file that was the target of the spec-corruption attacks in #284/#358. Features like rate limiting, observability, API-key management, agent runtime, and orchestration have no legitimate reason to modify the ZK passport validator client.

Combined with (a) you being the author of the #358 attack on this exact file, and (b) recurring unrelated scope creep flagged in review (e.g. silently raising MAX_PENDING_PER_AGENT 100→500, unused EVM/MetaMask dependencies, unauthenticated endpoints), these are being closed.

If any of this work is genuine, resubmit each feature as a focused PR that does not touch anything under lib/passport/, with no unrelated changes, and green CI. They will be reviewed on their merits.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EPIC] Agent Runtime — local lightweight agents + cloud orchestration

2 participants