@pome-sh/cli 0.11.0 → 0.13.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/dist/build-info.json +3 -3
- package/dist/src/cli/checks-add.js +16 -0
- package/dist/src/cli/checks-lint.d.ts +1 -0
- package/dist/src/cli/checks-lint.js +59 -0
- package/dist/src/cli/criterion-binding.d.ts +41 -0
- package/dist/src/cli/criterion-binding.js +111 -0
- package/dist/src/cli/main.js +12 -0
- package/dist/src/runner/runTask.d.ts +2 -2
- package/dist/src/task/insertCriterion.js +6 -1
- package/dist/src/task/parseTask.d.ts +21 -0
- package/dist/src/task/parseTask.js +48 -1
- package/dist/src/task/taskSchema.d.ts +4 -4
- package/node_modules/@pome-sh/sdk/dist/checks.d.ts +18 -0
- package/node_modules/@pome-sh/sdk/dist/checks.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/failure-injection.js +7 -0
- package/node_modules/@pome-sh/sdk/dist/failure-injection.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/index.d.ts +8 -0
- package/node_modules/@pome-sh/sdk/dist/index.js +1 -0
- package/node_modules/@pome-sh/sdk/dist/index.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js +10 -0
- package/node_modules/@pome-sh/sdk/dist/mcp-jsonrpc.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/recorder.js +8 -4
- package/node_modules/@pome-sh/sdk/dist/recorder.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/request-capture.d.ts +31 -0
- package/node_modules/@pome-sh/sdk/dist/request-capture.js +59 -0
- package/node_modules/@pome-sh/sdk/dist/request-capture.js.map +1 -0
- package/node_modules/@pome-sh/sdk/dist/server.d.ts +1 -0
- package/node_modules/@pome-sh/sdk/dist/server.js +13 -0
- package/node_modules/@pome-sh/sdk/dist/server.js.map +1 -1
- package/node_modules/@pome-sh/sdk/package.json +2 -2
- package/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +6 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +2 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +14 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js +40 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/package.json +1 -1
- package/node_modules/@pome-sh/shared-types/trace-contract.json +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/check-params.d.ts +1 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-params.js +17 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-params.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/check-tape.d.ts +5 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-tape.js +159 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-tape.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/dist/src/checks.d.ts +2 -0
- package/node_modules/@pome-sh/twin-github/dist/src/checks.js +13 -4
- package/node_modules/@pome-sh/twin-github/dist/src/checks.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/domain/checks.d.ts +4 -4
- package/node_modules/@pome-sh/twin-github/dist/src/domain/github-domain.d.ts +5 -5
- package/node_modules/@pome-sh/twin-github/dist/src/domain/pulls.d.ts +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/routes.js +16 -2
- 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 +3 -3
- package/node_modules/@pome-sh/twin-github/dist/src/tools.d.ts +22 -21
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js +22 -0
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/package.json +3 -3
- package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js +9 -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/seed.d.ts +2 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/session.d.ts +3 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/session.js +72 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/session.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js +5 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/package.json +4 -4
- package/package.json +5 -5
- 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/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.d.ts +0 -39
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js +0 -33
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +0 -254
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +0 -122
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +0 -175
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js +0 -182
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.d.ts +0 -90
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js +0 -72
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.d.ts +0 -28
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js +0 -35
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.d.ts +0 -31
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js +0 -76
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/manifest.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +0 -331
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +0 -33
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +0 -65
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +0 -455
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +0 -39
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +0 -47
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +0 -25
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js +0 -27
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +0 -100
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +0 -193
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +0 -64
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +0 -112
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +0 -26
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js +0 -61
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +0 -42
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js +0 -104
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +0 -57
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +0 -102
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +0 -134
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +0 -152
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +0 -480
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js +0 -270
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +0 -2
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js +0 -152
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.d.ts +0 -257
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js +0 -335
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.d.ts +0 -208
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js +0 -170
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +0 -14
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +0 -46
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +0 -1006
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js +0 -263
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +0 -53
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js +0 -51
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +0 -80
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js +0 -98
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.d.ts +0 -859
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js +0 -60
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js.map +0 -1
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/manifest-schema.json +0 -68
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/package.json +0 -55
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/trace-contract.json +0 -41
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Twin-core recorder (F-681 / F-720). Home: `packages/sdk/src/recorder.ts`
|
|
3
|
-
// (`@pome-sh/sdk`); all first-party twins and the CLI harness consume it.
|
|
4
|
-
// In-memory recorder + `handle()` helper. `handle({mutation}, fn)` wraps a
|
|
5
|
-
// Hono handler so every wrapped route emits a `RecorderEvent` matching
|
|
6
|
-
// `recording-spec.md` v1.0:
|
|
7
|
-
// - `latency_ms` boundary: start = Date.now() before request body parse,
|
|
8
|
-
// end = Date.now() immediately before c.json() writes the response.
|
|
9
|
-
// - `state_mutation` = the declared route/tool mutation flag.
|
|
10
|
-
// - `error` = response_body.message when status >= 400, null otherwise.
|
|
11
|
-
// - Memory is bounded by session timeout × max-rps.
|
|
12
|
-
// ── Write-through contract (F-720) ──────────────────────────────────────────
|
|
13
|
-
// Acceptance: an event is *accepted* once `RecorderStore.record()` returns.
|
|
14
|
-
// Heap stores retain it in memory; durable stores queue it for append.
|
|
15
|
-
// `flush()` / `close()` are the durability barrier; `record()` is not fsync.
|
|
16
|
-
// Recording pipeline: optional `recordingProjection` (twin-supplied) runs
|
|
17
|
-
// first, then `createRecorderHandle` redacts *before* every `store.record()`
|
|
18
|
-
// call — including custom stores and direct `recorder.record()` — so no
|
|
19
|
-
// store ever sees unredacted secrets. Stores must not re-emit raw bodies.
|
|
20
|
-
// Persisted row shape (F-698): durable stores write one redacted
|
|
21
|
-
// `TwinHttpEvent` NDJSON line per accepted event (shared-types
|
|
22
|
-
// `twinHttpEventSchema`) so on-disk `events.jsonl` matches the uploaded
|
|
23
|
-
// raw-trace byte shape. The in-memory mirror / `GET /_pome/events` still
|
|
24
|
-
// exposes legacy `RecorderEvent` rows.
|
|
25
|
-
// `flush()`: optional. When present, resolves after every accepted event is
|
|
26
|
-
// durable on the store's backing medium (fsync for file-backed). In-memory
|
|
27
|
-
// stores may omit it (no-op if called via a handle that forwards). Callers
|
|
28
|
-
// that need crash-bounded loss (≤ in-flight event) must await `flush()`
|
|
29
|
-
// before relying on the on-disk tape, or use a store that fsyncs on each
|
|
30
|
-
// `record()` (F-698 production default).
|
|
31
|
-
// `close()`: optional. When present, flushes pending writes, releases the
|
|
32
|
-
// backing resource, and is idempotent. After `close()`, further `record()`
|
|
33
|
-
// calls are undefined (stores should throw or no-op). Callers must await
|
|
34
|
-
// `close()` (or at least `flush()`) before upload/finalize so every accepted
|
|
35
|
-
// write has either landed on disk or surfaced as a flush/close error.
|
|
36
|
-
// Bounded stores (`maxEvents`): the cap applies only to the in-memory mirror
|
|
37
|
-
// used by `events()` / `GET /_pome/events` (memory pressure). The durable
|
|
38
|
-
// NDJSON tape is append-only and retains every accepted write — including
|
|
39
|
-
// rows later dropped from the heap mirror — so crash-safe upload reads the
|
|
40
|
-
// tape, not `events()`.
|
|
41
|
-
// Default runtime behavior: `createRecorderStore()` remains heap-only.
|
|
42
|
-
// Set `POME_RECORDER_EVENTS_PATH` (or pass `createFileBackedRecorderStore`)
|
|
43
|
-
// for durable write-through; twin boot resolves via `resolveRecorderStore()`.
|
|
44
|
-
import { randomUUID } from "node:crypto";
|
|
45
|
-
import { closeSync, createWriteStream, fsync, mkdirSync, openSync, } from "node:fs";
|
|
46
|
-
import { dirname } from "node:path";
|
|
47
|
-
import { envelopeFor } from "./errors.js";
|
|
48
|
-
import { redactEvent } from "./redaction.js";
|
|
49
|
-
export function createRecorderStore(options = {}) {
|
|
50
|
-
const items = [];
|
|
51
|
-
const cap = options.maxEvents !== undefined ? Math.max(1, options.maxEvents) : undefined;
|
|
52
|
-
let droppedCount = 0;
|
|
53
|
-
return {
|
|
54
|
-
record(event) {
|
|
55
|
-
items.push(event);
|
|
56
|
-
if (cap !== undefined) {
|
|
57
|
-
while (items.length > cap) {
|
|
58
|
-
items.shift();
|
|
59
|
-
droppedCount += 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
events() {
|
|
64
|
-
return [...items];
|
|
65
|
-
},
|
|
66
|
-
count() {
|
|
67
|
-
return items.length;
|
|
68
|
-
},
|
|
69
|
-
dropped() {
|
|
70
|
-
return droppedCount;
|
|
71
|
-
},
|
|
72
|
-
async flush() {
|
|
73
|
-
// Heap-only: accepted === durable for this store.
|
|
74
|
-
},
|
|
75
|
-
async close() {
|
|
76
|
-
// No backing resource.
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Env key for the durable recorder tape. When set, twin boot paths and the
|
|
82
|
-
* self-host harness use `createFileBackedRecorderStore` instead of heap-only.
|
|
83
|
-
* Architecture (F-698 / §9 Q3): recorder *transport* lives in twin-core
|
|
84
|
-
* (`packages/sdk`); twins inherit durability by reading this env.
|
|
85
|
-
*/
|
|
86
|
-
export const POME_RECORDER_EVENTS_PATH = "POME_RECORDER_EVENTS_PATH";
|
|
87
|
-
/**
|
|
88
|
-
* Wrap a legacy `RecorderEvent` into the unified `TwinHttpEvent` NDJSON row
|
|
89
|
-
* shape used by uploaded `events.jsonl` (FDRS-398). Pass-through only when
|
|
90
|
-
* `kind` is already `"TwinHttpEvent"`; any other kind is re-wrapped so the
|
|
91
|
-
* durable tape never persists a mismatched discriminator. Disk rows from the
|
|
92
|
-
* durable store use this shape so finalize/upload does not need a second wrap
|
|
93
|
-
* for crash-streamed events.
|
|
94
|
-
*/
|
|
95
|
-
export function toTwinHttpEventRow(event) {
|
|
96
|
-
const maybeKind = event.kind;
|
|
97
|
-
if (maybeKind === "TwinHttpEvent") {
|
|
98
|
-
const existing = event;
|
|
99
|
-
return {
|
|
100
|
-
...existing,
|
|
101
|
-
event_id: typeof existing.event_id === "string" ? existing.event_id : event.request_id,
|
|
102
|
-
parent_id: null,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
...event,
|
|
107
|
-
kind: "TwinHttpEvent",
|
|
108
|
-
event_id: event.request_id,
|
|
109
|
-
parent_id: null,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Durable recorder store (F-720 contract / F-698 implementation).
|
|
114
|
-
*
|
|
115
|
-
* Keeps an in-memory mirror of legacy `RecorderEvent` rows for `events()` /
|
|
116
|
-
* `GET /_pome/events` (unchanged API), and appends each accepted event as a
|
|
117
|
-
* `TwinHttpEvent` NDJSON line so on-disk `events.jsonl` matches the uploaded
|
|
118
|
-
* raw-trace byte shape. `flush()` drains pending writes and rethrows the
|
|
119
|
-
* first append/fsync failure; `fsync` (default true) bounds crash loss to
|
|
120
|
-
* the in-flight event. `maxEvents` caps only the heap mirror — the NDJSON
|
|
121
|
-
* tape stays append-only.
|
|
122
|
-
*/
|
|
123
|
-
export function createFileBackedRecorderStore(options) {
|
|
124
|
-
const items = [];
|
|
125
|
-
const cap = options.maxEvents !== undefined ? Math.max(1, options.maxEvents) : undefined;
|
|
126
|
-
let droppedCount = 0;
|
|
127
|
-
let closed = false;
|
|
128
|
-
const doFsync = options.fsync !== false;
|
|
129
|
-
mkdirSync(dirname(options.path), { recursive: true });
|
|
130
|
-
// Open the fd synchronously so fsync never races createWriteStream's
|
|
131
|
-
// async open (which can leave `writer.fd` undefined and silently skip
|
|
132
|
-
// durability on the first write).
|
|
133
|
-
const fd = openSync(options.path, "a");
|
|
134
|
-
const writer = createWriteStream(options.path, { fd, autoClose: false });
|
|
135
|
-
const pending = new Set();
|
|
136
|
-
// First append/fsync failure is retained so a later flush()/close() still
|
|
137
|
-
// reports it even after the rejected promise leaves `pending`.
|
|
138
|
-
let writeFailure = null;
|
|
139
|
-
function enqueueWrite(line) {
|
|
140
|
-
const write = new Promise((resolve, reject) => {
|
|
141
|
-
writer.write(line, (err) => {
|
|
142
|
-
if (err) {
|
|
143
|
-
reject(err);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (!doFsync) {
|
|
147
|
-
resolve();
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
fsync(fd, (fsyncErr) => (fsyncErr ? reject(fsyncErr) : resolve()));
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
pending.add(write);
|
|
154
|
-
// Handle rejection here so a failed write before flush() is not an
|
|
155
|
-
// unhandled rejection, and so flush() can still surface the error after
|
|
156
|
-
// the promise has left `pending`.
|
|
157
|
-
void write.then(() => {
|
|
158
|
-
pending.delete(write);
|
|
159
|
-
}, (err) => {
|
|
160
|
-
pending.delete(write);
|
|
161
|
-
if (!writeFailure) {
|
|
162
|
-
writeFailure = err instanceof Error ? err : new Error(String(err));
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
async function flush() {
|
|
167
|
-
while (pending.size > 0) {
|
|
168
|
-
// allSettled: individual failures are already captured in writeFailure;
|
|
169
|
-
// awaiting a rejected member of `pending` must not short-circuit drain.
|
|
170
|
-
await Promise.allSettled([...pending]);
|
|
171
|
-
}
|
|
172
|
-
if (writeFailure) {
|
|
173
|
-
const err = writeFailure;
|
|
174
|
-
writeFailure = null;
|
|
175
|
-
throw err;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
record(event) {
|
|
180
|
-
if (closed) {
|
|
181
|
-
throw new Error("RecorderStore.record() after close()");
|
|
182
|
-
}
|
|
183
|
-
items.push(event);
|
|
184
|
-
if (cap !== undefined) {
|
|
185
|
-
while (items.length > cap) {
|
|
186
|
-
items.shift();
|
|
187
|
-
droppedCount += 1;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
enqueueWrite(`${JSON.stringify(toTwinHttpEventRow(event))}\n`);
|
|
191
|
-
},
|
|
192
|
-
events() {
|
|
193
|
-
return [...items];
|
|
194
|
-
},
|
|
195
|
-
count() {
|
|
196
|
-
return items.length;
|
|
197
|
-
},
|
|
198
|
-
dropped() {
|
|
199
|
-
return droppedCount;
|
|
200
|
-
},
|
|
201
|
-
flush,
|
|
202
|
-
async close() {
|
|
203
|
-
if (closed) {
|
|
204
|
-
await flush();
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
closed = true;
|
|
208
|
-
await flush();
|
|
209
|
-
await new Promise((resolve, reject) => {
|
|
210
|
-
writer.end((err) => {
|
|
211
|
-
try {
|
|
212
|
-
closeSync(fd);
|
|
213
|
-
}
|
|
214
|
-
catch (closeErr) {
|
|
215
|
-
reject(err ?? closeErr);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (err)
|
|
219
|
-
reject(err);
|
|
220
|
-
else
|
|
221
|
-
resolve();
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Resolve the recorder store for a twin boot: durable file-backed when
|
|
229
|
-
* `POME_RECORDER_EVENTS_PATH` is set, otherwise the in-memory default.
|
|
230
|
-
*/
|
|
231
|
-
export function resolveRecorderStore(options = {}) {
|
|
232
|
-
const path = process.env[POME_RECORDER_EVENTS_PATH]?.trim();
|
|
233
|
-
if (path) {
|
|
234
|
-
return createFileBackedRecorderStore({ ...options, path });
|
|
235
|
-
}
|
|
236
|
-
return createRecorderStore(options);
|
|
237
|
-
}
|
|
238
|
-
export function createRecorderHandle(options) {
|
|
239
|
-
const store = options.store ?? createRecorderStore();
|
|
240
|
-
const errorEnvelope = options.errorEnvelope ?? envelopeFor;
|
|
241
|
-
const project = options.recordingProjection;
|
|
242
|
-
function accept(event) {
|
|
243
|
-
// Projection (optional) → secret redaction (always). Order is load-bearing:
|
|
244
|
-
// Gmail replaces MIME/attachment bytes with digests before scrubbing.
|
|
245
|
-
store.record(redactEvent(project ? project(event) : event));
|
|
246
|
-
}
|
|
247
|
-
function emit(c, started, requestBody, result, mutation, fidelity, error) {
|
|
248
|
-
const requestId = `req_${randomUUID()}`;
|
|
249
|
-
// FDRS-402 / FDRS-653 stamping (F-683: engine parity with the per-twin
|
|
250
|
-
// recorders it replaces): correlation_id persists the adapter's
|
|
251
|
-
// x-pome-correlation-id (falling back to the request id), and the task
|
|
252
|
-
// author's x-pome-scenario-step-id lands as the canonical task_step_id
|
|
253
|
-
// plus the legacy scenario_step_id key (frozen v1 trace format —
|
|
254
|
-
// preserve semantics, tolerant readers accept either).
|
|
255
|
-
const stepId = c.req.header("x-pome-scenario-step-id") ?? null;
|
|
256
|
-
const correlationHeader = c.req.header("x-pome-correlation-id") ?? null;
|
|
257
|
-
// Redaction is unconditional at the engine layer (F-681 / F-720): every
|
|
258
|
-
// event that reaches any store — including custom stores — is already
|
|
259
|
-
// scrubbed. Optional recordingProjection runs immediately before that.
|
|
260
|
-
accept({
|
|
261
|
-
ts: new Date().toISOString(),
|
|
262
|
-
run_id: options.runId,
|
|
263
|
-
twin: options.twin,
|
|
264
|
-
request_id: requestId,
|
|
265
|
-
correlation_id: correlationHeader ?? requestId,
|
|
266
|
-
task_step_id: stepId,
|
|
267
|
-
scenario_step_id: stepId,
|
|
268
|
-
step_id: null,
|
|
269
|
-
// FDRS-402 adapter-rich path: only twins that pin `stampToolCallId`
|
|
270
|
-
// persist the header here (github); the default tape stamps null.
|
|
271
|
-
tool_call_id: options.stampToolCallId ? correlationHeader : null,
|
|
272
|
-
method: c.req.method,
|
|
273
|
-
path: new URL(c.req.url).pathname,
|
|
274
|
-
request_body: requestBody,
|
|
275
|
-
status: result.status,
|
|
276
|
-
response_body: result.body,
|
|
277
|
-
latency_ms: Date.now() - started,
|
|
278
|
-
fidelity,
|
|
279
|
-
state_mutation: mutation,
|
|
280
|
-
state_delta: result.delta ?? null,
|
|
281
|
-
error,
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
record(event) {
|
|
286
|
-
accept(event);
|
|
287
|
-
},
|
|
288
|
-
events() {
|
|
289
|
-
return store.events();
|
|
290
|
-
},
|
|
291
|
-
count() {
|
|
292
|
-
return store.count?.() ?? store.events().length;
|
|
293
|
-
},
|
|
294
|
-
dropped() {
|
|
295
|
-
return store.dropped?.() ?? 0;
|
|
296
|
-
},
|
|
297
|
-
async flush() {
|
|
298
|
-
await store.flush?.();
|
|
299
|
-
},
|
|
300
|
-
async close() {
|
|
301
|
-
await store.close?.();
|
|
302
|
-
},
|
|
303
|
-
handle({ mutation, fidelity = "semantic", errorEnvelope: perCallEnvelope }, fn) {
|
|
304
|
-
const projectError = perCallEnvelope ?? errorEnvelope;
|
|
305
|
-
return async (c) => {
|
|
306
|
-
const started = Date.now();
|
|
307
|
-
let requestBody = null;
|
|
308
|
-
try {
|
|
309
|
-
requestBody =
|
|
310
|
-
c.req.method === "GET" || c.req.method === "HEAD"
|
|
311
|
-
? null
|
|
312
|
-
: await readRequestJson(c);
|
|
313
|
-
const result = await fn(c);
|
|
314
|
-
const effectiveMutation = result.mutation ?? mutation;
|
|
315
|
-
const errorMsg = result.status >= 400 ? extractMessage(result.body) ?? "request failed" : null;
|
|
316
|
-
emit(c, started, requestBody, result, effectiveMutation, fidelity, errorMsg);
|
|
317
|
-
return respondWith(c, result.status, result.body);
|
|
318
|
-
}
|
|
319
|
-
catch (caught) {
|
|
320
|
-
const envelope = projectError(caught);
|
|
321
|
-
// Failed routes never mutated state — record as state_mutation=false
|
|
322
|
-
// regardless of the declared flag. Per recording-spec § state_mutation,
|
|
323
|
-
// the field reflects whether the request *did* mutate state.
|
|
324
|
-
const errMsg = extractMessage(envelope.body) ??
|
|
325
|
-
(caught instanceof Error ? caught.message : "request failed");
|
|
326
|
-
emit(c, started, requestBody, { status: envelope.status, body: envelope.body }, false, fidelity, errMsg);
|
|
327
|
-
return respondWith(c, envelope.status, envelope.body);
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
// The Response constructor forbids a body on null-body statuses (204/205/
|
|
334
|
-
// 304) — `c.json(null, 204)` throws and surfaces as a 500. github's frozen
|
|
335
|
-
// surface answers deletes and the collaborator-membership check with a bare
|
|
336
|
-
// 204 (F-682), so those statuses return an empty body.
|
|
337
|
-
function respondWith(c, status, body) {
|
|
338
|
-
if (status === 204 || status === 205 || status === 304) {
|
|
339
|
-
return c.body(null, status);
|
|
340
|
-
}
|
|
341
|
-
return c.json(body, status);
|
|
342
|
-
}
|
|
343
|
-
// `clone()` throws synchronously once the body stream is disturbed — e.g.
|
|
344
|
-
// after the form token resolver's parseBody() read a form-encoded POST
|
|
345
|
-
// (F-683). A consumed or non-JSON body records as null, never a 500.
|
|
346
|
-
async function readRequestJson(c) {
|
|
347
|
-
try {
|
|
348
|
-
return await c.req.raw.clone().json();
|
|
349
|
-
}
|
|
350
|
-
catch {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
function extractMessage(body) {
|
|
355
|
-
if (!body || typeof body !== "object")
|
|
356
|
-
return undefined;
|
|
357
|
-
const record = body;
|
|
358
|
-
if (typeof record.message === "string")
|
|
359
|
-
return record.message;
|
|
360
|
-
// Gmail (and other Google-style) envelopes nest under `{ error: { message } }`.
|
|
361
|
-
if (record.error && typeof record.error === "object") {
|
|
362
|
-
const nested = record.error.message;
|
|
363
|
-
if (typeof nested === "string")
|
|
364
|
-
return nested;
|
|
365
|
-
}
|
|
366
|
-
return undefined;
|
|
367
|
-
}
|
|
368
|
-
//# sourceMappingURL=recorder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.js","sourceRoot":"","sources":["../src/recorder.ts"],"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,CAAC,KAA+B,CAAC,OAAO,CAAC;QAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC;IAChD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { redactEvent, redactSecrets } from "@pome-sh/shared-types/redaction";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redaction.js","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC"}
|
package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { type ToolSpec, type TwinDefinition } from "./index.js";
|
|
2
|
-
export declare class TwinBootError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
/** Engine-owned `/_pome/*` route names a twin's `pomeRoutes` may not shadow. */
|
|
6
|
-
export declare const POME_CORE_ROUTE_NAMES: Set<string>;
|
|
7
|
-
export declare function makeDeltaSink(): {
|
|
8
|
-
report(d: import("@pome-sh/shared-types").RecorderEvent["state_delta"]): void;
|
|
9
|
-
value(): {
|
|
10
|
-
before: Record<string, unknown> | null;
|
|
11
|
-
after: Record<string, unknown> | null;
|
|
12
|
-
} | null;
|
|
13
|
-
};
|
|
14
|
-
/** Hostnames the boot guard treats as loopback binds. */
|
|
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;
|
|
31
|
-
export declare function shadowedPrefix(routePath: string): string | null;
|
|
32
|
-
export declare function assertUniqueToolNames<TDomain>(tools: ReadonlyArray<ToolSpec<TDomain>>, twinId: string): void;
|
|
33
|
-
export declare function findTool<TDb, TSeed, TDomain>(definition: TwinDefinition<TDb, TSeed, TDomain>, name: string): ToolSpec<TDomain>;
|
|
34
|
-
export declare function readJson(req: Request): Promise<unknown>;
|
|
35
|
-
/**
|
|
36
|
-
* Convenience helper for `recorder.handle` inner functions. Returns a
|
|
37
|
-
* 200 response with the supplied `mutation` flag (default: false). Mirrors
|
|
38
|
-
* `packages/twin-github/src/app.ts:ok`.
|
|
39
|
-
*/
|
|
40
|
-
export declare function ok(body: unknown, mutation?: boolean): {
|
|
41
|
-
status: 200;
|
|
42
|
-
body: unknown;
|
|
43
|
-
mutation: boolean;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Convenience helper for `recorder.handle` inner functions. Returns a
|
|
47
|
-
* 201 response with `mutation: true`. Mirrors
|
|
48
|
-
* `packages/twin-github/src/app.ts:created`.
|
|
49
|
-
*/
|
|
50
|
-
export declare function created(body: unknown): {
|
|
51
|
-
status: 201;
|
|
52
|
-
body: unknown;
|
|
53
|
-
mutation: true;
|
|
54
|
-
};
|
|
@@ -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":"AAAA,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,qCAAqC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAsC,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE5E,MAAM,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