@songsid/agend 2.1.3 → 2.1.4-beta.10

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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/README.zh-TW.md +2 -2
  4. package/dist/backend/antigravity.d.ts +1 -0
  5. package/dist/backend/antigravity.js +1 -0
  6. package/dist/backend/antigravity.js.map +1 -1
  7. package/dist/backend/claude-code.d.ts +1 -0
  8. package/dist/backend/claude-code.js +24 -2
  9. package/dist/backend/claude-code.js.map +1 -1
  10. package/dist/backend/codex.d.ts +1 -0
  11. package/dist/backend/codex.js +43 -4
  12. package/dist/backend/codex.js.map +1 -1
  13. package/dist/backend/gemini-cli.d.ts +1 -0
  14. package/dist/backend/gemini-cli.js +1 -0
  15. package/dist/backend/gemini-cli.js.map +1 -1
  16. package/dist/backend/grok.d.ts +1 -0
  17. package/dist/backend/grok.js +1 -0
  18. package/dist/backend/grok.js.map +1 -1
  19. package/dist/backend/kiro.d.ts +1 -0
  20. package/dist/backend/kiro.js +1 -0
  21. package/dist/backend/kiro.js.map +1 -1
  22. package/dist/backend/mock.d.ts +1 -0
  23. package/dist/backend/mock.js +1 -0
  24. package/dist/backend/mock.js.map +1 -1
  25. package/dist/backend/opencode.d.ts +40 -0
  26. package/dist/backend/opencode.js +83 -5
  27. package/dist/backend/opencode.js.map +1 -1
  28. package/dist/backend/types.d.ts +10 -0
  29. package/dist/backend/types.js +7 -0
  30. package/dist/backend/types.js.map +1 -1
  31. package/dist/channel/adapters/discord.js +24 -7
  32. package/dist/channel/adapters/discord.js.map +1 -1
  33. package/dist/channel/mcp-server.js +6 -20
  34. package/dist/channel/mcp-server.js.map +1 -1
  35. package/dist/channel/mcp-tools.js +1 -1
  36. package/dist/channel/mcp-tools.js.map +1 -1
  37. package/dist/channel/types.d.ts +1 -1
  38. package/dist/classic-channel-manager.d.ts +34 -3
  39. package/dist/classic-channel-manager.js +190 -31
  40. package/dist/classic-channel-manager.js.map +1 -1
  41. package/dist/cli.js +74 -23
  42. package/dist/cli.js.map +1 -1
  43. package/dist/completion-install.d.ts +70 -0
  44. package/dist/completion-install.js +152 -0
  45. package/dist/completion-install.js.map +1 -0
  46. package/dist/completion.d.ts +7 -1
  47. package/dist/completion.js +14 -4
  48. package/dist/completion.js.map +1 -1
  49. package/dist/config-validator.js +35 -7
  50. package/dist/config-validator.js.map +1 -1
  51. package/dist/config.js +1 -0
  52. package/dist/config.js.map +1 -1
  53. package/dist/daemon.d.ts +53 -9
  54. package/dist/daemon.js +222 -86
  55. package/dist/daemon.js.map +1 -1
  56. package/dist/fleet-context.d.ts +8 -0
  57. package/dist/fleet-manager.d.ts +136 -5
  58. package/dist/fleet-manager.js +1088 -316
  59. package/dist/fleet-manager.js.map +1 -1
  60. package/dist/general-knowledge/skills/backend-providers/SKILL.md +114 -0
  61. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +3 -1
  62. package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +52 -0
  63. package/dist/general-knowledge/skills/development-workflow/SKILL.md +28 -0
  64. package/dist/general-knowledge/skills/fleet-config/SKILL.md +1 -0
  65. package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -0
  66. package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -0
  67. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -0
  68. package/dist/general-knowledge/skills/model-discovery/SKILL.md +1 -0
  69. package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -0
  70. package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -0
  71. package/dist/general-knowledge/skills/session-management/SKILL.md +1 -0
  72. package/dist/general-knowledge/skills/tui-effort/SKILL.md +1 -0
  73. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +30 -0
  74. package/dist/instance-lifecycle.d.ts +10 -0
  75. package/dist/instance-lifecycle.js +50 -33
  76. package/dist/instance-lifecycle.js.map +1 -1
  77. package/dist/instructions.d.ts +12 -0
  78. package/dist/instructions.js +33 -0
  79. package/dist/instructions.js.map +1 -1
  80. package/dist/locale.js +130 -0
  81. package/dist/locale.js.map +1 -1
  82. package/dist/outbound-schemas.d.ts +2 -1
  83. package/dist/outbound-schemas.js +1 -0
  84. package/dist/outbound-schemas.js.map +1 -1
  85. package/dist/quickstart.js +29 -2
  86. package/dist/quickstart.js.map +1 -1
  87. package/dist/restart-progress.d.ts +7 -1
  88. package/dist/restart-progress.js +27 -6
  89. package/dist/restart-progress.js.map +1 -1
  90. package/dist/setup-wizard.d.ts +4 -2
  91. package/dist/setup-wizard.js +2 -2
  92. package/dist/setup-wizard.js.map +1 -1
  93. package/dist/tool-progress.d.ts +40 -0
  94. package/dist/tool-progress.js +289 -0
  95. package/dist/tool-progress.js.map +1 -0
  96. package/dist/topic-commands.d.ts +26 -0
  97. package/dist/topic-commands.js +117 -1
  98. package/dist/topic-commands.js.map +1 -1
  99. package/dist/transcript-monitor.d.ts +15 -2
  100. package/dist/transcript-monitor.js +63 -17
  101. package/dist/transcript-monitor.js.map +1 -1
  102. package/dist/transcript-sources.d.ts +106 -0
  103. package/dist/transcript-sources.js +428 -0
  104. package/dist/transcript-sources.js.map +1 -0
  105. package/dist/types.d.ts +8 -0
  106. package/dist/ui/dashboard.html +5 -4
  107. package/dist/update-marker.d.ts +30 -0
  108. package/dist/update-marker.js +71 -20
  109. package/dist/update-marker.js.map +1 -1
  110. package/dist/update-progress.d.ts +6 -0
  111. package/dist/update-progress.js +29 -0
  112. package/dist/update-progress.js.map +1 -0
  113. package/dist/web-api.js +2 -2
  114. package/dist/web-api.js.map +1 -1
  115. package/dist/workflow-templates/default.md +2 -1
  116. package/package.json +2 -2
@@ -80,6 +80,9 @@ export interface FleetContext {
80
80
  ready: boolean;
81
81
  token: string | null;
82
82
  };
83
+ /** Persist and edit one `/update` message across the fleet process restart. */
84
+ beginUpdateProgress?(adapter: import("./channel/types.js").ChannelAdapter, chatId: string, threadId: string | undefined, messageId: string): void;
85
+ failUpdateProgress?(message: string): void;
83
86
  /** Human-readable effective model for an instance (resolves inherited defaults). */
84
87
  modelDisplayForInstance?(name: string): string;
85
88
  /**
@@ -97,4 +100,9 @@ export interface FleetContext {
97
100
  applyEffort?(instanceName: string, level: string): Promise<string>;
98
101
  /** TG inline-keyboard effort menu; same contract as promptModelMenu. */
99
102
  promptEffortMenu?(instanceName: string, userId: string, channelId: string, adapter: import("./channel/types.js").ChannelAdapter, chatId: string, threadId?: string): Promise<string | null>;
103
+ /**
104
+ * Post a nonce-armed confirmation before the destructive `/clear` command.
105
+ * Returns null when the buttons were posted, otherwise a user-facing error.
106
+ */
107
+ promptClearConfirmation?(instanceName: string, channelId: string, adapter: import("./channel/types.js").ChannelAdapter, chatId: string, threadId?: string): Promise<string | null>;
100
108
  }
@@ -106,6 +106,8 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
106
106
  readonly replyDeduper: ReplyDeduper;
107
107
  /** instanceName → what it is doing right now, when the backend can tell us. */
108
108
  private instanceActivity;
109
+ /** instanceName → this turn's tool list (multi-line), for the bubble. */
110
+ private instanceProgress;
109
111
  /** instanceName → tail of deliveries waiting for its IPC to come back. */
110
112
  private ipcWaitTails;
111
113
  /** instanceName → restart currently executing; concurrent callers join it. */
@@ -119,6 +121,8 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
119
121
  /** In-flight /effort selections, same coordinator shape as pendingModelSelects. */
120
122
  private pendingEffortSelects;
121
123
  private pendingModelSelects;
124
+ /** nonce → pending button prompt (hang restart, interactive assist, clean-exit restart). */
125
+ private pendingNonceButtons;
122
126
  private failoverActive;
123
127
  /** instance → when a click with no live button entry last fired a cancel. */
124
128
  private staleCancelClickAt;
@@ -135,6 +139,9 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
135
139
  private healthServer;
136
140
  private healthPortRetried;
137
141
  private updateCheckTimer;
142
+ private updateProgressTimer;
143
+ private updateProgressEditRunning;
144
+ private lastUpdateProgressText;
138
145
  private eventLogPruneTimer;
139
146
  private logRotateTimer;
140
147
  /** Days of event/activity history to keep. */
@@ -216,6 +223,9 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
216
223
  */
217
224
  private isModelAdmin;
218
225
  private handlePauseWakeSlash;
226
+ private handleUpdateSlash;
227
+ /** Admin-only full conversation reset for fleet-topic and Classic instances. */
228
+ private handleClearSlash;
219
229
  /** Get the adapter bound to an instance, falling back to primary adapter */
220
230
  getAdapterForInstance(name: string): ChannelAdapter | null;
221
231
  /** Get the world for an instance */
@@ -327,6 +337,10 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
327
337
  ready: boolean;
328
338
  token: string | null;
329
339
  };
340
+ beginUpdateProgress(adapter: ChannelAdapter, chatId: string, threadId: string | undefined, messageId: string): void;
341
+ failUpdateProgress(message: string): void;
342
+ /** The old fleet edits CLI install stages; the new fleet adopts the same message below. */
343
+ private startUpdateProgressMonitor;
330
344
  /** Start all instances from fleet config */
331
345
  startAll(configPath: string): Promise<void>;
332
346
  /**
@@ -426,8 +440,6 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
426
440
  private handleOutboundFromInstance;
427
441
  /** Side effects of a routed reply: cancel-button lifecycle, logs, SSE, chat log. */
428
442
  private afterReplyRouted;
429
- /** Handle tool status update from a daemon instance */
430
- private handleToolStatusFromInstance;
431
443
  private handleScheduleTrigger;
432
444
  private notifySourceTopic;
433
445
  private notifyScheduleFailure;
@@ -530,6 +542,58 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
530
542
  private static readonly FLEET_ERROR_THROTTLE_MS;
531
543
  private fleetErrorNotices;
532
544
  notifyInstanceTopic(instanceName: string, text: string, extraOpts?: import("./channel/types.js").SendOpts): void;
545
+ /**
546
+ * Post decision buttons whose callback ids are `<prefix><nonce>:<action>`.
547
+ * The entry is registered before the send and rolled back if the send
548
+ * fails, so a nonce in the map always refers to a message that exists (or
549
+ * is about to). Returns the nonce, or null when the alert could not be sent.
550
+ */
551
+ private postNonceButtonPrompt;
552
+ /**
553
+ * Claim a nonce-armed callback exactly once.
554
+ *
555
+ * Returns:
556
+ * - null — the callback is not for this prefix; try the next handler
557
+ * - "consumed" — for this prefix but stale/denied/malformed; stop dispatch
558
+ * - the entry+action — the click is authorized and now claimed (removed
559
+ * from the map before any await, so double clicks cannot act twice)
560
+ *
561
+ * A stale click (expired nonce, or a pre-upgrade button whose payload no
562
+ * longer parses) collapses the clicked message so the dead button stops
563
+ * inviting clicks — the same courtesy the cancel button extends.
564
+ */
565
+ private consumeNonceCallback;
566
+ /** Collapse a consumed prompt's buttons into a final status line. */
567
+ private retireNonceButtons;
568
+ /** Post the destructive `/clear` confirmation in the invoking channel. */
569
+ promptClearConfirmation(instanceName: string, channelId: string, adapter: ChannelAdapter, chatId: string, threadId?: string): Promise<string | null>;
570
+ /** Consume `/clear` Confirm/Cancel exactly once; only Confirm reaches IPC. */
571
+ private handleClearConfirmation;
572
+ /**
573
+ * Drop every pending prompt that refers to an instance being stopped or
574
+ * restarted — a restart offer for an instance the operator just restarted
575
+ * (or an assist for one they stopped) must not stay clickable for the rest
576
+ * of its 15 minutes.
577
+ */
578
+ clearNoncePromptsForInstance(instanceName: string): void;
579
+ /** A clean exit is intentional from the CLI's perspective, but often not from
580
+ * the operator's. Keep the instance notice passive and put the action in the
581
+ * same-world General topic where an administrator can make the choice. */
582
+ notifyNormalExit(instanceName: string): Promise<void>;
583
+ /** Consume a clean-exit Restart/Ignore button exactly once. */
584
+ private handleExitRestartPrompt;
585
+ private interactivePromptLabel;
586
+ /**
587
+ * Surface a stable terminal prompt in both places that matter:
588
+ * - the blocked instance gets a plain pointer to General;
589
+ * - General gets one-shot Confirm/Cancel controls on its own bound adapter.
590
+ *
591
+ * Only the prompt category crosses channels. The captured terminal line can
592
+ * contain usernames or secret-adjacent text and stays in daemon.log.
593
+ */
594
+ notifyInteractivePrompt(instanceName: string, kind: string): Promise<void>;
595
+ /** Consume a General assist button exactly once. */
596
+ private handleInteractivePromptAssist;
533
597
  /** Send a "🛑 Cancel" button to the instance's topic/channel after delivery. */
534
598
  /**
535
599
  * Handle the DC `/save` slash command for both classic AND fleet-topic targets.
@@ -555,7 +619,7 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
555
619
  */
556
620
  private handleCancelClick;
557
621
  private hasCancelButton;
558
- sendCancelButton(instanceName: string, correlationId?: string): Promise<void>;
622
+ sendCancelButton(instanceName: string, correlationId?: string, preserveProgress?: boolean): Promise<void>;
559
623
  /**
560
624
  * The cancel button's text for a given elapsed time.
561
625
  *
@@ -582,6 +646,26 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
582
646
  * never used to decide anything — purely what the user is shown.
583
647
  */
584
648
  private cacheInstanceActivity;
649
+ /**
650
+ * Cache the turn's tool-progress list and push it into the instance's live
651
+ * bubble, coalesced so a burst of tool events cannot flood the Bot API
652
+ * (Telegram's flood limit is per-chat across ALL forum topics, so edits are
653
+ * rate-limited per bubble AND ride behind the daemon-side 3s coalescer).
654
+ */
655
+ private cacheInstanceProgress;
656
+ /** At most one progress-driven edit per bubble per TOOL_PROGRESS_EDIT_MIN_MS. */
657
+ private scheduleProgressEdit;
658
+ /**
659
+ * The ONE composer for the bubble text. Both writers — the elapsed-time
660
+ * ticker and the tool-progress push — go through here; two independent
661
+ * renderers editing the same message is how the progress list used to get
662
+ * wiped by the next elapsed tick (#528 trap 2).
663
+ */
664
+ private composeBubbleText;
665
+ /** Pure composition of header + tool list, exposed for tests. */
666
+ static bubbleText(elapsedMs: number, activity: string | undefined, minElapsedMs: number, progress: string | undefined): string;
667
+ /** Recompose and edit the bubble in place; skips when nothing changed. */
668
+ private refreshBubble;
585
669
  /**
586
670
  * Refresh the button's text in place while the instance keeps working.
587
671
  *
@@ -622,7 +706,9 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
622
706
  private sweepOrphanedCancelButtons;
623
707
  /** Re-attempt a failed button delete up to CANCEL_BTN_MAX_RETRIES times. */
624
708
  private scheduleButtonRetry;
625
- /** Delete one button's message via its own adapter. Resolves on success,
709
+ /** Retire one cancel bubble via its own adapter. A bubble that accumulated
710
+ * tool progress is kept as a read-only history message; a plain bubble keeps
711
+ * the legacy delete/edit-to-checkmark behavior. Resolves on success and
626
712
  * rejects on failure so the caller can retry. */
627
713
  private deleteButtonMessage;
628
714
  /** Retire all cancel buttons for an instance — on reply or cancel. */
@@ -654,12 +740,57 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
654
740
  title: string;
655
741
  }>;
656
742
  sendHangNotification(instanceName: string, unchangedForMs?: number): Promise<void>;
743
+ /**
744
+ * Consume a hang Force-restart / Keep-waiting button exactly once. Restart
745
+ * goes through restartSingleInstance — serialized against concurrent restart
746
+ * sources, and with a Classic-instance fallback (the previous hand-rolled
747
+ * stop+start silently left Classic instances stopped while reporting
748
+ * "restarted").
749
+ */
750
+ private handleHangPrompt;
657
751
  private static INSTRUCTIONS_FILENAME;
658
752
  private static GENERAL_INSTRUCTIONS;
659
753
  /** Ensure the general instance has its project instructions file + knowledge */
660
754
  private ensureGeneralInstructions;
661
- /** Copy general-knowledge steering + skills to the general instance's workspace */
755
+ /** Resolve the workspace path a backend actually uses before publishing knowledge. */
756
+ private resolveKnowledgeWorkDir;
757
+ /**
758
+ * Where each backend natively loads on-demand skills from, relative to the
759
+ * workspace. Backends without a native skill mechanism (opencode, grok,
760
+ * antigravity, gemini-cli) are deliberately absent: dropping files a CLI
761
+ * never reads is clutter, not capability. Unknown directories are ignored
762
+ * by older CLI versions, so publishing is fail-open across upgrades.
763
+ */
764
+ private static SKILLS_DIR_SEGMENTS;
765
+ /** Copy general-knowledge steering + all role-eligible skills to General. */
662
766
  private syncGeneralKnowledge;
767
+ /** Publish only the bundled skills eligible for an instance role. */
768
+ private syncRoleSkills;
769
+ /**
770
+ * Steering (always-on rules like core-rules.md). Kiro loads a native
771
+ * steering directory; every other backend gets the content embedded into
772
+ * its instructions file (CLAUDE.md / AGENTS.md / …) inside a managed marker
773
+ * block — the previous behavior dropped bare .md files in the workspace
774
+ * root, which no CLI ever read. The block is replaced in place on every
775
+ * sync, so rule updates reach EXISTING workspaces; everything the user
776
+ * wrote outside the markers is preserved byte-for-byte.
777
+ */
778
+ private syncGeneralSteering;
779
+ private static STEERING_BLOCK_BEGIN;
780
+ private static STEERING_BLOCK_END;
781
+ /**
782
+ * Publish AgEnD's bundled skills into a CLI's native skills directory,
783
+ * owning ONLY what we published. A manifest records which skill names AgEnD
784
+ * wrote; a bundled rename/removal deletes the stale managed copy, while a
785
+ * skill the user created by hand is never listed and therefore never
786
+ * touched — even if a future bundle happens to reuse its name (the sync
787
+ * then skips it and logs, rather than overwrite the user's work). The sole
788
+ * migration exception is the pre-manifest Kiro General layout explicitly
789
+ * selected by adoptLegacyUnmanaged.
790
+ */
791
+ private syncManagedSkills;
792
+ /** Read AgEnD's roles extension from SKILL.md YAML frontmatter. */
793
+ private readManagedSkillRoles;
663
794
  /** Fetch forum topic icon stickers and pick emoji IDs for each state */
664
795
  private resolveTopicIcons;
665
796
  /** Set topic icon based on instance state */