@tangle-network/agent-app 0.62.3 → 0.63.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.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-profiles/d1.js +1 -1
  3. package/dist/agent-profiles/index.d.ts +4 -1
  4. package/dist/agent-profiles/index.js +1 -1
  5. package/dist/app-auth/index.js +2 -2
  6. package/dist/assistant/index.js +7 -7
  7. package/dist/chat-react/index.js +3 -3
  8. package/dist/chat-routes/cancellation.d.ts +61 -0
  9. package/dist/chat-routes/dispatch-first.d.ts +14 -25
  10. package/dist/chat-routes/early-turn-work.d.ts +10 -0
  11. package/dist/chat-routes/hybrid-producer.d.ts +4 -3
  12. package/dist/chat-routes/index.d.ts +2 -1
  13. package/dist/chat-routes/index.js +86 -1874
  14. package/dist/chat-routes/index.js.map +1 -1
  15. package/dist/chat-routes/native-turn-timing.d.ts +15 -0
  16. package/dist/chat-routes/producer-stream.d.ts +5 -0
  17. package/dist/chat-routes/route-producer.d.ts +3 -0
  18. package/dist/chat-routes/route-storage.d.ts +7 -0
  19. package/dist/chat-routes/router-producer.d.ts +31 -5
  20. package/dist/chat-routes/turn-admission.d.ts +2 -1
  21. package/dist/chat-routes/turn-execution.d.ts +6 -11
  22. package/dist/chat-routes/turn-ownership.d.ts +22 -0
  23. package/dist/chat-routes/turn-route-contracts.d.ts +112 -105
  24. package/dist/chat-routes/turn-routes.d.ts +4 -4
  25. package/dist/chat-routes/wire.d.ts +0 -7
  26. package/dist/chat-store/index.d.ts +1 -1
  27. package/dist/chat-store/index.js +21 -3
  28. package/dist/chat-store/index.js.map +1 -1
  29. package/dist/chat-store/schema.d.ts +3 -2
  30. package/dist/chat-store/store.d.ts +8 -0
  31. package/dist/{chunk-GIEUZBQQ.js → chunk-4CALWPN5.js} +3 -7
  32. package/dist/chunk-4CALWPN5.js.map +1 -0
  33. package/dist/chunk-4DBHC63F.js +54 -0
  34. package/dist/chunk-4DBHC63F.js.map +1 -0
  35. package/dist/{chunk-G7M2C72Q.js → chunk-5TSRFF5W.js} +1 -1
  36. package/dist/chunk-5TSRFF5W.js.map +1 -0
  37. package/dist/chunk-A2NQMVMF.js +485 -0
  38. package/dist/chunk-A2NQMVMF.js.map +1 -0
  39. package/dist/{chunk-PCAY23GS.js → chunk-AVBNS64P.js} +172 -2
  40. package/dist/chunk-AVBNS64P.js.map +1 -0
  41. package/dist/{chunk-4P5NFBWX.js → chunk-BI5AZAOO.js} +4 -4
  42. package/dist/chunk-BV3VZEKB.js +483 -0
  43. package/dist/chunk-BV3VZEKB.js.map +1 -0
  44. package/dist/{chunk-UW2DKTEM.js → chunk-IDG2XR5O.js} +20 -10
  45. package/dist/chunk-IDG2XR5O.js.map +1 -0
  46. package/dist/{chunk-KS4I7KVC.js → chunk-JRTWTADT.js} +184 -123
  47. package/dist/chunk-JRTWTADT.js.map +1 -0
  48. package/dist/chunk-KG2Y44XT.js +1 -0
  49. package/dist/chunk-KG2Y44XT.js.map +1 -0
  50. package/dist/chunk-MM3GOLHO.js +3365 -0
  51. package/dist/chunk-MM3GOLHO.js.map +1 -0
  52. package/dist/chunk-N6URQ6DM.js +225 -0
  53. package/dist/chunk-N6URQ6DM.js.map +1 -0
  54. package/dist/{chunk-ISRPOPMM.js → chunk-ND5XWLRU.js} +21 -18
  55. package/dist/chunk-ND5XWLRU.js.map +1 -0
  56. package/dist/{chunk-IUVDR3KJ.js → chunk-NHVSO47Q.js} +2 -2
  57. package/dist/{chunk-FAXSYC2C.js → chunk-RZLCBWGG.js} +2 -2
  58. package/dist/{chunk-MRZP65DZ.js → chunk-SRWQCWLR.js} +14 -3
  59. package/dist/chunk-SRWQCWLR.js.map +1 -0
  60. package/dist/{chunk-JRW6LCIA.js → chunk-V6YGLAQC.js} +2 -2
  61. package/dist/{chunk-54YIL7WM.js → chunk-WPPDNS63.js} +4 -4
  62. package/dist/{chunk-CQZVJVME.js → chunk-YCMVNXAX.js} +2 -2
  63. package/dist/design-canvas/index.js +3 -3
  64. package/dist/openui/index.js +3 -3
  65. package/dist/operator/index.js +2 -2
  66. package/dist/platform/billable-turn-admission.d.ts +13 -9
  67. package/dist/platform/delegated-keys.d.ts +4 -3
  68. package/dist/platform/delegated-turn-keys.d.ts +17 -6
  69. package/dist/platform/index.js +80 -23
  70. package/dist/platform/index.js.map +1 -1
  71. package/dist/preset-cloudflare/index.d.ts +2 -0
  72. package/dist/preset-cloudflare/index.js +344 -0
  73. package/dist/preset-cloudflare/index.js.map +1 -1
  74. package/dist/preset-cloudflare/native-completion-owner.d.ts +90 -0
  75. package/dist/preset-cloudflare/native-completion-store.d.ts +56 -0
  76. package/dist/preset-cloudflare/native-completion-workflow.d.ts +10 -0
  77. package/dist/public-consultation/index.js +28 -7
  78. package/dist/public-consultation/index.js.map +1 -1
  79. package/dist/rollout/d1.d.ts +103 -3
  80. package/dist/rollout/d1.js +152 -5
  81. package/dist/rollout/d1.js.map +1 -1
  82. package/dist/runtime/index.js +3 -4
  83. package/dist/runtime/index.js.map +1 -1
  84. package/dist/runtime/router-turn.d.ts +4 -0
  85. package/dist/runtime/router-turn.js +2 -3
  86. package/dist/sandbox/index.js +3 -4
  87. package/dist/sandbox/sandbox-run-tool.d.ts +5 -0
  88. package/dist/sequences/index.js +5 -5
  89. package/dist/signoff/cli.js +15 -3
  90. package/dist/signoff/cli.js.map +1 -1
  91. package/dist/signoff/config.d.ts +3 -1
  92. package/dist/signoff/index.d.ts +2 -1
  93. package/dist/signoff/index.js +3 -1
  94. package/dist/signoff/phases.d.ts +3 -0
  95. package/dist/signoff/proof.js +3 -0
  96. package/dist/signoff/proof.js.map +1 -1
  97. package/dist/signoff/run.d.ts +3 -1
  98. package/dist/signoff/types.d.ts +13 -0
  99. package/dist/skills-placement/box.js +5 -5
  100. package/dist/skills-placement/index.js +2 -2
  101. package/dist/tools/index.js +1 -1
  102. package/dist/turn-stream/adapters.d.ts +10 -4
  103. package/dist/turn-stream/index.js +33 -356
  104. package/dist/turn-stream/index.js.map +1 -1
  105. package/dist/turn-trace/index.d.ts +1 -0
  106. package/dist/turn-trace/index.js +4 -5
  107. package/dist/turn-trace/phase-timing.d.ts +20 -0
  108. package/dist/turn-trace/recorder.d.ts +3 -0
  109. package/dist/turn-trace/turn-facts.d.ts +17 -0
  110. package/dist/web-react/agent-profile-editor.js +1 -1
  111. package/dist/web-react/chat-stream.d.ts +0 -7
  112. package/dist/web-react/index.js +7 -9
  113. package/dist/work-product/index.js +7 -7
  114. package/package.json +1 -1
  115. package/dist/chat-routes/minted-thread.d.ts +0 -63
  116. package/dist/chunk-6R73V3Y5.js +0 -17
  117. package/dist/chunk-6R73V3Y5.js.map +0 -1
  118. package/dist/chunk-CCVWR33L.js +0 -99
  119. package/dist/chunk-CCVWR33L.js.map +0 -1
  120. package/dist/chunk-EFQUAWWF.js +0 -1749
  121. package/dist/chunk-EFQUAWWF.js.map +0 -1
  122. package/dist/chunk-G7M2C72Q.js.map +0 -1
  123. package/dist/chunk-GIEUZBQQ.js.map +0 -1
  124. package/dist/chunk-ISRPOPMM.js.map +0 -1
  125. package/dist/chunk-KS4I7KVC.js.map +0 -1
  126. package/dist/chunk-MRZP65DZ.js.map +0 -1
  127. package/dist/chunk-PCAY23GS.js.map +0 -1
  128. package/dist/chunk-UW2DKTEM.js.map +0 -1
  129. package/dist/chunk-VK3F4N4U.js +0 -133
  130. package/dist/chunk-VK3F4N4U.js.map +0 -1
  131. /package/dist/{chunk-4P5NFBWX.js.map → chunk-BI5AZAOO.js.map} +0 -0
  132. /package/dist/{chunk-IUVDR3KJ.js.map → chunk-NHVSO47Q.js.map} +0 -0
  133. /package/dist/{chunk-FAXSYC2C.js.map → chunk-RZLCBWGG.js.map} +0 -0
  134. /package/dist/{chunk-JRW6LCIA.js.map → chunk-V6YGLAQC.js.map} +0 -0
  135. /package/dist/{chunk-54YIL7WM.js.map → chunk-WPPDNS63.js.map} +0 -0
  136. /package/dist/{chunk-CQZVJVME.js.map → chunk-YCMVNXAX.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION_SEVERITY)) {\n throw new Error(`${label}: permission '${key}' must be 'allow' | 'ask' | 'deny' (got ${JSON.stringify(value)})`)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,OAGK;AAkBA,SAAS,wBAAwB,QAAoD;AAC1F,QAAM,SAAS,4BAA4B,MAAM;AACjD,SAAO;AAAA,IACL,MAAM,eAAe,MAAM;AACzB,aAAO,EAAE,GAAG,MAAM,cAAc,MAAM,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,IAC1E;AAAA,IACA,SAAS,MAAM,OAAO,QAAQ,EAAE,OAAO,KAAK,CAAC;AAAA,IAC7C,SAAS,OAAO;AAAA,EAClB;AACF;;;ACwCO,SAAS,kBAAwB,MAGR;AAC9B,MAAI,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,WAAW,KAAK,KAAK,KAAK,KAAK,IAAI,GAAG;AACnF,UAAM,IAAI,MAAM,mEAAmE,KAAK,UAAU,KAAK,IAAI,CAAC,GAAG;AAAA,EACjH;AACA,MAAI,OAAO,KAAK,UAAU,YAAY;AACpC,UAAM,IAAI,MAAM,iBAAiB,KAAK,IAAI,6BAA6B;AAAA,EACzE;AACA,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AAC9C;AAgBO,SAAS,sBAAsB,OAAmD;AACvF,QAAM,SAAS,oBAAI,IAA4B;AAC/C,aAAW,cAAc,OAAO;AAC9B,QAAI,OAAO,IAAI,WAAW,IAAI,GAAG;AAC/B,YAAM,IAAI,MAAM,2BAA2B,WAAW,IAAI,oDAA+C;AAAA,IAC3G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,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,WAAW,GAAG;AAC9D,UAAI,EAAE,SAAS,sBAAsB;AACnC,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,GAAG,2CAA2C,KAAK,UAAU,KAAK,CAAC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION_SEVERITY)) {\n throw new Error(`${label}: permission '${key}' must be 'allow' | 'ask' | 'deny' (got ${JSON.stringify(value)})`)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,OAGK;AAkBA,SAAS,wBAAwB,QAAoD;AAC1F,QAAM,SAAS,4BAA4B,MAAM;AACjD,SAAO;AAAA,IACL,MAAM,eAAe,MAAM;AACzB,aAAO,EAAE,GAAG,MAAM,cAAc,MAAM,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,IAC1E;AAAA,IACA,SAAS,MAAM,OAAO,QAAQ,EAAE,OAAO,KAAK,CAAC;AAAA,IAC7C,SAAS,OAAO;AAAA,EAClB;AACF;;;ACwCO,SAAS,kBAAwB,MAGR;AAC9B,MAAI,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,WAAW,KAAK,KAAK,KAAK,KAAK,IAAI,GAAG;AACnF,UAAM,IAAI,MAAM,mEAAmE,KAAK,UAAU,KAAK,IAAI,CAAC,GAAG;AAAA,EACjH;AACA,MAAI,OAAO,KAAK,UAAU,YAAY;AACpC,UAAM,IAAI,MAAM,iBAAiB,KAAK,IAAI,6BAA6B;AAAA,EACzE;AACA,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AA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O,aAAa,WAAW,OAAO,aAAa,UAAU;AAC/D,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,IAAI,8BAA8B,KAAK,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,MAC1G;AAAA,IACF;AAAA,EACF;AACA,MAAI,QAAQ,gBAAgB,QAAW;AACrC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,WAAW,GAAG;AAC9D,UAAI,EAAE,SAAS,sBAAsB;AACnC,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,GAAG,2CAA2C,KAAK,UAAU,KAAK,CAAC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -35,6 +35,10 @@ export interface RouterTurnTool {
35
35
  }
36
36
  /** What a running tool gets besides its arguments. */
37
37
  export interface RouterTurnToolContext {
38
+ /** This call's identity, shared by streamed parts, tool history and a native child execution. */
39
+ callId?: string;
40
+ /** The effective turn cancellation signal. Tools must pass it to cancellable I/O. */
41
+ signal?: AbortSignal;
38
42
  /**
39
43
  * Report a typed side event while the tool runs (a graph edit, a file written, a
40
44
  * progress step). It streams at once as a `tool_event` and is recorded in the
@@ -13,11 +13,10 @@ import {
13
13
  turnKnowledgeInstructions,
14
14
  workspaceKnowledgeForTurn,
15
15
  workspaceTurnCheckpoints
16
- } from "../chunk-UW2DKTEM.js";
17
- import "../chunk-VK3F4N4U.js";
16
+ } from "../chunk-IDG2XR5O.js";
18
17
  import "../chunk-D6UJEOZQ.js";
18
+ import "../chunk-AVBNS64P.js";
19
19
  import "../chunk-AMUXRAUO.js";
20
- import "../chunk-PCAY23GS.js";
21
20
  export {
22
21
  DURABLE_HOP_BUDGET_MS,
23
22
  asksForLanguage,
@@ -101,7 +101,7 @@ import {
101
101
  warmKey,
102
102
  warmReceiptId,
103
103
  warmWeekdayOf
104
- } from "../chunk-ISRPOPMM.js";
104
+ } from "../chunk-ND5XWLRU.js";
105
105
  import {
106
106
  createWarmCache
107
107
  } from "../chunk-F4TUZYMX.js";
@@ -149,14 +149,13 @@ import "../chunk-DSMGS4IV.js";
149
149
  import "../chunk-5BJHKQ33.js";
150
150
  import "../chunk-6A7MYOUI.js";
151
151
  import "../chunk-O7UX55EU.js";
152
- import "../chunk-S5SRJJQG.js";
153
152
  import "../chunk-XEAZWJ3W.js";
153
+ import "../chunk-S5SRJJQG.js";
154
154
  import "../chunk-7TZA2TAM.js";
155
155
  import "../chunk-UGWQLQDS.js";
156
156
  import "../chunk-WSQFNMIA.js";
157
- import "../chunk-VK3F4N4U.js";
158
157
  import "../chunk-D6UJEOZQ.js";
159
- import "../chunk-PCAY23GS.js";
158
+ import "../chunk-AVBNS64P.js";
160
159
  import {
161
160
  readSandboxBinaryBytes,
162
161
  shellQuote,
@@ -31,6 +31,9 @@ export declare class SandboxRunError extends Error {
31
31
  }
32
32
  /** The engine's per-call tool context (`RouterTurnToolContext`), kept structural so this module does not import the engine. */
33
33
  export interface SandboxToolContext {
34
+ /** The Router engine's call identity; never derived from task text. */
35
+ callId?: string;
36
+ signal?: AbortSignal;
34
37
  /** The engine-resolved member request, including checkpoint continuation. */
35
38
  userMessage?: string;
36
39
  emit(kind: string, data?: unknown): void;
@@ -40,6 +43,8 @@ export interface SandboxToolContext {
40
43
  span?: TurnSpan;
41
44
  }
42
45
  export interface SandboxTaskOptions {
46
+ /** Stable identity of this tool invocation, when the calling engine supplies it. */
47
+ callId?: string;
43
48
  signal: AbortSignal;
44
49
  timeoutMs: number;
45
50
  /** Streams a typed side event from the box run (a progress step, a file written) as the turn's `tool_event`. */
@@ -19,16 +19,16 @@ import {
19
19
  requireEnum,
20
20
  requireMcpString
21
21
  } from "../chunk-PEJ5OP5B.js";
22
- import {
23
- MCP_PROTOCOL_VERSIONS,
24
- buildScopedMcpServerEntry,
25
- createMcpToolHandler
26
- } from "../chunk-6A7MYOUI.js";
27
22
  import "../chunk-CQGEGPY7.js";
28
23
  import "../chunk-RN4WPTBH.js";
29
24
  import {
30
25
  assertMediaUrl
31
26
  } from "../chunk-WP2GYFZ4.js";
27
+ import {
28
+ MCP_PROTOCOL_VERSIONS,
29
+ buildScopedMcpServerEntry,
30
+ createMcpToolHandler
31
+ } from "../chunk-6A7MYOUI.js";
32
32
  import "../chunk-TXD5HXLE.js";
33
33
  import "../chunk-6Z7TZVKZ.js";
34
34
  import "../chunk-57XPEL7X.js";
@@ -10,7 +10,7 @@ import {
10
10
  runSignoff,
11
11
  runSurfaceLadderCli,
12
12
  runWorkspaceSurfaceCli
13
- } from "../chunk-KS4I7KVC.js";
13
+ } from "../chunk-JRTWTADT.js";
14
14
  import "../chunk-LRYY3OX7.js";
15
15
  import {
16
16
  invokedAsScript
@@ -84,6 +84,7 @@ function usage() {
84
84
  "Usage: agent-app-signoff [repoDir] [options]",
85
85
  "",
86
86
  " --source head|working-tree bytes to verify (default working-tree)",
87
+ " --phase all|release|suites declared scope (default all; partial requires classification)",
87
88
  " --config <path> config module (default signoff.config.mjs)",
88
89
  " --seed <n> base seed; reproduces a previous run",
89
90
  " --shuffle-runs <n> override every shuffled step's run count",
@@ -133,6 +134,10 @@ function parseArgs(argv) {
133
134
  case "--config":
134
135
  parsed.configPath = take();
135
136
  break;
137
+ // Validate centrally with the library path, before install.
138
+ case "--phase":
139
+ parsed.phase = take();
140
+ break;
136
141
  case "--seed":
137
142
  parsed.seed = positiveInt(take(), "--seed");
138
143
  break;
@@ -222,11 +227,18 @@ async function runSignoffCli(argv) {
222
227
  `);
223
228
  return report.ok ? 0 : 1;
224
229
  }
230
+ function exitAfterOutput(code) {
231
+ process.stdout.write("", () => {
232
+ process.stderr.write("", () => {
233
+ process.exit(code);
234
+ });
235
+ });
236
+ }
225
237
  if (invokedAsScript(import.meta.url, process.argv[1])) {
226
- runSignoffCli(process.argv.slice(2)).then((code) => process.exit(code)).catch((err) => {
238
+ runSignoffCli(process.argv.slice(2)).then(exitAfterOutput).catch((err) => {
227
239
  process.stderr.write(`${err instanceof Error ? err.message : String(err)}
228
240
  `);
229
- process.exit(2);
241
+ exitAfterOutput(2);
230
242
  });
231
243
  }
232
244
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/signoff/cli.ts","../../src/signoff/defaults-cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `agent-app-signoff` — run the local sign-off gate and print the proof.\n *\n * Exits 0 only when every declared step passed in a pristine tree. Exit 1 is a\n * real failure; exit 2 is a usage or config error, so a script can tell \"your\n * code is broken\" from \"your gate is misconfigured\".\n *\n * agent-app-signoff # this repo, working tree, default config\n * agent-app-signoff --source head # exactly the commit that would merge\n * agent-app-signoff --seed 12345 # reproduce a previous run's orders\n * agent-app-signoff --keep-going # run every step, full picture\n * agent-app-signoff --json proof.json # machine-readable record\n * agent-app-signoff defaults [repoDir] # which agent-app defaults each app has\n * agent-app-signoff shell-alignment --base-url <url> --route <path> # header dividers meet the rail\n * agent-app-signoff surface-ladder --base-url <url> --route <path> # cards and fields step off their parent\n * agent-app-signoff workspace-surface --base-url <url> --route <path> # every page on the shared panel\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { runDefaultsCli } from './defaults-cli'\nimport { invokedAsScript } from './invoked-as-script'\nimport { formatSignoffLine, formatSignoffReport } from './report'\nimport { runSignoff, type RunSignoffOptions } from './run'\nimport { runShellAlignmentCli } from './shell-alignment-cli'\nimport { runSurfaceLadderCli } from './surface-ladder-cli'\nimport { runWorkspaceSurfaceCli } from './workspace-surface-cli'\nimport type { SignoffEvent, SignoffSource } from './types'\n\ninterface ParsedArgs extends RunSignoffOptions {\n readonly jsonPath?: string\n readonly quiet?: boolean\n}\n\nfunction usage(): string {\n return [\n 'Usage: agent-app-signoff [repoDir] [options]',\n '',\n ' --source head|working-tree bytes to verify (default working-tree)',\n ' --config <path> config module (default signoff.config.mjs)',\n ' --seed <n> base seed; reproduces a previous run',\n ' --shuffle-runs <n> override every shuffled step\\'s run count',\n ' --max-parallel <n> cap concurrent steps',\n ' --cache-dir <path> clean trees + pristine stores live here',\n ' --keep-going run every step even after one fails',\n ' --keep-workspace leave the clean tree on disk to inspect',\n ' --json <path> write the machine-readable report',\n ' --quiet verdict only; no per-step progress',\n '',\n 'Subcommands:',\n ' defaults report which agent-app defaults each app has (--help for options)',\n ' shell-alignment measure header dividers against the rail in a browser (--help for options)',\n ' surface-ladder measure card and field steps, field borders and card copy in a browser (--help for options)',\n ' workspace-surface every page sits on one shared panel under an inset shell header (--help for options)',\n ].join('\\n')\n}\n\nfunction fail(message: string): never {\n process.stderr.write(`agent-app-signoff: ${message}\\n\\n${usage()}\\n`)\n process.exit(2)\n}\n\nfunction positiveInt(raw: string, flag: string): number {\n const value = Number.parseInt(raw, 10)\n if (!Number.isFinite(value) || value < 0) fail(`${flag} needs a non-negative integer, got \"${raw}\"`)\n return value\n}\n\nfunction parseArgs(argv: readonly string[]): ParsedArgs {\n const parsed: {\n repoDir?: string\n configPath?: string\n source?: SignoffSource\n seed?: number\n shuffleRuns?: number\n maxParallel?: number\n cacheDir?: string\n keepGoing?: boolean\n keepWorkspace?: boolean\n jsonPath?: string\n quiet?: boolean\n } = {}\n\n for (let index = 0; index < argv.length; index += 1) {\n const flag = argv[index] as string\n const take = (): string => {\n const value = argv[index + 1]\n if (value === undefined) fail(`${flag} needs a value`)\n index += 1\n return value\n }\n switch (flag) {\n case '--source': {\n const value = take()\n if (value !== 'head' && value !== 'working-tree') fail(`--source must be head or working-tree, got \"${value}\"`)\n parsed.source = value\n break\n }\n case '--config': parsed.configPath = take(); break\n case '--seed': parsed.seed = positiveInt(take(), '--seed'); break\n case '--shuffle-runs': parsed.shuffleRuns = positiveInt(take(), '--shuffle-runs'); break\n case '--max-parallel': parsed.maxParallel = positiveInt(take(), '--max-parallel'); break\n case '--cache-dir': parsed.cacheDir = take(); break\n case '--keep-going': parsed.keepGoing = true; break\n case '--keep-workspace': parsed.keepWorkspace = true; break\n case '--json': parsed.jsonPath = take(); break\n case '--quiet': parsed.quiet = true; break\n case '-h':\n case '--help':\n process.stdout.write(`${usage()}\\n`)\n process.exit(0)\n break\n default:\n if (flag.startsWith('-')) fail(`unknown option: ${flag}`)\n if (parsed.repoDir !== undefined) fail(`unexpected second directory: ${flag}`)\n parsed.repoDir = flag\n }\n }\n return parsed\n}\n\nfunction progressWriter(): (event: SignoffEvent) => void {\n return (event) => {\n switch (event.kind) {\n case 'cache-prune':\n process.stderr.write(`· cache ${event.beforeBytes} → ${event.afterBytes} allocated bytes; ` +\n `${event.removed.length} idle entries removed${event.overBudgetBytes ? `; ${event.overBudgetBytes} bytes held by active or kept trees` : ''}\\n`)\n break\n case 'tree':\n process.stderr.write(`· clean tree at ${event.path} (${event.head.slice(0, 12)}${event.dirty ? ' + working tree' : ''})\\n`)\n break\n case 'store':\n process.stderr.write(`· store ${event.cacheHit ? 'warm' : 'COLD'} ${event.cacheKey.slice(0, 16)}\\n`)\n break\n case 'install-start':\n process.stderr.write(`· ${event.command}\\n`)\n break\n case 'install-end':\n process.stderr.write(`· install exit ${event.exitCode} in ${event.durationMs}ms\\n`)\n break\n case 'step-start':\n process.stderr.write(`· start ${event.name}${event.seed === null ? '' : ` (seed ${event.seed})`}\\n`)\n break\n case 'step-end':\n process.stderr.write(`· ${event.status === 'passed' ? 'ok' : event.status} ${event.name} ${event.durationMs}ms\\n`)\n break\n }\n }\n}\n\nexport async function runSignoffCli(argv: readonly string[]): Promise<number> {\n if (argv[0] === 'defaults') return runDefaultsCli(argv.slice(1))\n if (argv[0] === 'shell-alignment') return runShellAlignmentCli(argv.slice(1))\n if (argv[0] === 'surface-ladder') return runSurfaceLadderCli(argv.slice(1))\n if (argv[0] === 'workspace-surface') return runWorkspaceSurfaceCli(argv.slice(1))\n const args = parseArgs(argv)\n const report = await runSignoff({ ...args, onEvent: args.quiet ? undefined : progressWriter() })\n\n if (args.jsonPath !== undefined) {\n const abs = resolve(args.jsonPath)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, `${JSON.stringify(report, null, 2)}\\n`)\n }\n\n // `--quiet` is documented as \"verdict only\", and CLAUDE.md names the one-line\n // `signoff PASS <sha> …` summary as an accepted PR proof. Printing the full\n // report here contradicted both, and left the only producer of that summary\n // with no caller.\n process.stdout.write(`${args.quiet ? formatSignoffLine(report) : formatSignoffReport(report)}\\n`)\n return report.ok ? 0 : 1\n}\n\n/* c8 ignore start — process wiring, exercised by the bin itself */\nif (invokedAsScript(import.meta.url, process.argv[1])) {\n runSignoffCli(process.argv.slice(2))\n .then((code) => process.exit(code))\n .catch((err: unknown) => {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(2)\n })\n}\n/* c8 ignore stop */\n","/**\n * `agent-app-signoff defaults` — report which agent-app defaults each app in a checkout has.\n *\n * agent-app-signoff defaults [repoDir] # the matrix for the apps in repoDir\n * agent-app-signoff defaults --probe # also ask Intelligence for each app's last exported turn\n * agent-app-signoff defaults --json matrix.json # the same rows, machine-readable\n *\n * Exit 0 unless an app turns a default off without a reason (1), or the usage is wrong (2). `--probe` reads the\n * Intelligence key from `TANGLE_INTELLIGENCE_API_KEY`; it reads the traces of the tenant that owns the apps' export keys.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { checkAppDefaults, collectLastExports, formatAppDefaults } from './app-defaults'\nimport { loadSignoffConfig } from './config'\n\nfunction defaultsUsage(): string {\n return [\n 'Usage: agent-app-signoff defaults [repoDir] [options]',\n '',\n ' --probe ask Intelligence for each app\\'s last exported turn (needs TANGLE_INTELLIGENCE_API_KEY)',\n ' --no-bundle skip the Worker upload measure (it runs the app\\'s own wrangler, so build first)',\n ' --json <path> write the rows',\n ].join('\\n')\n}\n\nexport async function runDefaultsCli(argv: readonly string[]): Promise<number> {\n let repoDir = process.cwd()\n let probe = false\n let measureBundle = true\n let jsonPath: string | undefined\n for (let index = 0; index < argv.length; index += 1) {\n const flag = argv[index] as string\n if (flag === '--probe') probe = true\n else if (flag === '--no-bundle') measureBundle = false\n else if (flag === '--json') {\n jsonPath = argv[index + 1]\n index += 1\n if (jsonPath === undefined) return usageError('--json needs a path')\n } else if (flag === '-h' || flag === '--help') {\n process.stdout.write(`${defaultsUsage()}\\n`)\n return 0\n } else if (flag.startsWith('-')) return usageError(`unknown option: ${flag}`)\n else repoDir = resolve(flag)\n }\n let exemptions\n try {\n exemptions = (await loadSignoffConfig({ repoRoot: repoDir })).config.agentApp?.exemptions\n } catch {\n // A checkout with no signoff config, or one that does not load here, declares no exemptions.\n }\n const apiKey = process.env.TANGLE_INTELLIGENCE_API_KEY?.trim()\n if (probe && !apiKey) return usageError('--probe needs TANGLE_INTELLIGENCE_API_KEY')\n const exports = probe && apiKey ? await collectLastExports(repoDir, apiKey) : undefined\n const result = checkAppDefaults(repoDir, { exemptions, measureBundle, exports })\n if (jsonPath !== undefined) {\n const abs = resolve(jsonPath)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, `${JSON.stringify(result, null, 2)}\\n`)\n }\n process.stdout.write(formatAppDefaults(result))\n return result.findings.length === 0 ? 0 : 1\n}\n\nfunction usageError(message: string): number {\n process.stderr.write(`agent-app-signoff defaults: ${message}\\n\\n${defaultsUsage()}\\n`)\n return 2\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,SAAS,aAAAA,YAAW,iBAAAC,sBAAqB;AACzC,SAAS,WAAAC,UAAS,WAAAC,gBAAe;;;ACTjC,SAAS,WAAW,qBAAqB;AACzC,SAAS,SAAS,eAAe;AAIjC,SAAS,gBAAwB;AAC/B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,eAAsB,eAAe,MAA0C;AAC7E,MAAI,UAAU,QAAQ,IAAI;AAC1B,MAAI,QAAQ;AACZ,MAAI,gBAAgB;AACpB,MAAI;AACJ,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,OAAO,KA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ACrD,gBAAc,QAAQ,KAAK,MAAM,CAAC,CAAC,EAChC,KAAK,CAAC,SAAS,QAAQ,KAAK,IAAI,CAAC,EACjC,MAAM,CAAC,QAAiB;AACvB,YAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACL;","names":["mkdirSync","writeFileSync","dirname","resolve","resolve","mkdirSync","dirname","writeFileSync"]}
1
+ {"version":3,"sources":["../../src/signoff/cli.ts","../../src/signoff/defaults-cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `agent-app-signoff` — run the local sign-off gate and print the proof.\n *\n * Exits 0 only when every selected step passed in a pristine tree (default all).\n * Partial phases are explicitly labelled. Exit 1 is a\n * real failure; exit 2 is a usage or config error, so a script can tell \"your\n * code is broken\" from \"your gate is misconfigured\".\n *\n * agent-app-signoff # this repo, working tree, default config\n * agent-app-signoff --source head # exactly the commit that would merge\n * agent-app-signoff --seed 12345 # reproduce a previous run's orders\n * agent-app-signoff --keep-going # run every step, full picture\n * agent-app-signoff --json proof.json # machine-readable record\n * agent-app-signoff defaults [repoDir] # which agent-app defaults each app has\n * agent-app-signoff shell-alignment --base-url <url> --route <path> # header dividers meet the rail\n * agent-app-signoff surface-ladder --base-url <url> --route <path> # cards and fields step off their parent\n * agent-app-signoff workspace-surface --base-url <url> --route <path> # every page on the shared panel\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { runDefaultsCli } from './defaults-cli'\nimport { invokedAsScript } from './invoked-as-script'\nimport { formatSignoffLine, formatSignoffReport } from './report'\nimport { runSignoff, type RunSignoffOptions } from './run'\nimport { runShellAlignmentCli } from './shell-alignment-cli'\nimport { runSurfaceLadderCli } from './surface-ladder-cli'\nimport { runWorkspaceSurfaceCli } from './workspace-surface-cli'\nimport type { SignoffEvent, SignoffSource, SignoffPhase } from './types'\n\ninterface ParsedArgs extends RunSignoffOptions {\n readonly jsonPath?: string\n readonly quiet?: boolean\n}\n\nfunction usage(): string {\n return [\n 'Usage: agent-app-signoff [repoDir] [options]',\n '',\n ' --source head|working-tree bytes to verify (default working-tree)',\n ' --phase all|release|suites declared scope (default all; partial requires classification)',\n ' --config <path> config module (default signoff.config.mjs)',\n ' --seed <n> base seed; reproduces a previous run',\n ' --shuffle-runs <n> override every shuffled step\\'s run count',\n ' --max-parallel <n> cap concurrent steps',\n ' --cache-dir <path> clean trees + pristine stores live here',\n ' --keep-going run every step even after one fails',\n ' --keep-workspace leave the clean tree on disk to inspect',\n ' --json <path> write the machine-readable report',\n ' --quiet verdict only; no per-step progress',\n '',\n 'Subcommands:',\n ' defaults report which agent-app defaults each app has (--help for options)',\n ' shell-alignment measure header dividers against the rail in a browser (--help for options)',\n ' surface-ladder measure card and field steps, field borders and card copy in a browser (--help for options)',\n ' workspace-surface every page sits on one shared panel under an inset shell header (--help for options)',\n ].join('\\n')\n}\n\nfunction fail(message: string): never {\n process.stderr.write(`agent-app-signoff: ${message}\\n\\n${usage()}\\n`)\n process.exit(2)\n}\n\nfunction positiveInt(raw: string, flag: string): number {\n const value = Number.parseInt(raw, 10)\n if (!Number.isFinite(value) || value < 0) fail(`${flag} needs a non-negative integer, got \"${raw}\"`)\n return value\n}\n\nfunction parseArgs(argv: readonly string[]): ParsedArgs {\n const parsed: {\n repoDir?: string\n configPath?: string\n source?: SignoffSource\n phase?: SignoffPhase\n seed?: number\n shuffleRuns?: number\n maxParallel?: number\n cacheDir?: string\n keepGoing?: boolean\n keepWorkspace?: boolean\n jsonPath?: string\n quiet?: boolean\n } = {}\n\n for (let index = 0; index < argv.length; index += 1) {\n const flag = argv[index] as string\n const take = (): string => {\n const value = argv[index + 1]\n if (value === undefined) fail(`${flag} needs a value`)\n index += 1\n return value\n }\n switch (flag) {\n case '--source': {\n const value = take()\n if (value !== 'head' && value !== 'working-tree') fail(`--source must be head or working-tree, got \"${value}\"`)\n parsed.source = value\n break\n }\n case '--config': parsed.configPath = take(); break\n // Validate centrally with the library path, before install.\n case '--phase': parsed.phase = take() as SignoffPhase; break\n case '--seed': parsed.seed = positiveInt(take(), '--seed'); break\n case '--shuffle-runs': parsed.shuffleRuns = positiveInt(take(), '--shuffle-runs'); break\n case '--max-parallel': parsed.maxParallel = positiveInt(take(), '--max-parallel'); break\n case '--cache-dir': parsed.cacheDir = take(); break\n case '--keep-going': parsed.keepGoing = true; break\n case '--keep-workspace': parsed.keepWorkspace = true; break\n case '--json': parsed.jsonPath = take(); break\n case '--quiet': parsed.quiet = true; break\n case '-h':\n case '--help':\n process.stdout.write(`${usage()}\\n`)\n process.exit(0)\n break\n default:\n if (flag.startsWith('-')) fail(`unknown option: ${flag}`)\n if (parsed.repoDir !== undefined) fail(`unexpected second directory: ${flag}`)\n parsed.repoDir = flag\n }\n }\n return parsed\n}\n\nfunction progressWriter(): (event: SignoffEvent) => void {\n return (event) => {\n switch (event.kind) {\n case 'cache-prune':\n process.stderr.write(`· cache ${event.beforeBytes} → ${event.afterBytes} allocated bytes; ` +\n `${event.removed.length} idle entries removed${event.overBudgetBytes ? `; ${event.overBudgetBytes} bytes held by active or kept trees` : ''}\\n`)\n break\n case 'tree':\n process.stderr.write(`· clean tree at ${event.path} (${event.head.slice(0, 12)}${event.dirty ? ' + working tree' : ''})\\n`)\n break\n case 'store':\n process.stderr.write(`· store ${event.cacheHit ? 'warm' : 'COLD'} ${event.cacheKey.slice(0, 16)}\\n`)\n break\n case 'install-start':\n process.stderr.write(`· ${event.command}\\n`)\n break\n case 'install-end':\n process.stderr.write(`· install exit ${event.exitCode} in ${event.durationMs}ms\\n`)\n break\n case 'step-start':\n process.stderr.write(`· start ${event.name}${event.seed === null ? '' : ` (seed ${event.seed})`}\\n`)\n break\n case 'step-end':\n process.stderr.write(`· ${event.status === 'passed' ? 'ok' : event.status} ${event.name} ${event.durationMs}ms\\n`)\n break\n }\n }\n}\n\nexport async function runSignoffCli(argv: readonly string[]): Promise<number> {\n if (argv[0] === 'defaults') return runDefaultsCli(argv.slice(1))\n if (argv[0] === 'shell-alignment') return runShellAlignmentCli(argv.slice(1))\n if (argv[0] === 'surface-ladder') return runSurfaceLadderCli(argv.slice(1))\n if (argv[0] === 'workspace-surface') return runWorkspaceSurfaceCli(argv.slice(1))\n const args = parseArgs(argv)\n const report = await runSignoff({ ...args, onEvent: args.quiet ? undefined : progressWriter() })\n\n if (args.jsonPath !== undefined) {\n const abs = resolve(args.jsonPath)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, `${JSON.stringify(report, null, 2)}\\n`)\n }\n\n // `--quiet` is documented as \"verdict only\", and CLAUDE.md names the one-line\n // `signoff PASS <sha> …` summary as an accepted PR proof. Printing the full\n // report here contradicted both, and left the only producer of that summary\n // with no caller.\n process.stdout.write(`${args.quiet ? formatSignoffLine(report) : formatSignoffReport(report)}\\n`)\n return report.ok ? 0 : 1\n}\n\n/* c8 ignore start — process wiring, exercised by the bin itself */\nfunction exitAfterOutput(code: number): void {\n // Drain queued pipe writes, then terminate even if a config retained a handle.\n process.stdout.write('', () => {\n process.stderr.write('', () => { process.exit(code) })\n })\n}\n\nif (invokedAsScript(import.meta.url, process.argv[1])) {\n runSignoffCli(process.argv.slice(2))\n .then(exitAfterOutput)\n .catch((err: unknown) => {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`)\n exitAfterOutput(2)\n })\n}\n/* c8 ignore stop */\n","/**\n * `agent-app-signoff defaults` — report which agent-app defaults each app in a checkout has.\n *\n * agent-app-signoff defaults [repoDir] # the matrix for the apps in repoDir\n * agent-app-signoff defaults --probe # also ask Intelligence for each app's last exported turn\n * agent-app-signoff defaults --json matrix.json # the same rows, machine-readable\n *\n * Exit 0 unless an app turns a default off without a reason (1), or the usage is wrong (2). `--probe` reads the\n * Intelligence key from `TANGLE_INTELLIGENCE_API_KEY`; it reads the traces of the tenant that owns the apps' export keys.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { checkAppDefaults, collectLastExports, formatAppDefaults } from './app-defaults'\nimport { loadSignoffConfig } from './config'\n\nfunction defaultsUsage(): string {\n return [\n 'Usage: agent-app-signoff defaults [repoDir] [options]',\n '',\n ' --probe ask Intelligence for each app\\'s last exported turn (needs TANGLE_INTELLIGENCE_API_KEY)',\n ' --no-bundle skip the Worker upload measure (it runs the app\\'s own wrangler, so build first)',\n ' --json <path> write the rows',\n ].join('\\n')\n}\n\nexport async function runDefaultsCli(argv: readonly string[]): Promise<number> {\n let repoDir = process.cwd()\n let probe = false\n let measureBundle = true\n let jsonPath: string | undefined\n for (let index = 0; index < argv.length; index += 1) {\n const flag = argv[index] as string\n if (flag === '--probe') probe = true\n else if (flag === '--no-bundle') measureBundle = false\n else if (flag === '--json') {\n jsonPath = argv[index + 1]\n index += 1\n if (jsonPath === undefined) return usageError('--json needs a path')\n } else if (flag === '-h' || flag === '--help') {\n process.stdout.write(`${defaultsUsage()}\\n`)\n return 0\n } else if (flag.startsWith('-')) return usageError(`unknown option: ${flag}`)\n else repoDir = resolve(flag)\n }\n let exemptions\n try {\n exemptions = (await loadSignoffConfig({ repoRoot: repoDir })).config.agentApp?.exemptions\n } catch {\n // A checkout with no signoff config, or one that does not load here, declares no exemptions.\n }\n const apiKey = process.env.TANGLE_INTELLIGENCE_API_KEY?.trim()\n if (probe && !apiKey) return usageError('--probe needs TANGLE_INTELLIGENCE_API_KEY')\n const exports = probe && apiKey ? await collectLastExports(repoDir, apiKey) : undefined\n const result = checkAppDefaults(repoDir, { exemptions, measureBundle, exports })\n if (jsonPath !== undefined) {\n const abs = resolve(jsonPath)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, `${JSON.stringify(result, null, 2)}\\n`)\n }\n process.stdout.write(formatAppDefaults(result))\n return result.findings.length === 0 ? 0 : 1\n}\n\nfunction usageError(message: string): number {\n process.stderr.write(`agent-app-signoff defaults: ${message}\\n\\n${defaultsUsage()}\\n`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AC,CAAC;AAChF,QAAM,OAAO,UAAU,IAAI;AAC3B,QAAM,SAAS,MAAM,WAAW,EAAE,GAAG,MAAM,SAAS,KAAK,QAAQ,SAAY,eAAe,EAAE,CAAC;AAE/F,MAAI,KAAK,aAAa,QAAW;AAC/B,UAAM,MAAMC,SAAQ,KAAK,QAAQ;AACjC,IAAAC,WAAUC,SAAQ,GAAG,GAAG,EAAE,WAAW,KAAK,CAAC;AAC3C,IAAAC,eAAc,KAAK,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,EAC3D;AAMA,UAAQ,OAAO,MAAM,GAAG,KAAK,QAAQ,kBAAkB,MAAM,IAAI,oBAAoB,MAAM,CAAC;AAAA,CAAI;AAChG,SAAO,OAAO,KAAK,IAAI;AACzB;AAGA,SAAS,gBAAgB,MAAoB;AAE3C,UAAQ,OAAO,MAAM,IAAI,MAAM;AAC7B,YAAQ,OAAO,MAAM,IAAI,MAAM;AAAE,cAAQ,KAAK,IAAI;AAAA,IAAE,CAAC;AAAA,EACvD,CAAC;AACH;AAEA,IAAI,gBAAgB,YAAY,KAAK,QAAQ,KAAK,CAAC,CAAC,GAAG;AACrD,gBAAc,QAAQ,KAAK,MAAM,CAAC,CAAC,EAChC,KAAK,eAAe,EACpB,MAAM,CAAC,QAAiB;AACvB,YAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,oBAAgB,CAAC;AAAA,EACnB,CAAC;AACL;","names":["mkdirSync","writeFileSync","dirname","resolve","resolve","mkdirSync","dirname","writeFileSync"]}
@@ -1,4 +1,4 @@
1
- import type { LoadedSignoffConfig, SignoffConfig } from './types';
1
+ import type { LoadedSignoffConfig, SignoffConfig, SignoffPhase } from './types';
2
2
  export declare function parseSignoffConfig(value: unknown, where: string): SignoffConfig;
3
3
  export declare function deriveSignoffConfig(scripts: Readonly<Record<string, string>>): {
4
4
  readonly config: SignoffConfig;
@@ -8,5 +8,7 @@ export interface LoadSignoffConfigOptions {
8
8
  readonly repoRoot: string;
9
9
  /** Explicit config path. Missing file is an error, never a silent fallback. */
10
10
  readonly configPath?: string;
11
+ /** Defaults to the full gate. Partial phases require complete classification. */
12
+ readonly phase?: SignoffPhase;
11
13
  }
12
14
  export declare function loadSignoffConfig(options: LoadSignoffConfigOptions): Promise<LoadedSignoffConfig>;
@@ -52,6 +52,7 @@
52
52
  */
53
53
  export { runSignoff, type RunSignoffOptions } from './run';
54
54
  export { loadSignoffConfig, type LoadSignoffConfigOptions } from './config';
55
+ export { pruneSignoffCache, type CachePruneOptions, type CachePruneResult } from './cache';
55
56
  export { formatSignoffReport } from './report';
56
57
  export { checkShellAlignment, collectShellDividers, formatShellAlignmentReport, judgeShellAlignment, SHELL_ALIGNMENT_TOLERANCE_PX, type ShellAlignmentFinding, type ShellAlignmentOptions, type ShellAlignmentReport, type ShellDivider, type ShellDividerSample, } from './shell-alignment';
57
58
  export { parseShellAlignmentArgs, runShellAlignmentCli } from './shell-alignment-cli';
@@ -61,4 +62,4 @@ export { checkWorkspaceSurface, collectWorkspaceSurface, formatWorkspaceSurfaceR
61
62
  export { runWorkspaceSurfaceCli } from './workspace-surface-cli';
62
63
  export { createRequestMeter, formatNetworkCount, isOverBudget, meterPage, reachedNetwork, NETWORK_OVER_BUDGET_EXIT, networkExitCode, QUIET_CHROMIUM_ARGS, REQUEST_BUDGET_PER_10S, type CdpResponseSource, type NetworkCount, type RequestMeter, } from './browser-budget';
63
64
  export { checkWorkerDefaults, formatWorkerDefaults, WORKER_COMPATIBILITY_DATE_FLOOR, type WorkerDefaultsFinding, type WorkerDefaultsResult, } from './worker-defaults';
64
- export type { LoadedSignoffConfig, SignoffAttempt, SignoffConfig, SignoffConfigOrigin, SignoffEvent, SignoffHostFacts, SignoffInstallResult, SignoffInstallSpec, SignoffRepoFacts, SignoffReport, SignoffShuffleSpec, SignoffSource, SignoffStepResult, SignoffStepSpec, SignoffStepStatus, } from './types';
65
+ export type { LoadedSignoffConfig, SignoffAttempt, SignoffConfig, SignoffConfigOrigin, SignoffEvent, SignoffHostFacts, SignoffInstallResult, SignoffInstallSpec, SignoffRepoFacts, SignoffReport, SignoffPhase, SignoffSelection, SignoffShuffleSpec, SignoffSource, SignoffStepResult, SignoffStepSpec, SignoffStepStatus, } from './types';
@@ -34,6 +34,7 @@ import {
34
34
  oklchL,
35
35
  parseShellAlignmentArgs,
36
36
  parseSurfaceLadderArgs,
37
+ pruneSignoffCache,
37
38
  reachedNetwork,
38
39
  runShellAlignmentCli,
39
40
  runSignoff,
@@ -41,7 +42,7 @@ import {
41
42
  runWorkspaceSurfaceCli,
42
43
  summarizeSurfacePage,
43
44
  surfaceDeltaL
44
- } from "../chunk-KS4I7KVC.js";
45
+ } from "../chunk-JRTWTADT.js";
45
46
  import "../chunk-LRYY3OX7.js";
46
47
  export {
47
48
  HEADER_TOP_TOLERANCE_PX,
@@ -79,6 +80,7 @@ export {
79
80
  oklchL,
80
81
  parseShellAlignmentArgs,
81
82
  parseSurfaceLadderArgs,
83
+ pruneSignoffCache,
82
84
  reachedNetwork,
83
85
  runShellAlignmentCli,
84
86
  runSignoff,
@@ -0,0 +1,3 @@
1
+ import type { LoadedSignoffConfig, SignoffPhase } from './types';
2
+ /** One selector for the runner and consumers of declared step metadata. */
3
+ export declare function selectSignoffPhase(loaded: LoadedSignoffConfig, phase?: SignoffPhase): LoadedSignoffConfig;
@@ -39,6 +39,9 @@ function seedsFromReport(report) {
39
39
  }
40
40
  function proofFromSignoffReport(input) {
41
41
  const { report } = input;
42
+ if (report.phase !== void 0 && report.phase !== "all") {
43
+ throw new Error(`signoff: partial phase ${report.phase} cannot issue a full sign-off proof`);
44
+ }
42
45
  const repoDir = input.repoDir ?? report.repo.root;
43
46
  const facts = readCommitFacts(repoDir, "HEAD");
44
47
  if (facts.commit !== report.repo.head) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/signoff/proof-from-report.ts"],"sourcesContent":["/**\n * The join between the runner and the proof: one sign-off run produces one\n * report, and this turns that report into the signed, attachable record.\n *\n * Nothing here re-runs or re-judges anything. The runner owns what happened; the\n * proof owns what is provable about it later. Keeping the two in one direction\n * is what stops a second, drifting idea of \"which steps ran\" from appearing.\n */\nimport { hashStepOutput, buildSignoffProof, type SignoffProof, type SignoffProofStep } from './proof-record'\nimport { readCommitFacts } from './proof-git'\nimport type { SignoffReport, SignoffStepResult } from './types'\n\n/**\n * A step that never executed has no exit code, so it is recorded as one no\n * process can produce. `status` is what a reader and the verifier judge on;\n * this exists so the field is never a plausible-looking `0`.\n */\nconst NO_EXIT_CODE = -1\n\n/** The `command` of a step that never executed. A skipped step had no command line. */\nconst NOT_EXECUTED_COMMAND = '(never executed)'\n\nexport interface ProofFromReportInput {\n readonly report: SignoffReport\n /** Repo identity the verifier's required-step table is keyed on. */\n readonly repo: string\n /** Source repository. Defaults to the root the run recorded. */\n readonly repoDir?: string\n /** Step ids the run treated as required. Defaults to every step the report carries. */\n readonly declaredRequired?: readonly string[]\n readonly key?: Uint8Array\n readonly now?: Date\n}\n\nfunction stepFromResult(result: SignoffStepResult, startedAtEpochMs: number): SignoffProofStep {\n const attempts = result.attempts\n const worst = attempts.reduce<number>((worstSoFar, attempt) => (attempt.exitCode !== 0 ? attempt.exitCode : worstSoFar), 0)\n return {\n id: result.name,\n command: attempts[0]?.command ?? NOT_EXECUTED_COMMAND,\n cwd: '.',\n status: result.status,\n exitCode: attempts.length === 0 ? NO_EXIT_CODE : worst,\n durationMs: Math.max(0, Math.round(result.durationMs)),\n startedAt: new Date(startedAtEpochMs + (result.startedAtMs ?? 0)).toISOString(),\n // Every attempt's output, in order — a shuffled step that failed on the\n // second seed must not digest to the same value as one that passed twice.\n outputSha256: hashStepOutput(attempts.map((attempt) => attempt.output).join('\\n')),\n }\n}\n\n/** Every seed the run used, keyed so a reader can replay one step rather than the whole run. */\nfunction seedsFromReport(report: SignoffReport): Record<string, string | number> {\n const seeds: Record<string, string | number> = { base: report.seedBase }\n for (const step of report.steps) {\n step.attempts.forEach((attempt, index) => {\n if (attempt.seed !== null) seeds[`${step.name}#${index}`] = attempt.seed\n })\n }\n return seeds\n}\n\nexport function proofFromSignoffReport(input: ProofFromReportInput): SignoffProof {\n const { report } = input\n const repoDir = input.repoDir ?? report.repo.root\n\n // HEAD moving during a run makes every later claim ambiguous — the checks ran\n // over one commit and the proof would name another. Refused, not reconciled.\n const facts = readCommitFacts(repoDir, 'HEAD')\n if (facts.commit !== report.repo.head) {\n throw new Error(`HEAD moved during the sign-off: the run verified ${report.repo.head}, ${repoDir} is now at ${facts.commit}`)\n }\n\n const startedAtEpochMs = Date.parse(report.startedAt)\n const install: SignoffProofStep = {\n id: 'install',\n command: report.install.command,\n cwd: report.workspace,\n status: report.install.exitCode === 0 ? 'passed' : 'failed',\n exitCode: report.install.exitCode,\n durationMs: Math.max(0, Math.round(report.install.durationMs)),\n startedAt: new Date(startedAtEpochMs).toISOString(),\n outputSha256: hashStepOutput(report.install.output),\n }\n const steps = [install, ...report.steps.map((step) => stepFromResult(step, startedAtEpochMs))]\n\n return buildSignoffProof({\n repoDir,\n repo: input.repo,\n steps,\n wallClockMs: report.wallClockMs,\n declaredRequired: input.declaredRequired ?? steps.map((step) => step.id),\n seeds: seedsFromReport(report),\n key: input.key,\n now: input.now,\n })\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAM,eAAe;AAGrB,IAAM,uBAAuB;AAc7B,SAAS,eAAe,QAA2B,kBAA4C;AAC7F,QAAM,WAAW,OAAO;AACxB,QAAM,QAAQ,SAAS,OAAe,CAAC,YAAY,YAAa,QAAQ,aAAa,IAAI,QAAQ,WAAW,YAAa,CAAC;AAC1H,SAAO;AAAA,IACL,IAAI,OAAO;AAAA,IACX,SAAS,SAAS,CAAC,GAAG,WAAW;AAAA,IACjC,KAAK;AAAA,IACL,QAAQ,OAAO;AAAA,IACf,UAAU,SAAS,WAAW,IAAI,eAAe;AAAA,IACjD,YAAY,KAAK,IAA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,IAAI,CAAC,SAAS,eAAe,MAAM,gBAAgB,CAAC,CAAC;AAE7F,SAAO,kBAAkB;AAAA,IACvB;AAAA,IACA,MAAM,MAAM;AAAA,IACZ;AAAA,IACA,aAAa,OAAO;AAAA,IACpB,kBAAkB,MAAM,oBAAoB,MAAM,IAAI,CAAC,SAAS,KAAK,EAAE;AAAA,IACvE,OAAO,gBAAgB,MAAM;AAAA,IAC7B,KAAK,MAAM;AAAA,IACX,KAAK,MAAM;AAAA,EACb,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/signoff/proof-from-report.ts"],"sourcesContent":["/**\n * The join between the runner and the proof: one sign-off run produces one\n * report, and this turns that report into the signed, attachable record.\n *\n * Nothing here re-runs or re-judges anything. The runner owns what happened; the\n * proof owns what is provable about it later. Keeping the two in one direction\n * is what stops a second, drifting idea of \"which steps ran\" from appearing.\n */\nimport { hashStepOutput, buildSignoffProof, type SignoffProof, type SignoffProofStep } from './proof-record'\nimport { readCommitFacts } from './proof-git'\nimport type { SignoffReport, SignoffStepResult } from './types'\n\n/**\n * A step that never executed has no exit code, so it is recorded as one no\n * process can produce. `status` is what a reader and the verifier judge on;\n * this exists so the field is never a plausible-looking `0`.\n */\nconst NO_EXIT_CODE = -1\n\n/** The `command` of a step that never executed. A skipped step had no command line. */\nconst NOT_EXECUTED_COMMAND = '(never executed)'\n\nexport interface ProofFromReportInput {\n readonly report: SignoffReport\n /** Repo identity the verifier's required-step table is keyed on. */\n readonly repo: string\n /** Source repository. Defaults to the root the run recorded. */\n readonly repoDir?: string\n /** Step ids the run treated as required. Defaults to every step the report carries. */\n readonly declaredRequired?: readonly string[]\n readonly key?: Uint8Array\n readonly now?: Date\n}\n\nfunction stepFromResult(result: SignoffStepResult, startedAtEpochMs: number): SignoffProofStep {\n const attempts = result.attempts\n const worst = attempts.reduce<number>((worstSoFar, attempt) => (attempt.exitCode !== 0 ? attempt.exitCode : worstSoFar), 0)\n return {\n id: result.name,\n command: attempts[0]?.command ?? NOT_EXECUTED_COMMAND,\n cwd: '.',\n status: result.status,\n exitCode: attempts.length === 0 ? NO_EXIT_CODE : worst,\n durationMs: Math.max(0, Math.round(result.durationMs)),\n startedAt: new Date(startedAtEpochMs + (result.startedAtMs ?? 0)).toISOString(),\n // Every attempt's output, in order — a shuffled step that failed on the\n // second seed must not digest to the same value as one that passed twice.\n outputSha256: hashStepOutput(attempts.map((attempt) => attempt.output).join('\\n')),\n }\n}\n\n/** Every seed the run used, keyed so a reader can replay one step rather than the whole run. */\nfunction seedsFromReport(report: SignoffReport): Record<string, string | number> {\n const seeds: Record<string, string | number> = { base: report.seedBase }\n for (const step of report.steps) {\n step.attempts.forEach((attempt, index) => {\n if (attempt.seed !== null) seeds[`${step.name}#${index}`] = attempt.seed\n })\n }\n return seeds\n}\n\nexport function proofFromSignoffReport(input: ProofFromReportInput): SignoffProof {\n const { report } = input\n if (report.phase !== undefined && report.phase !== 'all') {\n throw new Error(`signoff: partial phase ${report.phase} cannot issue a full sign-off proof`)\n }\n const repoDir = input.repoDir ?? report.repo.root\n\n // HEAD moving during a run makes every later claim ambiguous — the checks ran\n // over one commit and the proof would name another. Refused, not reconciled.\n const facts = readCommitFacts(repoDir, 'HEAD')\n if (facts.commit !== report.repo.head) {\n throw new Error(`HEAD moved during the sign-off: the run verified ${report.repo.head}, ${repoDir} is now at ${facts.commit}`)\n }\n\n const startedAtEpochMs = Date.parse(report.startedAt)\n const install: SignoffProofStep = {\n id: 'install',\n command: report.install.command,\n cwd: report.workspace,\n status: report.install.exitCode === 0 ? 'passed' : 'failed',\n exitCode: report.install.exitCode,\n durationMs: Math.max(0, Math.round(report.install.durationMs)),\n startedAt: new Date(startedAtEpochMs).toISOString(),\n outputSha256: hashStepOutput(report.install.output),\n }\n const steps = [install, ...report.steps.map((step) => stepFromResult(step, startedAtEpochMs))]\n\n return buildSignoffProof({\n repoDir,\n repo: input.repo,\n steps,\n wallClockMs: report.wallClockMs,\n declaredRequired: input.declaredRequired ?? steps.map((step) =>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,WAAW,OAAO,KAAK,MAAM;AACrC,UAAM,IAAI,MAAM,oDAAoD,OAAO,KAAK,IAAI,KAAK,OAAO,cAAc,MAAM,MAAM,EAAE;AAAA,EAC9H;AAEA,QAAM,mBAAmB,KAAK,MAAM,OAAO,SAAS;AACpD,QAAM,UAA4B;AAAA,IAChC,IAAI;AAAA,IACJ,SAAS,OAAO,QAAQ;AAAA,IACxB,KAAK,OAAO;AAAA,IACZ,QAAQ,OAAO,QAAQ,aAAa,IAAI,WAAW;AAAA,IACnD,UAAU,OAAO,QAAQ;AAAA,IACzB,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,QAAQ,UAAU,CAAC;AAAA,IAC7D,WAAW,IAAI,KAAK,gBAAgB,EAAE,YAAY;AAAA,IAClD,cAAc,eAAe,OAAO,QAAQ,MAAM;AAAA,EACpD;AACA,QAAM,QAAQ,CAAC,SAAS,GAAG,OAAO,MAAM,IAAI,CAAC,SAAS,eAAe,MAAM,gBAAgB,CAAC,CAAC;AAE7F,SAAO,kBAAkB;AAAA,IACvB;AAAA,IACA,MAAM,MAAM;AAAA,IACZ;AAAA,IACA,aAAa,OAAO;AAAA,IACpB,kBAAkB,MAAM,oBAAoB,MAAM,IAAI,CAAC,SAAS,KAAK,EAAE;AAAA,IACvE,OAAO,gBAAgB,MAAM;AAAA,IAC7B,KAAK,MAAM;AAAA,IACX,KAAK,MAAM;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -1,4 +1,4 @@
1
- import type { SignoffEvent, SignoffReport, SignoffSource } from './types';
1
+ import type { SignoffEvent, SignoffReport, SignoffPhase, SignoffSource } from './types';
2
2
  /**
3
3
  * The sign-off run: reproduce a clean CI environment, then go further.
4
4
  *
@@ -22,6 +22,8 @@ export interface RunSignoffOptions {
22
22
  readonly configPath?: string;
23
23
  /** Default `working-tree` — verify what you are about to commit. */
24
24
  readonly source?: SignoffSource;
25
+ /** Default all. Partial phases run declared steps and their prerequisites. */
26
+ readonly phase?: SignoffPhase;
25
27
  /** Run every step even after one fails. Default false. */
26
28
  readonly keepGoing?: boolean;
27
29
  /** Base seed. Pass a previous run's to reproduce it exactly. */
@@ -11,6 +11,13 @@
11
11
  * gates.
12
12
  */
13
13
  import type { AppDefaultsExemptions } from './app-defaults';
14
+ export type SignoffPhase = 'all' | 'release' | 'suites';
15
+ /** Declared scope, including dependency steps brought into a partial run. */
16
+ export interface SignoffSelection {
17
+ readonly requested: readonly string[];
18
+ readonly prerequisites: readonly string[];
19
+ readonly excluded: readonly string[];
20
+ }
14
21
  /** Which bytes get verified. */
15
22
  export type SignoffSource =
16
23
  /** Exactly the commit that would merge. Uncommitted work is NOT included. */
@@ -38,6 +45,8 @@ export interface SignoffShuffleSpec {
38
45
  }
39
46
  /** One verification step — a CI step, declared by the repo. */
40
47
  export interface SignoffStepSpec {
48
+ /** Required on every step before selecting a partial phase. No name inference. */
49
+ readonly phase?: Exclude<SignoffPhase, 'all'>;
41
50
  /** Unique within the config. Names the failure in the report. */
42
51
  readonly name: string;
43
52
  /** Shell command, run from `cwd` inside the clean tree. */
@@ -122,6 +131,7 @@ export type SignoffConfigOrigin = {
122
131
  export interface LoadedSignoffConfig {
123
132
  readonly config: SignoffConfig;
124
133
  readonly origin: SignoffConfigOrigin;
134
+ readonly selection?: SignoffSelection;
125
135
  }
126
136
  /** One execution of a step's command. A shuffled step has several. */
127
137
  export interface SignoffAttempt {
@@ -192,6 +202,9 @@ export interface SignoffHostFacts {
192
202
  readonly cpus: number;
193
203
  }
194
204
  export interface SignoffReport {
205
+ /** Absent on historical reports, which always ran the full gate. */
206
+ readonly phase?: SignoffPhase;
207
+ readonly selection?: SignoffSelection;
195
208
  readonly ok: boolean;
196
209
  readonly startedAt: string;
197
210
  readonly repo: SignoffRepoFacts;
@@ -1,13 +1,13 @@
1
+ import {
2
+ resolveSkillDir
3
+ } from "../chunk-WPPDNS63.js";
4
+ import "../chunk-76MPX7JQ.js";
5
+ import "../chunk-PV33JZKV.js";
1
6
  import {
2
7
  shellQuote,
3
8
  writeProfileFilesToBox
4
9
  } from "../chunk-CTREXL3O.js";
5
- import {
6
- resolveSkillDir
7
- } from "../chunk-54YIL7WM.js";
8
10
  import "../chunk-ELX5YITO.js";
9
- import "../chunk-76MPX7JQ.js";
10
- import "../chunk-PV33JZKV.js";
11
11
  import {
12
12
  sha256Hex
13
13
  } from "../chunk-HY57QRRW.js";
@@ -4,10 +4,10 @@ import {
4
4
  skillSupportFileMounts,
5
5
  unsupportedSkillHarnesses,
6
6
  withSkillSupportFiles
7
- } from "../chunk-54YIL7WM.js";
8
- import "../chunk-ELX5YITO.js";
7
+ } from "../chunk-WPPDNS63.js";
9
8
  import "../chunk-76MPX7JQ.js";
10
9
  import "../chunk-PV33JZKV.js";
10
+ import "../chunk-ELX5YITO.js";
11
11
  export {
12
12
  composeSkillsForHarness,
13
13
  resolveSkillDir,
@@ -24,8 +24,8 @@ import {
24
24
  verifyCapabilityToken,
25
25
  verifyExpiringCapabilityToken
26
26
  } from "../chunk-O7UX55EU.js";
27
- import "../chunk-S5SRJJQG.js";
28
27
  import "../chunk-XEAZWJ3W.js";
28
+ import "../chunk-S5SRJJQG.js";
29
29
  import {
30
30
  APP_TOOL_NAMES,
31
31
  buildAppToolOpenAITools,
@@ -14,7 +14,9 @@ export interface TurnStreamStubLike {
14
14
  /** The surface of `DurableObjectNamespace` the adapters use. */
15
15
  export interface TurnStreamNamespaceLike {
16
16
  idFromName(name: string): unknown;
17
- get(id: unknown): TurnStreamStubLike;
17
+ get(id: unknown, options?: {
18
+ locationHint?: string;
19
+ }): TurnStreamStubLike;
18
20
  }
19
21
  /** The HMAC secret shared between this worker and its `TurnStreamDO` binding.
20
22
  * Every adapter call mints a channel-bound capability token from it; the DO
@@ -53,9 +55,13 @@ export declare function acquireDurableTurnLock(namespace: TurnStreamNamespaceLik
53
55
  */
54
56
  export declare function peekDurableTurnLock(namespace: TurnStreamNamespaceLike, input: {
55
57
  workspaceId: string;
56
- threadId: string;
58
+ } & ({
59
+ scope: 'workspace';
60
+ threadId?: string;
61
+ } | {
57
62
  scope: TurnLockScope;
58
- }, auth: TurnStreamAuth): Promise<DurableTurnLock | null>;
63
+ threadId: string;
64
+ }), auth: TurnStreamAuth): Promise<DurableTurnLock | null>;
59
65
  /** Release a durable turn lock and indicate if the release was successful or deferred */
60
66
  export declare function releaseDurableTurnLock(namespace: TurnStreamNamespaceLike, input: TurnLockReleaseInput, auth: TurnStreamAuth): Promise<{
61
67
  released: boolean;
@@ -158,7 +164,7 @@ export declare function createDurableTurnLock<TContext>(options: CreateDurableTu
158
164
  release(handle: unknown): Promise<void>;
159
165
  warm(target: {
160
166
  tenantId: string;
161
- threadId: string;
167
+ threadId?: string;
162
168
  }): Promise<void>;
163
169
  };
164
170
  /** Coarse per-workspace marker that a thread's turn started / ended — drives