@agimon-ai/doompi-loop 0.0.1-alpha.76 → 0.0.1-alpha.78
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/dist/api-contracts.cjs +7 -0
- package/dist/api-contracts.d.cts +2 -0
- package/dist/api-contracts.d.mts +2 -0
- package/dist/api-contracts.mjs +2 -0
- package/dist/extensions/pi.cjs +36 -0
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.cts +5 -0
- package/dist/extensions/pi.d.cts.map +1 -0
- package/dist/extensions/pi.d.mts +5 -0
- package/dist/extensions/pi.d.mts.map +1 -0
- package/dist/extensions/pi.mjs +31 -0
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +51 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.cts +5 -0
- package/dist/extensions/server.d.cts.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +46 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +228 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/loopLaunchers.cjs +5 -0
- package/dist/loopLaunchers.d.cts +2 -0
- package/dist/loopLaunchers.d.mts +2 -0
- package/dist/loopLaunchers.mjs +2 -0
- package/dist/src/constants/loop.cjs +12 -0
- package/dist/src/constants/loop.cjs.map +1 -0
- package/dist/src/constants/loop.mjs +9 -0
- package/dist/src/constants/loop.mjs.map +1 -0
- package/dist/src/constants/piLoop.cjs +16 -0
- package/dist/src/constants/piLoop.cjs.map +1 -0
- package/dist/src/constants/piLoop.mjs +11 -0
- package/dist/src/constants/piLoop.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.cli.cjs +26 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.cli.mjs +26 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.cjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loop.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/loops.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/agent-settled.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/agent-settled.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/agent-settled.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/agent-settled.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-loop.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs +14 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs +15 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs +17 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs +18 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs.map +1 -0
- package/dist/src/schemas/apiContracts.cjs +13 -0
- package/dist/src/schemas/apiContracts.cjs.map +1 -0
- package/dist/src/schemas/apiContracts.d.cts +53 -0
- package/dist/src/schemas/apiContracts.d.cts.map +1 -0
- package/dist/src/schemas/apiContracts.d.mts +53 -0
- package/dist/src/schemas/apiContracts.d.mts.map +1 -0
- package/dist/src/schemas/apiContracts.mjs +13 -0
- package/dist/src/schemas/apiContracts.mjs.map +1 -0
- package/dist/src/schemas/loopLaunchers.cjs +17 -0
- package/dist/src/schemas/loopLaunchers.cjs.map +1 -0
- package/dist/src/schemas/loopLaunchers.d.cts +60 -0
- package/dist/src/schemas/loopLaunchers.d.cts.map +1 -0
- package/dist/src/schemas/loopLaunchers.d.mts +60 -0
- package/dist/src/schemas/loopLaunchers.d.mts.map +1 -0
- package/dist/src/schemas/loopLaunchers.mjs +15 -0
- package/dist/src/schemas/loopLaunchers.mjs.map +1 -0
- package/dist/src/services/defaultLoopLauncher/index.cjs +92 -0
- package/dist/src/services/defaultLoopLauncher/index.cjs.map +1 -0
- package/dist/src/services/defaultLoopLauncher/index.mjs +92 -0
- package/dist/src/services/defaultLoopLauncher/index.mjs.map +1 -0
- package/dist/src/services/loopCommand/index.cjs +15 -0
- package/dist/src/services/loopCommand/index.cjs.map +1 -0
- package/dist/src/services/loopCommand/index.mjs +15 -0
- package/dist/src/services/loopCommand/index.mjs.map +1 -0
- package/dist/src/services/loopLaunchers/index.cjs +180 -0
- package/dist/src/services/loopLaunchers/index.cjs.map +1 -0
- package/dist/src/services/loopLaunchers/index.mjs +180 -0
- package/dist/src/services/loopLaunchers/index.mjs.map +1 -0
- package/dist/src/services/serverRuntime/index.cjs +293 -0
- package/dist/src/services/serverRuntime/index.cjs.map +1 -0
- package/dist/src/services/serverRuntime/index.mjs +293 -0
- package/dist/src/services/serverRuntime/index.mjs.map +1 -0
- package/dist/src/tui/leader.cjs +36 -0
- package/dist/src/tui/leader.cjs.map +1 -0
- package/dist/src/tui/leader.mjs +36 -0
- package/dist/src/tui/leader.mjs.map +1 -0
- package/dist/src/tui/loopListOverlay.cjs +101 -0
- package/dist/src/tui/loopListOverlay.cjs.map +1 -0
- package/dist/src/tui/loopListOverlay.mjs +100 -0
- package/dist/src/tui/loopListOverlay.mjs.map +1 -0
- package/dist/src/tui/loopRuntime.cjs +256 -0
- package/dist/src/tui/loopRuntime.cjs.map +1 -0
- package/dist/src/tui/loopRuntime.mjs +256 -0
- package/dist/src/tui/loopRuntime.mjs.map +1 -0
- package/dist/src/tui/startLoopOverlay.cjs +71 -0
- package/dist/src/tui/startLoopOverlay.cjs.map +1 -0
- package/dist/src/tui/startLoopOverlay.mjs +70 -0
- package/dist/src/tui/startLoopOverlay.mjs.map +1 -0
- package/dist/src/types/loopView.cjs +19 -0
- package/dist/src/types/loopView.cjs.map +1 -0
- package/dist/src/types/loopView.mjs +18 -0
- package/dist/src/types/loopView.mjs.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
//#region src/services/loopLaunchers/index.ts
|
|
2
|
+
const MAX_ID_LENGTH = 256;
|
|
3
|
+
const MAX_GENERATION_LENGTH = 256;
|
|
4
|
+
const LAUNCHER_ID_LABEL = "loop launcher id";
|
|
5
|
+
const INSTANCE_ID_LABEL = "loop instance id";
|
|
6
|
+
function validId(value, label) {
|
|
7
|
+
const normalized = value.trim();
|
|
8
|
+
let hasControl = false;
|
|
9
|
+
for (const character of normalized) {
|
|
10
|
+
const code = character.codePointAt(0);
|
|
11
|
+
if (code !== void 0 && (code <= 31 || code === 127)) {
|
|
12
|
+
hasControl = true;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!normalized || normalized.length > MAX_ID_LENGTH || hasControl) throw new Error(`Invalid ${label}.`);
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
function snapshot(entry) {
|
|
20
|
+
return {
|
|
21
|
+
instanceId: entry.instanceId,
|
|
22
|
+
launcherId: entry.launcher.definition.id,
|
|
23
|
+
launcherLabel: entry.launcher.definition.label,
|
|
24
|
+
...entry.handle?.label ? { label: entry.handle.label } : {},
|
|
25
|
+
...entry.handle?.detail ? { detail: entry.handle.detail } : {},
|
|
26
|
+
state: entry.state,
|
|
27
|
+
...entry.startedAt ? { startedAt: entry.startedAt } : {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Creates the provider-owned launcher registry for one active Doom session. */
|
|
31
|
+
function createDoomLoopLaunchersService({ generation, createInstanceId, timestamp }) {
|
|
32
|
+
if (!generation || generation.length > MAX_GENERATION_LENGTH) throw new TypeError("Doom loop launchers require a valid generation.");
|
|
33
|
+
const launchers = /* @__PURE__ */ new Map();
|
|
34
|
+
const instances = /* @__PURE__ */ new Map();
|
|
35
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
36
|
+
let registrationSequence = 0;
|
|
37
|
+
let disposed = false;
|
|
38
|
+
const ensureActive = () => {
|
|
39
|
+
if (disposed) throw new Error("The Doom loop-launchers service is disposed.");
|
|
40
|
+
};
|
|
41
|
+
const notify = () => {
|
|
42
|
+
for (const listener of listeners) listener();
|
|
43
|
+
};
|
|
44
|
+
const stopEntry = async (entry, reason) => {
|
|
45
|
+
if (instances.get(entry.instanceId) !== entry) return;
|
|
46
|
+
entry.state = "stopping";
|
|
47
|
+
entry.abortController.abort(reason);
|
|
48
|
+
notify();
|
|
49
|
+
try {
|
|
50
|
+
await entry.handle?.stop(reason);
|
|
51
|
+
} finally {
|
|
52
|
+
if (instances.get(entry.instanceId) === entry) instances.delete(entry.instanceId);
|
|
53
|
+
notify();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return Object.freeze({
|
|
57
|
+
generation,
|
|
58
|
+
register(definition) {
|
|
59
|
+
ensureActive();
|
|
60
|
+
const id = validId(definition.id, LAUNCHER_ID_LABEL);
|
|
61
|
+
if (launchers.has(id)) throw new Error(`Loop launcher '${id}' is already registered.`);
|
|
62
|
+
const token = Symbol(id);
|
|
63
|
+
const entry = {
|
|
64
|
+
token,
|
|
65
|
+
definition: {
|
|
66
|
+
...definition,
|
|
67
|
+
id
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
launchers.set(id, entry);
|
|
71
|
+
registrationSequence += 1;
|
|
72
|
+
notify();
|
|
73
|
+
let registrationDisposed = false;
|
|
74
|
+
return Object.freeze({
|
|
75
|
+
id,
|
|
76
|
+
generation: `${generation}:launcher:${registrationSequence}`,
|
|
77
|
+
async dispose(reason = "Loop launcher disposed.") {
|
|
78
|
+
if (registrationDisposed) return;
|
|
79
|
+
registrationDisposed = true;
|
|
80
|
+
if (launchers.get(id)?.token !== token) return;
|
|
81
|
+
launchers.delete(id);
|
|
82
|
+
const owned = [...instances.values()].filter((instance) => instance.launcher.token === token);
|
|
83
|
+
await Promise.allSettled(owned.map((instance) => stopEntry(instance, reason)));
|
|
84
|
+
notify();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
listLaunchers() {
|
|
89
|
+
ensureActive();
|
|
90
|
+
return [...launchers.values()].map(({ definition }) => ({
|
|
91
|
+
id: definition.id,
|
|
92
|
+
source: definition.source,
|
|
93
|
+
label: definition.label,
|
|
94
|
+
...definition.description ? { description: definition.description } : {}
|
|
95
|
+
})).sort((left, right) => left.label.localeCompare(right.label) || left.id.localeCompare(right.id));
|
|
96
|
+
},
|
|
97
|
+
listInstances() {
|
|
98
|
+
ensureActive();
|
|
99
|
+
return [...instances.values()].map(snapshot).sort((left, right) => left.instanceId.localeCompare(right.instanceId));
|
|
100
|
+
},
|
|
101
|
+
subscribe(listener) {
|
|
102
|
+
ensureActive();
|
|
103
|
+
listeners.add(listener);
|
|
104
|
+
let subscribed = true;
|
|
105
|
+
return () => {
|
|
106
|
+
if (!subscribed) return;
|
|
107
|
+
subscribed = false;
|
|
108
|
+
listeners.delete(listener);
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
async launch(launcherId, options) {
|
|
112
|
+
ensureActive();
|
|
113
|
+
const normalizedLauncherId = validId(launcherId, LAUNCHER_ID_LABEL);
|
|
114
|
+
const launcher = launchers.get(normalizedLauncherId);
|
|
115
|
+
if (!launcher) throw new Error(`Loop launcher '${normalizedLauncherId}' is unavailable.`);
|
|
116
|
+
const instanceId = validId(options?.instanceId ?? createInstanceId(), INSTANCE_ID_LABEL);
|
|
117
|
+
if (instances.has(instanceId)) throw new Error(`Loop instance '${instanceId}' already exists.`);
|
|
118
|
+
const entry = {
|
|
119
|
+
instanceId,
|
|
120
|
+
launcher,
|
|
121
|
+
abortController: new AbortController(),
|
|
122
|
+
state: "starting"
|
|
123
|
+
};
|
|
124
|
+
instances.set(instanceId, entry);
|
|
125
|
+
notify();
|
|
126
|
+
try {
|
|
127
|
+
const handle = await launcher.definition.launch({
|
|
128
|
+
instanceId,
|
|
129
|
+
signal: entry.abortController.signal
|
|
130
|
+
});
|
|
131
|
+
const active = !disposed && instances.get(instanceId) === entry && !entry.abortController.signal.aborted;
|
|
132
|
+
if (!handle) {
|
|
133
|
+
if (instances.get(instanceId) === entry) instances.delete(instanceId);
|
|
134
|
+
notify();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (!active || handle.instanceId !== instanceId) {
|
|
138
|
+
await handle.stop(active ? "Loop launcher returned a mismatched instance id." : "Loop launch was cancelled.");
|
|
139
|
+
if (instances.get(instanceId) === entry) instances.delete(instanceId);
|
|
140
|
+
notify();
|
|
141
|
+
if (active) throw new Error(`Loop launcher '${normalizedLauncherId}' returned a mismatched instance id.`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
entry.handle = handle;
|
|
145
|
+
entry.state = "running";
|
|
146
|
+
entry.startedAt = timestamp();
|
|
147
|
+
notify();
|
|
148
|
+
return snapshot(entry);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const cancelled = entry.abortController.signal.aborted || disposed;
|
|
151
|
+
if (instances.get(instanceId) === entry) instances.delete(instanceId);
|
|
152
|
+
notify();
|
|
153
|
+
if (cancelled) return void 0;
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async stop(instanceId, reason) {
|
|
158
|
+
ensureActive();
|
|
159
|
+
const entry = instances.get(validId(instanceId, INSTANCE_ID_LABEL));
|
|
160
|
+
if (!entry) return false;
|
|
161
|
+
await stopEntry(entry, reason);
|
|
162
|
+
return true;
|
|
163
|
+
},
|
|
164
|
+
async stopAll(reason) {
|
|
165
|
+
if (disposed && instances.size === 0) return;
|
|
166
|
+
await Promise.allSettled([...instances.values()].map((entry) => stopEntry(entry, reason)));
|
|
167
|
+
},
|
|
168
|
+
async dispose(reason = "Doom loop-launchers service disposed.") {
|
|
169
|
+
if (disposed) return;
|
|
170
|
+
disposed = true;
|
|
171
|
+
launchers.clear();
|
|
172
|
+
await Promise.allSettled([...instances.values()].map((entry) => stopEntry(entry, reason)));
|
|
173
|
+
listeners.clear();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { createDoomLoopLaunchersService };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/loopLaunchers/index.ts"],"sourcesContent":["import type {\n DoomLoopLaunchersService,\n LoopInstanceSnapshot,\n LoopLauncherDefinition,\n LoopLauncherRegistration,\n StoppableLoop,\n} from '../../schemas/loopLaunchers';\n\nconst MAX_ID_LENGTH = 256;\nconst MAX_GENERATION_LENGTH = 256;\nconst LAUNCHER_ID_LABEL = 'loop launcher id';\nconst INSTANCE_ID_LABEL = 'loop instance id';\n\ninterface LauncherEntry {\n readonly token: symbol;\n readonly definition: LoopLauncherDefinition;\n}\n\ninterface InstanceEntry {\n readonly instanceId: string;\n readonly launcher: LauncherEntry;\n readonly abortController: AbortController;\n state: LoopInstanceSnapshot['state'];\n handle?: StoppableLoop;\n startedAt?: string;\n}\n\nexport interface LoopLaunchersDependencies {\n readonly generation: string;\n readonly createInstanceId: () => string;\n readonly timestamp: () => string;\n}\n\nfunction validId(value: string, label: string): string {\n const normalized = value.trim();\n let hasControl = false;\n for (const character of normalized) {\n const code = character.codePointAt(0);\n if (code !== undefined && (code <= 0x1f || code === 0x7f)) {\n hasControl = true;\n break;\n }\n }\n if (!normalized || normalized.length > MAX_ID_LENGTH || hasControl) throw new Error(`Invalid ${label}.`);\n return normalized;\n}\n\nfunction snapshot(entry: InstanceEntry): LoopInstanceSnapshot {\n return {\n instanceId: entry.instanceId,\n launcherId: entry.launcher.definition.id,\n launcherLabel: entry.launcher.definition.label,\n ...(entry.handle?.label ? { label: entry.handle.label } : {}),\n ...(entry.handle?.detail ? { detail: entry.handle.detail } : {}),\n state: entry.state,\n ...(entry.startedAt ? { startedAt: entry.startedAt } : {}),\n };\n}\n\n/** Creates the provider-owned launcher registry for one active Doom session. */\nexport function createDoomLoopLaunchersService({\n generation,\n createInstanceId,\n timestamp,\n}: LoopLaunchersDependencies): DoomLoopLaunchersService {\n if (!generation || generation.length > MAX_GENERATION_LENGTH) {\n throw new TypeError('Doom loop launchers require a valid generation.');\n }\n\n const launchers = new Map<string, LauncherEntry>();\n const instances = new Map<string, InstanceEntry>();\n const listeners = new Set<() => void>();\n let registrationSequence = 0;\n let disposed = false;\n\n const ensureActive = (): void => {\n if (disposed) throw new Error('The Doom loop-launchers service is disposed.');\n };\n const notify = (): void => {\n for (const listener of listeners) listener();\n };\n const stopEntry = async (entry: InstanceEntry, reason?: string): Promise<void> => {\n if (instances.get(entry.instanceId) !== entry) return;\n entry.state = 'stopping';\n entry.abortController.abort(reason);\n notify();\n try {\n await entry.handle?.stop(reason);\n } finally {\n if (instances.get(entry.instanceId) === entry) instances.delete(entry.instanceId);\n notify();\n }\n };\n\n const service: DoomLoopLaunchersService = {\n generation,\n register(definition): LoopLauncherRegistration {\n ensureActive();\n const id = validId(definition.id, LAUNCHER_ID_LABEL);\n if (launchers.has(id)) throw new Error(`Loop launcher '${id}' is already registered.`);\n const token = Symbol(id);\n const entry: LauncherEntry = { token, definition: { ...definition, id } };\n launchers.set(id, entry);\n registrationSequence += 1;\n notify();\n let registrationDisposed = false;\n return Object.freeze({\n id,\n generation: `${generation}:launcher:${registrationSequence}`,\n async dispose(reason = 'Loop launcher disposed.'): Promise<void> {\n if (registrationDisposed) return;\n registrationDisposed = true;\n if (launchers.get(id)?.token !== token) return;\n launchers.delete(id);\n const owned = [...instances.values()].filter((instance) => instance.launcher.token === token);\n await Promise.allSettled(owned.map((instance) => stopEntry(instance, reason)));\n notify();\n },\n });\n },\n listLaunchers() {\n ensureActive();\n return [...launchers.values()]\n .map(({ definition }) => ({\n id: definition.id,\n source: definition.source,\n label: definition.label,\n ...(definition.description ? { description: definition.description } : {}),\n }))\n .sort((left, right) => left.label.localeCompare(right.label) || left.id.localeCompare(right.id));\n },\n listInstances() {\n ensureActive();\n return [...instances.values()]\n .map(snapshot)\n .sort((left, right) => left.instanceId.localeCompare(right.instanceId));\n },\n subscribe(listener) {\n ensureActive();\n listeners.add(listener);\n let subscribed = true;\n return () => {\n if (!subscribed) return;\n subscribed = false;\n listeners.delete(listener);\n };\n },\n async launch(launcherId, options) {\n ensureActive();\n const normalizedLauncherId = validId(launcherId, LAUNCHER_ID_LABEL);\n const launcher = launchers.get(normalizedLauncherId);\n if (!launcher) throw new Error(`Loop launcher '${normalizedLauncherId}' is unavailable.`);\n const instanceId = validId(options?.instanceId ?? createInstanceId(), INSTANCE_ID_LABEL);\n if (instances.has(instanceId)) throw new Error(`Loop instance '${instanceId}' already exists.`);\n const entry: InstanceEntry = { instanceId, launcher, abortController: new AbortController(), state: 'starting' };\n instances.set(instanceId, entry);\n notify();\n try {\n const handle = await launcher.definition.launch({ instanceId, signal: entry.abortController.signal });\n const active = !disposed && instances.get(instanceId) === entry && !entry.abortController.signal.aborted;\n if (!handle) {\n if (instances.get(instanceId) === entry) instances.delete(instanceId);\n notify();\n return undefined;\n }\n if (!active || handle.instanceId !== instanceId) {\n await handle.stop(active ? 'Loop launcher returned a mismatched instance id.' : 'Loop launch was cancelled.');\n if (instances.get(instanceId) === entry) instances.delete(instanceId);\n notify();\n if (active) throw new Error(`Loop launcher '${normalizedLauncherId}' returned a mismatched instance id.`);\n return undefined;\n }\n entry.handle = handle;\n entry.state = 'running';\n entry.startedAt = timestamp();\n notify();\n return snapshot(entry);\n } catch (error) {\n const cancelled = entry.abortController.signal.aborted || disposed;\n if (instances.get(instanceId) === entry) instances.delete(instanceId);\n notify();\n if (cancelled) return undefined;\n throw error;\n }\n },\n async stop(instanceId, reason) {\n ensureActive();\n const entry = instances.get(validId(instanceId, INSTANCE_ID_LABEL));\n if (!entry) return false;\n await stopEntry(entry, reason);\n return true;\n },\n async stopAll(reason) {\n if (disposed && instances.size === 0) return;\n await Promise.allSettled([...instances.values()].map((entry) => stopEntry(entry, reason)));\n },\n async dispose(reason = 'Doom loop-launchers service disposed.') {\n if (disposed) return;\n disposed = true;\n launchers.clear();\n await Promise.allSettled([...instances.values()].map((entry) => stopEntry(entry, reason)));\n listeners.clear();\n },\n };\n\n return Object.freeze(service);\n}\n"],"mappings":";AAQA,MAAM,gBAAgB;AACtB,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAsB1B,SAAS,QAAQ,OAAe,OAAuB;CACrD,MAAM,aAAa,MAAM,KAAK;CAC9B,IAAI,aAAa;CACjB,KAAK,MAAM,aAAa,YAA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AM,QAAQ;IACd,MAAM,YAAY,UAAU;IAC5B,OAAO;IACP,OAAO,SAAS,KAAK;GACvB,SAAS,OAAO;IACd,MAAM,YAAY,MAAM,gBAAgB,OAAO,WAAW;IAC1D,IAAI,UAAU,IAAI,UAAU,MAAM,OAAO,UAAU,OAAO,UAAU;IACpE,OAAO;IACP,IAAI,WAAW,OAAO,KAAA;IACtB,MAAM;GACR;EACF;EACA,MAAM,KAAK,YAAY,QAAQ;GAC7B,aAAa;GACb,MAAM,QAAQ,UAAU,IAAI,QAAQ,YAAY,iBAAiB,CAAC;GAClE,IAAI,CAAC,OAAO,OAAO;GACnB,MAAM,UAAU,OAAO,MAAM;GAC7B,OAAO;EACT;EACA,MAAM,QAAQ,QAAQ;GACpB,IAAI,YAAY,UAAU,SAAS,GAAG;GACtC,MAAM,QAAQ,WAAW,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU,UAAU,OAAO,MAAM,CAAC,CAAC;EAC3F;EACA,MAAM,QAAQ,SAAS,yCAAyC;GAC9D,IAAI,UAAU;GACd,WAAW;GACX,UAAU,MAAM;GAChB,MAAM,QAAQ,WAAW,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU,UAAU,OAAO,MAAM,CAAC,CAAC;GACzF,UAAU,MAAM;EAClB;CAGyB,CAAC;AAC9B"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
const require_loop = require("../../constants/loop.cjs");
|
|
2
|
+
const require_index = require("../loopLaunchers/index.cjs");
|
|
3
|
+
const require_loopView = require("../../types/loopView.cjs");
|
|
4
|
+
let _agimon_ai_doompi_minor_mode = require("@agimon-ai/doompi-minor-mode");
|
|
5
|
+
let _agimon_ai_doompi_core_server_facet = require("@agimon-ai/doompi-core/server-facet");
|
|
6
|
+
//#region src/services/serverRuntime/index.ts
|
|
7
|
+
const SOURCE = "@agimon-ai/doompi-loop";
|
|
8
|
+
const MODE_ID = "loop.active";
|
|
9
|
+
const DEFAULT_LAUNCHER_ID = "doompi.default";
|
|
10
|
+
const DEFAULT_INTERVAL_SECONDS = 300;
|
|
11
|
+
const MIN_INTERVAL_SECONDS = 30;
|
|
12
|
+
const MAX_INTERVAL_SECONDS = 3600;
|
|
13
|
+
function notify(context, body, level = "info") {
|
|
14
|
+
return Promise.resolve(context.client.notify({
|
|
15
|
+
body,
|
|
16
|
+
level
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function numberInput(value, fallback) {
|
|
20
|
+
if (typeof value !== "string" || value.trim() === "") return fallback;
|
|
21
|
+
const parsed = Number(value);
|
|
22
|
+
if (!Number.isInteger(parsed) || parsed < MIN_INTERVAL_SECONDS || parsed > MAX_INTERVAL_SECONDS) throw new Error(`Interval must be between ${MIN_INTERVAL_SECONDS} and ${MAX_INTERVAL_SECONDS} seconds.`);
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
function createSessionState(host) {
|
|
26
|
+
let launchers;
|
|
27
|
+
let defaultRegistration;
|
|
28
|
+
let unsubscribe;
|
|
29
|
+
let modeOwner;
|
|
30
|
+
const modeSelected = () => (host.context.selection.state?.["minor-mode"] ?? []).includes(MODE_ID);
|
|
31
|
+
const modeState = () => {
|
|
32
|
+
const launcherCount = launchers?.listLaunchers().length ?? 0;
|
|
33
|
+
const active = (launchers?.listInstances().length ?? 0) > 0;
|
|
34
|
+
const canStart = launcherCount > 0 || !modeSelected();
|
|
35
|
+
return {
|
|
36
|
+
activation: active ? "active" : "inactive",
|
|
37
|
+
condition: launchers?.listInstances().some(({ state }) => state !== "running") ? "queued" : "ready",
|
|
38
|
+
...active ? {
|
|
39
|
+
detail: `${launchers?.listInstances().length} active`,
|
|
40
|
+
color: "warning"
|
|
41
|
+
} : {},
|
|
42
|
+
actions: [{
|
|
43
|
+
id: "start",
|
|
44
|
+
enabled: canStart,
|
|
45
|
+
...canStart ? {} : { disabledReason: "No loop launchers are registered." }
|
|
46
|
+
}, {
|
|
47
|
+
id: "stop",
|
|
48
|
+
enabled: active,
|
|
49
|
+
...active ? {} : { disabledReason: "No loops are active." }
|
|
50
|
+
}]
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The instances the activity dock lists.
|
|
55
|
+
*
|
|
56
|
+
* An empty list publishes an empty value rather than nothing, because the key
|
|
57
|
+
* being present is what keeps the group on screen as a launcher. The group
|
|
58
|
+
* declares no `hideWhenEmpty`, so an empty value is a header with no rows.
|
|
59
|
+
*/
|
|
60
|
+
const publishView = () => host.context.client.setStatus(require_loopView.LOOP_VIEW_STATUS_KEY, require_loopView.formatLoopStatusView(launchers?.listInstances() ?? []));
|
|
61
|
+
/** Both surfaces a loop shows up on: the minor-mode catalog and the activity dock. */
|
|
62
|
+
const publishMode = () => {
|
|
63
|
+
modeOwner?.publish();
|
|
64
|
+
publishView();
|
|
65
|
+
};
|
|
66
|
+
const startActivity = async (execution) => {
|
|
67
|
+
if (launchers !== void 0) return async () => void 0;
|
|
68
|
+
const dependencies = {
|
|
69
|
+
generation: `${execution.sessionId}:loop-launchers`,
|
|
70
|
+
createInstanceId: () => crypto.randomUUID(),
|
|
71
|
+
timestamp: () => (/* @__PURE__ */ new Date()).toISOString()
|
|
72
|
+
};
|
|
73
|
+
const service = require_index.createDoomLoopLaunchersService(dependencies);
|
|
74
|
+
const registration = service.register({
|
|
75
|
+
id: DEFAULT_LAUNCHER_ID,
|
|
76
|
+
source: SOURCE,
|
|
77
|
+
label: "Default loop",
|
|
78
|
+
description: "Run a prompt in this session on an interval.",
|
|
79
|
+
async launch({ instanceId, signal }) {
|
|
80
|
+
const promptValue = await execution.client.request({
|
|
81
|
+
kind: "input",
|
|
82
|
+
title: "Loop prompt",
|
|
83
|
+
multiline: true
|
|
84
|
+
}, signal);
|
|
85
|
+
const prompt = typeof promptValue === "string" ? promptValue.trim() : "";
|
|
86
|
+
if (!prompt || signal.aborted) return void 0;
|
|
87
|
+
const interval = numberInput(await execution.client.request({
|
|
88
|
+
kind: "input",
|
|
89
|
+
title: "Loop interval in seconds",
|
|
90
|
+
initialValue: String(DEFAULT_INTERVAL_SECONDS)
|
|
91
|
+
}, signal), DEFAULT_INTERVAL_SECONDS);
|
|
92
|
+
let stopped = false;
|
|
93
|
+
const tick = () => {
|
|
94
|
+
if (stopped || signal.aborted) return;
|
|
95
|
+
execution.session.prompt(prompt).catch((error) => {
|
|
96
|
+
notify(execution, `Loop pass failed: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const timer = setInterval(tick, interval * 1e3);
|
|
100
|
+
timer.unref?.();
|
|
101
|
+
tick();
|
|
102
|
+
return {
|
|
103
|
+
instanceId,
|
|
104
|
+
label: "Default loop",
|
|
105
|
+
detail: `every ${interval}s`,
|
|
106
|
+
stop() {
|
|
107
|
+
stopped = true;
|
|
108
|
+
clearInterval(timer);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
launchers = service;
|
|
114
|
+
defaultRegistration = registration;
|
|
115
|
+
unsubscribe = service.subscribe(publishMode);
|
|
116
|
+
publishMode();
|
|
117
|
+
return async () => {
|
|
118
|
+
unsubscribe?.();
|
|
119
|
+
unsubscribe = void 0;
|
|
120
|
+
await registration.dispose("Headless loop activity stopped.");
|
|
121
|
+
await service.dispose("Headless loop activity stopped.");
|
|
122
|
+
if (launchers === service) launchers = void 0;
|
|
123
|
+
if (defaultRegistration === registration) defaultRegistration = void 0;
|
|
124
|
+
publishMode();
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
modeOwner = (0, _agimon_ai_doompi_minor_mode.defineMinorMode)({
|
|
128
|
+
descriptor: {
|
|
129
|
+
source: SOURCE,
|
|
130
|
+
id: MODE_ID,
|
|
131
|
+
label: "Loop",
|
|
132
|
+
description: "Session-scoped recurring prompt loops.",
|
|
133
|
+
order: 60,
|
|
134
|
+
actions: [{
|
|
135
|
+
id: "start",
|
|
136
|
+
label: "Start",
|
|
137
|
+
description: "Start a loop with a registered launcher.",
|
|
138
|
+
contexts: ["headless"],
|
|
139
|
+
parameters: [{
|
|
140
|
+
name: "launcherId",
|
|
141
|
+
label: "Launcher",
|
|
142
|
+
kind: "string",
|
|
143
|
+
required: true,
|
|
144
|
+
minLength: 1
|
|
145
|
+
}, {
|
|
146
|
+
name: "instanceId",
|
|
147
|
+
label: "Instance ID",
|
|
148
|
+
kind: "string",
|
|
149
|
+
required: false,
|
|
150
|
+
minLength: 1
|
|
151
|
+
}]
|
|
152
|
+
}, {
|
|
153
|
+
id: "stop",
|
|
154
|
+
label: "Stop",
|
|
155
|
+
description: "Stop one active loop instance.",
|
|
156
|
+
contexts: ["headless"],
|
|
157
|
+
parameters: [{
|
|
158
|
+
name: "instanceId",
|
|
159
|
+
label: "Instance ID",
|
|
160
|
+
kind: "string",
|
|
161
|
+
required: true,
|
|
162
|
+
minLength: 1
|
|
163
|
+
}, {
|
|
164
|
+
name: "reason",
|
|
165
|
+
label: "Reason",
|
|
166
|
+
kind: "string",
|
|
167
|
+
required: false,
|
|
168
|
+
minLength: 1
|
|
169
|
+
}]
|
|
170
|
+
}]
|
|
171
|
+
},
|
|
172
|
+
state: modeState,
|
|
173
|
+
async handleAction(_runtime, actionId, argumentsValue, { signal }) {
|
|
174
|
+
signal.throwIfAborted();
|
|
175
|
+
if (actionId === "start" && !launchers) {
|
|
176
|
+
const modes = (host.context.selection.state?.["minor-mode"] ?? []).filter((mode) => mode !== MODE_ID);
|
|
177
|
+
await host.changeSelection({
|
|
178
|
+
axis: "state",
|
|
179
|
+
key: "minor-mode",
|
|
180
|
+
values: [...modes, MODE_ID]
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!launchers) throw new Error("Loop activity is not active.");
|
|
184
|
+
if (actionId === "start") {
|
|
185
|
+
const instance = await launchers.launch(String(argumentsValue.launcherId ?? ""), argumentsValue.instanceId ? { instanceId: String(argumentsValue.instanceId) } : {});
|
|
186
|
+
publishMode();
|
|
187
|
+
return { message: instance ? `Loop '${instance.instanceId}' started.` : "Loop launch was cancelled." };
|
|
188
|
+
}
|
|
189
|
+
if (actionId === "stop") {
|
|
190
|
+
const stopped = await launchers.stop(String(argumentsValue.instanceId ?? ""), String(argumentsValue.reason ?? "Stopped through minor_mode."));
|
|
191
|
+
if (stopped && launchers.listInstances().length === 0) {
|
|
192
|
+
const modes = (host.context.selection.state?.["minor-mode"] ?? []).filter((mode) => mode !== MODE_ID);
|
|
193
|
+
await host.changeSelection({
|
|
194
|
+
axis: "state",
|
|
195
|
+
key: "minor-mode",
|
|
196
|
+
values: modes
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
publishMode();
|
|
200
|
+
return { message: stopped ? "Loop stopped." : "Loop instance was not active." };
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`Unknown loop mode action: ${actionId}`);
|
|
203
|
+
}
|
|
204
|
+
}).createOwner(void 0);
|
|
205
|
+
return {
|
|
206
|
+
services: [(0, _agimon_ai_doompi_minor_mode.serverMinorModes)([modeOwner])],
|
|
207
|
+
resources: [{
|
|
208
|
+
when: {
|
|
209
|
+
state: { "minor-mode": MODE_ID },
|
|
210
|
+
attribution: {
|
|
211
|
+
kind: "minor",
|
|
212
|
+
mode: MODE_ID
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
name: "doompi-use-loop",
|
|
216
|
+
kind: "skill",
|
|
217
|
+
read: () => (0, _agimon_ai_doompi_core_server_facet.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/doompi-use-loop/SKILL.md")
|
|
218
|
+
}],
|
|
219
|
+
activities: [{
|
|
220
|
+
when: {
|
|
221
|
+
state: { "minor-mode": MODE_ID },
|
|
222
|
+
attribution: {
|
|
223
|
+
kind: "minor",
|
|
224
|
+
mode: MODE_ID
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
name: "doompi-loop",
|
|
228
|
+
start: startActivity
|
|
229
|
+
}],
|
|
230
|
+
commands: [{
|
|
231
|
+
name: require_loop.START_COMMAND_NAME,
|
|
232
|
+
description: "Start a registered loop.",
|
|
233
|
+
async execute(args, execution) {
|
|
234
|
+
if (!launchers) {
|
|
235
|
+
const modes = host.context.selection.state?.["minor-mode"] ?? [];
|
|
236
|
+
await host.changeSelection({
|
|
237
|
+
axis: "state",
|
|
238
|
+
key: "minor-mode",
|
|
239
|
+
values: [...modes, MODE_ID]
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (!launchers) throw new Error("Loop activity is not active.");
|
|
243
|
+
const available = launchers.listLaunchers();
|
|
244
|
+
const selected = args.trim() || await execution.client.request({
|
|
245
|
+
kind: "select",
|
|
246
|
+
title: "Choose a loop launcher",
|
|
247
|
+
options: available.map((entry) => ({
|
|
248
|
+
label: entry.label,
|
|
249
|
+
value: entry.id
|
|
250
|
+
}))
|
|
251
|
+
});
|
|
252
|
+
const launcherId = args.trim() || (typeof selected === "string" ? selected : "");
|
|
253
|
+
if (!launcherId) return;
|
|
254
|
+
const instance = await launchers.launch(launcherId);
|
|
255
|
+
publishMode();
|
|
256
|
+
await notify(execution, instance ? `Loop '${instance.instanceId}' started.` : "Loop launch was cancelled.");
|
|
257
|
+
}
|
|
258
|
+
}, {
|
|
259
|
+
name: require_loop.LIST_COMMAND_NAME,
|
|
260
|
+
description: "List and stop active loops.",
|
|
261
|
+
async execute(_args, execution) {
|
|
262
|
+
const instances = launchers?.listInstances() ?? [];
|
|
263
|
+
await notify(execution, instances.length === 0 ? "No loops are active." : JSON.stringify(instances, null, 2));
|
|
264
|
+
}
|
|
265
|
+
}],
|
|
266
|
+
hooks: [{
|
|
267
|
+
event: "session_start",
|
|
268
|
+
async handle() {
|
|
269
|
+
publishView();
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
when: {
|
|
273
|
+
state: { "minor-mode": MODE_ID },
|
|
274
|
+
attribution: {
|
|
275
|
+
kind: "minor",
|
|
276
|
+
mode: MODE_ID
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
event: "session_shutdown",
|
|
280
|
+
async handle() {
|
|
281
|
+
await launchers?.stopAll("Headless session shutdown.");
|
|
282
|
+
}
|
|
283
|
+
}],
|
|
284
|
+
async onDispose() {
|
|
285
|
+
await defaultRegistration?.dispose("Headless loop facet disposed.");
|
|
286
|
+
await launchers?.dispose("Headless loop facet disposed.");
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
exports.createSessionState = createSessionState;
|
|
292
|
+
|
|
293
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["LOOP_VIEW_STATUS_KEY","formatLoopStatusView","createDoomLoopLaunchersService","defineMinorMode","serverMinorModes","readPackageResource","START_COMMAND_NAME","LIST_COMMAND_NAME"],"sources":["../../../../src/services/serverRuntime/index.ts"],"sourcesContent":["import { serverMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner, type MinorModeState } from '@agimon-ai/doompi-minor-mode';\n\nimport { LIST_COMMAND_NAME, START_COMMAND_NAME } from '../../constants/loop';\nimport type { DoomLoopLaunchersService, LoopLauncherRegistration, StoppableLoop } from '../../schemas/loopLaunchers';\nimport { createDoomLoopLaunchersService, type LoopLaunchersDependencies } from '../../services/loopLaunchers';\nimport { formatLoopStatusView, LOOP_VIEW_STATUS_KEY } from '../../types/loopView';\n\nconst SOURCE = '@agimon-ai/doompi-loop';\nconst MODE_ID = 'loop.active';\nconst DEFAULT_LAUNCHER_ID = 'doompi.default';\nconst DEFAULT_INTERVAL_SECONDS = 300;\nconst MIN_INTERVAL_SECONDS = 30;\nconst MAX_INTERVAL_SECONDS = 3600;\n\nfunction notify(\n context: {\n client: { notify(request: { body: string; level?: 'info' | 'warning' | 'error' }): void | Promise<void> };\n },\n body: string,\n level: 'info' | 'warning' | 'error' = 'info',\n): Promise<void> {\n return Promise.resolve(context.client.notify({ body, level }));\n}\n\nfunction numberInput(value: unknown, fallback: number): number {\n if (typeof value !== 'string' || value.trim() === '') return fallback;\n const parsed = Number(value);\n if (!Number.isInteger(parsed) || parsed < MIN_INTERVAL_SECONDS || parsed > MAX_INTERVAL_SECONDS) {\n throw new Error(`Interval must be between ${MIN_INTERVAL_SECONDS} and ${MAX_INTERVAL_SECONDS} seconds.`);\n }\n return parsed;\n}\n\nimport { type DoomHeadlessExecutionContext, type DoomHeadlessHostService } from '@agimon-ai/doompi-core/headless';\nimport { readPackageResource, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nexport function createSessionState(host: DoomHeadlessHostService): DoomServerSessionPlugin {\n let launchers: DoomLoopLaunchersService | undefined;\n let defaultRegistration: LoopLauncherRegistration | undefined;\n let unsubscribe: (() => void) | undefined;\n let modeOwner: MinorModeOwner | undefined;\n const modeSelected = (): boolean => (host.context.selection.state?.['minor-mode'] ?? []).includes(MODE_ID);\n const modeState = (): MinorModeState => {\n const launcherCount = launchers?.listLaunchers().length ?? 0;\n const active = (launchers?.listInstances().length ?? 0) > 0;\n const canStart = launcherCount > 0 || !modeSelected();\n return {\n activation: active ? 'active' : 'inactive',\n condition: launchers?.listInstances().some(({ state }) => state !== 'running') ? 'queued' : 'ready',\n ...(active ? { detail: `${launchers?.listInstances().length} active`, color: 'warning' } : {}),\n actions: [\n {\n id: 'start',\n enabled: canStart,\n ...(canStart ? {} : { disabledReason: 'No loop launchers are registered.' }),\n },\n {\n id: 'stop',\n enabled: active,\n ...(active ? {} : { disabledReason: 'No loops are active.' }),\n },\n ],\n };\n };\n /**\n * The instances the activity dock lists.\n *\n * An empty list publishes an empty value rather than nothing, because the key\n * being present is what keeps the group on screen as a launcher. The group\n * declares no `hideWhenEmpty`, so an empty value is a header with no rows.\n */\n const publishView = (): void =>\n host.context.client.setStatus(LOOP_VIEW_STATUS_KEY, formatLoopStatusView(launchers?.listInstances() ?? []));\n /** Both surfaces a loop shows up on: the minor-mode catalog and the activity dock. */\n const publishMode = (): void => {\n modeOwner?.publish();\n publishView();\n };\n const startActivity = async (execution: typeof host.context): Promise<() => Promise<void>> => {\n if (launchers !== undefined) return async () => undefined;\n const dependencies: LoopLaunchersDependencies = {\n generation: `${execution.sessionId}:loop-launchers`,\n createInstanceId: () => crypto.randomUUID(),\n timestamp: () => new Date().toISOString(),\n };\n const service = createDoomLoopLaunchersService(dependencies);\n const registration = service.register({\n id: DEFAULT_LAUNCHER_ID,\n source: SOURCE,\n label: 'Default loop',\n description: 'Run a prompt in this session on an interval.',\n async launch({ instanceId, signal }): Promise<StoppableLoop | undefined> {\n const promptValue = await execution.client.request(\n { kind: 'input', title: 'Loop prompt', multiline: true },\n signal,\n );\n const prompt = typeof promptValue === 'string' ? promptValue.trim() : '';\n if (!prompt || signal.aborted) return undefined;\n const interval = numberInput(\n await execution.client.request(\n { kind: 'input', title: 'Loop interval in seconds', initialValue: String(DEFAULT_INTERVAL_SECONDS) },\n signal,\n ),\n DEFAULT_INTERVAL_SECONDS,\n );\n let stopped = false;\n const tick = (): void => {\n if (stopped || signal.aborted) return;\n void execution.session.prompt(prompt).catch((error) => {\n void notify(\n execution,\n `Loop pass failed: ${error instanceof Error ? error.message : String(error)}`,\n 'warning',\n );\n });\n };\n const timer = setInterval(tick, interval * 1000);\n timer.unref?.();\n tick();\n return {\n instanceId,\n label: 'Default loop',\n detail: `every ${interval}s`,\n stop() {\n stopped = true;\n clearInterval(timer);\n },\n };\n },\n });\n launchers = service;\n defaultRegistration = registration;\n unsubscribe = service.subscribe(publishMode);\n publishMode();\n return async () => {\n unsubscribe?.();\n unsubscribe = undefined;\n await registration.dispose('Headless loop activity stopped.');\n await service.dispose('Headless loop activity stopped.');\n if (launchers === service) launchers = undefined;\n if (defaultRegistration === registration) defaultRegistration = undefined;\n publishMode();\n };\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: SOURCE,\n id: MODE_ID,\n label: 'Loop',\n description: 'Session-scoped recurring prompt loops.',\n order: 60,\n actions: [\n {\n id: 'start',\n label: 'Start',\n description: 'Start a loop with a registered launcher.',\n contexts: ['headless'],\n parameters: [\n { name: 'launcherId', label: 'Launcher', kind: 'string', required: true, minLength: 1 },\n { name: 'instanceId', label: 'Instance ID', kind: 'string', required: false, minLength: 1 },\n ],\n },\n {\n id: 'stop',\n label: 'Stop',\n description: 'Stop one active loop instance.',\n contexts: ['headless'],\n parameters: [\n { name: 'instanceId', label: 'Instance ID', kind: 'string', required: true, minLength: 1 },\n { name: 'reason', label: 'Reason', kind: 'string', required: false, minLength: 1 },\n ],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, argumentsValue, { signal }) {\n signal.throwIfAborted();\n if (actionId === 'start' && !launchers) {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== MODE_ID);\n await host.changeSelection({ axis: 'state', key: 'minor-mode', values: [...modes, MODE_ID] });\n }\n if (!launchers) throw new Error('Loop activity is not active.');\n if (actionId === 'start') {\n const instance = await launchers.launch(\n String(argumentsValue.launcherId ?? ''),\n argumentsValue.instanceId ? { instanceId: String(argumentsValue.instanceId) } : {},\n );\n publishMode();\n return { message: instance ? `Loop '${instance.instanceId}' started.` : 'Loop launch was cancelled.' };\n }\n if (actionId === 'stop') {\n const stopped = await launchers.stop(\n String(argumentsValue.instanceId ?? ''),\n String(argumentsValue.reason ?? 'Stopped through minor_mode.'),\n );\n if (stopped && launchers.listInstances().length === 0) {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== MODE_ID);\n await host.changeSelection({ axis: 'state', key: 'minor-mode', values: modes });\n }\n publishMode();\n return { message: stopped ? 'Loop stopped.' : 'Loop instance was not active.' };\n }\n throw new Error(`Unknown loop mode action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n resources: [\n {\n when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: 'doompi-use-loop',\n kind: 'skill',\n read: () => readPackageResource(import.meta.url, 'src/prompts/doompi-use-loop/SKILL.md'),\n },\n ],\n activities: [\n {\n when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: 'doompi-loop',\n start: startActivity,\n },\n ],\n commands: [\n {\n name: START_COMMAND_NAME,\n description: 'Start a registered loop.',\n async execute(args: string, execution: DoomHeadlessExecutionContext) {\n if (!launchers) {\n const modes = host.context.selection.state?.['minor-mode'] ?? [];\n await host.changeSelection({ axis: 'state', key: 'minor-mode', values: [...modes, MODE_ID] });\n }\n if (!launchers) throw new Error('Loop activity is not active.');\n const available = launchers.listLaunchers();\n const selected =\n args.trim() ||\n (await execution.client.request({\n kind: 'select',\n title: 'Choose a loop launcher',\n options: available.map((entry) => ({ label: entry.label, value: entry.id })),\n }));\n const launcherId = args.trim() || (typeof selected === 'string' ? selected : '');\n if (!launcherId) return;\n const instance = await launchers.launch(launcherId);\n publishMode();\n await notify(execution, instance ? `Loop '${instance.instanceId}' started.` : 'Loop launch was cancelled.');\n },\n },\n {\n name: LIST_COMMAND_NAME,\n description: 'List and stop active loops.',\n async execute(_args: string, execution: DoomHeadlessExecutionContext) {\n const instances = launchers?.listInstances() ?? [];\n await notify(execution, instances.length === 0 ? 'No loops are active.' : JSON.stringify(instances, null, 2));\n },\n },\n ],\n hooks: [\n {\n // Ungated on purpose: the dock's loops group is a way in, so it has to\n // exist before anyone selects loop mode. The activity below is gated on\n // that selection and cannot do this job.\n event: 'session_start',\n async handle() {\n publishView();\n },\n },\n {\n when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n event: 'session_shutdown',\n async handle() {\n await launchers?.stopAll('Headless session shutdown.');\n },\n },\n ],\n async onDispose() {\n await defaultRegistration?.dispose('Headless loop facet disposed.');\n await launchers?.dispose('Headless loop facet disposed.');\n },\n };\n}\n"],"mappings":";;;;;;AAQA,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,sBAAsB;AAC5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