@codespar/cli 0.14.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -17
- package/dist/commands/audit-replay.js +267 -0
- package/dist/commands/audit-replay.js.map +1 -0
- package/dist/commands/init.js +28 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/surface.js +4 -1
- package/dist/surface.js.map +1 -1
- package/package.json +1 -1
- package/templates/bills-agent/README.md +8 -5
- package/templates/bills-agent/agents/bills-agent/.env.example +3 -3
- package/templates/bills-agent/agents/bills-agent/AGENTS.md +1 -1
- package/templates/bills-agent/agents/bills-agent/CLAUDE.md +1 -1
- package/templates/bills-agent/agents/bills-agent/README.md +62 -22
- package/templates/bills-agent/agents/bills-agent/SYSTEM_PROMPT.md +1 -1
- package/templates/bills-agent/agents/bills-agent/agent.yaml +2 -2
- package/templates/bills-agent/agents/bills-agent/package.json +14 -11
- package/templates/bills-agent/agents/bills-agent/src/kit.ts +193 -0
- package/templates/bills-agent/agents/bills-agent/test/adversarial.test.ts +8 -7
- package/templates/bills-agent/agents/bills-agent/test/check.test.ts +19 -2
- package/templates/bills-agent/agents/bills-agent/test/cli.test.ts +72 -24
- package/templates/bills-agent/agents/bills-agent/test/fixtures/excursao-300.transcript.jsonl +2 -0
- package/templates/bills-agent/agents/bills-agent/test/fixtures/material-400.transcript.jsonl +2 -0
- package/templates/bills-agent/agents/bills-agent/test/inspect.test.ts +124 -0
- package/templates/bills-agent/agents/bills-agent/test/provider.test.ts +25 -0
- package/templates/bills-agent/agents/bills-agent/test/scenarios.test.ts +10 -9
- package/templates/bills-agent/agents/bills-agent/tsconfig.json +0 -1
- package/templates/bills-agent/package.json +5 -2
- package/templates/bills-agent/packages/agent-core/README.md +2 -0
- package/templates/bills-agent/packages/agent-core/package.json +1 -1
- package/templates/bills-agent/packages/agent-core/src/api/charge-rail.ts +27 -6
- package/templates/bills-agent/packages/agent-core/src/api/rail.ts +16 -0
- package/templates/bills-agent/packages/agent-core/src/api/sandbox-payer.ts +20 -7
- package/templates/bills-agent/packages/agent-core/src/approval.ts +16 -2
- package/templates/bills-agent/packages/agent-core/src/bundle.ts +50 -4
- package/templates/bills-agent/packages/agent-core/src/channels.ts +140 -0
- package/templates/bills-agent/packages/agent-core/src/check.ts +90 -8
- package/templates/bills-agent/packages/agent-core/src/clock.ts +42 -0
- package/templates/bills-agent/packages/agent-core/src/engine.ts +119 -18
- package/templates/bills-agent/packages/agent-core/src/hash.ts +13 -0
- package/templates/bills-agent/packages/agent-core/src/index.ts +3 -0
- package/templates/bills-agent/packages/agent-core/src/manifest.ts +1 -1
- package/templates/bills-agent/packages/agent-core/src/rail.ts +16 -2
- package/templates/bills-agent/packages/agent-core/src/receipt-verification.ts +401 -0
- package/templates/bills-agent/packages/agent-core/src/state-machine.ts +3 -1
- package/templates/bills-agent/packages/agent-core/src/stubs/charge-rail.ts +2 -0
- package/templates/bills-agent/packages/agent-core/src/stubs/rail.ts +19 -2
- package/templates/bills-agent/packages/agent-core/src/types.ts +28 -0
- package/templates/bills-agent/packages/agent-core/test/approval.test.ts +36 -2
- package/templates/bills-agent/packages/agent-core/test/bundle.test.ts +85 -0
- package/templates/bills-agent/packages/agent-core/test/clock.test.ts +25 -0
- package/templates/bills-agent/packages/agent-core/test/engine.test.ts +73 -1
- package/templates/bills-agent/packages/agent-core/test/fixtures/staging-receipt-keys.json +18 -0
- package/templates/bills-agent/packages/agent-core/test/fixtures/staging-receipt.json +24 -0
- package/templates/bills-agent/packages/agent-core/test/helpers.ts +1 -1
- package/templates/bills-agent/packages/agent-core/test/manifest.test.ts +2 -2
- package/templates/bills-agent/packages/agent-core/test/receipt-verification.test.ts +316 -0
- package/templates/bills-agent/packages/agent-core/test/receivables.test.ts +51 -0
- package/templates/bills-agent/packages/agent-runtime/README.md +68 -0
- package/templates/bills-agent/packages/agent-runtime/bin.mjs +32 -0
- package/templates/bills-agent/packages/agent-runtime/package.json +23 -0
- package/templates/bills-agent/{agents/bills-agent → packages/agent-runtime}/src/adversarial.ts +36 -44
- package/templates/bills-agent/packages/agent-runtime/src/agent.ts +68 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/contact.ts +13 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/index.ts +72 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/rules.ts +120 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/types.ts +124 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/cloud-api.ts +358 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/emulator.ts +206 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/evidence.ts +109 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/index.ts +225 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/open.ts +143 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/present.ts +47 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/run.ts +113 -0
- package/templates/bills-agent/packages/agent-runtime/src/channels/whatsapp/session.ts +113 -0
- package/templates/bills-agent/packages/agent-runtime/src/cli.ts +98 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/check.ts +15 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/decide.ts +63 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/eval.ts +58 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/inspect.ts +100 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/poll-whatsapp.ts +317 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/poll.ts +144 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/reconcile.ts +42 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/rerun.ts +86 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/resume.ts +43 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/start-whatsapp.ts +131 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/start.ts +245 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/verify.ts +129 -0
- package/templates/bills-agent/packages/agent-runtime/src/commands/webhook.ts +39 -0
- package/templates/bills-agent/packages/agent-runtime/src/default-kit.ts +83 -0
- package/templates/bills-agent/packages/agent-runtime/src/index.ts +12 -0
- package/templates/bills-agent/packages/agent-runtime/src/inspect.ts +797 -0
- package/templates/bills-agent/packages/agent-runtime/src/kit.ts +206 -0
- package/templates/{collections-agent/agents/collections-agent → bills-agent/packages/agent-runtime}/src/poll.ts +22 -11
- package/templates/{collections-agent/agents/collections-agent → bills-agent/packages/agent-runtime}/src/scenarios.ts +50 -34
- package/templates/bills-agent/{agents/bills-agent → packages/agent-runtime}/src/setup.ts +88 -66
- package/templates/bills-agent/packages/agent-runtime/src/terminal.ts +154 -0
- package/templates/{collections-agent/agents/collections-agent/channels/webhook/index.ts → bills-agent/packages/agent-runtime/src/webhook.ts} +1 -1
- package/templates/bills-agent/packages/agent-runtime/test/inspect.test.ts +336 -0
- package/templates/bills-agent/packages/agent-runtime/test/verify-cli.test.ts +127 -0
- package/templates/bills-agent/packages/agent-runtime/test/whatsapp-cloud-api.test.ts +232 -0
- package/templates/bills-agent/packages/agent-runtime/test/whatsapp-emulator.integration.test.ts +204 -0
- package/templates/bills-agent/packages/agent-runtime/test/whatsapp-evidence.test.ts +94 -0
- package/templates/bills-agent/packages/agent-runtime/test/whatsapp-rules.test.ts +174 -0
- package/templates/bills-agent/packages/agent-runtime/test/whatsapp-session.test.ts +135 -0
- package/templates/bills-agent/packages/agent-runtime/tsconfig.json +9 -0
- package/templates/bills-agent/vitest.config.ts +1 -1
- package/templates/collections-agent/README.md +8 -5
- package/templates/collections-agent/agents/collections-agent/.env.example +14 -0
- package/templates/collections-agent/agents/collections-agent/AGENTS.md +6 -4
- package/templates/collections-agent/agents/collections-agent/CLAUDE.md +6 -4
- package/templates/collections-agent/agents/collections-agent/README.md +184 -16
- package/templates/collections-agent/agents/collections-agent/agent.yaml +3 -3
- package/templates/collections-agent/agents/collections-agent/channels/whatsapp/README.md +111 -0
- package/templates/collections-agent/agents/collections-agent/channels/whatsapp/acordo-1042.json +11 -0
- package/templates/collections-agent/agents/collections-agent/channels/whatsapp/acordo-1103.json +11 -0
- package/templates/collections-agent/agents/collections-agent/channels/whatsapp/templates.json +23 -0
- package/templates/collections-agent/agents/collections-agent/package.json +12 -10
- package/templates/collections-agent/agents/collections-agent/runbook.md +52 -1
- package/templates/collections-agent/agents/collections-agent/src/kit.ts +265 -0
- package/templates/collections-agent/agents/collections-agent/test/adversarial.test.ts +9 -8
- package/templates/collections-agent/agents/collections-agent/test/check.test.ts +43 -1
- package/templates/collections-agent/agents/collections-agent/test/cli.test.ts +56 -18
- package/templates/collections-agent/agents/collections-agent/test/fixtures/agreed-1042-awaiting-payer.transcript.jsonl +4 -0
- package/templates/collections-agent/agents/collections-agent/test/scenarios.test.ts +11 -10
- package/templates/collections-agent/agents/collections-agent/test/webhook.test.ts +4 -7
- package/templates/collections-agent/agents/collections-agent/test/whatsapp-poll.test.ts +271 -0
- package/templates/collections-agent/agents/collections-agent/test/whatsapp.test.ts +213 -0
- package/templates/collections-agent/agents/collections-agent/tsconfig.json +0 -1
- package/templates/collections-agent/package.json +3 -1
- package/templates/collections-agent/packages/agent-core/README.md +2 -0
- package/templates/collections-agent/packages/agent-core/package.json +1 -1
- package/templates/collections-agent/packages/agent-core/src/api/charge-rail.ts +27 -6
- package/templates/collections-agent/packages/agent-core/src/api/rail.ts +16 -0
- package/templates/collections-agent/packages/agent-core/src/api/sandbox-payer.ts +20 -7
- package/templates/collections-agent/packages/agent-core/src/approval.ts +16 -2
- package/templates/collections-agent/packages/agent-core/src/bundle.ts +50 -4
- package/templates/collections-agent/packages/agent-core/src/channels.ts +140 -0
- package/templates/collections-agent/packages/agent-core/src/check.ts +90 -8
- package/templates/collections-agent/packages/agent-core/src/clock.ts +42 -0
- package/templates/collections-agent/packages/agent-core/src/engine.ts +119 -18
- package/templates/collections-agent/packages/agent-core/src/hash.ts +13 -0
- package/templates/collections-agent/packages/agent-core/src/index.ts +3 -0
- package/templates/collections-agent/packages/agent-core/src/manifest.ts +1 -1
- package/templates/collections-agent/packages/agent-core/src/rail.ts +16 -2
- package/templates/collections-agent/packages/agent-core/src/receipt-verification.ts +401 -0
- package/templates/collections-agent/packages/agent-core/src/state-machine.ts +3 -1
- package/templates/collections-agent/packages/agent-core/src/stubs/charge-rail.ts +2 -0
- package/templates/collections-agent/packages/agent-core/src/stubs/rail.ts +19 -2
- package/templates/collections-agent/packages/agent-core/src/types.ts +28 -0
- package/templates/collections-agent/packages/agent-core/test/approval.test.ts +36 -2
- package/templates/collections-agent/packages/agent-core/test/bundle.test.ts +85 -0
- package/templates/collections-agent/packages/agent-core/test/clock.test.ts +25 -0
- package/templates/collections-agent/packages/agent-core/test/engine.test.ts +73 -1
- package/templates/collections-agent/packages/agent-core/test/fixtures/staging-receipt-keys.json +18 -0
- package/templates/collections-agent/packages/agent-core/test/fixtures/staging-receipt.json +24 -0
- package/templates/collections-agent/packages/agent-core/test/helpers.ts +1 -1
- package/templates/collections-agent/packages/agent-core/test/manifest.test.ts +2 -2
- package/templates/collections-agent/packages/agent-core/test/receipt-verification.test.ts +316 -0
- package/templates/collections-agent/packages/agent-core/test/receivables.test.ts +51 -0
- package/templates/collections-agent/packages/agent-runtime/README.md +68 -0
- package/templates/collections-agent/packages/agent-runtime/bin.mjs +32 -0
- package/templates/collections-agent/packages/agent-runtime/package.json +23 -0
- package/templates/collections-agent/{agents/collections-agent → packages/agent-runtime}/src/adversarial.ts +29 -50
- package/templates/collections-agent/packages/agent-runtime/src/agent.ts +68 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/contact.ts +13 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/index.ts +72 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/rules.ts +120 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/types.ts +124 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/cloud-api.ts +358 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/emulator.ts +206 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/evidence.ts +109 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/index.ts +225 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/open.ts +143 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/present.ts +47 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/run.ts +113 -0
- package/templates/collections-agent/packages/agent-runtime/src/channels/whatsapp/session.ts +113 -0
- package/templates/collections-agent/packages/agent-runtime/src/cli.ts +98 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/check.ts +15 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/decide.ts +63 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/eval.ts +58 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/inspect.ts +100 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/poll-whatsapp.ts +317 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/poll.ts +144 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/reconcile.ts +42 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/rerun.ts +86 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/resume.ts +43 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/start-whatsapp.ts +131 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/start.ts +245 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/verify.ts +129 -0
- package/templates/collections-agent/packages/agent-runtime/src/commands/webhook.ts +39 -0
- package/templates/collections-agent/packages/agent-runtime/src/default-kit.ts +83 -0
- package/templates/collections-agent/packages/agent-runtime/src/index.ts +12 -0
- package/templates/collections-agent/packages/agent-runtime/src/inspect.ts +797 -0
- package/templates/collections-agent/packages/agent-runtime/src/kit.ts +206 -0
- package/templates/collections-agent/packages/agent-runtime/src/poll.ts +105 -0
- package/templates/{bills-agent/agents/bills-agent → collections-agent/packages/agent-runtime}/src/scenarios.ts +98 -26
- package/templates/collections-agent/packages/agent-runtime/src/setup.ts +229 -0
- package/templates/collections-agent/packages/agent-runtime/src/terminal.ts +154 -0
- package/templates/collections-agent/packages/agent-runtime/src/webhook.ts +131 -0
- package/templates/collections-agent/packages/agent-runtime/test/inspect.test.ts +336 -0
- package/templates/collections-agent/packages/agent-runtime/test/verify-cli.test.ts +127 -0
- package/templates/collections-agent/packages/agent-runtime/test/whatsapp-cloud-api.test.ts +232 -0
- package/templates/collections-agent/packages/agent-runtime/test/whatsapp-emulator.integration.test.ts +204 -0
- package/templates/collections-agent/packages/agent-runtime/test/whatsapp-evidence.test.ts +94 -0
- package/templates/collections-agent/packages/agent-runtime/test/whatsapp-rules.test.ts +174 -0
- package/templates/collections-agent/packages/agent-runtime/test/whatsapp-session.test.ts +135 -0
- package/templates/collections-agent/packages/agent-runtime/tsconfig.json +9 -0
- package/templates/collections-agent/vitest.config.ts +1 -1
- package/templates/hello-agent/LICENSE +21 -0
- package/templates/hello-agent/README.md +23 -0
- package/templates/hello-agent/_gitignore +10 -0
- package/templates/hello-agent/agents/hello-agent/.env.example +5 -0
- package/templates/hello-agent/agents/hello-agent/AGENTS.md +15 -0
- package/templates/hello-agent/agents/hello-agent/CLAUDE.md +15 -0
- package/templates/hello-agent/agents/hello-agent/README.md +33 -0
- package/templates/hello-agent/agents/hello-agent/SYSTEM_PROMPT.md +19 -0
- package/templates/hello-agent/agents/hello-agent/agent.yaml +19 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/beneficiary-swap.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/beneficiary-swap.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/exfiltration.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/exfiltration.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/false-authority.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/false-authority.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/fractioning.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/fractioning.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/model-total.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/model-total.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/prompt-injection.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/prompt-injection.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/evals/adversarial/webhook-replay.json +6 -0
- package/templates/hello-agent/agents/hello-agent/evals/eval.yaml +7 -0
- package/templates/hello-agent/agents/hello-agent/guardrails.json +8 -0
- package/templates/hello-agent/agents/hello-agent/mandate.example.json +17 -0
- package/templates/hello-agent/agents/hello-agent/package.json +19 -0
- package/templates/hello-agent/agents/hello-agent/runbook.md +10 -0
- package/templates/hello-agent/agents/hello-agent/scenarios/happy-path.json +6 -0
- package/templates/hello-agent/agents/hello-agent/scenarios/happy-path.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/scenarios/prompt-injection.json +6 -0
- package/templates/hello-agent/agents/hello-agent/scenarios/prompt-injection.transcript.jsonl +2 -0
- package/templates/hello-agent/agents/hello-agent/src/bills.ts +23 -0
- package/templates/hello-agent/agents/hello-agent/src/kit.ts +33 -0
- package/templates/hello-agent/agents/hello-agent/tools.json +11 -0
- package/templates/hello-agent/agents/hello-agent/tsconfig.json +9 -0
- package/templates/hello-agent/package.json +30 -0
- package/templates/hello-agent/packages/agent-core/README.md +21 -0
- package/templates/hello-agent/packages/agent-core/package.json +24 -0
- package/templates/hello-agent/packages/agent-core/src/agent.ts +125 -0
- package/templates/hello-agent/packages/agent-core/src/api/charge-rail.ts +175 -0
- package/templates/hello-agent/packages/agent-core/src/api/client.ts +53 -0
- package/templates/hello-agent/packages/agent-core/src/api/mandate-status.ts +58 -0
- package/templates/hello-agent/packages/agent-core/src/api/rail.ts +117 -0
- package/templates/hello-agent/packages/agent-core/src/api/sandbox-payer.ts +58 -0
- package/templates/hello-agent/packages/agent-core/src/approval.ts +123 -0
- package/templates/hello-agent/packages/agent-core/src/bundle.ts +159 -0
- package/templates/hello-agent/packages/agent-core/src/channels.ts +140 -0
- package/templates/hello-agent/packages/agent-core/src/check.ts +253 -0
- package/templates/hello-agent/packages/agent-core/src/clock.ts +42 -0
- package/templates/hello-agent/packages/agent-core/src/engine.ts +885 -0
- package/templates/hello-agent/packages/agent-core/src/escalate.ts +85 -0
- package/templates/hello-agent/packages/agent-core/src/events.ts +40 -0
- package/templates/hello-agent/packages/agent-core/src/guardrails.ts +45 -0
- package/templates/hello-agent/packages/agent-core/src/hash.ts +62 -0
- package/templates/hello-agent/packages/agent-core/src/ids.ts +10 -0
- package/templates/hello-agent/packages/agent-core/src/index.ts +32 -0
- package/templates/hello-agent/packages/agent-core/src/mandate.ts +100 -0
- package/templates/hello-agent/packages/agent-core/src/manifest.ts +76 -0
- package/templates/hello-agent/packages/agent-core/src/providers/anthropic.ts +76 -0
- package/templates/hello-agent/packages/agent-core/src/providers/replay.ts +63 -0
- package/templates/hello-agent/packages/agent-core/src/providers/types.ts +39 -0
- package/templates/hello-agent/packages/agent-core/src/rail.ts +101 -0
- package/templates/hello-agent/packages/agent-core/src/receipt-verification.ts +401 -0
- package/templates/hello-agent/packages/agent-core/src/revocation.ts +30 -0
- package/templates/hello-agent/packages/agent-core/src/secrets.ts +30 -0
- package/templates/hello-agent/packages/agent-core/src/state/store.ts +307 -0
- package/templates/hello-agent/packages/agent-core/src/state-machine.ts +148 -0
- package/templates/hello-agent/packages/agent-core/src/stubs/charge-rail.ts +195 -0
- package/templates/hello-agent/packages/agent-core/src/stubs/mandate-status.ts +57 -0
- package/templates/hello-agent/packages/agent-core/src/stubs/rail.ts +141 -0
- package/templates/hello-agent/packages/agent-core/src/tools.ts +55 -0
- package/templates/hello-agent/packages/agent-core/src/types.ts +134 -0
- package/templates/hello-agent/packages/agent-core/test/approval.test.ts +117 -0
- package/templates/hello-agent/packages/agent-core/test/bundle.test.ts +85 -0
- package/templates/hello-agent/packages/agent-core/test/clock.test.ts +25 -0
- package/templates/hello-agent/packages/agent-core/test/engine.test.ts +596 -0
- package/templates/hello-agent/packages/agent-core/test/escalate.test.ts +42 -0
- package/templates/hello-agent/packages/agent-core/test/fixtures/staging-receipt-keys.json +18 -0
- package/templates/hello-agent/packages/agent-core/test/fixtures/staging-receipt.json +24 -0
- package/templates/hello-agent/packages/agent-core/test/helpers.ts +139 -0
- package/templates/hello-agent/packages/agent-core/test/mandate-status.test.ts +153 -0
- package/templates/hello-agent/packages/agent-core/test/manifest.test.ts +45 -0
- package/templates/hello-agent/packages/agent-core/test/receipt-verification.test.ts +316 -0
- package/templates/hello-agent/packages/agent-core/test/receivables.test.ts +316 -0
- package/templates/hello-agent/packages/agent-core/test/secrets.test.ts +28 -0
- package/templates/hello-agent/packages/agent-core/test/state-machine.test.ts +67 -0
- package/templates/hello-agent/packages/agent-core/test/transitions.type-test.ts +59 -0
- package/templates/hello-agent/packages/agent-core/tsconfig.json +10 -0
- package/templates/hello-agent/packages/agent-runtime/README.md +68 -0
- package/templates/hello-agent/packages/agent-runtime/bin.mjs +32 -0
- package/templates/hello-agent/packages/agent-runtime/package.json +23 -0
- package/templates/hello-agent/packages/agent-runtime/src/adversarial.ts +169 -0
- package/templates/hello-agent/packages/agent-runtime/src/agent.ts +68 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/contact.ts +13 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/index.ts +72 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/rules.ts +120 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/types.ts +124 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/cloud-api.ts +358 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/emulator.ts +206 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/evidence.ts +109 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/index.ts +225 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/open.ts +143 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/present.ts +47 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/run.ts +113 -0
- package/templates/hello-agent/packages/agent-runtime/src/channels/whatsapp/session.ts +113 -0
- package/templates/hello-agent/packages/agent-runtime/src/cli.ts +98 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/check.ts +15 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/decide.ts +63 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/eval.ts +58 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/inspect.ts +100 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/poll-whatsapp.ts +317 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/poll.ts +144 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/reconcile.ts +42 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/rerun.ts +86 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/resume.ts +43 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/start-whatsapp.ts +131 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/start.ts +245 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/verify.ts +129 -0
- package/templates/hello-agent/packages/agent-runtime/src/commands/webhook.ts +39 -0
- package/templates/hello-agent/packages/agent-runtime/src/default-kit.ts +83 -0
- package/templates/hello-agent/packages/agent-runtime/src/index.ts +12 -0
- package/templates/hello-agent/packages/agent-runtime/src/inspect.ts +797 -0
- package/templates/hello-agent/packages/agent-runtime/src/kit.ts +206 -0
- package/templates/hello-agent/packages/agent-runtime/src/poll.ts +105 -0
- package/templates/hello-agent/packages/agent-runtime/src/scenarios.ts +268 -0
- package/templates/hello-agent/packages/agent-runtime/src/setup.ts +229 -0
- package/templates/hello-agent/packages/agent-runtime/src/terminal.ts +154 -0
- package/templates/hello-agent/packages/agent-runtime/src/webhook.ts +131 -0
- package/templates/hello-agent/packages/agent-runtime/test/inspect.test.ts +336 -0
- package/templates/hello-agent/packages/agent-runtime/test/verify-cli.test.ts +127 -0
- package/templates/hello-agent/packages/agent-runtime/test/whatsapp-cloud-api.test.ts +232 -0
- package/templates/hello-agent/packages/agent-runtime/test/whatsapp-emulator.integration.test.ts +204 -0
- package/templates/hello-agent/packages/agent-runtime/test/whatsapp-evidence.test.ts +94 -0
- package/templates/hello-agent/packages/agent-runtime/test/whatsapp-rules.test.ts +174 -0
- package/templates/hello-agent/packages/agent-runtime/test/whatsapp-session.test.ts +135 -0
- package/templates/hello-agent/packages/agent-runtime/tsconfig.json +9 -0
- package/templates/hello-agent/tsconfig.base.json +16 -0
- package/templates/hello-agent/vitest.config.ts +12 -0
- package/templates/kits.lock.json +60 -12
- package/templates/supplier-payments-agent/LICENSE +21 -0
- package/templates/supplier-payments-agent/README.md +23 -0
- package/templates/supplier-payments-agent/_gitignore +10 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/.env.example +7 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/AGENTS.md +21 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/CLAUDE.md +21 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/README.md +118 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/SYSTEM_PROMPT.md +29 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/agent.yaml +26 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/batch-tampering.json +12 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/batch-tampering.transcript.jsonl +3 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/beneficiary-swap-mandate.json +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/beneficiary-swap.json +10 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/beneficiary-swap.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/exfiltration.json +13 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/exfiltration.transcript.jsonl +3 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/false-authority.json +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/false-authority.transcript.jsonl +3 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/fractioning.json +15 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/fractioning.transcript.jsonl +6 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/model-total.json +10 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/model-total.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/prompt-injection.json +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/prompt-injection.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/adversarial/webhook-replay.json +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/evals/eval.yaml +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/guardrails.json +15 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/mandate.example.json +70 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/package.json +26 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/runbook.md +19 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/beneficiary-not-allowed.json +14 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/beneficiary-not-allowed.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/cap-exceeded.json +12 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/cap-exceeded.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/escalated-above-threshold.json +20 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/escalated-above-threshold.transcript.jsonl +7 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/happy-path.json +19 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/happy-path.transcript.jsonl +3 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/mandate-revoked.json +21 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/mandate-revoked.transcript.jsonl +9 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/partial-batch-failure.json +21 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/partial-batch-failure.transcript.jsonl +3 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/prompt-injection.json +12 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/scenarios/prompt-injection.transcript.jsonl +2 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/src/kit.ts +176 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/src/modules/batch-payout.ts +345 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/src/modules/pix-out.ts +118 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/src/payables.ts +76 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/test/adversarial.test.ts +53 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/test/batch.test.ts +384 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/test/check.test.ts +109 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/test/scenarios.test.ts +81 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/tools.json +53 -0
- package/templates/supplier-payments-agent/agents/supplier-payments-agent/tsconfig.json +9 -0
- package/templates/supplier-payments-agent/package.json +36 -0
- package/templates/supplier-payments-agent/packages/agent-core/README.md +21 -0
- package/templates/supplier-payments-agent/packages/agent-core/package.json +24 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/agent.ts +125 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/api/charge-rail.ts +175 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/api/client.ts +53 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/api/mandate-status.ts +58 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/api/rail.ts +117 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/api/sandbox-payer.ts +58 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/approval.ts +123 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/bundle.ts +159 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/channels.ts +140 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/check.ts +253 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/clock.ts +42 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/engine.ts +885 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/escalate.ts +85 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/events.ts +40 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/guardrails.ts +45 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/hash.ts +62 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/ids.ts +10 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/index.ts +32 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/mandate.ts +100 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/manifest.ts +76 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/providers/anthropic.ts +76 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/providers/replay.ts +63 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/providers/types.ts +39 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/rail.ts +101 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/receipt-verification.ts +401 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/revocation.ts +30 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/secrets.ts +30 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/state/store.ts +307 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/state-machine.ts +148 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/stubs/charge-rail.ts +195 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/stubs/mandate-status.ts +57 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/stubs/rail.ts +141 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/tools.ts +55 -0
- package/templates/supplier-payments-agent/packages/agent-core/src/types.ts +134 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/approval.test.ts +117 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/bundle.test.ts +85 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/clock.test.ts +25 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/engine.test.ts +596 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/escalate.test.ts +42 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/fixtures/staging-receipt-keys.json +18 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/fixtures/staging-receipt.json +24 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/helpers.ts +139 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/mandate-status.test.ts +153 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/manifest.test.ts +45 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/receipt-verification.test.ts +316 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/receivables.test.ts +316 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/secrets.test.ts +28 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/state-machine.test.ts +67 -0
- package/templates/supplier-payments-agent/packages/agent-core/test/transitions.type-test.ts +59 -0
- package/templates/supplier-payments-agent/packages/agent-core/tsconfig.json +10 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/README.md +68 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/bin.mjs +32 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/package.json +23 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/adversarial.ts +169 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/agent.ts +68 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/contact.ts +13 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/index.ts +72 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/rules.ts +120 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/types.ts +124 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/cloud-api.ts +358 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/emulator.ts +206 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/evidence.ts +109 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/index.ts +225 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/open.ts +143 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/present.ts +47 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/run.ts +113 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/channels/whatsapp/session.ts +113 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/cli.ts +98 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/check.ts +15 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/decide.ts +63 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/eval.ts +58 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/inspect.ts +100 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/poll-whatsapp.ts +317 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/poll.ts +144 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/reconcile.ts +42 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/rerun.ts +86 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/resume.ts +43 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/start-whatsapp.ts +131 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/start.ts +245 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/verify.ts +129 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/commands/webhook.ts +39 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/default-kit.ts +83 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/index.ts +12 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/inspect.ts +797 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/kit.ts +206 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/poll.ts +105 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/scenarios.ts +268 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/setup.ts +229 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/terminal.ts +154 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/src/webhook.ts +131 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/inspect.test.ts +336 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/verify-cli.test.ts +127 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/whatsapp-cloud-api.test.ts +232 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/whatsapp-emulator.integration.test.ts +204 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/whatsapp-evidence.test.ts +94 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/whatsapp-rules.test.ts +174 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/test/whatsapp-session.test.ts +135 -0
- package/templates/supplier-payments-agent/packages/agent-runtime/tsconfig.json +9 -0
- package/templates/supplier-payments-agent/tsconfig.base.json +16 -0
- package/templates/supplier-payments-agent/vitest.config.ts +12 -0
- package/templates/bills-agent/agents/bills-agent/channels/terminal/index.ts +0 -108
- package/templates/bills-agent/agents/bills-agent/src/commands/approve.ts +0 -9
- package/templates/bills-agent/agents/bills-agent/src/commands/check.ts +0 -13
- package/templates/bills-agent/agents/bills-agent/src/commands/consent.ts +0 -26
- package/templates/bills-agent/agents/bills-agent/src/commands/decide.ts +0 -45
- package/templates/bills-agent/agents/bills-agent/src/commands/deny.ts +0 -7
- package/templates/bills-agent/agents/bills-agent/src/commands/eval.ts +0 -37
- package/templates/bills-agent/agents/bills-agent/src/commands/reconcile.ts +0 -38
- package/templates/bills-agent/agents/bills-agent/src/commands/rerun.ts +0 -65
- package/templates/bills-agent/agents/bills-agent/src/commands/resume.ts +0 -30
- package/templates/bills-agent/agents/bills-agent/src/main.ts +0 -185
- package/templates/collections-agent/agents/collections-agent/channels/terminal/index.ts +0 -178
- package/templates/collections-agent/agents/collections-agent/src/commands/approve.ts +0 -10
- package/templates/collections-agent/agents/collections-agent/src/commands/check.ts +0 -13
- package/templates/collections-agent/agents/collections-agent/src/commands/decide.ts +0 -48
- package/templates/collections-agent/agents/collections-agent/src/commands/deny.ts +0 -7
- package/templates/collections-agent/agents/collections-agent/src/commands/eval.ts +0 -39
- package/templates/collections-agent/agents/collections-agent/src/commands/poll.ts +0 -35
- package/templates/collections-agent/agents/collections-agent/src/commands/reconcile.ts +0 -38
- package/templates/collections-agent/agents/collections-agent/src/commands/rerun.ts +0 -55
- package/templates/collections-agent/agents/collections-agent/src/commands/resume.ts +0 -30
- package/templates/collections-agent/agents/collections-agent/src/commands/webhook.ts +0 -36
- package/templates/collections-agent/agents/collections-agent/src/main.ts +0 -193
- package/templates/collections-agent/agents/collections-agent/src/setup.ts +0 -250
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of collecting over a conversation, tried and refused.
|
|
3
|
+
*
|
|
4
|
+
* Every case here is an ATTEMPT: the message is handed to the channel the way
|
|
5
|
+
* the runner hands it one, and what is asserted is that nothing left the
|
|
6
|
+
* process. The backend under the channel is a recorder, so "refused" is not a
|
|
7
|
+
* claim about a return value — it is the recorder having seen nothing.
|
|
8
|
+
*
|
|
9
|
+
* The last case is the one that matters most: the same attempts through a
|
|
10
|
+
* DIFFERENT backend. The rules live above the backend, so choosing one cannot
|
|
11
|
+
* be a way around them.
|
|
12
|
+
*/
|
|
13
|
+
import { describe, expect, it } from "vitest";
|
|
14
|
+
import { WhatsAppChannel } from "../src/channels/whatsapp/index.js";
|
|
15
|
+
import { checkOutbound } from "../src/channels/rules.js";
|
|
16
|
+
import type { ChannelBackend, InboundMessage, OutboundBody, SentMessage } from "../src/channels/types.js";
|
|
17
|
+
|
|
18
|
+
/** A backend that carries nothing and remembers everything it was asked to carry. */
|
|
19
|
+
class Recorder implements ChannelBackend {
|
|
20
|
+
readonly delivered: Array<{ to: string; body: OutboundBody }> = [];
|
|
21
|
+
constructor(
|
|
22
|
+
readonly name = "recorder",
|
|
23
|
+
readonly live = false,
|
|
24
|
+
private readonly inbox: InboundMessage[] = [],
|
|
25
|
+
) {}
|
|
26
|
+
async open(): Promise<void> {}
|
|
27
|
+
async next(): Promise<InboundMessage | undefined> {
|
|
28
|
+
return this.inbox.shift();
|
|
29
|
+
}
|
|
30
|
+
async deliver(to: string, body: OutboundBody): Promise<SentMessage> {
|
|
31
|
+
this.delivered.push({ to, body });
|
|
32
|
+
return { id: `rec_${this.delivered.length}`, state: "sent" };
|
|
33
|
+
}
|
|
34
|
+
async close(): Promise<void> {}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const CONTACT = "+5511987654321";
|
|
38
|
+
const INSIDE = new Date("2026-09-23T14:00:00-03:00");
|
|
39
|
+
const OUTSIDE = new Date("2026-09-23T22:30:00-03:00");
|
|
40
|
+
const HOURS = { window: "08:00-20:00", timezone: "America/Sao_Paulo" };
|
|
41
|
+
|
|
42
|
+
function channelAt(now: Date, backend = new Recorder(), openSession = true) {
|
|
43
|
+
const channel = new WhatsAppChannel({
|
|
44
|
+
backend,
|
|
45
|
+
conversation: { contact: CONTACT, subject: "acordo-1042" },
|
|
46
|
+
now: () => now,
|
|
47
|
+
hours: HOURS,
|
|
48
|
+
knownSubjects: ["acordo-1042", "acordo-1077", "acordo-1103"],
|
|
49
|
+
templates: [{ name: "cobranca_lembrete", language: "pt_BR", description: "a reminder", body: "Oi {{1}}, sobre o acordo." }],
|
|
50
|
+
});
|
|
51
|
+
// A session is open because the person wrote; the window is WhatsApp's rule, not ours, and has its own test below.
|
|
52
|
+
if (openSession) {
|
|
53
|
+
(channel as unknown as { session: { observeInbound(t: number): void } }).session.observeInbound(Math.floor(now.getTime() / 1000));
|
|
54
|
+
}
|
|
55
|
+
return { channel, backend };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe("the collection rules, tried through the channel", () => {
|
|
59
|
+
it("sends inside the collection hours", async () => {
|
|
60
|
+
const { channel, backend } = channelAt(INSIDE);
|
|
61
|
+
const sent = await channel.say("Oi, Joana! Sobre o pedido #1042.");
|
|
62
|
+
expect(sent.refused).toBeUndefined();
|
|
63
|
+
expect(backend.delivered).toHaveLength(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("refuses everything outside the collection hours, and the backend never sees it", async () => {
|
|
67
|
+
const { channel, backend } = channelAt(OUTSIDE);
|
|
68
|
+
const sent = await channel.say("Oi, Joana! Sobre o pedido #1042.");
|
|
69
|
+
expect(sent.refused?.rule).toBe("collection_hours");
|
|
70
|
+
expect(sent.state).toBe("failed");
|
|
71
|
+
expect(backend.delivered).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("refuses a message to any contact but the one the conversation is bound to", () => {
|
|
75
|
+
const refusal = checkOutbound("+5511900000000", { kind: "text", text: "sobre a sua divida" }, {
|
|
76
|
+
conversation: { contact: CONTACT, subject: "acordo-1042" },
|
|
77
|
+
hours: HOURS,
|
|
78
|
+
now: () => INSIDE,
|
|
79
|
+
});
|
|
80
|
+
expect(refusal?.rule).toBe("bound_contact");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("refuses a message that names another debtor's agreement", async () => {
|
|
84
|
+
const { channel, backend } = channelAt(INSIDE);
|
|
85
|
+
const sent = await channel.say("O acordo-1077 do Carlos tambem esta em aberto, voces podem combinar.");
|
|
86
|
+
expect(sent.refused?.rule).toBe("subject_scope");
|
|
87
|
+
expect(backend.delivered).toHaveLength(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("refuses a CPF or a CNPJ in a message, formatted or bare", async () => {
|
|
91
|
+
for (const text of ["confirma o CPF 111.444.777-35?", "o CPF do titular e 11144477735", "CNPJ 12.345.678/0001-95", "CNPJ 12345678000195"]) {
|
|
92
|
+
const { channel, backend } = channelAt(INSIDE);
|
|
93
|
+
const sent = await channel.say(text);
|
|
94
|
+
expect(sent.refused?.rule, text).toBe("no_document");
|
|
95
|
+
expect(backend.delivered).toHaveLength(0);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("does NOT read a Pix copy-and-paste or a boleto line as a document", async () => {
|
|
100
|
+
const { channel, backend } = channelAt(INSIDE);
|
|
101
|
+
const brcode = "00020126580014br.gov.bcb.pix0136stub-chg_abc5204000053039865802BR5909CODESPAR6009SAO PAULO62070503***6304STUB";
|
|
102
|
+
const bankLine = "78517596684364082005302425802108566187285620000";
|
|
103
|
+
expect((await channel.send({ kind: "instrument", instrument: "pix_copy_paste", value: brcode })).refused).toBeUndefined();
|
|
104
|
+
expect((await channel.send({ kind: "instrument", instrument: "boleto_bank_line", value: bankLine })).refused).toBeUndefined();
|
|
105
|
+
expect(backend.delivered).toHaveLength(2);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("refuses an empty message", async () => {
|
|
109
|
+
const { channel } = channelAt(INSIDE);
|
|
110
|
+
expect((await channel.say(" ")).refused?.rule).toBe("empty_message");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("masks the contact everywhere it is written down", async () => {
|
|
114
|
+
const { channel } = channelAt(INSIDE);
|
|
115
|
+
await channel.say("Oi!");
|
|
116
|
+
for (const line of channel.log()) {
|
|
117
|
+
expect(line.contact).not.toContain("987654321");
|
|
118
|
+
expect(line.contact).toContain("****");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("applies the same rules through a different backend: a backend is not a way around one", async () => {
|
|
123
|
+
const other = new Recorder("another-backend", true);
|
|
124
|
+
const { channel, backend } = channelAt(OUTSIDE, other);
|
|
125
|
+
expect((await channel.say("boa noite, sobre a sua divida")).refused?.rule).toBe("collection_hours");
|
|
126
|
+
expect((await channelAt(INSIDE, new Recorder("another-backend", true)).channel.say("CPF 11144477735")).refused?.rule).toBe("no_document");
|
|
127
|
+
expect(backend.delivered).toHaveLength(0);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe("WhatsApp's own rule: the 24-hour session window", () => {
|
|
132
|
+
it("carries a free-form message while the window is open", async () => {
|
|
133
|
+
const { channel, backend } = channelAt(INSIDE);
|
|
134
|
+
expect((await channel.say("Oi, Joana!")).refused).toBeUndefined();
|
|
135
|
+
expect(backend.delivered).toHaveLength(1);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("refuses a free-form message once the window has shut, and says what would carry", async () => {
|
|
139
|
+
const { channel, backend } = channelAt(INSIDE, new Recorder(), false);
|
|
140
|
+
const sent = await channel.say("Recebemos, acordo quitado.");
|
|
141
|
+
expect(sent.refused?.rule).toBe("session_window_closed");
|
|
142
|
+
expect(sent.refused?.detail).toContain("template");
|
|
143
|
+
expect(backend.delivered).toHaveLength(0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("carries a declared template with the window shut", async () => {
|
|
147
|
+
const { channel, backend } = channelAt(INSIDE, new Recorder(), false);
|
|
148
|
+
const sent = await channel.send({ kind: "template", template: "cobranca_lembrete", language: "pt_BR", variables: ["Joana"] });
|
|
149
|
+
expect(sent.refused).toBeUndefined();
|
|
150
|
+
expect(backend.delivered).toHaveLength(1);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("refuses a template the agent never declared: Meta only delivers the ones it approved", async () => {
|
|
154
|
+
const { channel, backend } = channelAt(INSIDE, new Recorder(), false);
|
|
155
|
+
const sent = await channel.send({ kind: "template", template: "nao_registrado", language: "pt_BR", variables: [] });
|
|
156
|
+
expect(sent.refused?.rule).toBe("template_unknown");
|
|
157
|
+
expect(backend.delivered).toHaveLength(0);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("holds a template to the house rules too: an approved template is not a way past the hours", async () => {
|
|
161
|
+
const { channel, backend } = channelAt(OUTSIDE, new Recorder(), false);
|
|
162
|
+
const sent = await channel.send({ kind: "template", template: "cobranca_lembrete", language: "pt_BR", variables: ["Joana"] });
|
|
163
|
+
expect(sent.refused?.rule).toBe("collection_hours");
|
|
164
|
+
expect(backend.delivered).toHaveLength(0);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("reopens the window when the person writes again", async () => {
|
|
168
|
+
const backend = new Recorder("recorder", false, [{ id: "in_1", from: CONTACT, text: "oi", timestamp: Math.floor(INSIDE.getTime() / 1000) }]);
|
|
169
|
+
const { channel } = channelAt(INSIDE, backend, false);
|
|
170
|
+
expect((await channel.say("antes")).refused?.rule).toBe("session_window_closed");
|
|
171
|
+
await channel.next();
|
|
172
|
+
expect((await channel.say("depois")).refused).toBeUndefined();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 24-hour window, read back and reasoned about.
|
|
3
|
+
*
|
|
4
|
+
* Two things are under test and they are the two halves of issue #25. A
|
|
5
|
+
* conversation that a later process comes back to has to know where its
|
|
6
|
+
* window stood, and the only honest source for that is the PROVIDER's
|
|
7
|
+
* timestamp in the record — not the run's own clock, which belongs to a
|
|
8
|
+
* machine WhatsApp never consulted. And a message that may only go as a
|
|
9
|
+
* template has to be held to what the agent actually declared, because a
|
|
10
|
+
* template Meta never approved is not a message, it is a 4xx.
|
|
11
|
+
*
|
|
12
|
+
* None of it needs the emulator: every refusal here happens above the
|
|
13
|
+
* backend, which is the whole claim `channels/` makes.
|
|
14
|
+
*/
|
|
15
|
+
import { describe, expect, it } from "vitest";
|
|
16
|
+
import { templateArity, type WhatsAppTemplate } from "@codespar/agent-core";
|
|
17
|
+
import { WhatsAppChannel } from "../src/channels/whatsapp/index.js";
|
|
18
|
+
import { SessionWindow, sessionStateFromChannelLog, SESSION_WINDOW_SECONDS } from "../src/channels/whatsapp/session.js";
|
|
19
|
+
import type { ChannelBackend, InboundMessage, OutboundBody, SentMessage } from "../src/channels/types.js";
|
|
20
|
+
|
|
21
|
+
class Recorder implements ChannelBackend {
|
|
22
|
+
readonly name = "recorder";
|
|
23
|
+
readonly live = false;
|
|
24
|
+
readonly delivered: OutboundBody[] = [];
|
|
25
|
+
async open(): Promise<void> {}
|
|
26
|
+
async next(): Promise<InboundMessage | undefined> {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
async deliver(_to: string, body: OutboundBody): Promise<SentMessage> {
|
|
30
|
+
this.delivered.push(body);
|
|
31
|
+
return { id: `rec_${this.delivered.length}`, state: "sent" };
|
|
32
|
+
}
|
|
33
|
+
async close(): Promise<void> {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const CONTACT = "+5511987654321";
|
|
37
|
+
const TUESDAY = new Date("2026-09-23T14:00:00-03:00");
|
|
38
|
+
const FRIDAY = new Date("2026-09-25T14:00:00-03:00");
|
|
39
|
+
const QUITADO: WhatsAppTemplate = { name: "acordo_quitado", language: "pt_BR", description: "paid", body: "Recebemos o pagamento do {{1}}." };
|
|
40
|
+
|
|
41
|
+
function channel(now: Date, lastInboundAt?: number, backend = new Recorder()) {
|
|
42
|
+
const c = new WhatsAppChannel({
|
|
43
|
+
backend,
|
|
44
|
+
conversation: { contact: CONTACT, subject: "acordo-1042" },
|
|
45
|
+
now: () => now,
|
|
46
|
+
templates: [QUITADO],
|
|
47
|
+
...(lastInboundAt !== undefined ? { session: { lastInboundAt } } : {}),
|
|
48
|
+
});
|
|
49
|
+
return { channel: c, backend };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe("where the window stood, read back from the record", () => {
|
|
53
|
+
it("takes the provider's timestamp and never the line's own `at`", () => {
|
|
54
|
+
const state = sessionStateFromChannelLog([
|
|
55
|
+
{ direction: "in", at: "2020-01-01T00:00:00.000Z", provider_timestamp: 1790182801 },
|
|
56
|
+
{ direction: "out", at: "2026-09-23T17:00:10.000Z" },
|
|
57
|
+
{ direction: "in", at: "2020-01-01T00:00:00.000Z", provider_timestamp: 1790182821 },
|
|
58
|
+
]);
|
|
59
|
+
expect(state.lastInboundAt).toBe(1790182821);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("yields nothing from a log whose inbound lines carry no provider timestamp, and the window then reads as shut", () => {
|
|
63
|
+
// A bundle written before the timestamp was recorded. Shut is the safe
|
|
64
|
+
// direction: a template is deliverable in both halves of the rule.
|
|
65
|
+
const state = sessionStateFromChannelLog([{ direction: "in", at: "2026-09-23T17:00:00.000Z", text: "oi" }]);
|
|
66
|
+
expect(state.lastInboundAt).toBeUndefined();
|
|
67
|
+
expect(new SessionWindow([], state).open(TUESDAY)).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("ignores outbound lines: the window is opened by the PERSON writing, not by us", () => {
|
|
71
|
+
expect(sessionStateFromChannelLog([{ direction: "out", provider_timestamp: 1790182801 }]).lastInboundAt).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("a conversation a later process comes back to", () => {
|
|
76
|
+
it("writes freely when the restored window is still open", async () => {
|
|
77
|
+
const { channel: c, backend } = channel(TUESDAY, Math.floor(TUESDAY.getTime() / 1000) - 3600);
|
|
78
|
+
expect(c.sessionOpen).toBe(true);
|
|
79
|
+
expect(c.sessionRemainingSeconds).toBe(SESSION_WINDOW_SECONDS - 3600);
|
|
80
|
+
const sent = await c.say("Recebemos, acordo quitado.");
|
|
81
|
+
expect(sent.refused).toBeUndefined();
|
|
82
|
+
expect(backend.delivered).toHaveLength(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("refuses free text once the restored window has shut, which is the case the poll exists for", async () => {
|
|
86
|
+
const { channel: c, backend } = channel(FRIDAY, Math.floor(TUESDAY.getTime() / 1000));
|
|
87
|
+
expect(c.sessionOpen).toBe(false);
|
|
88
|
+
const sent = await c.say("Recebemos, acordo quitado.");
|
|
89
|
+
expect(sent.refused?.rule).toBe("session_window_closed");
|
|
90
|
+
expect(backend.delivered).toHaveLength(0);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("carries the declared template in the same breath, with the language the registry holds", async () => {
|
|
94
|
+
const { channel: c, backend } = channel(FRIDAY, Math.floor(TUESDAY.getTime() / 1000));
|
|
95
|
+
const declared = c.declaredTemplate("acordo_quitado");
|
|
96
|
+
expect(declared?.language).toBe("pt_BR");
|
|
97
|
+
const sent = await c.send({ kind: "template", template: declared!.name, language: declared!.language, variables: ["acordo-1042"] });
|
|
98
|
+
expect(sent.refused).toBeUndefined();
|
|
99
|
+
expect(backend.delivered).toEqual([{ kind: "template", template: "acordo_quitado", language: "pt_BR", variables: ["acordo-1042"] }]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("reads as shut when nothing restored it: a process with no record of the conversation assumes the worst", () => {
|
|
103
|
+
expect(channel(TUESDAY).channel.sessionOpen).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe("the local registry refuses what Meta would refuse", () => {
|
|
108
|
+
it("a name the agent never declared", async () => {
|
|
109
|
+
const { channel: c, backend } = channel(FRIDAY, Math.floor(TUESDAY.getTime() / 1000));
|
|
110
|
+
const sent = await c.send({ kind: "template", template: "nao_registrado", language: "pt_BR", variables: [] });
|
|
111
|
+
expect(sent.refused?.rule).toBe("template_unknown");
|
|
112
|
+
expect(backend.delivered).toHaveLength(0);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("a language the template was not registered in: an approved template does not exist in another", async () => {
|
|
116
|
+
const { channel: c, backend } = channel(FRIDAY, Math.floor(TUESDAY.getTime() / 1000));
|
|
117
|
+
const sent = await c.send({ kind: "template", template: "acordo_quitado", language: "es_MX", variables: ["acordo-1042"] });
|
|
118
|
+
expect(sent.refused?.rule).toBe("template_language_unknown");
|
|
119
|
+
expect(backend.delivered).toHaveLength(0);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("a variable count the body has no placeholders for", async () => {
|
|
123
|
+
const { channel: c, backend } = channel(FRIDAY, Math.floor(TUESDAY.getTime() / 1000));
|
|
124
|
+
const sent = await c.send({ kind: "template", template: "acordo_quitado", language: "pt_BR", variables: ["acordo-1042", "a mais"] });
|
|
125
|
+
expect(sent.refused?.rule).toBe("template_variables_mismatch");
|
|
126
|
+
expect(sent.refused?.detail).toContain("takes 1 variable(s)");
|
|
127
|
+
expect(backend.delivered).toHaveLength(0);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("counts the placeholders the way Meta numbers them", () => {
|
|
131
|
+
expect(templateArity("nenhuma")).toBe(0);
|
|
132
|
+
expect(templateArity("Oi {{1}}, sobre o {{2}}.")).toBe(2);
|
|
133
|
+
expect(templateArity("Oi {{ 1 }}.")).toBe(1);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"exactOptionalPropertyTypes": true,
|
|
8
|
+
"noUncheckedIndexedAccess": true,
|
|
9
|
+
"noImplicitOverride": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"types": ["node"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
include: ["packages/*/test/**/*.test.ts", "agents/*/test/**/*.test.ts", "test/**/*.test.ts"],
|
|
6
|
+
pool: "forks",
|
|
7
|
+
maxWorkers: 1,
|
|
8
|
+
minWorkers: 1,
|
|
9
|
+
fileParallelism: false,
|
|
10
|
+
testTimeout: 30000,
|
|
11
|
+
},
|
|
12
|
+
});
|
package/templates/kits.lock.json
CHANGED
|
@@ -1,41 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
3
|
"kits_repo": "https://github.com/codespar/agent-starter-kits",
|
|
4
|
-
"kits_ref": "
|
|
5
|
-
"commit": "
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
"kits_ref": "8f130b7cdc30510c929e6f7ebb07184f763e6ce4",
|
|
5
|
+
"commit": "8f130b7cdc30510c929e6f7ebb07184f763e6ce4",
|
|
6
|
+
"vendored_packages": [
|
|
7
|
+
{
|
|
8
|
+
"name": "@codespar/agent-core",
|
|
9
|
+
"source": "packages/agent-core",
|
|
10
|
+
"version": "0.1.0"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "@codespar/agent-runtime",
|
|
14
|
+
"source": "packages/agent-runtime",
|
|
15
|
+
"version": "0.1.0"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
10
18
|
"templates": {
|
|
11
19
|
"bills-agent": {
|
|
12
20
|
"source": "agents/bills-agent",
|
|
13
21
|
"description": "The consumer delegates the month's bills to an agent that pays under a signed mandate: per-payment cap, monthly cap, named payees, expiry. Every payment returns a receipt.",
|
|
14
22
|
"version": "0.1.0",
|
|
15
|
-
"cli": "@codespar/cli@0.
|
|
23
|
+
"cli": "@codespar/cli@0.14.0",
|
|
16
24
|
"mcp": "@codespar/mcp@0.5.8",
|
|
17
|
-
"
|
|
25
|
+
"vendored": {
|
|
26
|
+
"@codespar/agent-core": "0.1.0",
|
|
27
|
+
"@codespar/agent-runtime": "0.1.0"
|
|
28
|
+
},
|
|
18
29
|
"next_steps": [
|
|
19
30
|
"cp agents/bills-agent/.env.example agents/bills-agent/.env # then fill in your keys",
|
|
20
31
|
"npm install",
|
|
21
32
|
"npm run consent -- --yes",
|
|
22
33
|
"npm start"
|
|
23
34
|
],
|
|
24
|
-
"hash": "sha256:
|
|
35
|
+
"hash": "sha256:e75c5293ae7d576fa5263b9f7bc8accbd4b83d781a5220f4bbc4368f8746abc3"
|
|
25
36
|
},
|
|
26
37
|
"collections-agent": {
|
|
27
38
|
"source": "agents/collections-agent",
|
|
28
39
|
"description": "The merchant's agent that collects: agrees terms with the payer inside a negotiation envelope, issues one bolepix per instalment with an idempotency key, presents the QR and the copy-and-paste in the conversation, and closes the cycle on commerce.charge.paid or commerce.charge.expired.",
|
|
29
40
|
"version": "0.1.0",
|
|
30
|
-
"cli": "@codespar/cli@0.
|
|
41
|
+
"cli": "@codespar/cli@0.14.0",
|
|
31
42
|
"mcp": "@codespar/mcp@0.5.8",
|
|
32
|
-
"
|
|
43
|
+
"vendored": {
|
|
44
|
+
"@codespar/agent-core": "0.1.0",
|
|
45
|
+
"@codespar/agent-runtime": "0.1.0"
|
|
46
|
+
},
|
|
33
47
|
"next_steps": [
|
|
34
48
|
"cp agents/collections-agent/.env.example agents/collections-agent/.env # then fill in your keys",
|
|
35
49
|
"npm install",
|
|
36
50
|
"npm start"
|
|
37
51
|
],
|
|
38
|
-
"hash": "sha256:
|
|
52
|
+
"hash": "sha256:0588aa52d737058375f5a617844071998a5db3147bddd73447577f756cd11c10"
|
|
53
|
+
},
|
|
54
|
+
"hello-agent": {
|
|
55
|
+
"source": "agents/hello-agent",
|
|
56
|
+
"description": "The worked example of the codespar-agent-builder skill: a read-only agent that reads the month's bills and cannot pay. Built from the five files, the packs and one kit module.",
|
|
57
|
+
"version": "0.1.0",
|
|
58
|
+
"cli": "@codespar/cli@0.14.0",
|
|
59
|
+
"mcp": "@codespar/mcp@0.5.8",
|
|
60
|
+
"vendored": {
|
|
61
|
+
"@codespar/agent-core": "0.1.0",
|
|
62
|
+
"@codespar/agent-runtime": "0.1.0"
|
|
63
|
+
},
|
|
64
|
+
"next_steps": [
|
|
65
|
+
"cp agents/hello-agent/.env.example agents/hello-agent/.env # then fill in your keys",
|
|
66
|
+
"npm install",
|
|
67
|
+
"npm start"
|
|
68
|
+
],
|
|
69
|
+
"hash": "sha256:f75d8ddb2d1808e337e7c785a3801bbce127a6822de9b761f5c57c28ce1848b9"
|
|
70
|
+
},
|
|
71
|
+
"supplier-payments-agent": {
|
|
72
|
+
"source": "agents/supplier-payments-agent",
|
|
73
|
+
"description": "A company delegates its suppliers, commissions and payroll to an agent that pays them in batches under one signed mandate. A batch is a loop of executions: one refusal does not stop the others, and re-running it pays nobody twice.",
|
|
74
|
+
"version": "0.1.0",
|
|
75
|
+
"cli": "@codespar/cli@0.14.0",
|
|
76
|
+
"mcp": "@codespar/mcp@0.5.8",
|
|
77
|
+
"vendored": {
|
|
78
|
+
"@codespar/agent-core": "0.1.0",
|
|
79
|
+
"@codespar/agent-runtime": "0.1.0"
|
|
80
|
+
},
|
|
81
|
+
"next_steps": [
|
|
82
|
+
"cp agents/supplier-payments-agent/.env.example agents/supplier-payments-agent/.env # then fill in your keys",
|
|
83
|
+
"npm install",
|
|
84
|
+
"npm start"
|
|
85
|
+
],
|
|
86
|
+
"hash": "sha256:a89cb114242eb0f5e3114801341dbf90ea54e7665f73d24bb68a9fdf452b2753"
|
|
39
87
|
}
|
|
40
88
|
}
|
|
41
89
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 codespar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
Scaffolded by `codespar init --template supplier-payments-agent` from the `supplier-payments-agent` starter kit
|
|
4
|
+
(https://github.com/codespar/agent-starter-kits at `8f130b7cdc30510c929e6f7ebb07184f763e6ce4`, agent 0.1.0).
|
|
5
|
+
|
|
6
|
+
A company delegates its suppliers, commissions and payroll to an agent that pays them in batches under one signed mandate. A batch is a loop of executions: one refusal does not stop the others, and re-running it pays nobody twice.
|
|
7
|
+
|
|
8
|
+
`@codespar/agent-core` and `@codespar/agent-runtime` are not published on npm, so the copies this agent was built
|
|
9
|
+
against are vendored here and linked as npm workspaces; the agent's own
|
|
10
|
+
`package.json` pins resolve to them unchanged:
|
|
11
|
+
|
|
12
|
+
- `packages/agent-core/` — @codespar/agent-core 0.1.0
|
|
13
|
+
- `packages/agent-runtime/` — @codespar/agent-runtime 0.1.0
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
cp agents/supplier-payments-agent/.env.example agents/supplier-payments-agent/.env # then fill in your keys
|
|
17
|
+
npm install
|
|
18
|
+
npm start
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The agent's guide is [`agents/supplier-payments-agent/README.md`](agents/supplier-payments-agent/README.md); its commands run at this root
|
|
22
|
+
(`npm run check`, `npm run eval`, `npm test`) or inside `agents/supplier-payments-agent/`. The manifest pins
|
|
23
|
+
`cli: "@codespar/cli@0.14.0"`, the CLI version whose `agent run`/`eval` this agent was written for.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Copy to agents/supplier-payments-agent/.env. `npm install` runs at the repository ROOT (npm workspace), then `npm start`.
|
|
2
|
+
# Test key from https://dashboard.codespar.dev (starts with csk_test_). A live key is refused.
|
|
3
|
+
CODESPAR_API_KEY=csk_test_your_key_here
|
|
4
|
+
# https://console.anthropic.com. Leave empty to replay the recorded happy path (the old placeholder sk-ant-your_key_here also counts as empty).
|
|
5
|
+
ANTHROPIC_API_KEY=
|
|
6
|
+
# Staging only (docs/OPEN_QUESTIONS.md, item 12): a staging test key also needs the staging base URL. A production key needs nothing here.
|
|
7
|
+
# CODESPAR_API_URL=https://api.staging.codespar.dev
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Rules for the coding agent working on supplier-payments-agent
|
|
2
|
+
|
|
3
|
+
You are editing a reference agent of the CodeSpar Agent Starter Kits. These rules keep it a reference.
|
|
4
|
+
|
|
5
|
+
1. **Read `agent.yaml` before editing anything.** It is the index. `SYSTEM_PROMPT.md`, `tools.json`, `guardrails.json` and `mandate.example.json` must agree with it, and `npm run check` fails when they do not.
|
|
6
|
+
2. **A batch is a loop of executions, one per line.** Never fold a batch back into one multi-item execution to "save a round trip". Not because the core would strand the siblings — it no longer does — but because a payroll line has to be approvable, refusable and re-runnable ALONE: one execution of 200 items is one all-or-nothing decision, and one wrong key sends the whole list back through approval. `src/modules/batch-payout.ts` and `docs/OPEN_QUESTIONS.md` § 40 say why; read them before changing the loop.
|
|
7
|
+
3. **The loop `continue`s, it never breaks.** Every exit from one line — a refusal, a claim already held, a malformed line — is a fact about that line only. A change that lets one line throw past the loop is the bug this agent exists to not have.
|
|
8
|
+
4. **The claim is the thing that stops a double payment.** `engine.claim`/`claimed` pairs a batch line with the execution that covers it, and it is taken BEFORE the channel can run the execution. Claiming afterwards would leave a settled payout unclaimed on a crash, which is the double payment. Only a claim whose execution ended without moving money (`denied`, `expired`, `failed`) is retried.
|
|
9
|
+
5. **The set is bound, and the binding is not decoration.** The list is hashed ONCE, before any line is drafted, and every artifact of the batch carries that `batch_hash` with the line's `index` and the list's `count`. Hash with `batchHash` from the core — it is `itemsHash` over the ordered list; do not write a second canonicalisation — and resolve with `engine.preview`, which does not throw, so a line the core would refuse still occupies its position. A run whose list differs from the one some line of that ref was approved under is refused BEFORE it drafts anything: the surviving lines would each answer `already_settled` and nothing per-line would notice.
|
|
10
|
+
6. **The lines of a batch are the company's, not the model's.** `codespar_pay` refuses `batch_ref` together with `items` or `total_minor`. Do not "helpfully" merge them: that refusal is what makes a batch un-fractionable.
|
|
11
|
+
7. **Do not widen `tools.json` or the mandate without asking.** The tool list is closed on purpose; the mandate's caps and payees are the company's. Adding a tool or a payee is a product decision, not a refactor.
|
|
12
|
+
8. **The model proposes, the code executes.** Nothing you write may let a model output reach `executing` without going through `ExecutionEngine` in `@codespar/agent-core`. If you need a new check, add it to the core or to a `policyExtension`, never to the prompt.
|
|
13
|
+
9. **`escalate_above` only tightens.** A trigger may send an execution to a human; it may never raise a cap or add a payee.
|
|
14
|
+
10. **`actor` on everything.** Every event, approval and receipt copy carries who acted. A receipt without an actor fails the CI.
|
|
15
|
+
11. **Sandbox by construction.** Only `csk_test_` keys. Never commit `.env`, `.codespar/` or `runs/`. The pre-commit secret scan and the CI both refuse a key-shaped string.
|
|
16
|
+
12. **Before you say a task is done:** `npm run check`, `npm run eval` (adversarial suite plus scenarios, on the replay provider, no model needed) and `npm test` at the repository root. All green, or it is not done.
|
|
17
|
+
13. **Use the CodeSpar MCP and skills** (`@codespar/mcp@0.5.8`, pinned in `agent.yaml`) to learn the real API. When the spec in `docs/spec-v5.1.1.md` and the API diverge, follow the API and log it in `docs/OPEN_QUESTIONS.md`.
|
|
18
|
+
14. **Say which signature you mean.** A receipt sealed since the API added Ed25519 carries a signature anybody can check against the published key set, with no credential — that is what `npm run verify -- <receipt-file>` does. "Verifiable by a third party" is true of THAT and of nothing else here: a receipt sealed before the change carries no Ed25519 signature and never will, and the approval artifact is still HMAC with a local development key. Write the phrase only where `Ed25519` is written too; `npm run check` fails otherwise.
|
|
19
|
+
15. **No telemetry.** Nothing in this repository phones home.
|
|
20
|
+
|
|
21
|
+
`AGENTS.md` and `CLAUDE.md` are the same file; the CI fails if they diverge. Edit both or neither.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Rules for the coding agent working on supplier-payments-agent
|
|
2
|
+
|
|
3
|
+
You are editing a reference agent of the CodeSpar Agent Starter Kits. These rules keep it a reference.
|
|
4
|
+
|
|
5
|
+
1. **Read `agent.yaml` before editing anything.** It is the index. `SYSTEM_PROMPT.md`, `tools.json`, `guardrails.json` and `mandate.example.json` must agree with it, and `npm run check` fails when they do not.
|
|
6
|
+
2. **A batch is a loop of executions, one per line.** Never fold a batch back into one multi-item execution to "save a round trip". Not because the core would strand the siblings — it no longer does — but because a payroll line has to be approvable, refusable and re-runnable ALONE: one execution of 200 items is one all-or-nothing decision, and one wrong key sends the whole list back through approval. `src/modules/batch-payout.ts` and `docs/OPEN_QUESTIONS.md` § 40 say why; read them before changing the loop.
|
|
7
|
+
3. **The loop `continue`s, it never breaks.** Every exit from one line — a refusal, a claim already held, a malformed line — is a fact about that line only. A change that lets one line throw past the loop is the bug this agent exists to not have.
|
|
8
|
+
4. **The claim is the thing that stops a double payment.** `engine.claim`/`claimed` pairs a batch line with the execution that covers it, and it is taken BEFORE the channel can run the execution. Claiming afterwards would leave a settled payout unclaimed on a crash, which is the double payment. Only a claim whose execution ended without moving money (`denied`, `expired`, `failed`) is retried.
|
|
9
|
+
5. **The set is bound, and the binding is not decoration.** The list is hashed ONCE, before any line is drafted, and every artifact of the batch carries that `batch_hash` with the line's `index` and the list's `count`. Hash with `batchHash` from the core — it is `itemsHash` over the ordered list; do not write a second canonicalisation — and resolve with `engine.preview`, which does not throw, so a line the core would refuse still occupies its position. A run whose list differs from the one some line of that ref was approved under is refused BEFORE it drafts anything: the surviving lines would each answer `already_settled` and nothing per-line would notice.
|
|
10
|
+
6. **The lines of a batch are the company's, not the model's.** `codespar_pay` refuses `batch_ref` together with `items` or `total_minor`. Do not "helpfully" merge them: that refusal is what makes a batch un-fractionable.
|
|
11
|
+
7. **Do not widen `tools.json` or the mandate without asking.** The tool list is closed on purpose; the mandate's caps and payees are the company's. Adding a tool or a payee is a product decision, not a refactor.
|
|
12
|
+
8. **The model proposes, the code executes.** Nothing you write may let a model output reach `executing` without going through `ExecutionEngine` in `@codespar/agent-core`. If you need a new check, add it to the core or to a `policyExtension`, never to the prompt.
|
|
13
|
+
9. **`escalate_above` only tightens.** A trigger may send an execution to a human; it may never raise a cap or add a payee.
|
|
14
|
+
10. **`actor` on everything.** Every event, approval and receipt copy carries who acted. A receipt without an actor fails the CI.
|
|
15
|
+
11. **Sandbox by construction.** Only `csk_test_` keys. Never commit `.env`, `.codespar/` or `runs/`. The pre-commit secret scan and the CI both refuse a key-shaped string.
|
|
16
|
+
12. **Before you say a task is done:** `npm run check`, `npm run eval` (adversarial suite plus scenarios, on the replay provider, no model needed) and `npm test` at the repository root. All green, or it is not done.
|
|
17
|
+
13. **Use the CodeSpar MCP and skills** (`@codespar/mcp@0.5.8`, pinned in `agent.yaml`) to learn the real API. When the spec in `docs/spec-v5.1.1.md` and the API diverge, follow the API and log it in `docs/OPEN_QUESTIONS.md`.
|
|
18
|
+
14. **Say which signature you mean.** A receipt sealed since the API added Ed25519 carries a signature anybody can check against the published key set, with no credential — that is what `npm run verify -- <receipt-file>` does. "Verifiable by a third party" is true of THAT and of nothing else here: a receipt sealed before the change carries no Ed25519 signature and never will, and the approval artifact is still HMAC with a local development key. Write the phrase only where `Ed25519` is written too; `npm run check` fails otherwise.
|
|
19
|
+
15. **No telemetry.** Nothing in this repository phones home.
|
|
20
|
+
|
|
21
|
+
`AGENTS.md` and `CLAUDE.md` are the same file; the CI fails if they diverge. Edit both or neither.
|