@pome-sh/cli 0.1.1 → 0.2.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 +5 -6
- package/dist/build-info.json +3 -3
- package/dist/src/cli/eval.js +26 -8
- package/dist/src/cli/init-sdk.d.ts +0 -3
- package/dist/src/cli/init-sdk.js +117 -24
- package/dist/src/cli/main.js +23 -69
- package/dist/src/cli/register.d.ts +9 -0
- package/dist/src/cli/register.js +51 -5
- package/dist/src/cli/session.d.ts +7 -1
- package/dist/src/cli/session.js +87 -27
- package/dist/src/demo/runDemo.js +3 -2
- package/dist/src/hosted/client.d.ts +41 -5
- package/dist/src/hosted/client.js +333 -19
- package/dist/src/hosted/errors.d.ts +11 -1
- package/dist/src/hosted/errors.js +8 -1
- package/dist/src/hosted/evalResultView.d.ts +2 -0
- package/dist/src/hosted/evalResultView.js +22 -0
- package/dist/src/hosted/uploadAndFinalize.d.ts +18 -1
- package/dist/src/hosted/uploadAndFinalize.js +51 -3
- package/dist/src/recorder/inspect.js +20 -2
- package/dist/src/runner/mergeAdapterSignals.js +2 -2
- package/dist/src/runner/ports.js +3 -0
- package/dist/src/runner/runScenario.d.ts +79 -2
- package/dist/src/runner/runScenario.js +94 -36
- package/dist/src/runner/runScenarioHosted.d.ts +37 -0
- package/dist/src/runner/runScenarioHosted.js +257 -58
- package/dist/src/runner/runTrialGroup.d.ts +1 -3
- package/dist/src/runner/runTrialGroup.js +1 -3
- package/dist/src/scenario/parseScenario.d.ts +5 -0
- package/dist/src/scenario/parseScenario.js +135 -8
- package/dist/src/scenario/scenarioSchema.d.ts +200 -3
- package/dist/src/scenario/scenarioSchema.js +12 -1
- package/dist/src/twin/twinHarness.d.ts +10 -0
- package/dist/src/twin/twinHarness.js +6 -2
- package/dist/src/twin/twinStart.d.ts +19 -0
- package/dist/src/twin/twinStart.js +156 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +121 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +204 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +1 -0
- package/node_modules/@pome-sh/sdk/dist/parity.d.ts +55 -0
- package/node_modules/@pome-sh/sdk/dist/parity.js +112 -0
- package/node_modules/@pome-sh/sdk/dist/parity.js.map +1 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +15 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.js +96 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/server.d.ts +1 -1
- package/node_modules/@pome-sh/sdk/dist/server.js +9 -7
- package/node_modules/@pome-sh/sdk/dist/server.js.map +1 -1
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.d.ts +13 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.js +6 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +215 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +83 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +175 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.js +182 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.d.ts +27 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.js +34 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +286 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +33 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +65 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +455 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +39 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +47 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +25 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.js +27 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +100 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +185 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +64 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +112 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +26 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.js +61 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +42 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.js +96 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +51 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +74 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +134 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +152 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +418 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.js +234 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +2 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.js +152 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.d.ts +198 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.js +225 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.d.ts +201 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.js +166 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +66 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.js +84 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.d.ts +483 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/package.json +54 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/trace-contract.json +41 -0
- package/node_modules/@pome-sh/sdk/package.json +6 -2
- package/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +252 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +122 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/index.d.ts +13 -1353
- package/node_modules/@pome-sh/shared-types/dist/index.js +14 -568
- package/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +45 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +8 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +7 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +62 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js +36 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/rest.d.ts +245 -0
- package/node_modules/@pome-sh/shared-types/dist/rest.js +303 -0
- package/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/run.d.ts +7 -0
- package/node_modules/@pome-sh/shared-types/dist/run.js +4 -0
- package/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +14 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +46 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/task.d.ts +485 -0
- package/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/package.json +2 -1
- package/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
- package/node_modules/@pome-sh/twin-github/FIDELITY.md +127 -67
- package/node_modules/@pome-sh/twin-github/README.md +3 -7
- package/node_modules/@pome-sh/twin-github/dist/examples/claude-github-agent.js +4 -20
- package/node_modules/@pome-sh/twin-github/dist/examples/claude-github-agent.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/access-control.d.ts +3 -3
- package/node_modules/@pome-sh/twin-github/dist/src/domain.d.ts +141 -3
- package/node_modules/@pome-sh/twin-github/dist/src/domain.js +0 -0
- package/node_modules/@pome-sh/twin-github/dist/src/domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/routes.js +2 -0
- package/node_modules/@pome-sh/twin-github/dist/src/routes.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/seed.d.ts +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/serializers.d.ts +2 -2
- package/node_modules/@pome-sh/twin-github/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-github/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/tools.d.ts +168 -18
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js +23 -0
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/fidelity.inventory.json +773 -0
- package/node_modules/@pome-sh/twin-github/package.json +5 -4
- package/node_modules/@pome-sh/twin-slack/FIDELITY.md +121 -35
- package/node_modules/@pome-sh/twin-slack/README.md +2 -6
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.d.ts +1 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.js +92 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/smoke.js +3 -3
- package/node_modules/@pome-sh/twin-slack/dist/scripts/smoke.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/scripts/validate-mcp.js +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/scripts/validate-mcp.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-slack/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.d.ts +30 -4
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.js +48 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/fidelity.inventory.json +377 -0
- package/node_modules/@pome-sh/twin-slack/package.json +5 -4
- package/node_modules/@pome-sh/twin-stripe/FIDELITY.md +151 -50
- package/node_modules/@pome-sh/twin-stripe/README.md +42 -45
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.d.ts +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.js +186 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/smoke.js +8 -4
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/smoke.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/db.js +26 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/db.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.d.ts +101 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.js +195 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.d.ts +15 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.js +17 -5
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.d.ts +47 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.js +103 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/events.d.ts +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/events.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.d.ts +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.js +3 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.d.ts +61 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.js +214 -52
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.d.ts +45 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.js +159 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.d.ts +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.js +16 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.d.ts +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.js +144 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.d.ts +420 -43
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.js +442 -13
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.d.ts +19 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.js +15 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.d.ts +2 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.js +2 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.d.ts +8 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js +105 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.js +117 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.js +47 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/index.js +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-intents.js +28 -102
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-intents.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.js +33 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.d.ts +10 -8
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.js +3 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.d.ts +181 -21
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.js +257 -34
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-stripe/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.d.ts +107 -5
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.js +139 -6
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/types.d.ts +73 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/upstream-types.d.ts +8 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/x402.js +6 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/x402.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/fidelity.inventory.json +425 -0
- package/node_modules/@pome-sh/twin-stripe/package.json +5 -4
- package/package.json +8 -8
- package/skills/pome-setup/SKILL.md +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// Structured fidelity inventory (F-730). Each twin ships a machine-readable
|
|
4
|
+
// surface list — `fidelity.inventory.json` — carrying, per MCP tool and REST
|
|
5
|
+
// surface, the heat tier (how deep the endpoint SHOULD be, ruled by the
|
|
6
|
+
// F-729 rubric) orthogonal to the fidelity tier (how deep it IS, per
|
|
7
|
+
// `fidelityTierSchema`), plus a justification for the classification.
|
|
8
|
+
//
|
|
9
|
+
// The FIDELITY doc tables are 1:1-linted against this inventory instead of
|
|
10
|
+
// the old soft "docs mention the tool name" checks (which let twin-stripe's
|
|
11
|
+
// implemented-but-undocumented refunds drift by silently). Known, ticketed
|
|
12
|
+
// doc gaps are declared in `doc_drift`: the lint accepts exactly those
|
|
13
|
+
// gaps and fails loudly once the docs catch up, so a declaration can never
|
|
14
|
+
// outlive the drift it describes.
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
import { fidelityTierSchema } from "./index.js";
|
|
18
|
+
export const heatTierSchema = z.enum(["hot", "warm", "cold", "unclassified"]);
|
|
19
|
+
export const fidelitySurfaceSchema = z.strictObject({
|
|
20
|
+
/** MCP tool name, or the REST surface string exactly as documented. */
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
heat: heatTierSchema,
|
|
23
|
+
fidelity: fidelityTierSchema,
|
|
24
|
+
justification: z.string().min(1),
|
|
25
|
+
});
|
|
26
|
+
export const fidelityDocDriftSchema = z.strictObject({
|
|
27
|
+
kind: z.enum(["tool", "rest"]),
|
|
28
|
+
/** Must match an inventory entry of the same kind. */
|
|
29
|
+
name: z.string().min(1),
|
|
30
|
+
reason: z.string().min(1),
|
|
31
|
+
/** The Linear ticket that owns reconciling the docs. */
|
|
32
|
+
ticket: z.string().regex(/^F-\d+$/),
|
|
33
|
+
});
|
|
34
|
+
export const fidelityInventorySchema = z.strictObject({
|
|
35
|
+
twin: z.string().min(1),
|
|
36
|
+
package: z.string().min(1),
|
|
37
|
+
/** ISO date (YYYY-MM-DD) of the last human review of this inventory. */
|
|
38
|
+
updated: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
39
|
+
notes: z.string().optional(),
|
|
40
|
+
tools: z.array(fidelitySurfaceSchema).min(1),
|
|
41
|
+
rest: z.array(fidelitySurfaceSchema),
|
|
42
|
+
doc_drift: z.array(fidelityDocDriftSchema).default([]),
|
|
43
|
+
});
|
|
44
|
+
export function loadFidelityInventory(path) {
|
|
45
|
+
return fidelityInventorySchema.parse(JSON.parse(readFileSync(path, "utf8")));
|
|
46
|
+
}
|
|
47
|
+
const TOOL_NAME_HEADERS = new Set(["tool"]);
|
|
48
|
+
const REST_NAME_HEADERS = new Set(["route", "endpoint", "surface"]);
|
|
49
|
+
function splitTableRow(line) {
|
|
50
|
+
return line
|
|
51
|
+
.replace(/^\s*\|/, "")
|
|
52
|
+
.replace(/\|\s*$/, "")
|
|
53
|
+
.split("|")
|
|
54
|
+
.map((cell) => cell.trim());
|
|
55
|
+
}
|
|
56
|
+
function isSeparatorRow(cells) {
|
|
57
|
+
return cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Expand one name cell into surface names. Backticked spans are the names;
|
|
61
|
+
* a span with no `.`, `/`, or space is shorthand for a sibling of the first
|
|
62
|
+
* span (Slack-style `` `reactions.add` / `remove` / `get` ``) and inherits
|
|
63
|
+
* its dotted prefix. Cells with no backticks name the surface verbatim
|
|
64
|
+
* (e.g. "Any unsupported path").
|
|
65
|
+
*/
|
|
66
|
+
export function expandSurfaceCell(cell) {
|
|
67
|
+
const spans = [...cell.matchAll(/`([^`]+)`/g)].map((match) => match[1].trim());
|
|
68
|
+
if (spans.length === 0) {
|
|
69
|
+
const text = cell.trim();
|
|
70
|
+
return text.length > 0 ? [text] : [];
|
|
71
|
+
}
|
|
72
|
+
const [first, ...rest] = spans;
|
|
73
|
+
const lastDot = first.lastIndexOf(".");
|
|
74
|
+
const prefix = lastDot >= 0 ? first.slice(0, lastDot + 1) : "";
|
|
75
|
+
return [
|
|
76
|
+
first,
|
|
77
|
+
...rest.map((span) => /[./ ]/.test(span) || prefix === "" ? span : `${prefix}${span}`),
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse every markdown table whose header names surfaces of `kind` + Tier.
|
|
82
|
+
* The Heat column (ENDPOINT-TIERS.md) is optional: parsed when the header
|
|
83
|
+
* names it, omitted otherwise, so pre-heat tables stay legal.
|
|
84
|
+
*/
|
|
85
|
+
export function parseFidelityDocRows(markdown, kind) {
|
|
86
|
+
const nameHeaders = kind === "tool" ? TOOL_NAME_HEADERS : REST_NAME_HEADERS;
|
|
87
|
+
const rows = [];
|
|
88
|
+
const lines = markdown.split("\n");
|
|
89
|
+
let nameIdx = -1;
|
|
90
|
+
let tierIdx = -1;
|
|
91
|
+
let heatIdx = -1;
|
|
92
|
+
let inTable = false;
|
|
93
|
+
for (const line of lines) {
|
|
94
|
+
if (!line.trimStart().startsWith("|")) {
|
|
95
|
+
inTable = false;
|
|
96
|
+
nameIdx = -1;
|
|
97
|
+
tierIdx = -1;
|
|
98
|
+
heatIdx = -1;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const cells = splitTableRow(line);
|
|
102
|
+
if (!inTable) {
|
|
103
|
+
const headers = cells.map((cell) => cell.toLowerCase());
|
|
104
|
+
nameIdx = headers.findIndex((header) => nameHeaders.has(header));
|
|
105
|
+
tierIdx = headers.findIndex((header) => header === "tier");
|
|
106
|
+
heatIdx = headers.findIndex((header) => header === "heat");
|
|
107
|
+
inTable = true;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (isSeparatorRow(cells) || nameIdx < 0 || tierIdx < 0)
|
|
111
|
+
continue;
|
|
112
|
+
const fidelity = cells[tierIdx] ?? "";
|
|
113
|
+
const heat = heatIdx >= 0 ? { heat: cells[heatIdx] ?? "" } : {};
|
|
114
|
+
for (const name of expandSurfaceCell(cells[nameIdx] ?? "")) {
|
|
115
|
+
rows.push({ name, fidelity, ...heat });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return rows;
|
|
119
|
+
}
|
|
120
|
+
// ─── Lint: inventory ⇔ docs, both directions ─────────────────────────────────
|
|
121
|
+
/**
|
|
122
|
+
* 1:1-lint the inventory against the FIDELITY doc tables. Returns human-
|
|
123
|
+
* readable problems (empty = clean). Directions checked per kind:
|
|
124
|
+
* every doc row must be in the inventory with the same fidelity tier, and
|
|
125
|
+
* every inventory entry must be documented unless a `doc_drift` entry
|
|
126
|
+
* (with its owning ticket) declares the gap. A drift declaration whose
|
|
127
|
+
* name IS documented is stale and reported, so drift entries self-expire.
|
|
128
|
+
*/
|
|
129
|
+
export function lintFidelityInventory(inventory, docs) {
|
|
130
|
+
const problems = [];
|
|
131
|
+
for (const kind of ["tool", "rest"]) {
|
|
132
|
+
const sources = docs.filter((doc) => doc.kind === kind);
|
|
133
|
+
if (sources.length === 0)
|
|
134
|
+
continue;
|
|
135
|
+
const labels = sources.map((doc) => doc.label).join(", ");
|
|
136
|
+
const entries = kind === "tool" ? inventory.tools : inventory.rest;
|
|
137
|
+
const drift = new Map(inventory.doc_drift.filter((d) => d.kind === kind).map((d) => [d.name, d]));
|
|
138
|
+
const inventoryByName = new Map();
|
|
139
|
+
for (const entry of entries) {
|
|
140
|
+
if (inventoryByName.has(entry.name)) {
|
|
141
|
+
problems.push(`inventory ${kind} '${entry.name}' is listed twice`);
|
|
142
|
+
}
|
|
143
|
+
inventoryByName.set(entry.name, entry);
|
|
144
|
+
}
|
|
145
|
+
const documented = new Map();
|
|
146
|
+
for (const source of sources) {
|
|
147
|
+
for (const row of parseFidelityDocRows(source.markdown, kind)) {
|
|
148
|
+
const existing = documented.get(row.name);
|
|
149
|
+
if (existing && existing.fidelity !== row.fidelity) {
|
|
150
|
+
problems.push(`${labels}: ${kind} '${row.name}' is documented twice with conflicting tiers ('${existing.fidelity}' vs '${row.fidelity}')`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (existing &&
|
|
154
|
+
existing.heat !== undefined &&
|
|
155
|
+
row.heat !== undefined &&
|
|
156
|
+
existing.heat !== row.heat) {
|
|
157
|
+
problems.push(`${labels}: ${kind} '${row.name}' is documented twice with conflicting heat ('${existing.heat}' vs '${row.heat}')`);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
documented.set(row.name, row);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
for (const [name, row] of documented) {
|
|
164
|
+
const entry = inventoryByName.get(name);
|
|
165
|
+
if (!entry) {
|
|
166
|
+
problems.push(`${labels}: ${kind} '${name}' documented but missing from fidelity.inventory.json`);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (entry.fidelity !== row.fidelity) {
|
|
170
|
+
problems.push(`${kind} '${name}': inventory says fidelity '${entry.fidelity}' but ${labels} says '${row.fidelity}'`);
|
|
171
|
+
}
|
|
172
|
+
if (row.heat !== undefined && entry.heat !== row.heat) {
|
|
173
|
+
problems.push(`${kind} '${name}': inventory says heat '${entry.heat}' but ${labels} says '${row.heat}'`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (const entry of entries) {
|
|
177
|
+
if (documented.has(entry.name))
|
|
178
|
+
continue;
|
|
179
|
+
const declared = drift.get(entry.name);
|
|
180
|
+
if (!declared) {
|
|
181
|
+
problems.push(`${kind} '${entry.name}' is in fidelity.inventory.json but undocumented in ${labels}; add the row or declare doc_drift`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const declared of drift.values()) {
|
|
185
|
+
if (!inventoryByName.has(declared.name)) {
|
|
186
|
+
problems.push(`doc_drift ${kind} '${declared.name}' (${declared.ticket}) matches no inventory entry`);
|
|
187
|
+
}
|
|
188
|
+
if (documented.has(declared.name)) {
|
|
189
|
+
problems.push(`doc_drift ${kind} '${declared.name}' (${declared.ticket}) is stale — ${labels} now documents it; remove the declaration`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return problems;
|
|
194
|
+
}
|
|
195
|
+
/** Set-compare tool names: inventory vs the live `listTools()` surface. */
|
|
196
|
+
export function compareToolNames(inventoryNames, liveNames) {
|
|
197
|
+
const inventory = new Set(inventoryNames);
|
|
198
|
+
const live = new Set(liveNames);
|
|
199
|
+
return {
|
|
200
|
+
missing: [...live].filter((name) => !inventory.has(name)).sort(),
|
|
201
|
+
extra: [...inventory].filter((name) => !live.has(name)).sort(),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=fidelity-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fidelity-inventory.js","sourceRoot":"","sources":["../src/fidelity-inventory.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,qEAAqE;AACrE,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,uEAAuE;AACvE,2EAA2E;AAC3E,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAG9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD,uEAAuE;IACvE,IAAI,EAAE,CAAC,CAAC,MAAM,E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YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAC9B,cAAwB,EACxB,SAAmB;IAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;KAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type FidelityInventory } from "./fidelity-inventory.js";
|
|
2
|
+
export type ParityState = Record<string, unknown>;
|
|
3
|
+
export interface ParityStep {
|
|
4
|
+
tool: string;
|
|
5
|
+
arguments?: Record<string, unknown> | ((state: ParityState) => Record<string, unknown>);
|
|
6
|
+
/** Pull cross-call state (ids, numbers, shas) out of the response body. */
|
|
7
|
+
capture?: (body: unknown, state: ParityState) => void;
|
|
8
|
+
/** Expected HTTP status; default: any 2xx. */
|
|
9
|
+
status?: number;
|
|
10
|
+
/** Extra body assertion; return a problem string to fail the step. */
|
|
11
|
+
verify?: (body: unknown) => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface ParityRestProbe {
|
|
14
|
+
/** Label in the report, e.g. "unsupported-rest". */
|
|
15
|
+
surface: string;
|
|
16
|
+
method?: string;
|
|
17
|
+
/** Session-relative path, e.g. "/repos/acme/api/actions/runs". */
|
|
18
|
+
path: string;
|
|
19
|
+
/** Expected HTTP status. */
|
|
20
|
+
status: number;
|
|
21
|
+
/** Assert the body carries a `fidelity: "unsupported"` marker. */
|
|
22
|
+
expectUnsupportedEnvelope?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ParityAppLike {
|
|
25
|
+
request(path: string | Request, init?: RequestInit): Response | Promise<Response>;
|
|
26
|
+
}
|
|
27
|
+
export interface RunParityOptions {
|
|
28
|
+
app: ParityAppLike;
|
|
29
|
+
twin: string;
|
|
30
|
+
inventory: FidelityInventory;
|
|
31
|
+
/** `listTools()` names from the twin source — the code truth. */
|
|
32
|
+
liveToolNames: string[];
|
|
33
|
+
steps: ParityStep[];
|
|
34
|
+
restProbes?: ParityRestProbe[];
|
|
35
|
+
/** Session id; default "fidelity-parity". */
|
|
36
|
+
sid?: string;
|
|
37
|
+
/** JWT secret; default env TWIN_AUTH_SECRET or the engine dev secret. */
|
|
38
|
+
secret?: string;
|
|
39
|
+
/** Extra JWT claims (login, team_id, account_id, ...). */
|
|
40
|
+
claims?: Record<string, unknown>;
|
|
41
|
+
/** Applied to every step without its own `verify` (twin error envelopes). */
|
|
42
|
+
stepVerify?: (body: unknown) => string | undefined;
|
|
43
|
+
/** Optional live upstream probes; entries are appended to the report. */
|
|
44
|
+
live?: () => Promise<unknown[]>;
|
|
45
|
+
}
|
|
46
|
+
export interface ParityResult {
|
|
47
|
+
ok: boolean;
|
|
48
|
+
failures: string[];
|
|
49
|
+
report: unknown[];
|
|
50
|
+
}
|
|
51
|
+
export declare function runFidelityParity(options: RunParityOptions): Promise<ParityResult>;
|
|
52
|
+
/** Script entrypoint: run, print the JSON report, set the exit code. */
|
|
53
|
+
export declare function runParityCli(options: RunParityOptions): Promise<ParityResult>;
|
|
54
|
+
export { compareToolNames, expandSurfaceCell, fidelityDocDriftSchema, fidelityInventorySchema, fidelitySurfaceSchema, heatTierSchema, lintFidelityInventory, loadFidelityInventory, parseFidelityDocRows, } from "./fidelity-inventory.js";
|
|
55
|
+
export type { FidelityDocDrift, FidelityDocRow, FidelityDocSource, FidelityInventory, FidelitySurface, HeatTier, } from "./fidelity-inventory.js";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// Shared fidelity:parity runner (F-730). One engine-level runner; each twin
|
|
4
|
+
// supplies declarative scenario data — an ordered, stateful chain of MCP
|
|
5
|
+
// calls with cross-call captures (a PR number, a charge id, a message ts) —
|
|
6
|
+
// plus its structured fidelity inventory. No per-twin runner copies (M1
|
|
7
|
+
// "twin-infra copies: 0" gate).
|
|
8
|
+
//
|
|
9
|
+
// The runner asserts three rings agree before it reports green:
|
|
10
|
+
// 1. live tool list (code truth from listTools())
|
|
11
|
+
// 2. fidelity.inventory.json tools (the machine-readable inventory)
|
|
12
|
+
// 3. scenario step coverage (every inventory tool exercised)
|
|
13
|
+
// and that every step answers its expected status through the frozen
|
|
14
|
+
// `POST /s/:sid/mcp/call` surface. Optional REST probes pin the loud-501
|
|
15
|
+
// unsupported envelope; an optional `live` hook lets a twin compare
|
|
16
|
+
// read-only shapes against the real upstream (e.g. `gh api`).
|
|
17
|
+
import { sign } from "hono/jwt";
|
|
18
|
+
import { compareToolNames, } from "./fidelity-inventory.js";
|
|
19
|
+
function bodyKeys(body) {
|
|
20
|
+
if (Array.isArray(body))
|
|
21
|
+
return ["array"];
|
|
22
|
+
if (body && typeof body === "object") {
|
|
23
|
+
return Object.keys(body).sort();
|
|
24
|
+
}
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
export async function runFidelityParity(options) {
|
|
28
|
+
const sid = options.sid ?? "fidelity-parity";
|
|
29
|
+
const secret = options.secret ?? process.env.TWIN_AUTH_SECRET ?? "dev-only-insecure-secret";
|
|
30
|
+
const token = await sign({ sid, exp: Math.floor(Date.now() / 1000) + 3600, ...options.claims }, secret);
|
|
31
|
+
const base = `/s/${sid}`;
|
|
32
|
+
const failures = [];
|
|
33
|
+
const report = [];
|
|
34
|
+
// Ring 1 ⇔ ring 2: inventory tools must equal the live tool list.
|
|
35
|
+
const inventoryNames = options.inventory.tools.map((entry) => entry.name);
|
|
36
|
+
const inventoryDiff = compareToolNames(inventoryNames, options.liveToolNames);
|
|
37
|
+
for (const name of inventoryDiff.missing) {
|
|
38
|
+
failures.push(`tool '${name}' is live in listTools() but missing from fidelity.inventory.json`);
|
|
39
|
+
}
|
|
40
|
+
for (const name of inventoryDiff.extra) {
|
|
41
|
+
failures.push(`tool '${name}' is in fidelity.inventory.json but not in listTools()`);
|
|
42
|
+
}
|
|
43
|
+
// Ring 2 ⇔ ring 3: every inventory tool needs at least one scenario step.
|
|
44
|
+
const covered = new Set(options.steps.map((step) => step.tool));
|
|
45
|
+
for (const name of inventoryNames) {
|
|
46
|
+
if (!covered.has(name))
|
|
47
|
+
failures.push(`no parity scenario step covers tool '${name}'`);
|
|
48
|
+
}
|
|
49
|
+
for (const tool of covered) {
|
|
50
|
+
if (!inventoryNames.includes(tool)) {
|
|
51
|
+
failures.push(`scenario step calls '${tool}' which is not in fidelity.inventory.json`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const state = {};
|
|
55
|
+
for (const step of options.steps) {
|
|
56
|
+
const args = typeof step.arguments === "function" ? step.arguments(state) : step.arguments ?? {};
|
|
57
|
+
const response = await options.app.request(`${base}/mcp/call`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
60
|
+
body: JSON.stringify({ tool: step.tool, arguments: args }),
|
|
61
|
+
});
|
|
62
|
+
const body = await response.json().catch(() => ({}));
|
|
63
|
+
const expected = step.status === undefined ? response.ok : response.status === step.status;
|
|
64
|
+
if (!expected) {
|
|
65
|
+
failures.push(`${step.tool}: expected ${step.status ?? "2xx"}, got ${response.status} ${JSON.stringify(body).slice(0, 300)}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const problem = (step.verify ?? options.stepVerify)?.(body);
|
|
69
|
+
if (problem)
|
|
70
|
+
failures.push(`${step.tool}: ${problem}`);
|
|
71
|
+
step.capture?.(body, state);
|
|
72
|
+
}
|
|
73
|
+
report.push({ tool: step.tool, status: response.status, ok: response.ok, keys: bodyKeys(body) });
|
|
74
|
+
}
|
|
75
|
+
for (const probe of options.restProbes ?? []) {
|
|
76
|
+
const response = await options.app.request(`${base}${probe.path}`, {
|
|
77
|
+
method: probe.method ?? "GET",
|
|
78
|
+
headers: { authorization: `Bearer ${token}` },
|
|
79
|
+
});
|
|
80
|
+
const body = await response.json().catch(() => ({}));
|
|
81
|
+
if (response.status !== probe.status) {
|
|
82
|
+
failures.push(`${probe.surface}: expected ${probe.status}, got ${response.status}`);
|
|
83
|
+
}
|
|
84
|
+
if (probe.expectUnsupportedEnvelope && !JSON.stringify(body).includes('"fidelity":"unsupported"')) {
|
|
85
|
+
failures.push(`${probe.surface}: body does not carry the fidelity:"unsupported" envelope`);
|
|
86
|
+
}
|
|
87
|
+
report.push({ surface: probe.surface, status: response.status, body });
|
|
88
|
+
}
|
|
89
|
+
if (options.live) {
|
|
90
|
+
report.push(...(await options.live()));
|
|
91
|
+
}
|
|
92
|
+
return { ok: failures.length === 0, failures, report };
|
|
93
|
+
}
|
|
94
|
+
/** Script entrypoint: run, print the JSON report, set the exit code. */
|
|
95
|
+
export async function runParityCli(options) {
|
|
96
|
+
const result = await runFidelityParity(options);
|
|
97
|
+
console.log(JSON.stringify({
|
|
98
|
+
twin: options.twin,
|
|
99
|
+
tools: options.inventory.tools.length,
|
|
100
|
+
rest_surfaces: options.inventory.rest.length,
|
|
101
|
+
ok: result.ok,
|
|
102
|
+
failures: result.failures,
|
|
103
|
+
report: result.report,
|
|
104
|
+
}, null, 2));
|
|
105
|
+
if (!result.ok) {
|
|
106
|
+
console.error(`fidelity:parity FAILED for ${options.twin} (${result.failures.length} problem(s))`);
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
export { compareToolNames, expandSurfaceCell, fidelityDocDriftSchema, fidelityInventorySchema, fidelitySurfaceSchema, heatTierSchema, lintFidelityInventory, loadFidelityInventory, parseFidelityDocRows, } from "./fidelity-inventory.js";
|
|
112
|
+
//# sourceMappingURL=parity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parity.js","sourceRoot":"","sources":["../src/parity.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,gCAAgC;AAChC,EAAE;AACF,gEAAgE;AAChE,oDAAoD;AACpD,sEAAsE;AACtE,+DAA+D;AAC/D,qEAAqE;AACrE,yEAAyE;AACzE,oEAAoE;AACpE,8DAA8D;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAyDjC,SAAS,QAAQ,CAAC,IAAa;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,IAAI,CAAC,IAA+B,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAyB;IAC/D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,iBAAiB,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IAC5F,MAAM,KAAK,GAAG,MAAM,IAAI,CACtB,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAA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gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC"}
|
|
@@ -13,6 +13,21 @@ export declare function makeDeltaSink(): {
|
|
|
13
13
|
};
|
|
14
14
|
/** Hostnames the boot guard treats as loopback binds. */
|
|
15
15
|
export declare function isLoopbackHost(value: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* F-708: self-generate `TWIN_AUTH_SECRET` on first boot. An env-injected
|
|
18
|
+
* secret always wins (pome-cloud injects per-tenant secrets — that contract
|
|
19
|
+
* is untouched), and loopback binds keep the dev-fallback path. Otherwise
|
|
20
|
+
* the secret persisted at the compose-era contract location
|
|
21
|
+
* `.pome-data/<twin>/secret` (cwd-relative; `POME_TWIN_DATA_DIR` overrides
|
|
22
|
+
* the directory) is reused, or a fresh 32-byte hex secret is generated,
|
|
23
|
+
* persisted there, and printed once to stdout so the operator can mint JWTs.
|
|
24
|
+
*
|
|
25
|
+
* The resolved secret lands in `process.env.TWIN_AUTH_SECRET`, which is
|
|
26
|
+
* process-global by design: the engine's auth (`resolveAuthSecret`) reads
|
|
27
|
+
* the env, so one process serves one secret — the frozen boot contract is
|
|
28
|
+
* one twin per process, and a multi-twin process shares the first secret.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureTwinAuthSecret(twin: string, host: string): void;
|
|
16
31
|
export declare function shadowedPrefix(routePath: string): string | null;
|
|
17
32
|
export declare function assertUniqueToolNames<TDomain>(tools: ReadonlyArray<ToolSpec<TDomain>>, twinId: string): void;
|
|
18
33
|
export declare function findTool<TDb, TSeed, TDomain>(definition: TwinDefinition<TDb, TSeed, TDomain>, name: string): ToolSpec<TDomain>;
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// out of server.ts (F-685) purely for module-size hygiene; everything a twin
|
|
5
5
|
// may import (TwinBootError, isLoopbackHost) is re-exported from server.ts,
|
|
6
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";
|
|
7
10
|
import { RESERVED_SESSION_PREFIXES } from "./index.js";
|
|
8
11
|
import { UnknownToolError } from "./errors.js";
|
|
9
12
|
export class TwinBootError extends Error {
|
|
@@ -29,6 +32,99 @@ export function makeDeltaSink() {
|
|
|
29
32
|
export function isLoopbackHost(value) {
|
|
30
33
|
return value === "127.0.0.1" || value === "::1" || value === "localhost";
|
|
31
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
|
+
}
|
|
32
128
|
export function shadowedPrefix(routePath) {
|
|
33
129
|
for (const prefix of RESERVED_SESSION_PREFIXES) {
|
|
34
130
|
if (routePath === prefix || routePath.startsWith(`${prefix}/`))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-helpers.js","sourceRoot":"","sources":["../src/server-helpers.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E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,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAY;IACzC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,WAAW;YAAE,MAAM,GAAG,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,EAAE,CAAC,IAAa,EAAE,QAAQ,GAAG,KAAK;IAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { type TwinDefinition } from "./index.js";
|
|
3
3
|
import { type RecorderStore } from "./recorder.js";
|
|
4
|
-
export { TwinBootError, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
4
|
+
export { TwinBootError, ensureTwinAuthSecret, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
5
5
|
export { createRecorderHandle, createRecorderStore, createFileBackedRecorderStore, resolveRecorderStore, toTwinHttpEventRow, POME_RECORDER_EVENTS_PATH, } from "./recorder.js";
|
|
6
6
|
export type { RecorderStore, RecorderStoreOptions, FileBackedRecorderStoreOptions, ErrorEnvelopeFn, } from "./recorder.js";
|
|
7
7
|
export { bearerAuth, requireAdminAuth, resolveAuthSecret } from "./auth.js";
|
|
@@ -31,10 +31,10 @@ import { handleMcpJsonRpc, mcpMethodNotAllowed } from "./mcp-jsonrpc.js";
|
|
|
31
31
|
import { createRecorderHandle, resolveRecorderStore } from "./recorder.js";
|
|
32
32
|
import { redactSecrets } from "./redaction.js";
|
|
33
33
|
import { TwinError, envelopeFor } from "./errors.js";
|
|
34
|
-
import { POME_CORE_ROUTE_NAMES, TwinBootError, assertUniqueToolNames, findTool, isLoopbackHost, makeDeltaSink, readJson, shadowedPrefix, } from "./server-helpers.js";
|
|
34
|
+
import { POME_CORE_ROUTE_NAMES, TwinBootError, assertUniqueToolNames, ensureTwinAuthSecret, findTool, isLoopbackHost, makeDeltaSink, readJson, shadowedPrefix, } from "./server-helpers.js";
|
|
35
35
|
// Public boot surface consumed by twin entrypoints
|
|
36
|
-
// (`import {
|
|
37
|
-
export { TwinBootError, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
36
|
+
// (`import { ensureTwinAuthSecret, serve } from "@pome-sh/sdk/server"`).
|
|
37
|
+
export { TwinBootError, ensureTwinAuthSecret, isLoopbackHost, created, ok } from "./server-helpers.js";
|
|
38
38
|
export { createRecorderHandle, createRecorderStore, createFileBackedRecorderStore, resolveRecorderStore, toTwinHttpEventRow, POME_RECORDER_EVENTS_PATH, } from "./recorder.js";
|
|
39
39
|
export { bearerAuth, requireAdminAuth, resolveAuthSecret } from "./auth.js";
|
|
40
40
|
// Alternate serving bridges (anything that isn't @hono/node-server) must feed
|
|
@@ -314,11 +314,13 @@ export function createApp(definition, options = {}) {
|
|
|
314
314
|
*/
|
|
315
315
|
export async function serve(definition, options = {}) {
|
|
316
316
|
const hostname = options.hostname ?? "127.0.0.1";
|
|
317
|
-
// Contract boot guard: a twin must
|
|
318
|
-
//
|
|
317
|
+
// Contract boot guard: a twin must never serve real traffic with the dev
|
|
318
|
+
// fallback secret. Since F-708 a non-loopback bind with no env-injected
|
|
319
|
+
// secret self-generates + persists one instead of refusing to boot; a
|
|
320
|
+
// failed generation still throws before the app is built, so the process
|
|
319
321
|
// exits non-zero without ever listening.
|
|
320
|
-
if (options.port !== undefined && !isLoopbackHost(hostname)
|
|
321
|
-
|
|
322
|
+
if (options.port !== undefined && !isLoopbackHost(hostname)) {
|
|
323
|
+
ensureTwinAuthSecret(definition.id, hostname);
|
|
322
324
|
}
|
|
323
325
|
// Resolve the store once so `close()` can flush the same instance the app
|
|
324
326
|
// records into (durable when POME_RECORDER_EVENTS_PATH is set).
|