@prismshadow/penguin-server 0.2.15 → 0.2.17

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 (124) hide show
  1. package/README.md +1 -1
  2. package/dist/api/types.d.ts +318 -86
  3. package/dist/api/types.js +9 -3
  4. package/dist/auth-token.d.ts +1 -1
  5. package/dist/auth-token.js +2 -2
  6. package/dist/{chunk-HMTT2PX4.js → chunk-2LZDP26O.js} +8 -5
  7. package/dist/chunk-2LZDP26O.js.map +1 -0
  8. package/dist/{chunk-LPPVGHYD.js → chunk-BL4U7GYY.js} +2 -2
  9. package/dist/chunk-BL4U7GYY.js.map +1 -0
  10. package/dist/{chunk-5Z4UCHDB.js → chunk-D3JNA6ZI.js} +69 -6
  11. package/dist/chunk-D3JNA6ZI.js.map +1 -0
  12. package/dist/{chunk-TOOTEEM4.js → chunk-G7GY7PJU.js} +1 -1
  13. package/dist/chunk-G7GY7PJU.js.map +1 -0
  14. package/dist/chunk-GGIINEEK.js +3401 -0
  15. package/dist/chunk-GGIINEEK.js.map +1 -0
  16. package/dist/chunk-HDBZRVA5.js +29 -0
  17. package/dist/chunk-HDBZRVA5.js.map +1 -0
  18. package/dist/{chunk-NVWAYYRX.js → chunk-HPOHMZCH.js} +686 -531
  19. package/dist/chunk-HPOHMZCH.js.map +1 -0
  20. package/dist/{chunk-QFV3ERQO.js → chunk-OQZDL3TR.js} +2 -2
  21. package/dist/hmr/manifest.js +1 -1
  22. package/dist/index.js +9351 -5551
  23. package/dist/index.js.map +1 -1
  24. package/dist/machine-status.js +2 -2
  25. package/dist/model-catalog.d.ts +610 -0
  26. package/dist/model-catalog.js +108 -0
  27. package/dist/model-catalog.js.map +1 -0
  28. package/dist/plugin/index.d.ts +141 -78
  29. package/dist/reset-admin-password.js +3 -4
  30. package/dist/reset-admin-password.js.map +1 -1
  31. package/dist/version-report.js +2 -2
  32. package/package.json +15 -14
  33. package/web-dist/assets/{abnfDiagram-VCTEODGH-CKWh4hoA.js → abnfDiagram-VCTEODGH-DMzkb4l4.js} +1 -1
  34. package/web-dist/assets/{addon-clipboard-DxLqat7q.js → addon-clipboard-BtD2BVSi.js} +1 -1
  35. package/web-dist/assets/{addon-fit-B8oPGPkW.js → addon-fit-Dr6HWsi_.js} +1 -1
  36. package/web-dist/assets/{addon-web-links-C0W5TcK0.js → addon-web-links-VEE3YLzQ.js} +1 -1
  37. package/web-dist/assets/{arc-Dp9EkaAH.js → arc-CvMPOU_B.js} +1 -1
  38. package/web-dist/assets/{architectureDiagram-5GKGNRK7-BQ3LUcle.js → architectureDiagram-5GKGNRK7-Bk65mIBz.js} +1 -1
  39. package/web-dist/assets/{blockDiagram-I7D4REHJ-CZzyU0Jj.js → blockDiagram-I7D4REHJ-D54-XSNs.js} +1 -1
  40. package/web-dist/assets/{c4Diagram-7LVT6UL2-Qps3jeAu.js → c4Diagram-7LVT6UL2-Dm954LSt.js} +1 -1
  41. package/web-dist/assets/channel-CVHI75kz.js +1 -0
  42. package/web-dist/assets/{chunk-2Q5K7J3B-CQMntzuX.js → chunk-2Q5K7J3B-D_LJ_7Cn.js} +1 -1
  43. package/web-dist/assets/{chunk-5VM5RSS4-2H2ZJAte.js → chunk-5VM5RSS4-B8RI4tl3.js} +1 -1
  44. package/web-dist/assets/{chunk-F27PBJKO-B30xCNBv.js → chunk-F27PBJKO-aVSYH9JV.js} +1 -1
  45. package/web-dist/assets/{chunk-IMKFNOWR-Cyfx4zDs.js → chunk-IMKFNOWR-DnkdWeq2.js} +1 -1
  46. package/web-dist/assets/{chunk-JWPE2WC7-DADUytTh.js → chunk-JWPE2WC7-C2pJzKuW.js} +1 -1
  47. package/web-dist/assets/{chunk-POPQ4Y6H-9bjsAxLS.js → chunk-POPQ4Y6H-Bx7Iikzx.js} +1 -1
  48. package/web-dist/assets/{chunk-SVP7TREG-B9xO1VpN.js → chunk-SVP7TREG-qJC2SMqr.js} +1 -1
  49. package/web-dist/assets/{chunk-TICWLB2K-B6oDkrep.js → chunk-TICWLB2K-Crl_BgKI.js} +1 -1
  50. package/web-dist/assets/{chunk-XXDRQBXY-BbU8DR4B.js → chunk-XXDRQBXY-BFFemuGm.js} +1 -1
  51. package/web-dist/assets/classDiagram-ZZMXUADV-CBdzAPFu.js +1 -0
  52. package/web-dist/assets/classDiagram-v2-VYDZK3BY-CBdzAPFu.js +1 -0
  53. package/web-dist/assets/{cose-bilkent-JH36ORCC-pkbuyec-.js → cose-bilkent-JH36ORCC-Bmh2Kx7h.js} +1 -1
  54. package/web-dist/assets/{cynefin-OW5HDTMX-DU9YQQnc.js → cynefin-OW5HDTMX-BveNWnUV.js} +1 -1
  55. package/web-dist/assets/{cynefinDiagram-5FMLGOSQ-3a3XuhQq.js → cynefinDiagram-5FMLGOSQ-85itazbJ.js} +1 -1
  56. package/web-dist/assets/{dagre-GXQ25YYZ-BfZ9C5CZ.js → dagre-GXQ25YYZ-DIZT-KY_.js} +1 -1
  57. package/web-dist/assets/{diagram-S7CK7UJ4-BoGhVBMn.js → diagram-S7CK7UJ4-Dum-g63f.js} +1 -1
  58. package/web-dist/assets/{diagram-UQ7AKVKN-zE67quty.js → diagram-UQ7AKVKN-DallMKJl.js} +1 -1
  59. package/web-dist/assets/{diagram-VSXAHHWV-NihoXeXm.js → diagram-VSXAHHWV-DWELqxfN.js} +1 -1
  60. package/web-dist/assets/{diagram-VX7I27RA-1627np0S.js → diagram-VX7I27RA-BNs0gB9E.js} +1 -1
  61. package/web-dist/assets/{diagram-Z3DM3KII-Ddg_bUan.js → diagram-Z3DM3KII-C9mF9xAd.js} +1 -1
  62. package/web-dist/assets/{ebnfDiagram-PWID7BFC-CmPUOM4j.js → ebnfDiagram-PWID7BFC-D_Diy9HH.js} +1 -1
  63. package/web-dist/assets/{erDiagram-RLTQ6QDP-DiTnEK72.js → erDiagram-RLTQ6QDP-4QTS5VIh.js} +1 -1
  64. package/web-dist/assets/{flowDiagram-HODETNUW-mGQ38tRM.js → flowDiagram-HODETNUW-CliTRrtV.js} +1 -1
  65. package/web-dist/assets/{ganttDiagram-EL5Y4UJY-DU7MlzpW.js → ganttDiagram-EL5Y4UJY-DCRd-Ss4.js} +1 -1
  66. package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-CRE_3vjl.js → gitGraphDiagram-WWUBYQGX-CTz13GjS.js} +1 -1
  67. package/web-dist/assets/highlighter-BScH1Ud3.js +2 -0
  68. package/web-dist/assets/{highlighter-core-B5CvXcEK.js → highlighter-core-DKz8Z6-I.js} +1 -1
  69. package/web-dist/assets/{highlighter.worker-D6D9fPma.js → highlighter.worker-CKF6ok1g.js} +1 -1
  70. package/web-dist/assets/index-BUvJ5Ctt.js +1299 -0
  71. package/web-dist/assets/index-DRj7nvPY.css +1 -0
  72. package/web-dist/assets/{infoDiagram-27XIBGKW-Cdo6Ar-a.js → infoDiagram-27XIBGKW-DNfTEPAV.js} +1 -1
  73. package/web-dist/assets/{ishikawaDiagram-5VMMS53U-C27pgect.js → ishikawaDiagram-5VMMS53U-B7aCjjG1.js} +1 -1
  74. package/web-dist/assets/{journeyDiagram-3NMN7TZE-CVxtKpLG.js → journeyDiagram-3NMN7TZE-COmDALVr.js} +1 -1
  75. package/web-dist/assets/{kanban-definition-UXKFOSKX-DWA31Da7.js → kanban-definition-UXKFOSKX-BzUfPINh.js} +1 -1
  76. package/web-dist/assets/{layout-DWKCU9PO.js → layout-BwzuPU4M.js} +1 -1
  77. package/web-dist/assets/{linear-BwCthj_k.js → linear-WPZTYjz3.js} +1 -1
  78. package/web-dist/assets/mermaid.core-zKzlwpkw.js +310 -0
  79. package/web-dist/assets/{mindmap-definition-YA3MSWOX-BLEDhbn1.js → mindmap-definition-YA3MSWOX-DCRg7eAx.js} +1 -1
  80. package/web-dist/assets/{pegDiagram-XKGWAZYB-CLEM1SDU.js → pegDiagram-XKGWAZYB-DyphzDLU.js} +1 -1
  81. package/web-dist/assets/{pieDiagram-E7YTZNPT-B__g6eF0.js → pieDiagram-E7YTZNPT-BI5DueGA.js} +1 -1
  82. package/web-dist/assets/powershell-DXrKVo3G.js +1 -0
  83. package/web-dist/assets/powershell-Dpen1YoG.js +1 -0
  84. package/web-dist/assets/{quadrantDiagram-AXDQQJYC-C7VQ2LMY.js → quadrantDiagram-AXDQQJYC-GZxSMY2Z.js} +1 -1
  85. package/web-dist/assets/{railroadDiagram-O6MQD6OU-eWNnzjwS.js → railroadDiagram-O6MQD6OU-DEFCigBf.js} +1 -1
  86. package/web-dist/assets/{requirementDiagram-BXWQKSXE-Bi5qeD4b.js → requirementDiagram-BXWQKSXE-Br0thc4j.js} +1 -1
  87. package/web-dist/assets/{sankeyDiagram-P5KCCOFB-DG1VOpXX.js → sankeyDiagram-P5KCCOFB-DYf0pY67.js} +1 -1
  88. package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-Fhkw73Th.js → sequenceDiagram-WJ2MYXX4-1EFMboX4.js} +1 -1
  89. package/web-dist/assets/{sizeCapture-INFHLROL-D9E_17SF.js → sizeCapture-INFHLROL-BuOFv-5q.js} +1 -1
  90. package/web-dist/assets/{stateDiagram-D77RDMKH-Cs5Y0xhW.js → stateDiagram-D77RDMKH-Bg3H1tjX.js} +1 -1
  91. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-DfaDaPAd.js +1 -0
  92. package/web-dist/assets/{swimlanes-42K2YHIH-t-EocvKZ.js → swimlanes-42K2YHIH-BuOa6Osb.js} +1 -1
  93. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BopAC7b8.js +8 -0
  94. package/web-dist/assets/{timeline-definition-24CTP7MA-CozGCxuA.js → timeline-definition-24CTP7MA-BDekfdDT.js} +1 -1
  95. package/web-dist/assets/{vennDiagram-4TSXK5OY-ewU8ycSa.js → vennDiagram-4TSXK5OY-DnC09UI4.js} +1 -1
  96. package/web-dist/assets/{wardleyDiagram-VM6X3IG4-DuAhDu-0.js → wardleyDiagram-VM6X3IG4-BXKvxuZQ.js} +1 -1
  97. package/web-dist/assets/{xterm-v5e56GC9.js → xterm-oY4DYg5s.js} +1 -1
  98. package/web-dist/assets/{xychartDiagram-S5SC5T6Z-BxGuZO23.js → xychartDiagram-S5SC5T6Z-DdDC1VLb.js} +1 -1
  99. package/web-dist/index.html +12 -6
  100. package/web-dist/{workflow-ui.css → workbench-ui.css} +72 -67
  101. package/dist/benchmark-package.d.ts +0 -39
  102. package/dist/benchmark-package.js +0 -97
  103. package/dist/benchmark-package.js.map +0 -1
  104. package/dist/chunk-54E64LWB.js +0 -63
  105. package/dist/chunk-54E64LWB.js.map +0 -1
  106. package/dist/chunk-5Z4UCHDB.js.map +0 -1
  107. package/dist/chunk-HMTT2PX4.js.map +0 -1
  108. package/dist/chunk-JKJXQTHH.js +0 -19
  109. package/dist/chunk-JKJXQTHH.js.map +0 -1
  110. package/dist/chunk-LPPVGHYD.js.map +0 -1
  111. package/dist/chunk-NVWAYYRX.js.map +0 -1
  112. package/dist/chunk-Q4ON2L6E.js +0 -52
  113. package/dist/chunk-Q4ON2L6E.js.map +0 -1
  114. package/dist/chunk-TOOTEEM4.js.map +0 -1
  115. package/web-dist/assets/channel--PblgLlC.js +0 -1
  116. package/web-dist/assets/classDiagram-ZZMXUADV-mn8tbuqa.js +0 -1
  117. package/web-dist/assets/classDiagram-v2-VYDZK3BY-mn8tbuqa.js +0 -1
  118. package/web-dist/assets/highlighter-CzfXQ6yd.js +0 -2
  119. package/web-dist/assets/index-BdG4qRyI.js +0 -1275
  120. package/web-dist/assets/index-W-xYFoIm.css +0 -1
  121. package/web-dist/assets/mermaid.core-BcTrmPOv.js +0 -310
  122. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-CEM51fAf.js +0 -1
  123. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BrR66vrK.js +0 -8
  124. /package/dist/{chunk-QFV3ERQO.js.map → chunk-OQZDL3TR.js.map} +0 -0
@@ -1,10 +1,10 @@
1
- import { SpawnConfiner, OmniMessage, ThinkingLevelName, ToolCallPayload, ApprovalDecision, ProjectConfig, ModelRef, PluginTables, ListEndpointModelsOptions, ModelRequestContext, ProxyEnvPolicy, ControlEnvContext, AgentAssembly, ApproveFn, StopReason, CompactAvailability, SessionTitleResult, BackgroundCommandInfo, ToolDetachResult, BackgroundSubagentInfo, SubagentMessageOptions, SubagentMessageOutcome } from '@prismshadow/penguin-core';
1
+ import { SpawnConfiner, AmspRecord, ThinkingLevelName, ToolCallPayload, ApprovalDecision, ProjectConfig, ModelRef, PluginTables, ListEndpointModelsOptions, ModelRequestContext, ProxyEnvPolicy, ControlEnvContext, AgentAssembly, ApproveFn, StopReason, CompactAvailability, SessionTitleResult, BackgroundCommandInfo, ToolDetachResult, BackgroundSubagentInfo, SubagentMessageOptions, SubagentMessageOutcome } from '@prismshadow/penguin-core';
2
2
  import { SandboxProviderSource, SandboxSettings, SandboxDimension, SandboxLimit } from '@prismshadow/penguin-core/plugin';
3
3
  import { Slot, Opaque } from '@prismshadow/penguin-core/kernel';
4
4
  import { ApprovalMode, ModelRefDto, ChatDefaultsDto, CommandPolicyDto, ModelVisionDetectRequest, ModelVisionDetectResponse, ModelTestRequest, ModelTestResponse, ModelProtocolDetectRequest, ModelProtocolDetectResponse, EndpointModelListRequest, EndpointModelListResponse, ModelsResponse, ModelsUpdateRequest, ProviderConnectionUpdate, PresetSyncMode, PresetSyncResponse, ServerEvent, MessagingChannel, UnavailableSandboxBackend, SessionSandboxPreset, SessionSandbox, SessionInfo, SessionCategory, SessionCategoryCounts, ModelScopeAuthFlowStatusResponse, SessionStatus, PendingSteeringInfo, SessionBackgroundTasks, PendingFollowUpInfo, AgentConfigDto, AgentConfigUpdateRequest, AgentKernelUpdateResponse, VaultResponse, VaultUpdateRequest, PluginUpdateRef, MessagingRuntimeStatus, PluginConfiguration, ContributionsResponse, RendererRef } from '../api/types.js';
5
5
  export { PluginConfigField } from '../api/types.js';
6
6
  import { ThinkingLevelName as ThinkingLevelName$1 } from '@prismshadow/penguin-core/interfaces';
7
- import { SessionSource } from '@prismshadow/penguin-core/omnimessage';
7
+ import { SessionSource } from '@prismshadow/amsp';
8
8
  import { Hono } from 'hono';
9
9
  import '@prismshadow/penguin-hmr';
10
10
 
@@ -23,8 +23,10 @@ interface UserRow {
23
23
 
24
24
  /**
25
25
  * "desktop" and "setup" may set a password without the old one (theirs is random and was never
26
- * shown); desktop-only routes open to "desktop" alone. "token" is the local API token's Bearer
27
- * header — per request, never a stored row. Anything else reads as "password".
26
+ * shown); desktop-only routes open to "desktop" alone. "token" is the local API token's
27
+ * authority, whether presented as a Bearer header or exchanged for a Remote cookie.
28
+ * Exchanging the credential must not grant the person's privileges. Anything else reads as
29
+ * "password".
28
30
  */
29
31
  type SessionVia = "password" | "desktop" | "setup" | "token";
30
32
 
@@ -195,6 +197,12 @@ interface CreateTerminalSessionOptions {
195
197
  cwd: string;
196
198
  /** Owning user id — a shell is the most privileged thing this server hands out. */
197
199
  ownerUserId: string;
200
+ /**
201
+ * The conversation (PenguinHarness Session) this shell was opened for — not this object's own
202
+ * id. A label the Web App files the shell under, so each conversation lists only its own; null
203
+ * for a shell no conversation asked for (the API, the CLI, the standalone /terminal page).
204
+ */
205
+ sessionId?: string | null;
198
206
  /**
199
207
  * Stable per-user display number (tmux-style), assigned by the manager at creation. It
200
208
  * travels with the terminal for its whole life — UI numbering must never depend on list
@@ -254,6 +262,8 @@ interface TerminalSessionInfo {
254
262
  name: string;
255
263
  cwd: string;
256
264
  ownerUserId: string;
265
+ /** The conversation the shell belongs to, or null (see CreateTerminalSessionOptions.sessionId). */
266
+ sessionId: string | null;
257
267
  title: string | null;
258
268
  cols: number;
259
269
  rows: number;
@@ -272,6 +282,8 @@ declare class TerminalSession {
272
282
  readonly ownerUserId: string;
273
283
  readonly createdAt: Date;
274
284
  private name;
285
+ /** The conversation this shell belongs to; changes only when that conversation's id does. */
286
+ private owningSession;
275
287
  private readonly terminal;
276
288
  private readonly ptyProcess;
277
289
  private readonly inputMode;
@@ -291,6 +303,8 @@ declare class TerminalSession {
291
303
  get exit(): TerminalExitInfo | null;
292
304
  info(): TerminalSessionInfo;
293
305
  rename(name: string): void;
306
+ /** Files the shell under another conversation — the same one, once its id has self-healed. */
307
+ setSession(sessionId: string | null): void;
294
308
  write(data: string): void;
295
309
  /**
296
310
  * Applies a size request under the claim/update ownership rule, resizing both the pty and
@@ -322,6 +336,8 @@ declare class TerminalSession {
322
336
  interface CreateTerminalRequest {
323
337
  cwd: string;
324
338
  ownerUserId: string;
339
+ /** The conversation the shell is opened for; absent or null for none. */
340
+ sessionId?: string | null;
325
341
  name?: string;
326
342
  cols?: number;
327
343
  rows?: number;
@@ -370,8 +386,8 @@ interface RecallableFile {
370
386
 
371
387
  /** The open streaming fragments of running sessions, as their holder uses them — what {@link LiveTailTracker} implements. */
372
388
  interface LiveTail {
373
- observe(sessionId: string, msg: OmniMessage): void;
374
- fragments(sessionId: string): OmniMessage[];
389
+ observe(sessionId: string, msg: AmspRecord): void;
390
+ fragments(sessionId: string): AmspRecord[];
375
391
  clear(sessionId: string): void;
376
392
  }
377
393
 
@@ -475,7 +491,7 @@ interface SessionRow {
475
491
  * the CLI, or adopted from a Trace a legacy CLI-direct run left behind), "org" (opened by
476
492
  * the organization runtime — a desk or a ticket session — or spawned as a sub-session of
477
493
  * one, which inherits the stamp at registration), "api" (created by an Agent API run — the
478
- * only rows the API may continue); NULL = legacy row from before the column existed,
494
+ * only rows the API may continue), "workbench" (created by the Workbench host); NULL = legacy row from before the column existed,
479
495
  * treated as web. Free text in SQLite, so a new value needs no migration.
480
496
  * Provenance that outlives its organization: development mode's list is the one reader
481
497
  * that filters on it (through the list's `excludeOrg`), and it hides "org" rows whether or
@@ -484,7 +500,7 @@ interface SessionRow {
484
500
  * (runtime/session-sources.ts); `client` is a separate, DB-only axis that meta never
485
501
  * records.
486
502
  */
487
- client?: "web" | "cli" | "org" | "api" | null;
503
+ client?: "web" | "cli" | "org" | "api" | "workbench" | null;
488
504
  /** Cache: a Trace record exists (set at task start / adoption / subagent registration; backfilled by list hydration). */
489
505
  hasTrace?: boolean;
490
506
  /**
@@ -525,14 +541,14 @@ interface SessionRow {
525
541
  */
526
542
 
527
543
  interface PendingApproval {
528
- toolCall: OmniMessage<ToolCallPayload>;
544
+ toolCall: AmspRecord<ToolCallPayload>;
529
545
  origin?: string[];
530
546
  }
531
547
  /** A Session runtime's pending approvals, as its holder uses them — what {@link ApprovalRegistry} implements. */
532
548
  interface Approvals {
533
549
  readonly size: number;
534
550
  list(): PendingApproval[];
535
- wait(toolCall: OmniMessage<ToolCallPayload>): Promise<ApprovalDecision>;
551
+ wait(toolCall: AmspRecord<ToolCallPayload>): Promise<ApprovalDecision>;
536
552
  decide(toolCallId: string, decision: ApprovalDecision): boolean;
537
553
  denyAll(): void;
538
554
  denyMain(): void;
@@ -541,7 +557,7 @@ interface Approvals {
541
557
  /** A numbered channel event; `id` is `<epoch>-<seq>`, `data` is serialized single-line JSON. */
542
558
  interface ChannelEvent {
543
559
  id: string;
544
- /** SSE event name; omitted (OmniMessage) means no `event:` line. */
560
+ /** SSE event name; omitted (a record) means no `event:` line. */
545
561
  event?: string;
546
562
  data: string;
547
563
  }
@@ -766,6 +782,13 @@ interface TitleNotifier {
766
782
  * written before the source was required, which records none.
767
783
  */
768
784
  type RecordedSource = SessionSource | null;
785
+ /**
786
+ * Who is reading a list, as far as the listing rule cares: a server that adopted this one as a
787
+ * machine at `adoptedAt` (read from {@link ADOPTED_AT_HEADER}), or anyone else (`{}`).
788
+ */
789
+ interface ListingView {
790
+ adoptedAt?: string;
791
+ }
769
792
 
770
793
  /** One indexed Trace shard. */
771
794
  interface TraceFileRow {
@@ -832,7 +855,7 @@ declare abstract class TraceIndex {
832
855
  fileIndex: number;
833
856
  date: string;
834
857
  sizeBytes: number;
835
- records: OmniMessage[];
858
+ records: AmspRecord[];
836
859
  }): void;
837
860
  abstract removeSession(projectId: string, agentId: string, sessionId: string): void;
838
861
  abstract removeAgent(projectId: string, agentId: string): void;
@@ -866,7 +889,7 @@ interface PlatformModelCatalog {
866
889
  models: PlatformCatalogModel[];
867
890
  }
868
891
  /**
869
- * Catalog merge result. `updated` counts route migrations; existing metadata is preserved.
892
+ * Catalog merge result. `updated` counts changes to existing prices, promotions or routes.
870
893
  */
871
894
  interface PlatformModelApplyResult {
872
895
  added: number;
@@ -894,6 +917,8 @@ type UtilityCompletion = {
894
917
  /** ProjectConfigStore: the mechanism ProjectConfigService implements. */
895
918
  declare abstract class ProjectConfigStore {
896
919
  abstract readRaw(projectId: string): Promise<RawTable>;
920
+ /** Reads every Project's config once, so what the read path's one-time migrations write back (core's and the server's) is on disk before any Session opens one. */
921
+ abstract migrateStoredConfigs(): Promise<void>;
897
922
  abstract loadConfig(projectId: string): Promise<ProjectConfig>;
898
923
  abstract writeRaw(projectId: string, data: RawTable): Promise<void>;
899
924
  abstract writeInitialConfig(projectId: string, name: string): Promise<void>;
@@ -941,9 +966,8 @@ declare abstract class ProjectConfigStore {
941
966
  abstract getModelApiKey(projectId: string, provider: string, modelId: string): Promise<string | undefined>;
942
967
  /**
943
968
  * The key a group's account balance is read with: the group key (never a row's own), or
944
- * else the environment key a Session on one of the group's rows would use on its effective
945
- * endpoint, when that variable's official endpoint is the balance endpoint's own host.
946
- * Server-side only.
969
+ * else the vendor's environment key where MMSP's vendor client reads it for the group's base
970
+ * URL (none, or the vendor's own default endpoint). Server-side only.
947
971
  */
948
972
  abstract getGroupBalanceKey(projectId: string, provider: string): Promise<string | undefined>;
949
973
  abstract setModelApiKeyResolver(resolver: (context: ModelRequestContext) => Promise<string | undefined>): void;
@@ -1079,8 +1103,8 @@ declare class SessionService {
1079
1103
  /**
1080
1104
  * The approval mode a Session created without one starts with. An organization's Session
1081
1105
  * keeps `allow-all`: its runtime names the mode it wants, and nobody is there to answer an
1082
- * ask a preset might bring. The other unattended creators — a scheduled run, a workflow —
1083
- * pass `allow-all` themselves (scheduler.ts, workflows/service.ts).
1106
+ * ask a preset might bring. The other unattended creators — a scheduled run, a workbench —
1107
+ * pass `allow-all` themselves (scheduler.ts, workbenches/service.ts).
1084
1108
  */
1085
1109
  private startApproval;
1086
1110
  /** A Session's policy: its snapshot, or — for a row from before snapshots — the settings. */
@@ -1101,9 +1125,11 @@ declare class SessionService {
1101
1125
  * Session the user never kept reads archived, and a subagent with a stray mark does not.
1102
1126
  *
1103
1127
  * `orgIds` is the list flow's one-query organization map (see listSessions); without it the
1104
- * organization is a point lookup, which is what the single-Session paths want.
1128
+ * organization is a point lookup, which is what the single-Session paths want. `view` is who
1129
+ * is reading (sourceSeenBy): a server that adopted this one sees its earlier Sessions as CLI
1130
+ * tasks, in `source` and `archived` alike.
1105
1131
  */
1106
- toInfo(row: SessionRow, hasTrace: boolean, orgIds?: ReadonlyMap<string, string>): Promise<SessionInfo>;
1132
+ toInfo(row: SessionRow, hasTrace: boolean, orgIds?: ReadonlyMap<string, string>, view?: ListingView): Promise<SessionInfo>;
1107
1133
  /**
1108
1134
  * A Session's source, with session_meta as the single source of truth: the in-process
1109
1135
  * registry answers first (populated at creation / subagent registration / forks / adoption /
@@ -1113,9 +1139,11 @@ declare class SessionService {
1113
1139
  * no source is read with the row's client (readRecordedSource). A Session with no Trace yet
1114
1140
  * is NOT cached — its meta appears with the first run — and reads as its row says
1115
1141
  * (unrunSource): the organization runtime's as `company`, the Agent API's as `api`, any other
1116
- * as unknown.
1142
+ * as unknown. What the reader sees of it (sourceSeenBy) is applied last and never cached.
1117
1143
  */
1118
1144
  private sourceOf;
1145
+ /** The source as recorded (see sourceOf), whoever reads it. */
1146
+ private recordedSourceOf;
1119
1147
  /** Whether this Session already has a Trace record (a Task has been run): answered by the index (reconciled first). */
1120
1148
  hasTrace(row: SessionRow): Promise<boolean>;
1121
1149
  /**
@@ -1130,7 +1158,7 @@ declare class SessionService {
1130
1158
  * through the trace index once (hasTrace reconciles the Agent), so a subagent Session is
1131
1159
  * known for one even before any list has walked it.
1132
1160
  */
1133
- listingOf(row: SessionRow): Promise<SessionCategory | null>;
1161
+ listingOf(row: SessionRow, view?: ListingView): Promise<SessionCategory | null>;
1134
1162
  /**
1135
1163
  * List, sorted by createdAt descending — or, with `order: "activity"`, by lastActiveAt
1136
1164
  * descending (ties by sessionId, see {@link compareActivityDesc}). Every row is served
@@ -1187,6 +1215,9 @@ declare class SessionService {
1187
1215
  * stays `user`, and a row the organization caches name before the reconcile pass stamps it
1188
1216
  * reads as `user`. Without the flag every row is served, whichever client created it, but
1189
1217
  * for that rule.
1218
+ *
1219
+ * `view` is who reads the list (sourceSeenBy): every row is classified and served as that
1220
+ * reader sees it.
1190
1221
  */
1191
1222
  listSessions(projectId: string, agentId: string, opts?: {
1192
1223
  paging?: SessionListPaging;
@@ -1195,6 +1226,7 @@ declare class SessionService {
1195
1226
  workspaceGroup?: string;
1196
1227
  withCounts?: boolean;
1197
1228
  excludeOrg?: boolean;
1229
+ view?: ListingView;
1198
1230
  }): Promise<{
1199
1231
  sessions: SessionInfo[];
1200
1232
  counts?: SessionCategoryCounts;
@@ -1208,9 +1240,9 @@ declare class SessionService {
1208
1240
  * and `excludeOrg`, classified the same way — with the source each was classified by and
1209
1241
  * whether it has a Trace. It builds no SessionInfo: the page makes one (toInfo) only for the
1210
1242
  * rows a response carries, so a request costs a classification per archived row, not a full
1211
- * row view per archived row.
1243
+ * row view per archived row. `view` is who reads it, as for listSessions.
1212
1244
  */
1213
- archivedRows(projectId: string, agentId: string): Promise<ArchivedRow[]>;
1245
+ archivedRows(projectId: string, agentId: string, view?: ListingView): Promise<ArchivedRow[]>;
1214
1246
  /**
1215
1247
  * The rows a list walk starts from: the Agent's index rows, an organization's left out when
1216
1248
  * `excludeOrg` asks (see listSessions), with the Project's organization map; and when any row
@@ -1247,6 +1279,7 @@ declare class SessionService {
1247
1279
  /** The provider group for `modelId`; always paired with modelId, never inferred. */
1248
1280
  provider?: string;
1249
1281
  workspace?: string;
1282
+ thinkingLevel?: ThinkingLevelName;
1250
1283
  approvalMode?: ApprovalMode;
1251
1284
  /** The composer's sandbox picks; omitted halves take the server's settings. */
1252
1285
  sandbox?: Partial<SessionSandbox>;
@@ -1266,7 +1299,7 @@ declare class SessionService {
1266
1299
  * are the only callers that pass them, so no request can claim either provenance for
1267
1300
  * itself ("api" is what lets the Agent API continue a Session).
1268
1301
  */
1269
- client?: "web" | "cli" | "org" | "api";
1302
+ client?: "web" | "cli" | "org" | "api" | "workbench";
1270
1303
  }): Promise<SessionInfo>;
1271
1304
  /** A new Session's snapshot: the settings, with the creator's picks (checked) on top. */
1272
1305
  private snapshotSandbox;
@@ -1379,7 +1412,7 @@ declare class ModelScopeAuthService {
1379
1412
  private sweep;
1380
1413
  private evictOldest;
1381
1414
  }
1382
- declare const ModelScopeAuth_base: (abstract new () => Pick<ModelScopeAuthService, "status" | "start" | "retryApply" | "cancel" | "ensureFresh">) & (<C>(target: C, context: ClassDecoratorContext) => C);
1415
+ declare const ModelScopeAuth_base: (abstract new () => Pick<ModelScopeAuthService, "status" | "start" | "cancel" | "retryApply" | "ensureFresh">) & (<C>(target: C, context: ClassDecoratorContext) => C);
1383
1416
  /** The per-App ModelScope key authorization capability consumed by Project model routes. */
1384
1417
  declare abstract class ModelScopeAuth extends ModelScopeAuth_base {
1385
1418
  }
@@ -1392,10 +1425,10 @@ type RunOpts = {
1392
1425
  };
1393
1426
  interface RuntimeSession {
1394
1427
  readonly sessionId: string;
1395
- run(newMessages: OmniMessage[], opts: RunOpts): AsyncGenerator<OmniMessage>;
1428
+ run(newMessages: AmspRecord[], opts: RunOpts): AsyncGenerator<AmspRecord>;
1396
1429
  compact(opts: {
1397
1430
  signal: AbortSignal;
1398
- }): AsyncGenerator<OmniMessage>;
1431
+ }): AsyncGenerator<AmspRecord>;
1399
1432
  /**
1400
1433
  * The running context's model (core `Session.provider` / `Session.modelId`, getters over
1401
1434
  * the context's session_meta): the row's pair at creation, moved by each in-session switch
@@ -1416,7 +1449,7 @@ interface RuntimeSession {
1416
1449
  provider: string;
1417
1450
  modelId: string;
1418
1451
  signal: AbortSignal;
1419
- }): AsyncGenerator<OmniMessage, StopReason>;
1452
+ }): AsyncGenerator<AmspRecord, StopReason>;
1420
1453
  /**
1421
1454
  * The Session's thinking level (core `Session.thinkingLevel`, plain state): soft-limited —
1422
1455
  * an assignment applies from the Session's very next LLM request. Optional: test fakes may
@@ -1426,23 +1459,30 @@ interface RuntimeSession {
1426
1459
  /** Whether compaction is possible and why; when not ok, compact() yields no messages (see core ContextEngine.compactability). */
1427
1460
  compactability(): CompactAvailability;
1428
1461
  /** Queues a mid-run steering input (core `Session.steer`); false when no Task is running. */
1429
- steer(input: OmniMessage[]): boolean;
1462
+ steer(input: AmspRecord[]): boolean;
1430
1463
  /**
1431
1464
  * Withdraws a steering input queued via `steer` before core delivers it (core
1432
1465
  * `Session.unsteer`, matched by input-list identity); false when it is no longer queued —
1433
1466
  * already delivered, or the run exited. Optional: test fakes may omit it, in which case
1434
1467
  * every recall reports "already delivered".
1435
1468
  */
1436
- unsteer?(input: OmniMessage[]): boolean;
1469
+ unsteer?(input: AmspRecord[]): boolean;
1437
1470
  /** Skips the in-progress reconnect backoff, firing the next retry immediately (core `Session.skipReconnectWait`); false when no wait is in progress. */
1438
1471
  skipReconnectWait(): boolean;
1439
1472
  /**
1440
1473
  * Whether a run with empty input would send anything (core `Session.hasPendingInput`): the
1441
- * failed turn's input held as carry-over — in process, or rebuilt from the Trace after a
1442
- * restart — or a compaction summary waiting for the next run. Optional: test fakes may omit
1443
- * it, reading as nothing held.
1474
+ * input of a turn that failed or was stopped, held as carry-over — in process, or rebuilt
1475
+ * from the Trace after a restart — or a compaction summary waiting for the next run.
1476
+ * Optional: test fakes may omit it, reading as nothing held.
1444
1477
  */
1445
1478
  hasPendingInput?(): boolean;
1479
+ /**
1480
+ * Whether the next Task opens a new Trace file (core `Session.contextOpenPending`): a
1481
+ * compaction left the next context's file to its first write, so that Task streams the new
1482
+ * `session_meta` behind its `task_begin`, and the input echo waits for it (see InputEcho).
1483
+ * Optional: test fakes may omit it, reading as no.
1484
+ */
1485
+ contextOpenPending?(): boolean;
1446
1486
  /**
1447
1487
  * Runs the named package's `user_prompt` hook (core `Session.runUserPromptHook` — hooks
1448
1488
  * run in core and nowhere else); null = the package is not installed or names no such
@@ -1474,13 +1514,13 @@ interface RuntimeSession {
1474
1514
  */
1475
1515
  onBackgroundNotice?(listener: () => void): void;
1476
1516
  /** Takes the queued background completion notices as task input (core `Session.takeBackgroundNotices`). Optional, like onBackgroundNotice. */
1477
- takeBackgroundNotices?(): OmniMessage[];
1517
+ takeBackgroundNotices?(): AmspRecord[];
1478
1518
  /** Whether completion notices are still queued (core `Session.hasPendingBackgroundNotices`); pins the entry against idle eviction. Optional, like onBackgroundNotice. */
1479
1519
  hasPendingBackgroundNotices?(): boolean;
1480
1520
  /** Refreshes the listen-port probes behind the process list's `serviceUrl` (core `Session.probeBackgroundCommandServices`). Optional: test fakes may omit it. */
1481
1521
  probeBackgroundCommandServices?(): Promise<void>;
1482
1522
  /** Subscribes live-forwarded background-subagent messages (core `Session.onBackgroundMessage`); the manager publishes them to the session channel. Optional: test fakes may omit it. */
1483
- onBackgroundMessage?(listener: (msg: OmniMessage) => void): void;
1523
+ onBackgroundMessage?(listener: (msg: AmspRecord) => void): void;
1484
1524
  /** Background command processes owned by the Session's environment (core `Session.listBackgroundCommands`). Optional: test fakes may omit it. */
1485
1525
  listBackgroundCommands?(): BackgroundCommandInfo[];
1486
1526
  /** Kills one background command process (core `Session.killBackgroundCommand`); false when the id is unknown. Optional, like listBackgroundCommands. */
@@ -1492,7 +1532,7 @@ interface RuntimeSession {
1492
1532
  /** All live subagent child sessions of the Session's environment (core `Session.listBackgroundSubagents`). Optional, like listBackgroundCommands. */
1493
1533
  listBackgroundSubagents?(): BackgroundSubagentInfo[];
1494
1534
  /** Host message to one child session — steering mid-run, a follow-up run when idle, a revival when released (core `Session.sendToBackgroundSubagent`). Optional. */
1495
- sendToBackgroundSubagent?(childSessionId: string, messages: OmniMessage[], opts?: SubagentMessageOptions): Promise<SubagentMessageOutcome>;
1535
+ sendToBackgroundSubagent?(childSessionId: string, messages: AmspRecord[], opts?: SubagentMessageOptions): Promise<SubagentMessageOutcome>;
1496
1536
  /** Subscribes the host's session-lifetime fallback approval sink for child sessions (core `Session.setSubagentApprovalFallback`). Optional. */
1497
1537
  setSubagentApprovalFallback?(approve: ApproveFn): void;
1498
1538
  /** Aborts one child session's current run, keeping the session (core `Session.abortBackgroundSubagentRun`); false when unknown or idle. Optional. */
@@ -1510,13 +1550,13 @@ interface RuntimeSession {
1510
1550
  interface SessionLoader {
1511
1551
  /**
1512
1552
  * Load a runtime Session from an index row: recover (with a Trace) or self-heal
1513
- * rebuild (no Trace, session_id will change). Throws HttpError(409) for unrecoverable
1553
+ * rebuild (no Trace, under the row's session_id). Throws HttpError(409) for unrecoverable
1514
1554
  * cases such as a missing Workspace.
1515
1555
  */
1516
1556
  load(row: SessionRow): Promise<RuntimeSession>;
1517
1557
  }
1518
1558
  interface UsageRecorderLike {
1519
- record(ctx: UsageContext, msg: OmniMessage): Promise<void>;
1559
+ record(ctx: UsageContext, msg: AmspRecord): Promise<void>;
1520
1560
  }
1521
1561
  interface SessionManagerDeps {
1522
1562
  /** The in-memory state this manager works on (see agent-state.ts). Optional: a manager built without one — unit tests — gets an empty state of its own. */
@@ -1527,6 +1567,12 @@ interface SessionManagerDeps {
1527
1567
  /** Session-origin registry (session_meta is the single source of truth; subagent registration records the forwarded meta's source here). */
1528
1568
  sources: SessionOrigins;
1529
1569
  recorder: UsageRecorderLike;
1570
+ /**
1571
+ * The data root, for what is read off an Agent's state on disk before a Session is loaded
1572
+ * (startGoal's goal-plugin check). Optional: a manager built without one — unit tests on a
1573
+ * fake loader — skips those reads, and the loaded Session's own answer decides.
1574
+ */
1575
+ root?: string;
1530
1576
  /** Automatic Session title generation (optional: not injected in tests or when disabled). */
1531
1577
  titles?: TitleNotifier;
1532
1578
  /** Error persistence (optional: without it, only logs — same as before this was wired up). */
@@ -1573,7 +1619,7 @@ interface RecallStore {
1573
1619
  interface QueuedFollowUp {
1574
1620
  /** Recall handle (PendingFollowUpInfo.id), assigned at queue time. */
1575
1621
  id: string;
1576
- input: OmniMessage[];
1622
+ input: AmspRecord[];
1577
1623
  /**
1578
1624
  * Original content for recall, and the content `task_state` shows on the queued line.
1579
1625
  * Always present: a caller that knows more than the input carries (the HTTP route, which
@@ -1586,7 +1632,7 @@ interface QueuedFollowUp {
1586
1632
  /** One undelivered steering entry: the display info broadcast on task_state, plus what a recall needs — the exact input list core queued (its unsteer handle) and the original content. */
1587
1633
  interface PendingSteeringEntry {
1588
1634
  info: PendingSteeringInfo;
1589
- input: OmniMessage[];
1635
+ input: AmspRecord[];
1590
1636
  recall: RecallStore;
1591
1637
  }
1592
1638
  /** Active-table entry: a loaded runtime Session plus its running state. */
@@ -1628,7 +1674,7 @@ interface RuntimeEntry {
1628
1674
  * the input publish, so the live channel cannot backfill it either. GET /messages
1629
1675
  * appends the ones the Trace has not caught up to yet (exact-envelope dedup).
1630
1676
  */
1631
- pendingInputs: OmniMessage[];
1677
+ pendingInputs: AmspRecord[];
1632
1678
  /**
1633
1679
  * The running Task's streamed bootstrap records (mcp_connect begin/end,
1634
1680
  * tool_list_ready), held until the run ends. Their Trace writes are deferred by the
@@ -1637,7 +1683,7 @@ interface RuntimeEntry {
1637
1683
  * otherwise show nothing at all (a silent blank while a slow server times out).
1638
1684
  * GET /messages appends whichever of them the Trace has not caught up to.
1639
1685
  */
1640
- pendingBootstrap: OmniMessage[];
1686
+ pendingBootstrap: AmspRecord[];
1641
1687
  /**
1642
1688
  * Steering messages queued on core but not yet delivered to the model — a display mirror
1643
1689
  * of core's steering queue (same FIFO order), so the composer's "steering queued" hint and
@@ -1733,7 +1779,7 @@ declare class SessionManager {
1733
1779
  * the resume fallback names the child's owning Agent from its own session row, which must
1734
1780
  * belong to the parent's project.
1735
1781
  */
1736
- sendToSubagent(sessionId: string, childSessionId: string, messages: OmniMessage[]): Promise<SubagentMessageOutcome>;
1782
+ sendToSubagent(sessionId: string, childSessionId: string, messages: AmspRecord[]): Promise<SubagentMessageOutcome>;
1737
1783
  /**
1738
1784
  * Sets a Session's thinking level on its loaded runtime (core `Session.thinkingLevel`,
1739
1785
  * plain state): the row's value is what the loader applies at load, so this only needs to
@@ -1749,12 +1795,12 @@ declare class SessionManager {
1749
1795
  /** Queued follow-up tasks awaiting auto-start, as their display/recall info (id + content summary). */
1750
1796
  pendingFollowUpsOf(sessionId: string): PendingFollowUpInfo[];
1751
1797
  /**
1752
- * Live tail of a running session: one synthetic `partial_* start` OmniMessage per open
1798
+ * Live tail of a running session: one synthetic `partial_* start` AmspRecord per open
1753
1799
  * streaming fragment, carrying the full accumulated content so far (see live-tail.ts).
1754
1800
  * Empty when idle or when nothing is streaming. GET /messages attaches this (with a
1755
1801
  * channel cursor) so a client joining mid-stream can render the in-progress message.
1756
1802
  */
1757
- liveFragments(sessionId: string): OmniMessage[];
1803
+ liveFragments(sessionId: string): AmspRecord[];
1758
1804
  /**
1759
1805
  * The running Task's input messages as published at launch; empty when idle. The engine
1760
1806
  * writes these exact envelopes to the Trace only after the first run's bootstrap (MCP
@@ -1762,9 +1808,9 @@ declare class SessionManager {
1762
1808
  * not caught up to yet — without this, a client rebuilding history during the connect
1763
1809
  * (the draft flow subscribes only after the input publish) loses the user's own message.
1764
1810
  */
1765
- pendingInputs(sessionId: string): OmniMessage[];
1811
+ pendingInputs(sessionId: string): AmspRecord[];
1766
1812
  /** The running Task's streamed bootstrap records (see RuntimeEntry.pendingBootstrap); empty when idle. */
1767
- pendingBootstrap(sessionId: string): OmniMessage[];
1813
+ pendingBootstrap(sessionId: string): AmspRecord[];
1768
1814
  /** Number of Sessions for this Agent that are currently running / compacting. */
1769
1815
  activeCountForAgent(projectId: string, agentId: string): number;
1770
1816
  /** Add a newly created Session to the active table (status idle), avoiding a redundant load on the next Task. */
@@ -1852,7 +1898,7 @@ declare class SessionManager {
1852
1898
  * caller's store is read off the input, so a queued follow-up is recallable and shows
1853
1899
  * its content whichever path queued it.
1854
1900
  */
1855
- startTask(sessionId: string, input: OmniMessage[], opts?: {
1901
+ startTask(sessionId: string, input: AmspRecord[], opts?: {
1856
1902
  queueIfBusy?: boolean;
1857
1903
  recall?: RecallStore;
1858
1904
  }): Promise<{
@@ -1860,13 +1906,14 @@ declare class SessionManager {
1860
1906
  queued: boolean;
1861
1907
  }>;
1862
1908
  /**
1863
- * Retry a failed run (`POST /retry`): a Task started with EMPTY input, so core sends the
1864
- * input of the turn that failed — held as carry-over since the run ended `fatal` or gave
1865
- * up reconnecting — and nothing else. No user message is published or recorded, and with no
1909
+ * Retry a failed or stopped run (`POST /retry`): a Task started with EMPTY input, so core
1910
+ * sends the input of the turn that did not finish — held as carry-over since the run ended
1911
+ * `fatal`, gave up reconnecting or was stopped by the user, with whatever the model had
1912
+ * already written — and nothing else. No user message is published or recorded, and with no
1866
1913
  * Prompt there is no user_prompt consult. Gated like startTask (busy is the same 409) but
1867
1914
  * never queued, and refused with 409 `nothing_to_retry` when nothing is held — the user's
1868
- * next message already resent that input, or no run failed — since the run would end at
1869
- * once and the client would watch a Task start and stop with nothing sent. Not a person's
1915
+ * next message already resent that input, or no run was cut short — since the run would end
1916
+ * at once and the client would watch a Task start and stop with nothing sent. Not a person's
1870
1917
  * input for company mode's hop accounting: the turn it resends was counted, or not, when
1871
1918
  * it was first sent.
1872
1919
  */
@@ -1881,13 +1928,15 @@ declare class SessionManager {
1881
1928
  * `user_prompt` hook (hooks run in core and nowhere else — `Session.runUserPromptHook`)
1882
1929
  * writes the Session's goal file and answers the round-1 protocol message; it runs under
1883
1930
  * the session lock AFTER the idle check, since it overwrites the goal file a running goal
1884
- * is reading. Not installed (null) is the route's 409; an empty answer a 500. Round inputs
1931
+ * is reading. An Agent without the goal plugin's hook package is refused with the route's
1932
+ * 409 before the Session is even loaded (goal-plugin.ts); a loaded Session whose hook
1933
+ * answers null is the same 409, and an empty answer a 500. Round inputs
1885
1934
  * are yielded by core and published like any streamed message; progress additionally goes
1886
1935
  * out as goal_* server events (the run state itself is the goal file the plugin maintains).
1887
1936
  */
1888
1937
  startGoal(sessionId: string, args: {
1889
1938
  /** The user's own message(s) exactly as submitted — text and images, no wrapping. */
1890
- messages: OmniMessage[];
1939
+ messages: AmspRecord[];
1891
1940
  /** The user's own objective text (leading marker blocks stripped): what the plugin records, the goal_started event and the title material. */
1892
1941
  objective: string;
1893
1942
  budget: number;
@@ -1897,7 +1946,7 @@ declare class SessionManager {
1897
1946
  /**
1898
1947
  * Taps a goal run's stream for `drive`: round boundaries become goal_round events —
1899
1948
  * round 1 from the seeded input (core never yields a run's initial input, so it is
1900
- * counted here, where startGoal published it), later rounds from the stop-hook continues
1949
+ * counted here, from what startGoal echoes), later rounds from the stop-hook continues
1901
1950
  * core yields, each announced by the hook's `continue` event; a harness-stamped input
1902
1951
  * nothing announced is another package's user_prompt context riding behind the
1903
1952
  * objective, not a round — and the goal hook's `stop` event becomes the
@@ -1910,9 +1959,9 @@ declare class SessionManager {
1910
1959
  /** Closes a goal as aborted for the UI (stream cut off / infrastructure failure). */
1911
1960
  private finishAborted;
1912
1961
  /**
1913
- * Shared task launch (fresh tasks, auto-started follow-ups and retries): flips to running,
1914
- * publishes the input, and drives the run. Caller holds the session lock and has verified
1915
- * idle. A retry's input is empty: nothing is published or held, and drive gets no title
1962
+ * Shared task launch (fresh tasks, auto-started follow-ups and retries): flips to running
1963
+ * and drives the run, which echoes the input. Caller holds the session lock and has verified
1964
+ * idle. A retry's input is empty: nothing is echoed or held, and drive gets no title
1916
1965
  * material — the turn it resends already offered its text when it was first sent.
1917
1966
  */
1918
1967
  private launchTask;
@@ -1992,7 +2041,7 @@ declare class SessionManager {
1992
2041
  * keeps the composer's "steering queued" hint, content included, alive across reloads —
1993
2042
  * and the content itself is what a recall (recallSteering) hands back to the composer.
1994
2043
  */
1995
- steer(sessionId: string, input: OmniMessage[], recall: RecallStore): void;
2044
+ steer(sessionId: string, input: AmspRecord[], recall: RecallStore): void;
1996
2045
  /**
1997
2046
  * Recall an undelivered steering message (#287): withdraw it from core's queue and the
1998
2047
  * display mirror, re-broadcast state, and hand back its original content for the composer
@@ -2148,12 +2197,10 @@ declare class SessionManager {
2148
2197
  * a Task arriving mid-load waits for this load instead of starting a second one.
2149
2198
  *
2150
2199
  * A Session that is gone or being deleted, alone or with its Agent, resolves quietly: there is
2151
- * nothing to warm and the caller has nothing to do about it. So does one with no Trace yet,
2152
- * because loading it is a self-heal REBUILD under a new session id — that would move the
2153
- * Session out from under the binding that asked, and earlier than any Task would. The row's
2154
- * `hasTrace` is a cache, so a row that has not caught up only misses the warm-up. Any other
2155
- * load failure rejects; the first Task meets the same failure and reports it where a person
2156
- * will see it.
2200
+ * nothing to warm and the caller has nothing to do about it. One that never ran is rebuilt
2201
+ * under its own id (see createCoreSessionLoader), so the binding that asked keeps its Session.
2202
+ * Any other load failure rejects; the first Task meets the same failure and reports it where a
2203
+ * person will see it.
2157
2204
  */
2158
2205
  preload(sessionId: string): Promise<void>;
2159
2206
  private assertOpen;
@@ -2164,7 +2211,9 @@ declare class SessionManager {
2164
2211
  private assertIdle;
2165
2212
  private generationOf;
2166
2213
  private refreshProviderCredentialIfNeeded;
2167
- /** get-or-resume-or-heal: use directly on an active-table hit; otherwise load via the loader, updating the index's primary key on self-heal. */
2214
+ /** get-or-resume-or-heal: use directly on an active-table hit; otherwise load via the loader, updating the index's primary key when it answers another id. */
2215
+ /** startGoal's check before the load (goal-plugin.ts); an unknown id is left to ensureEntry's 404. */
2216
+ private assertGoalPluginInstalled;
2168
2217
  private ensureEntry;
2169
2218
  /**
2170
2219
  * Auto-start of queued background completion notices: called when core signals an
@@ -2178,7 +2227,8 @@ declare class SessionManager {
2178
2227
  * Drive the output stream in the background: publish each message + persist usage +
2179
2228
  * persist LLM/tool errors; on completion (including errors) resets to idle and pushes
2180
2229
  * the status. `titleSource` is passed only for Task runs (compaction doesn't generate
2181
- * a title): its user text drives automatic title generation at run start.
2230
+ * a title): its user text drives automatic title generation at run start, and its `echo`
2231
+ * is the run's input, published right behind the run's first `task_begin` (see InputEcho).
2182
2232
  */
2183
2233
  private drive;
2184
2234
  /**
@@ -2353,8 +2403,10 @@ interface AgentListItem {
2353
2403
  kernelOutdated: boolean;
2354
2404
  /** Number of vault keys. */
2355
2405
  vaultKeyCount: number;
2356
- /** Number of scheduled tasks (count of .toml files under schedule/, including invalid ones). */
2406
+ /** Number of scheduled tasks (count of .toml files directly under schedule/, including invalid ones; archived files under schedule/expired/ are not counted). */
2357
2407
  scheduleCount: number;
2408
+ /** Workbench folders with a manifest, including ones with a load error. */
2409
+ workbenchCount: number;
2358
2410
  /** Number of installed Skills (count of skills/<name>/ directories that contain a SKILL.md). */
2359
2411
  skillCount: number;
2360
2412
  /** Number of installed hook packages (hooks/<name>/ directories with a hooks.json). */
@@ -2372,6 +2424,8 @@ declare class AgentService implements AgentLifecycle {
2372
2424
  private readonly snapshots;
2373
2425
  /** Union of DB index ∪ directory scan; unmanaged directory Agents are backfilled into the DB. */
2374
2426
  listAgents(projectId: string): Promise<AgentListItem[]>;
2427
+ /** Count installed folders without compiling or walking their UI/runtime assets. */
2428
+ private workbenchCount;
2375
2429
  /**
2376
2430
  * Every id `createAgent` refuses as taken, as names only: the index rows and every entry under
2377
2431
  * `agents/`. Unlike `listAgents`, this includes a folder with no `system_config.yaml`, and it
@@ -2380,7 +2434,7 @@ declare class AgentService implements AgentLifecycle {
2380
2434
  takenAgentIds(projectId: string): Promise<string[]>;
2381
2435
  /** Number of vault keys (falls back to 0 on read failure). */
2382
2436
  private vaultKeyCount;
2383
- /** Number of scheduled tasks: count of .toml files under schedule/ (0 if the directory doesn't exist). */
2437
+ /** Number of scheduled tasks: count of .toml files directly under schedule/ (0 if the directory doesn't exist). The expired/ subdirectory of archived files is not a .toml name, so it is never counted. */
2384
2438
  private scheduleCount;
2385
2439
  /**
2386
2440
  * One pass over `skills/` and one over `hooks/`, answering the card's questions: how many
@@ -2836,7 +2890,7 @@ type AppEnv = {
2836
2890
  /** Minimal dependency on SessionManager (eases test doubles; mirrors ScheduleTaskRunner). */
2837
2891
  interface MessagingTaskRunnerShape {
2838
2892
  statusOf(sessionId: string): string;
2839
- startTask(sessionId: string, input: OmniMessage[],
2893
+ startTask(sessionId: string, input: AmspRecord[],
2840
2894
  /**
2841
2895
  * `recall` is what a queued follow-up hands back when the user withdraws it in the Web
2842
2896
  * App. It is optional because the manager derives one from the input for every caller
@@ -3314,19 +3368,28 @@ interface PluginConfigSlots {
3314
3368
  groups: Slot<SettingsGroupDecl>;
3315
3369
  }
3316
3370
 
3317
- /** The assembled business surface: one request in, one response (or a decline) out. */
3371
+ /**
3372
+ * The assembled business surface: one request in, one response (or a decline) out.
3373
+ *
3374
+ * `fetchAs` is the same surface entered as a user already established by other means — the
3375
+ * API socket (socket/serve.ts), whose handshake the runtime authenticated and whose owner it
3376
+ * checked before the platform ever saw the socket. Those requests carry no cookie, so the
3377
+ * gate in front of the routes is not the cookie one but "this user": the routes themselves,
3378
+ * their authorization and their errors are identical.
3379
+ */
3318
3380
  declare abstract class Http {
3319
3381
  abstract fetch(request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
3382
+ abstract fetchAs(userId: string, request: Opaque<"Request", Request>): Promise<Opaque<"Response", Response>>;
3320
3383
  }
3321
3384
  interface HttpSlots {
3322
3385
  /**
3323
- * A route group. `auth: "user"` mounts it behind the cookie gate, `"none"` in front of
3324
- * it; `order` is the mount position (a stable number, since Hono matches in order). The
3325
- * code half is the group's Hono app.
3386
+ * A route group. `auth: "user"` accepts a cookie or the local API token; `"token"` accepts
3387
+ * only the local API token, without renewing cookies; `"none"` is public. `order` is the
3388
+ * mount position (a stable number, since Hono matches in order). The code half is the Hono app.
3326
3389
  */
3327
3390
  routes: Slot<{
3328
3391
  prefix: string;
3329
- auth: "user" | "none";
3392
+ auth: "user" | "token" | "none";
3330
3393
  order: number;
3331
3394
  }, Opaque<"Hono", Hono<AppEnv>>>;
3332
3395
  }
@@ -3364,7 +3427,7 @@ interface WebShellSlots {
3364
3427
  renderer: RendererRef;
3365
3428
  };
3366
3429
  /**
3367
- * A tab beside a Session's chat. A workflow contributes here too, from its own tree, where
3430
+ * A tab beside a Session's chat. A workbench contributes here too, from its own tree, where
3368
3431
  * the host publishes this slot under this module's name and scopes the tab to its Agent.
3369
3432
  */
3370
3433
  sessionTabs: {