@agimon-ai/doompi-loop 0.0.1-alpha.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/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/commands/loopCommand.cjs +2 -0
- package/dist/commands/loopCommand.cjs.map +1 -0
- package/dist/commands/loopCommand.mjs +2 -0
- package/dist/commands/loopCommand.mjs.map +1 -0
- package/dist/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.mjs +2 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/extension.cjs +2 -0
- package/dist/extension.cjs.map +1 -0
- package/dist/extension.d.cts +6 -0
- package/dist/extension.d.cts.map +1 -0
- package/dist/extension.d.mts +6 -0
- package/dist/extension.d.mts.map +1 -0
- package/dist/extension.mjs +2 -0
- package/dist/extension.mjs.map +1 -0
- package/dist/extensions/pi.cjs +2 -0
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.cts +2 -0
- package/dist/extensions/pi.d.mts +2 -0
- package/dist/extensions/pi.mjs +2 -0
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/launcher.cjs +2 -0
- package/dist/launcher.cjs.map +1 -0
- package/dist/launcher.d.cts +47 -0
- package/dist/launcher.d.cts.map +1 -0
- package/dist/launcher.d.mts +47 -0
- package/dist/launcher.d.mts.map +1 -0
- package/dist/launcher.mjs +2 -0
- package/dist/launcher.mjs.map +1 -0
- package/dist/leader.cjs +2 -0
- package/dist/leader.cjs.map +1 -0
- package/dist/leader.mjs +2 -0
- package/dist/leader.mjs.map +1 -0
- package/dist/tui/loopListOverlay.cjs +2 -0
- package/dist/tui/loopListOverlay.cjs.map +1 -0
- package/dist/tui/loopListOverlay.mjs +2 -0
- package/dist/tui/loopListOverlay.mjs.map +1 -0
- package/dist/tui/startLoopOverlay.cjs +2 -0
- package/dist/tui/startLoopOverlay.cjs.map +1 -0
- package/dist/tui/startLoopOverlay.mjs +2 -0
- package/dist/tui/startLoopOverlay.mjs.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vuong Ngo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @agimon-ai/doompi-loop
|
|
2
|
+
|
|
3
|
+
Generic multi-loop controller for Doompi.
|
|
4
|
+
|
|
5
|
+
Runs a prompt on a schedule or until a condition holds. Loop is a minor mode: it toggles
|
|
6
|
+
mid-session, stacks with the others, and reports itself on the shared `MODES` line.
|
|
7
|
+
|
|
8
|
+
Part of [Doompi](https://www.npmjs.com/package/@agimon-ai/doompi), a coding agent that loads
|
|
9
|
+
only the skills and tools you name. This package is composed by Doompi and is not usually
|
|
10
|
+
installed on its own.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @agimon-ai/doompi-loop
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## How it loads
|
|
19
|
+
|
|
20
|
+
Doompi loads this unconditionally. It is core, not a layer, so it does not appear in
|
|
21
|
+
`.doom/modes.yaml`: making it optional would only create broken configurations.
|
|
22
|
+
|
|
23
|
+
Extension entry: `@agimon-ai/doompi-loop/extensions/pi`
|
|
24
|
+
|
|
25
|
+
## Leader
|
|
26
|
+
|
|
27
|
+
`SPC l s` starts a loop, `SPC l l` lists and stops them, once the extension is loaded.
|
|
28
|
+
|
|
29
|
+
## Entry points
|
|
30
|
+
|
|
31
|
+
| Import |
|
|
32
|
+
| -------------------------------------- |
|
|
33
|
+
| `@agimon-ai/doompi-loop` |
|
|
34
|
+
| `@agimon-ai/doompi-loop/extensions/pi` |
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../constants.cjs");function t(t,n){t.registerCommand(e.START_COMMAND_NAME,{description:e.START_COMMAND_DESCRIPTION,handler:async(e,t)=>n.start(t)}),t.registerCommand(e.LIST_COMMAND_NAME,{description:e.LIST_COMMAND_DESCRIPTION,handler:async(e,t)=>n.list(t)})}exports.registerCommands=t;
|
|
2
|
+
//# sourceMappingURL=loopCommand.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopCommand.cjs","names":["START_COMMAND_NAME","START_COMMAND_DESCRIPTION","LIST_COMMAND_NAME","LIST_COMMAND_DESCRIPTION"],"sources":["../../src/commands/loopCommand.ts"],"sourcesContent":["import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport {\n LIST_COMMAND_DESCRIPTION,\n LIST_COMMAND_NAME,\n START_COMMAND_DESCRIPTION,\n START_COMMAND_NAME,\n} from '../constants.ts';\n\nexport interface LoopCommandHandlers {\n start(ctx: ExtensionContext): Promise<void>;\n list(ctx: ExtensionContext): Promise<void>;\n}\n\nexport function registerCommands(pi: ExtensionAPI, handlers: LoopCommandHandlers): void {\n pi.registerCommand(START_COMMAND_NAME, {\n description: START_COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => handlers.start(ctx),\n });\n pi.registerCommand(LIST_COMMAND_NAME, {\n description: LIST_COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => handlers.list(ctx),\n });\n}\n"],"mappings":"oCAaA,SAAgB,EAAiB,EAAkB,EAAqC,CACtF,EAAG,gBAAgBA,EAAAA,mBAAoB,CACrC,YAAaC,EAAAA,0BACb,QAAS,MAAO,EAAO,IAAQ,EAAS,MAAM,CAAG,CACnD,CAAC,EACD,EAAG,gBAAgBC,EAAAA,kBAAmB,CACpC,YAAaC,EAAAA,yBACb,QAAS,MAAO,EAAO,IAAQ,EAAS,KAAK,CAAG,CAClD,CAAC,CACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{LIST_COMMAND_DESCRIPTION as e,LIST_COMMAND_NAME as t,START_COMMAND_DESCRIPTION as n,START_COMMAND_NAME as r}from"../constants.mjs";function i(i,a){i.registerCommand(r,{description:n,handler:async(e,t)=>a.start(t)}),i.registerCommand(t,{description:e,handler:async(e,t)=>a.list(t)})}export{i as registerCommands};
|
|
2
|
+
//# sourceMappingURL=loopCommand.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopCommand.mjs","names":[],"sources":["../../src/commands/loopCommand.ts"],"sourcesContent":["import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport {\n LIST_COMMAND_DESCRIPTION,\n LIST_COMMAND_NAME,\n START_COMMAND_DESCRIPTION,\n START_COMMAND_NAME,\n} from '../constants.ts';\n\nexport interface LoopCommandHandlers {\n start(ctx: ExtensionContext): Promise<void>;\n list(ctx: ExtensionContext): Promise<void>;\n}\n\nexport function registerCommands(pi: ExtensionAPI, handlers: LoopCommandHandlers): void {\n pi.registerCommand(START_COMMAND_NAME, {\n description: START_COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => handlers.start(ctx),\n });\n pi.registerCommand(LIST_COMMAND_NAME, {\n description: LIST_COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => handlers.list(ctx),\n });\n}\n"],"mappings":"0IAaA,SAAgB,EAAiB,EAAkB,EAAqC,CACtF,EAAG,gBAAgB,EAAoB,CACrC,YAAa,EACb,QAAS,MAAO,EAAO,IAAQ,EAAS,MAAM,CAAG,CACnD,CAAC,EACD,EAAG,gBAAgB,EAAmB,CACpC,YAAa,EACb,QAAS,MAAO,EAAO,IAAQ,EAAS,KAAK,CAAG,CAClD,CAAC,CACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
exports.ACTIVE_MODE_COLOR=`warning`,exports.LIST_COMMAND_DESCRIPTION=`List and stop active loops`,exports.LIST_COMMAND_NAME=`loops`,exports.MODE_STATUS_ID=`loop.active`,exports.NOTIFY_INFO_LEVEL=`info`,exports.PACKAGE_SOURCE=`@agimon-ai/doompi-loop`,exports.START_COMMAND_DESCRIPTION=`Start a registered loop`,exports.START_COMMAND_NAME=`loop`,exports.STATUS_KEY=`doom-loop`;
|
|
2
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PACKAGE_SOURCE = '@agimon-ai/doompi-loop';\nexport const START_COMMAND_NAME = 'loop';\nexport const LIST_COMMAND_NAME = 'loops';\nexport const START_COMMAND_DESCRIPTION = 'Start a registered loop';\nexport const LIST_COMMAND_DESCRIPTION = 'List and stop active loops';\nexport const LOOPS_GROUP_ORDER = 60;\nexport const STATUS_KEY = 'doom-loop';\nexport const MODE_STATUS_ID = 'loop.active';\nexport const ACTIVE_MODE_COLOR = 'warning';\nexport const NOTIFY_INFO_LEVEL = 'info';\n"],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`@agimon-ai/doompi-loop`,t=`loop`,n=`loops`,r=`Start a registered loop`,i=`List and stop active loops`,a=`doom-loop`,o=`loop.active`,s=`warning`,c=`info`;export{s as ACTIVE_MODE_COLOR,i as LIST_COMMAND_DESCRIPTION,n as LIST_COMMAND_NAME,o as MODE_STATUS_ID,c as NOTIFY_INFO_LEVEL,e as PACKAGE_SOURCE,r as START_COMMAND_DESCRIPTION,t as START_COMMAND_NAME,a as STATUS_KEY};
|
|
2
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PACKAGE_SOURCE = '@agimon-ai/doompi-loop';\nexport const START_COMMAND_NAME = 'loop';\nexport const LIST_COMMAND_NAME = 'loops';\nexport const START_COMMAND_DESCRIPTION = 'Start a registered loop';\nexport const LIST_COMMAND_DESCRIPTION = 'List and stop active loops';\nexport const LOOPS_GROUP_ORDER = 60;\nexport const STATUS_KEY = 'doom-loop';\nexport const MODE_STATUS_ID = 'loop.active';\nexport const ACTIVE_MODE_COLOR = 'warning';\nexport const NOTIFY_INFO_LEVEL = 'info';\n"],"mappings":"AAAA,MAAa,EAAiB,yBACjB,EAAqB,OACrB,EAAoB,QACpB,EAA4B,0BAC5B,EAA2B,6BAE3B,EAAa,YACb,EAAiB,cACjB,EAAoB,UACpB,EAAoB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants.cjs"),t=require("./commands/loopCommand.cjs"),n=require("./launcher.cjs"),r=require("./leader.cjs"),i=require("./tui/loopListOverlay.cjs"),a=require("./tui/startLoopOverlay.cjs");let o=require("@agimon-ai/doompi-ui/mode");const s=Symbol.for(`@agimon-ai/doompi-loop/installed-hosts`);function c(e){let t=globalThis,n=t[s]??new WeakSet;return t[s]=n,!n.has(e)&&(n.add(e),!0)}function l(s){if(!c(s))return;let l,u,d,f=n.createLoopLauncherClient(()=>l),p=(0,o.registerDoomModeContribution)(s,{source:e.PACKAGE_SOURCE,id:e.MODE_STATUS_ID,order:60});r.registerLeaderContribution(s);let m=()=>{let t=f.listInstances().length;u?.ui?.setStatus(e.STATUS_KEY,t?`loops: ${t}`:void 0),p.update(t?{label:`LOOP`,detail:`${t} active`,color:e.ACTIVE_MODE_COLOR}:void 0)};t.registerCommands(s,{async start(t){let n=f.listLaunchers();if(!n.length){t.ui.notify(`No loop launchers are registered for this session.`,e.NOTIFY_INFO_LEVEL);return}let r=await a.openStartLoopOverlay(t,n);if(r)try{let n=await f.launch(r);n&&t.ui.notify(`${n.label??n.launcherLabel} started.`,e.NOTIFY_INFO_LEVEL)}catch(e){t.ui.notify(`Loop could not start: ${e instanceof Error?e.message:String(e)}`,`error`)}},async list(e){await i.openLoopListOverlay(e,f)}}),s.on(`session_start`,(e,t)=>{d?.(),u=t,l=t.sessionManager.getSessionId(),d=f.subscribe(m),m()}),s.on(`session_shutdown`,async()=>{await f.stopAll(`Pi session shut down.`),d?.(),d=void 0,u?.ui?.setStatus(e.STATUS_KEY,void 0),u=void 0,l=void 0,p.update(void 0)})}exports.registerLoopExtension=l;
|
|
2
|
+
//# sourceMappingURL=extension.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.cjs","names":["createLoopLauncherClient","registerDoomModeContribution","PACKAGE_SOURCE","MODE_STATUS_ID","STATUS_KEY","ACTIVE_MODE_COLOR","NOTIFY_INFO_LEVEL","openStartLoopOverlay","openLoopListOverlay"],"sources":["../src/extension.ts"],"sourcesContent":["import { registerDoomModeContribution } from '@agimon-ai/doompi-ui/mode';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { registerCommands } from './commands/loopCommand.ts';\nimport {\n ACTIVE_MODE_COLOR,\n LOOPS_GROUP_ORDER,\n MODE_STATUS_ID,\n NOTIFY_INFO_LEVEL,\n PACKAGE_SOURCE,\n STATUS_KEY,\n} from './constants.ts';\nimport { createLoopLauncherClient } from './launcher.ts';\nimport { registerLeaderContribution } from './leader.ts';\nimport { openLoopListOverlay } from './tui/loopListOverlay.ts';\nimport { openStartLoopOverlay } from './tui/startLoopOverlay.ts';\n\nconst INSTALLATIONS_KEY = Symbol.for('@agimon-ai/doompi-loop/installed-hosts');\n\ntype InstallationRegistry = typeof globalThis & {\n [INSTALLATIONS_KEY]?: WeakSet<object>;\n};\n\nfunction claimHostInstallation(pi: ExtensionAPI): boolean {\n const registry = globalThis as InstallationRegistry;\n const installedHosts = registry[INSTALLATIONS_KEY] ?? new WeakSet<object>();\n registry[INSTALLATIONS_KEY] = installedHosts;\n if (installedHosts.has(pi)) return false;\n installedHosts.add(pi);\n return true;\n}\n\nexport function registerLoopExtension(pi: ExtensionAPI): void {\n if (!claimHostInstallation(pi)) return;\n let sessionId: string | undefined;\n let context: ExtensionContext | undefined;\n let unsubscribe: (() => void) | undefined;\n const client = createLoopLauncherClient(() => sessionId);\n const mode = registerDoomModeContribution(pi, {\n source: PACKAGE_SOURCE,\n id: MODE_STATUS_ID,\n order: LOOPS_GROUP_ORDER,\n });\n registerLeaderContribution(pi);\n\n const updateStatus = (): void => {\n const count = client.listInstances().length;\n context?.ui?.setStatus(STATUS_KEY, count ? `loops: ${count}` : undefined);\n mode.update(count ? { label: 'LOOP', detail: `${count} active`, color: ACTIVE_MODE_COLOR } : undefined);\n };\n\n registerCommands(pi, {\n async start(ctx) {\n const launchers = client.listLaunchers();\n if (!launchers.length) {\n ctx.ui.notify('No loop launchers are registered for this session.', NOTIFY_INFO_LEVEL);\n return;\n }\n const launcherId = await openStartLoopOverlay(ctx, launchers);\n if (!launcherId) return;\n try {\n const instance = await client.launch(launcherId);\n if (instance) ctx.ui.notify(`${instance.label ?? instance.launcherLabel} started.`, NOTIFY_INFO_LEVEL);\n } catch (error) {\n ctx.ui.notify(`Loop could not start: ${error instanceof Error ? error.message : String(error)}`, 'error');\n }\n },\n async list(ctx) {\n await openLoopListOverlay(ctx, client);\n },\n });\n\n pi.on('session_start', (_event, ctx) => {\n unsubscribe?.();\n context = ctx;\n sessionId = ctx.sessionManager.getSessionId();\n unsubscribe = client.subscribe(updateStatus);\n updateStatus();\n });\n\n pi.on('session_shutdown', async () => {\n await client.stopAll('Pi session shut down.');\n unsubscribe?.();\n unsubscribe = undefined;\n context?.ui?.setStatus(STATUS_KEY, undefined);\n context = undefined;\n sessionId = undefined;\n mode.update(undefined);\n });\n}\n"],"mappings":"2PAgBA,MAAM,EAAoB,OAAO,IAAI,wCAAwC,EAM7E,SAAS,EAAsB,EAA2B,CACxD,IAAM,EAAW,WACX,EAAiB,EAAS,IAAsB,IAAI,QAI1D,MAHA,GAAS,GAAqB,EAC9B,CAAI,EAAe,IAAI,CAAE,IACzB,EAAe,IAAI,CAAE,EACd,GACT,CAEA,SAAgB,EAAsB,EAAwB,CAC5D,GAAI,CAAC,EAAsB,CAAE,EAAG,OAChC,IAAI,EACA,EACA,EACE,EAASA,EAAAA,6BAA+B,CAAS,EACjD,GAAA,EAAOC,EAAAA,6BAAAA,CAA6B,EAAI,CAC5C,OAAQC,EAAAA,eACR,GAAIC,EAAAA,eACJ,MAAA,EACF,CAAC,EACD,EAAA,2BAA2B,CAAE,EAE7B,IAAM,MAA2B,CAC/B,IAAM,EAAQ,EAAO,cAAc,CAAC,CAAC,OACrC,GAAS,IAAI,UAAUC,EAAAA,WAAY,EAAQ,UAAU,IAAU,IAAA,EAAS,EACxE,EAAK,OAAO,EAAQ,CAAE,MAAO,OAAQ,OAAQ,GAAG,EAAM,SAAU,MAAOC,EAAAA,iBAAkB,EAAI,IAAA,EAAS,CACxG,EAEA,EAAA,iBAAiB,EAAI,CACnB,MAAM,MAAM,EAAK,CACf,IAAM,EAAY,EAAO,cAAc,EACvC,GAAI,CAAC,EAAU,OAAQ,CACrB,EAAI,GAAG,OAAO,qDAAsDC,EAAAA,iBAAiB,EACrF,MACF,CACA,IAAM,EAAa,MAAMC,EAAAA,qBAAqB,EAAK,CAAS,EACvD,KACL,GAAI,CACF,IAAM,EAAW,MAAM,EAAO,OAAO,CAAU,EAC3C,GAAU,EAAI,GAAG,OAAO,GAAG,EAAS,OAAS,EAAS,cAAc,WAAYD,EAAAA,iBAAiB,CACvG,OAAS,EAAO,CACd,EAAI,GAAG,OAAO,yBAAyB,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,IAAK,OAAO,CAC1G,CACF,EACA,MAAM,KAAK,EAAK,CACd,MAAME,EAAAA,oBAAoB,EAAK,CAAM,CACvC,CACF,CAAC,EAED,EAAG,GAAG,iBAAkB,EAAQ,IAAQ,CACtC,IAAc,EACd,EAAU,EACV,EAAY,EAAI,eAAe,aAAa,EAC5C,EAAc,EAAO,UAAU,CAAY,EAC3C,EAAa,CACf,CAAC,EAED,EAAG,GAAG,mBAAoB,SAAY,CACpC,MAAM,EAAO,QAAQ,uBAAuB,EAC5C,IAAc,EACd,EAAc,IAAA,GACd,GAAS,IAAI,UAAUJ,EAAAA,WAAY,IAAA,EAAS,EAC5C,EAAU,IAAA,GACV,EAAY,IAAA,GACZ,EAAK,OAAO,IAAA,EAAS,CACvB,CAAC,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.cts","names":[],"sources":["../src/extension.ts"],"mappings":";;iBA+BgB,sBAAsB,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.mts","names":[],"sources":["../src/extension.ts"],"mappings":";;iBA+BgB,sBAAsB,IAAI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ACTIVE_MODE_COLOR as e,MODE_STATUS_ID as t,NOTIFY_INFO_LEVEL as n,PACKAGE_SOURCE as r,STATUS_KEY as i}from"./constants.mjs";import{registerCommands as a}from"./commands/loopCommand.mjs";import{createLoopLauncherClient as o}from"./launcher.mjs";import{registerLeaderContribution as s}from"./leader.mjs";import{openLoopListOverlay as c}from"./tui/loopListOverlay.mjs";import{openStartLoopOverlay as l}from"./tui/startLoopOverlay.mjs";import{registerDoomModeContribution as u}from"@agimon-ai/doompi-ui/mode";const d=Symbol.for(`@agimon-ai/doompi-loop/installed-hosts`);function f(e){let t=globalThis,n=t[d]??new WeakSet;return t[d]=n,!n.has(e)&&(n.add(e),!0)}function p(d){if(!f(d))return;let p,m,h,g=o(()=>p),_=u(d,{source:r,id:t,order:60});s(d);let v=()=>{let t=g.listInstances().length;m?.ui?.setStatus(i,t?`loops: ${t}`:void 0),_.update(t?{label:`LOOP`,detail:`${t} active`,color:e}:void 0)};a(d,{async start(e){let t=g.listLaunchers();if(!t.length){e.ui.notify(`No loop launchers are registered for this session.`,n);return}let r=await l(e,t);if(r)try{let t=await g.launch(r);t&&e.ui.notify(`${t.label??t.launcherLabel} started.`,n)}catch(t){e.ui.notify(`Loop could not start: ${t instanceof Error?t.message:String(t)}`,`error`)}},async list(e){await c(e,g)}}),d.on(`session_start`,(e,t)=>{h?.(),m=t,p=t.sessionManager.getSessionId(),h=g.subscribe(v),v()}),d.on(`session_shutdown`,async()=>{await g.stopAll(`Pi session shut down.`),h?.(),h=void 0,m?.ui?.setStatus(i,void 0),m=void 0,p=void 0,_.update(void 0)})}export{p as registerLoopExtension};
|
|
2
|
+
//# sourceMappingURL=extension.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.mjs","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import { registerDoomModeContribution } from '@agimon-ai/doompi-ui/mode';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { registerCommands } from './commands/loopCommand.ts';\nimport {\n ACTIVE_MODE_COLOR,\n LOOPS_GROUP_ORDER,\n MODE_STATUS_ID,\n NOTIFY_INFO_LEVEL,\n PACKAGE_SOURCE,\n STATUS_KEY,\n} from './constants.ts';\nimport { createLoopLauncherClient } from './launcher.ts';\nimport { registerLeaderContribution } from './leader.ts';\nimport { openLoopListOverlay } from './tui/loopListOverlay.ts';\nimport { openStartLoopOverlay } from './tui/startLoopOverlay.ts';\n\nconst INSTALLATIONS_KEY = Symbol.for('@agimon-ai/doompi-loop/installed-hosts');\n\ntype InstallationRegistry = typeof globalThis & {\n [INSTALLATIONS_KEY]?: WeakSet<object>;\n};\n\nfunction claimHostInstallation(pi: ExtensionAPI): boolean {\n const registry = globalThis as InstallationRegistry;\n const installedHosts = registry[INSTALLATIONS_KEY] ?? new WeakSet<object>();\n registry[INSTALLATIONS_KEY] = installedHosts;\n if (installedHosts.has(pi)) return false;\n installedHosts.add(pi);\n return true;\n}\n\nexport function registerLoopExtension(pi: ExtensionAPI): void {\n if (!claimHostInstallation(pi)) return;\n let sessionId: string | undefined;\n let context: ExtensionContext | undefined;\n let unsubscribe: (() => void) | undefined;\n const client = createLoopLauncherClient(() => sessionId);\n const mode = registerDoomModeContribution(pi, {\n source: PACKAGE_SOURCE,\n id: MODE_STATUS_ID,\n order: LOOPS_GROUP_ORDER,\n });\n registerLeaderContribution(pi);\n\n const updateStatus = (): void => {\n const count = client.listInstances().length;\n context?.ui?.setStatus(STATUS_KEY, count ? `loops: ${count}` : undefined);\n mode.update(count ? { label: 'LOOP', detail: `${count} active`, color: ACTIVE_MODE_COLOR } : undefined);\n };\n\n registerCommands(pi, {\n async start(ctx) {\n const launchers = client.listLaunchers();\n if (!launchers.length) {\n ctx.ui.notify('No loop launchers are registered for this session.', NOTIFY_INFO_LEVEL);\n return;\n }\n const launcherId = await openStartLoopOverlay(ctx, launchers);\n if (!launcherId) return;\n try {\n const instance = await client.launch(launcherId);\n if (instance) ctx.ui.notify(`${instance.label ?? instance.launcherLabel} started.`, NOTIFY_INFO_LEVEL);\n } catch (error) {\n ctx.ui.notify(`Loop could not start: ${error instanceof Error ? error.message : String(error)}`, 'error');\n }\n },\n async list(ctx) {\n await openLoopListOverlay(ctx, client);\n },\n });\n\n pi.on('session_start', (_event, ctx) => {\n unsubscribe?.();\n context = ctx;\n sessionId = ctx.sessionManager.getSessionId();\n unsubscribe = client.subscribe(updateStatus);\n updateStatus();\n });\n\n pi.on('session_shutdown', async () => {\n await client.stopAll('Pi session shut down.');\n unsubscribe?.();\n unsubscribe = undefined;\n context?.ui?.setStatus(STATUS_KEY, undefined);\n context = undefined;\n sessionId = undefined;\n mode.update(undefined);\n });\n}\n"],"mappings":"ggBAgBA,MAAM,EAAoB,OAAO,IAAI,wCAAwC,EAM7E,SAAS,EAAsB,EAA2B,CACxD,IAAM,EAAW,WACX,EAAiB,EAAS,IAAsB,IAAI,QAI1D,MAHA,GAAS,GAAqB,EAC9B,CAAI,EAAe,IAAI,CAAE,IACzB,EAAe,IAAI,CAAE,EACd,GACT,CAEA,SAAgB,EAAsB,EAAwB,CAC5D,GAAI,CAAC,EAAsB,CAAE,EAAG,OAChC,IAAI,EACA,EACA,EACE,EAAS,MAA+B,CAAS,EACjD,EAAO,EAA6B,EAAI,CAC5C,OAAQ,EACR,GAAI,EACJ,MAAA,EACF,CAAC,EACD,EAA2B,CAAE,EAE7B,IAAM,MAA2B,CAC/B,IAAM,EAAQ,EAAO,cAAc,CAAC,CAAC,OACrC,GAAS,IAAI,UAAU,EAAY,EAAQ,UAAU,IAAU,IAAA,EAAS,EACxE,EAAK,OAAO,EAAQ,CAAE,MAAO,OAAQ,OAAQ,GAAG,EAAM,SAAU,MAAO,CAAkB,EAAI,IAAA,EAAS,CACxG,EAEA,EAAiB,EAAI,CACnB,MAAM,MAAM,EAAK,CACf,IAAM,EAAY,EAAO,cAAc,EACvC,GAAI,CAAC,EAAU,OAAQ,CACrB,EAAI,GAAG,OAAO,qDAAsD,CAAiB,EACrF,MACF,CACA,IAAM,EAAa,MAAM,EAAqB,EAAK,CAAS,EACvD,KACL,GAAI,CACF,IAAM,EAAW,MAAM,EAAO,OAAO,CAAU,EAC3C,GAAU,EAAI,GAAG,OAAO,GAAG,EAAS,OAAS,EAAS,cAAc,WAAY,CAAiB,CACvG,OAAS,EAAO,CACd,EAAI,GAAG,OAAO,yBAAyB,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,IAAK,OAAO,CAC1G,CACF,EACA,MAAM,KAAK,EAAK,CACd,MAAM,EAAoB,EAAK,CAAM,CACvC,CACF,CAAC,EAED,EAAG,GAAG,iBAAkB,EAAQ,IAAQ,CACtC,IAAc,EACd,EAAU,EACV,EAAY,EAAI,eAAe,aAAa,EAC5C,EAAc,EAAO,UAAU,CAAY,EAC3C,EAAa,CACf,CAAC,EAED,EAAG,GAAG,mBAAoB,SAAY,CACpC,MAAM,EAAO,QAAQ,uBAAuB,EAC5C,IAAc,EACd,EAAc,IAAA,GACd,GAAS,IAAI,UAAU,EAAY,IAAA,EAAS,EAC5C,EAAU,IAAA,GACV,EAAY,IAAA,GACZ,EAAK,OAAO,IAAA,EAAS,CACvB,CAAC,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.cjs","names":["registerLoopExtension"],"sources":["../../src/extensions/pi.ts"],"sourcesContent":["import { registerLoopExtension } from '../extension.ts';\n\nexport default registerLoopExtension;\n"],"mappings":"AAEA,IAAA,4BAAeA,CAAAA,CAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.mjs","names":[],"sources":["../../src/extensions/pi.ts"],"sourcesContent":["import { registerLoopExtension } from '../extension.ts';\n\nexport default registerLoopExtension;\n"],"mappings":"yDAEA,IAAA,EAAe"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./launcher.cjs"),t=require("./extension.cjs");exports.createLoopLauncherClient=e.createLoopLauncherClient,exports.registerLoopExtension=t.registerLoopExtension,exports.registerLoopLauncher=e.registerLoopLauncher;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { registerLoopExtension } from "./extension.cjs";
|
|
2
|
+
import { LoopInstanceSnapshot, LoopLaunchRequest, LoopLauncherClient, LoopLauncherRegistration, LoopLauncherSummary, RegisterLoopLauncherOptions, StoppableLoop, createLoopLauncherClient, registerLoopLauncher } from "./launcher.cjs";
|
|
3
|
+
export { type LoopInstanceSnapshot, type LoopLaunchRequest, type LoopLauncherClient, type LoopLauncherRegistration, type LoopLauncherSummary, type RegisterLoopLauncherOptions, type StoppableLoop, createLoopLauncherClient, registerLoopExtension, registerLoopLauncher };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { registerLoopExtension } from "./extension.mjs";
|
|
2
|
+
import { LoopInstanceSnapshot, LoopLaunchRequest, LoopLauncherClient, LoopLauncherRegistration, LoopLauncherSummary, RegisterLoopLauncherOptions, StoppableLoop, createLoopLauncherClient, registerLoopLauncher } from "./launcher.mjs";
|
|
3
|
+
export { type LoopInstanceSnapshot, type LoopLaunchRequest, type LoopLauncherClient, type LoopLauncherRegistration, type LoopLauncherSummary, type RegisterLoopLauncherOptions, type StoppableLoop, createLoopLauncherClient, registerLoopExtension, registerLoopLauncher };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLoopLauncherClient as e,registerLoopLauncher as t}from"./launcher.mjs";import{registerLoopExtension as n}from"./extension.mjs";export{e as createLoopLauncherClient,n as registerLoopExtension,t as registerLoopLauncher};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("node:crypto");const t=Symbol.for(`@agimon-ai/doompi-loop.launchers.v1`),n=`loop session id`,r=`loop launcher id`,i=`loop instance id`;function a(){let e=globalThis;return e[t]??=new Map}function o(e,t){let n=e.trim(),r=!1;for(let e of n){let t=e.codePointAt(0);if(t!==void 0&&(t<=31||t===127)){r=!0;break}}if(!n||n.length>256||r)throw Error(`Invalid ${t}.`);return n}function s(e,t){let r=o(e,n),i=a().get(r);if(i||!t)return i;let s={launchers:new Map,instances:new Map,listeners:new Set};return a().set(r,s),s}function c(e){for(let t of e.listeners)t()}function l(e){return{instanceId:e.instanceId,launcherId:e.launcher.options.id,launcherLabel:e.launcher.options.label,...e.handle?.label?{label:e.handle.label}:{},...e.handle?.detail?{detail:e.handle.detail}:{},state:e.state,...e.startedAt?{startedAt:e.startedAt}:{}}}async function u(e,t,n){if(e.instances.get(t.instanceId)===t){t.state=`stopping`,t.abortController.abort(n),c(e);try{await t.handle?.stop(n)}finally{e.instances.get(t.instanceId)===t&&e.instances.delete(t.instanceId),c(e)}}}function d(e,t){t.launchers.size||t.instances.size||t.listeners.size||a().get(e)===t&&a().delete(e)}function f(e,t){let i=o(e,n),a=o(t.id,r),l=s(i,!0);if(l.launchers.has(a))throw Error(`Loop launcher '${a}' is already registered for session '${i}'.`);let f={token:Symbol(a),options:{...t,id:a}};l.launchers.set(a,f),c(l);let p=!1;return{async dispose(e=`Loop launcher disposed.`){if(p)return;p=!0;let t=s(i,!1);if(!t||t.launchers.get(a)?.token!==f.token)return;t.launchers.delete(a);let n=[...t.instances.values()].filter(e=>e.launcher.token===f.token);await Promise.allSettled(n.map(n=>u(t,n,e))),c(t),d(i,t)}}}function p(t){let a=e=>{let r=t();if(!r)return;let i=o(r,n),a=s(i,e);return a?{key:i,session:a}:void 0};return{listLaunchers(){let e=a(!1)?.session;return e?[...e.launchers.values()].map(({options:e})=>({id:e.id,source:e.source,label:e.label,...e.description?{description:e.description}:{}})).sort((e,t)=>e.label.localeCompare(t.label)||e.id.localeCompare(t.id)):[]},listInstances(){let e=a(!1)?.session;return e?[...e.instances.values()].map(l).sort((e,t)=>e.instanceId.localeCompare(t.instanceId)):[]},subscribe(e){let t=a(!0);if(!t)return()=>void 0;t.session.listeners.add(e);let n=!1;return()=>{n||(n=!0,t.session.listeners.delete(e),d(t.key,t.session))}},async launch(t,n){let s=a(!0);if(!s)throw Error(`The session-bound loop launcher registry is unavailable.`);let u=o(t,r),d=s.session.launchers.get(u);if(!d)throw Error(`Loop launcher '${u}' is unavailable.`);let f=o(n?.instanceId??(0,e.randomUUID)(),i);if(s.session.instances.has(f))throw Error(`Loop instance '${f}' already exists.`);let p={instanceId:f,launcher:d,abortController:new AbortController,state:`starting`};s.session.instances.set(f,p),c(s.session);try{let e=await d.options.launch({instanceId:f,signal:p.abortController.signal}),t=s.session.instances.get(f)===p&&!p.abortController.signal.aborted;if(!e){s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session);return}if(!t||e.instanceId!==f){if(await e.stop(t?`Loop launcher returned a mismatched instance id.`:`Loop launch was cancelled.`),s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session),t)throw Error(`Loop launcher '${u}' returned a mismatched instance id.`);return}return p.handle=e,p.state=`running`,p.startedAt=new Date().toISOString(),c(s.session),l(p)}catch(e){let t=p.abortController.signal.aborted;if(s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session),t)return;throw e}},async stop(e,t){let n=a(!1)?.session;if(!n)return!1;let r=n.instances.get(o(e,i));return r?(await u(n,r,t),!0):!1},async stopAll(e){let t=a(!1)?.session;t&&await Promise.allSettled([...t.instances.values()].map(n=>u(t,n,e)))}}}exports.createLoopLauncherClient=p,exports.registerLoopLauncher=f;
|
|
2
|
+
//# sourceMappingURL=launcher.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.cjs","names":["randomUUID"],"sources":["../src/launcher.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nconst REGISTRY_KEY = Symbol.for('@agimon-ai/doompi-loop.launchers.v1');\nconst MAX_ID_LENGTH = 256;\nconst SESSION_ID_LABEL = 'loop session id';\nconst LAUNCHER_ID_LABEL = 'loop launcher id';\nconst INSTANCE_ID_LABEL = 'loop instance id';\n\nexport interface LoopLaunchRequest {\n readonly instanceId: string;\n readonly signal: AbortSignal;\n}\n\nexport interface StoppableLoop {\n readonly instanceId: string;\n readonly label?: string;\n readonly detail?: string;\n stop(reason?: string): void | Promise<void>;\n}\n\nexport interface LoopLauncherSummary {\n readonly id: string;\n readonly source: string;\n readonly label: string;\n readonly description?: string;\n}\n\nexport interface LoopInstanceSnapshot {\n readonly instanceId: string;\n readonly launcherId: string;\n readonly launcherLabel: string;\n readonly label?: string;\n readonly detail?: string;\n readonly state: 'starting' | 'running' | 'stopping';\n readonly startedAt?: string;\n}\n\nexport interface LoopLauncherRegistration {\n dispose(reason?: string): Promise<void>;\n}\n\nexport interface LoopLauncherClient {\n listLaunchers(): readonly LoopLauncherSummary[];\n listInstances(): readonly LoopInstanceSnapshot[];\n subscribe(listener: () => void): () => void;\n launch(launcherId: string, options?: { instanceId?: string }): Promise<LoopInstanceSnapshot | undefined>;\n stop(instanceId: string, reason?: string): Promise<boolean>;\n stopAll(reason?: string): Promise<void>;\n}\n\nexport interface RegisterLoopLauncherOptions extends LoopLauncherSummary {\n launch(request: LoopLaunchRequest): Promise<StoppableLoop | undefined>;\n}\n\ninterface LauncherEntry {\n readonly token: symbol;\n readonly options: RegisterLoopLauncherOptions;\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\ninterface SessionRegistry {\n readonly launchers: Map<string, LauncherEntry>;\n readonly instances: Map<string, InstanceEntry>;\n readonly listeners: Set<() => void>;\n}\n\ntype LoopRegistry = Map<string, SessionRegistry>;\n\nfunction registry(): LoopRegistry {\n const root = globalThis as typeof globalThis & { [REGISTRY_KEY]?: LoopRegistry };\n return (root[REGISTRY_KEY] ??= new Map());\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 getSession(sessionId: string, create: boolean): SessionRegistry | undefined {\n const key = validId(sessionId, SESSION_ID_LABEL);\n const existing = registry().get(key);\n if (existing || !create) return existing;\n const created: SessionRegistry = { launchers: new Map(), instances: new Map(), listeners: new Set() };\n registry().set(key, created);\n return created;\n}\n\nfunction notify(session: SessionRegistry): void {\n for (const listener of session.listeners) listener();\n}\n\nfunction snapshot(entry: InstanceEntry): LoopInstanceSnapshot {\n return {\n instanceId: entry.instanceId,\n launcherId: entry.launcher.options.id,\n launcherLabel: entry.launcher.options.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\nasync function stopEntry(session: SessionRegistry, entry: InstanceEntry, reason?: string): Promise<void> {\n if (session.instances.get(entry.instanceId) !== entry) return;\n entry.state = 'stopping';\n entry.abortController.abort(reason);\n notify(session);\n try {\n await entry.handle?.stop(reason);\n } finally {\n if (session.instances.get(entry.instanceId) === entry) session.instances.delete(entry.instanceId);\n notify(session);\n }\n}\n\nfunction cleanSession(sessionId: string, session: SessionRegistry): void {\n if (session.launchers.size || session.instances.size || session.listeners.size) return;\n if (registry().get(sessionId) === session) registry().delete(sessionId);\n}\n\nexport function registerLoopLauncher(\n sessionId: string,\n options: RegisterLoopLauncherOptions,\n): LoopLauncherRegistration {\n const sessionKey = validId(sessionId, SESSION_ID_LABEL);\n const launcherId = validId(options.id, LAUNCHER_ID_LABEL);\n const session = getSession(sessionKey, true) as SessionRegistry;\n if (session.launchers.has(launcherId)) {\n throw new Error(`Loop launcher '${launcherId}' is already registered for session '${sessionKey}'.`);\n }\n const entry: LauncherEntry = { token: Symbol(launcherId), options: { ...options, id: launcherId } };\n session.launchers.set(launcherId, entry);\n notify(session);\n let disposed = false;\n return {\n async dispose(reason = 'Loop launcher disposed.'): Promise<void> {\n if (disposed) return;\n disposed = true;\n const current = getSession(sessionKey, false);\n if (!current || current.launchers.get(launcherId)?.token !== entry.token) return;\n current.launchers.delete(launcherId);\n const owned = [...current.instances.values()].filter((instance) => instance.launcher.token === entry.token);\n await Promise.allSettled(owned.map((instance) => stopEntry(current, instance, reason)));\n notify(current);\n cleanSession(sessionKey, current);\n },\n };\n}\n\nexport function createLoopLauncherClient(sessionId: () => string | undefined): LoopLauncherClient {\n const current = (create: boolean): { key: string; session: SessionRegistry } | undefined => {\n const value = sessionId();\n if (!value) return undefined;\n const key = validId(value, SESSION_ID_LABEL);\n const session = getSession(key, create);\n return session ? { key, session } : undefined;\n };\n return {\n listLaunchers() {\n const session = current(false)?.session;\n if (!session) return [];\n return [...session.launchers.values()]\n .map(({ options }) => ({\n id: options.id,\n source: options.source,\n label: options.label,\n ...(options.description ? { description: options.description } : {}),\n }))\n .sort((left, right) => left.label.localeCompare(right.label) || left.id.localeCompare(right.id));\n },\n listInstances() {\n const session = current(false)?.session;\n return session\n ? [...session.instances.values()]\n .map(snapshot)\n .sort((left, right) => left.instanceId.localeCompare(right.instanceId))\n : [];\n },\n subscribe(listener) {\n const target = current(true);\n if (!target) return () => undefined;\n target.session.listeners.add(listener);\n let disposed = false;\n return () => {\n if (disposed) return;\n disposed = true;\n target.session.listeners.delete(listener);\n cleanSession(target.key, target.session);\n };\n },\n async launch(launcherId, options) {\n const target = current(true);\n if (!target) throw new Error('The session-bound loop launcher registry is unavailable.');\n const normalizedLauncherId = validId(launcherId, LAUNCHER_ID_LABEL);\n const launcher = target.session.launchers.get(normalizedLauncherId);\n if (!launcher) throw new Error(`Loop launcher '${normalizedLauncherId}' is unavailable.`);\n const instanceId = validId(options?.instanceId ?? randomUUID(), INSTANCE_ID_LABEL);\n if (target.session.instances.has(instanceId)) throw new Error(`Loop instance '${instanceId}' already exists.`);\n const entry: InstanceEntry = { instanceId, launcher, abortController: new AbortController(), state: 'starting' };\n target.session.instances.set(instanceId, entry);\n notify(target.session);\n try {\n const handle = await launcher.options.launch({ instanceId, signal: entry.abortController.signal });\n const active = target.session.instances.get(instanceId) === entry && !entry.abortController.signal.aborted;\n if (!handle) {\n if (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\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 (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\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 = new Date().toISOString();\n notify(target.session);\n return snapshot(entry);\n } catch (error) {\n const cancelled = entry.abortController.signal.aborted;\n if (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\n if (cancelled) return undefined;\n throw error;\n }\n },\n async stop(instanceId, reason) {\n const session = current(false)?.session;\n if (!session) return false;\n const entry = session.instances.get(validId(instanceId, INSTANCE_ID_LABEL));\n if (!entry) return false;\n await stopEntry(session, entry, reason);\n return true;\n },\n async stopAll(reason) {\n const session = current(false)?.session;\n if (!session) return;\n await Promise.allSettled([...session.instances.values()].map((entry) => stopEntry(session, entry, reason)));\n },\n };\n}\n"],"mappings":"6BAEA,MAAM,EAAe,OAAO,IAAI,qCAAqC,EAE/D,EAAmB,kBACnB,EAAoB,mBACpB,EAAoB,mBAsE1B,SAAS,GAAyB,CAChC,IAAM,EAAO,WACb,MAAQ,GAAK,KAAkB,IAAI,GACrC,CAEA,SAAS,EAAQ,EAAe,EAAuB,CACrD,IAAM,EAAa,EAAM,KAAK,EAC1B,EAAa,GACjB,IAAK,IAAM,KAAa,EAAY,CAClC,IAAM,EAAO,EAAU,YAAY,CAAC,EACpC,GAAI,IAAS,IAAA,KAAc,GAAQ,IAAQ,IAAS,KAAO,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AU,IAAI,EAAQ,EAAY,CAAiB,CAAC,EAG1E,OAFK,GACL,MAAM,EAAU,EAAS,EAAO,CAAM,EAC/B,IAFY,EAGrB,EACA,MAAM,QAAQ,EAAQ,CACpB,IAAM,EAAU,EAAQ,EAAK,CAAC,EAAE,QAC3B,GACL,MAAM,QAAQ,WAAW,CAAC,GAAG,EAAQ,UAAU,OAAO,CAAC,CAAC,CAAC,IAAK,GAAU,EAAU,EAAS,EAAO,CAAM,CAAC,CAAC,CAC5G,CACF,CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/launcher.d.ts
|
|
2
|
+
interface LoopLaunchRequest {
|
|
3
|
+
readonly instanceId: string;
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
interface StoppableLoop {
|
|
7
|
+
readonly instanceId: string;
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
readonly detail?: string;
|
|
10
|
+
stop(reason?: string): void | Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
interface LoopLauncherSummary {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
}
|
|
18
|
+
interface LoopInstanceSnapshot {
|
|
19
|
+
readonly instanceId: string;
|
|
20
|
+
readonly launcherId: string;
|
|
21
|
+
readonly launcherLabel: string;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
readonly detail?: string;
|
|
24
|
+
readonly state: 'starting' | 'running' | 'stopping';
|
|
25
|
+
readonly startedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
interface LoopLauncherRegistration {
|
|
28
|
+
dispose(reason?: string): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
interface LoopLauncherClient {
|
|
31
|
+
listLaunchers(): readonly LoopLauncherSummary[];
|
|
32
|
+
listInstances(): readonly LoopInstanceSnapshot[];
|
|
33
|
+
subscribe(listener: () => void): () => void;
|
|
34
|
+
launch(launcherId: string, options?: {
|
|
35
|
+
instanceId?: string;
|
|
36
|
+
}): Promise<LoopInstanceSnapshot | undefined>;
|
|
37
|
+
stop(instanceId: string, reason?: string): Promise<boolean>;
|
|
38
|
+
stopAll(reason?: string): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
interface RegisterLoopLauncherOptions extends LoopLauncherSummary {
|
|
41
|
+
launch(request: LoopLaunchRequest): Promise<StoppableLoop | undefined>;
|
|
42
|
+
}
|
|
43
|
+
declare function registerLoopLauncher(sessionId: string, options: RegisterLoopLauncherOptions): LoopLauncherRegistration;
|
|
44
|
+
declare function createLoopLauncherClient(sessionId: () => string | undefined): LoopLauncherClient;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { LoopInstanceSnapshot, LoopLaunchRequest, LoopLauncherClient, LoopLauncherRegistration, LoopLauncherSummary, RegisterLoopLauncherOptions, StoppableLoop, createLoopLauncherClient, registerLoopLauncher };
|
|
47
|
+
//# sourceMappingURL=launcher.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.d.cts","names":[],"sources":["../src/launcher.ts"],"mappings":";UAQiB;WACN;WACA,QAAQ;;UAGF;WACN;WACA;WACA;EACT,KAAK,yBAAyB;;UAGf;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;;UAGM;EACf,QAAQ,kBAAkB;;UAGX;EACf,0BAA0B;EAC1B,0BAA0B;EAC1B,UAAU;EACV,OAAO,oBAAoB;IAAY;MAAwB,QAAQ;EACvE,KAAK,oBAAoB,kBAAkB;EAC3C,QAAQ,kBAAkB;;UAGX,oCAAoC;EACnD,OAAO,SAAS,oBAAoB,QAAQ;;iBAuF9B,qBACd,mBACA,SAAS,8BACR;iBA0Ba,yBAAyB,sCAAsC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/launcher.d.ts
|
|
2
|
+
interface LoopLaunchRequest {
|
|
3
|
+
readonly instanceId: string;
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
interface StoppableLoop {
|
|
7
|
+
readonly instanceId: string;
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
readonly detail?: string;
|
|
10
|
+
stop(reason?: string): void | Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
interface LoopLauncherSummary {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
}
|
|
18
|
+
interface LoopInstanceSnapshot {
|
|
19
|
+
readonly instanceId: string;
|
|
20
|
+
readonly launcherId: string;
|
|
21
|
+
readonly launcherLabel: string;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
readonly detail?: string;
|
|
24
|
+
readonly state: 'starting' | 'running' | 'stopping';
|
|
25
|
+
readonly startedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
interface LoopLauncherRegistration {
|
|
28
|
+
dispose(reason?: string): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
interface LoopLauncherClient {
|
|
31
|
+
listLaunchers(): readonly LoopLauncherSummary[];
|
|
32
|
+
listInstances(): readonly LoopInstanceSnapshot[];
|
|
33
|
+
subscribe(listener: () => void): () => void;
|
|
34
|
+
launch(launcherId: string, options?: {
|
|
35
|
+
instanceId?: string;
|
|
36
|
+
}): Promise<LoopInstanceSnapshot | undefined>;
|
|
37
|
+
stop(instanceId: string, reason?: string): Promise<boolean>;
|
|
38
|
+
stopAll(reason?: string): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
interface RegisterLoopLauncherOptions extends LoopLauncherSummary {
|
|
41
|
+
launch(request: LoopLaunchRequest): Promise<StoppableLoop | undefined>;
|
|
42
|
+
}
|
|
43
|
+
declare function registerLoopLauncher(sessionId: string, options: RegisterLoopLauncherOptions): LoopLauncherRegistration;
|
|
44
|
+
declare function createLoopLauncherClient(sessionId: () => string | undefined): LoopLauncherClient;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { LoopInstanceSnapshot, LoopLaunchRequest, LoopLauncherClient, LoopLauncherRegistration, LoopLauncherSummary, RegisterLoopLauncherOptions, StoppableLoop, createLoopLauncherClient, registerLoopLauncher };
|
|
47
|
+
//# sourceMappingURL=launcher.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.d.mts","names":[],"sources":["../src/launcher.ts"],"mappings":";UAQiB;WACN;WACA,QAAQ;;UAGF;WACN;WACA;WACA;EACT,KAAK,yBAAyB;;UAGf;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;;UAGM;EACf,QAAQ,kBAAkB;;UAGX;EACf,0BAA0B;EAC1B,0BAA0B;EAC1B,UAAU;EACV,OAAO,oBAAoB;IAAY;MAAwB,QAAQ;EACvE,KAAK,oBAAoB,kBAAkB;EAC3C,QAAQ,kBAAkB;;UAGX,oCAAoC;EACnD,OAAO,SAAS,oBAAoB,QAAQ;;iBAuF9B,qBACd,mBACA,SAAS,8BACR;iBA0Ba,yBAAyB,sCAAsC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";const t=Symbol.for(`@agimon-ai/doompi-loop.launchers.v1`),n=`loop session id`,r=`loop launcher id`,i=`loop instance id`;function a(){let e=globalThis;return e[t]??=new Map}function o(e,t){let n=e.trim(),r=!1;for(let e of n){let t=e.codePointAt(0);if(t!==void 0&&(t<=31||t===127)){r=!0;break}}if(!n||n.length>256||r)throw Error(`Invalid ${t}.`);return n}function s(e,t){let r=o(e,n),i=a().get(r);if(i||!t)return i;let s={launchers:new Map,instances:new Map,listeners:new Set};return a().set(r,s),s}function c(e){for(let t of e.listeners)t()}function l(e){return{instanceId:e.instanceId,launcherId:e.launcher.options.id,launcherLabel:e.launcher.options.label,...e.handle?.label?{label:e.handle.label}:{},...e.handle?.detail?{detail:e.handle.detail}:{},state:e.state,...e.startedAt?{startedAt:e.startedAt}:{}}}async function u(e,t,n){if(e.instances.get(t.instanceId)===t){t.state=`stopping`,t.abortController.abort(n),c(e);try{await t.handle?.stop(n)}finally{e.instances.get(t.instanceId)===t&&e.instances.delete(t.instanceId),c(e)}}}function d(e,t){t.launchers.size||t.instances.size||t.listeners.size||a().get(e)===t&&a().delete(e)}function f(e,t){let i=o(e,n),a=o(t.id,r),l=s(i,!0);if(l.launchers.has(a))throw Error(`Loop launcher '${a}' is already registered for session '${i}'.`);let f={token:Symbol(a),options:{...t,id:a}};l.launchers.set(a,f),c(l);let p=!1;return{async dispose(e=`Loop launcher disposed.`){if(p)return;p=!0;let t=s(i,!1);if(!t||t.launchers.get(a)?.token!==f.token)return;t.launchers.delete(a);let n=[...t.instances.values()].filter(e=>e.launcher.token===f.token);await Promise.allSettled(n.map(n=>u(t,n,e))),c(t),d(i,t)}}}function p(t){let a=e=>{let r=t();if(!r)return;let i=o(r,n),a=s(i,e);return a?{key:i,session:a}:void 0};return{listLaunchers(){let e=a(!1)?.session;return e?[...e.launchers.values()].map(({options:e})=>({id:e.id,source:e.source,label:e.label,...e.description?{description:e.description}:{}})).sort((e,t)=>e.label.localeCompare(t.label)||e.id.localeCompare(t.id)):[]},listInstances(){let e=a(!1)?.session;return e?[...e.instances.values()].map(l).sort((e,t)=>e.instanceId.localeCompare(t.instanceId)):[]},subscribe(e){let t=a(!0);if(!t)return()=>void 0;t.session.listeners.add(e);let n=!1;return()=>{n||(n=!0,t.session.listeners.delete(e),d(t.key,t.session))}},async launch(t,n){let s=a(!0);if(!s)throw Error(`The session-bound loop launcher registry is unavailable.`);let u=o(t,r),d=s.session.launchers.get(u);if(!d)throw Error(`Loop launcher '${u}' is unavailable.`);let f=o(n?.instanceId??e(),i);if(s.session.instances.has(f))throw Error(`Loop instance '${f}' already exists.`);let p={instanceId:f,launcher:d,abortController:new AbortController,state:`starting`};s.session.instances.set(f,p),c(s.session);try{let e=await d.options.launch({instanceId:f,signal:p.abortController.signal}),t=s.session.instances.get(f)===p&&!p.abortController.signal.aborted;if(!e){s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session);return}if(!t||e.instanceId!==f){if(await e.stop(t?`Loop launcher returned a mismatched instance id.`:`Loop launch was cancelled.`),s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session),t)throw Error(`Loop launcher '${u}' returned a mismatched instance id.`);return}return p.handle=e,p.state=`running`,p.startedAt=new Date().toISOString(),c(s.session),l(p)}catch(e){let t=p.abortController.signal.aborted;if(s.session.instances.get(f)===p&&s.session.instances.delete(f),c(s.session),t)return;throw e}},async stop(e,t){let n=a(!1)?.session;if(!n)return!1;let r=n.instances.get(o(e,i));return r?(await u(n,r,t),!0):!1},async stopAll(e){let t=a(!1)?.session;t&&await Promise.allSettled([...t.instances.values()].map(n=>u(t,n,e)))}}}export{p as createLoopLauncherClient,f as registerLoopLauncher};
|
|
2
|
+
//# sourceMappingURL=launcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.mjs","names":[],"sources":["../src/launcher.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nconst REGISTRY_KEY = Symbol.for('@agimon-ai/doompi-loop.launchers.v1');\nconst MAX_ID_LENGTH = 256;\nconst SESSION_ID_LABEL = 'loop session id';\nconst LAUNCHER_ID_LABEL = 'loop launcher id';\nconst INSTANCE_ID_LABEL = 'loop instance id';\n\nexport interface LoopLaunchRequest {\n readonly instanceId: string;\n readonly signal: AbortSignal;\n}\n\nexport interface StoppableLoop {\n readonly instanceId: string;\n readonly label?: string;\n readonly detail?: string;\n stop(reason?: string): void | Promise<void>;\n}\n\nexport interface LoopLauncherSummary {\n readonly id: string;\n readonly source: string;\n readonly label: string;\n readonly description?: string;\n}\n\nexport interface LoopInstanceSnapshot {\n readonly instanceId: string;\n readonly launcherId: string;\n readonly launcherLabel: string;\n readonly label?: string;\n readonly detail?: string;\n readonly state: 'starting' | 'running' | 'stopping';\n readonly startedAt?: string;\n}\n\nexport interface LoopLauncherRegistration {\n dispose(reason?: string): Promise<void>;\n}\n\nexport interface LoopLauncherClient {\n listLaunchers(): readonly LoopLauncherSummary[];\n listInstances(): readonly LoopInstanceSnapshot[];\n subscribe(listener: () => void): () => void;\n launch(launcherId: string, options?: { instanceId?: string }): Promise<LoopInstanceSnapshot | undefined>;\n stop(instanceId: string, reason?: string): Promise<boolean>;\n stopAll(reason?: string): Promise<void>;\n}\n\nexport interface RegisterLoopLauncherOptions extends LoopLauncherSummary {\n launch(request: LoopLaunchRequest): Promise<StoppableLoop | undefined>;\n}\n\ninterface LauncherEntry {\n readonly token: symbol;\n readonly options: RegisterLoopLauncherOptions;\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\ninterface SessionRegistry {\n readonly launchers: Map<string, LauncherEntry>;\n readonly instances: Map<string, InstanceEntry>;\n readonly listeners: Set<() => void>;\n}\n\ntype LoopRegistry = Map<string, SessionRegistry>;\n\nfunction registry(): LoopRegistry {\n const root = globalThis as typeof globalThis & { [REGISTRY_KEY]?: LoopRegistry };\n return (root[REGISTRY_KEY] ??= new Map());\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 getSession(sessionId: string, create: boolean): SessionRegistry | undefined {\n const key = validId(sessionId, SESSION_ID_LABEL);\n const existing = registry().get(key);\n if (existing || !create) return existing;\n const created: SessionRegistry = { launchers: new Map(), instances: new Map(), listeners: new Set() };\n registry().set(key, created);\n return created;\n}\n\nfunction notify(session: SessionRegistry): void {\n for (const listener of session.listeners) listener();\n}\n\nfunction snapshot(entry: InstanceEntry): LoopInstanceSnapshot {\n return {\n instanceId: entry.instanceId,\n launcherId: entry.launcher.options.id,\n launcherLabel: entry.launcher.options.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\nasync function stopEntry(session: SessionRegistry, entry: InstanceEntry, reason?: string): Promise<void> {\n if (session.instances.get(entry.instanceId) !== entry) return;\n entry.state = 'stopping';\n entry.abortController.abort(reason);\n notify(session);\n try {\n await entry.handle?.stop(reason);\n } finally {\n if (session.instances.get(entry.instanceId) === entry) session.instances.delete(entry.instanceId);\n notify(session);\n }\n}\n\nfunction cleanSession(sessionId: string, session: SessionRegistry): void {\n if (session.launchers.size || session.instances.size || session.listeners.size) return;\n if (registry().get(sessionId) === session) registry().delete(sessionId);\n}\n\nexport function registerLoopLauncher(\n sessionId: string,\n options: RegisterLoopLauncherOptions,\n): LoopLauncherRegistration {\n const sessionKey = validId(sessionId, SESSION_ID_LABEL);\n const launcherId = validId(options.id, LAUNCHER_ID_LABEL);\n const session = getSession(sessionKey, true) as SessionRegistry;\n if (session.launchers.has(launcherId)) {\n throw new Error(`Loop launcher '${launcherId}' is already registered for session '${sessionKey}'.`);\n }\n const entry: LauncherEntry = { token: Symbol(launcherId), options: { ...options, id: launcherId } };\n session.launchers.set(launcherId, entry);\n notify(session);\n let disposed = false;\n return {\n async dispose(reason = 'Loop launcher disposed.'): Promise<void> {\n if (disposed) return;\n disposed = true;\n const current = getSession(sessionKey, false);\n if (!current || current.launchers.get(launcherId)?.token !== entry.token) return;\n current.launchers.delete(launcherId);\n const owned = [...current.instances.values()].filter((instance) => instance.launcher.token === entry.token);\n await Promise.allSettled(owned.map((instance) => stopEntry(current, instance, reason)));\n notify(current);\n cleanSession(sessionKey, current);\n },\n };\n}\n\nexport function createLoopLauncherClient(sessionId: () => string | undefined): LoopLauncherClient {\n const current = (create: boolean): { key: string; session: SessionRegistry } | undefined => {\n const value = sessionId();\n if (!value) return undefined;\n const key = validId(value, SESSION_ID_LABEL);\n const session = getSession(key, create);\n return session ? { key, session } : undefined;\n };\n return {\n listLaunchers() {\n const session = current(false)?.session;\n if (!session) return [];\n return [...session.launchers.values()]\n .map(({ options }) => ({\n id: options.id,\n source: options.source,\n label: options.label,\n ...(options.description ? { description: options.description } : {}),\n }))\n .sort((left, right) => left.label.localeCompare(right.label) || left.id.localeCompare(right.id));\n },\n listInstances() {\n const session = current(false)?.session;\n return session\n ? [...session.instances.values()]\n .map(snapshot)\n .sort((left, right) => left.instanceId.localeCompare(right.instanceId))\n : [];\n },\n subscribe(listener) {\n const target = current(true);\n if (!target) return () => undefined;\n target.session.listeners.add(listener);\n let disposed = false;\n return () => {\n if (disposed) return;\n disposed = true;\n target.session.listeners.delete(listener);\n cleanSession(target.key, target.session);\n };\n },\n async launch(launcherId, options) {\n const target = current(true);\n if (!target) throw new Error('The session-bound loop launcher registry is unavailable.');\n const normalizedLauncherId = validId(launcherId, LAUNCHER_ID_LABEL);\n const launcher = target.session.launchers.get(normalizedLauncherId);\n if (!launcher) throw new Error(`Loop launcher '${normalizedLauncherId}' is unavailable.`);\n const instanceId = validId(options?.instanceId ?? randomUUID(), INSTANCE_ID_LABEL);\n if (target.session.instances.has(instanceId)) throw new Error(`Loop instance '${instanceId}' already exists.`);\n const entry: InstanceEntry = { instanceId, launcher, abortController: new AbortController(), state: 'starting' };\n target.session.instances.set(instanceId, entry);\n notify(target.session);\n try {\n const handle = await launcher.options.launch({ instanceId, signal: entry.abortController.signal });\n const active = target.session.instances.get(instanceId) === entry && !entry.abortController.signal.aborted;\n if (!handle) {\n if (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\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 (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\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 = new Date().toISOString();\n notify(target.session);\n return snapshot(entry);\n } catch (error) {\n const cancelled = entry.abortController.signal.aborted;\n if (target.session.instances.get(instanceId) === entry) target.session.instances.delete(instanceId);\n notify(target.session);\n if (cancelled) return undefined;\n throw error;\n }\n },\n async stop(instanceId, reason) {\n const session = current(false)?.session;\n if (!session) return false;\n const entry = session.instances.get(validId(instanceId, INSTANCE_ID_LABEL));\n if (!entry) return false;\n await stopEntry(session, entry, reason);\n return true;\n },\n async stopAll(reason) {\n const session = current(false)?.session;\n if (!session) return;\n await Promise.allSettled([...session.instances.values()].map((entry) => stopEntry(session, entry, reason)));\n },\n };\n}\n"],"mappings":"yCAEA,MAAM,EAAe,OAAO,IAAI,qCAAqC,EAE/D,EAAmB,kBACnB,EAAoB,mBACpB,EAAoB,mBAsE1B,SAAS,GAAyB,CAChC,IAAM,EAAO,WACb,MAAQ,GAAK,KAAkB,IAAI,GACrC,CAEA,SAAS,EAAQ,EAAe,EAAuB,CACrD,IAAM,EAAa,EAAM,KAAK,EAC1B,EAAa,GACjB,IAAK,IAAM,KAAa,EAAY,CAClC,IAAM,EAAO,EAAU,YAAY,CAAC,EACpC,GAAI,IAAS,IAAA,KAAc,GAAQ,IAAQ,IAAS,KAAO,CACzD,EAAa,GACb,KACF,CACF,CACA,GAAI,CAAC,GAAc,EAAW,OAAS,KAAiB,EAAY,MAAU,MAAM,WAAW,EAAM,EAAE,EACvG,OAAO,CACT,CAEA,SAAS,EAAW,EAAmB,EAA8C,CACnF,IAAM,EAAM,EAAQ,EAAW,CAAgB,EACzC,EAAW,EAAS,CAAC,CAAC,IAAI,CAAG,EACnC,GAAI,GAAY,CAAC,EAAQ,OAAO,EAChC,IAAM,EAA2B,CAAE,UAAW,IAAI,IAAO,UAAW,IAAI,IAAO,UAAW,IAAI,GAAM,EAEpG,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const e=require("./constants.cjs");let t=require("@agimon-ai/doompi-ui/leader");function n(n){return(0,t.registerDoomLeaderContribution)(n,{source:e.PACKAGE_SOURCE,bindings:[{id:`loop.start`,path:[{key:`l`,label:`loops`,order:60},{key:`s`,label:`start`}],command:{name:e.START_COMMAND_NAME}},{id:`loop.list`,path:[{key:`l`,label:`loops`,order:60},{key:`l`,label:`list`,detail:`stop`}],command:{name:e.LIST_COMMAND_NAME}}]})}exports.registerLeaderContribution=n;
|
|
2
|
+
//# sourceMappingURL=leader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leader.cjs","names":["registerDoomLeaderContribution","PACKAGE_SOURCE","START_COMMAND_NAME","LIST_COMMAND_NAME"],"sources":["../src/leader.ts"],"sourcesContent":["import { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { LIST_COMMAND_NAME, LOOPS_GROUP_ORDER, PACKAGE_SOURCE, START_COMMAND_NAME } from './constants.ts';\n\nexport function registerLeaderContribution(pi: Pick<ExtensionAPI, 'events' | 'on'>): () => void {\n return registerDoomLeaderContribution(pi, {\n source: PACKAGE_SOURCE,\n bindings: [\n {\n id: 'loop.start',\n path: [\n { key: 'l', label: 'loops', order: LOOPS_GROUP_ORDER },\n { key: 's', label: 'start' },\n ],\n command: { name: START_COMMAND_NAME },\n },\n {\n id: 'loop.list',\n path: [\n { key: 'l', label: 'loops', order: LOOPS_GROUP_ORDER },\n { key: 'l', label: 'list', detail: 'stop' },\n ],\n command: { name: LIST_COMMAND_NAME },\n },\n ],\n });\n}\n"],"mappings":"gFAIA,SAAgB,EAA2B,EAAqD,CAC9F,OAAA,EAAOA,EAAAA,+BAAAA,CAA+B,EAAI,CACxC,OAAQC,EAAAA,eACR,SAAU,CACR,CACE,GAAI,aACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAA,EAAyB,EACrD,CAAE,IAAK,IAAK,MAAO,OAAQ,CAC7B,EACA,QAAS,CAAE,KAAMC,EAAAA,kBAAmB,CACtC,EACA,CACE,GAAI,YACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAA,EAAyB,EACrD,CAAE,IAAK,IAAK,MAAO,OAAQ,OAAQ,MAAO,CAC5C,EACA,QAAS,CAAE,KAAMC,EAAAA,iBAAkB,CACrC,CACF,CACF,CAAC,CACH"}
|
package/dist/leader.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{LIST_COMMAND_NAME as e,PACKAGE_SOURCE as t,START_COMMAND_NAME as n}from"./constants.mjs";import{registerDoomLeaderContribution as r}from"@agimon-ai/doompi-ui/leader";function i(i){return r(i,{source:t,bindings:[{id:`loop.start`,path:[{key:`l`,label:`loops`,order:60},{key:`s`,label:`start`}],command:{name:n}},{id:`loop.list`,path:[{key:`l`,label:`loops`,order:60},{key:`l`,label:`list`,detail:`stop`}],command:{name:e}}]})}export{i as registerLeaderContribution};
|
|
2
|
+
//# sourceMappingURL=leader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leader.mjs","names":[],"sources":["../src/leader.ts"],"sourcesContent":["import { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { LIST_COMMAND_NAME, LOOPS_GROUP_ORDER, PACKAGE_SOURCE, START_COMMAND_NAME } from './constants.ts';\n\nexport function registerLeaderContribution(pi: Pick<ExtensionAPI, 'events' | 'on'>): () => void {\n return registerDoomLeaderContribution(pi, {\n source: PACKAGE_SOURCE,\n bindings: [\n {\n id: 'loop.start',\n path: [\n { key: 'l', label: 'loops', order: LOOPS_GROUP_ORDER },\n { key: 's', label: 'start' },\n ],\n command: { name: START_COMMAND_NAME },\n },\n {\n id: 'loop.list',\n path: [\n { key: 'l', label: 'loops', order: LOOPS_GROUP_ORDER },\n { key: 'l', label: 'list', detail: 'stop' },\n ],\n command: { name: LIST_COMMAND_NAME },\n },\n ],\n });\n}\n"],"mappings":"6KAIA,SAAgB,EAA2B,EAAqD,CAC9F,OAAO,EAA+B,EAAI,CACxC,OAAQ,EACR,SAAU,CACR,CACE,GAAI,aACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAA,EAAyB,EACrD,CAAE,IAAK,IAAK,MAAO,OAAQ,CAC7B,EACA,QAAS,CAAE,KAAM,CAAmB,CACtC,EACA,CACE,GAAI,YACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAA,EAAyB,EACrD,CAAE,IAAK,IAAK,MAAO,OAAQ,OAAQ,MAAO,CAC5C,EACA,QAAS,CAAE,KAAM,CAAkB,CACrC,CACF,CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("@agimon-ai/doompi-ui/components/doomOverlay"),t=require("@earendil-works/pi-tui");const n=`Stopped from the loop list.`;var r=class extends e.DoomOverlay{client;done;unsubscribe;instances;selected=0;constructor(e,t,n,r){super(e,t),this.client=n,this.done=r,this.instances=n.listInstances(),this.unsubscribe=n.subscribe(()=>this.refresh())}dispose(){this.unsubscribe()}handleInput(e){if((0,t.matchesKey)(e,`escape`)||(0,t.matchesKey)(e,`ctrl+c`)||e===`q`)return this.done(void 0);if((0,t.matchesKey)(e,`up`)||e===`k`)return this.move(-1);if((0,t.matchesKey)(e,`down`)||e===`j`)return this.move(1);if(e===`x`){let e=this.instances[this.selected];e&&this.client.stop(e.instanceId,n)}}getChrome(){return{title:`LOOPS`,breadcrumb:`SPC › l / loops › l / list`,headerRight:`${this.instances.length} active`,footer:`x stop · j/k move · esc close · launched detached work continues`,footerHints:[[`x`,`stop scheduling`],[`j/k`,`move`],[`esc`,`close`]],accent:e.DOOM_OVERLAY_ACCENT}}renderBody(e){let n=this.theme.fg(`dim`,(0,t.truncateToWidth)(`Stopping a loop does not cancel detached work already launched.`,e));return this.instances.length?[n,``,...this.instances.flatMap((n,r)=>{let i=r===this.selected?this.theme.fg(`accent`,`▸`):` `,a=n.label??n.launcherLabel,o=this.theme.fg(n.state===`running`?`success`:`warning`,n.state),s=(0,t.truncateToWidth)(`${i} ${a} · ${o}`,e),c=n.detail??n.instanceId;return[s,` ${this.theme.fg(`dim`,(0,t.truncateToWidth)(c,Math.max(0,e-4)))}`]})]:[this.theme.fg(`dim`,`No loop instances are active in this session.`),``,n]}refresh(){this.instances=this.client.listInstances(),this.selected=Math.min(this.selected,Math.max(0,this.instances.length-1)),this.invalidate()}move(e){this.instances.length&&(this.selected=Math.max(0,Math.min(this.selected+e,this.instances.length-1)),this.invalidate())}};async function i(t,i){if(t.mode!==`tui`){let e=i.listInstances(),r=e.map(e=>`${e.label??e.launcherLabel} (${e.instanceId})`),a=await t.ui.select(`Stop loop scheduling`,r),o=e[r.indexOf(a??``)];o&&await i.stop(o.instanceId,n);return}await t.ui.custom((e,t,n,a)=>new r(e,t,i,a),e.DOOM_FULLSCREEN_UI_OPTIONS)}exports.LoopListOverlay=r,exports.openLoopListOverlay=i;
|
|
2
|
+
//# sourceMappingURL=loopListOverlay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopListOverlay.cjs","names":["DoomOverlay","matchesKey","DOOM_OVERLAY_ACCENT","truncateToWidth","DOOM_FULLSCREEN_UI_OPTIONS"],"sources":["../../src/tui/loopListOverlay.ts"],"sourcesContent":["import {\n DOOM_FULLSCREEN_UI_OPTIONS,\n DOOM_OVERLAY_ACCENT,\n DoomOverlay,\n type DoomOverlayChrome,\n type DoomOverlayTui,\n} from '@agimon-ai/doompi-ui/components/doomOverlay';\nimport type { ExtensionContext, Theme } from '@earendil-works/pi-coding-agent';\nimport { matchesKey, truncateToWidth } from '@earendil-works/pi-tui';\nimport type { LoopInstanceSnapshot, LoopLauncherClient } from '../launcher.ts';\n\nconst EMPTY_MESSAGE = 'No loop instances are active in this session.';\nconst STOP_SCOPE_MESSAGE = 'Stopping a loop does not cancel detached work already launched.';\nconst STOP_REASON = 'Stopped from the loop list.';\n\nexport class LoopListOverlay extends DoomOverlay {\n private readonly unsubscribe: () => void;\n private instances: readonly LoopInstanceSnapshot[];\n private selected = 0;\n\n constructor(\n tui: DoomOverlayTui,\n theme: Theme,\n private readonly client: LoopLauncherClient,\n private readonly done: (result: undefined) => void,\n ) {\n super(tui, theme);\n this.instances = client.listInstances();\n this.unsubscribe = client.subscribe(() => this.refresh());\n }\n\n dispose(): void {\n this.unsubscribe();\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c') || data === 'q') return this.done(undefined);\n if (matchesKey(data, 'up') || data === 'k') return this.move(-1);\n if (matchesKey(data, 'down') || data === 'j') return this.move(1);\n if (data === 'x') {\n const instance = this.instances[this.selected];\n if (instance) void this.client.stop(instance.instanceId, STOP_REASON);\n }\n }\n\n protected getChrome(): DoomOverlayChrome {\n return {\n title: 'LOOPS',\n breadcrumb: 'SPC › l / loops › l / list',\n headerRight: `${this.instances.length} active`,\n footer: 'x stop · j/k move · esc close · launched detached work continues',\n footerHints: [\n ['x', 'stop scheduling'],\n ['j/k', 'move'],\n ['esc', 'close'],\n ],\n accent: DOOM_OVERLAY_ACCENT,\n };\n }\n\n protected renderBody(width: number): string[] {\n const stopScope = this.theme.fg('dim', truncateToWidth(STOP_SCOPE_MESSAGE, width));\n if (!this.instances.length) return [this.theme.fg('dim', EMPTY_MESSAGE), '', stopScope];\n return [\n stopScope,\n '',\n ...this.instances.flatMap((instance, index) => {\n const marker = index === this.selected ? this.theme.fg('accent', '▸') : ' ';\n const name = instance.label ?? instance.launcherLabel;\n const state = this.theme.fg(instance.state === 'running' ? 'success' : 'warning', instance.state);\n const line = truncateToWidth(`${marker} ${name} · ${state}`, width);\n const detail = instance.detail ?? instance.instanceId;\n return [line, ` ${this.theme.fg('dim', truncateToWidth(detail, Math.max(0, width - 4)))}`];\n }),\n ];\n }\n\n private refresh(): void {\n this.instances = this.client.listInstances();\n this.selected = Math.min(this.selected, Math.max(0, this.instances.length - 1));\n this.invalidate();\n }\n\n private move(delta: number): void {\n if (!this.instances.length) return;\n this.selected = Math.max(0, Math.min(this.selected + delta, this.instances.length - 1));\n this.invalidate();\n }\n}\n\nexport async function openLoopListOverlay(ctx: ExtensionContext, client: LoopLauncherClient): Promise<void> {\n if (ctx.mode !== 'tui') {\n const instances = client.listInstances();\n const labels = instances.map((instance) => `${instance.label ?? instance.launcherLabel} (${instance.instanceId})`);\n const selected = await ctx.ui.select('Stop loop scheduling', labels);\n const instance = instances[labels.indexOf(selected ?? '')];\n if (instance) await client.stop(instance.instanceId, STOP_REASON);\n return;\n }\n await ctx.ui.custom<undefined>(\n (tui, theme, _keybindings, done) => new LoopListOverlay(tui, theme, client, done),\n DOOM_FULLSCREEN_UI_OPTIONS,\n );\n}\n"],"mappings":"iGAWA,MAEM,EAAc,8BAEpB,IAAa,EAAb,cAAqCA,EAAAA,WAAY,CAQ5B,OACA,KARnB,YACA,UACA,SAAmB,EAEnB,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,EAAK,CAAK,EAHC,KAAA,OAAA,EACA,KAAA,KAAA,EAGjB,KAAK,UAAY,EAAO,cAAc,EACtC,KAAK,YAAc,EAAO,cAAgB,KAAK,QAAQ,CAAC,CAC1D,CAEA,SAAgB,CACd,KAAK,YAAY,CACnB,CAEA,YAAY,EAAoB,CAC9B,IAAA,EAAIC,EAAAA,WAAAA,CAAW,EAAM,QAAQ,IAAA,EAAKA,EAAAA,WAAAA,CAAW,EAAM,QAAQ,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,IAAA,EAAS,EACxG,IAAA,EAAIA,EAAAA,WAAAA,CAAW,EAAM,IAAI,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,EAAE,EAC/D,IAAA,EAAIA,EAAAA,WAAAA,CAAW,EAAM,MAAM,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,CAAC,EAChE,GAAI,IAAS,IAAK,CA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SACpB,KAAK,SAAW,KAAK,IAAI,EAAG,KAAK,IAAI,KAAK,SAAW,EAAO,KAAK,UAAU,OAAS,CAAC,CAAC,EACtF,KAAK,WAAW,EAClB,CACF,EAEA,eAAsB,EAAoB,EAAuB,EAA2C,CAC1G,GAAI,EAAI,OAAS,MAAO,CACtB,IAAM,EAAY,EAAO,cAAc,EACjC,EAAS,EAAU,IAAK,GAAa,GAAG,EAAS,OAAS,EAAS,cAAc,IAAI,EAAS,WAAW,EAAE,EAC3G,EAAW,MAAM,EAAI,GAAG,OAAO,uBAAwB,CAAM,EAC7D,EAAW,EAAU,EAAO,QAAQ,GAAY,EAAE,GACpD,GAAU,MAAM,EAAO,KAAK,EAAS,WAAY,CAAW,EAChE,MACF,CACA,MAAM,EAAI,GAAG,QACV,EAAK,EAAO,EAAc,IAAS,IAAI,EAAgB,EAAK,EAAO,EAAQ,CAAI,EAChFC,EAAAA,0BACF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DOOM_FULLSCREEN_UI_OPTIONS as e,DOOM_OVERLAY_ACCENT as t,DoomOverlay as n}from"@agimon-ai/doompi-ui/components/doomOverlay";import{matchesKey as r,truncateToWidth as i}from"@earendil-works/pi-tui";const a=`Stopped from the loop list.`;var o=class extends n{client;done;unsubscribe;instances;selected=0;constructor(e,t,n,r){super(e,t),this.client=n,this.done=r,this.instances=n.listInstances(),this.unsubscribe=n.subscribe(()=>this.refresh())}dispose(){this.unsubscribe()}handleInput(e){if(r(e,`escape`)||r(e,`ctrl+c`)||e===`q`)return this.done(void 0);if(r(e,`up`)||e===`k`)return this.move(-1);if(r(e,`down`)||e===`j`)return this.move(1);if(e===`x`){let e=this.instances[this.selected];e&&this.client.stop(e.instanceId,a)}}getChrome(){return{title:`LOOPS`,breadcrumb:`SPC › l / loops › l / list`,headerRight:`${this.instances.length} active`,footer:`x stop · j/k move · esc close · launched detached work continues`,footerHints:[[`x`,`stop scheduling`],[`j/k`,`move`],[`esc`,`close`]],accent:t}}renderBody(e){let t=this.theme.fg(`dim`,i(`Stopping a loop does not cancel detached work already launched.`,e));return this.instances.length?[t,``,...this.instances.flatMap((t,n)=>{let r=n===this.selected?this.theme.fg(`accent`,`▸`):` `,a=t.label??t.launcherLabel,o=this.theme.fg(t.state===`running`?`success`:`warning`,t.state),s=i(`${r} ${a} · ${o}`,e),c=t.detail??t.instanceId;return[s,` ${this.theme.fg(`dim`,i(c,Math.max(0,e-4)))}`]})]:[this.theme.fg(`dim`,`No loop instances are active in this session.`),``,t]}refresh(){this.instances=this.client.listInstances(),this.selected=Math.min(this.selected,Math.max(0,this.instances.length-1)),this.invalidate()}move(e){this.instances.length&&(this.selected=Math.max(0,Math.min(this.selected+e,this.instances.length-1)),this.invalidate())}};async function s(t,n){if(t.mode!==`tui`){let e=n.listInstances(),r=e.map(e=>`${e.label??e.launcherLabel} (${e.instanceId})`),i=await t.ui.select(`Stop loop scheduling`,r),o=e[r.indexOf(i??``)];o&&await n.stop(o.instanceId,a);return}await t.ui.custom((e,t,r,i)=>new o(e,t,n,i),e)}export{o as LoopListOverlay,s as openLoopListOverlay};
|
|
2
|
+
//# sourceMappingURL=loopListOverlay.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopListOverlay.mjs","names":[],"sources":["../../src/tui/loopListOverlay.ts"],"sourcesContent":["import {\n DOOM_FULLSCREEN_UI_OPTIONS,\n DOOM_OVERLAY_ACCENT,\n DoomOverlay,\n type DoomOverlayChrome,\n type DoomOverlayTui,\n} from '@agimon-ai/doompi-ui/components/doomOverlay';\nimport type { ExtensionContext, Theme } from '@earendil-works/pi-coding-agent';\nimport { matchesKey, truncateToWidth } from '@earendil-works/pi-tui';\nimport type { LoopInstanceSnapshot, LoopLauncherClient } from '../launcher.ts';\n\nconst EMPTY_MESSAGE = 'No loop instances are active in this session.';\nconst STOP_SCOPE_MESSAGE = 'Stopping a loop does not cancel detached work already launched.';\nconst STOP_REASON = 'Stopped from the loop list.';\n\nexport class LoopListOverlay extends DoomOverlay {\n private readonly unsubscribe: () => void;\n private instances: readonly LoopInstanceSnapshot[];\n private selected = 0;\n\n constructor(\n tui: DoomOverlayTui,\n theme: Theme,\n private readonly client: LoopLauncherClient,\n private readonly done: (result: undefined) => void,\n ) {\n super(tui, theme);\n this.instances = client.listInstances();\n this.unsubscribe = client.subscribe(() => this.refresh());\n }\n\n dispose(): void {\n this.unsubscribe();\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c') || data === 'q') return this.done(undefined);\n if (matchesKey(data, 'up') || data === 'k') return this.move(-1);\n if (matchesKey(data, 'down') || data === 'j') return this.move(1);\n if (data === 'x') {\n const instance = this.instances[this.selected];\n if (instance) void this.client.stop(instance.instanceId, STOP_REASON);\n }\n }\n\n protected getChrome(): DoomOverlayChrome {\n return {\n title: 'LOOPS',\n breadcrumb: 'SPC › l / loops › l / list',\n headerRight: `${this.instances.length} active`,\n footer: 'x stop · j/k move · esc close · launched detached work continues',\n footerHints: [\n ['x', 'stop scheduling'],\n ['j/k', 'move'],\n ['esc', 'close'],\n ],\n accent: DOOM_OVERLAY_ACCENT,\n };\n }\n\n protected renderBody(width: number): string[] {\n const stopScope = this.theme.fg('dim', truncateToWidth(STOP_SCOPE_MESSAGE, width));\n if (!this.instances.length) return [this.theme.fg('dim', EMPTY_MESSAGE), '', stopScope];\n return [\n stopScope,\n '',\n ...this.instances.flatMap((instance, index) => {\n const marker = index === this.selected ? this.theme.fg('accent', '▸') : ' ';\n const name = instance.label ?? instance.launcherLabel;\n const state = this.theme.fg(instance.state === 'running' ? 'success' : 'warning', instance.state);\n const line = truncateToWidth(`${marker} ${name} · ${state}`, width);\n const detail = instance.detail ?? instance.instanceId;\n return [line, ` ${this.theme.fg('dim', truncateToWidth(detail, Math.max(0, width - 4)))}`];\n }),\n ];\n }\n\n private refresh(): void {\n this.instances = this.client.listInstances();\n this.selected = Math.min(this.selected, Math.max(0, this.instances.length - 1));\n this.invalidate();\n }\n\n private move(delta: number): void {\n if (!this.instances.length) return;\n this.selected = Math.max(0, Math.min(this.selected + delta, this.instances.length - 1));\n this.invalidate();\n }\n}\n\nexport async function openLoopListOverlay(ctx: ExtensionContext, client: LoopLauncherClient): Promise<void> {\n if (ctx.mode !== 'tui') {\n const instances = client.listInstances();\n const labels = instances.map((instance) => `${instance.label ?? instance.launcherLabel} (${instance.instanceId})`);\n const selected = await ctx.ui.select('Stop loop scheduling', labels);\n const instance = instances[labels.indexOf(selected ?? '')];\n if (instance) await client.stop(instance.instanceId, STOP_REASON);\n return;\n }\n await ctx.ui.custom<undefined>(\n (tui, theme, _keybindings, done) => new LoopListOverlay(tui, theme, client, done),\n DOOM_FULLSCREEN_UI_OPTIONS,\n );\n}\n"],"mappings":"4MAWA,MAEM,EAAc,8BAEpB,IAAa,EAAb,cAAqC,CAAY,CAQ5B,OACA,KARnB,YACA,UACA,SAAmB,EAEnB,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,EAAK,CAAK,EAHC,KAAA,OAAA,EACA,KAAA,KAAA,EAGjB,KAAK,UAAY,EAAO,cAAc,EACtC,KAAK,YAAc,EAAO,cAAgB,KAAK,QAAQ,CAAC,CAC1D,CAEA,SAAgB,CACd,KAAK,YAAY,CACnB,CAEA,YAAY,EAAoB,CAC9B,GAAI,EAAW,EAAM,QAAQ,GAAK,EAAW,EAAM,QAAQ,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,IAAA,EAAS,EACxG,GAAI,EAAW,EAAM,IAAI,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,EAAE,EAC/D,GAAI,EAAW,EAAM,MAAM,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,CAAC,EAChE,GAAI,IAAS,IAAK,CAChB,IAAM,EAAW,KAAK,UAAU,KAAK,UACjC,GAAU,KAAU,OAAO,KAAK,EAAS,WAAY,CAAW,CACtE,CACF,CAEA,WAAyC,CACvC,MAAO,CACL,MAAO,QACP,WAAY,6BACZ,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jC,EAAS,EAAU,IAAK,GAAa,GAAG,EAAS,OAAS,EAAS,cAAc,IAAI,EAAS,WAAW,EAAE,EAC3G,EAAW,MAAM,EAAI,GAAG,OAAO,uBAAwB,CAAM,EAC7D,EAAW,EAAU,EAAO,QAAQ,GAAY,EAAE,GACpD,GAAU,MAAM,EAAO,KAAK,EAAS,WAAY,CAAW,EAChE,MACF,CACA,MAAM,EAAI,GAAG,QACV,EAAK,EAAO,EAAc,IAAS,IAAI,EAAgB,EAAK,EAAO,EAAQ,CAAI,EAChF,CACF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("@agimon-ai/doompi-ui/components/doomOverlay"),t=require("@earendil-works/pi-tui");var n=class extends e.DoomOverlay{launchers;done;selected=0;constructor(e,t,n,r){super(e,t),this.launchers=n,this.done=r}handleInput(e){if((0,t.matchesKey)(e,`escape`)||(0,t.matchesKey)(e,`ctrl+c`)||e===`q`)return this.done(void 0);if((0,t.matchesKey)(e,`up`)||e===`k`)return this.move(-1);if((0,t.matchesKey)(e,`down`)||e===`j`)return this.move(1);(0,t.matchesKey)(e,`enter`)&&this.done(this.launchers[this.selected]?.id)}getChrome(){return{title:`START LOOP`,breadcrumb:`SPC › l / loops › s / start`,footer:`enter launch · j/k move · esc close`,footerHints:[[`enter`,`launch`],[`j/k`,`move`],[`esc`,`close`]],accent:e.DOOM_OVERLAY_ACCENT}}renderBody(e){return this.launchers.length?this.launchers.flatMap((n,r)=>{let i=r===this.selected,a=i?this.theme.fg(`accent`,`▸`):` `,o=i?this.theme.bold(n.label):n.label,s=[`${a} ${(0,t.truncateToWidth)(o,Math.max(0,e-2))}`];return n.description&&s.push(` ${this.theme.fg(`dim`,(0,t.truncateToWidth)(n.description,Math.max(0,e-4)))}`),s}):[this.theme.fg(`dim`,`No loop launchers are registered for this session.`)]}move(e){this.launchers.length&&(this.selected=Math.max(0,Math.min(this.selected+e,this.launchers.length-1)),this.invalidate())}};async function r(t,r){if(t.mode!==`tui`){let e=r.map(e=>e.label),n=await t.ui.select(`Start loop`,e);return r[e.indexOf(n??``)]?.id}return t.ui.custom((e,t,i,a)=>new n(e,t,r,a),e.DOOM_FULLSCREEN_UI_OPTIONS)}exports.StartLoopOverlay=n,exports.openStartLoopOverlay=r;
|
|
2
|
+
//# sourceMappingURL=startLoopOverlay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startLoopOverlay.cjs","names":["DoomOverlay","matchesKey","DOOM_OVERLAY_ACCENT","truncateToWidth","DOOM_FULLSCREEN_UI_OPTIONS"],"sources":["../../src/tui/startLoopOverlay.ts"],"sourcesContent":["import {\n DOOM_FULLSCREEN_UI_OPTIONS,\n DOOM_OVERLAY_ACCENT,\n DoomOverlay,\n type DoomOverlayChrome,\n type DoomOverlayTui,\n} from '@agimon-ai/doompi-ui/components/doomOverlay';\nimport type { ExtensionContext, Theme } from '@earendil-works/pi-coding-agent';\nimport { matchesKey, truncateToWidth } from '@earendil-works/pi-tui';\nimport type { LoopLauncherSummary } from '../launcher.ts';\n\nconst EMPTY_MESSAGE = 'No loop launchers are registered for this session.';\n\nexport class StartLoopOverlay extends DoomOverlay {\n private selected = 0;\n\n constructor(\n tui: DoomOverlayTui,\n theme: Theme,\n private readonly launchers: readonly LoopLauncherSummary[],\n private readonly done: (result: string | undefined) => void,\n ) {\n super(tui, theme);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c') || data === 'q') return this.done(undefined);\n if (matchesKey(data, 'up') || data === 'k') return this.move(-1);\n if (matchesKey(data, 'down') || data === 'j') return this.move(1);\n if (matchesKey(data, 'enter')) this.done(this.launchers[this.selected]?.id);\n }\n\n protected getChrome(): DoomOverlayChrome {\n return {\n title: 'START LOOP',\n breadcrumb: 'SPC › l / loops › s / start',\n footer: 'enter launch · j/k move · esc close',\n footerHints: [\n ['enter', 'launch'],\n ['j/k', 'move'],\n ['esc', 'close'],\n ],\n accent: DOOM_OVERLAY_ACCENT,\n };\n }\n\n protected renderBody(width: number): string[] {\n if (!this.launchers.length) return [this.theme.fg('dim', EMPTY_MESSAGE)];\n return this.launchers.flatMap((launcher, index) => {\n const selected = index === this.selected;\n const marker = selected ? this.theme.fg('accent', '▸') : ' ';\n const label = selected ? this.theme.bold(launcher.label) : launcher.label;\n const lines = [`${marker} ${truncateToWidth(label, Math.max(0, width - 2))}`];\n if (launcher.description)\n lines.push(` ${this.theme.fg('dim', truncateToWidth(launcher.description, Math.max(0, width - 4)))}`);\n return lines;\n });\n }\n\n private move(delta: number): void {\n if (!this.launchers.length) return;\n this.selected = Math.max(0, Math.min(this.selected + delta, this.launchers.length - 1));\n this.invalidate();\n }\n}\n\nexport async function openStartLoopOverlay(\n ctx: ExtensionContext,\n launchers: readonly LoopLauncherSummary[],\n): Promise<string | undefined> {\n if (ctx.mode !== 'tui') {\n const labels = launchers.map((launcher) => launcher.label);\n const selected = await ctx.ui.select('Start loop', labels);\n return launchers[labels.indexOf(selected ?? '')]?.id;\n }\n return ctx.ui.custom<string | undefined>(\n (tui, theme, _keybindings, done) => new StartLoopOverlay(tui, theme, launchers, done),\n DOOM_FULLSCREEN_UI_OPTIONS,\n );\n}\n"],"mappings":"iGAaA,IAAa,EAAb,cAAsCA,EAAAA,WAAY,CAM7B,UACA,KANnB,SAAmB,EAEnB,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,EAAK,CAAK,EAHC,KAAA,UAAA,EACA,KAAA,KAAA,CAGnB,CAEA,YAAY,EAAoB,CAC9B,IAAA,EAAIC,EAAAA,WAAAA,CAAW,EAAM,QAAQ,IAAA,EAAKA,EAAAA,WAAAA,CAAW,EAAM,QAAQ,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,IAAA,EAAS,EACxG,IAAA,EAAIA,EAAAA,WAAAA,CAAW,EAAM,IAAI,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,EAAE,EAC/D,IAAA,EAAIA,EAAAA,WAAAA,CAAW,EAAM,MAAM,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,OAAO,EAAU,EAAO,QAAQ,GAAY,EAAE,EAAE,EAAE,EACpD,CACA,OAAO,EAAI,GAAG,QACX,EAAK,EAAO,EAAc,IAAS,IAAI,EAAiB,EAAK,EAAO,EAAW,CAAI,EACpFC,EAAAA,0BACF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DOOM_FULLSCREEN_UI_OPTIONS as e,DOOM_OVERLAY_ACCENT as t,DoomOverlay as n}from"@agimon-ai/doompi-ui/components/doomOverlay";import{matchesKey as r,truncateToWidth as i}from"@earendil-works/pi-tui";var a=class extends n{launchers;done;selected=0;constructor(e,t,n,r){super(e,t),this.launchers=n,this.done=r}handleInput(e){if(r(e,`escape`)||r(e,`ctrl+c`)||e===`q`)return this.done(void 0);if(r(e,`up`)||e===`k`)return this.move(-1);if(r(e,`down`)||e===`j`)return this.move(1);r(e,`enter`)&&this.done(this.launchers[this.selected]?.id)}getChrome(){return{title:`START LOOP`,breadcrumb:`SPC › l / loops › s / start`,footer:`enter launch · j/k move · esc close`,footerHints:[[`enter`,`launch`],[`j/k`,`move`],[`esc`,`close`]],accent:t}}renderBody(e){return this.launchers.length?this.launchers.flatMap((t,n)=>{let r=n===this.selected,a=r?this.theme.fg(`accent`,`▸`):` `,o=r?this.theme.bold(t.label):t.label,s=[`${a} ${i(o,Math.max(0,e-2))}`];return t.description&&s.push(` ${this.theme.fg(`dim`,i(t.description,Math.max(0,e-4)))}`),s}):[this.theme.fg(`dim`,`No loop launchers are registered for this session.`)]}move(e){this.launchers.length&&(this.selected=Math.max(0,Math.min(this.selected+e,this.launchers.length-1)),this.invalidate())}};async function o(t,n){if(t.mode!==`tui`){let e=n.map(e=>e.label),r=await t.ui.select(`Start loop`,e);return n[e.indexOf(r??``)]?.id}return t.ui.custom((e,t,r,i)=>new a(e,t,n,i),e)}export{a as StartLoopOverlay,o as openStartLoopOverlay};
|
|
2
|
+
//# sourceMappingURL=startLoopOverlay.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startLoopOverlay.mjs","names":[],"sources":["../../src/tui/startLoopOverlay.ts"],"sourcesContent":["import {\n DOOM_FULLSCREEN_UI_OPTIONS,\n DOOM_OVERLAY_ACCENT,\n DoomOverlay,\n type DoomOverlayChrome,\n type DoomOverlayTui,\n} from '@agimon-ai/doompi-ui/components/doomOverlay';\nimport type { ExtensionContext, Theme } from '@earendil-works/pi-coding-agent';\nimport { matchesKey, truncateToWidth } from '@earendil-works/pi-tui';\nimport type { LoopLauncherSummary } from '../launcher.ts';\n\nconst EMPTY_MESSAGE = 'No loop launchers are registered for this session.';\n\nexport class StartLoopOverlay extends DoomOverlay {\n private selected = 0;\n\n constructor(\n tui: DoomOverlayTui,\n theme: Theme,\n private readonly launchers: readonly LoopLauncherSummary[],\n private readonly done: (result: string | undefined) => void,\n ) {\n super(tui, theme);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c') || data === 'q') return this.done(undefined);\n if (matchesKey(data, 'up') || data === 'k') return this.move(-1);\n if (matchesKey(data, 'down') || data === 'j') return this.move(1);\n if (matchesKey(data, 'enter')) this.done(this.launchers[this.selected]?.id);\n }\n\n protected getChrome(): DoomOverlayChrome {\n return {\n title: 'START LOOP',\n breadcrumb: 'SPC › l / loops › s / start',\n footer: 'enter launch · j/k move · esc close',\n footerHints: [\n ['enter', 'launch'],\n ['j/k', 'move'],\n ['esc', 'close'],\n ],\n accent: DOOM_OVERLAY_ACCENT,\n };\n }\n\n protected renderBody(width: number): string[] {\n if (!this.launchers.length) return [this.theme.fg('dim', EMPTY_MESSAGE)];\n return this.launchers.flatMap((launcher, index) => {\n const selected = index === this.selected;\n const marker = selected ? this.theme.fg('accent', '▸') : ' ';\n const label = selected ? this.theme.bold(launcher.label) : launcher.label;\n const lines = [`${marker} ${truncateToWidth(label, Math.max(0, width - 2))}`];\n if (launcher.description)\n lines.push(` ${this.theme.fg('dim', truncateToWidth(launcher.description, Math.max(0, width - 4)))}`);\n return lines;\n });\n }\n\n private move(delta: number): void {\n if (!this.launchers.length) return;\n this.selected = Math.max(0, Math.min(this.selected + delta, this.launchers.length - 1));\n this.invalidate();\n }\n}\n\nexport async function openStartLoopOverlay(\n ctx: ExtensionContext,\n launchers: readonly LoopLauncherSummary[],\n): Promise<string | undefined> {\n if (ctx.mode !== 'tui') {\n const labels = launchers.map((launcher) => launcher.label);\n const selected = await ctx.ui.select('Start loop', labels);\n return launchers[labels.indexOf(selected ?? '')]?.id;\n }\n return ctx.ui.custom<string | undefined>(\n (tui, theme, _keybindings, done) => new StartLoopOverlay(tui, theme, launchers, done),\n DOOM_FULLSCREEN_UI_OPTIONS,\n );\n}\n"],"mappings":"4MAaA,IAAa,EAAb,cAAsC,CAAY,CAM7B,UACA,KANnB,SAAmB,EAEnB,YACE,EACA,EACA,EACA,EACA,CACA,MAAM,EAAK,CAAK,EAHC,KAAA,UAAA,EACA,KAAA,KAAA,CAGnB,CAEA,YAAY,EAAoB,CAC9B,GAAI,EAAW,EAAM,QAAQ,GAAK,EAAW,EAAM,QAAQ,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,IAAA,EAAS,EACxG,GAAI,EAAW,EAAM,IAAI,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,EAAE,EAC/D,GAAI,EAAW,EAAM,MAAM,GAAK,IAAS,IAAK,OAAO,KAAK,KAAK,CAAC,EAC5D,EAAW,EAAM,OAAO,GAAG,KAAK,KAAK,KAAK,UAAU,KAAK,SAAS,EAAE,EAAE,CAC5E,CAEA,WAAyC,CACvC,MAAO,CACL,MAAO,aACP,WAAY,8BACZ,OAAQ,sCACR,YAAa,CACX,CAAC,QAAS,QAAQ,EAClB,CAAC,MAAO,MAAM,EACd,CAAC,MAAO,OAAO,CACjB,EACA,OAAQ,CACV,CACF,CAEA,WAAqB,EAAyB,CAE5C,OADK,KAAK,UAAU,OACb,KAAK,UAAU,SAAS,EAAU,IAAU,CACjD,IAAM,EAAW,IAAU,KAAK,SAC1B,EAAS,EAAW,KAAK,MAAM,GAAG,SAAU,GAAG,EAAI,IACnD,EAAQ,EAAW,KAAK,MAAM,KAAK,EAAS,KAAK,EAAI,EAAS,MAC9D,EAAQ,CAAC,GAAG,EAAO,GAAG,EAAgB,EAAO,KAAK,IAAI,EAAG,EAAQ,CAAC,CAAC,GAAG,EAG5E,OAFI,EAAS,aACX,EAAM,KAAK,OAAO,KAAK,MAAM,GAAG,MAAO,EAAgB,EAAS,YAAa,KAAK,IAAI,EAAG,EAAQ,CAAC,CAAC,CAAC,GAAG,EAClG,CACT,CAAC,EATkC,CAAC,KAAK,MAAM,GAAG,MAAO,oDAAa,CAAC,CAUzE,CAEA,KAAa,EAAqB,CAC3B,KAAK,UAAU,SACpB,KAAK,SAAW,KAAK,IAAI,EAAG,KAAK,IAAI,KAAK,SAAW,EAAO,KAAK,UAAU,OAAS,CAAC,CAAC,EACtF,KAAK,WAAW,EAClB,CACF,EAEA,eAAsB,EACpB,EACA,EAC6B,CAC7B,GAAI,EAAI,OAAS,MAAO,CACtB,IAAM,EAAS,EAAU,IAAK,GAAa,EAAS,KAAK,EACnD,EAAW,MAAM,EAAI,GAAG,OAAO,aAAc,CAAM,EACzD,OAAO,EAAU,EAAO,QAAQ,GAAY,EAAE,EAAE,EAAE,EACpD,CACA,OAAO,EAAI,GAAG,QACX,EAAK,EAAO,EAAc,IAAS,IAAI,EAAiB,EAAK,EAAO,EAAW,CAAI,EACpF,CACF,CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agimon-ai/doompi-loop",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Generic multi-loop controller for Doompi",
|
|
5
|
+
"homepage": "https://agimon.ai",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Vuong Ngo",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"jsnext:main": "./dist/index.mjs",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./extensions/pi": {
|
|
23
|
+
"types": "./dist/extensions/pi.d.mts",
|
|
24
|
+
"import": "./dist/extensions/pi.mjs",
|
|
25
|
+
"require": "./dist/extensions/pi.cjs"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.0",
|
|
34
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@earendil-works/pi-coding-agent": "0.84.1",
|
|
38
|
+
"@earendil-works/pi-tui": "0.84.1",
|
|
39
|
+
"@types/node": "26.1.1",
|
|
40
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
41
|
+
"tsdown": "0.22.14",
|
|
42
|
+
"typescript": "6.0.3",
|
|
43
|
+
"vitest": "4.1.10"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@earendil-works/pi-coding-agent": "0.84.1",
|
|
47
|
+
"@earendil-works/pi-tui": "0.84.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@earendil-works/pi-coding-agent": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"@earendil-works/pi-tui": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=22.19.0"
|
|
59
|
+
},
|
|
60
|
+
"pi": {
|
|
61
|
+
"extensions": [
|
|
62
|
+
"./dist/extensions/pi.mjs"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsdown",
|
|
67
|
+
"test": "vitest --run",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"lint": "oxlint . && oxfmt . --check",
|
|
70
|
+
"fixcode": "oxlint . --fix && oxfmt ."
|
|
71
|
+
}
|
|
72
|
+
}
|