logicsrc/docs/agentstack.md
Anthony Ettinger 850cf5ea44
feat(agentstack): add @logicsrc/agentstack coordination module (#5)
* feat(agentstack): add @logicsrc/agentstack coordination module

AgentStack is the LogicSRC module for portable agent, task, payment, and
reputation coordination across Profullstack apps. Reference implementation of
the `agentstack` capability in the Profullstack Shared AppKit OpenSpec.

- packages/agentstack: DID helpers (did:coinpay:user/agent), DidTask model +
  lifecycle, AgentStack in-memory coordinator (agents, tasks, delegation,
  events), and a validated LogicSRC plugin definition. 9 vitest cases.
- Wire @logicsrc/agentstack into the root build chain (after plugin-core).
- docs/agentstack.md + mention in openspec-comparison.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(agentstack): note dual-runtime support (Bun + Node.js + Workers + browser)

Matches the revised Shared AppKit PRD's Runtime Compatibility Strategy.
AgentStack is runtime-neutral (no Bun/Node-only APIs; time is injected).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 16:39:32 -07:00

85 lines
2.9 KiB
Markdown

# AgentStack
Status: draft module
AgentStack (`@logicsrc/agentstack`) is the LogicSRC module for **portable agent, task,
payment, and reputation coordination** across Profullstack microsaas apps. It is the
reference implementation of the `agentstack` capability defined in the Profullstack Shared
AppKit OpenSpec (`profullstack-web/openspec/specs/agentstack`).
## Why
Profullstack apps (sh1pt, uGig, qaaas.dev, crawlproof, commandboard.run, coinpayportal,
logicsrc, intr0s) need to share agents, tasks, reputation, and payment context without
forcing a shared login or one global account database. AgentStack provides a small,
provider-neutral coordination layer on top of CoinPay DIDs.
## Identity model
```txt
User DID: did:coinpay:user:123
Agent DID: did:coinpay:agent:abc
Task: task_123
```
Each app keeps a local `users.id` and links it to a CoinPay DID. The same person can appear
in many apps while every app independently owns its account:
```txt
sh1pt.users.id -> did:coinpay:user:123
ugig.users.id -> did:coinpay:user:123
qaaas.users.id -> did:coinpay:user:123
crawlproof.users.id -> did:coinpay:user:123
```
## Task lifecycle
```txt
pending -> queued -> running -> blocked -> complete | failed | cancelled
```
A task may carry `paymentIntentId`, `escrowId`, and `reputationEventId` so coordination,
payment, escrow, and reputation stay linked. Terminal statuses (`complete`, `failed`,
`cancelled`) are final.
## Surface
- DID helpers: `userDid`, `agentDid`, `makeDid`, `parseDid`
- `DidTask`, `AgentProfile`, `DelegationGrant` types
- `AgentStack` coordinator: `registerAgent`, `createTask`, `assignTask`,
`updateTaskStatus`, `delegate`, `revokeDelegation`, `listTasks`, `snapshot`, `on`
- `agentStackPlugin` — a validated LogicSRC `PluginDefinition`
## Runtime
Runtime-neutral by design — pure TypeScript, no Bun- or Node-only APIs (time is injected via
the `AgentStack` constructor). Runs on Bun, Node.js, Cloudflare Workers, and the browser,
matching the Profullstack dual-runtime standard (Bun + Node.js both first-class).
## Plugin manifest
```jsonc
{
"id": "agentstack",
"name": "AgentStack",
"type": ["agents", "tasks", "coordination"],
"capabilities": [
"agents.register", "agents.delegate",
"tasks.create", "tasks.assign", "tasks.update", "tasks.publish",
"reputation.sync", "payments.link", "escrow.link"
],
"commands": ["agents", "tasks", "delegate"],
"env": ["AGENTSTACK_API_URL", "AGENTSTACK_API_KEY", "COINPAY_API_BASE_URL"]
}
```
## Relationship to other modules
- **CoinPay plugin** — provides the DID/wallet/payment/escrow/reputation backend AgentStack
references.
- **uGig plugin** — publishes tasks to the jobs/gigs marketplace via `tasks.publish`.
- **AgentSwarm orchestration** — higher-level multi-agent orchestration can consume
AgentStack tasks and delegation grants.
See also [`openspec-comparison.md`](openspec-comparison.md) and the `agentstack` OpenSpec
capability.