agentfootprint 7.18.0 → 7.19.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 (79) hide show
  1. package/dist/adapters/hosting/agentcore.js +23 -9
  2. package/dist/adapters/hosting/agentcore.js.map +1 -1
  3. package/dist/core/Agent.js +6 -0
  4. package/dist/core/Agent.js.map +1 -1
  5. package/dist/core/agent/stages/toolCalls.js +13 -0
  6. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  7. package/dist/core/durabilityBarrier.js +68 -0
  8. package/dist/core/durabilityBarrier.js.map +1 -0
  9. package/dist/esm/adapters/hosting/agentcore.d.ts +4 -4
  10. package/dist/esm/adapters/hosting/agentcore.js +24 -10
  11. package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
  12. package/dist/esm/core/Agent.js +6 -0
  13. package/dist/esm/core/Agent.js.map +1 -1
  14. package/dist/esm/core/agent/stages/toolCalls.d.ts +21 -0
  15. package/dist/esm/core/agent/stages/toolCalls.js +13 -0
  16. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  17. package/dist/esm/core/durabilityBarrier.d.ts +61 -0
  18. package/dist/esm/core/durabilityBarrier.js +63 -0
  19. package/dist/esm/core/durabilityBarrier.js.map +1 -0
  20. package/dist/esm/hosting/durability.d.ts +92 -0
  21. package/dist/esm/hosting/durability.js +174 -0
  22. package/dist/esm/hosting/durability.js.map +1 -0
  23. package/dist/esm/hosting/envelope.d.ts +75 -14
  24. package/dist/esm/hosting/envelope.js +141 -16
  25. package/dist/esm/hosting/envelope.js.map +1 -1
  26. package/dist/esm/hosting/errors.d.ts +60 -11
  27. package/dist/esm/hosting/errors.js +92 -18
  28. package/dist/esm/hosting/errors.js.map +1 -1
  29. package/dist/esm/hosting/httpHost.d.ts +17 -1
  30. package/dist/esm/hosting/httpHost.js +42 -6
  31. package/dist/esm/hosting/httpHost.js.map +1 -1
  32. package/dist/esm/hosting/index.d.ts +7 -4
  33. package/dist/esm/hosting/index.js +6 -3
  34. package/dist/esm/hosting/index.js.map +1 -1
  35. package/dist/esm/hosting/nodeHost.d.ts +4 -2
  36. package/dist/esm/hosting/nodeHost.js +14 -3
  37. package/dist/esm/hosting/nodeHost.js.map +1 -1
  38. package/dist/esm/hosting/standingAgent.d.ts +22 -7
  39. package/dist/esm/hosting/standingAgent.js +144 -32
  40. package/dist/esm/hosting/standingAgent.js.map +1 -1
  41. package/dist/esm/hosting/types.d.ts +193 -19
  42. package/dist/hosting/durability.js +178 -0
  43. package/dist/hosting/durability.js.map +1 -0
  44. package/dist/hosting/envelope.js +146 -18
  45. package/dist/hosting/envelope.js.map +1 -1
  46. package/dist/hosting/errors.js +95 -19
  47. package/dist/hosting/errors.js.map +1 -1
  48. package/dist/hosting/httpHost.js +42 -6
  49. package/dist/hosting/httpHost.js.map +1 -1
  50. package/dist/hosting/index.js +10 -2
  51. package/dist/hosting/index.js.map +1 -1
  52. package/dist/hosting/nodeHost.js +14 -3
  53. package/dist/hosting/nodeHost.js.map +1 -1
  54. package/dist/hosting/standingAgent.js +142 -30
  55. package/dist/hosting/standingAgent.js.map +1 -1
  56. package/dist/types/adapters/hosting/agentcore.d.ts +4 -4
  57. package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
  58. package/dist/types/core/Agent.d.ts.map +1 -1
  59. package/dist/types/core/agent/stages/toolCalls.d.ts +21 -0
  60. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  61. package/dist/types/core/durabilityBarrier.d.ts +62 -0
  62. package/dist/types/core/durabilityBarrier.d.ts.map +1 -0
  63. package/dist/types/hosting/durability.d.ts +93 -0
  64. package/dist/types/hosting/durability.d.ts.map +1 -0
  65. package/dist/types/hosting/envelope.d.ts +75 -14
  66. package/dist/types/hosting/envelope.d.ts.map +1 -1
  67. package/dist/types/hosting/errors.d.ts +60 -11
  68. package/dist/types/hosting/errors.d.ts.map +1 -1
  69. package/dist/types/hosting/httpHost.d.ts +17 -1
  70. package/dist/types/hosting/httpHost.d.ts.map +1 -1
  71. package/dist/types/hosting/index.d.ts +7 -4
  72. package/dist/types/hosting/index.d.ts.map +1 -1
  73. package/dist/types/hosting/nodeHost.d.ts +4 -2
  74. package/dist/types/hosting/nodeHost.d.ts.map +1 -1
  75. package/dist/types/hosting/standingAgent.d.ts +22 -7
  76. package/dist/types/hosting/standingAgent.d.ts.map +1 -1
  77. package/dist/types/hosting/types.d.ts +193 -19
  78. package/dist/types/hosting/types.d.ts.map +1 -1
  79. package/package.json +1 -1
@@ -0,0 +1,174 @@
1
+ /**
2
+ * hosting/durability — how often a run's progress becomes crash-survivable.
3
+ *
4
+ * A standing agent that only writes at the end of a turn is one restart away
5
+ * from losing everything the turn had done: the tool calls it made, the results
6
+ * it read, the iterations it spent. This is the dial that decides how much of
7
+ * that survives, and what it costs.
8
+ *
9
+ * ── Where a mid-run write can honestly come from ─────────────────────────────
10
+ * From the COMMIT boundary, and nowhere else. footprintjs commits a stage's
11
+ * writes after the stage function returns, and committed state is
12
+ * immutable-after-swap — so `ScopeRecorder.onCommit` is the one moment where
13
+ * "what the run has agreed on so far" is a real, complete, consistent thing.
14
+ * Reading the agent's live state at any other moment would be reading a stage's
15
+ * work in progress.
16
+ *
17
+ * There is no mid-run engine checkpoint to store: footprintjs builds a
18
+ * `FlowchartCheckpoint` only at a pause (`getCheckpoint()` is documented as "the
19
+ * most recent PAUSED execution"). So what a mid-run write can carry is a
20
+ * CONVERSATION — the same `AgentRunCheckpoint` every finished turn stores — and
21
+ * that is exactly enough, because that is what the next turn resumes from.
22
+ *
23
+ * ── Why it writes on SOME commits and not all of them ────────────────────────
24
+ * A two-iteration turn commits about forty times. Exactly two of those commits
25
+ * change the conversation: `Initialize` (the user's message lands) and
26
+ * `ToolCalls` (an iteration's assistant turn and its tool results land). Every
27
+ * other commit would store bytes identical to the last write. So the trigger is
28
+ * "this commit wrote `history`", which is not an optimisation but the honest
29
+ * reading of the question: the conversation moved iff `history` moved.
30
+ *
31
+ * ── What a commit boundary actually guarantees, and what it does not ─────────
32
+ * It guarantees the whole stage. The agent dispatches ALL of one iteration's
33
+ * tool calls inside one stage body, so a crash part-way through that body stores
34
+ * nothing from it and a replay re-runs that iteration's tools. That is the
35
+ * shipped idempotency requirement, unchanged — mutating tools must be
36
+ * idempotent, keyed on stable call content rather than `ctx.toolCallId`. What
37
+ * `'sync'` adds is a BOUND on it: iteration N's tools do not start until
38
+ * iteration N-1's write has landed, so the replay is the current iteration and
39
+ * never an earlier one.
40
+ *
41
+ * Pattern: an observer (`CombinedRecorder`) for the snapshot, a serialiser for
42
+ * the writes, and — for `'sync'` only — a barrier the tool dispatch waits on.
43
+ * Role: internal to `standingAgent`. Deliberately not exported: it is how the
44
+ * composer keeps its promise, not a second way to write to a store.
45
+ */
46
+ import { installDurabilityBarrier } from '../core/durabilityBarrier.js';
47
+ /**
48
+ * Build the writer.
49
+ *
50
+ * Under `'sync'` it also answers the tool-dispatch barrier, which is what turns
51
+ * "we write often" into a bound on how much can re-run.
52
+ */
53
+ export function durableWriter(options) {
54
+ const { mode, session, runId, write } = options;
55
+ /** The write currently on the wire, or `undefined` when nothing is. */
56
+ let inFlight;
57
+ /**
58
+ * The newest snapshot that has not been started yet. At most ONE, and a newer
59
+ * one replaces it: the conversation only grows, so a superseded snapshot is a
60
+ * prefix of the one replacing it and writing it first would buy nothing.
61
+ */
62
+ let queued;
63
+ /**
64
+ * Why the NEWEST write did not land, or `undefined` when it did. Cleared by a
65
+ * write that succeeds — a store that failed once and then took the newer
66
+ * state has made that state durable, and reporting the older failure would be
67
+ * describing a problem that no longer exists.
68
+ */
69
+ let failure;
70
+ /** Per-run accumulation, rebuilt from the commits themselves. */
71
+ let history = [];
72
+ let userMessage = '';
73
+ let iteration = 0;
74
+ function pump() {
75
+ if (inFlight !== undefined || queued === undefined)
76
+ return;
77
+ const next = queued;
78
+ queued = undefined;
79
+ inFlight = write(next.sessionId, next.conversation)
80
+ .then(() => {
81
+ failure = undefined;
82
+ }, (err) => {
83
+ failure = new Error(`[hosting] the session store did not accept this run's progress, so nothing ` +
84
+ `after this point may proceed as if it had` +
85
+ (mode === 'sync' ? ` — the next tool call was not allowed to run` : '') +
86
+ `. Underlying error: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
87
+ })
88
+ .then(() => {
89
+ inFlight = undefined;
90
+ pump();
91
+ });
92
+ }
93
+ function enqueue(sessionId) {
94
+ queued = {
95
+ sessionId,
96
+ conversation: {
97
+ version: 1,
98
+ runId: runId() ?? 'unknown',
99
+ // The commit event hands over the stage's retained write view. Clone on
100
+ // the way to a store so nothing a persistence layer does can reach back
101
+ // into the run's own snapshot.
102
+ history: structuredClone(history),
103
+ lastCompletedIteration: iteration,
104
+ originalInput: { message: userMessage },
105
+ checkpointedAt: Date.now(),
106
+ },
107
+ };
108
+ pump();
109
+ }
110
+ const recorder = {
111
+ id: 'af-hosting-durability',
112
+ // INLINE, always. A write delivered one beat behind is a write that can be
113
+ // lost by the very crash it exists to survive — and under `'sync'` the
114
+ // barrier would be waiting on a snapshot the queue had not handed over yet.
115
+ // The causal-evidence bridge and the compaction meter are inline for the
116
+ // same class of reason.
117
+ delivery: 'inline',
118
+ onCommit(event) {
119
+ let conversationMoved = false;
120
+ for (const mutation of event.mutations) {
121
+ if (mutation.key === 'history' && Array.isArray(mutation.value)) {
122
+ history = mutation.value;
123
+ conversationMoved = true;
124
+ }
125
+ else if (mutation.key === 'userMessage' && typeof mutation.value === 'string') {
126
+ userMessage = mutation.value;
127
+ }
128
+ else if (mutation.key === 'iteration' && typeof mutation.value === 'number') {
129
+ iteration = mutation.value;
130
+ }
131
+ }
132
+ if (!conversationMoved)
133
+ return;
134
+ const sessionId = session();
135
+ if (sessionId === undefined)
136
+ return;
137
+ enqueue(sessionId);
138
+ },
139
+ // A fresh run starts from a fresh conversation. Without this a resumed run
140
+ // whose first commit has not landed yet could stamp the previous run's
141
+ // history onto this run's id.
142
+ clear() {
143
+ history = [];
144
+ userMessage = '';
145
+ iteration = 0;
146
+ },
147
+ };
148
+ const settle = async () => {
149
+ // Loop rather than await once: a write that completes may release a queued
150
+ // successor, and "settled" has to mean nothing is left.
151
+ while (inFlight !== undefined || queued !== undefined) {
152
+ pump();
153
+ await inFlight;
154
+ }
155
+ if (failure)
156
+ throw failure;
157
+ };
158
+ return {
159
+ recorder,
160
+ install(agent) {
161
+ // `'async'` deliberately takes NO barrier: its whole promise is that the
162
+ // run does not wait, and a barrier would be that promise broken quietly.
163
+ if (mode !== 'sync')
164
+ return () => undefined;
165
+ return installDurabilityBarrier(agent, () => {
166
+ if (inFlight === undefined && queued === undefined && failure === undefined)
167
+ return undefined;
168
+ return settle();
169
+ });
170
+ },
171
+ settle,
172
+ };
173
+ }
174
+ //# sourceMappingURL=durability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durability.js","sourceRoot":"","sources":["../../../src/hosting/durability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AA4CxE;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEhD,uEAAuE;IACvE,IAAI,QAAmC,CAAC;IACxC;;;;OAIG;IACH,IAAI,MAA2E,CAAC;IAChF;;;;;OAKG;IACH,IAAI,OAA0B,CAAC;IAE/B,iEAAiE;IACjE,IAAI,OAAO,GAA0B,EAAE,CAAC;IACxC,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,SAAS,IAAI;QACX,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO;QAC3D,MAAM,IAAI,GAAG,MAAM,CAAC;QACpB,MAAM,GAAG,SAAS,CAAC;QACnB,QAAQ,GAAG,KAAK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AAO,CAAC,KAAa;YACnB,yEAAyE;YACzE,yEAAyE;YACzE,IAAI,IAAI,KAAK,MAAM;gBAAE,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;YAC5C,OAAO,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAE;gBAC1C,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;oBACzE,OAAO,SAAS,CAAC;gBACnB,OAAO,MAAM,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,17 +1,27 @@
1
1
  /**
2
- * hosting/envelope — pack a conversation for storage, and refuse to unpack one
3
- * you cannot read.
4
- *
5
- * Two functions and one rule: **an unknown format is refused by name, never
6
- * guessed at.** A store outlives the code that wrote to it. Somebody will
7
- * deploy a newer runtime, it will write a newer format, and an older instance
8
- * still running will read it. The only honest thing that older instance can do
9
- * is say which format it found, which ones it knows, and stop — because
10
- * "restore what I can and hope" means an agent answering from a conversation
11
- * that is missing whatever the older reader did not understand.
2
+ * hosting/envelope — pack a session for storage, and refuse to unpack one you
3
+ * cannot read.
4
+ *
5
+ * One rule, and everything here is a consequence of it: **an envelope this
6
+ * runtime cannot read is refused BY NAME, never guessed at.** A store outlives
7
+ * the code that wrote to it. Somebody will deploy a newer runtime, it will write
8
+ * a newer format, and an older instance still running will read it. The only
9
+ * honest thing that older instance can do is say which format it found, which
10
+ * ones it knows, and stop — because "restore what I can and hope" means an agent
11
+ * answering from a session that is missing whatever the older reader did not
12
+ * understand.
13
+ *
14
+ * ── Two formats, two readers, and why they refuse each other ─────────────────
15
+ * `readEnvelope` unpacks a CONVERSATION; `readPausedRun` unpacks a PAUSED RUN.
16
+ * Each refuses the other's format by name and points at its sibling. That looks
17
+ * fussy until you notice the alternative: one reader that quietly returned the
18
+ * conversation inside a paused run would hand back a session that LOOKS finished
19
+ * while a person is still waiting on a question nobody mentioned. That is a
20
+ * half-restore wearing a happy path, which is the exact failure the format field
21
+ * exists to prevent.
12
22
  */
13
23
  import { type AgentRunCheckpoint } from '../core/runCheckpoint.js';
14
- import type { CheckpointEnvelope } from './types.js';
24
+ import type { CheckpointEnvelope, ConversationEnvelope, PausedRun, PausedRunEnvelope } from './types.js';
15
25
  /**
16
26
  * Pack a conversation checkpoint for storage.
17
27
  *
@@ -19,7 +29,28 @@ import type { CheckpointEnvelope } from './types.js';
19
29
  * const conversation = agent.checkpoint();
20
30
  * if (conversation) await sessions.persist(sessionId, toEnvelope(conversation));
21
31
  */
22
- export declare function toEnvelope(checkpoint: AgentRunCheckpoint): CheckpointEnvelope;
32
+ export declare function toEnvelope(checkpoint: AgentRunCheckpoint): ConversationEnvelope;
33
+ /**
34
+ * Pack a paused run for storage — the engine checkpoint, the conversation as of
35
+ * the pause, and the question it is waiting on.
36
+ *
37
+ * Store it anywhere that speaks JSON. Note what JSON does and does not preserve
38
+ * here: `agent.resume()` reads `checkpoint.sharedState`, which round-trips
39
+ * unchanged; the engine's diagnostic halves lose their explicitly-`undefined`
40
+ * properties, because that is what `JSON.stringify` does to them. See
41
+ * {@link PausedRun}.
42
+ *
43
+ * @example
44
+ * const outcome = await agent.run({ message });
45
+ * if (isPaused(outcome)) {
46
+ * await sessions.persist(sessionId, toPausedEnvelope({
47
+ * checkpoint: outcome.checkpoint,
48
+ * conversation: agent.checkpoint()!,
49
+ * pending: { pauseData: outcome.pauseData },
50
+ * }));
51
+ * }
52
+ */
53
+ export declare function toPausedEnvelope(paused: PausedRun): PausedRunEnvelope;
23
54
  /**
24
55
  * Unpack a stored envelope back into a conversation checkpoint.
25
56
  *
@@ -27,7 +58,37 @@ export declare function toEnvelope(checkpoint: AgentRunCheckpoint): CheckpointEn
27
58
  * else wrote, in a format this runtime may not know, and typing the parameter
28
59
  * as the happy shape would be assuming the very thing that needs checking.
29
60
  *
30
- * @throws TypeError naming the format when it is one this runtime cannot read,
31
- * and naming the missing field when the conversation inside is malformed.
61
+ * @throws TypeError naming the format when it is one this runtime cannot read;
62
+ * naming the missing field when the conversation inside is malformed; and
63
+ * pointing at {@link readPausedRun} when the envelope holds a paused run,
64
+ * which is a session with a question outstanding rather than a conversation.
32
65
  */
33
66
  export declare function readEnvelope(envelope: unknown): AgentRunCheckpoint;
67
+ /**
68
+ * Unpack a stored envelope back into a paused run.
69
+ *
70
+ * @throws TypeError naming the format when it is one this runtime cannot read;
71
+ * pointing at {@link readEnvelope} when the envelope holds a plain
72
+ * conversation; and naming the missing field when the paused run inside is
73
+ * malformed.
74
+ */
75
+ export declare function readPausedRun(envelope: unknown): PausedRun;
76
+ /**
77
+ * Check that an envelope is one this runtime can read, and hand it back
78
+ * unchanged — without committing to which half you wanted.
79
+ *
80
+ * This is what a STORE wants. A store's job is to notice that the bytes it is
81
+ * about to hand over are unreadable, so the refusal names the store that
82
+ * produced them rather than whoever read them next; it has no business caring
83
+ * whether the session inside is mid-conversation or mid-question.
84
+ *
85
+ * @throws TypeError naming the format when this runtime cannot read it, or the
86
+ * missing field when the payload is malformed.
87
+ *
88
+ * @example
89
+ * async hydrate(sessionId) {
90
+ * const stored = await myStore.get(sessionId);
91
+ * return stored === undefined ? undefined : checkEnvelope(stored);
92
+ * }
93
+ */
94
+ export declare function checkEnvelope(envelope: unknown): CheckpointEnvelope;
@@ -1,18 +1,28 @@
1
1
  /**
2
- * hosting/envelope — pack a conversation for storage, and refuse to unpack one
3
- * you cannot read.
2
+ * hosting/envelope — pack a session for storage, and refuse to unpack one you
3
+ * cannot read.
4
4
  *
5
- * Two functions and one rule: **an unknown format is refused by name, never
6
- * guessed at.** A store outlives the code that wrote to it. Somebody will
7
- * deploy a newer runtime, it will write a newer format, and an older instance
8
- * still running will read it. The only honest thing that older instance can do
9
- * is say which format it found, which ones it knows, and stop — because
10
- * "restore what I can and hope" means an agent answering from a conversation
11
- * that is missing whatever the older reader did not understand.
5
+ * One rule, and everything here is a consequence of it: **an envelope this
6
+ * runtime cannot read is refused BY NAME, never guessed at.** A store outlives
7
+ * the code that wrote to it. Somebody will deploy a newer runtime, it will write
8
+ * a newer format, and an older instance still running will read it. The only
9
+ * honest thing that older instance can do is say which format it found, which
10
+ * ones it knows, and stop — because "restore what I can and hope" means an agent
11
+ * answering from a session that is missing whatever the older reader did not
12
+ * understand.
13
+ *
14
+ * ── Two formats, two readers, and why they refuse each other ─────────────────
15
+ * `readEnvelope` unpacks a CONVERSATION; `readPausedRun` unpacks a PAUSED RUN.
16
+ * Each refuses the other's format by name and points at its sibling. That looks
17
+ * fussy until you notice the alternative: one reader that quietly returned the
18
+ * conversation inside a paused run would hand back a session that LOOKS finished
19
+ * while a person is still waiting on a question nobody mentioned. That is a
20
+ * half-restore wearing a happy path, which is the exact failure the format field
21
+ * exists to prevent.
12
22
  */
13
23
  import { validateCheckpoint } from '../core/runCheckpoint.js';
14
24
  /** Every format this runtime can read. Add, never redefine. */
15
- const KNOWN_FORMATS = ['conversation-v1'];
25
+ const KNOWN_FORMATS = ['conversation-v1', 'flowchart-v1'];
16
26
  /**
17
27
  * Pack a conversation checkpoint for storage.
18
28
  *
@@ -23,6 +33,29 @@ const KNOWN_FORMATS = ['conversation-v1'];
23
33
  export function toEnvelope(checkpoint) {
24
34
  return { format: 'conversation-v1', data: checkpoint, savedAt: Date.now() };
25
35
  }
36
+ /**
37
+ * Pack a paused run for storage — the engine checkpoint, the conversation as of
38
+ * the pause, and the question it is waiting on.
39
+ *
40
+ * Store it anywhere that speaks JSON. Note what JSON does and does not preserve
41
+ * here: `agent.resume()` reads `checkpoint.sharedState`, which round-trips
42
+ * unchanged; the engine's diagnostic halves lose their explicitly-`undefined`
43
+ * properties, because that is what `JSON.stringify` does to them. See
44
+ * {@link PausedRun}.
45
+ *
46
+ * @example
47
+ * const outcome = await agent.run({ message });
48
+ * if (isPaused(outcome)) {
49
+ * await sessions.persist(sessionId, toPausedEnvelope({
50
+ * checkpoint: outcome.checkpoint,
51
+ * conversation: agent.checkpoint()!,
52
+ * pending: { pauseData: outcome.pauseData },
53
+ * }));
54
+ * }
55
+ */
56
+ export function toPausedEnvelope(paused) {
57
+ return { format: 'flowchart-v1', data: paused, savedAt: Date.now() };
58
+ }
26
59
  /**
27
60
  * Unpack a stored envelope back into a conversation checkpoint.
28
61
  *
@@ -30,20 +63,112 @@ export function toEnvelope(checkpoint) {
30
63
  * else wrote, in a format this runtime may not know, and typing the parameter
31
64
  * as the happy shape would be assuming the very thing that needs checking.
32
65
  *
33
- * @throws TypeError naming the format when it is one this runtime cannot read,
34
- * and naming the missing field when the conversation inside is malformed.
66
+ * @throws TypeError naming the format when it is one this runtime cannot read;
67
+ * naming the missing field when the conversation inside is malformed; and
68
+ * pointing at {@link readPausedRun} when the envelope holds a paused run,
69
+ * which is a session with a question outstanding rather than a conversation.
35
70
  */
36
71
  export function readEnvelope(envelope) {
37
- if (!envelope || typeof envelope !== 'object') {
38
- throw new TypeError(`[hosting] stored session is not an envelope (got ${envelope === null ? 'null' : typeof envelope}). ` + `Expected { format, data, savedAt } as written by toEnvelope().`);
72
+ if (readFormat(envelope) === 'flowchart-v1') {
73
+ throw new TypeError(`[hosting] this envelope holds a PAUSED RUN ('flowchart-v1'), not a conversation. ` +
74
+ `Read it with readPausedRun(envelope) — it is waiting on a person's decision, and ` +
75
+ `handing back only the conversation inside it would restore a session that looks ` +
76
+ `finished while somebody is still waiting to be asked.`);
77
+ }
78
+ return validateCheckpoint(envelope.data);
79
+ }
80
+ /**
81
+ * Unpack a stored envelope back into a paused run.
82
+ *
83
+ * @throws TypeError naming the format when it is one this runtime cannot read;
84
+ * pointing at {@link readEnvelope} when the envelope holds a plain
85
+ * conversation; and naming the missing field when the paused run inside is
86
+ * malformed.
87
+ */
88
+ export function readPausedRun(envelope) {
89
+ if (readFormat(envelope) === 'conversation-v1') {
90
+ throw new TypeError(`[hosting] this envelope holds a conversation ('conversation-v1'), not a paused run. ` +
91
+ `Read it with readEnvelope(envelope). Nothing is waiting on a decision here.`);
92
+ }
93
+ return validatePausedRun(envelope.data);
94
+ }
95
+ /**
96
+ * Check that an envelope is one this runtime can read, and hand it back
97
+ * unchanged — without committing to which half you wanted.
98
+ *
99
+ * This is what a STORE wants. A store's job is to notice that the bytes it is
100
+ * about to hand over are unreadable, so the refusal names the store that
101
+ * produced them rather than whoever read them next; it has no business caring
102
+ * whether the session inside is mid-conversation or mid-question.
103
+ *
104
+ * @throws TypeError naming the format when this runtime cannot read it, or the
105
+ * missing field when the payload is malformed.
106
+ *
107
+ * @example
108
+ * async hydrate(sessionId) {
109
+ * const stored = await myStore.get(sessionId);
110
+ * return stored === undefined ? undefined : checkEnvelope(stored);
111
+ * }
112
+ */
113
+ export function checkEnvelope(envelope) {
114
+ if (readFormat(envelope) === 'flowchart-v1') {
115
+ validatePausedRun(envelope.data);
116
+ }
117
+ else {
118
+ validateCheckpoint(envelope.data);
119
+ }
120
+ return envelope;
121
+ }
122
+ /**
123
+ * The one place a `format` is checked, so every refusal in this file says the
124
+ * same thing in the same words.
125
+ */
126
+ function readFormat(envelope) {
127
+ if (!envelope || typeof envelope !== 'object' || Array.isArray(envelope)) {
128
+ throw new TypeError(`[hosting] stored session is not an envelope (got ${envelope === null ? 'null' : Array.isArray(envelope) ? 'an array' : typeof envelope}). Expected { format, data, savedAt } as written by toEnvelope() / toPausedEnvelope().`);
39
129
  }
40
130
  const found = envelope.format;
41
131
  if (typeof found !== 'string' || !KNOWN_FORMATS.includes(found)) {
42
132
  throw new TypeError(`[hosting] unknown checkpoint format '${String(found)}'. ` +
43
133
  `This runtime reads: ${KNOWN_FORMATS.join(', ')}. ` +
44
- `Refusing rather than restoring a conversation it cannot read — a newer envelope ` +
134
+ `Refusing rather than restoring a session it cannot read — a newer envelope ` +
45
135
  `needs a runtime that knows the format that wrote it.`);
46
136
  }
47
- return validateCheckpoint(envelope.data);
137
+ return found;
138
+ }
139
+ /**
140
+ * Validate a paused run at deserialization time, naming the missing piece.
141
+ *
142
+ * Only the fields resume actually consumes are required. `executionTree` and
143
+ * `subflowResults` are the engine's diagnostic halves — a checkpoint that lost
144
+ * them in transit still resumes, so demanding them would refuse a session that
145
+ * would have worked.
146
+ */
147
+ function validatePausedRun(value) {
148
+ if (!value || typeof value !== 'object') {
149
+ throw new TypeError('[hosting] paused run is not an object.');
150
+ }
151
+ const run = value;
152
+ const cp = run.checkpoint;
153
+ if (!cp || typeof cp !== 'object') {
154
+ throw new TypeError(`[hosting] paused run is missing required field: checkpoint. ` +
155
+ `It is the engine checkpoint agent.resume() continues from; without it the run ` +
156
+ `cannot be continued at all.`);
157
+ }
158
+ if (typeof cp.pausedStageId !== 'string' ||
159
+ !cp.sharedState ||
160
+ typeof cp.sharedState !== 'object') {
161
+ throw new TypeError(`[hosting] paused run's checkpoint is missing required fields (pausedStageId, ` +
162
+ `sharedState) — the two agent.resume() rebuilds the cursor and the run's state from.`);
163
+ }
164
+ if (!Array.isArray(cp.subflowPath)) {
165
+ throw new TypeError(`[hosting] paused run's checkpoint is missing required field: subflowPath.`);
166
+ }
167
+ if (!run.pending || typeof run.pending !== 'object') {
168
+ throw new TypeError(`[hosting] paused run is missing required field: pending — the question it is ` +
169
+ `waiting on. A stored pause nobody can describe is a session that hangs.`);
170
+ }
171
+ validateCheckpoint(run.conversation);
172
+ return run;
48
173
  }
49
174
  //# sourceMappingURL=envelope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/hosting/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAGvF,+DAA+D;AAC/D,MAAM,aAAa,GAAsB,CAAC,iBAAiB,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,UAA8B;IACvD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC9E,CAAC;AAED;;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AAI,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CACjB,+EAA+E;YAC7E,yEAAyE,CAC5E,CAAC;IACJ,CAAC;IACD,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrC,OAAO,GAAgB,CAAC;AAC1B,CAAC"}
@@ -3,17 +3,21 @@
3
3
  * same words.
4
4
  *
5
5
  * A refusal that varies by adapter is a refusal nobody can write a test or a
6
- * runbook against. These three carry a stable `code`, name WHO refused, and say
6
+ * runbook against. These five carry a stable `code`, name WHO refused, and say
7
7
  * what the caller should do instead. Adapters map the codes onto whatever their
8
8
  * transport uses to say "no" — that mapping is the adapter's business and lives
9
9
  * in the adapter, never here.
10
10
  *
11
- * `requireCapability` is the fourth refusal and the only one that is a
11
+ * Note what is NOT here: a run that paused. That is unfinished work rather than
12
+ * a refusal, and it leaves through `reply.awaiting(...)` — its own terminal —
13
+ * not through an error dressed up as one.
14
+ *
15
+ * `requireCapability` is the last refusal and the only one that is a
12
16
  * programming mistake rather than a runtime condition, so it throws a plain
13
17
  * `Error`: nothing branches on "I forgot to feature-detect", it just needs to
14
18
  * say so loudly and name the adapter it is talking about.
15
19
  */
16
- import type { AgentHost, HostCapability } from './types.js';
20
+ import type { AgentHost, HostCapability, PendingAsk } from './types.js';
17
21
  /**
18
22
  * Thrown when a request arrives at a host that is shutting down or shut down.
19
23
  *
@@ -44,22 +48,67 @@ export declare class ConcurrentRunError extends Error {
44
48
  constructor(sessionId: string, activeRunId?: string);
45
49
  }
46
50
  /**
47
- * Raised when a run paused to ask a person something and the reply cannot carry
48
- * a pause.
51
+ * Raised when a run paused to ask a person something and there is **nowhere to
52
+ * keep it**.
49
53
  *
50
54
  * **The run did not fail.** A pause is unfinished work: the agent stopped to ask
51
- * and is waiting for an answer. What cannot happen here is storing it — the
52
- * `'conversation-v1'` envelope holds a conversation, and a paused run is a
53
- * conversation plus an engine checkpoint. So nothing is written, and the
54
- * session keeps exactly the conversation it had before this request.
55
+ * and is waiting for an answer. Since 7.19 a paused run is stored as
56
+ * `'flowchart-v1'` and continued by a later request carrying a decision — so the
57
+ * one case left where a pause genuinely cannot be carried is a request with no
58
+ * session id. There is no session to store it under, and therefore no later
59
+ * request that could ever answer it.
60
+ *
61
+ * The other half of the old meaning — "the reply cannot carry a pause" — is
62
+ * gone: {@link HostReply.awaiting} carries it now. An adapter that has not
63
+ * implemented that terminal still gets its pause STORED (the store is not the
64
+ * transport's business) and this refusal on the wire, naming the session it can
65
+ * be answered on.
55
66
  */
56
67
  export declare class PauseNotCarriedError extends Error {
57
68
  readonly code: "ERR_PAUSE_NOT_CARRIED";
58
69
  /** The tool that asked, when the run recorded which one it was. */
59
70
  readonly toolName?: string;
60
- /** The session whose stored conversation was left untouched. */
71
+ /** The session the paused run was stored under, when there was one. */
61
72
  readonly sessionId?: string;
62
- constructor(toolName?: string, sessionId?: string);
73
+ /** Whether the paused run was stored. `false` means it is gone. */
74
+ readonly stored: boolean;
75
+ constructor(toolName?: string, sessionId?: string, stored?: boolean);
76
+ }
77
+ /**
78
+ * Thrown when a new message arrives for a session whose run is waiting on a
79
+ * person's decision.
80
+ *
81
+ * The message is NOT run and the pause is NOT discarded — those are the two ways
82
+ * this could have gone wrong. Answering the message would step over an
83
+ * outstanding consent gate; dropping the paused run to make room for the message
84
+ * would throw away work a person was asked about. So the request is refused, the
85
+ * pending question is named, and the session sits exactly where it was.
86
+ *
87
+ * Answer it by sending the same session a request carrying
88
+ * {@link HostRequest.decision}.
89
+ */
90
+ export declare class AwaitingDecisionError extends Error {
91
+ readonly code: "ERR_AWAITING_DECISION";
92
+ /** The session that is waiting. */
93
+ readonly sessionId: string;
94
+ /** What it is waiting on — the same payload `reply.awaiting()` delivered. */
95
+ readonly pending: PendingAsk;
96
+ constructor(sessionId: string, pending: PendingAsk);
97
+ }
98
+ /**
99
+ * Thrown when a request carries a decision for a session that is not waiting on
100
+ * one.
101
+ *
102
+ * Usually a duplicate delivery: the run was already continued, or already
103
+ * answered, and the same decision arrived twice. Running it as an ordinary
104
+ * message would put a raw approval into the conversation as if the user had
105
+ * typed it, so it is refused by name instead.
106
+ */
107
+ export declare class NoPendingAskError extends Error {
108
+ readonly code: "ERR_NO_PENDING_ASK";
109
+ /** The session the decision was addressed to. */
110
+ readonly sessionId: string;
111
+ constructor(sessionId: string);
63
112
  }
64
113
  /**
65
114
  * Assert that a host can do something, and throw a corrective error naming the