@songsid/agend 2.2.0-beta.5 → 2.2.0-beta.7

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 (127) hide show
  1. package/dist/agent-cli-instructions.md +6 -2
  2. package/dist/agent-cli.js +9 -5
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/backend/claude-carry.d.ts +22 -0
  5. package/dist/backend/claude-carry.js +170 -0
  6. package/dist/backend/claude-carry.js.map +1 -0
  7. package/dist/backend/claude-code.d.ts +16 -0
  8. package/dist/backend/claude-code.js +92 -2
  9. package/dist/backend/claude-code.js.map +1 -1
  10. package/dist/backend/credential-profile.d.ts +7 -0
  11. package/dist/backend/credential-profile.js +7 -1
  12. package/dist/backend/credential-profile.js.map +1 -1
  13. package/dist/backend/kiro.js +5 -2
  14. package/dist/backend/kiro.js.map +1 -1
  15. package/dist/backend/muse.d.ts +67 -0
  16. package/dist/backend/muse.js +370 -44
  17. package/dist/backend/muse.js.map +1 -1
  18. package/dist/backend/types.d.ts +7 -0
  19. package/dist/backend/types.js.map +1 -1
  20. package/dist/background-work-ended.d.ts +18 -0
  21. package/dist/background-work-ended.js +30 -0
  22. package/dist/background-work-ended.js.map +1 -0
  23. package/dist/channel/adapters/discord.js +12 -1
  24. package/dist/channel/adapters/discord.js.map +1 -1
  25. package/dist/channel/adapters/telegram.d.ts +4 -5
  26. package/dist/channel/adapters/telegram.js +39 -17
  27. package/dist/channel/adapters/telegram.js.map +1 -1
  28. package/dist/channel/mcp-tools.js +3 -3
  29. package/dist/channel/mcp-tools.js.map +1 -1
  30. package/dist/channel/message-edit-errors.d.ts +5 -0
  31. package/dist/channel/message-edit-errors.js +24 -0
  32. package/dist/channel/message-edit-errors.js.map +1 -0
  33. package/dist/channel/types.d.ts +3 -0
  34. package/dist/cli.js +25 -10
  35. package/dist/cli.js.map +1 -1
  36. package/dist/cross-instance-envelope.js +2 -0
  37. package/dist/cross-instance-envelope.js.map +1 -1
  38. package/dist/daemon.d.ts +6 -0
  39. package/dist/daemon.js +165 -54
  40. package/dist/daemon.js.map +1 -1
  41. package/dist/delivery-outbox.d.ts +27 -0
  42. package/dist/delivery-outbox.js +175 -6
  43. package/dist/delivery-outbox.js.map +1 -1
  44. package/dist/fleet-context.d.ts +4 -1
  45. package/dist/fleet-manager.d.ts +110 -6
  46. package/dist/fleet-manager.js +558 -100
  47. package/dist/fleet-manager.js.map +1 -1
  48. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +44 -9
  49. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +14 -1
  50. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +4 -0
  51. package/dist/human-delivery-receipts.d.ts +83 -0
  52. package/dist/human-delivery-receipts.js +194 -0
  53. package/dist/human-delivery-receipts.js.map +1 -0
  54. package/dist/instructions.d.ts +1 -1
  55. package/dist/instructions.js +1 -1
  56. package/dist/instructions.js.map +1 -1
  57. package/dist/locale.js +22 -2
  58. package/dist/locale.js.map +1 -1
  59. package/dist/needs-you-hub.js +2 -0
  60. package/dist/needs-you-hub.js.map +1 -1
  61. package/dist/needs-you-live.d.ts +6 -0
  62. package/dist/needs-you-live.js +23 -3
  63. package/dist/needs-you-live.js.map +1 -1
  64. package/dist/outbound-handlers.d.ts +10 -0
  65. package/dist/outbound-handlers.js +39 -14
  66. package/dist/outbound-handlers.js.map +1 -1
  67. package/dist/outbound-schemas.d.ts +15 -13
  68. package/dist/outbound-schemas.js +5 -0
  69. package/dist/outbound-schemas.js.map +1 -1
  70. package/dist/public-link-progress.d.ts +1 -1
  71. package/dist/public-link-progress.js +8 -2
  72. package/dist/public-link-progress.js.map +1 -1
  73. package/dist/public-preview.d.ts +2 -1
  74. package/dist/public-preview.js +8 -5
  75. package/dist/public-preview.js.map +1 -1
  76. package/dist/public-web-link.d.ts +4 -1
  77. package/dist/public-web-link.js +27 -10
  78. package/dist/public-web-link.js.map +1 -1
  79. package/dist/reply-buttons-controller.d.ts +3 -0
  80. package/dist/reply-buttons-controller.js +3 -2
  81. package/dist/reply-buttons-controller.js.map +1 -1
  82. package/dist/restart-progress.d.ts +4 -0
  83. package/dist/restart-progress.js +7 -0
  84. package/dist/restart-progress.js.map +1 -1
  85. package/dist/service-installer.d.ts +31 -0
  86. package/dist/service-installer.js +41 -2
  87. package/dist/service-installer.js.map +1 -1
  88. package/dist/topic-commands.d.ts +3 -2
  89. package/dist/topic-commands.js +17 -5
  90. package/dist/topic-commands.js.map +1 -1
  91. package/dist/tunnel/cloudflared.d.ts +7 -15
  92. package/dist/tunnel/cloudflared.js +36 -1
  93. package/dist/tunnel/cloudflared.js.map +1 -1
  94. package/dist/tunnel/types.d.ts +5 -1
  95. package/dist/tunnel/types.js.map +1 -1
  96. package/dist/ui/chat-strings.js +8 -2
  97. package/dist/ui/chat-thread.js +24 -4
  98. package/dist/ui/chat-time.js +80 -0
  99. package/dist/ui/preview-panel.js +7 -1
  100. package/dist/ui/preview.js +5 -1
  101. package/dist/ui/shared/app-stream.js +21 -4
  102. package/dist/ui/shared/app.css +9 -3
  103. package/dist/ui/shared/usage-dialog.js +10 -1
  104. package/dist/update-install.d.ts +6 -2
  105. package/dist/update-install.js +8 -2
  106. package/dist/update-install.js.map +1 -1
  107. package/dist/update-marker.d.ts +11 -0
  108. package/dist/update-marker.js +12 -0
  109. package/dist/update-marker.js.map +1 -1
  110. package/dist/web-api.d.ts +5 -1
  111. package/dist/web-api.js +8 -1
  112. package/dist/web-api.js.map +1 -1
  113. package/dist/web-commands.d.ts +2 -2
  114. package/dist/web-commands.js +3 -2
  115. package/dist/web-commands.js.map +1 -1
  116. package/dist/web-reply-files.d.ts +45 -0
  117. package/dist/web-reply-files.js +223 -0
  118. package/dist/web-reply-files.js.map +1 -0
  119. package/dist/web-server-drain.d.ts +10 -0
  120. package/dist/web-server-drain.js +50 -0
  121. package/dist/web-server-drain.js.map +1 -0
  122. package/dist/web-upload.d.ts +17 -4
  123. package/dist/web-upload.js +64 -13
  124. package/dist/web-upload.js.map +1 -1
  125. package/package.json +1 -1
  126. package/templates/launchd.plist.ejs +3 -1
  127. package/templates/systemd.service.ejs +2 -1
@@ -1,3 +1,4 @@
1
+ import { type HumanOrigin } from "./human-delivery-receipts.js";
1
2
  import { SettingsExecution } from "./settings-transaction.js";
2
3
  import type { LoginCodeOwner } from "./web-login.js";
3
4
  import { type ProfileTicket } from "./runtime-cpu-profile.js";
@@ -63,6 +64,7 @@ import { type AgentEndpointContext } from "./agent-endpoint.js";
63
64
  import { ClassicChannelManager } from "./classic-channel-manager.js";
64
65
  import { type ExplicitInstanceRemoval } from "./instance-removal.js";
65
66
  import type { InstanceState, InteractionSnapshot } from "./backend/types.js";
67
+ import { type Daemon } from "./daemon.js";
66
68
  import { WakeCoordinator } from "./wake-coordinator.js";
67
69
  import { TargetQueueWorker } from "./target-queue-worker.js";
68
70
  import { resolveDeliveryWorkerMode } from "./types.js";
@@ -75,6 +77,7 @@ import { type PreviewAvailability } from "./web-preview.js";
75
77
  import { type ConnectionMetadata, type ConnectionBinding, type BindingProbe, type SecretApplyJob, type ProviderSecretApplyJob } from "./connection-secrets.js";
76
78
  import { type ProviderSecretStatus } from "./provider-secret-registry.js";
77
79
  import { ApplyJobStore, type ApplyJob, type ApplyTargetKind, type SelfRestartResult } from "./apply-job.js";
80
+ import { type CarryResult } from "./backend/claude-carry.js";
78
81
  import { StormWindow } from "./storm-window.js";
79
82
  import { SpawnGate } from "./spawn-gate.js";
80
83
  import { BackendOutageTracker } from "./backend-outage.js";
@@ -102,6 +105,17 @@ export declare function selectLruEvictions(warm: string[], cap: number, opts: {
102
105
  * must match here, or a deleted instance's CLI is left running (#1305 P2-3).
103
106
  */
104
107
  export declare function isOrphanInstanceWindowName(name: string): boolean;
108
+ /** restartSingleInstance's options. `carry` (#1753): a credential-profile switch; its outcome is written into `result`. */
109
+ export interface RestartOpts {
110
+ freshStart?: boolean;
111
+ explicit?: boolean;
112
+ carry?: {
113
+ backend: string;
114
+ from: string | null;
115
+ to: string | null;
116
+ result?: CarryResult | null;
117
+ };
118
+ }
105
119
  /**
106
120
  * Answer shape for `list_models`. `scope` reports where the LIST came from —
107
121
  * "instance" only when it was read through that instance's own backend config,
@@ -206,7 +220,7 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
206
220
  private replyObligationTimer;
207
221
  private readonly activeDurableTargets;
208
222
  /** Live view of lifecycle.daemons — used throughout; not deprecated. */
209
- get daemons(): Map<string, import("./daemon.js").Daemon>;
223
+ get daemons(): Map<string, Daemon>;
210
224
  fleetConfig: FleetConfig | null;
211
225
  private rawFleetConfig;
212
226
  private rawFleetDocument;
@@ -305,6 +319,11 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
305
319
  private webChannelEchoGuards;
306
320
  /** instanceName → restart currently executing; concurrent callers join it. */
307
321
  private restartsInFlight;
322
+ /**
323
+ * #1753: each in-flight restart's stop → start gap — the conversation carry it will run there (its own, or one a later
324
+ * caller joined with before the gap), and whether the gap has been reached.
325
+ */
326
+ private readonly restartGaps;
308
327
  /**
309
328
  * Delayed automatic retries for instances whose startup failed. Before this a
310
329
  * failed start was logged once and the instance stayed `stopped` until an
@@ -403,6 +422,7 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
403
422
  private connectionBindingInFlight;
404
423
  private collabInstances;
405
424
  private healthServer;
425
+ private healthServerDrain;
406
426
  /** #1306: the preview listener (health_port + 1 by default), and whether it is listening. */
407
427
  private previewListener;
408
428
  private previewListening;
@@ -452,6 +472,10 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
452
472
  private webChatStore;
453
473
  /** Uploaded files and the files the dashboard may fetch back (uploads, reply attachments). */
454
474
  readonly webFiles: WebFileLedger;
475
+ /** #1770: per instance, its last web reply still copying its files — the next one is shown after it, in order. */
476
+ private readonly webReplyOrder;
477
+ /** #1770: an instance's web-files byte cap (a field, so a test can make it small). */
478
+ private webReplyMaxBytes;
455
479
  /** #1682: the people seen on inbound messages (id → name), for the web chat's mention pills; bounded, in memory. */
456
480
  readonly seenUsers: SeenUsers;
457
481
  private webPrefsStore?;
@@ -537,10 +561,13 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
537
561
  kind: string;
538
562
  correlationId: string;
539
563
  payload: Record<string, unknown>;
564
+ forwards?: readonly string[];
565
+ requestedKind?: string;
540
566
  }): {
541
567
  deliveryId: string;
542
568
  state: string;
543
569
  duplicate: boolean;
570
+ kind: string;
544
571
  };
545
572
  queryDurableDeliveryStatus(callerInstance: string, selector: DeliveryStatusSelector): DeliveryStatusPage;
546
573
  /** #1641: why a target is not taking queued work right now, or null when nothing known holds it. */
@@ -610,6 +637,18 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
610
637
  */
611
638
  isPlannedRestart(): boolean;
612
639
  private finishStartup;
640
+ /**
641
+ * We are the post-update fleet: the update is over by definition. Clearing it here (rather than in the update
642
+ * command, which exits before the new fleet is up) is what keeps the quiet window from outliving the restart.
643
+ * #1660 exception: an update still owing its retire outcome keeps its receipt until the cleanup watch resolves it —
644
+ * deleting it here is what lost the warning. Terminal stages are still cleared unconditionally.
645
+ * #1735: and while the watch is armed it owns the marker — even if the outcome landed after the completion posted
646
+ * (a launchd kickstart or a detached restart returns at once, so it can land at any point of the boot): the watch
647
+ * appends it, then clears.
648
+ * #1737 review: and only the marker this boot adopted. One written since — a `/restart full` or a new `/update`
649
+ * landing while this boot's completion was still being edited — belongs to its writer and is left alone.
650
+ */
651
+ private clearSettledUpdateMarker;
613
652
  lastActivityMs(name: string): number;
614
653
  /** Capture the current daemon and delivery owner for a background context read. */
615
654
  getPaneContextSource(name: string): import("./pane-context-cache.js").PaneContextSource | null;
@@ -872,6 +911,17 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
872
911
  hasPendingIdleGatedDelivery(instanceName: string): boolean;
873
912
  /** The running launch's own steer capability (#1405); undefined for a backend without one, or no running Daemon. */
874
913
  instanceLaunchSupportsSteer(instanceName: string): boolean | undefined;
914
+ private humanReceiptDaemons;
915
+ /** Cached FM + lifecycle + Daemon + tmux owner; unknown ownership grants nothing. */
916
+ private humanReceiptOwner;
917
+ private listenForHumanReceipt;
918
+ /** Evidence-only admission. Bots/system/agent payloads have no trusted origin. */
919
+ private humanReceiptPayload;
920
+ /** Bind at the actual IPC send, after all wake/reconnect waits. No human retry lane. */
921
+ private bindHumanReceiptPayload;
922
+ deliverHumanToInstance(instanceName: string, payload: Record<string, unknown>, origin: HumanOrigin | undefined, originalBody: string, options?: DeliveryOptions): Promise<boolean | void>;
923
+ /** Synchronous steer/btw handoff, using the same evidence and owner binding. */
924
+ sendHumanControl(instanceName: string, payload: Record<string, unknown>, origin: HumanOrigin | undefined, originalBody: string): boolean;
875
925
  /** Single delivery facade: wake paused CLIs and serialize non-user work behind idle. */
876
926
  deliverToInstance(instanceName: string, payload: Record<string, unknown>, options?: DeliveryOptions): Promise<boolean | void>;
877
927
  /**
@@ -1105,12 +1155,11 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1105
1155
  /** Last-resort completion after RestartProgress could not deliver to its
1106
1156
  * adopted target. It stays bounded and never wakes a not-ready gateway. */
1107
1157
  private sendFleetStartCompletionFallback;
1108
- stopInstance(name: string, transition?: TransitionHandle): Promise<void>;
1158
+ stopInstance(name: string, transition?: TransitionHandle): Promise<{
1159
+ backgroundWorkEnded: boolean;
1160
+ }>;
1109
1161
  /** Restart a single instance, reloading fleet.yaml first to pick up config changes. */
1110
- restartSingleInstance(name: string, opts?: {
1111
- freshStart?: boolean;
1112
- explicit?: boolean;
1113
- }): Promise<void>;
1162
+ restartSingleInstance(name: string, opts?: RestartOpts): Promise<void>;
1114
1163
  isInstanceRestarting(name: string): boolean;
1115
1164
  /** InstanceLifecycleContext: an explicit wake joins the restart in flight. */
1116
1165
  restartInFlight(name: string): Promise<void> | undefined;
@@ -1131,6 +1180,12 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1131
1180
  * One-shot: the daemon deletes it on startup.
1132
1181
  */
1133
1182
  private writeFreshStartMarker;
1183
+ /**
1184
+ * #1753: a credential-profile switch, between the old CLI's stop and the new one's start. Where the backend can take
1185
+ * the conversation along (claude-code), copy it into the new profile and make it the one `--continue` picks; when that
1186
+ * cannot be done, or the backend cannot, start fresh as before. Null when nothing was tried.
1187
+ */
1188
+ private switchConversation;
1134
1189
  /** Load .env file from data dir into process.env */
1135
1190
  private loadEnvFile;
1136
1191
  /** Initialize auth before any adapter can answer /dashboard. */
@@ -1154,6 +1209,23 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1154
1209
  private publicOwnerCurrent;
1155
1210
  /** Exact owning General. No primary-adapter or name fallback participates in authorization. */
1156
1211
  private dashboardOwner;
1212
+ /**
1213
+ * #1742: the General a fleet admin's DM speaks for (`/start web`): the same owner `/web` in that General would make
1214
+ * — this bot's configured group and its one General topic. No address to match in a DM, so it must be unambiguous:
1215
+ * no General, or more than one on this bot and group, and there is no owner (nothing is guessed).
1216
+ */
1217
+ private dmDashboardOwner;
1218
+ /**
1219
+ * #1742: a fleet admin whose Telegram `/web` could not reach them privately may next open the bot's DM and press
1220
+ * Telegram's START, which sends a bare `/start` — read as `/start web` (the DM menu) for 10 minutes, once, for that
1221
+ * admin on that bot. Monotonic: a wall-clock jump neither opens nor shuts it.
1222
+ */
1223
+ private readonly tgWebStartWindows;
1224
+ private openTgWebStartWindow;
1225
+ /** Uses the window up: true when it was open. */
1226
+ private takeTgWebStartWindow;
1227
+ /** #1742: `/start web` from a fleet admin: the /web menu right here in the DM, for the General this bot serves. */
1228
+ private startWebInDm;
1157
1229
  private getPublicWebLink;
1158
1230
  getPublicWebStatus(): {
1159
1231
  state: string;
@@ -1191,6 +1263,10 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1191
1263
  /** Why the DM did not go, for the log only (Discord 50007 = the user does not accept DMs from this server's members). */
1192
1264
  private logDashboardDmFailure;
1193
1265
  /** False when the menu was not shown (the caller still owes the user an answer). */
1266
+ /**
1267
+ * `dmChatId` (#1742): show it in the owner's own private chat with the bot instead of the General — the owner, its
1268
+ * gates and the code's route are the same; only where the menu sits (and its clicks are good) changes.
1269
+ */
1194
1270
  private showDashboardMenu;
1195
1271
  private handleDashboardCallback;
1196
1272
  /** `/dashboard revoke`: sign out every browser and withdraw any unused code. */
@@ -1249,6 +1325,22 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1249
1325
  * starts this timer on that path (Prism a) — without this, the owed
1250
1326
  * outcome would sit in the marker unwatched. READY never waits for it.
1251
1327
  */
1328
+ /**
1329
+ * #1735: what the completion of an adopted update does about its retire outcome, read from the marker as it is now.
1330
+ * Already landed with a warning (a detached restart returns before this fleet boots, so the updater retires first)
1331
+ * → render it in the completion. Still owed (`cleanup: "pending"` — a service restart waits for READY, which comes
1332
+ * after the completion) → watch for it. Anything else (no retire on this update, done silently, another receipt)
1333
+ * → nothing.
1334
+ */
1335
+ /**
1336
+ * #1716: background work this restart/update ended, scoped to the operation
1337
+ * so an older stop never reports (`sinceAt` null = plain boot, report
1338
+ * nothing). A method — not a module function — because the #1737
1339
+ * extracted-completion harness runs this region verbatim with only
1340
+ * `this`-methods plus a fixed context.
1341
+ */
1342
+ private collectBackgroundWorkEndedNames;
1343
+ private updateCleanupAtCompletion;
1252
1344
  private armCleanupWatch;
1253
1345
  /**
1254
1346
  * #1660: append a recorded cleanup outcome to the adopted update message,
@@ -1461,6 +1553,11 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1461
1553
  */
1462
1554
  private resolveInboundTarget;
1463
1555
  private handleInboundMessage;
1556
+ /**
1557
+ * #1752: the bot that speaks back about an inbound message — in a fleet topic the owning instance's adapter, never
1558
+ * the sibling that happened to win the dedup race; elsewhere (ClassicBot rooms, no routed instance) the receiver.
1559
+ */
1560
+ private inboundNoticeAdapter;
1464
1561
  private handleInboundMessageCore;
1465
1562
  /** Handle outbound tool calls from a daemon instance */
1466
1563
  /** Warn (but don't block) when rate limits are high. 30-min debounce per instance. */
@@ -1503,7 +1600,14 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
1503
1600
  private isWebOnlyFleet;
1504
1601
  /** On a fleet with no chat platform, the dashboard is where an instance-health prompt is posted (#1307 item 6). */
1505
1602
  private webOnlyPromptPlace;
1603
+ /** Resolves when the reply is in the web chat (#1770: after its files are copied); the caller need not wait. */
1506
1604
  private afterReplyRouted;
1605
+ /**
1606
+ * #1770: a reply's files as the web chat shows them. Each is copied into the instance's web-files/ and served from
1607
+ * the copy. One the copy refuses (a symlink, not a regular file, over 50 MB, a state file, missing) is not shown;
1608
+ * one that could not be copied (I/O) is served from the agent's own path, as before — until the fleet restarts.
1609
+ */
1610
+ private webReplyAttachments;
1507
1611
  private handleScheduleTrigger;
1508
1612
  /**
1509
1613
  * The adapter that can actually post into a chat, found by its group.