@songsid/agend 2.2.0-beta.8 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -24
- package/README.zh-TW.md +40 -24
- package/dist/agent-endpoint.js +3 -0
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-whats-new.js +7 -1
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.d.ts +3 -1
- package/dist/auth-api.js +15 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/antigravity.d.ts +33 -0
- package/dist/backend/antigravity.js +126 -18
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.d.ts +3 -0
- package/dist/backend/claude-code.js +9 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex-metadata.d.ts +33 -0
- package/dist/backend/codex-metadata.js +122 -18
- package/dist/backend/codex-metadata.js.map +1 -1
- package/dist/backend/codex.d.ts +3 -0
- package/dist/backend/codex.js +17 -1
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/effort-metadata.d.ts +37 -1
- package/dist/backend/effort-metadata.js +86 -15
- package/dist/backend/effort-metadata.js.map +1 -1
- package/dist/backend/grok.d.ts +4 -0
- package/dist/backend/grok.js +14 -0
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro.d.ts +18 -1
- package/dist/backend/kiro.js +35 -8
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/launch-effort.d.ts +61 -0
- package/dist/backend/launch-effort.js +170 -0
- package/dist/backend/launch-effort.js.map +1 -0
- package/dist/backend/muse.d.ts +17 -0
- package/dist/backend/muse.js +86 -16
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +40 -1
- package/dist/backend/types.js +12 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-command.d.ts +91 -0
- package/dist/backend-command.js +122 -0
- package/dist/backend-command.js.map +1 -0
- package/dist/channel/adapters/discord.d.ts +12 -0
- package/dist/channel/adapters/discord.js +49 -2
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +18 -0
- package/dist/channel/adapters/telegram.js +24 -3
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-tools.js +2 -0
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/tool-router.d.ts +2 -0
- package/dist/channel/tool-router.js +1 -1
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/channel/types.d.ts +16 -0
- package/dist/cli.js +124 -24
- package/dist/cli.js.map +1 -1
- package/dist/command-table.d.ts +2 -2
- package/dist/command-table.js +5 -2
- package/dist/command-table.js.map +1 -1
- package/dist/compact-watch.d.ts +86 -0
- package/dist/compact-watch.js +288 -0
- package/dist/compact-watch.js.map +1 -0
- package/dist/config-validator.js +39 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +13 -1
- package/dist/daemon.js +160 -13
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +8 -1
- package/dist/delivery-outbox.js +6 -2
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/doctor.js +7 -0
- package/dist/doctor.js.map +1 -1
- package/dist/fleet-context.d.ts +7 -0
- package/dist/fleet-manager.d.ts +160 -10
- package/dist/fleet-manager.js +837 -121
- package/dist/fleet-manager.js.map +1 -1
- package/dist/forged-envelope-scan.d.ts +4 -3
- package/dist/forged-envelope-scan.js +4 -3
- package/dist/forged-envelope-scan.js.map +1 -1
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -1
- package/dist/install-lock.d.ts +18 -1
- package/dist/install-lock.js +30 -3
- package/dist/install-lock.js.map +1 -1
- package/dist/instance-avatar.d.ts +5 -4
- package/dist/instance-avatar.js +12 -8
- package/dist/instance-avatar.js.map +1 -1
- package/dist/instance-lifecycle.js +3 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.js +2 -2
- package/dist/instructions.js.map +1 -1
- package/dist/kiro-compact-pane.d.ts +38 -0
- package/dist/kiro-compact-pane.js +57 -0
- package/dist/kiro-compact-pane.js.map +1 -0
- package/dist/kiro-log-gate.d.ts +42 -0
- package/dist/kiro-log-gate.js +39 -0
- package/dist/kiro-log-gate.js.map +1 -0
- package/dist/launchd-handoff.d.ts +43 -0
- package/dist/launchd-handoff.js +56 -0
- package/dist/launchd-handoff.js.map +1 -0
- package/dist/locale.js +202 -30
- package/dist/locale.js.map +1 -1
- package/dist/log-service.js +10 -2
- package/dist/log-service.js.map +1 -1
- package/dist/log-steps.d.ts +26 -0
- package/dist/log-steps.js +215 -3
- package/dist/log-steps.js.map +1 -1
- package/dist/login-shell.d.ts +21 -0
- package/dist/login-shell.js +98 -0
- package/dist/login-shell.js.map +1 -0
- package/dist/outbound-handlers.d.ts +27 -0
- package/dist/outbound-handlers.js +120 -36
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +12 -0
- package/dist/outbound-schemas.js +15 -4
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/provider-probe.d.ts +29 -0
- package/dist/provider-probe.js +198 -2
- package/dist/provider-probe.js.map +1 -1
- package/dist/public-web-gateway.d.ts +2 -0
- package/dist/public-web-gateway.js +11 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/quickstart-api.d.ts +1 -1
- package/dist/quickstart-api.js +8 -6
- package/dist/quickstart-api.js.map +1 -1
- package/dist/quickstart.d.ts +12 -0
- package/dist/quickstart.js +36 -6
- package/dist/quickstart.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +86 -5
- package/dist/reply-buttons-controller.js +271 -7
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +48 -3
- package/dist/reply-buttons.js +105 -10
- package/dist/reply-buttons.js.map +1 -1
- package/dist/reply-polls.d.ts +85 -0
- package/dist/reply-polls.js +154 -0
- package/dist/reply-polls.js.map +1 -0
- package/dist/restart-guard.d.ts +6 -3
- package/dist/restart-guard.js +6 -3
- package/dist/restart-guard.js.map +1 -1
- package/dist/restart-progress.d.ts +0 -2
- package/dist/restart-progress.js +0 -2
- package/dist/restart-progress.js.map +1 -1
- package/dist/sd-notify.d.ts +22 -1
- package/dist/sd-notify.js +63 -10
- package/dist/sd-notify.js.map +1 -1
- package/dist/service-activation.d.ts +15 -7
- package/dist/service-activation.js +42 -26
- package/dist/service-activation.js.map +1 -1
- package/dist/service-installer.d.ts +24 -0
- package/dist/service-installer.js +49 -1
- package/dist/service-installer.js.map +1 -1
- package/dist/service-plan.d.ts +11 -0
- package/dist/service-plan.js +23 -0
- package/dist/service-plan.js.map +1 -1
- package/dist/systemd-peer-bus.d.ts +95 -0
- package/dist/systemd-peer-bus.js +430 -0
- package/dist/systemd-peer-bus.js.map +1 -0
- package/dist/systemd-runtime.d.ts +27 -1
- package/dist/systemd-runtime.js +69 -7
- package/dist/systemd-runtime.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/topic-commands.d.ts +68 -2
- package/dist/topic-commands.js +141 -27
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-jsonl.d.ts +7 -2
- package/dist/transcript-jsonl.js +13 -7
- package/dist/transcript-jsonl.js.map +1 -1
- package/dist/transcript-sources.js +6 -1
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/ui/chat-commands.js +1 -0
- package/dist/ui/chat-render.js +55 -10
- package/dist/ui/chat-store.js +69 -5
- package/dist/ui/chat-strings.js +28 -16
- package/dist/ui/chat-thread.js +132 -14
- package/dist/ui/chat-tour.js +17 -14
- package/dist/ui/panel-chat.js +16 -10
- package/dist/ui/panel-fleet.js +15 -2
- package/dist/ui/panel-log.js +55 -15
- package/dist/ui/panel-needs.js +10 -7
- package/dist/ui/panel-settings.js +58 -7
- package/dist/ui/settings-dialogs.js +11 -6
- package/dist/ui/settings-model.js +3 -1
- package/dist/ui/settings-strings.js +24 -10
- package/dist/ui/settings-token.js +7 -0
- package/dist/ui/settings-wizard.js +5 -3
- package/dist/ui/shared/app-i18n.js +1 -1
- package/dist/ui/shared/app-stream.js +4 -1
- package/dist/ui/shared/app.css +52 -10
- package/dist/ui/shared/header-tools.js +34 -14
- package/dist/ui/shared/instance-switch.js +5 -2
- package/dist/ui/shared/panel-view.js +15 -4
- package/dist/ui/shared/signin.js +15 -9
- package/dist/ui/shared/ui-icons.js +1 -0
- package/dist/ui/shared/view-strings.js +10 -2
- package/dist/ui/signin.html +8 -3
- package/dist/unrecognised-prompt.js +2 -2
- package/dist/unrecognised-prompt.js.map +1 -1
- package/dist/update-check.d.ts +31 -0
- package/dist/update-check.js +47 -0
- package/dist/update-check.js.map +1 -1
- package/dist/update-launch.d.ts +48 -1
- package/dist/update-launch.js +159 -5
- package/dist/update-launch.js.map +1 -1
- package/dist/usage/providers.d.ts +28 -8
- package/dist/usage/providers.js +96 -41
- package/dist/usage/providers.js.map +1 -1
- package/dist/view-api.js +26 -9
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +44 -2
- package/dist/web-api.js +265 -57
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +26 -1
- package/dist/web-chat-history.js +47 -8
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-commands.d.ts +39 -3
- package/dist/web-commands.js +22 -5
- package/dist/web-commands.js.map +1 -1
- package/dist/web-login.d.ts +14 -0
- package/dist/web-login.js +4 -2
- package/dist/web-login.js.map +1 -1
- package/dist/web-prefs.d.ts +18 -0
- package/dist/web-prefs.js +36 -4
- package/dist/web-prefs.js.map +1 -1
- package/dist/web-profile.d.ts +32 -0
- package/dist/web-profile.js +132 -0
- package/dist/web-profile.js.map +1 -0
- package/dist/web-session.d.ts +14 -0
- package/dist/web-session.js +10 -0
- package/dist/web-session.js.map +1 -1
- package/dist/web-upload.d.ts +119 -4
- package/dist/web-upload.js +252 -39
- package/dist/web-upload.js.map +1 -1
- package/launcher/install-admission.cjs +61 -6
- package/package.json +3 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1218 PR4: whether the Log may read a kiro instance's own history, and if not, why (the leader's ruling, 2026-10-13;
|
|
3
|
+
* sol's design check on #849). Two proofs are needed, and both must be positive — an unknown is a no:
|
|
4
|
+
*
|
|
5
|
+
* 1. **The root.** The launch's store root is the one the reader would open. Per engine: a credential profile's launch
|
|
6
|
+
* sets `XDG_DATA_HOME` itself, which proves the classic (v1) store; the TUI (v2) store's `KIRO_HOME` is inherited from
|
|
7
|
+
* the tmux server's environment and set by no launch, so it is never proven here. Launches are not changed to prove
|
|
8
|
+
* it (a prefix would move an existing instance's store, account and conversation): that is a report-only
|
|
9
|
+
* root-consistency change of its own (#849).
|
|
10
|
+
* 2. **The current session.** `--resume-id` proves where a launch started, not where the instance is now: a `/clear` or
|
|
11
|
+
* `/chat load` typed in its terminal can move it unseen, and a sibling in the same directory writes rows that look the
|
|
12
|
+
* same. No seam observes that yet (#1789), so this proof is never positive today.
|
|
13
|
+
*
|
|
14
|
+
* Until both hold, a kiro Log shows fleet events only, with the reason. There is no "may not be current" fallback,
|
|
15
|
+
* and no newest-row-for-this-directory or cross-engine guess. Fresh and legacy launches own no conversation id; V3 is
|
|
16
|
+
* not read at all.
|
|
17
|
+
*/
|
|
18
|
+
/** What an instance's last built kiro launch was: its engine, how it chose its conversation, its credential profile. */
|
|
19
|
+
export interface KiroLogLaunch {
|
|
20
|
+
engine: "v1" | "v2" | "v3" | null;
|
|
21
|
+
mode: "legacy" | "resume" | "fresh";
|
|
22
|
+
credentialProfile: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Why a kiro Log shows fleet events only (each one worded on the tab). */
|
|
25
|
+
export type KiroLogReason = "kiro_not_running" | "kiro_v3" | "kiro_engine_unknown" | "kiro_legacy" | "kiro_fresh" | "kiro_v2_root" | "kiro_no_profile" | "kiro_session_unobservable";
|
|
26
|
+
/** The proofs beyond the launch itself. Neither exists yet: see #849 (root) and #1789 (current session). */
|
|
27
|
+
export interface KiroLogProofs {
|
|
28
|
+
/** The TUI store's root, proven equal for this launch. */
|
|
29
|
+
v2Root?(): boolean;
|
|
30
|
+
/** The conversation the instance is in now is the one its launch resumed. */
|
|
31
|
+
currentSession?(): boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Today's proofs: none. */
|
|
34
|
+
export declare const KIRO_LOG_PROOFS_TODAY: KiroLogProofs;
|
|
35
|
+
export type KiroLogGate = {
|
|
36
|
+
open: false;
|
|
37
|
+
reason: KiroLogReason;
|
|
38
|
+
} | {
|
|
39
|
+
open: true;
|
|
40
|
+
engine: "v1" | "v2";
|
|
41
|
+
};
|
|
42
|
+
export declare function kiroLogGate(launch: KiroLogLaunch | null, proofs?: KiroLogProofs): KiroLogGate;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1218 PR4: whether the Log may read a kiro instance's own history, and if not, why (the leader's ruling, 2026-10-13;
|
|
3
|
+
* sol's design check on #849). Two proofs are needed, and both must be positive — an unknown is a no:
|
|
4
|
+
*
|
|
5
|
+
* 1. **The root.** The launch's store root is the one the reader would open. Per engine: a credential profile's launch
|
|
6
|
+
* sets `XDG_DATA_HOME` itself, which proves the classic (v1) store; the TUI (v2) store's `KIRO_HOME` is inherited from
|
|
7
|
+
* the tmux server's environment and set by no launch, so it is never proven here. Launches are not changed to prove
|
|
8
|
+
* it (a prefix would move an existing instance's store, account and conversation): that is a report-only
|
|
9
|
+
* root-consistency change of its own (#849).
|
|
10
|
+
* 2. **The current session.** `--resume-id` proves where a launch started, not where the instance is now: a `/clear` or
|
|
11
|
+
* `/chat load` typed in its terminal can move it unseen, and a sibling in the same directory writes rows that look the
|
|
12
|
+
* same. No seam observes that yet (#1789), so this proof is never positive today.
|
|
13
|
+
*
|
|
14
|
+
* Until both hold, a kiro Log shows fleet events only, with the reason. There is no "may not be current" fallback,
|
|
15
|
+
* and no newest-row-for-this-directory or cross-engine guess. Fresh and legacy launches own no conversation id; V3 is
|
|
16
|
+
* not read at all.
|
|
17
|
+
*/
|
|
18
|
+
/** Today's proofs: none. */
|
|
19
|
+
export const KIRO_LOG_PROOFS_TODAY = {};
|
|
20
|
+
export function kiroLogGate(launch, proofs = KIRO_LOG_PROOFS_TODAY) {
|
|
21
|
+
if (!launch)
|
|
22
|
+
return { open: false, reason: "kiro_not_running" };
|
|
23
|
+
if (launch.engine === "v3")
|
|
24
|
+
return { open: false, reason: "kiro_v3" };
|
|
25
|
+
if (!launch.engine)
|
|
26
|
+
return { open: false, reason: "kiro_engine_unknown" };
|
|
27
|
+
if (launch.mode === "legacy")
|
|
28
|
+
return { open: false, reason: "kiro_legacy" };
|
|
29
|
+
if (launch.mode !== "resume")
|
|
30
|
+
return { open: false, reason: "kiro_fresh" };
|
|
31
|
+
if (launch.engine === "v2" && proofs.v2Root?.() !== true)
|
|
32
|
+
return { open: false, reason: "kiro_v2_root" };
|
|
33
|
+
if (launch.engine === "v1" && !launch.credentialProfile)
|
|
34
|
+
return { open: false, reason: "kiro_no_profile" };
|
|
35
|
+
if (proofs.currentSession?.() !== true)
|
|
36
|
+
return { open: false, reason: "kiro_session_unobservable" };
|
|
37
|
+
return { open: true, engine: launch.engine };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=kiro-log-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kiro-log-gate.js","sourceRoot":"","sources":["../src/kiro-log-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsBH,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAkB,EAAE,CAAC;AAIvD,MAAM,UAAU,WAAW,CAAC,MAA4B,EAAE,SAAwB,qBAAqB;IACrG,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAChE,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACtE,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAC1E,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAC5E,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAC3E,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACzG,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC3G,IAAI,MAAM,CAAC,cAAc,EAAE,EAAE,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACpG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Set on the detached copy: it does the work itself (never hands off again). */
|
|
2
|
+
export declare const HANDED_OFF_ENV = "AGEND_LAUNCHD_HANDOFF";
|
|
3
|
+
export declare const HANDOFF_LOG = "service-activation.log";
|
|
4
|
+
/** A fleet agent's session (AGEND_INSTANCE_NAME, inherited by everything it runs), and not already the copy. */
|
|
5
|
+
export declare function shouldHandOff(env: NodeJS.ProcessEnv): boolean;
|
|
6
|
+
/** The part of a ChildProcess the hand-off uses: launch success and failure arrive as events (spawn / error). */
|
|
7
|
+
export interface SpawnedChild {
|
|
8
|
+
once(event: "spawn", listener: () => void): unknown;
|
|
9
|
+
once(event: "error", listener: (err: Error) => void): unknown;
|
|
10
|
+
unref(): void;
|
|
11
|
+
}
|
|
12
|
+
export interface HandOffDeps {
|
|
13
|
+
open(path: string): number;
|
|
14
|
+
write(fd: number, text: string): void;
|
|
15
|
+
close(fd: number): void;
|
|
16
|
+
spawn(command: string, args: string[], options: {
|
|
17
|
+
detached: true;
|
|
18
|
+
stdio: ["ignore", number, number];
|
|
19
|
+
env: NodeJS.ProcessEnv;
|
|
20
|
+
}): SpawnedChild;
|
|
21
|
+
now(): Date;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Start the detached copy of `self` (this CLI, these arguments). It is handed off only once it has started (the `spawn`
|
|
25
|
+
* event); a launch that fails (`error`: ENOENT, EAGAIN …) comes back as a reason, and the caller then goes on itself.
|
|
26
|
+
* This command was already allowed through the gate, so the copy carries an origin of its own: the confirmation an
|
|
27
|
+
* agent gave (or the updater's origin) does not have to be given twice.
|
|
28
|
+
*/
|
|
29
|
+
export declare function handOff(o: {
|
|
30
|
+
agendHome: string;
|
|
31
|
+
self: {
|
|
32
|
+
command: string;
|
|
33
|
+
args: string[];
|
|
34
|
+
};
|
|
35
|
+
env: NodeJS.ProcessEnv;
|
|
36
|
+
action: string;
|
|
37
|
+
}, deps: HandOffDeps): Promise<{
|
|
38
|
+
ok: true;
|
|
39
|
+
log: string;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
reason: string;
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1871: on launchd, an activation takes two steps from the client: `launchctl bootout`, then `bootstrap`. The bootout
|
|
3
|
+
* stops the fleet, and the fleet's stop kills every agent's CLI. So a command run in an agent's pane dies between the
|
|
4
|
+
* two steps: the job stays unloaded (the fleet is down), its plan stays pending, and nobody is left to say so.
|
|
5
|
+
*
|
|
6
|
+
* Run from an agent session, such a command hands itself to a detached copy instead. The copy runs in its own session,
|
|
7
|
+
* as chat /update does, so it outlives the stop. Its output goes to a log in the AgEnD home.
|
|
8
|
+
*/
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { ORIGIN_ENV } from "./fleet-control-audit.js";
|
|
11
|
+
/** Set on the detached copy: it does the work itself (never hands off again). */
|
|
12
|
+
export const HANDED_OFF_ENV = "AGEND_LAUNCHD_HANDOFF";
|
|
13
|
+
export const HANDOFF_LOG = "service-activation.log";
|
|
14
|
+
/** A fleet agent's session (AGEND_INSTANCE_NAME, inherited by everything it runs), and not already the copy. */
|
|
15
|
+
export function shouldHandOff(env) {
|
|
16
|
+
return !!(env.AGEND_INSTANCE_NAME ?? "").trim() && env[HANDED_OFF_ENV] !== "1";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Start the detached copy of `self` (this CLI, these arguments). It is handed off only once it has started (the `spawn`
|
|
20
|
+
* event); a launch that fails (`error`: ENOENT, EAGAIN …) comes back as a reason, and the caller then goes on itself.
|
|
21
|
+
* This command was already allowed through the gate, so the copy carries an origin of its own: the confirmation an
|
|
22
|
+
* agent gave (or the updater's origin) does not have to be given twice.
|
|
23
|
+
*/
|
|
24
|
+
export async function handOff(o, deps) {
|
|
25
|
+
const log = join(o.agendHome, HANDOFF_LOG);
|
|
26
|
+
let fd;
|
|
27
|
+
try {
|
|
28
|
+
fd = deps.open(log);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
return { ok: false, reason: `cannot open ${log}: ${err.message}` };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
deps.write(fd, `\n[${deps.now().toISOString()}] agend ${o.action}, handed off from ${o.env.AGEND_INSTANCE_NAME}'s session (#1871)\n`);
|
|
35
|
+
const env = { ...o.env, [HANDED_OFF_ENV]: "1", [ORIGIN_ENV]: `launchd hand-off of agend ${o.action} from ${o.env.AGEND_INSTANCE_NAME}` };
|
|
36
|
+
const child = deps.spawn(o.self.command, o.self.args, { detached: true, stdio: ["ignore", fd, fd], env });
|
|
37
|
+
const started = await new Promise(resolve => {
|
|
38
|
+
child.once("error", err => resolve(err));
|
|
39
|
+
child.once("spawn", () => resolve(null));
|
|
40
|
+
});
|
|
41
|
+
if (started)
|
|
42
|
+
return { ok: false, reason: `the detached copy did not start: ${started.message}` };
|
|
43
|
+
child.unref();
|
|
44
|
+
return { ok: true, log };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return { ok: false, reason: `the detached copy did not start: ${err.message}` };
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
try {
|
|
51
|
+
deps.close(fd);
|
|
52
|
+
}
|
|
53
|
+
catch { /* the child holds its own copy */ }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=launchd-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launchd-handoff.js","sourceRoot":"","sources":["../src/launchd-handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAEpD,gHAAgH;AAChH,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC;AACjF,CAAC;AAiBD;;;;;GAKG;AACH,MAAM,CAAC,KAA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