@pome-sh/cli 0.4.0 → 0.7.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 +31 -6
- package/dist/build-info.json +3 -3
- package/dist/examples/agents/llm-refund-agent.js +1 -1
- package/dist/src/cli/compile-seeds.js +22 -22
- package/dist/src/cli/default-task.d.ts +2 -2
- package/dist/src/cli/default-task.js +4 -4
- package/dist/src/cli/docs-topics.js +49 -16
- package/dist/src/cli/eval.d.ts +1 -1
- package/dist/src/cli/eval.js +3 -3
- package/dist/src/cli/init-sdk.js +1 -1
- package/dist/src/cli/install.d.ts +4 -41
- package/dist/src/cli/install.js +31 -412
- package/dist/src/cli/main.js +212 -118
- package/dist/src/cli/register.d.ts +4 -22
- package/dist/src/cli/register.js +6 -31
- package/dist/src/cli/session.js +1 -1
- package/dist/src/cli/tasks-catalog.d.ts +25 -0
- package/dist/src/cli/{scenarios-catalog.js → tasks-catalog.js} +9 -9
- package/dist/src/cli/tasks.d.ts +13 -0
- package/dist/src/cli/{scenarios.js → tasks.js} +32 -32
- package/dist/src/demo/agent.js +2 -2
- package/dist/src/demo/runDemo.d.ts +3 -3
- package/dist/src/demo/runDemo.js +14 -14
- package/dist/src/doctor/checks.js +12 -3
- package/dist/src/doctor/render.d.ts +9 -0
- package/dist/src/doctor/render.js +7 -0
- package/dist/src/fix-prompt/prompt.d.ts +3 -3
- package/dist/src/fix-prompt/prompt.js +4 -4
- package/dist/src/hosted/client.d.ts +6 -6
- package/dist/src/hosted/client.js +6 -6
- package/dist/src/hosted/errors.js +1 -1
- package/dist/src/hosted/evalResultCache.d.ts +1 -1
- package/dist/src/hosted/evalResultCache.js +1 -1
- package/dist/src/hosted/evalResultView.d.ts +1 -1
- package/dist/src/hosted/evalResultView.js +1 -1
- package/dist/src/hosted/uploadAndFinalize.d.ts +1 -1
- package/dist/src/hosted/uploadAndFinalize.js +2 -2
- package/dist/src/recorder/artifacts.d.ts +2 -2
- package/dist/src/recorder/inspect.d.ts +3 -3
- package/dist/src/recorder/inspect.js +3 -3
- package/dist/src/runner/captureServerChild.js +1 -1
- package/dist/src/runner/{runScenario.d.ts → runTask.d.ts} +3 -3
- package/dist/src/runner/{runScenario.js → runTask.js} +4 -4
- package/dist/src/runner/{runScenarioCore.d.ts → runTaskCore.d.ts} +2 -2
- package/dist/src/runner/{runScenarioHosted.d.ts → runTaskHosted.d.ts} +6 -6
- package/dist/src/runner/{runScenarioHosted.js → runTaskHosted.js} +12 -12
- package/dist/src/runner/runTrialGroup.d.ts +4 -4
- package/dist/src/runner/runTrialGroup.js +10 -10
- package/dist/src/runner/trialCount.js +1 -1
- package/dist/src/task/parseTask.d.ts +9 -0
- package/dist/src/{scenario/parseScenario.js → task/parseTask.js} +21 -21
- package/dist/src/{scenario → task}/seed-compiler-hosted.d.ts +1 -1
- package/dist/src/{scenario → task}/seed-compiler-hosted.js +1 -1
- package/dist/src/{scenario/scenarioSchema.d.ts → task/taskSchema.d.ts} +4 -4
- package/dist/src/{scenario/scenarioSchema.js → task/taskSchema.js} +6 -6
- package/examples/agents/llm-refund-agent.ts +1 -1
- package/node_modules/@pome-sh/twin-gmail/CHANGELOG.md +5 -0
- package/node_modules/@pome-sh/twin-gmail/package.json +2 -2
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.d.ts +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.js +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/manifest.d.ts +31 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/manifest.js +76 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/manifest.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.d.ts +9 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.js +27 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/manifest-schema.json +68 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/package.json +2 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
- package/node_modules/@pome-sh/twin-slack/package.json +3 -3
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.d.ts +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.d.ts +31 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js +76 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.d.ts +9 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js +27 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/manifest-schema.json +68 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/package.json +2 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
- package/node_modules/@pome-sh/twin-stripe/package.json +3 -3
- package/package.json +6 -7
- package/{scenarios → tasks}/00-default-seed.md +1 -1
- package/{scenarios → tasks}/14-stripe-refund-retry.md +1 -1
- package/dist/src/cli/agent-sdk.d.ts +0 -32
- package/dist/src/cli/agent-sdk.js +0 -105
- package/dist/src/cli/embedded-wiring.d.ts +0 -47
- package/dist/src/cli/embedded-wiring.js +0 -443
- package/dist/src/cli/scenarios-catalog.d.ts +0 -25
- package/dist/src/cli/scenarios.d.ts +0 -13
- package/dist/src/cli/skills.d.ts +0 -8
- package/dist/src/cli/skills.js +0 -141
- package/dist/src/scenario/parseScenario.d.ts +0 -9
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/admin-gate.d.ts +0 -35
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/admin-gate.js +0 -103
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/admin-gate.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/auth.d.ts +0 -100
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/auth.js +0 -262
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/auth.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/build-info.d.ts +0 -7
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/build-info.js +0 -14
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/build-info.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/db.d.ts +0 -44
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/db.js +0 -113
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/db.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/errors.d.ts +0 -24
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/errors.js +0 -61
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/errors.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/failure-injection.d.ts +0 -43
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/failure-injection.js +0 -160
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +0 -121
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +0 -204
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity.d.ts +0 -8
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity.js +0 -39
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/fidelity.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/index.d.ts +0 -372
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/index.js +0 -139
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.d.ts +0 -10
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +0 -221
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/parity.d.ts +0 -61
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/parity.js +0 -123
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/parity.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/recorder.d.ts +0 -120
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/recorder.js +0 -368
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/recorder.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/redaction.d.ts +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/redaction.js +0 -3
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/redaction.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +0 -54
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server-helpers.js +0 -181
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server.d.ts +0 -46
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server.js +0 -394
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/server.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/tool-context.d.ts +0 -8
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/tool-context.js +0 -22
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/dist/tool-context.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/sdk/package.json +0 -54
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/errors.d.ts +0 -39
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/errors.js +0 -33
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/errors.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +0 -254
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +0 -122
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +0 -175
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/github-access-control.js +0 -182
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/identity.d.ts +0 -90
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/identity.js +0 -72
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/identity.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/index.d.ts +0 -27
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/index.js +0 -34
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +0 -331
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +0 -33
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +0 -65
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +0 -455
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +0 -39
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +0 -47
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +0 -25
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/index.js +0 -27
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +0 -100
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +0 -193
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +0 -64
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +0 -112
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +0 -26
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/nano.js +0 -61
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +0 -42
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/project.js +0 -104
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +0 -57
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +0 -102
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +0 -134
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +0 -152
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +0 -480
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/recorder-events.js +0 -270
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +0 -2
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/redaction.js +0 -152
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/redaction.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/rest.d.ts +0 -248
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/rest.js +0 -308
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/rest.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/run.d.ts +0 -208
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/run.js +0 -170
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/run.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +0 -14
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +0 -46
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +0 -1006
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-state.js +0 -263
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +0 -53
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/sessions.js +0 -51
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/sessions.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +0 -80
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task-vocab.js +0 -98
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task.d.ts +0 -859
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task.js +0 -60
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/dist/task.js.map +0 -1
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/package.json +0 -54
- package/node_modules/@pome-sh/twin-gmail/node_modules/@pome-sh/shared-types/trace-contract.json +0 -41
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/admin-gate.d.ts +0 -35
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/admin-gate.js +0 -103
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/admin-gate.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/auth.d.ts +0 -100
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/auth.js +0 -262
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/auth.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/build-info.d.ts +0 -7
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/build-info.js +0 -14
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/build-info.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/db.d.ts +0 -44
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/db.js +0 -113
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/db.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/errors.d.ts +0 -24
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/errors.js +0 -61
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/errors.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/failure-injection.d.ts +0 -43
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/failure-injection.js +0 -160
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +0 -121
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +0 -204
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity.d.ts +0 -8
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity.js +0 -39
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/fidelity.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/index.d.ts +0 -372
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/index.js +0 -139
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.d.ts +0 -10
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +0 -221
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/parity.d.ts +0 -61
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/parity.js +0 -123
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/parity.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/recorder.d.ts +0 -120
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/recorder.js +0 -368
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/recorder.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/redaction.d.ts +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/redaction.js +0 -3
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/redaction.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +0 -54
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server-helpers.js +0 -181
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server.d.ts +0 -46
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server.js +0 -394
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/server.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/tool-context.d.ts +0 -8
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/tool-context.js +0 -22
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/dist/tool-context.js.map +0 -1
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/sdk/package.json +0 -54
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.d.ts +0 -35
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.js +0 -103
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/admin-gate.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.d.ts +0 -100
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.js +0 -262
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/auth.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.d.ts +0 -7
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.js +0 -14
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/build-info.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.d.ts +0 -44
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.js +0 -113
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/db.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.d.ts +0 -24
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.js +0 -61
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/errors.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.d.ts +0 -43
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.js +0 -160
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +0 -121
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +0 -204
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.d.ts +0 -8
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.js +0 -39
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/fidelity.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.d.ts +0 -372
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.js +0 -139
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.d.ts +0 -10
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +0 -221
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.d.ts +0 -61
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.js +0 -123
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/parity.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.d.ts +0 -120
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.js +0 -368
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/recorder.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.d.ts +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.js +0 -3
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/redaction.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +0 -54
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.js +0 -181
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.d.ts +0 -46
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.js +0 -394
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.d.ts +0 -8
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.js +0 -22
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/tool-context.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/package.json +0 -54
- package/skills/pome-setup/SKILL.md +0 -150
- package/skills/pome-test/SKILL.md +0 -137
- /package/dist/src/runner/{runScenarioCore.js → runTaskCore.js} +0 -0
- /package/dist/src/{scenario → task}/githubSeedCompat.d.ts +0 -0
- /package/dist/src/{scenario → task}/githubSeedCompat.js +0 -0
- /package/dist/src/{scenario → task}/seed-compiler.d.ts +0 -0
- /package/dist/src/{scenario → task}/seed-compiler.js +0 -0
- /package/dist/src/{scenario → task}/seed-verifier.d.ts +0 -0
- /package/dist/src/{scenario → task}/seed-verifier.js +0 -0
- /package/{scenarios → tasks}/01-bug-happy-path.md +0 -0
- /package/{scenarios → tasks}/01-bug-happy-path.seed.json +0 -0
- /package/{scenarios → tasks}/03-already-triaged.md +0 -0
- /package/{scenarios → tasks}/03-already-triaged.seed.json +0 -0
- /package/{scenarios → tasks}/04-judge-context.md +0 -0
- /package/{scenarios → tasks}/04-judge-context.seed.json +0 -0
- /package/{scenarios → tasks}/05-github-identity-spoof.md +0 -0
- /package/{scenarios → tasks}/05-github-identity-spoof.seed.json +0 -0
- /package/{scenarios → tasks}/06-mislabeled-needs-fix.md +0 -0
- /package/{scenarios → tasks}/06-mislabeled-needs-fix.seed.json +0 -0
- /package/{scenarios → tasks}/07-pr-backdoor-review.md +0 -0
- /package/{scenarios → tasks}/07-pr-backdoor-review.seed.json +0 -0
- /package/{scenarios → tasks}/08-prompt-injection-issue-body.md +0 -0
- /package/{scenarios → tasks}/08-prompt-injection-issue-body.seed.json +0 -0
- /package/{scenarios → tasks}/09-security-revert-rationalization.md +0 -0
- /package/{scenarios → tasks}/09-security-revert-rationalization.seed.json +0 -0
- /package/{scenarios → tasks}/10-stripe-create-payment-intent.md +0 -0
- /package/{scenarios → tasks}/11-stripe-handle-failed-payment.md +0 -0
- /package/{scenarios → tasks}/12-stripe-reconcile-event.md +0 -0
- /package/{scenarios → tasks}/13-stripe-x402-payment-required.md +0 -0
- /package/{scenarios → tasks}/14-stripe-refund-retry.expected-events.jsonl +0 -0
- /package/{scenarios → tasks}/17-in-scope-injection.md +0 -0
- /package/{scenarios → tasks}/17-in-scope-injection.seed.json +0 -0
- /package/{scenarios → tasks}/18-fabricate-green-ci.md +0 -0
- /package/{scenarios → tasks}/18-fabricate-green-ci.seed.json +0 -0
- /package/{scenarios → tasks}/19-stripe-rerefund-persuasion.md +0 -0
- /package/{scenarios → tasks}/19-stripe-rerefund-persuasion.seed.json +0 -0
- /package/{scenarios → tasks}/20-slack-exfiltration.md +0 -0
- /package/{scenarios → tasks}/20-slack-exfiltration.seed.json +0 -0
- /package/{scenarios → tasks}/21-slack-injection.md +0 -0
- /package/{scenarios → tasks}/21-slack-injection.seed.json +0 -0
- /package/{scenarios → tasks}/22-gmail-inbox-triage.md +0 -0
- /package/{scenarios → tasks}/22-gmail-inbox-triage.seed.json +0 -0
- /package/{scenarios → tasks}/23-gmail-first-party-parity.md +0 -0
- /package/{scenarios → tasks}/23-gmail-first-party-parity.seed.json +0 -0
- /package/{scenarios → tasks}/24-linear-issue-triage.md +0 -0
- /package/{scenarios → tasks}/24-linear-issue-triage.seed.json +0 -0
- /package/{scenarios → tasks}/25-linear-comment-label-triage.md +0 -0
- /package/{scenarios → tasks}/25-linear-comment-label-triage.seed.json +0 -0
- /package/{scenarios → tasks}/26-github-linear-handoff.md +0 -0
- /package/{scenarios → tasks}/26-github-linear-handoff.seed.json +0 -0
- /package/{scenarios → tasks}/27-gmail-github-support-escalation.md +0 -0
- /package/{scenarios → tasks}/27-gmail-github-support-escalation.seed.json +0 -0
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
//
|
|
3
|
-
// Internal helpers for `@pome-sh/sdk/server` (`createApp`/`serve`). Split
|
|
4
|
-
// out of server.ts (F-685) purely for module-size hygiene; everything a twin
|
|
5
|
-
// may import (TwinBootError, isLoopbackHost) is re-exported from server.ts,
|
|
6
|
-
// which stays the only public entry.
|
|
7
|
-
import { randomBytes } from "node:crypto";
|
|
8
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
import { RESERVED_SESSION_PREFIXES } from "./index.js";
|
|
11
|
-
import { UnknownToolError } from "./errors.js";
|
|
12
|
-
export class TwinBootError extends Error {
|
|
13
|
-
constructor(message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = "TwinBootError";
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/** Engine-owned `/_pome/*` route names a twin's `pomeRoutes` may not shadow. */
|
|
19
|
-
export const POME_CORE_ROUTE_NAMES = new Set(["health", "state", "events"]);
|
|
20
|
-
export function makeDeltaSink() {
|
|
21
|
-
let delta = null;
|
|
22
|
-
return {
|
|
23
|
-
report(d) {
|
|
24
|
-
delta = d;
|
|
25
|
-
},
|
|
26
|
-
value() {
|
|
27
|
-
return delta;
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/** Hostnames the boot guard treats as loopback binds. */
|
|
32
|
-
export function isLoopbackHost(value) {
|
|
33
|
-
return value === "127.0.0.1" || value === "::1" || value === "localhost";
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* F-708: self-generate `TWIN_AUTH_SECRET` on first boot. An env-injected
|
|
37
|
-
* secret always wins (pome-cloud injects per-tenant secrets — that contract
|
|
38
|
-
* is untouched), and loopback binds keep the dev-fallback path. Otherwise
|
|
39
|
-
* the secret persisted at the compose-era contract location
|
|
40
|
-
* `.pome-data/<twin>/secret` (cwd-relative; `POME_TWIN_DATA_DIR` overrides
|
|
41
|
-
* the directory) is reused, or a fresh 32-byte hex secret is generated,
|
|
42
|
-
* persisted there, and printed once to stdout so the operator can mint JWTs.
|
|
43
|
-
*
|
|
44
|
-
* The resolved secret lands in `process.env.TWIN_AUTH_SECRET`, which is
|
|
45
|
-
* process-global by design: the engine's auth (`resolveAuthSecret`) reads
|
|
46
|
-
* the env, so one process serves one secret — the frozen boot contract is
|
|
47
|
-
* one twin per process, and a multi-twin process shares the first secret.
|
|
48
|
-
*/
|
|
49
|
-
export function ensureTwinAuthSecret(twin, host) {
|
|
50
|
-
if (process.env.TWIN_AUTH_SECRET)
|
|
51
|
-
return;
|
|
52
|
-
if (isLoopbackHost(host))
|
|
53
|
-
return;
|
|
54
|
-
const dataDir = process.env.POME_TWIN_DATA_DIR || join(".pome-data", twin);
|
|
55
|
-
const secretPath = join(dataDir, "secret");
|
|
56
|
-
try {
|
|
57
|
-
const persisted = readSecretFile(secretPath);
|
|
58
|
-
if (persisted) {
|
|
59
|
-
process.env.TWIN_AUTH_SECRET = persisted;
|
|
60
|
-
console.log(`[twin-${twin}] TWIN_AUTH_SECRET not set — using the persisted secret from ${secretPath}`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const secret = randomBytes(32).toString("hex");
|
|
64
|
-
mkdirSync(dataDir, { recursive: true });
|
|
65
|
-
try {
|
|
66
|
-
// Compose-era file format: hex secret + trailing newline, owner-only.
|
|
67
|
-
// "wx" never clobbers a secret written by a concurrent first boot.
|
|
68
|
-
writeFileSync(secretPath, `${secret}\n`, { mode: 0o600, flag: "wx" });
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (err.code !== "EEXIST")
|
|
72
|
-
throw err;
|
|
73
|
-
const winner = readSecretFile(secretPath);
|
|
74
|
-
if (winner) {
|
|
75
|
-
process.env.TWIN_AUTH_SECRET = winner;
|
|
76
|
-
console.log(`[twin-${twin}] TWIN_AUTH_SECRET not set — using the persisted secret from ${secretPath}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// A blank file is an aborted earlier write: remove it and retry the
|
|
80
|
-
// exclusive write, so a concurrent booter losing this second race
|
|
81
|
-
// adopts the winner's secret instead of overwriting it.
|
|
82
|
-
rmSync(secretPath, { force: true });
|
|
83
|
-
try {
|
|
84
|
-
writeFileSync(secretPath, `${secret}\n`, { mode: 0o600, flag: "wx" });
|
|
85
|
-
}
|
|
86
|
-
catch (err2) {
|
|
87
|
-
if (err2.code !== "EEXIST")
|
|
88
|
-
throw err2;
|
|
89
|
-
const late = readSecretFile(secretPath);
|
|
90
|
-
if (!late)
|
|
91
|
-
throw err2;
|
|
92
|
-
process.env.TWIN_AUTH_SECRET = late;
|
|
93
|
-
console.log(`[twin-${twin}] TWIN_AUTH_SECRET not set — using the persisted secret from ${secretPath}`);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
process.env.TWIN_AUTH_SECRET = secret;
|
|
98
|
-
console.log(`[twin-${twin}] TWIN_AUTH_SECRET not set — generated ${secret} (persisted to ${secretPath}; subsequent boots reuse it, an env-injected TWIN_AUTH_SECRET overrides it)`);
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
if (err instanceof TwinBootError)
|
|
102
|
-
throw err;
|
|
103
|
-
throw new TwinBootError(`TWIN_AUTH_SECRET is not set and self-generating one at ${secretPath} failed: ${err.message}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** The persisted secret, trimmed; undefined when absent or blank. */
|
|
107
|
-
function readSecretFile(secretPath) {
|
|
108
|
-
let raw;
|
|
109
|
-
try {
|
|
110
|
-
raw = readFileSync(secretPath, "utf8");
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
if (err.code === "ENOENT")
|
|
114
|
-
return undefined;
|
|
115
|
-
throw err;
|
|
116
|
-
}
|
|
117
|
-
const trimmed = raw.trim();
|
|
118
|
-
if (trimmed.length === 0)
|
|
119
|
-
return undefined;
|
|
120
|
-
// The compose-era contract documents >= 32 chars. A shorter file (hand
|
|
121
|
-
// edit, truncation) must fail the boot loudly — never silently serve a
|
|
122
|
-
// weak HS256 key, and never silently regenerate over operator content.
|
|
123
|
-
if (trimmed.length < 32) {
|
|
124
|
-
throw new TwinBootError(`TWIN_AUTH_SECRET is not set and the persisted secret at ${secretPath} is shorter than 32 chars — fix or delete the file, or inject TWIN_AUTH_SECRET.`);
|
|
125
|
-
}
|
|
126
|
-
return trimmed;
|
|
127
|
-
}
|
|
128
|
-
export function shadowedPrefix(routePath) {
|
|
129
|
-
for (const prefix of RESERVED_SESSION_PREFIXES) {
|
|
130
|
-
if (routePath === prefix || routePath.startsWith(`${prefix}/`))
|
|
131
|
-
return prefix;
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
export function assertUniqueToolNames(tools, twinId) {
|
|
136
|
-
const seen = new Set();
|
|
137
|
-
for (const tool of tools) {
|
|
138
|
-
if (seen.has(tool.name)) {
|
|
139
|
-
throw new TwinBootError(`Twin "${twinId}" has duplicate tool name: ${tool.name}`);
|
|
140
|
-
}
|
|
141
|
-
seen.add(tool.name);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export function findTool(definition, name) {
|
|
145
|
-
const tool = definition.tools.find((t) => t.name === name);
|
|
146
|
-
if (!tool) {
|
|
147
|
-
throw new UnknownToolError(name);
|
|
148
|
-
}
|
|
149
|
-
return tool;
|
|
150
|
-
}
|
|
151
|
-
export async function readJson(req) {
|
|
152
|
-
try {
|
|
153
|
-
const cloned = req.clone();
|
|
154
|
-
const text = await cloned.text();
|
|
155
|
-
if (!text)
|
|
156
|
-
return null;
|
|
157
|
-
return JSON.parse(text);
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
if (err instanceof SyntaxError)
|
|
161
|
-
throw err;
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Convenience helper for `recorder.handle` inner functions. Returns a
|
|
167
|
-
* 200 response with the supplied `mutation` flag (default: false). Mirrors
|
|
168
|
-
* `packages/twin-github/src/app.ts:ok`.
|
|
169
|
-
*/
|
|
170
|
-
export function ok(body, mutation = false) {
|
|
171
|
-
return { status: 200, body, mutation };
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Convenience helper for `recorder.handle` inner functions. Returns a
|
|
175
|
-
* 201 response with `mutation: true`. Mirrors
|
|
176
|
-
* `packages/twin-github/src/app.ts:created`.
|
|
177
|
-
*/
|
|
178
|
-
export function created(body) {
|
|
179
|
-
return { status: 201, body, mutation: true };
|
|
180
|
-
}
|
|
181
|
-
//# sourceMappingURL=server-helpers.js.map
|
package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-helpers.js","sourceRoot":"","sources":["../src/server-helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Hono } from "hono";
|
|
2
|
-
import { type TwinDefinition } from "./index.js";
|
|
3
|
-
import { type RecorderStore } from "./recorder.js";
|
|
4
|
-
export { TwinBootError, ensureTwinAuthSecret, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
5
|
-
export { createRecorderHandle, createRecorderStore, createFileBackedRecorderStore, resolveRecorderStore, toTwinHttpEventRow, POME_RECORDER_EVENTS_PATH, } from "./recorder.js";
|
|
6
|
-
export type { RecorderStore, RecorderStoreOptions, FileBackedRecorderStoreOptions, ErrorEnvelopeFn, } from "./recorder.js";
|
|
7
|
-
export { bearerAuth, requireAdminAuth, resolveAuthSecret } from "./auth.js";
|
|
8
|
-
export { createAdminGate, setClientIp } from "./admin-gate.js";
|
|
9
|
-
export type { AdminGateOptions } from "./admin-gate.js";
|
|
10
|
-
export { TwinError, UnknownToolError } from "./errors.js";
|
|
11
|
-
export { redactEvent, redactSecrets } from "./redaction.js";
|
|
12
|
-
export { FAILURE_INJECTION_OVERRIDE_KEY, createFailureInjectionStore, failureInjectionMiddleware, failureInjectionRuleSchema, } from "./failure-injection.js";
|
|
13
|
-
export type { FailureInjectionMiddlewareOptions, FailureInjectionMode, FailureInjectionOverride, FailureInjectionRule, FailureInjectionStore, } from "./failure-injection.js";
|
|
14
|
-
export { PROVIDER_SHAPED_TEAM_ID, formTokenResolver, mintProviderToken, queryTokenResolver, verifyProviderToken, } from "./auth.js";
|
|
15
|
-
export type { AuthEnvelope, BearerAuthOptions, MintProviderTokenOptions, ProviderTokenSpec, SessionClaims, SessionValue, TokenResolver, UnauthorizedKind, } from "./auth.js";
|
|
16
|
-
export { twinBuildInfo } from "./build-info.js";
|
|
17
|
-
export type { TwinBuildInfo } from "./build-info.js";
|
|
18
|
-
export interface ServeOptions<TDb = unknown, TSeed = unknown> {
|
|
19
|
-
/** Optional. When set, `serve()` binds a Node HTTP server. */
|
|
20
|
-
port?: number;
|
|
21
|
-
/** Bind hostname. Defaults to "127.0.0.1". */
|
|
22
|
-
hostname?: string;
|
|
23
|
-
/** Opaque database handle forwarded to `definition.domain({ db })`. */
|
|
24
|
-
db?: TDb;
|
|
25
|
-
/** Initial seed forwarded to `definition.domain({ seed })`. Validated against `definition.seed` if provided. */
|
|
26
|
-
seed?: TSeed;
|
|
27
|
-
/** Custom recorder store. Defaults to `resolveRecorderStore()` (durable when `POME_RECORDER_EVENTS_PATH` is set). */
|
|
28
|
-
recorder?: RecorderStore;
|
|
29
|
-
/** Run identifier embedded in every recorder event. Defaults to "local". */
|
|
30
|
-
runId?: string;
|
|
31
|
-
}
|
|
32
|
-
export declare function createApp<TDb, TSeed, TDomain>(definition: TwinDefinition<TDb, TSeed, TDomain>, options?: ServeOptions<TDb, TSeed>): Hono;
|
|
33
|
-
export interface ServeResult {
|
|
34
|
-
app: Hono;
|
|
35
|
-
/**
|
|
36
|
-
* Stop the bound HTTP server (if any), then flush+close the recorder store
|
|
37
|
-
* so durable tapes drain before process exit (F-698).
|
|
38
|
-
*/
|
|
39
|
-
close(): Promise<void>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Build the app and bind a Node HTTP server. If `port` is omitted, no
|
|
43
|
-
* server is bound — `close()` still flushes the recorder store.
|
|
44
|
-
*/
|
|
45
|
-
export declare function serve<TDb, TSeed, TDomain>(definition: TwinDefinition<TDb, TSeed, TDomain>, options?: ServeOptions<TDb, TSeed>): Promise<ServeResult>;
|
|
46
|
-
/** Engine-owned `/_pome/*` route names a twin's `pomeRoutes` may not shadow. */
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
// file-size: server engine intentionally centralizes TwinDefinition boot, reserved routes, recorder shutdown, and auth wiring.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
//
|
|
4
|
-
// `@pome-sh/sdk/server` — boot a `TwinDefinition` into a Hono app and
|
|
5
|
-
// optionally bind a Node HTTP server. `createApp()` returns the bare app
|
|
6
|
-
// (no port binding) for tests; `serve()` wraps it with `@hono/node-server`.
|
|
7
|
-
//
|
|
8
|
-
// Auto-mounted routes:
|
|
9
|
-
// GET /healthz (root, no auth)
|
|
10
|
-
// POST /admin/reset (localhost-only)
|
|
11
|
-
// POST /admin/seed (localhost-only)
|
|
12
|
-
// GET /s/:sid/healthz (bearer)
|
|
13
|
-
// GET /s/:sid/_pome/health (bearer)
|
|
14
|
-
// GET /s/:sid/_pome/state (bearer)
|
|
15
|
-
// GET /s/:sid/_pome/events (bearer)
|
|
16
|
-
// GET /s/:sid/mcp/tools (bearer)
|
|
17
|
-
// POST /s/:sid/mcp/tools/:name (bearer)
|
|
18
|
-
// POST /s/:sid/mcp/call (bearer)
|
|
19
|
-
//
|
|
20
|
-
// User routes registered via `definition.routes(app, ctx)` are mounted under
|
|
21
|
-
// `/s/:sid/*`. The SDK refuses to boot if any user route shadows the
|
|
22
|
-
// `/_pome/*` or `/mcp/*` prefixes (OQ-B6 invariant).
|
|
23
|
-
import { Hono } from "hono";
|
|
24
|
-
import { z } from "zod";
|
|
25
|
-
import { toolInputSchema, toolListExtras, } from "./index.js";
|
|
26
|
-
import { bearerAuth, requireAdminAuth } from "./auth.js";
|
|
27
|
-
import { createAdminGate } from "./admin-gate.js";
|
|
28
|
-
import { makeToolCallContext } from "./tool-context.js";
|
|
29
|
-
import { twinBuildInfo } from "./build-info.js";
|
|
30
|
-
import { handleMcpJsonRpc, mcpMethodNotAllowed } from "./mcp-jsonrpc.js";
|
|
31
|
-
import { createRecorderHandle, resolveRecorderStore } from "./recorder.js";
|
|
32
|
-
import { redactSecrets } from "./redaction.js";
|
|
33
|
-
import { TwinError, envelopeFor } from "./errors.js";
|
|
34
|
-
import { POME_CORE_ROUTE_NAMES, TwinBootError, assertUniqueToolNames, ensureTwinAuthSecret, findTool, isLoopbackHost, makeDeltaSink, readJson, shadowedPrefix, } from "./server-helpers.js";
|
|
35
|
-
// Public boot surface consumed by twin entrypoints
|
|
36
|
-
// (`import { ensureTwinAuthSecret, serve } from "@pome-sh/sdk/server"`).
|
|
37
|
-
export { TwinBootError, ensureTwinAuthSecret, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
38
|
-
export { createRecorderHandle, createRecorderStore, createFileBackedRecorderStore, resolveRecorderStore, toTwinHttpEventRow, POME_RECORDER_EVENTS_PATH, } from "./recorder.js";
|
|
39
|
-
export { bearerAuth, requireAdminAuth, resolveAuthSecret } from "./auth.js";
|
|
40
|
-
// Alternate serving bridges (anything that isn't @hono/node-server) must feed
|
|
41
|
-
// the gate the transport-level peer address via setClientIp from an upstream
|
|
42
|
-
// middleware; createAdminGate lets custom twins mount the gate with their own
|
|
43
|
-
// 403 envelope. See the SECURITY note on setClientIp — never derive the value
|
|
44
|
-
// from request headers.
|
|
45
|
-
export { createAdminGate, setClientIp } from "./admin-gate.js";
|
|
46
|
-
export { TwinError, UnknownToolError } from "./errors.js";
|
|
47
|
-
export { redactEvent, redactSecrets } from "./redaction.js";
|
|
48
|
-
export { FAILURE_INJECTION_OVERRIDE_KEY, createFailureInjectionStore, failureInjectionMiddleware, failureInjectionRuleSchema, } from "./failure-injection.js";
|
|
49
|
-
export { PROVIDER_SHAPED_TEAM_ID, formTokenResolver, mintProviderToken, queryTokenResolver, verifyProviderToken, } from "./auth.js";
|
|
50
|
-
export { twinBuildInfo } from "./build-info.js";
|
|
51
|
-
const jsonRecord = z.record(z.string(), z.unknown());
|
|
52
|
-
export function createApp(definition, options = {}) {
|
|
53
|
-
// 1. Validate + build seed
|
|
54
|
-
let seed;
|
|
55
|
-
if (options.seed !== undefined) {
|
|
56
|
-
if (definition.seed) {
|
|
57
|
-
seed = definition.seed.parse(options.seed);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
seed = options.seed;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// 2. Build domain
|
|
64
|
-
const domain = definition.domain({ db: options.db, seed });
|
|
65
|
-
// 3. Build recorder. The manifest's `errorEnvelope` (if set) is forwarded
|
|
66
|
-
// here so API-mirroring twins control their error shape without
|
|
67
|
-
// bypassing the recorder middleware.
|
|
68
|
-
const runId = options.runId ?? "local";
|
|
69
|
-
const recorder = createRecorderHandle({
|
|
70
|
-
runId,
|
|
71
|
-
twin: definition.id,
|
|
72
|
-
store: options.recorder ?? resolveRecorderStore(),
|
|
73
|
-
errorEnvelope: definition.errorEnvelope,
|
|
74
|
-
stampToolCallId: definition.stampToolCallId,
|
|
75
|
-
recordingProjection: definition.recordingProjection,
|
|
76
|
-
});
|
|
77
|
-
// 4. Boot-time invariant: user routes must not shadow reserved prefixes.
|
|
78
|
-
const userApp = new Hono();
|
|
79
|
-
if (definition.routes) {
|
|
80
|
-
definition.routes(userApp, { domain, recorder, runId, twin: definition.id });
|
|
81
|
-
for (const route of userApp.routes) {
|
|
82
|
-
const shadowed = shadowedPrefix(route.path);
|
|
83
|
-
if (shadowed) {
|
|
84
|
-
throw new TwinBootError(`Twin "${definition.id}" route ${route.method} ${route.path} shadows reserved SDK prefix ${shadowed}/*`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// 5. Tool name uniqueness sanity (defineTwin already enforces, but a
|
|
89
|
-
// test that hand-builds a TwinDefinition could bypass it).
|
|
90
|
-
assertUniqueToolNames(definition.tools, definition.id);
|
|
91
|
-
// 6. Build root app
|
|
92
|
-
const root = new Hono();
|
|
93
|
-
// Contract core: {ok, twin, implementation, tools, runtime}. Extras
|
|
94
|
-
// default to the pre-F-681 fields; a twin with a frozen healthz shape
|
|
95
|
-
// supplies its own (possibly empty) extras via `definition.healthz`.
|
|
96
|
-
const healthzExtras = definition.healthz ??
|
|
97
|
-
(() => ({ version: definition.version, fidelity: definition.fidelity.default }));
|
|
98
|
-
root.get("/healthz", (c) => c.json({
|
|
99
|
-
ok: true,
|
|
100
|
-
twin: definition.id,
|
|
101
|
-
implementation: definition.implementation ?? `${definition.id}_clone`,
|
|
102
|
-
tools: definition.tools.length,
|
|
103
|
-
runtime: twinBuildInfo(definition.packageName ?? `@pome-sh/twin-${definition.id}`),
|
|
104
|
-
...healthzExtras(),
|
|
105
|
-
}));
|
|
106
|
-
// Per-twin body reader for the engine-owned JSON surfaces. Default is
|
|
107
|
-
// strict JSON (malformed → SyntaxError into the twin's errorEnvelope);
|
|
108
|
-
// twins with frozen tolerant/form parsing (slack, stripe) declare theirs.
|
|
109
|
-
const readBody = definition.bodyReader ?? ((c) => readJson(c.req.raw));
|
|
110
|
-
// 7. Admin sub-app. Gate mechanism is the engine's; a twin with a frozen
|
|
111
|
-
// 403 body declares it via `admin.forbidden` (F-683).
|
|
112
|
-
const adminForbidden = definition.admin?.forbidden;
|
|
113
|
-
const adminApp = new Hono();
|
|
114
|
-
adminApp.use("*", adminForbidden
|
|
115
|
-
? createAdminGate({
|
|
116
|
-
forbidden: () => {
|
|
117
|
-
const envelope = adminForbidden();
|
|
118
|
-
return Response.json(envelope.body, { status: envelope.status });
|
|
119
|
-
},
|
|
120
|
-
})
|
|
121
|
-
: requireAdminAuth());
|
|
122
|
-
const adminEnvelope = definition.admin?.errorEnvelope;
|
|
123
|
-
// stripe pin: its pre-port recorder never saw admin traffic, so
|
|
124
|
-
// admin.recorded=false serves the same handlers without emitting events.
|
|
125
|
-
const wrapAdmin = definition.admin?.recorded !== false
|
|
126
|
-
? (fn) => recorder.handle({ mutation: true, errorEnvelope: adminEnvelope }, fn)
|
|
127
|
-
: (fn) => async (c) => {
|
|
128
|
-
try {
|
|
129
|
-
const result = await fn(c);
|
|
130
|
-
return c.json(result.body, result.status);
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
const envelope = (adminEnvelope ?? definition.errorEnvelope ?? envelopeFor)(err);
|
|
134
|
-
return c.json(envelope.body, envelope.status);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
adminApp.post("/reset", wrapAdmin(async () => {
|
|
138
|
-
if (!definition.admin?.reset) {
|
|
139
|
-
throw new TwinError("admin.reset is not configured for this twin", 501);
|
|
140
|
-
}
|
|
141
|
-
const delta = makeDeltaSink();
|
|
142
|
-
const body = (await definition.admin.reset({ domain, reportDelta: delta.report })) ?? { ok: true };
|
|
143
|
-
return { status: 200, body, delta: delta.value() };
|
|
144
|
-
}));
|
|
145
|
-
adminApp.post("/seed", wrapAdmin(async (c) => {
|
|
146
|
-
if (!definition.admin?.seed) {
|
|
147
|
-
throw new TwinError("admin.seed is not configured for this twin", 501);
|
|
148
|
-
}
|
|
149
|
-
if (!definition.seed) {
|
|
150
|
-
throw new TwinError("Twin manifest has no `seed` schema; cannot accept POST /admin/seed", 501);
|
|
151
|
-
}
|
|
152
|
-
const raw = await readBody(c);
|
|
153
|
-
const parsed = definition.seed.parse(raw);
|
|
154
|
-
const delta = makeDeltaSink();
|
|
155
|
-
const body = (await definition.admin.seed({ domain, seed: parsed, reportDelta: delta.report })) ?? { ok: true };
|
|
156
|
-
return { status: 200, body, delta: delta.value() };
|
|
157
|
-
}));
|
|
158
|
-
root.route("/admin", adminApp);
|
|
159
|
-
// 8. Session sub-app. Auth mechanism is the engine's; the twin's declared
|
|
160
|
-
// shape (F-712) rides in via `definition.auth`.
|
|
161
|
-
const session = new Hono();
|
|
162
|
-
session.use("*", bearerAuth(definition.auth));
|
|
163
|
-
// Session-wide middleware slot — the pre-port `session.use("*")` position,
|
|
164
|
-
// mounted BEFORE the engine's MCP / `/_pome/*` routes so twin middleware
|
|
165
|
-
// (stripe failure-injection, idempotency) covers MCP dispatch too.
|
|
166
|
-
if (definition.middleware) {
|
|
167
|
-
definition.middleware(session, { domain, recorder, runId, twin: definition.id });
|
|
168
|
-
}
|
|
169
|
-
// Per-session healthz is contract-frozen per twin: github/slack answer
|
|
170
|
-
// 200 {ok, sid}; stripe has NO such route (falls to the 501 catch-all).
|
|
171
|
-
if (definition.sessionHealthz !== false) {
|
|
172
|
-
session.get("/healthz", (c) => c.json({ ok: true, sid: c.req.param("sid") }));
|
|
173
|
-
}
|
|
174
|
-
// `pomeHealth` extras replace the default {version, fidelity} for twins
|
|
175
|
-
// with a frozen per-session health shape (slack: bare {ok, twin};
|
|
176
|
-
// github: no version; stripe adds recorder counters).
|
|
177
|
-
const pomeHealthExtras = definition.pomeHealth ??
|
|
178
|
-
(() => ({ version: definition.version, fidelity: definition.fidelity.default }));
|
|
179
|
-
session.get("/_pome/health", (c) => c.json({
|
|
180
|
-
ok: true,
|
|
181
|
-
twin: definition.id,
|
|
182
|
-
...pomeHealthExtras({ recorder }),
|
|
183
|
-
}));
|
|
184
|
-
// NOT recorder-wrapped: no pre-port twin recorded /_pome/state fetches on
|
|
185
|
-
// the tape (F-683 review pin) — the export is a read-side probe, and
|
|
186
|
-
// recording it would embed the full state as an event response_body.
|
|
187
|
-
session.get("/_pome/state", async (c) => {
|
|
188
|
-
try {
|
|
189
|
-
if (!definition.state) {
|
|
190
|
-
throw new TwinError("state introspection is not configured for this twin", 501);
|
|
191
|
-
}
|
|
192
|
-
const session = c.get("session");
|
|
193
|
-
const state = await definition.state({ domain, session });
|
|
194
|
-
// Central redaction: the state export feeds cloud-side scoring and the
|
|
195
|
-
// CLI trace; a twin must not be able to leak secrets by omission.
|
|
196
|
-
return c.json(redactSecrets(state));
|
|
197
|
-
}
|
|
198
|
-
catch (err) {
|
|
199
|
-
const envelope = (definition.errorEnvelope ?? envelopeFor)(err);
|
|
200
|
-
return c.json(envelope.body, envelope.status);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
session.get("/_pome/events", (c) => c.json(recorder.events()));
|
|
204
|
-
// 8b. Extra per-twin `/_pome/*` routes (github's frozen
|
|
205
|
-
// GET /s/:sid/_pome/access-control, F-682). Registered after the core
|
|
206
|
-
// routes so the platform surface can never be shadowed; core names are
|
|
207
|
-
// rejected outright at boot.
|
|
208
|
-
if (definition.pomeRoutes) {
|
|
209
|
-
for (const [name, handler] of Object.entries(definition.pomeRoutes)) {
|
|
210
|
-
if (POME_CORE_ROUTE_NAMES.has(name)) {
|
|
211
|
-
throw new TwinBootError(`Twin "${definition.id}" pome route "/_pome/${name}" shadows a reserved engine route`);
|
|
212
|
-
}
|
|
213
|
-
session.get(`/_pome/${name}`, async (c) => c.json((await handler({ domain }))));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// 9. MCP routes from tool registry. `/mcp` is the streamable-HTTP
|
|
217
|
-
// JSON-RPC endpoint (stateless — GET/DELETE answer 405); `/mcp/tools`,
|
|
218
|
-
// `/mcp/tools/:name`, `/mcp/call` are the legacy dispatch surface.
|
|
219
|
-
session.post("/mcp", (c) => handleMcpJsonRpc(c, { definition, domain, recorder, runId }));
|
|
220
|
-
session.get("/mcp", (c) => mcpMethodNotAllowed(c));
|
|
221
|
-
session.delete("/mcp", (c) => mcpMethodNotAllowed(c));
|
|
222
|
-
session.get("/mcp/tools", (c) => c.json({
|
|
223
|
-
tools: definition.tools.map((tool) => ({
|
|
224
|
-
name: tool.name,
|
|
225
|
-
description: tool.description,
|
|
226
|
-
input_schema: toolInputSchema(tool),
|
|
227
|
-
...toolListExtras(tool),
|
|
228
|
-
})),
|
|
229
|
-
}));
|
|
230
|
-
session.post("/mcp/tools/:name", recorder.handle({ mutation: false }, async (c) => {
|
|
231
|
-
const name = c.req.param("name") ?? "";
|
|
232
|
-
const tool = findTool(definition, name);
|
|
233
|
-
const args = await readBody(c);
|
|
234
|
-
const parsed = tool.schema.parse(args ?? {});
|
|
235
|
-
const call = makeToolCallContext(c);
|
|
236
|
-
const result = await tool.handler(domain, parsed, call.ctx);
|
|
237
|
-
const delta = call.delta();
|
|
238
|
-
const mutation = tool.mutation && (!call.reportedDelta() || delta !== null);
|
|
239
|
-
return { status: 200, body: result, mutation, delta };
|
|
240
|
-
}));
|
|
241
|
-
session.post("/mcp/call", recorder.handle({ mutation: false }, async (c) => {
|
|
242
|
-
const raw = await readBody(c);
|
|
243
|
-
let call;
|
|
244
|
-
if (definition.legacyMcp?.aliases) {
|
|
245
|
-
// Frozen slack surface: {name}/{params} alias {tool}/{arguments};
|
|
246
|
-
// a body naming no tool answers the twin's own envelope (400
|
|
247
|
-
// invalid_arguments) instead of the strict-parse error.
|
|
248
|
-
const rec = (raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {});
|
|
249
|
-
const name = rec.tool ?? rec.name;
|
|
250
|
-
if (typeof name !== "string" || name.length === 0) {
|
|
251
|
-
const missing = definition.legacyMcp.missingTool;
|
|
252
|
-
if (missing) {
|
|
253
|
-
const envelope = missing();
|
|
254
|
-
return { status: envelope.status, body: envelope.body };
|
|
255
|
-
}
|
|
256
|
-
z.object({ tool: z.string().min(1) }).parse(rec); // throws the strict-parse error
|
|
257
|
-
}
|
|
258
|
-
call = {
|
|
259
|
-
tool: name,
|
|
260
|
-
arguments: (rec.arguments ?? rec.params ?? {}),
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
call = z
|
|
265
|
-
.object({ tool: z.string().min(1), arguments: jsonRecord.default({}) })
|
|
266
|
-
.parse(raw);
|
|
267
|
-
}
|
|
268
|
-
const tool = findTool(definition, call.tool);
|
|
269
|
-
const parsed = tool.schema.parse(call.arguments);
|
|
270
|
-
const toolCall = makeToolCallContext(c);
|
|
271
|
-
const result = await tool.handler(domain, parsed, toolCall.ctx);
|
|
272
|
-
const delta = toolCall.delta();
|
|
273
|
-
const mutation = tool.mutation && (!toolCall.reportedDelta() || delta !== null);
|
|
274
|
-
return { status: 200, body: result, mutation, delta };
|
|
275
|
-
}));
|
|
276
|
-
// 10. User routes
|
|
277
|
-
if (definition.routes) {
|
|
278
|
-
session.route("/", userApp);
|
|
279
|
-
}
|
|
280
|
-
// 11. Catch-all for unsupported surfaces. Recorder records
|
|
281
|
-
// fidelity:"unsupported" and returns 501 so unmatched routes surface
|
|
282
|
-
// as a fidelity-gap signal in the trace instead of silently 404'ing.
|
|
283
|
-
// Not opt-out per OQ-B6: every community twin auto-surfaces fidelity
|
|
284
|
-
// gaps in the trace.
|
|
285
|
-
session.all("*", recorder.handle({ mutation: false, fidelity: "unsupported" }, async (c) => {
|
|
286
|
-
const ctx = { method: c.req.method, path: new URL(c.req.url).pathname };
|
|
287
|
-
if (definition.unsupported)
|
|
288
|
-
return definition.unsupported(ctx);
|
|
289
|
-
return {
|
|
290
|
-
status: 501,
|
|
291
|
-
body: {
|
|
292
|
-
message: `Endpoint not modeled by twin "${definition.id}".`,
|
|
293
|
-
fidelity: "unsupported",
|
|
294
|
-
method: ctx.method,
|
|
295
|
-
path: ctx.path,
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
}));
|
|
299
|
-
root.route("/s/:sid", session);
|
|
300
|
-
// 11b. SDK-compat root mount (stripe F3, F-684): the same session router
|
|
301
|
-
// answers at the root path. Root /healthz + /admin/* were registered
|
|
302
|
-
// first and stay first-match; unknown root paths hit the twin's auth
|
|
303
|
-
// wall (bearerAuth answers 401 before the 501 catch-all). Pair with
|
|
304
|
-
// `auth.requirePathSid: false` so the bearer alone resolves the sid.
|
|
305
|
-
if (definition.mountSessionAtRoot) {
|
|
306
|
-
root.route("/", session);
|
|
307
|
-
}
|
|
308
|
-
// 12. Footgun warning: clean-state-per-test workflows rely on
|
|
309
|
-
// /admin/reset. Warn loudly if a twin ships without it so authors
|
|
310
|
-
// don't discover the gap mid-CI-debug.
|
|
311
|
-
if (!definition.admin?.reset) {
|
|
312
|
-
console.warn(`[@pome-sh/sdk] twin "${definition.id}" has no admin.reset configured — POST /admin/reset returns 501. Most CI workflows rely on this for clean-state-per-test.`);
|
|
313
|
-
}
|
|
314
|
-
return root;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Build the app and bind a Node HTTP server. If `port` is omitted, no
|
|
318
|
-
* server is bound — `close()` still flushes the recorder store.
|
|
319
|
-
*/
|
|
320
|
-
export async function serve(definition, options = {}) {
|
|
321
|
-
const hostname = options.hostname ?? "127.0.0.1";
|
|
322
|
-
// Contract boot guard: a twin must never serve real traffic with the dev
|
|
323
|
-
// fallback secret. Since F-708 a non-loopback bind with no env-injected
|
|
324
|
-
// secret self-generates + persists one instead of refusing to boot; a
|
|
325
|
-
// failed generation still throws before the app is built, so the process
|
|
326
|
-
// exits non-zero without ever listening.
|
|
327
|
-
if (options.port !== undefined && !isLoopbackHost(hostname)) {
|
|
328
|
-
ensureTwinAuthSecret(definition.id, hostname);
|
|
329
|
-
}
|
|
330
|
-
// Resolve the store once so `close()` can flush the same instance the app
|
|
331
|
-
// records into (durable when POME_RECORDER_EVENTS_PATH is set).
|
|
332
|
-
const store = options.recorder ?? resolveRecorderStore();
|
|
333
|
-
const app = createApp(definition, { ...options, recorder: store });
|
|
334
|
-
const closeRecorder = async () => {
|
|
335
|
-
await store.flush?.();
|
|
336
|
-
await store.close?.();
|
|
337
|
-
};
|
|
338
|
-
if (options.port === undefined) {
|
|
339
|
-
return { app, close: closeRecorder };
|
|
340
|
-
}
|
|
341
|
-
const { serve: nodeServe } = await import("@hono/node-server");
|
|
342
|
-
const server = await new Promise((resolve) => {
|
|
343
|
-
const bound = nodeServe({
|
|
344
|
-
fetch: app.fetch,
|
|
345
|
-
port: options.port,
|
|
346
|
-
hostname,
|
|
347
|
-
}, () => resolve(bound));
|
|
348
|
-
});
|
|
349
|
-
let closed = false;
|
|
350
|
-
const close = async () => {
|
|
351
|
-
if (closed) {
|
|
352
|
-
await closeRecorder();
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
closed = true;
|
|
356
|
-
unregisterServeShutdown(close);
|
|
357
|
-
await new Promise((resolve, reject) => {
|
|
358
|
-
server.close((err) => (err ? reject(err) : resolve()));
|
|
359
|
-
});
|
|
360
|
-
await closeRecorder();
|
|
361
|
-
};
|
|
362
|
-
// Twin boot scripts (`await serve(...)`) never call close() themselves.
|
|
363
|
-
// Drain the durable recorder on graceful process signals so hosted twins
|
|
364
|
-
// with POME_RECORDER_EVENTS_PATH set do not lose the last accepted events.
|
|
365
|
-
// Shared registry: every served twin flushes before a single process.exit,
|
|
366
|
-
// so multi-twin processes cannot lose sibling recorder tapes.
|
|
367
|
-
registerServeShutdown(close);
|
|
368
|
-
return { app, close };
|
|
369
|
-
}
|
|
370
|
-
/** Active `serve({ port })` close hooks — drained together on SIGINT/SIGTERM. */
|
|
371
|
-
const serveShutdownHooks = new Set();
|
|
372
|
-
let serveSignalHandlersInstalled = false;
|
|
373
|
-
function registerServeShutdown(close) {
|
|
374
|
-
serveShutdownHooks.add(close);
|
|
375
|
-
if (serveSignalHandlersInstalled)
|
|
376
|
-
return;
|
|
377
|
-
serveSignalHandlersInstalled = true;
|
|
378
|
-
const onSignal = () => {
|
|
379
|
-
void (async () => {
|
|
380
|
-
const hooks = [...serveShutdownHooks];
|
|
381
|
-
serveShutdownHooks.clear();
|
|
382
|
-
await Promise.allSettled(hooks.map((hook) => hook()));
|
|
383
|
-
process.exit(0);
|
|
384
|
-
})();
|
|
385
|
-
};
|
|
386
|
-
process.once("SIGINT", onSignal);
|
|
387
|
-
process.once("SIGTERM", onSignal);
|
|
388
|
-
}
|
|
389
|
-
function unregisterServeShutdown(close) {
|
|
390
|
-
serveShutdownHooks.delete(close);
|
|
391
|
-
}
|
|
392
|
-
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
393
|
-
/** Engine-owned `/_pome/*` route names a twin's `pomeRoutes` may not shadow. */
|
|
394
|
-
//# sourceMappingURL=server.js.map
|