@codespar/cli 0.14.1 → 0.17.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/commands/mandate-verify.js +98 -19
- package/dist/commands/mandate-verify.js.map +1 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/mandate-codec.js +31 -20
- package/dist/mandate-codec.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
|
+
});
|
|
@@ -2,7 +2,7 @@ import { defineConfig } from "vitest/config";
|
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
test: {
|
|
5
|
-
include: ["packages/*/test/**/*.test.ts", "agents/*/test/**/*.test.ts"],
|
|
5
|
+
include: ["packages/*/test/**/*.test.ts", "agents/*/test/**/*.test.ts", "test/**/*.test.ts"],
|
|
6
6
|
pool: "forks",
|
|
7
7
|
maxWorkers: 1,
|
|
8
8
|
minWorkers: 1,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# {{name}}
|
|
2
2
|
|
|
3
3
|
Scaffolded by `codespar init --template collections-agent` from the `collections-agent` starter kit
|
|
4
|
-
(https://github.com/codespar/agent-starter-kits at `
|
|
4
|
+
(https://github.com/codespar/agent-starter-kits at `8f130b7cdc30510c929e6f7ebb07184f763e6ce4`, agent 0.1.0).
|
|
5
5
|
|
|
6
6
|
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.
|
|
7
7
|
|
|
8
|
-
`@codespar/agent-core`
|
|
9
|
-
against
|
|
10
|
-
|
|
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
|
|
11
14
|
|
|
12
15
|
```
|
|
13
16
|
cp agents/collections-agent/.env.example agents/collections-agent/.env # then fill in your keys
|
|
@@ -17,4 +20,4 @@ the agent's own `package.json` pin resolves to it unchanged.
|
|
|
17
20
|
|
|
18
21
|
The agent's guide is [`agents/collections-agent/README.md`](agents/collections-agent/README.md); its commands run at this root
|
|
19
22
|
(`npm run check`, `npm run eval`, `npm test`) or inside `agents/collections-agent/`. The manifest pins
|
|
20
|
-
`cli: "@codespar/cli@0.
|
|
23
|
+
`cli: "@codespar/cli@0.14.0"`, the CLI version whose `agent run`/`eval` this agent was written for.
|
|
@@ -2,3 +2,17 @@
|
|
|
2
2
|
CODESPAR_API_KEY=csk_test_your_key_here
|
|
3
3
|
# https://console.anthropic.com. Without it, `npm start` replays the recorded happy-path.
|
|
4
4
|
ANTHROPIC_API_KEY=sk-ant-your_key_here
|
|
5
|
+
|
|
6
|
+
# --- WhatsApp, the official Cloud API backend. Commented out and empty on purpose. ---
|
|
7
|
+
# The default backend needs NONE of these: it talks to a local Cloud API emulator
|
|
8
|
+
# (`npm run whatsapp:emulator` at the repo root), with no Meta account and nothing
|
|
9
|
+
# leaving the machine. Uncomment these only if you have your own Meta Business
|
|
10
|
+
# account and want `--backend cloud-api`, which is the same code pointed at
|
|
11
|
+
# graph.facebook.com. This repo has never run one; the shapes are written from
|
|
12
|
+
# Meta's published documentation. Nothing in the tests or the CI reads them.
|
|
13
|
+
# WHATSAPP_PHONE_NUMBER_ID=
|
|
14
|
+
# WHATSAPP_ACCESS_TOKEN=
|
|
15
|
+
# WHATSAPP_VERIFY_TOKEN=
|
|
16
|
+
# WHATSAPP_APP_SECRET=
|
|
17
|
+
# WHATSAPP_API_VERSION=v21.0
|
|
18
|
+
# WHATSAPP_WEBHOOK_PORT=3111
|
|
@@ -9,11 +9,13 @@ You are editing a reference agent of the CodeSpar Agent Starter Kits. These rule
|
|
|
9
9
|
5. **`actor` on everything.** Every event, approval and receipt copy carries who acted. A record without an actor fails the CI.
|
|
10
10
|
6. **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. The sandbox payer (`POST /v1/test/charges/{id}/pay`) is test-environment only and the code never calls it with anything else.
|
|
11
11
|
7. **One receivable per instalment, one `idempotency_key` per receivable.** The key is the attempt id; a retry must return the same charge, never a second one the same debtor could pay twice. Do not touch that.
|
|
12
|
-
8. **The cycle closes on the state machine, not on prose.** `commerce.charge.paid` settles; `expired` and `cancelled` fail. By poll (`GET /v1/charges/{id}`) or by webhook (`
|
|
12
|
+
8. **The cycle closes on the state machine, not on prose.** `commerce.charge.paid` settles; `expired` and `cancelled` fail. By poll (`GET /v1/charges/{id}`) or by webhook (`packages/agent-runtime/src/webhook.ts`, `npm run webhook`), once and only once. A duplicate event never sends the debtor a second message.
|
|
13
13
|
9. **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.
|
|
14
14
|
10. **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`.
|
|
15
|
-
11. **Do not write "verifiable by a third party"** anywhere. The
|
|
16
|
-
12. **Collection has rules** (hours, secrecy of the debt, no embarrassment, LGPD). The prompt codifies them and the
|
|
17
|
-
13. **
|
|
15
|
+
11. **Do not write "verifiable by a third party"** anywhere in this agent. The Ed25519 seal a third party can check exists on a PAYMENT receipt; this agent mints receivables, and the API seals no record for a paid charge — no chain, no signature, nothing to verify. The approval artifact is HMAC with a local key.
|
|
16
|
+
12. **Collection has rules** (hours, secrecy of the debt, no embarrassment, LGPD). The prompt codifies them, the envelope enforces the hours at the gate, and the channel enforces them again on every outbound message (`packages/agent-runtime/src/channels/rules.ts`): nothing outside the collection hours, nothing to a contact other than the bound one, nothing naming another debtor's agreement, no CPF or CNPJ in a message. Do not loosen any of them, and do not add a path that sends a message without going through `channel.send`.
|
|
17
|
+
13. **A channel is the runner's, the conversations are this agent's.** `channels/whatsapp/<name>.json` names the contact, the agreement and the debtor's turns; `agent.yaml` declares the channel; `npm run check` fails if the two disagree in either direction. Never put a real phone number or a real document in one — the shipped conversation is a fixture, like `src/agreements.ts`.
|
|
18
|
+
14. **The official WhatsApp backend is never called from a test or the CI.** The credentials are absent by default and commented out in `.env.example`. What the tests drive are the pure functions (signature, webhook parse, handshake, request builder); a test that reaches Meta is a bug, not coverage.
|
|
19
|
+
15. **No telemetry.** Nothing in this repository phones home.
|
|
18
20
|
|
|
19
21
|
`AGENTS.md` and `CLAUDE.md` are the same file; the CI fails if they diverge. Edit both or neither.
|
|
@@ -9,11 +9,13 @@ You are editing a reference agent of the CodeSpar Agent Starter Kits. These rule
|
|
|
9
9
|
5. **`actor` on everything.** Every event, approval and receipt copy carries who acted. A record without an actor fails the CI.
|
|
10
10
|
6. **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. The sandbox payer (`POST /v1/test/charges/{id}/pay`) is test-environment only and the code never calls it with anything else.
|
|
11
11
|
7. **One receivable per instalment, one `idempotency_key` per receivable.** The key is the attempt id; a retry must return the same charge, never a second one the same debtor could pay twice. Do not touch that.
|
|
12
|
-
8. **The cycle closes on the state machine, not on prose.** `commerce.charge.paid` settles; `expired` and `cancelled` fail. By poll (`GET /v1/charges/{id}`) or by webhook (`
|
|
12
|
+
8. **The cycle closes on the state machine, not on prose.** `commerce.charge.paid` settles; `expired` and `cancelled` fail. By poll (`GET /v1/charges/{id}`) or by webhook (`packages/agent-runtime/src/webhook.ts`, `npm run webhook`), once and only once. A duplicate event never sends the debtor a second message.
|
|
13
13
|
9. **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.
|
|
14
14
|
10. **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`.
|
|
15
|
-
11. **Do not write "verifiable by a third party"** anywhere. The
|
|
16
|
-
12. **Collection has rules** (hours, secrecy of the debt, no embarrassment, LGPD). The prompt codifies them and the
|
|
17
|
-
13. **
|
|
15
|
+
11. **Do not write "verifiable by a third party"** anywhere in this agent. The Ed25519 seal a third party can check exists on a PAYMENT receipt; this agent mints receivables, and the API seals no record for a paid charge — no chain, no signature, nothing to verify. The approval artifact is HMAC with a local key.
|
|
16
|
+
12. **Collection has rules** (hours, secrecy of the debt, no embarrassment, LGPD). The prompt codifies them, the envelope enforces the hours at the gate, and the channel enforces them again on every outbound message (`packages/agent-runtime/src/channels/rules.ts`): nothing outside the collection hours, nothing to a contact other than the bound one, nothing naming another debtor's agreement, no CPF or CNPJ in a message. Do not loosen any of them, and do not add a path that sends a message without going through `channel.send`.
|
|
17
|
+
13. **A channel is the runner's, the conversations are this agent's.** `channels/whatsapp/<name>.json` names the contact, the agreement and the debtor's turns; `agent.yaml` declares the channel; `npm run check` fails if the two disagree in either direction. Never put a real phone number or a real document in one — the shipped conversation is a fixture, like `src/agreements.ts`.
|
|
18
|
+
14. **The official WhatsApp backend is never called from a test or the CI.** The credentials are absent by default and commented out in `.env.example`. What the tests drive are the pure functions (signature, webhook parse, handshake, request builder); a test that reaches Meta is a bug, not coverage.
|
|
19
|
+
15. **No telemetry.** Nothing in this repository phones home.
|
|
18
20
|
|
|
19
21
|
`AGENTS.md` and `CLAUDE.md` are the same file; the CI fails if they diverge. Edit both or neither.
|