@tangle-network/agent-app 0.60.62 → 0.60.64

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 (113) hide show
  1. package/dist/{DesignCanvasEditor-3DL3PF6P.js → DesignCanvasEditor-UOOPYYYR.js} +3 -3
  2. package/dist/VaultPane-XUAGL5SP.js +7 -0
  3. package/dist/agent-profiles/d1.js +3 -3
  4. package/dist/agent-profiles/index.js +3 -3
  5. package/dist/app-auth/index.js +3 -3
  6. package/dist/assistant/index.js +11 -10
  7. package/dist/assistant/index.js.map +1 -1
  8. package/dist/chat-react/index.js +1 -1
  9. package/dist/chat-routes/index.js +16 -16
  10. package/dist/chat-store/index.js +3 -3
  11. package/dist/{chunk-FAU5FIFD.js → chunk-2FLSODOX.js} +3 -2
  12. package/dist/chunk-2FLSODOX.js.map +1 -0
  13. package/dist/chunk-5UQJ7F3P.js +41 -0
  14. package/dist/chunk-5UQJ7F3P.js.map +1 -0
  15. package/dist/{chunk-YXYQ6MJL.js → chunk-5V6VTO5Q.js} +65 -2
  16. package/dist/chunk-5V6VTO5Q.js.map +1 -0
  17. package/dist/chunk-7UB4K2R2.js +470 -0
  18. package/dist/chunk-7UB4K2R2.js.map +1 -0
  19. package/dist/{chunk-T2IESIJ7.js → chunk-BMZTYGKE.js} +2 -2
  20. package/dist/{chunk-2YLSWZ5W.js → chunk-JBEFTXDO.js} +4 -4
  21. package/dist/{chunk-JGZ7WEPL.js → chunk-JC7YSRBR.js} +15 -1
  22. package/dist/chunk-JC7YSRBR.js.map +1 -0
  23. package/dist/{chunk-N7ZJWESQ.js → chunk-KBTY4AAU.js} +274 -4
  24. package/dist/chunk-KBTY4AAU.js.map +1 -0
  25. package/dist/{chunk-S2G5NAWV.js → chunk-KSITU6BQ.js} +4 -4
  26. package/dist/{chunk-CN5HNTU6.js → chunk-NRG2YHGY.js} +2 -2
  27. package/dist/{chunk-GNA5I5NM.js → chunk-ORFRFCXQ.js} +53 -22
  28. package/dist/chunk-ORFRFCXQ.js.map +1 -0
  29. package/dist/{chunk-4WJREKXX.js → chunk-OUW5AI2G.js} +9 -9
  30. package/dist/chunk-OUW5AI2G.js.map +1 -0
  31. package/dist/{chunk-M36GXE2W.js → chunk-QXKKS3I4.js} +3 -3
  32. package/dist/chunk-RYUTKTOR.js +510 -0
  33. package/dist/chunk-RYUTKTOR.js.map +1 -0
  34. package/dist/{chunk-FWLCPAST.js → chunk-SH56N4PV.js} +3 -3
  35. package/dist/{chunk-QBNV6BJ4.js → chunk-ST3ARHJH.js} +3 -2
  36. package/dist/chunk-ST3ARHJH.js.map +1 -0
  37. package/dist/{chunk-4DIO2LTR.js → chunk-TMOYOMSW.js} +5 -5
  38. package/dist/{chunk-4DIO2LTR.js.map → chunk-TMOYOMSW.js.map} +1 -1
  39. package/dist/{chunk-J7TCMW2J.js → chunk-XMIV374H.js} +2 -2
  40. package/dist/{chunk-ZGUXI5SI.js → chunk-XNKLQG26.js} +5 -5
  41. package/dist/{chunk-XCBDWT5H.js → chunk-Z362IHYL.js} +2 -2
  42. package/dist/{chunk-VUXCM5ZO.js → chunk-ZZACC24K.js} +1 -1
  43. package/dist/{chunk-VUXCM5ZO.js.map → chunk-ZZACC24K.js.map} +1 -1
  44. package/dist/design-canvas-react/index.js +6 -6
  45. package/dist/design-canvas-react/lazy.js +1 -1
  46. package/dist/launch-invariants/auth-lookup-cache.d.ts +57 -0
  47. package/dist/launch-invariants/catalog.d.ts +51 -0
  48. package/dist/launch-invariants/cli.d.ts +10 -0
  49. package/dist/launch-invariants/cli.js +88 -0
  50. package/dist/launch-invariants/cli.js.map +1 -0
  51. package/dist/launch-invariants/conformance.d.ts +49 -0
  52. package/dist/launch-invariants/index.d.ts +19 -0
  53. package/dist/launch-invariants/index.js +253 -0
  54. package/dist/launch-invariants/index.js.map +1 -0
  55. package/dist/launch-invariants/limit-alarms.d.ts +66 -0
  56. package/dist/launch-invariants/schedule.d.ts +114 -0
  57. package/dist/launch-invariants/settlement.d.ts +90 -0
  58. package/dist/launch-invariants/sized-reads.d.ts +50 -0
  59. package/dist/launch-invariants/testing.d.ts +175 -0
  60. package/dist/launch-invariants/testing.js +45 -0
  61. package/dist/launch-invariants/testing.js.map +1 -0
  62. package/dist/preset-cloudflare/index.js +2 -2
  63. package/dist/public-consultation/index.js +7 -7
  64. package/dist/sandbox/index.js +4 -4
  65. package/dist/signoff/cli.js +7 -2
  66. package/dist/signoff/cli.js.map +1 -1
  67. package/dist/signoff/index.d.ts +2 -0
  68. package/dist/signoff/index.js +15 -1
  69. package/dist/signoff/shell-alignment-cli.d.ts +8 -0
  70. package/dist/signoff/shell-alignment.d.ts +82 -0
  71. package/dist/stream/index.d.ts +1 -0
  72. package/dist/stream/index.js +9 -5
  73. package/dist/stream/orphaned-turns.d.ts +56 -0
  74. package/dist/stream/turn-buffer.d.ts +12 -0
  75. package/dist/studio-react/index.js +1 -1
  76. package/dist/teams/invitations-api.js +3 -3
  77. package/dist/theme/brand.generated.d.ts +1 -1
  78. package/dist/theme/index.js +1 -1
  79. package/dist/theme/tokens.css +7 -2
  80. package/dist/tools/index.js +4 -4
  81. package/dist/turn-health/index.js +6 -17
  82. package/dist/turn-health/index.js.map +1 -1
  83. package/dist/turn-stream/index.js +1 -1
  84. package/dist/vault/index.js +1 -1
  85. package/dist/vault/lazy.js +1 -1
  86. package/dist/web-react/index.d.ts +1 -1
  87. package/dist/web-react/index.js +19 -15
  88. package/dist/web-react/lazy-load-boundary.d.ts +19 -1
  89. package/dist/work-product/index.js +2 -2
  90. package/dist/workspace-export/index.js +30 -9
  91. package/dist/workspace-export/index.js.map +1 -1
  92. package/dist/workspace-export/react.js +14 -5
  93. package/dist/workspace-export/react.js.map +1 -1
  94. package/package.json +23 -12
  95. package/dist/VaultPane-A2RGT5PI.js +0 -7
  96. package/dist/chunk-4WJREKXX.js.map +0 -1
  97. package/dist/chunk-FAU5FIFD.js.map +0 -1
  98. package/dist/chunk-GNA5I5NM.js.map +0 -1
  99. package/dist/chunk-JGZ7WEPL.js.map +0 -1
  100. package/dist/chunk-N7ZJWESQ.js.map +0 -1
  101. package/dist/chunk-QBNV6BJ4.js.map +0 -1
  102. package/dist/chunk-YXYQ6MJL.js.map +0 -1
  103. /package/dist/{DesignCanvasEditor-3DL3PF6P.js.map → DesignCanvasEditor-UOOPYYYR.js.map} +0 -0
  104. /package/dist/{VaultPane-A2RGT5PI.js.map → VaultPane-XUAGL5SP.js.map} +0 -0
  105. /package/dist/{chunk-T2IESIJ7.js.map → chunk-BMZTYGKE.js.map} +0 -0
  106. /package/dist/{chunk-2YLSWZ5W.js.map → chunk-JBEFTXDO.js.map} +0 -0
  107. /package/dist/{chunk-S2G5NAWV.js.map → chunk-KSITU6BQ.js.map} +0 -0
  108. /package/dist/{chunk-CN5HNTU6.js.map → chunk-NRG2YHGY.js.map} +0 -0
  109. /package/dist/{chunk-M36GXE2W.js.map → chunk-QXKKS3I4.js.map} +0 -0
  110. /package/dist/{chunk-FWLCPAST.js.map → chunk-SH56N4PV.js.map} +0 -0
  111. /package/dist/{chunk-J7TCMW2J.js.map → chunk-XMIV374H.js.map} +0 -0
  112. /package/dist/{chunk-ZGUXI5SI.js.map → chunk-XNKLQG26.js.map} +0 -0
  113. /package/dist/{chunk-XCBDWT5H.js.map → chunk-Z362IHYL.js.map} +0 -0
@@ -0,0 +1,175 @@
1
+ import type { AlertSink } from '../turn-health/sink.js';
2
+ import { type InvariantVerdict } from './catalog.js';
3
+ import { type LimitAlarms } from './limit-alarms.js';
4
+ export { describeVerdict } from './catalog.js';
5
+ /** Set by `agent-app-invariants` to the file it reads verdicts from. */
6
+ export declare const INVARIANT_RESULTS_ENV = "AGENT_APP_INVARIANTS_RESULTS";
7
+ /**
8
+ * Record a verdict for the conformance report and fail the caller when it did
9
+ * not pass. Returns the verdict on a pass.
10
+ */
11
+ export declare function recordInvariant(verdict: InvariantVerdict): InvariantVerdict;
12
+ /** Record several verdicts; fails after recording all of them. */
13
+ export declare function recordInvariants(verdicts: readonly InvariantVerdict[]): InvariantVerdict[];
14
+ /** Run a full garbage collection, so a heap reading counts only live objects. */
15
+ export declare function forceGc(): void;
16
+ /** What a measured binding saw while one job ran. */
17
+ export interface D1Reads {
18
+ queries: number;
19
+ maxQueryBytes: number;
20
+ /** The query that returned the most bytes. */
21
+ largestSql: string;
22
+ peakHeapBytes: number;
23
+ /** The query running when the heap peaked: where a job holds what it read. */
24
+ peakSql: string;
25
+ }
26
+ /**
27
+ * The D1 binding with every response measured (serialized bytes) and the live
28
+ * heap sampled after a collection before and after every query. Works over
29
+ * Cloudflare D1 and the sqlite-backed D1 shims apps test with. A database
30
+ * engine that keeps its pages off the JS heap (node:sqlite, better-sqlite3)
31
+ * leaves heap growth to the job's own objects.
32
+ */
33
+ export declare function measureD1<D extends object>(d1: D, reads?: D1Reads, options?: {
34
+ sampleHeap?: boolean;
35
+ }): {
36
+ d1: D;
37
+ reads: D1Reads;
38
+ };
39
+ /** One scheduled job (or report route) as the budget check runs it. */
40
+ export interface BudgetedJob {
41
+ name: string;
42
+ run: () => Promise<unknown>;
43
+ /** False for a job that reads nothing from D1 (it then passes bounded reads vacuously). Default true. */
44
+ readsD1?: boolean;
45
+ }
46
+ export interface JobMeasurement {
47
+ name: string;
48
+ reads: D1Reads;
49
+ heapGrowthBytes: number;
50
+ error?: string;
51
+ }
52
+ export interface ScheduledJobBudgetOptions {
53
+ /** The app's D1 over its day-sized fixture. */
54
+ d1: object;
55
+ /** Point the app's database accessor at the measured binding (`setD1`, `setDatabase(drizzle(...))`). */
56
+ install: (measured: object) => void;
57
+ jobs: readonly BudgetedJob[];
58
+ /** Every job the app schedules, by the names {@link jobs} uses. Each must be measured. */
59
+ scheduled: readonly string[];
60
+ maxQueryBytes?: number;
61
+ maxHeapGrowthBytes?: number;
62
+ /** Silence the jobs' own logging while they run. Default true. */
63
+ quiet?: boolean;
64
+ }
65
+ /** Run one job against a measured binding. */
66
+ export declare function measureJob(job: BudgetedJob, d1: object, install: (measured: object) => void, quiet?: boolean): Promise<JobMeasurement>;
67
+ /**
68
+ * Bounded reads and the memory budget for every scheduled job, on the app's
69
+ * day-sized fixture. Returns a bounded-reads and a memory-budget verdict per
70
+ * job, and a coverage verdict naming any scheduled job that was not run.
71
+ */
72
+ export declare function checkScheduledJobBudgets(options: ScheduledJobBudgetOptions): Promise<InvariantVerdict[]>;
73
+ export type StallMode = 'ok' | 'error' | 'hang';
74
+ /** The D1 binding with a switch that makes every query fail or never answer, as an overloaded D1 did. */
75
+ export declare function stallingD1<D extends object>(d1: D): {
76
+ d1: D;
77
+ stall(mode: StallMode): void;
78
+ readonly mode: StallMode;
79
+ };
80
+ export interface AuthStallOptions {
81
+ /** A label for the lookup: "session", "API key". */
82
+ subject: string;
83
+ /** Three distinct valid credentials the app's store accepts. */
84
+ credentials: {
85
+ cached: string;
86
+ revoked: string;
87
+ aged: string;
88
+ };
89
+ /** The app's real lookup: truthy when the credential is accepted. A throw or a falsy value is a refusal. */
90
+ verify: (credential: string) => Promise<unknown>;
91
+ /** The app's real revoke path (revoke the key, sign the session out). */
92
+ revoke: (credential: string) => Promise<void>;
93
+ /** Switch the D1 the lookup reads. */
94
+ stall: (mode: StallMode) => void;
95
+ /** The keys the app's auth caches hold. */
96
+ cacheKeys: () => string[];
97
+ /** Include a stall that never answers (costs one lookup deadline, 2.5 s). Default true. */
98
+ hang?: boolean;
99
+ }
100
+ /**
101
+ * A verified credential keeps working while D1 errors or stalls; it is refused
102
+ * once revoked, and once its last verification is more than 60 s old; and the
103
+ * cache holds SHA-256 keys, not secrets. Uses the app's real lookup, revoke
104
+ * path and D1, with `Date.now` moved forward to age the cache.
105
+ */
106
+ export declare function checkAuthSurvivesStall(options: AuthStallOptions): Promise<InvariantVerdict>;
107
+ export interface AuthorizeBeforeStreamOptions {
108
+ subject: string;
109
+ /** The app's real route handler, as its router mounts it. */
110
+ handle: (request: Request) => Promise<Response>;
111
+ /** Requests the route must refuse: no session, another workspace's thread, a revoked key. */
112
+ refused: ReadonlyArray<{
113
+ name: string;
114
+ request: () => Request;
115
+ status?: readonly number[];
116
+ }>;
117
+ /** Product state the route touched (rows written, producers started); empty after every refusal. */
118
+ touched?: () => readonly string[];
119
+ }
120
+ /** Each refused request gets a plain 4xx, opens no stream and touches nothing. */
121
+ export declare function checkAuthorizeBeforeStream(options: AuthorizeBeforeStreamOptions): Promise<InvariantVerdict>;
122
+ /** One event of the recorded long turn and the turn-relative time it arrived. */
123
+ export interface TimedTurnEvent {
124
+ atMs: number;
125
+ event: Record<string, unknown>;
126
+ }
127
+ /**
128
+ * The long turn GTM recorded on 2026-10-10, reproduced in shape: a reasoning
129
+ * model streaming three events per token (the harness's raw part update, a
130
+ * model-processing heartbeat and the delta), with tool calls between runs of
131
+ * reasoning and text. 59,659 events over about ten minutes, as that turn wrote
132
+ * them before coalescing.
133
+ */
134
+ export declare function recordedLongTurn(options?: {
135
+ tokens?: number;
136
+ toolCalls?: number;
137
+ tokenMs?: number;
138
+ }): TimedTurnEvent[];
139
+ export interface CoalescedTurnOptions {
140
+ subject: string;
141
+ /**
142
+ * Start persisting one turn through the app's real turn persistence (its turn
143
+ * store and buffer, as its chat route builds them). `detach` hands the turn
144
+ * to a durable owner the way the route's completion handoff does; omit it when
145
+ * the app has no detached lane.
146
+ */
147
+ open: (turnId: string) => Promise<{
148
+ onEvent(event: unknown): Promise<void>;
149
+ detach?(): Promise<void>;
150
+ done(): Promise<void>;
151
+ }>;
152
+ /** Stored events for the turn. */
153
+ count: (turnId: string) => Promise<number>;
154
+ maxEvents?: number;
155
+ fixture?: readonly TimedTurnEvent[];
156
+ }
157
+ /** The recorded long turn stores at most 5,000 events, attached and after a handoff. */
158
+ export declare function checkCoalescedTurn(options: CoalescedTurnOptions): Promise<InvariantVerdict>;
159
+ /** Hard platform limits a declared budget may not exceed. */
160
+ export declare const PLATFORM_LIMITS: {
161
+ /** A Worker isolate's memory. */
162
+ readonly 'worker-memory': number;
163
+ /** Platform snapshots per sandbox; the cap GTM hit on 2026-10-10. */
164
+ readonly 'snapshot-count': 25;
165
+ /** Requests per minute per operator key. */
166
+ readonly 'key-rate': 60;
167
+ };
168
+ export interface LimitAlarmCheckOptions {
169
+ subject: string;
170
+ /** Build the app's real limit alarms (its budgets and wiring) over a capturing sink. */
171
+ create: (sink: AlertSink) => LimitAlarms | Promise<LimitAlarms>;
172
+ }
173
+ /** Every resource alarms at 80% and not below, escalates at the limit, and no budget exceeds the platform's. */
174
+ export declare function checkLimitAlarms(options: LimitAlarmCheckOptions): Promise<InvariantVerdict>;
175
+ export { buildConformanceReport, formatConformanceReport, readDeploymentFacts, readVerdicts, type ConformanceReport, type DeploymentFacts, type InvariantReport, type InvariantStatus, type LaunchInvariantsConfig, } from './conformance.js';
@@ -0,0 +1,45 @@
1
+ import {
2
+ INVARIANT_RESULTS_ENV,
3
+ PLATFORM_LIMITS,
4
+ buildConformanceReport,
5
+ checkAuthSurvivesStall,
6
+ checkAuthorizeBeforeStream,
7
+ checkCoalescedTurn,
8
+ checkLimitAlarms,
9
+ checkScheduledJobBudgets,
10
+ forceGc,
11
+ formatConformanceReport,
12
+ measureD1,
13
+ measureJob,
14
+ readDeploymentFacts,
15
+ readVerdicts,
16
+ recordInvariant,
17
+ recordInvariants,
18
+ recordedLongTurn,
19
+ stallingD1
20
+ } from "../chunk-RYUTKTOR.js";
21
+ import {
22
+ describeVerdict
23
+ } from "../chunk-7UB4K2R2.js";
24
+ export {
25
+ INVARIANT_RESULTS_ENV,
26
+ PLATFORM_LIMITS,
27
+ buildConformanceReport,
28
+ checkAuthSurvivesStall,
29
+ checkAuthorizeBeforeStream,
30
+ checkCoalescedTurn,
31
+ checkLimitAlarms,
32
+ checkScheduledJobBudgets,
33
+ describeVerdict,
34
+ forceGc,
35
+ formatConformanceReport,
36
+ measureD1,
37
+ measureJob,
38
+ readDeploymentFacts,
39
+ readVerdicts,
40
+ recordInvariant,
41
+ recordInvariants,
42
+ recordedLongTurn,
43
+ stallingD1
44
+ };
45
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -12,8 +12,8 @@ import {
12
12
  } from "../chunk-4LBCTFBP.js";
13
13
  import {
14
14
  assertRenderUiSchema
15
- } from "../chunk-J7TCMW2J.js";
16
- import "../chunk-4DIO2LTR.js";
15
+ } from "../chunk-XMIV374H.js";
16
+ import "../chunk-TMOYOMSW.js";
17
17
 
18
18
  // src/preset-cloudflare/workflow-instance.ts
19
19
  async function ensureCloudflareWorkflowInstance(binding, input) {
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  createChatTurnRoutes,
3
3
  streamChatRouteAsSandboxEvents
4
- } from "../chunk-FWLCPAST.js";
5
- import "../chunk-Q7WEEN7P.js";
4
+ } from "../chunk-SH56N4PV.js";
6
5
  import "../chunk-UTAIRVOK.js";
7
6
  import "../chunk-RN4WPTBH.js";
7
+ import "../chunk-Q7WEEN7P.js";
8
8
  import "../chunk-3NCPXNBZ.js";
9
- import "../chunk-2YLSWZ5W.js";
9
+ import "../chunk-JBEFTXDO.js";
10
10
  import "../chunk-ZVEEWGDK.js";
11
11
  import "../chunk-6E7LKHYV.js";
12
12
  import "../chunk-TXD5HXLE.js";
13
- import "../chunk-YXYQ6MJL.js";
13
+ import "../chunk-5V6VTO5Q.js";
14
14
  import "../chunk-YG66IHDU.js";
15
- import "../chunk-ZGUXI5SI.js";
16
- import "../chunk-6VQCFJWP.js";
15
+ import "../chunk-XNKLQG26.js";
17
16
  import "../chunk-LQYIBL3G.js";
18
- import "../chunk-JGZ7WEPL.js";
17
+ import "../chunk-6VQCFJWP.js";
18
+ import "../chunk-JC7YSRBR.js";
19
19
 
20
20
  // src/public-consultation/index.ts
21
21
  import { searchKnowledge } from "@tangle-network/agent-knowledge";
@@ -114,13 +114,13 @@ import {
114
114
  } from "../chunk-4LBCTFBP.js";
115
115
  import "../chunk-MCYJON3F.js";
116
116
  import "../chunk-LWSJK546.js";
117
- import "../chunk-S2G5NAWV.js";
117
+ import "../chunk-KSITU6BQ.js";
118
118
  import "../chunk-6A7MYOUI.js";
119
- import "../chunk-J7TCMW2J.js";
119
+ import "../chunk-XMIV374H.js";
120
120
  import "../chunk-S5SRJJQG.js";
121
- import "../chunk-T2IESIJ7.js";
121
+ import "../chunk-BMZTYGKE.js";
122
122
  import "../chunk-UGWQLQDS.js";
123
- import "../chunk-4DIO2LTR.js";
123
+ import "../chunk-TMOYOMSW.js";
124
124
  import "../chunk-D6UJEOZQ.js";
125
125
  export {
126
126
  DEFAULT_FOREGROUND_PROVISION_CLAIM_TTL_SECONDS,
@@ -2,8 +2,9 @@
2
2
  import {
3
3
  formatSignoffLine,
4
4
  formatSignoffReport,
5
+ runShellAlignmentCli,
5
6
  runSignoff
6
- } from "../chunk-N7ZJWESQ.js";
7
+ } from "../chunk-KBTY4AAU.js";
7
8
  import {
8
9
  invokedAsScript
9
10
  } from "../chunk-C3CAYGGQ.js";
@@ -24,7 +25,10 @@ function usage() {
24
25
  " --keep-going run every step even after one fails",
25
26
  " --keep-workspace leave the clean tree on disk to inspect",
26
27
  " --json <path> write the machine-readable report",
27
- " --quiet verdict only; no per-step progress"
28
+ " --quiet verdict only; no per-step progress",
29
+ "",
30
+ "Subcommands:",
31
+ " shell-alignment measure header dividers against the rail in a browser (--help for options)"
28
32
  ].join("\n");
29
33
  }
30
34
  function fail(message) {
@@ -128,6 +132,7 @@ function progressWriter() {
128
132
  };
129
133
  }
130
134
  async function runSignoffCli(argv) {
135
+ if (argv[0] === "shell-alignment") return runShellAlignmentCli(argv.slice(1));
131
136
  const args = parseArgs(argv);
132
137
  const report = await runSignoff({ ...args, onEvent: args.quiet ? void 0 : progressWriter() });
133
138
  if (args.jsonPath !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/signoff/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 */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { invokedAsScript } from './invoked-as-script'\nimport { formatSignoffLine, formatSignoffReport } from './report'\nimport { runSignoff, type RunSignoffOptions } from './run'\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 ].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\nexport function 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 '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 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"],"mappings":";;;;;;;;;;;AAcA,SAAS,WAAW,qBAAqB;AACzC,SAAS,SAAS,eAAe;AAWjC,SAAS,QAAgB;AACvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,KAAK,SAAwB;AACpC,UAAQ,OAAO,MAAM,sBAAsB,OAAO;AAAA;AAAA,EAAO,MAAM,CAAC;AAAA,CAAI;AACpE,UAAQ,KAAK,CAAC;AAChB;AAEA,SAAS,YAAY,KAAa,MAAsB;AACtD,QAAM,QAAQ,OAAO,SAAS,KAAK,EAAE;AACrC,MAAI,CAAC,OAAO,SAAS,KAAK,KAAK,QAAQ,EAAG,MAAK,GAAG,IAAI,uCAAuC,GAAG,GAAG;AACnG,SAAO;AACT;AAEO,SAAS,UAAU,MAAqC;AAC7D,QAAM,SAYF,CAAC;AAEL,WAAS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MAAM,CAAC;AAAA,CAAI;AAChG,SAAO,OAAO,KAAK,IAAI;AACzB;AAGA,IAAI,gBAAgB,YAAY,KAAK,QAAQ,KAAK,CAAC,CAAC,GAAG;AACrD,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":[]}
1
+ {"version":3,"sources":["../../src/signoff/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 shell-alignment --base-url <url> --route <path> # header dividers meet the rail\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { invokedAsScript } from './invoked-as-script'\nimport { formatSignoffLine, formatSignoffReport } from './report'\nimport { runSignoff, type RunSignoffOptions } from './run'\nimport { runShellAlignmentCli } from './shell-alignment-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 ' shell-alignment measure header dividers against the rail in a browser (--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\nexport function 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 '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] === 'shell-alignment') return runShellAlignmentCli(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 instan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53
53
  export { runSignoff, type RunSignoffOptions } from './run';
54
54
  export { loadSignoffConfig, type LoadSignoffConfigOptions } from './config';
55
55
  export { formatSignoffReport } from './report';
56
+ export { checkShellAlignment, collectShellDividers, formatShellAlignmentReport, judgeShellAlignment, SHELL_ALIGNMENT_TOLERANCE_PX, type ShellAlignmentFinding, type ShellAlignmentOptions, type ShellAlignmentReport, type ShellDivider, type ShellDividerSample, } from './shell-alignment';
57
+ export { parseShellAlignmentArgs, runShellAlignmentCli } from './shell-alignment-cli';
56
58
  export { checkWorkerDefaults, formatWorkerDefaults, WORKER_COMPATIBILITY_DATE_FLOOR, type WorkerDefaultsFinding, type WorkerDefaultsResult, } from './worker-defaults';
57
59
  export type { LoadedSignoffConfig, SignoffAttempt, SignoffConfig, SignoffConfigOrigin, SignoffEvent, SignoffHostFacts, SignoffInstallResult, SignoffInstallSpec, SignoffRepoFacts, SignoffReport, SignoffShuffleSpec, SignoffSource, SignoffStepResult, SignoffStepSpec, SignoffStepStatus, } from './types';
@@ -1,17 +1,31 @@
1
1
  import {
2
+ SHELL_ALIGNMENT_TOLERANCE_PX,
2
3
  WORKER_COMPATIBILITY_DATE_FLOOR,
4
+ checkShellAlignment,
3
5
  checkWorkerDefaults,
6
+ collectShellDividers,
7
+ formatShellAlignmentReport,
4
8
  formatSignoffReport,
5
9
  formatWorkerDefaults,
10
+ judgeShellAlignment,
6
11
  loadSignoffConfig,
12
+ parseShellAlignmentArgs,
13
+ runShellAlignmentCli,
7
14
  runSignoff
8
- } from "../chunk-N7ZJWESQ.js";
15
+ } from "../chunk-KBTY4AAU.js";
9
16
  export {
17
+ SHELL_ALIGNMENT_TOLERANCE_PX,
10
18
  WORKER_COMPATIBILITY_DATE_FLOOR,
19
+ checkShellAlignment,
11
20
  checkWorkerDefaults,
21
+ collectShellDividers,
22
+ formatShellAlignmentReport,
12
23
  formatSignoffReport,
13
24
  formatWorkerDefaults,
25
+ judgeShellAlignment,
14
26
  loadSignoffConfig,
27
+ parseShellAlignmentArgs,
28
+ runShellAlignmentCli,
15
29
  runSignoff
16
30
  };
17
31
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import { type ShellAlignmentOptions } from './shell-alignment';
2
+ export declare function shellAlignmentUsage(): string;
3
+ export declare class ShellAlignmentUsageError extends Error {
4
+ }
5
+ export declare function parseShellAlignmentArgs(argv: readonly string[]): ShellAlignmentOptions & {
6
+ readonly jsonPath?: string;
7
+ };
8
+ export declare function runShellAlignmentCli(argv: readonly string[]): Promise<number>;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Shell alignment: on each route, at desktop and phone widths, the main pane's
3
+ * header divider must continue the sidebar rail's first divider.
4
+ *
5
+ * Every shell header row is a sandbox-ui `ShellHeader` at brand's
6
+ * `--shell-header-height`, so their bottom borders share one y. A product that
7
+ * gives a header its own height (Hospitality's 66px inbox head beside a 56px
8
+ * rail) moves its divider off that line; this check measures the rendered page,
9
+ * so it catches the drift whatever CSS caused it.
10
+ *
11
+ * The browser half (`collectShellDividers`) only reads geometry; the decision
12
+ * (`judgeShellAlignment`) is a pure function so it is unit-tested without a browser.
13
+ */
14
+ /** A horizontal divider: the bottom border of a top-anchored row. Coordinates in CSS px. */
15
+ export interface ShellDivider {
16
+ readonly label: string;
17
+ readonly left: number;
18
+ readonly right: number;
19
+ readonly top: number;
20
+ readonly bottom: number;
21
+ }
22
+ export interface ShellDividerSample {
23
+ readonly route: string;
24
+ readonly width: number;
25
+ readonly theme: string;
26
+ /** `--shell-header-height` resolved to px on this page. */
27
+ readonly shellHeaderPx: number;
28
+ /** The rail's first divider (desktop), or null when the rail is hidden. */
29
+ readonly rail: ShellDivider | null;
30
+ /** The phone bar standing in for the rail below its breakpoint, or null. */
31
+ readonly phoneBar: ShellDivider | null;
32
+ /** Every top-anchored row divider in the main pane and its side panels. */
33
+ readonly headers: readonly ShellDivider[];
34
+ }
35
+ export interface ShellAlignmentFinding {
36
+ readonly route: string;
37
+ readonly width: number;
38
+ readonly theme: string;
39
+ readonly header: string;
40
+ /** Signed px: positive when the header divider sits below the expected line. */
41
+ readonly offsetPx: number;
42
+ readonly expectedY: number;
43
+ readonly actualY: number;
44
+ readonly reason: string;
45
+ }
46
+ export declare const SHELL_ALIGNMENT_TOLERANCE_PX = 0.5;
47
+ /**
48
+ * Desktop: every header divider lands on the rail's first divider.
49
+ * Phone: the rail is hidden; the phone bar is one shell row, and a header row
50
+ * that starts under it is exactly one shell row tall.
51
+ */
52
+ export declare function judgeShellAlignment(sample: ShellDividerSample, tolerancePx?: number): ShellAlignmentFinding[];
53
+ /**
54
+ * Runs in the page (Playwright serializes it). A divider is the visible bottom
55
+ * border of a wide, top-anchored element with no top border: header rows have
56
+ * only a bottom divider, while inputs, cards and the inset surface draw a full
57
+ * box and are skipped. Returns raw geometry; `judgeShellAlignment` decides.
58
+ */
59
+ export declare function collectShellDividers(): Omit<ShellDividerSample, 'route' | 'width' | 'theme'>;
60
+ export interface ShellAlignmentOptions {
61
+ readonly baseUrl: string;
62
+ readonly routes: readonly string[];
63
+ readonly widths?: readonly number[];
64
+ readonly themes?: readonly ('light' | 'dark')[];
65
+ /** Playwright storage state (cookies, localStorage) for an authenticated app. */
66
+ readonly storageState?: string;
67
+ /** Run in each page before the app loads, with `theme` in scope, to apply the app's own theme switch. */
68
+ readonly themeScript?: string;
69
+ /** Write a screenshot per failing route and width here. */
70
+ readonly screenshotDir?: string;
71
+ readonly tolerancePx?: number;
72
+ /** Wait for this selector after navigation (default `[data-shell-header]`). */
73
+ readonly readySelector?: string;
74
+ }
75
+ export interface ShellAlignmentReport {
76
+ readonly samples: readonly ShellDividerSample[];
77
+ readonly findings: readonly ShellAlignmentFinding[];
78
+ readonly maxOffsetPx: number;
79
+ }
80
+ /** Drive Chromium over every route × width × theme and judge each page. Needs the optional `playwright` peer. */
81
+ export declare function checkShellAlignment(options: ShellAlignmentOptions): Promise<ShellAlignmentReport>;
82
+ export declare function formatShellAlignmentReport(report: ShellAlignmentReport): string;
@@ -9,3 +9,4 @@ export * from './stream-normalizer';
9
9
  export * from './turn-identity';
10
10
  export * from './turn-buffer';
11
11
  export * from './turn-observation';
12
+ export * from './orphaned-turns';
@@ -1,8 +1,10 @@
1
1
  import {
2
+ ORPHANED_TURN_CODE,
2
3
  consumeTurnStream,
3
4
  observeTurnEvent,
4
- parseTurnObservation
5
- } from "../chunk-YXYQ6MJL.js";
5
+ parseTurnObservation,
6
+ settleOrphanedTurns
7
+ } from "../chunk-5V6VTO5Q.js";
6
8
  import {
7
9
  buildUserTextParts,
8
10
  messageHasTurnId,
@@ -30,9 +32,9 @@ import {
30
32
  terminalizeDanglingAssistantToolUpdates,
31
33
  terminalizeDanglingToolPart,
32
34
  terminalizeDanglingToolParts
33
- } from "../chunk-ZGUXI5SI.js";
34
- import "../chunk-6VQCFJWP.js";
35
+ } from "../chunk-XNKLQG26.js";
35
36
  import "../chunk-LQYIBL3G.js";
37
+ import "../chunk-6VQCFJWP.js";
36
38
  import {
37
39
  DEFAULT_RUNNING_TURN_LEASE_MS,
38
40
  DEFAULT_RUNNING_TURN_RENEW_INTERVAL_MS,
@@ -49,12 +51,13 @@ import {
49
51
  pumpBufferedTurn,
50
52
  replayTurnEvents,
51
53
  stampReplaySeq
52
- } from "../chunk-JGZ7WEPL.js";
54
+ } from "../chunk-JC7YSRBR.js";
53
55
  export {
54
56
  DEFAULT_RUNNING_TURN_LEASE_MS,
55
57
  DEFAULT_RUNNING_TURN_RENEW_INTERVAL_MS,
56
58
  MISSING_TOOL_TERMINAL_ERROR,
57
59
  MISSING_TOOL_TERMINAL_REASON,
60
+ ORPHANED_TURN_CODE,
58
61
  TURN_EVENTS_MIGRATION_SQL,
59
62
  TURN_STATUS_LEASE_MIGRATION_SQL,
60
63
  TURN_STATUS_RETENTION_MIGRATION_SQL,
@@ -89,6 +92,7 @@ export {
89
92
  resolveChatTurn,
90
93
  resolveToolId,
91
94
  resolveToolName,
95
+ settleOrphanedTurns,
92
96
  stampReplaySeq,
93
97
  terminalizeDanglingAssistantToolUpdates,
94
98
  terminalizeDanglingToolPart,
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Settle turn streams whose owner is gone.
3
+ *
4
+ * A running turn row is a lease: the buffer renews it every 30 s while a
5
+ * producer lives, and a durable observer renews it on each pass. A row nothing
6
+ * renewed past its lease has no producer left; the Worker that streamed it
7
+ * died. Left alone it stays `running` forever: a reconnecting client waits on
8
+ * it, discovery offers it, and reports count it as in flight. On 2026-10-10
9
+ * GTM held 51 such rows, some for hours, and its failure notices arrived 8–11 h
10
+ * after the turns had stopped.
11
+ *
12
+ * {@link settleOrphanedTurns} ends each one the way the buffer ends a failed
13
+ * turn: a terminal `error` event naming the phase it stopped in, then status
14
+ * `error`, written only while the row is still running and still stale, and
15
+ * without moving its update time (reports place a stream by it). It returns
16
+ * each turn's detection lag, the time from its lease expiring to this
17
+ * settlement, so a product can report how late it noticed. Run it from its own
18
+ * scheduled invocation at least every 15 minutes.
19
+ */
20
+ import { type StaleRunningTurn, type TurnEventStore } from './turn-buffer';
21
+ /** The failure code carried by the terminal event of a settled orphan. */
22
+ export declare const ORPHANED_TURN_CODE = "turn.orphaned";
23
+ export interface SettleOrphanedTurnsOptions {
24
+ store: TurnEventStore;
25
+ now?: number;
26
+ /** A row older than this since its last renewal is orphaned. Default the running lease, 5 minutes. */
27
+ staleAfterMs?: number;
28
+ /** Most rows settled per run; the next run takes the rest. Default 50. */
29
+ limit?: number;
30
+ /**
31
+ * Whether something still owns this turn although it stopped renewing the
32
+ * row, such as an open completion admission with a live lease. An owned turn
33
+ * is skipped. A product whose durable owner does not renew the row must
34
+ * answer this, or its live turns are settled as orphans.
35
+ */
36
+ isOwned?: (turn: StaleRunningTurn) => Promise<boolean>;
37
+ }
38
+ export interface SettledOrphanedTurn {
39
+ turnId: string;
40
+ scopeId: string | null;
41
+ /** Unix ms the row was last renewed. */
42
+ lastRenewedAt: number;
43
+ /** From its lease expiring to this settlement. */
44
+ detectionLagMs: number;
45
+ /** The run phase the stream last reported, when it reported one. */
46
+ phase: string | null;
47
+ }
48
+ export interface SettleOrphanedTurnsResult {
49
+ settled: SettledOrphanedTurn[];
50
+ /** Stale rows an owner still held. */
51
+ owned: string[];
52
+ /** Most detection lag among the settled turns, in ms. */
53
+ maxDetectionLagMs: number;
54
+ }
55
+ /** End every running turn stream nothing has renewed past its lease. */
56
+ export declare function settleOrphanedTurns(options: SettleOrphanedTurnsOptions): Promise<SettleOrphanedTurnsResult>;
@@ -59,6 +59,18 @@ export interface TurnEventStore {
59
59
  /** Remove terminal turns whose status was updated before `before` (Unix
60
60
  * milliseconds or a Date). Running turns are never eligible. */
61
61
  pruneTerminalTurns?(before: number | Date): Promise<number>;
62
+ /** Running turns last renewed before `before` (Unix ms), oldest first, at most
63
+ * `limit`: the candidates {@link settleOrphanedTurns} settles. */
64
+ listStaleRunning?(before: number, limit: number): Promise<StaleRunningTurn[]>;
65
+ /** The last `count` events of a turn, newest first; a bounded read of the tail. */
66
+ readTail?(turnId: string, count: number): Promise<BufferedTurnEvent[]>;
67
+ }
68
+ /** A running turn nothing has renewed since `updatedAt`. */
69
+ export interface StaleRunningTurn {
70
+ turnId: string;
71
+ scopeId: string | null;
72
+ /** Unix ms of the last status write. */
73
+ updatedAt: number;
62
74
  }
63
75
  /**
64
76
  * Settling a stream nothing produces any more. A sweep that ends an orphaned
@@ -39,7 +39,7 @@ import {
39
39
  } from "../chunk-PT7H37YH.js";
40
40
  import {
41
41
  useInfiniteScroll
42
- } from "../chunk-FAU5FIFD.js";
42
+ } from "../chunk-2FLSODOX.js";
43
43
  import "../chunk-XEURJVS5.js";
44
44
  import {
45
45
  CheckGlyph,
@@ -1,6 +1,3 @@
1
- import {
2
- SeatLimitError
3
- } from "../chunk-MEUNTJL5.js";
4
1
  import {
5
2
  generateInvitationToken,
6
3
  getInvitationExpiresAt,
@@ -8,6 +5,9 @@ import {
8
5
  normalizeInvitationEmail,
9
6
  parseInvitationPermission
10
7
  } from "../chunk-AB63T2LM.js";
8
+ import {
9
+ SeatLimitError
10
+ } from "../chunk-MEUNTJL5.js";
11
11
  import "../chunk-DJ4VJIH5.js";
12
12
  import {
13
13
  hasWorkspaceRole