@agimon-ai/doompi-loop 0.0.1-alpha.72 → 0.0.1-alpha.73
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../constants/loop.cjs"),t=require("../services/loopLaunchers/index.cjs"),n=require("../services/loopResource/index.cjs");let r=require("@agimon-ai/doompi-minor-mode");const i=`@agimon-ai/doompi-loop`,a=`loop.active`,o=3600;function s(e,t,n=`info`){return Promise.resolve(e.client.notify({body:t,level:n}))}function c(e,t){if(typeof e!=`string`||e.trim()===``)return t;let n=Number(e);if(!Number.isInteger(n)||n<30||n>o)throw Error(`Interval must be between 30 and ${o} seconds.`);return n}function l(o){let l,u,d,f,p=()=>(o.context.selection.state?.[`minor-mode`]??[]).includes(a),m=()=>{let e=l?.listLaunchers().length??0,t=(l?.listInstances().length??0)>0,n=e>0||!p();return{activation:t?`active`:`inactive`,condition:l?.listInstances().some(({state:e})=>e!==`running`)?`queued`:`ready`,...t?{detail:`${l?.listInstances().length} active`,color:`warning`}:{},actions:[{id:`start`,enabled:n,...n?{}:{disabledReason:`No loop launchers are registered.`}},{id:`stop`,enabled:t,...t?{}:{disabledReason:`No loops are active.`}}]}},h=()=>f?.publish();return f=(0,r.defineMinorMode)({descriptor:{source:i,id:a,label:`Loop`,description:`Session-scoped recurring prompt loops.`,order:60,actions:[{id:`start`,label:`Start`,description:`Start a loop with a registered launcher.`,contexts:[`headless`],parameters:[{name:`launcherId`,label:`Launcher`,kind:`string`,required:!0,minLength:1},{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!1,minLength:1}]},{id:`stop`,label:`Stop`,description:`Stop one active loop instance.`,contexts:[`headless`],parameters:[{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!0,minLength:1},{name:`reason`,label:`Reason`,kind:`string`,required:!1,minLength:1}]}]},state:m,async handleAction(e,t,n,{signal:r}){if(r.throwIfAborted(),t===`start`&&!l){let e=(o.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==a);await o.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,a]})}if(!l)throw Error(`Loop activity is not active.`);if(t===`start`){let e=await l.launch(String(n.launcherId??``),n.instanceId?{instanceId:String(n.instanceId)}:{});return h(),{message:e?`Loop '${e.instanceId}' started.`:`Loop launch was cancelled.`}}if(t===`stop`){let e=await l.stop(String(n.instanceId??``),String(n.reason??`Stopped through minor_mode.`));if(e&&l.listInstances().length===0){let e=(o.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==a);await o.changeSelection({axis:`state`,key:`minor-mode`,values:e})}return h(),{message:e?`Loop stopped.`:`Loop instance was not active.`}}throw Error(`Unknown loop mode action: ${t}`)}}).createOwner(void 0),{services:[(0,r.serverMinorModes)([f])],resources:[{when:{state:{"minor-mode":a},attribution:{kind:`minor`,mode:a}},name:`doompi-use-loop`,kind:`skill`,read:()=>n.readLoopResource()}],activities:[{when:{state:{"minor-mode":a},attribution:{kind:`minor`,mode:a}},name:`doompi-loop`,start:async e=>{if(l!==void 0)return async()=>void 0;let n={generation:`${e.sessionId}:loop-launchers`,createInstanceId:()=>crypto.randomUUID(),timestamp:()=>new Date().toISOString()},r=t.createDoomLoopLaunchersService(n),a=r.register({id:`doompi.default`,source:i,label:`Default loop`,description:`Run a prompt in this session on an interval.`,async launch({instanceId:t,signal:n}){let r=await e.client.request({kind:`input`,title:`Loop prompt`,multiline:!0},n),i=typeof r==`string`?r.trim():``;if(!i||n.aborted)return;let a=c(await e.client.request({kind:`input`,title:`Loop interval in seconds`,initialValue:`300`},n),300),o=!1,l=()=>{o||n.aborted||e.session.prompt(i).catch(t=>{s(e,`Loop pass failed: ${t instanceof Error?t.message:String(t)}`,`warning`)})},u=setInterval(l,a*1e3);return u.unref?.(),l(),{instanceId:t,label:`Default loop`,detail:`every ${a}s`,stop(){o=!0,clearInterval(u)}}}});return l=r,u=a,d=r.subscribe(h),h(),async()=>{d?.(),d=void 0,await a.dispose(`Headless loop activity stopped.`),await r.dispose(`Headless loop activity stopped.`),l===r&&(l=void 0),u===a&&(u=void 0),h()}}}],commands:[{
|
|
1
|
+
const e=require("../constants/loop.cjs"),t=require("../services/loopLaunchers/index.cjs"),n=require("../services/loopResource/index.cjs");let r=require("@agimon-ai/doompi-minor-mode");const i=`@agimon-ai/doompi-loop`,a=`loop.active`,o=3600;function s(e,t,n=`info`){return Promise.resolve(e.client.notify({body:t,level:n}))}function c(e,t){if(typeof e!=`string`||e.trim()===``)return t;let n=Number(e);if(!Number.isInteger(n)||n<30||n>o)throw Error(`Interval must be between 30 and ${o} seconds.`);return n}function l(o){let l,u,d,f,p=()=>(o.context.selection.state?.[`minor-mode`]??[]).includes(a),m=()=>{let e=l?.listLaunchers().length??0,t=(l?.listInstances().length??0)>0,n=e>0||!p();return{activation:t?`active`:`inactive`,condition:l?.listInstances().some(({state:e})=>e!==`running`)?`queued`:`ready`,...t?{detail:`${l?.listInstances().length} active`,color:`warning`}:{},actions:[{id:`start`,enabled:n,...n?{}:{disabledReason:`No loop launchers are registered.`}},{id:`stop`,enabled:t,...t?{}:{disabledReason:`No loops are active.`}}]}},h=()=>f?.publish();return f=(0,r.defineMinorMode)({descriptor:{source:i,id:a,label:`Loop`,description:`Session-scoped recurring prompt loops.`,order:60,actions:[{id:`start`,label:`Start`,description:`Start a loop with a registered launcher.`,contexts:[`headless`],parameters:[{name:`launcherId`,label:`Launcher`,kind:`string`,required:!0,minLength:1},{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!1,minLength:1}]},{id:`stop`,label:`Stop`,description:`Stop one active loop instance.`,contexts:[`headless`],parameters:[{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!0,minLength:1},{name:`reason`,label:`Reason`,kind:`string`,required:!1,minLength:1}]}]},state:m,async handleAction(e,t,n,{signal:r}){if(r.throwIfAborted(),t===`start`&&!l){let e=(o.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==a);await o.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,a]})}if(!l)throw Error(`Loop activity is not active.`);if(t===`start`){let e=await l.launch(String(n.launcherId??``),n.instanceId?{instanceId:String(n.instanceId)}:{});return h(),{message:e?`Loop '${e.instanceId}' started.`:`Loop launch was cancelled.`}}if(t===`stop`){let e=await l.stop(String(n.instanceId??``),String(n.reason??`Stopped through minor_mode.`));if(e&&l.listInstances().length===0){let e=(o.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==a);await o.changeSelection({axis:`state`,key:`minor-mode`,values:e})}return h(),{message:e?`Loop stopped.`:`Loop instance was not active.`}}throw Error(`Unknown loop mode action: ${t}`)}}).createOwner(void 0),{services:[(0,r.serverMinorModes)([f])],resources:[{when:{state:{"minor-mode":a},attribution:{kind:`minor`,mode:a}},name:`doompi-use-loop`,kind:`skill`,read:()=>n.readLoopResource()}],activities:[{when:{state:{"minor-mode":a},attribution:{kind:`minor`,mode:a}},name:`doompi-loop`,start:async e=>{if(l!==void 0)return async()=>void 0;let n={generation:`${e.sessionId}:loop-launchers`,createInstanceId:()=>crypto.randomUUID(),timestamp:()=>new Date().toISOString()},r=t.createDoomLoopLaunchersService(n),a=r.register({id:`doompi.default`,source:i,label:`Default loop`,description:`Run a prompt in this session on an interval.`,async launch({instanceId:t,signal:n}){let r=await e.client.request({kind:`input`,title:`Loop prompt`,multiline:!0},n),i=typeof r==`string`?r.trim():``;if(!i||n.aborted)return;let a=c(await e.client.request({kind:`input`,title:`Loop interval in seconds`,initialValue:`300`},n),300),o=!1,l=()=>{o||n.aborted||e.session.prompt(i).catch(t=>{s(e,`Loop pass failed: ${t instanceof Error?t.message:String(t)}`,`warning`)})},u=setInterval(l,a*1e3);return u.unref?.(),l(),{instanceId:t,label:`Default loop`,detail:`every ${a}s`,stop(){o=!0,clearInterval(u)}}}});return l=r,u=a,d=r.subscribe(h),h(),async()=>{d?.(),d=void 0,await a.dispose(`Headless loop activity stopped.`),await r.dispose(`Headless loop activity stopped.`),l===r&&(l=void 0),u===a&&(u=void 0),h()}}}],commands:[{name:e.START_COMMAND_NAME,description:`Start a registered loop.`,async execute(e,t){if(!l){let e=o.context.selection.state?.[`minor-mode`]??[];await o.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,a]})}if(!l)throw Error(`Loop activity is not active.`);let n=l.listLaunchers(),r=e.trim()||await t.client.request({kind:`select`,title:`Choose a loop launcher`,options:n.map(e=>({label:e.label,value:e.id}))}),i=e.trim()||(typeof r==`string`?r:``);if(!i)return;let c=await l.launch(i);h(),await s(t,c?`Loop '${c.instanceId}' started.`:`Loop launch was cancelled.`)}},{name:e.LIST_COMMAND_NAME,description:`List and stop active loops.`,async execute(e,t){let n=l?.listInstances()??[];await s(t,n.length===0?`No loops are active.`:JSON.stringify(n,null,2))}}],hooks:[{when:{state:{"minor-mode":a},attribution:{kind:`minor`,mode:a}},event:`session_shutdown`,async handle(){await l?.stopAll(`Headless session shutdown.`)}}],async onDispose(){await u?.dispose(`Headless loop facet disposed.`),await l?.dispose(`Headless loop facet disposed.`)}}}exports.createSessionState=l;
|
|
2
2
|
//# sourceMappingURL=serverRuntime.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverRuntime.cjs","names":["createDoomLoopLaunchersService","defineMinorMode","serverMinorModes","readLoopResource","START_COMMAND_NAME","LIST_COMMAND_NAME"],"sources":["../../../src/controllers/serverRuntime.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 { readLoopResource } from '../services/loopResource';\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 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 const publishMode = (): void => modeOwner?.publish();\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: () => readLoopResource(),\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 when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: START_COMMAND_NAME,\n description: 'Start a registered loop.',\n async execute(args: string, execution: DoomHeadlessExecutionContext) {\n if (!launchers) throw new Error('Loop activity is not active.');\n const available = launchers.listLaunchers();\n const selected = 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 when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: LIST_COMMAND_NAME,\n description: 'List and stop active loops.',\n async execute(_args: string, execution: DoomHeadlessExecutionContext) {\n if (!launchers) throw new Error('Loop activity is not active.');\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 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":"wLAQA,MAAM,EAAS,yBACT,EAAU,cAIV,EAAuB,KAE7B,SAAS,EACP,EAGA,EACA,EAAsC,OACvB,CACf,OAAO,QAAQ,QAAQ,EAAQ,OAAO,OAAO,CAAE,OAAM,OAAM,CAAC,CAAC,CAC/D,CAEA,SAAS,EAAY,EAAgB,EAA0B,CAC7D,GAAI,OAAO,GAAU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,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,KAAMC,EAAAA,kBACN,YAAa,8BACb,MAAM,QAAQ,EAAe,EAAyC,CACpE,GAAI,CAAC,EAAW,MAAU,MAAM,8BAA8B,EAC9D,IAAM,EAAY,EAAU,cAAc,EAC1C,MAAM,EAAO,EAAW,EAAU,SAAW,EAAI,uBAAyB,KAAK,UAAU,EAAW,KAAM,CAAC,CAAC,CAC9G,CACF,CACF,EACA,MAAO,CACL,CACE,KAAM,CAAE,MAAO,CAAE,aAAc,CAAQ,EAAG,YAAa,CAAE,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,MAAO,mBACP,MAAM,QAAS,CACb,MAAM,GAAW,QAAQ,4BAA4B,CACvD,CACF,CACF,EACA,MAAM,WAAY,CAChB,MAAM,GAAqB,QAAQ,+BAA+B,EAClE,MAAM,GAAW,QAAQ,+BAA+B,CAC1D,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"serverRuntime.cjs","names":["createDoomLoopLaunchersService","defineMinorMode","serverMinorModes","readLoopResource","START_COMMAND_NAME","LIST_COMMAND_NAME"],"sources":["../../../src/controllers/serverRuntime.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 { readLoopResource } from '../services/loopResource';\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 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 const publishMode = (): void => modeOwner?.publish();\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: () => readLoopResource(),\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 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":"wLAQA,MAAM,EAAS,yBACT,EAAU,cAIV,EAAuB,KAE7B,SAAS,EACP,EAGA,EACA,EAAsC,OACvB,CACf,OAAO,QAAQ,QAAQ,EAAQ,OAAO,OAAO,CAAE,OAAM,OAAM,CAAC,CAAC,CAC/D,CAEA,SAAS,EAAY,EAAgB,EAA0B,CAC7D,GAAI,OAAO,GAAU,UAAY,EAAM,KAAK,IAAM,GAAI,OAAO,EAC7D,IAAM,EAAS,OAAO,CAAK,EAC3B,GAAI,CAAC,OAAO,UAAU,CAAM,GAAK,EAAS,IAAwB,EAAS,EACzE,MAAU,MAAM,mCA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,CAAC,EACjD,MAAM,EAAO,EAAW,EAAU,SAAW,EAAI,uBAAyB,KAAK,UAAU,EAAW,KAAM,CAAC,CAAC,CAC9G,CACF,CACF,EACA,MAAO,CACL,CACE,KAAM,CAAE,MAAO,CAAE,aAAc,CAAQ,EAAG,YAAa,CAAE,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,MAAO,mBACP,MAAM,QAAS,CACb,MAAM,GAAW,QAAQ,4BAA4B,CACvD,CACF,CACF,EACA,MAAM,WAAY,CAChB,MAAM,GAAqB,QAAQ,+BAA+B,EAClE,MAAM,GAAW,QAAQ,+BAA+B,CAC1D,CACF,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LIST_COMMAND_NAME as e,START_COMMAND_NAME as t}from"../constants/loop.mjs";import{createDoomLoopLaunchersService as n}from"../services/loopLaunchers/index.mjs";import{readLoopResource as r}from"../services/loopResource/index.mjs";import{defineMinorMode as i,serverMinorModes as a}from"@agimon-ai/doompi-minor-mode";const o=`@agimon-ai/doompi-loop`,s=`loop.active`,c=3600;function l(e,t,n=`info`){return Promise.resolve(e.client.notify({body:t,level:n}))}function u(e,t){if(typeof e!=`string`||e.trim()===``)return t;let n=Number(e);if(!Number.isInteger(n)||n<30||n>c)throw Error(`Interval must be between 30 and ${c} seconds.`);return n}function d(c){let d,f,p,m,h=()=>(c.context.selection.state?.[`minor-mode`]??[]).includes(s),g=()=>{let e=d?.listLaunchers().length??0,t=(d?.listInstances().length??0)>0,n=e>0||!h();return{activation:t?`active`:`inactive`,condition:d?.listInstances().some(({state:e})=>e!==`running`)?`queued`:`ready`,...t?{detail:`${d?.listInstances().length} active`,color:`warning`}:{},actions:[{id:`start`,enabled:n,...n?{}:{disabledReason:`No loop launchers are registered.`}},{id:`stop`,enabled:t,...t?{}:{disabledReason:`No loops are active.`}}]}},_=()=>m?.publish();return m=i({descriptor:{source:o,id:s,label:`Loop`,description:`Session-scoped recurring prompt loops.`,order:60,actions:[{id:`start`,label:`Start`,description:`Start a loop with a registered launcher.`,contexts:[`headless`],parameters:[{name:`launcherId`,label:`Launcher`,kind:`string`,required:!0,minLength:1},{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!1,minLength:1}]},{id:`stop`,label:`Stop`,description:`Stop one active loop instance.`,contexts:[`headless`],parameters:[{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!0,minLength:1},{name:`reason`,label:`Reason`,kind:`string`,required:!1,minLength:1}]}]},state:g,async handleAction(e,t,n,{signal:r}){if(r.throwIfAborted(),t===`start`&&!d){let e=(c.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==s);await c.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,s]})}if(!d)throw Error(`Loop activity is not active.`);if(t===`start`){let e=await d.launch(String(n.launcherId??``),n.instanceId?{instanceId:String(n.instanceId)}:{});return _(),{message:e?`Loop '${e.instanceId}' started.`:`Loop launch was cancelled.`}}if(t===`stop`){let e=await d.stop(String(n.instanceId??``),String(n.reason??`Stopped through minor_mode.`));if(e&&d.listInstances().length===0){let e=(c.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==s);await c.changeSelection({axis:`state`,key:`minor-mode`,values:e})}return _(),{message:e?`Loop stopped.`:`Loop instance was not active.`}}throw Error(`Unknown loop mode action: ${t}`)}}).createOwner(void 0),{services:[a([m])],resources:[{when:{state:{"minor-mode":s},attribution:{kind:`minor`,mode:s}},name:`doompi-use-loop`,kind:`skill`,read:()=>r()}],activities:[{when:{state:{"minor-mode":s},attribution:{kind:`minor`,mode:s}},name:`doompi-loop`,start:async e=>{if(d!==void 0)return async()=>void 0;let t={generation:`${e.sessionId}:loop-launchers`,createInstanceId:()=>crypto.randomUUID(),timestamp:()=>new Date().toISOString()},r=n(t),i=r.register({id:`doompi.default`,source:o,label:`Default loop`,description:`Run a prompt in this session on an interval.`,async launch({instanceId:t,signal:n}){let r=await e.client.request({kind:`input`,title:`Loop prompt`,multiline:!0},n),i=typeof r==`string`?r.trim():``;if(!i||n.aborted)return;let a=u(await e.client.request({kind:`input`,title:`Loop interval in seconds`,initialValue:`300`},n),300),o=!1,s=()=>{o||n.aborted||e.session.prompt(i).catch(t=>{l(e,`Loop pass failed: ${t instanceof Error?t.message:String(t)}`,`warning`)})},c=setInterval(s,a*1e3);return c.unref?.(),s(),{instanceId:t,label:`Default loop`,detail:`every ${a}s`,stop(){o=!0,clearInterval(c)}}}});return d=r,f=i,p=r.subscribe(_),_(),async()=>{p?.(),p=void 0,await i.dispose(`Headless loop activity stopped.`),await r.dispose(`Headless loop activity stopped.`),d===r&&(d=void 0),f===i&&(f=void 0),_()}}}],commands:[{
|
|
1
|
+
import{LIST_COMMAND_NAME as e,START_COMMAND_NAME as t}from"../constants/loop.mjs";import{createDoomLoopLaunchersService as n}from"../services/loopLaunchers/index.mjs";import{readLoopResource as r}from"../services/loopResource/index.mjs";import{defineMinorMode as i,serverMinorModes as a}from"@agimon-ai/doompi-minor-mode";const o=`@agimon-ai/doompi-loop`,s=`loop.active`,c=3600;function l(e,t,n=`info`){return Promise.resolve(e.client.notify({body:t,level:n}))}function u(e,t){if(typeof e!=`string`||e.trim()===``)return t;let n=Number(e);if(!Number.isInteger(n)||n<30||n>c)throw Error(`Interval must be between 30 and ${c} seconds.`);return n}function d(c){let d,f,p,m,h=()=>(c.context.selection.state?.[`minor-mode`]??[]).includes(s),g=()=>{let e=d?.listLaunchers().length??0,t=(d?.listInstances().length??0)>0,n=e>0||!h();return{activation:t?`active`:`inactive`,condition:d?.listInstances().some(({state:e})=>e!==`running`)?`queued`:`ready`,...t?{detail:`${d?.listInstances().length} active`,color:`warning`}:{},actions:[{id:`start`,enabled:n,...n?{}:{disabledReason:`No loop launchers are registered.`}},{id:`stop`,enabled:t,...t?{}:{disabledReason:`No loops are active.`}}]}},_=()=>m?.publish();return m=i({descriptor:{source:o,id:s,label:`Loop`,description:`Session-scoped recurring prompt loops.`,order:60,actions:[{id:`start`,label:`Start`,description:`Start a loop with a registered launcher.`,contexts:[`headless`],parameters:[{name:`launcherId`,label:`Launcher`,kind:`string`,required:!0,minLength:1},{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!1,minLength:1}]},{id:`stop`,label:`Stop`,description:`Stop one active loop instance.`,contexts:[`headless`],parameters:[{name:`instanceId`,label:`Instance ID`,kind:`string`,required:!0,minLength:1},{name:`reason`,label:`Reason`,kind:`string`,required:!1,minLength:1}]}]},state:g,async handleAction(e,t,n,{signal:r}){if(r.throwIfAborted(),t===`start`&&!d){let e=(c.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==s);await c.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,s]})}if(!d)throw Error(`Loop activity is not active.`);if(t===`start`){let e=await d.launch(String(n.launcherId??``),n.instanceId?{instanceId:String(n.instanceId)}:{});return _(),{message:e?`Loop '${e.instanceId}' started.`:`Loop launch was cancelled.`}}if(t===`stop`){let e=await d.stop(String(n.instanceId??``),String(n.reason??`Stopped through minor_mode.`));if(e&&d.listInstances().length===0){let e=(c.context.selection.state?.[`minor-mode`]??[]).filter(e=>e!==s);await c.changeSelection({axis:`state`,key:`minor-mode`,values:e})}return _(),{message:e?`Loop stopped.`:`Loop instance was not active.`}}throw Error(`Unknown loop mode action: ${t}`)}}).createOwner(void 0),{services:[a([m])],resources:[{when:{state:{"minor-mode":s},attribution:{kind:`minor`,mode:s}},name:`doompi-use-loop`,kind:`skill`,read:()=>r()}],activities:[{when:{state:{"minor-mode":s},attribution:{kind:`minor`,mode:s}},name:`doompi-loop`,start:async e=>{if(d!==void 0)return async()=>void 0;let t={generation:`${e.sessionId}:loop-launchers`,createInstanceId:()=>crypto.randomUUID(),timestamp:()=>new Date().toISOString()},r=n(t),i=r.register({id:`doompi.default`,source:o,label:`Default loop`,description:`Run a prompt in this session on an interval.`,async launch({instanceId:t,signal:n}){let r=await e.client.request({kind:`input`,title:`Loop prompt`,multiline:!0},n),i=typeof r==`string`?r.trim():``;if(!i||n.aborted)return;let a=u(await e.client.request({kind:`input`,title:`Loop interval in seconds`,initialValue:`300`},n),300),o=!1,s=()=>{o||n.aborted||e.session.prompt(i).catch(t=>{l(e,`Loop pass failed: ${t instanceof Error?t.message:String(t)}`,`warning`)})},c=setInterval(s,a*1e3);return c.unref?.(),s(),{instanceId:t,label:`Default loop`,detail:`every ${a}s`,stop(){o=!0,clearInterval(c)}}}});return d=r,f=i,p=r.subscribe(_),_(),async()=>{p?.(),p=void 0,await i.dispose(`Headless loop activity stopped.`),await r.dispose(`Headless loop activity stopped.`),d===r&&(d=void 0),f===i&&(f=void 0),_()}}}],commands:[{name:t,description:`Start a registered loop.`,async execute(e,t){if(!d){let e=c.context.selection.state?.[`minor-mode`]??[];await c.changeSelection({axis:`state`,key:`minor-mode`,values:[...e,s]})}if(!d)throw Error(`Loop activity is not active.`);let n=d.listLaunchers(),r=e.trim()||await t.client.request({kind:`select`,title:`Choose a loop launcher`,options:n.map(e=>({label:e.label,value:e.id}))}),i=e.trim()||(typeof r==`string`?r:``);if(!i)return;let a=await d.launch(i);_(),await l(t,a?`Loop '${a.instanceId}' started.`:`Loop launch was cancelled.`)}},{name:e,description:`List and stop active loops.`,async execute(e,t){let n=d?.listInstances()??[];await l(t,n.length===0?`No loops are active.`:JSON.stringify(n,null,2))}}],hooks:[{when:{state:{"minor-mode":s},attribution:{kind:`minor`,mode:s}},event:`session_shutdown`,async handle(){await d?.stopAll(`Headless session shutdown.`)}}],async onDispose(){await f?.dispose(`Headless loop facet disposed.`),await d?.dispose(`Headless loop facet disposed.`)}}}export{d as createSessionState};
|
|
2
2
|
//# sourceMappingURL=serverRuntime.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverRuntime.mjs","names":[],"sources":["../../../src/controllers/serverRuntime.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 { readLoopResource } from '../services/loopResource';\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 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 const publishMode = (): void => modeOwner?.publish();\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: () => readLoopResource(),\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 when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: START_COMMAND_NAME,\n description: 'Start a registered loop.',\n async execute(args: string, execution: DoomHeadlessExecutionContext) {\n if (!launchers) throw new Error('Loop activity is not active.');\n const available = launchers.listLaunchers();\n const selected = 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 when: { state: { 'minor-mode': MODE_ID }, attribution: { kind: 'minor', mode: MODE_ID } },\n name: LIST_COMMAND_NAME,\n description: 'List and stop active loops.',\n async execute(_args: string, execution: DoomHeadlessExecutionContext) {\n if (!launchers) throw new Error('Loop activity is not active.');\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 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":"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,EAClD,EAAY,EACZ,MAAM,EAAO,EAAW,EAAW,SAAS,EAAS,WAAW,YAAc,4BAA4B,CAC5G,CACF,EACA,CACE,KAAM,CAAE,MAAO,CAAE,aAAc,CAAQ,EAAG,YAAa,CAAE,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,KAAM,EACN,YAAa,8BACb,MAAM,QAAQ,EAAe,EAAyC,CACpE,GAAI,CAAC,EAAW,MAAU,MAAM,8BAA8B,EAC9D,IAAM,EAAY,EAAU,cAAc,EAC1C,MAAM,EAAO,EAAW,EAAU,SAAW,EAAI,uBAAyB,KAAK,UAAU,EAAW,KAAM,CAAC,CAAC,CAC9G,CACF,CACF,EACA,MAAO,CACL,CACE,KAAM,CAAE,MAAO,CAAE,aAAc,CAAQ,EAAG,YAAa,CAAE,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,MAAO,mBACP,MAAM,QAAS,CACb,MAAM,GAAW,QAAQ,4BAA4B,CACvD,CACF,CACF,EACA,MAAM,WAAY,CAChB,MAAM,GAAqB,QAAQ,+BAA+B,EAClE,MAAM,GAAW,QAAQ,+BAA+B,CAC1D,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"serverRuntime.mjs","names":[],"sources":["../../../src/controllers/serverRuntime.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 { readLoopResource } from '../services/loopResource';\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 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 const publishMode = (): void => modeOwner?.publish();\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: () => readLoopResource(),\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 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":"kUAQA,MAAM,EAAS,yBACT,EAAU,cAIV,EAAuB,KAE7B,SAAS,EACP,EAGA,EACA,EAAsC,OACvB,CACf,OAAO,QAAQ,QAAQ,EAAQ,OAAO,OAAO,CAAE,OAAM,OAAM,CAAC,CAAC,CAC/D,CAEA,SAAS,EAAY,EAAgB,EAA0B,CAC7D,GAAI,OAAO,GAAU,UAAY,EAAM,KAAK,IAAM,GAAI,OAAO,EAC7D,IAAM,EAAS,OAAO,CAAK,EAC3B,GAAI,CAAC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M,EAAO,EAAW,EAAU,SAAW,EAAI,uBAAyB,KAAK,UAAU,EAAW,KAAM,CAAC,CAAC,CAC9G,CACF,CACF,EACA,MAAO,CACL,CACE,KAAM,CAAE,MAAO,CAAE,aAAc,CAAQ,EAAG,YAAa,CAAE,KAAM,QAAS,KAAM,CAAQ,CAAE,EACxF,MAAO,mBACP,MAAM,QAAS,CACb,MAAM,GAAW,QAAQ,4BAA4B,CACvD,CACF,CACF,EACA,MAAM,WAAY,CAChB,MAAM,GAAqB,QAAQ,+BAA+B,EAClE,MAAM,GAAW,QAAQ,+BAA+B,CAC1D,CACF,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-loop",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.73",
|
|
4
4
|
"description": "Session-scoped recurring prompt scheduler and loop controls for Pi coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -68,21 +68,21 @@
|
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@agimon-ai/doompi-
|
|
73
|
-
"@agimon-ai/doompi-
|
|
74
|
-
"@agimon-ai/doompi-
|
|
75
|
-
"@
|
|
71
|
+
"@agimon-ai/doompi-core": "0.0.1-alpha.72",
|
|
72
|
+
"@agimon-ai/doompi-minor-mode": "0.0.1-alpha.72",
|
|
73
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.72",
|
|
74
|
+
"@agimon-ai/doompi-web-components": "0.0.1-alpha.30",
|
|
75
|
+
"@deepseek-ai/cordis": "4.0.2"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
79
79
|
"@earendil-works/pi-tui": "0.85.1",
|
|
80
|
-
"@types/node": "26.
|
|
81
|
-
"@types/react": "19.
|
|
82
|
-
"@types/react-dom": "19.
|
|
80
|
+
"@types/node": "26.5.1",
|
|
81
|
+
"@types/react": "19.3.0",
|
|
82
|
+
"@types/react-dom": "19.3.0",
|
|
83
83
|
"@vitest/coverage-v8": "5.0.0",
|
|
84
|
-
"react": "19.
|
|
85
|
-
"react-dom": "19.
|
|
84
|
+
"react": "19.3.0",
|
|
85
|
+
"react-dom": "19.3.0",
|
|
86
86
|
"tsdown": "0.23.0",
|
|
87
87
|
"typescript": "7.0.2",
|
|
88
88
|
"vitest": "5.0.0"
|