@stigmer/client 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/app-handover.d.ts +119 -0
  2. package/app-handover.d.ts.map +1 -0
  3. package/app-handover.js +523 -0
  4. package/app-handover.js.map +1 -0
  5. package/gen/organization.d.ts +2 -0
  6. package/gen/organization.d.ts.map +1 -1
  7. package/gen/organization.js +8 -0
  8. package/gen/organization.js.map +1 -1
  9. package/iam-principal.d.ts +11 -0
  10. package/iam-principal.d.ts.map +1 -1
  11. package/iam-principal.js +16 -0
  12. package/iam-principal.js.map +1 -1
  13. package/index.d.ts +11 -5
  14. package/index.d.ts.map +1 -1
  15. package/index.js +10 -3
  16. package/index.js.map +1 -1
  17. package/package.json +3 -3
  18. package/platform.d.ts +41 -3
  19. package/platform.d.ts.map +1 -1
  20. package/platform.js +56 -3
  21. package/platform.js.map +1 -1
  22. package/run/format-elapsed.d.ts +10 -0
  23. package/run/format-elapsed.d.ts.map +1 -0
  24. package/run/format-elapsed.js +25 -0
  25. package/run/format-elapsed.js.map +1 -0
  26. package/run/step-words.d.ts +78 -0
  27. package/run/step-words.d.ts.map +1 -0
  28. package/run/step-words.js +316 -0
  29. package/run/step-words.js.map +1 -0
  30. package/run/tool-view.d.ts +26 -2
  31. package/run/tool-view.d.ts.map +1 -1
  32. package/run/tool-view.js +83 -17
  33. package/run/tool-view.js.map +1 -1
  34. package/run/turn-activity.d.ts +9 -7
  35. package/run/turn-activity.d.ts.map +1 -1
  36. package/run/turn-activity.js +24 -144
  37. package/run/turn-activity.js.map +1 -1
  38. package/run/turn-ending.d.ts +59 -0
  39. package/run/turn-ending.d.ts.map +1 -0
  40. package/run/turn-ending.js +394 -0
  41. package/run/turn-ending.js.map +1 -0
  42. package/run/turn-steps.d.ts +16 -0
  43. package/run/turn-steps.d.ts.map +1 -0
  44. package/run/turn-steps.js +65 -0
  45. package/run/turn-steps.js.map +1 -0
  46. package/session-events.d.ts +3 -1
  47. package/session-events.d.ts.map +1 -1
  48. package/session-events.js +1 -0
  49. package/session-events.js.map +1 -1
  50. package/src/app-handover.ts +613 -0
  51. package/src/gen/organization.ts +7 -0
  52. package/src/iam-principal.ts +21 -0
  53. package/src/index.ts +49 -1
  54. package/src/platform.ts +80 -3
  55. package/src/run/format-elapsed.ts +22 -0
  56. package/src/run/step-words.ts +360 -0
  57. package/src/run/tool-view.ts +102 -19
  58. package/src/run/turn-activity.ts +27 -146
  59. package/src/run/turn-ending.ts +475 -0
  60. package/src/run/turn-steps.ts +81 -0
  61. package/src/session-events.ts +4 -1
@@ -0,0 +1,59 @@
1
+ import type { Turn } from "@stigmer/session-log";
2
+ /** How the ending reads at a glance: red didn't finish, amber paused at a limit or interrupted, grey stopped. */
3
+ export type TurnEndingTone = "failed" | "paused" | "stopped";
4
+ /**
5
+ * The one act that picks the turn back up. `run_again` and `resume` pick a
6
+ * FAILED turn up where it stopped (the run's recover); `continue` sends
7
+ * "Continue" as the person's next message; `rerun` sends the turn's message
8
+ * again; `choose_model` opens the composer's model picker; `none` offers no
9
+ * act, because doing the same again would fail the same way.
10
+ */
11
+ export type TurnEndingAct = "run_again" | "resume" | "continue" | "rerun" | "choose_model" | "none";
12
+ /** Where the fix lives: the organization's models page, the agent's page, the provider's billing or status page, or nowhere. */
13
+ export type TurnEndingLink = "models_hub" | "agent" | "provider_billing" | "provider_status" | "none";
14
+ /** Who reads the ending, as the comfort and the link need it. */
15
+ export interface TurnEndingViewer {
16
+ /** May manage the organization's model keys (an admin). */
17
+ readonly canManageProviders: boolean;
18
+ /** May open the agent that ran the turn (a member). */
19
+ readonly canOpenAgent: boolean;
20
+ /** May take the turn's act at all (recover or send); a reader may not. */
21
+ readonly canAct: boolean;
22
+ /** Stopped this turn themself. */
23
+ readonly stoppedIt: boolean;
24
+ }
25
+ /** The names the detail's model id resolves to; absent when the caller doesn't know it. */
26
+ export interface TurnEndingNames {
27
+ /** The provider's display name ("Anthropic"). */
28
+ readonly provider?: string;
29
+ /** The model's display name ("Claude Sonnet 4.6"). */
30
+ readonly model?: string;
31
+ }
32
+ /** An ended turn's words (module header). */
33
+ export interface TurnEnding {
34
+ readonly tone: TurnEndingTone;
35
+ /** The status pill's words. */
36
+ readonly pill: string;
37
+ readonly headline: string;
38
+ readonly comfort: string;
39
+ /** The note under the plan's to-do the turn stopped on ("Stopped here"). */
40
+ readonly stepNote: string;
41
+ /** The act this viewer is offered; `none` for a reader. */
42
+ readonly act: TurnEndingAct;
43
+ /** The link this viewer is offered; `none` for one who can't act on it. */
44
+ readonly link: TurnEndingLink;
45
+ /** The stop detail's kind, or the stop cause when the runner named none: what Copy details names. */
46
+ readonly kind: string;
47
+ }
48
+ /** What an ending reads when the caller asks: the turn, who reads it, and the names its model resolves to. */
49
+ export interface DescribeTurnEndingInput {
50
+ readonly turn: Turn;
51
+ readonly viewer: TurnEndingViewer;
52
+ readonly names?: TurnEndingNames;
53
+ }
54
+ /**
55
+ * How `turn` ended, in words (module header); undefined while it works, when
56
+ * it finished on its own, and for an ending its own surface tells.
57
+ */
58
+ export declare function describeTurnEnding({ turn, viewer, names }: DescribeTurnEndingInput): TurnEnding | undefined;
59
+ //# sourceMappingURL=turn-ending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-ending.d.ts","sourceRoot":"","sources":["../src/run/turn-ending.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,iHAAiH;AACjH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;AAEpG,gIAAgI;AAChI,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO,GAAG,kBAAkB,GAAG,iBAAiB,G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,uBAAuB,GAAG,UAAU,GAAG,SAAS,CAqBhH"}
@@ -0,0 +1,394 @@
1
+ // How an ended turn that didn't finish reads: one sentence on what
2
+ // happened, one that comforts (what wasn't lost, or who can fix it), the
3
+ // word the session's status pill says, the note the plan's stopped to-do
4
+ // takes, the one act that picks the turn back up, and at most one link to
5
+ // the fix. Every surface that tells a person a turn went wrong reads this
6
+ // one table, so the notice under the turn and the pill above it cannot
7
+ // disagree.
8
+ //
9
+ // It reads only what a session's events fold into a turn
10
+ // (@stigmer/session-log): the turn's phase, its stop cause, and the stop
11
+ // detail the runner names beside it (`StigmerStopDetail`: a refused key, a
12
+ // spending cap, a connected app that wouldn't connect, with the model or app
13
+ // it names). The error's text is never read for meaning: it stays the
14
+ // details a person copies for support.
15
+ //
16
+ // Trade-offs:
17
+ // - Words, not markup or addresses: the act and the link are identifiers
18
+ // (`run_again`, `models_hub`), and the surface owns what each does and
19
+ // where it points, so a terminal can adopt the same words.
20
+ // - The provider and the model are names the caller resolves from the
21
+ // detail's model id (the React kit's model registry); unknown, they read
22
+ // "the model provider" and "this model".
23
+ // - The error's text is quoted once: an agent that can't run as it is set up
24
+ // fails with the runner's own sentence for a person (its actionable
25
+ // surface), which the comfort leads with.
26
+ // - What a turn finished is counted from its own to-do list
27
+ // (`turnSteps`), never guessed from its steps: "2 of 5 to-dos are done".
28
+ // - A turn the runner named no kind for (an older runner, a desktop app's
29
+ // local runner not yet updated) reads one generic sentence per stop cause.
30
+ // - Who reads decides the comfort: one who can fix the cause (an admin for a
31
+ // key, a member for the agent) is told how; anyone else is told that
32
+ // nothing was lost and, where it helps, who can fix it.
33
+ import { turnSteps } from "./turn-steps.js";
34
+ const DIDNT_FINISH = "Didn't finish";
35
+ const LOST_NOTHING = "Nothing was lost: your message is still here.";
36
+ const KEPT = "What it finished is kept{done}.";
37
+ /** One entry per stop kind the runner names (`StigmerStopDetail.kind`), in the order of the wire's list. */
38
+ const BY_KIND = {
39
+ provider_key_rejected: {
40
+ tone: "failed",
41
+ pill: DIDNT_FINISH,
42
+ headline: "{Provider} refused this organization's model key.",
43
+ fixer: "The key on Models & providers isn't valid any more. Replace it, then Run again: the turn picks up where it stopped, and your message isn't sent twice. Nothing was lost.",
44
+ reader: `The key on Models & providers isn't valid any more, and only an admin can replace it. ${LOST_NOTHING} Ask an admin of this organization to replace it.`,
45
+ act: "run_again",
46
+ link: "models_hub",
47
+ fixedBy: "admin",
48
+ stepNote: "Stopped here",
49
+ },
50
+ provider_key_missing: {
51
+ tone: "failed",
52
+ pill: DIDNT_FINISH,
53
+ headline: "This organization has no {provider} key.",
54
+ fixer: `Add one on Models & providers, then Run again. ${LOST_NOTHING}`,
55
+ reader: `Only an admin can add one. ${LOST_NOTHING} Ask an admin of this organization to add it.`,
56
+ act: "run_again",
57
+ link: "models_hub",
58
+ fixedBy: "admin",
59
+ stepNote: "Stopped here",
60
+ },
61
+ provider_out_of_credit: {
62
+ tone: "failed",
63
+ pill: DIDNT_FINISH,
64
+ headline: "Your {provider} account has no credit left.",
65
+ fixer: "The key works, but {provider} won't run the model until the account has credit. Add some, then Run again: the turn picks up where it stopped. Nothing was lost.",
66
+ reader: `{Provider} won't run the model until the organization's account has credit. ${LOST_NOTHING}`,
67
+ act: "run_again",
68
+ link: "provider_billing",
69
+ fixedBy: "admin",
70
+ stepNote: "Stopped here",
71
+ },
72
+ provider_rate_limited: {
73
+ tone: "failed",
74
+ pill: DIDNT_FINISH,
75
+ headline: "{Provider} was too busy to answer.",
76
+ fixer: "This is on {provider}'s side and usually passes within minutes. Nothing was lost; Run again picks up where it stopped.",
77
+ reader: `This is on {provider}'s side and usually passes within minutes. ${LOST_NOTHING}`,
78
+ act: "run_again",
79
+ link: "provider_status",
80
+ fixedBy: "actor",
81
+ stepNote: "Stopped here",
82
+ },
83
+ provider_overloaded: {
84
+ tone: "failed",
85
+ pill: DIDNT_FINISH,
86
+ headline: "{Provider} was too busy to answer.",
87
+ fixer: "This is on {provider}'s side and usually passes within minutes. Nothing was lost; Run again picks up where it stopped.",
88
+ reader: `This is on {provider}'s side and usually passes within minutes. ${LOST_NOTHING}`,
89
+ act: "run_again",
90
+ link: "provider_status",
91
+ fixedBy: "actor",
92
+ stepNote: "Stopped here",
93
+ },
94
+ model_unavailable: {
95
+ tone: "failed",
96
+ pill: DIDNT_FINISH,
97
+ headline: "This key can't use {model}.",
98
+ fixer: "{Provider} says the model isn't available to this account. Choose another model, then send your message again. Nothing was lost.",
99
+ reader: `{Provider} says the model isn't available to this account. ${LOST_NOTHING}`,
100
+ act: "choose_model",
101
+ link: "none",
102
+ fixedBy: "actor",
103
+ stepNote: "Stopped here",
104
+ },
105
+ provider_unreachable: {
106
+ tone: "failed",
107
+ pill: DIDNT_FINISH,
108
+ headline: "Stigmer couldn't reach {provider}.",
109
+ fixer: "The connection dropped before {provider} answered. Nothing was lost; Run again picks up where it stopped.",
110
+ reader: `The connection dropped before {provider} answered. ${LOST_NOTHING}`,
111
+ act: "run_again",
112
+ link: "provider_status",
113
+ fixedBy: "actor",
114
+ stepNote: "Stopped here",
115
+ },
116
+ request_rejected: {
117
+ tone: "failed",
118
+ pill: DIDNT_FINISH,
119
+ headline: "{Provider} refused this request.",
120
+ fixer: "The conversation is too long for the model, or the request isn't one it accepts. Running it again would fail the same way: start a new session or send something shorter. Nothing was lost.",
121
+ reader: `The conversation is too long for the model, or the request isn't one it accepts. ${LOST_NOTHING}`,
122
+ act: "none",
123
+ link: "none",
124
+ fixedBy: "actor",
125
+ stepNote: "Stopped here",
126
+ },
127
+ cost_cap: {
128
+ tone: "paused",
129
+ pill: "Paused at its spending cap",
130
+ headline: "This turn reached its spending cap.",
131
+ fixer: `${KEPT} Continue sends "Continue" as your next message, and it carries on with a fresh budget. The cap is on the agent's page.`,
132
+ reader: KEPT,
133
+ act: "continue",
134
+ link: "agent",
135
+ fixedBy: "actor",
136
+ stepNote: "Paused here",
137
+ },
138
+ tool_call_limit: {
139
+ tone: "paused",
140
+ pill: "Paused at its step limit",
141
+ headline: "This turn reached its step limit.",
142
+ fixer: `Agents pause after so many tool calls in one turn, so a loop can't run forever. ${KEPT} Continue sends "Continue" and it carries on.`,
143
+ reader: `Agents pause after so many tool calls in one turn, so a loop can't run forever. ${KEPT}`,
144
+ act: "continue",
145
+ link: "agent",
146
+ fixedBy: "actor",
147
+ stepNote: "Paused here",
148
+ },
149
+ stalled: {
150
+ tone: "failed",
151
+ pill: DIDNT_FINISH,
152
+ headline: "The turn stalled and was stopped.",
153
+ fixer: "Its last step stopped making progress. Everything before it is kept: Resume picks up there, and steps that worked aren't run again.",
154
+ reader: "Its last step stopped making progress. Everything before it is kept.",
155
+ act: "resume",
156
+ link: "none",
157
+ fixedBy: "actor",
158
+ stepNote: "Stalled here",
159
+ },
160
+ operation_limit: {
161
+ tone: "failed",
162
+ pill: DIDNT_FINISH,
163
+ headline: "This turn hit its time limit.",
164
+ fixer: "One step ran longer than a turn may, so it was stopped while it worked. Everything before it is kept: Resume picks up there, and steps that worked aren't run again.",
165
+ reader: "One step ran longer than a turn may, so it was stopped while it worked. Everything before it is kept.",
166
+ act: "resume",
167
+ link: "none",
168
+ fixedBy: "actor",
169
+ stepNote: "Stopped here",
170
+ },
171
+ workspace_busy: {
172
+ tone: "failed",
173
+ pill: DIDNT_FINISH,
174
+ headline: "Another turn of this session held the workspace.",
175
+ fixer: "This turn waited for its files and gave up before it started. Nothing was lost; Resume once the other turn has finished.",
176
+ reader: "This turn waited for its files and gave up before it started. Nothing was lost.",
177
+ act: "resume",
178
+ link: "none",
179
+ fixedBy: "actor",
180
+ stepNote: "Stopped here",
181
+ },
182
+ agent_setup: {
183
+ tone: "failed",
184
+ pill: DIDNT_FINISH,
185
+ headline: "This agent can't run as it's set up.",
186
+ fixer: "{error} Change the agent, then Run again. Nothing was lost.",
187
+ reader: `${LOST_NOTHING} Its owner can fix the agent.`,
188
+ act: "run_again",
189
+ link: "agent",
190
+ fixedBy: "member",
191
+ stepNote: "Stopped here",
192
+ },
193
+ app_unreachable: {
194
+ tone: "failed",
195
+ pill: DIDNT_FINISH,
196
+ headline: "The {app} app wouldn't connect.",
197
+ fixer: `The agent needs it and couldn't reach it, so the turn stopped before it began. Check the app on the agent's page, then Run again. ${LOST_NOTHING}`,
198
+ reader: `The agent needs it and couldn't reach it, so the turn stopped before it began. ${LOST_NOTHING}`,
199
+ act: "run_again",
200
+ link: "agent",
201
+ fixedBy: "member",
202
+ stepNote: "Stopped here",
203
+ },
204
+ app_needs_sign_in: {
205
+ tone: "failed",
206
+ pill: DIDNT_FINISH,
207
+ headline: "The {app} app needs a new sign-in.",
208
+ fixer: `The agent couldn't use it because its sign-in has expired. Sign in again on the agent's page, then Run again. ${LOST_NOTHING}`,
209
+ reader: `The agent couldn't use it because its sign-in has expired. ${LOST_NOTHING}`,
210
+ act: "run_again",
211
+ link: "agent",
212
+ fixedBy: "member",
213
+ stepNote: "Stopped here",
214
+ },
215
+ internal: {
216
+ tone: "failed",
217
+ pill: DIDNT_FINISH,
218
+ headline: "Something broke on Stigmer's side.",
219
+ fixer: "It wasn't anything you did, and what the agent finished is kept. Run again picks up where it stopped; if it happens twice, copy the details for support.",
220
+ reader: "It wasn't anything you did, and what the agent finished is kept.",
221
+ act: "run_again",
222
+ link: "none",
223
+ fixedBy: "actor",
224
+ stepNote: "Stopped here",
225
+ },
226
+ runner_lost: {
227
+ tone: "paused",
228
+ pill: "Interrupted",
229
+ headline: "The turn was interrupted when the machine running it stopped.",
230
+ fixer: "It kept its place. Resume picks up after the last finished step: steps that worked aren't run again, and your message isn't sent twice.",
231
+ reader: "It kept its place.",
232
+ act: "resume",
233
+ link: "none",
234
+ fixedBy: "actor",
235
+ stepNote: "Interrupted here",
236
+ },
237
+ no_sandbox_room: {
238
+ tone: "failed",
239
+ pill: "Didn't start",
240
+ headline: "Every sandbox was busy, so this turn didn't start.",
241
+ fixer: `${LOST_NOTHING} Run again waits for room again.`,
242
+ reader: LOST_NOTHING,
243
+ act: "run_again",
244
+ link: "none",
245
+ fixedBy: "actor",
246
+ stepNote: "Didn't start",
247
+ },
248
+ };
249
+ /** One entry per stop cause, for a turn the runner named no kind for, and the stops whose cause says it all. */
250
+ const BY_CAUSE = {
251
+ model_error: {
252
+ tone: "failed",
253
+ pill: DIDNT_FINISH,
254
+ headline: "The model provider didn't finish this turn.",
255
+ fixer: "It failed on the provider's side, and Stigmer wasn't told why. Nothing was lost; Run again picks up where it stopped.",
256
+ reader: `It failed on the provider's side. ${LOST_NOTHING}`,
257
+ act: "run_again",
258
+ link: "none",
259
+ fixedBy: "actor",
260
+ stepNote: "Stopped here",
261
+ },
262
+ failed: {
263
+ tone: "failed",
264
+ pill: DIDNT_FINISH,
265
+ headline: "This turn didn't finish.",
266
+ fixer: "Something stopped it before it was done, and Stigmer wasn't told why. Nothing was lost; Run again picks up where it stopped. If it happens twice, copy the details for support.",
267
+ reader: `Something stopped it before it was done. ${LOST_NOTHING}`,
268
+ act: "run_again",
269
+ link: "none",
270
+ fixedBy: "actor",
271
+ stepNote: "Stopped here",
272
+ },
273
+ timeout: {
274
+ tone: "failed",
275
+ pill: DIDNT_FINISH,
276
+ headline: "The turn ran out of time and was stopped.",
277
+ fixer: "Everything before it is kept: Resume picks up there, and steps that worked aren't run again.",
278
+ reader: "Everything before it is kept.",
279
+ act: "resume",
280
+ link: "none",
281
+ fixedBy: "actor",
282
+ stepNote: "Stopped here",
283
+ },
284
+ budget_reached: {
285
+ tone: "paused",
286
+ pill: "Paused at a limit",
287
+ headline: "This turn reached one of its limits.",
288
+ fixer: `${KEPT} Continue sends "Continue" as your next message, and it carries on. The limits are on the agent's page.`,
289
+ reader: KEPT,
290
+ act: "continue",
291
+ link: "agent",
292
+ fixedBy: "actor",
293
+ stepNote: "Paused here",
294
+ },
295
+ infrastructure: BY_KIND["runner_lost"],
296
+ user: {
297
+ tone: "stopped",
298
+ pill: "Stopped",
299
+ headline: "This turn was stopped.",
300
+ fixer: `${KEPT} Continue sends "Continue" as your next message, and it carries on from here.`,
301
+ reader: KEPT,
302
+ act: "continue",
303
+ link: "none",
304
+ fixedBy: "actor",
305
+ stepNote: "Stopped here",
306
+ },
307
+ platform_stop: {
308
+ tone: "stopped",
309
+ pill: "Stopped by Stigmer",
310
+ headline: "Stigmer stopped this turn.",
311
+ fixer: "It wasn't the agent and it wasn't you. What it finished is kept; run it again when you're ready. If it can't run, sending will say why.",
312
+ reader: "It wasn't the agent and it wasn't you. What it finished is kept.",
313
+ act: "rerun",
314
+ link: "none",
315
+ fixedBy: "actor",
316
+ stepNote: "Stopped here",
317
+ },
318
+ };
319
+ /** A person's own stop, read by the person who stopped it. */
320
+ const STOPPED_BY_YOU = { pill: "Stopped by you", headline: "You stopped this turn." };
321
+ /** Stop causes whose own surface tells the ending (an eval's try, a file review's settlement): no notice. */
322
+ const QUIET_CAUSES = new Set(["eval_stopped", "review_resolved"]);
323
+ /**
324
+ * How `turn` ended, in words (module header); undefined while it works, when
325
+ * it finished on its own, and for an ending its own surface tells.
326
+ */
327
+ export function describeTurnEnding({ turn, viewer, names = {} }) {
328
+ const status = turn.status;
329
+ if (!turn.ended || status === undefined)
330
+ return undefined;
331
+ const cause = status.stopCause;
332
+ if (QUIET_CAUSES.has(cause))
333
+ return undefined;
334
+ const kind = status.stopDetail?.kind ?? "";
335
+ const entry = entryOf(status.phase, cause, kind);
336
+ if (entry === undefined)
337
+ return undefined;
338
+ const ownStop = cause === "user" || (status.phase === "cancelled" && cause === "") ? viewer.stoppedIt : false;
339
+ const canFix = viewer.canAct && (entry.fixedBy === "admin" ? viewer.canManageProviders : entry.fixedBy === "member" ? viewer.canOpenAgent : true);
340
+ const fill = filler(turn, names, status.stopDetail?.app ?? "");
341
+ return {
342
+ tone: entry.tone,
343
+ pill: ownStop ? STOPPED_BY_YOU.pill : entry.pill,
344
+ headline: fill(ownStop ? STOPPED_BY_YOU.headline : entry.headline),
345
+ comfort: fill(canFix ? entry.fixer : entry.reader),
346
+ stepNote: entry.stepNote,
347
+ act: viewer.canAct ? entry.act : "none",
348
+ link: canFix ? entry.link : "none",
349
+ kind: kind !== "" ? kind : cause,
350
+ };
351
+ }
352
+ /** The entry for an ending: its kind's, else its cause's, else its phase's. */
353
+ function entryOf(phase, cause, kind) {
354
+ const byKind = BY_KIND[kind];
355
+ if (byKind !== undefined)
356
+ return byKind;
357
+ const byCause = BY_CAUSE[cause];
358
+ if (byCause !== undefined)
359
+ return byCause;
360
+ if (phase === "failed")
361
+ return BY_CAUSE["failed"];
362
+ // A cancel or a termination no cause explains is a stop (an operator's terminate, a run older than causes).
363
+ if (phase === "cancelled" || phase === "terminated")
364
+ return BY_CAUSE["user"];
365
+ return undefined;
366
+ }
367
+ /** Fills a sentence's placeholders from the turn and its names. */
368
+ function filler(turn, names, app) {
369
+ // The agent's setup failure is a person's sentence already (the runner's
370
+ // actionable surface): the one error the comfort quotes.
371
+ const error = (turn.status?.error ?? "").trim();
372
+ const provider = names.provider ?? "the model provider";
373
+ const model = names.model ?? "this model";
374
+ const done = doneOf(turn);
375
+ return (text) => text
376
+ .replaceAll("{Provider}", capitalized(provider))
377
+ .replaceAll("{provider}", provider)
378
+ .replaceAll("{model}", model)
379
+ .replaceAll("{app}", app === "" ? "connected" : app)
380
+ .replaceAll("{done}", done)
381
+ .replaceAll("{error}", error);
382
+ }
383
+ /** What the turn finished, from its own to-do list: ": 2 of 5 to-dos are done", or nothing with no list. */
384
+ function doneOf(turn) {
385
+ const plan = turnSteps(turn).plan;
386
+ if (plan.length === 0)
387
+ return "";
388
+ const done = plan.filter((item) => item.todo.status === "completed").length;
389
+ return `: ${done} of ${plan.length} to-dos are done`;
390
+ }
391
+ function capitalized(text) {
392
+ return text.charAt(0).toUpperCase() + text.slice(1);
393
+ }
394
+ //# sourceMappingURL=turn-ending.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-ending.js","sourceRoot":"","sources":["../src/run/turn-ending.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E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KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Todo, ToolUse, Turn } from "@stigmer/session-log";
2
+ /** One item of the agent's to-do list, with the calls made while it was in progress. */
3
+ export interface PlanItem {
4
+ readonly todo: Todo;
5
+ readonly calls: readonly ToolUse[];
6
+ }
7
+ /** A turn's steps (module header). */
8
+ export interface TurnSteps {
9
+ /** The to-do list in order, each item with its calls; empty when the agent keeps no list. */
10
+ readonly plan: readonly PlanItem[];
11
+ /** The calls made before any list, or while nothing on it was in progress, in order: every call when there is no list. */
12
+ readonly loose: readonly ToolUse[];
13
+ }
14
+ /** `turn`'s steps: its plan and its loose calls (module header). */
15
+ export declare function turnSteps(turn: Turn): TurnSteps;
16
+ //# sourceMappingURL=turn-steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-steps.d.ts","sourceRoot":"","sources":["../src/run/turn-steps.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIhE,wFAAwF;AACxF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;CACpC;AAED,sCAAsC;AACtC,MAAM,WAAW,SAAS;IACxB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC,0HAA0H;IAC1H,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;CACpC;AAOD,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAyB/C"}
@@ -0,0 +1,65 @@
1
+ // A turn's steps as its plan: the agent's own to-do list, each item with
2
+ // the calls the agent made while that item was in progress, and the calls
3
+ // made before any list or while nothing on it was in progress. Every
4
+ // surface that draws a turn's work as the agent's plan reads this one
5
+ // derivation.
6
+ //
7
+ // It reads only what a session's events fold into a turn
8
+ // (@stigmer/session-log): the turn's items in log order. The fold keeps
9
+ // every to-do call among them and the latest list on the turn; replaying
10
+ // the to-do calls in item order with the fold's own rule (`applyTodoUpdate`)
11
+ // gives, at each other call, the item that was in progress when it was made.
12
+ // A to-do call counts where the fold counts it: on the primary thread,
13
+ // built in (not a connected app's tool of the same name), returned without
14
+ // an error.
15
+ //
16
+ // Trade-offs:
17
+ // - The plan is the list the replay ends on, which is the turn's latest
18
+ // list (`Turn.todos`) once every to-do call returned. A call made under an
19
+ // item a later full rewrite dropped has no item to sit under, so it joins
20
+ // the loose calls, in order.
21
+ // - A call's place is its position among the turn's items (the order the
22
+ // log first named each), so a call the agent made right after updating
23
+ // its list sits under the item that update put in progress.
24
+ // - Only the primary thread's calls are steps here: a subagent's own calls
25
+ // belong to its card, as everywhere else.
26
+ // - Items are matched by the fold's ids, and neither engine sends one, so
27
+ // an item's id is its place in the list (`todo-<i>`). A rewrite that
28
+ // inserts or reorders items moves the calls made under a place to
29
+ // whatever item now sits there; agents append and tick rather than
30
+ // reorder, so the plan reads right in practice.
31
+ import { applyTodoUpdate } from "@stigmer/session-log";
32
+ import { resolveToolKind } from "./tool-view.js";
33
+ /** Whether `tool` is a to-do call the fold applies (module header). */
34
+ function isAppliedTodoCall(tool) {
35
+ return tool.threadId === "" && tool.mcpServerName === "" && resolveToolKind(tool) === "todo" && tool.result !== undefined && !tool.result.isError;
36
+ }
37
+ /** `turn`'s steps: its plan and its loose calls (module header). */
38
+ export function turnSteps(turn) {
39
+ const list = new Map();
40
+ const callsById = new Map();
41
+ const placed = [];
42
+ for (const item of turn.items) {
43
+ if (item.kind !== "tool_use" || item.threadId !== "")
44
+ continue;
45
+ if (resolveToolKind(item) === "todo" && item.mcpServerName === "") {
46
+ if (isAppliedTodoCall(item)) {
47
+ applyTodoUpdate(list, item.input["todos"], { merge: item.input["merge"] === true, now: item.result.processedAt });
48
+ }
49
+ continue;
50
+ }
51
+ const current = [...list.values()].find((todo) => todo.status === "in_progress");
52
+ placed.push({ tool: item, todoId: current?.id });
53
+ }
54
+ const loose = [];
55
+ for (const { tool, todoId } of placed) {
56
+ if (todoId === undefined || !list.has(todoId)) {
57
+ loose.push(tool);
58
+ continue;
59
+ }
60
+ callsById.set(todoId, [...(callsById.get(todoId) ?? []), tool]);
61
+ }
62
+ const plan = [...list.values()].map((todo) => ({ todo, calls: callsById.get(todo.id) ?? [] }));
63
+ return { plan, loose };
64
+ }
65
+ //# sourceMappingURL=turn-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-steps.js","sourceRoot":"","sources":["../src/run/turn-steps.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,sEAAsE;AACtE,cAAc;AACd,EAAE;AACF,yDAAyD;AACzD,wEAAwE;AACxE,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,uEAAuE;AACvE,2EAA2E;AAC3E,YAAY;AACZ,EAAE;AACF,cAAc;AACd,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,+BAA+B;AAC/B,yEAAyE;AACzE,yEAAyE;AACzE,8DAA8D;AAC9D,2EAA2E;AAC3E,4CAA4C;AAC5C,0EAA0E;AAC1E,uEAAuE;AACvE,oEAAoE;AACpE,qEAAqE;AACrE,kDAAkD;AAGlD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAgBjD,uEAAuE;AACvE,SAAS,iBAAiB,CAAC,IAAa;IACtC,OAAO,IAAI,CAAC,QAAQ,KAAK,EAAE,IAAI,IAAI,CAAC,aAAa,KAAK,EAAE,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;AAC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IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,SAAS;QACX,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/F,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC"}
@@ -38,7 +38,7 @@
38
38
  import { type JsonObject } from "@bufbuild/protobuf";
39
39
  import type { Run } from "@stigmer/apis/ai/stigmer/agentic/run/v1/api_pb";
40
40
  import type { Attention, ListSessionEventsRequest, SessionEventList, StreamAttentionRequest, StreamSessionEventsRequest, StreamSessionEventsResponse } from "@stigmer/apis/ai/stigmer/agentic/session/v1/io_pb";
41
- import { type ToolUse, type Turn, type TurnPhase } from "@stigmer/session-log";
41
+ import { type ToolUse, type Turn, type TurnPhase, type TurnStopDetail } from "@stigmer/session-log";
42
42
  import type { RunInput } from "./gen/run.js";
43
43
  /** The preview types a follow can ask for (`StreamSessionEventsRequest.event_deltas`). */
44
44
  export type SessionPreviewType = "agent.message" | "agent.thinking" | "stigmer.tool_output_delta" | "stigmer.run.liveness";
@@ -129,6 +129,8 @@ export interface TurnOutcome {
129
129
  readonly structuredOutput: JsonObject | undefined;
130
130
  /** Why it ended (RunStatus.stop_cause), once it has; "" otherwise. */
131
131
  readonly stopCause: string;
132
+ /** Which kind of ending the cause was (RunStatus.stop_detail), once it ended and the runner said; absent otherwise. */
133
+ readonly stopDetail?: TurnStopDetail;
132
134
  /** What went wrong, when it failed or was stopped with a reason. */
133
135
  readonly error: string;
134
136
  /** The tool uses that wait for an answer, when `phase` is waiting. */
@@ -1 +1 @@
1
- {"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["src/session-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gDAAgD,CAAC;AAC1E,OAAO,KAAK,EACV,SAAS,EACT,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,mDAAmD,CAAC;AAM3D,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAS7C,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,gBAAgB,GAChB,2BAA2B,GAC3B,sBAAsB,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,kBAAkB,CAKlE,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE;QAChB,YAAY,CAAC,KAAK,EAAE,0BAA0B,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,2BAA2B,CAAC,CAAC;QAClH,UAAU,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;KACxE,CAAC;CACH;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,QAAQ,CAAC,GAAG,EAAE;QAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,CAAC;C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AAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,WAAW,CAczG;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAM,GAC1C,OAAO,CAAC,WAAW,CAAC,CAGtB"}
package/session-events.js CHANGED
@@ -212,6 +212,7 @@ export function turnOutcomeOf(turn, place, lastSeq, waiting = false) {
212
212
  answer: turn.answer,
213
213
  structuredOutput: turn.structuredOutput,
214
214
  stopCause: turn.status?.stopCause ?? "",
215
+ ...(ended && turn.status?.stopDetail !== undefined ? { stopDetail: turn.status.stopDetail } : {}),
215
216
  error: turn.status?.error ?? "",
216
217
  asks: ended ? [] : turn.asks,
217
218
  turn,