@songsid/agend 2.1.0-beta.4 → 2.1.0-beta.40
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.
- package/README.md +1 -0
- package/README.zh-TW.md +2 -1
- package/dist/access-path.js +3 -3
- package/dist/access-path.js.map +1 -1
- package/dist/agent-cli.js +1 -1
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.d.ts +8 -0
- package/dist/agent-endpoint.js +36 -8
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/backend/antigravity.d.ts +2 -0
- package/dist/backend/antigravity.js +30 -3
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.d.ts +2 -0
- package/dist/backend/claude-code.js +16 -4
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/factory.js +4 -1
- package/dist/backend/factory.js.map +1 -1
- package/dist/backend/grok.d.ts +53 -0
- package/dist/backend/grok.js +302 -0
- package/dist/backend/grok.js.map +1 -0
- package/dist/backend/kiro.d.ts +2 -0
- package/dist/backend/kiro.js +32 -3
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +36 -3
- package/dist/backend/types.js +1 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +20 -0
- package/dist/channel/adapters/discord.js +89 -11
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.js +4 -1
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-tools.js +18 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/chat-export.js +5 -2
- package/dist/chat-export.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +16 -1
- package/dist/classic-channel-manager.js +76 -4
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +116 -19
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +70 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +14 -1
- package/dist/config.js.map +1 -1
- package/dist/context-guardian.d.ts +2 -0
- package/dist/context-guardian.js +10 -2
- package/dist/context-guardian.js.map +1 -1
- package/dist/daemon-entry.js +2 -1
- package/dist/daemon-entry.js.map +1 -1
- package/dist/daemon.d.ts +91 -6
- package/dist/daemon.js +602 -186
- package/dist/daemon.js.map +1 -1
- package/dist/daily-summary.js +7 -2
- package/dist/daily-summary.js.map +1 -1
- package/dist/fleet-context.d.ts +6 -0
- package/dist/fleet-manager.d.ts +113 -8
- package/dist/fleet-manager.js +972 -142
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-system-prompt.js +1 -1
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +19 -13
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +30 -51
- package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -1
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +19 -13
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +1 -5
- package/dist/general-knowledge/skills/scheduling/SKILL.md +41 -0
- package/dist/general-knowledge/skills/session-management/SKILL.md +29 -116
- package/dist/instance-lifecycle.d.ts +15 -1
- package/dist/instance-lifecycle.js +71 -22
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +28 -2
- package/dist/locale.js.map +1 -1
- package/dist/logger.d.ts +6 -0
- package/dist/logger.js +28 -9
- package/dist/logger.js.map +1 -1
- package/dist/outbound-handlers.d.ts +3 -0
- package/dist/outbound-handlers.js +224 -11
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +44 -2
- package/dist/outbound-schemas.js +50 -3
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pause-marker.d.ts +5 -0
- package/dist/pause-marker.js +36 -0
- package/dist/pause-marker.js.map +1 -0
- package/dist/scheduler/db.d.ts +8 -0
- package/dist/scheduler/db.js +74 -5
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/db.test.js +50 -0
- package/dist/scheduler/db.test.js.map +1 -1
- package/dist/scheduler/scheduler.d.ts +6 -0
- package/dist/scheduler/scheduler.js +99 -16
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/scheduler/scheduler.test.js +131 -1
- package/dist/scheduler/scheduler.test.js.map +1 -1
- package/dist/scheduler/types.d.ts +9 -3
- package/dist/scheduler/types.js.map +1 -1
- package/dist/settings-api.d.ts +20 -2
- package/dist/settings-api.js +213 -9
- package/dist/settings-api.js.map +1 -1
- package/dist/setup-wizard.js +8 -0
- package/dist/setup-wizard.js.map +1 -1
- package/dist/statusline-watcher.d.ts +1 -1
- package/dist/statusline-watcher.js +3 -2
- package/dist/statusline-watcher.js.map +1 -1
- package/dist/tmux-control.d.ts +7 -0
- package/dist/tmux-control.js +22 -1
- package/dist/tmux-control.js.map +1 -1
- package/dist/tmux-manager.d.ts +1 -1
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.d.ts +19 -1
- package/dist/topic-commands.js +148 -23
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.js +2 -0
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/types.d.ts +29 -1
- package/dist/tz-utils.d.ts +26 -0
- package/dist/tz-utils.js +46 -0
- package/dist/tz-utils.js.map +1 -0
- package/dist/ui/dashboard.html +3 -3
- package/dist/ui/settings.html +453 -74
- package/dist/web-api.d.ts +1 -0
- package/dist/web-api.js +24 -15
- package/dist/web-api.js.map +1 -1
- package/dist/workflow-templates/default.md +0 -4
- package/package.json +2 -1
package/dist/fleet-manager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FleetConfig, InstanceConfig } from "./types.js";
|
|
1
|
+
import type { FleetConfig, RawFleetConfig, InstanceConfig } from "./types.js";
|
|
2
2
|
import { type RouteTarget } from "./fleet-context.js";
|
|
3
3
|
import { EventLog } from "./event-log.js";
|
|
4
4
|
import { AdapterWorld } from "./adapter-world.js";
|
|
@@ -14,9 +14,34 @@ import { InstanceLifecycle, type LifecycleContext } from "./instance-lifecycle.j
|
|
|
14
14
|
import { type ArchiverContext } from "./topic-archiver.js";
|
|
15
15
|
import { type StatuslineWatcherContext } from "./statusline-watcher.js";
|
|
16
16
|
import { type OutboundContext } from "./outbound-handlers.js";
|
|
17
|
+
import { type RawConfigPatch } from "./settings-api.js";
|
|
17
18
|
import { type AgentEndpointContext } from "./agent-endpoint.js";
|
|
18
19
|
import { ClassicChannelManager } from "./classic-channel-manager.js";
|
|
20
|
+
import type { InstanceState } from "./backend/types.js";
|
|
19
21
|
export declare function resolveReplyThreadId(argsThreadId: unknown, instanceConfig?: InstanceConfig): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Pure warm-cap victim selection (extracted for testability). Given the current
|
|
24
|
+
* warm (running) instance names and a cap, return the LRU idle instances to evict
|
|
25
|
+
* so the running count returns to the cap. Skips: the `exclude` instance, any
|
|
26
|
+
* already-evicting, general instances (never evicted), and non-idle instances
|
|
27
|
+
* (working/stuck can't be evicted). Oldest last-inbound is evicted first; a
|
|
28
|
+
* missing timestamp (0) sorts oldest. cap <= 0 (or non-integer) = unlimited → [].
|
|
29
|
+
*/
|
|
30
|
+
export declare function selectLruEvictions(warm: string[], cap: number, opts: {
|
|
31
|
+
exclude?: string;
|
|
32
|
+
isEvicting: (name: string) => boolean;
|
|
33
|
+
isGeneral: (name: string) => boolean;
|
|
34
|
+
isIdle: (name: string) => boolean;
|
|
35
|
+
lastInboundAt: (name: string) => number;
|
|
36
|
+
}): string[];
|
|
37
|
+
export interface DeliveryOptions {
|
|
38
|
+
/** Explicitly identify agent-to-agent delivery when metadata is unavailable. */
|
|
39
|
+
isCrossInstance?: boolean;
|
|
40
|
+
/** Force or bypass the idle gate. Schedules set this explicitly. */
|
|
41
|
+
waitForIdle?: boolean;
|
|
42
|
+
/** Test/operational override; normal deliveries use the 60 second backstop. */
|
|
43
|
+
idleTimeoutMs?: number;
|
|
44
|
+
}
|
|
20
45
|
export declare class FleetManager implements FleetContext, LifecycleContext, ArchiverContext, StatuslineWatcherContext, OutboundContext, AgentEndpointContext {
|
|
21
46
|
dataDir: string;
|
|
22
47
|
private children;
|
|
@@ -24,6 +49,9 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
24
49
|
/** @deprecated Use lifecycle.daemons — kept for backward compat */
|
|
25
50
|
get daemons(): Map<string, import("./daemon.js").Daemon>;
|
|
26
51
|
fleetConfig: FleetConfig | null;
|
|
52
|
+
private rawFleetConfig;
|
|
53
|
+
private rawFleetDocument;
|
|
54
|
+
private savedFleetConfigSnapshot;
|
|
27
55
|
adapter: ChannelAdapter | null;
|
|
28
56
|
readonly worlds: Map<string, AdapterWorld>;
|
|
29
57
|
readonly adapters: Map<string, ChannelAdapter>;
|
|
@@ -48,12 +76,27 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
48
76
|
private webhookEmitter;
|
|
49
77
|
private topicIcons;
|
|
50
78
|
private lastActivity;
|
|
79
|
+
/** Latest pane-derived execution snapshot reported by each daemon. */
|
|
80
|
+
private instanceStateCache;
|
|
81
|
+
/** CLI pane status overrides; daemon.pid alone only proves FleetManager lives. */
|
|
82
|
+
private instanceProcessStatus;
|
|
83
|
+
/** Instances currently being auto-paused by warm_cap, so concurrent checks don't double-evict. */
|
|
84
|
+
private warmCapEvicting;
|
|
85
|
+
/** Per-instance tail keeps cross-instance and scheduled deliveries FIFO. */
|
|
86
|
+
private idleGatedDeliveryTails;
|
|
87
|
+
/** Non-user work must observe a fresh idle snapshot after the latest delivery. */
|
|
88
|
+
private lastDeliveryAt;
|
|
89
|
+
/** State-cache updates wake event-driven idle waiters without busy polling. */
|
|
90
|
+
private instanceIdleWaiters;
|
|
51
91
|
private lastInboundUser;
|
|
52
92
|
private cancelButtons;
|
|
53
93
|
private lastInboundMsg;
|
|
54
94
|
private topicArchiver;
|
|
55
95
|
controlClient: TmuxControlClient | null;
|
|
56
96
|
classicChannels: ClassicChannelManager | null;
|
|
97
|
+
private pendingClassicStarts;
|
|
98
|
+
/** In-flight /model selections, keyed by nonce (see handleModelSelection). */
|
|
99
|
+
private pendingModelSelects;
|
|
57
100
|
private failoverActive;
|
|
58
101
|
readonly ipcStoppingInstances: Set<string>;
|
|
59
102
|
private adapterRestarting;
|
|
@@ -76,6 +119,8 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
76
119
|
getSysInfo(): import("./fleet-context.js").SysInfo;
|
|
77
120
|
/** Load fleet.yaml and build routing table */
|
|
78
121
|
loadConfig(configPath: string): FleetConfig;
|
|
122
|
+
/** User-authored fleet.yaml, before defaults are merged into instances. */
|
|
123
|
+
getRawFleetConfig(): RawFleetConfig;
|
|
79
124
|
/** Build topic routing table: { topicId -> RouteTarget } */
|
|
80
125
|
buildRoutingTable(): Map<string, RouteTarget>;
|
|
81
126
|
/**
|
|
@@ -97,6 +142,7 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
97
142
|
* /cancel). Classic-only commands (/chat, /load) must NOT use this.
|
|
98
143
|
*/
|
|
99
144
|
private resolveSlashTarget;
|
|
145
|
+
private handlePauseWakeSlash;
|
|
100
146
|
/** Get the adapter bound to an instance, falling back to primary adapter */
|
|
101
147
|
getAdapterForInstance(name: string): ChannelAdapter | null;
|
|
102
148
|
/** Get the world for an instance */
|
|
@@ -114,9 +160,32 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
114
160
|
*/
|
|
115
161
|
bindInstanceAdapter(name: string, adapterId: string, fromInbound?: boolean): void;
|
|
116
162
|
getInstanceStatus(name: string): "running" | "paused" | "stopped" | "crashed";
|
|
117
|
-
|
|
118
|
-
|
|
163
|
+
getInstanceExecutionState(name: string): InstanceState | null;
|
|
164
|
+
isClassicInstance(name: string): boolean;
|
|
165
|
+
private cacheInstanceExecutionState;
|
|
166
|
+
private cacheInstanceProcessStatus;
|
|
167
|
+
/**
|
|
168
|
+
* Fleet-wide warm cap: if more than `defaults.warm_cap` instances are running,
|
|
169
|
+
* auto-pause the least-recently-active idle instances until back at the cap.
|
|
170
|
+
* Never evicts general instances (must stay warm) or working/stuck instances
|
|
171
|
+
* (only idle). 0/unset = unlimited. wake-before-deliver re-warms any evicted
|
|
172
|
+
* instance when a message next arrives.
|
|
173
|
+
*
|
|
174
|
+
* @param exclude instance to spare (e.g. one just woken to receive a delivery).
|
|
175
|
+
*/
|
|
176
|
+
private enforceWarmCap;
|
|
177
|
+
private waitForInstanceIdle;
|
|
178
|
+
private deliverWithIdleGate;
|
|
179
|
+
/** Single delivery facade: wake paused CLIs and serialize non-user work behind idle. */
|
|
180
|
+
deliverToInstance(instanceName: string, payload: Record<string, unknown>, options?: DeliveryOptions): Promise<void>;
|
|
181
|
+
/** Fleet admin is an explicit config allowlist entry, not merely an open/paired user. */
|
|
182
|
+
isFleetAdmin(userId: string, adapterId?: string): boolean;
|
|
183
|
+
changeInstancePauseState(name: string, action: "pause" | "wake"): Promise<"paused" | "awake" | "not_idle">;
|
|
184
|
+
/** Apply a Settings edit to a ClassicBot channel without waiting for the poller. */
|
|
185
|
+
restartClassicInstanceFromSettings(instanceName: string): Promise<void>;
|
|
119
186
|
startInstance(name: string, config: InstanceConfig, topicMode: boolean): Promise<void>;
|
|
187
|
+
/** Recreate a daemon for a marker-only paused instance after an explicit wake/delivery. */
|
|
188
|
+
startPersistedPausedInstance(name: string): Promise<void>;
|
|
120
189
|
/**
|
|
121
190
|
* Start instances with configurable concurrency and stagger delay.
|
|
122
191
|
* Instances sharing the same working_directory are serialized within a group
|
|
@@ -126,7 +195,16 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
126
195
|
private startInstancesWithConcurrency;
|
|
127
196
|
stopInstance(name: string): Promise<void>;
|
|
128
197
|
/** Restart a single instance, reloading fleet.yaml first to pick up config changes. */
|
|
129
|
-
restartSingleInstance(name: string
|
|
198
|
+
restartSingleInstance(name: string, opts?: {
|
|
199
|
+
freshStart?: boolean;
|
|
200
|
+
}): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Mark an instance so its next daemon start skips session resume. Written AFTER
|
|
203
|
+
* stop (survives the old daemon's cleanup) and BEFORE start so the respawn reads
|
|
204
|
+
* it — reuses the crash-state → resumeDisabled path from crash-loop recovery.
|
|
205
|
+
* One-shot: the daemon deletes it on startup.
|
|
206
|
+
*/
|
|
207
|
+
private writeFreshStartMarker;
|
|
130
208
|
/** Load .env file from data dir into process.env */
|
|
131
209
|
private loadEnvFile;
|
|
132
210
|
/** Start all instances from fleet config */
|
|
@@ -198,10 +276,15 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
198
276
|
private botUserId;
|
|
199
277
|
/** Periodically check if bound topics still exist */
|
|
200
278
|
private startTopicCleanupPoller;
|
|
201
|
-
/**
|
|
202
|
-
|
|
279
|
+
/**
|
|
280
|
+
* Patch only values changed in the effective config into the original YAML
|
|
281
|
+
* document. Unknown keys, explicit overrides and comments remain untouched.
|
|
282
|
+
*/
|
|
283
|
+
saveFleetConfig(explicitPatches?: RawConfigPatch[]): void;
|
|
284
|
+
private patchFleetDocument;
|
|
203
285
|
removeInstance(name: string): Promise<void>;
|
|
204
286
|
startStatuslineWatcher(name: string): void;
|
|
287
|
+
stopStatuslineWatcher(name: string): void;
|
|
205
288
|
reactMessageStatus(instanceName: string, chatId: string, messageId: string, emoji: string): void;
|
|
206
289
|
private static FAILOVER_TRIGGER_PCT;
|
|
207
290
|
private static FAILOVER_RECOVER_PCT;
|
|
@@ -260,7 +343,7 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
260
343
|
id: string;
|
|
261
344
|
title: string;
|
|
262
345
|
}>;
|
|
263
|
-
sendHangNotification(instanceName: string): Promise<void>;
|
|
346
|
+
sendHangNotification(instanceName: string, unchangedForMs?: number): Promise<void>;
|
|
264
347
|
private static INSTRUCTIONS_FILENAME;
|
|
265
348
|
private static GENERAL_INSTRUCTIONS;
|
|
266
349
|
/** Ensure the general instance has its project instructions file + knowledge */
|
|
@@ -283,12 +366,34 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
|
|
|
283
366
|
private forwardToClassicInstance;
|
|
284
367
|
/** Paste raw text directly to a classic instance's CLI (no [user:] wrapping) */
|
|
285
368
|
private pasteRawToClassicInstance;
|
|
369
|
+
/** Resolve the backend name configured for an instance (fleet or classic). */
|
|
370
|
+
private backendNameForInstance;
|
|
371
|
+
/** Best-effort model list for `/model` (empty ⇒ caller falls back to free-text). Never throws. */
|
|
372
|
+
private getModelOptions;
|
|
373
|
+
/** `/model` slash handler (admin only). No arg → DC menu; `/model <name>` → apply directly. */
|
|
374
|
+
private handleModelSlash;
|
|
375
|
+
/** Consume a `/model` selection callback. Returns true for all model-select ids (incl. stale). */
|
|
376
|
+
private handleModelSelection;
|
|
377
|
+
/** Apply a model to an instance: runtime paste (claude-code) or persist + restart (others). */
|
|
378
|
+
applyModel(instanceName: string, model: string): Promise<string>;
|
|
286
379
|
/** Read recent chat log for agent context */
|
|
287
380
|
private getRecentChatLog;
|
|
381
|
+
/** Return a user-facing blocker without mutating ClassicBot state. */
|
|
382
|
+
private validateClassicStart;
|
|
383
|
+
private isBackendInstalled;
|
|
384
|
+
private getMissingBackendWarning;
|
|
385
|
+
/** Handle Discord's required static slash choice, warning before a likely startup failure. */
|
|
386
|
+
private handleClassicStartSlash;
|
|
387
|
+
/** Present platform-native backend choices, then start on selection or timeout. */
|
|
388
|
+
private beginClassicBackendSelection;
|
|
389
|
+
/** Consume a selection callback. Returns true for all ClassicBot callback IDs, including stale ones. */
|
|
390
|
+
private handleClassicBackendSelection;
|
|
391
|
+
/** Atomically claim one pending request so timeout/click races create at most one instance. */
|
|
392
|
+
private finishClassicBackendSelection;
|
|
288
393
|
/** Start a classic channel instance with lightweight config */
|
|
289
394
|
private startClassicInstance;
|
|
290
395
|
/** Handle /start slash command — register classic channel */
|
|
291
|
-
handleClassicStart(channelId: string, channelName: string, userId: string, guildId?: string, adapterId?: string): Promise<string>;
|
|
396
|
+
handleClassicStart(channelId: string, channelName: string, userId: string, guildId?: string, adapterId?: string, backend?: string): Promise<string>;
|
|
292
397
|
/** Handle /stop slash command — unregister classic channel */
|
|
293
398
|
handleClassicStop(channelId: string, adapterId?: string): Promise<string>;
|
|
294
399
|
stopAll(): Promise<void>;
|