@agimon-ai/doompi-computer-use 0.0.1-alpha.22 → 0.0.1-alpha.24

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.
@@ -8,7 +8,6 @@ const require_route_server = require("../src/extensions/workspaces/sessions/(bac
8
8
  const require_computer_use_server$1 = require("../src/extensions/workspaces/sessions/(backend)/command/computer-use.server.cjs");
9
9
  const require_before_agent_start_server = require("../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.cjs");
10
10
  const require_session_shutdown_server = require("../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.cjs");
11
- const require_computer_use_server$2 = require("../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.cjs");
12
11
  const require_00_computer_state_server = require("../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server.cjs");
13
12
  const require_10_computer_action_server = require("../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server.cjs");
14
13
  const require_20_computer_exec_server = require("../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server.cjs");
@@ -48,9 +47,6 @@ const facet = (0, _agimon_ai_doompi_core_server_facet.defineServerPlugin)({
48
47
  get hooks() {
49
48
  return [via({ event: "before_agent_start" }, at(require_before_agent_start_server.default, contextSession)), via({ event: "session_shutdown" }, at(require_session_shutdown_server.default, contextSession))];
50
49
  },
51
- get toolRestrictions() {
52
- return [at(require_computer_use_server$2.default, contextSession)];
53
- },
54
50
  get tools() {
55
51
  return [
56
52
  via({ name: "00_computer_state" }, at(require_00_computer_state_server.default, contextSession)),
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["defineServerPlugin","channelComputerUse","rootSession","composeRootHooks","apiRoute","commandComputerUse","hookBeforeAgentStart","hookSessionShutdown","toolRestrictionComputerUse","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../generated/server.ts"],"sourcesContent":["// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extension-file';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelComputerUse from '../src/extensions/(backend)/channel/computer-use.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/computer-use/route.server';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookSessionShutdown from '../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server';\nimport toolRestrictionComputerUse from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-computer-use',\n global: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n workspace: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n get commands(): DoomServerSessionPlugin['commands'] { return [via({ name: 'computer-use' }, at(commandComputerUse, contextSession))]; },\n get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_shutdown' }, at(hookSessionShutdown, contextSession))]; },\n get toolRestrictions(): DoomServerSessionPlugin['toolRestrictions'] { return [at(toolRestrictionComputerUse, contextSession)]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: '00_computer_state' }, at(tool00ComputerState, contextSession)), via({ name: '10_computer_action' }, at(tool10ComputerAction, contextSession)), via({ name: '20_computer_exec' }, at(tool20ComputerExec, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,SAAA,GAAQA,oCAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,eAAe,EACb,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGC,4BAAAA,QAAmB,CAAC,CAAC;CAAG,EACjI;CACA,kBAAkB,EAChB,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGA,4BAAAA,QAAmB,CAAC,CAAC;CAAG,EACjI;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAAA,QAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGC,sCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,MAAsC;IAAE,OAAO,CAAC,GAAGC,qBAAAA,SAAU,cAAc,CAAC;GAAG;GACnF,IAAI,WAAgD;IAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGH,4BAAAA,QAAmB,CAAC,CAAC;GAAG;GAC/H,IAAI,WAAgD;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,GAAGI,8BAAAA,SAAoB,cAAc,CAAC,CAAC;GAAG;GACtI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,kCAAAA,SAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,mBAAmB,GAAG,GAAGC,gCAAAA,SAAqB,cAAc,CAAC,CAAC;GAAG;GACtN,IAAI,mBAAgE;IAAE,OAAO,CAAC,GAAGC,8BAAAA,SAA4B,cAAc,CAAC;GAAG;GAC/H,IAAI,QAA0C;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,iCAAAA,SAAqB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAGC,kCAAAA,SAAsB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,gCAAAA,SAAoB,cAAc,CAAC;IAAC;GAAG;GAChS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.cjs","names":["defineServerPlugin","channelComputerUse","rootSession","composeRootHooks","apiRoute","commandComputerUse","hookBeforeAgentStart","hookSessionShutdown","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../generated/server.ts"],"sourcesContent":["// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extension-file';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelComputerUse from '../src/extensions/(backend)/channel/computer-use.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/computer-use/route.server';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookSessionShutdown from '../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-computer-use',\n global: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n workspace: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n get commands(): DoomServerSessionPlugin['commands'] { return [via({ name: 'computer-use' }, at(commandComputerUse, contextSession))]; },\n get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_shutdown' }, at(hookSessionShutdown, contextSession))]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: '00_computer_state' }, at(tool00ComputerState, contextSession)), via({ name: '10_computer_action' }, at(tool10ComputerAction, contextSession)), via({ name: '20_computer_exec' }, at(tool20ComputerExec, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,SAAA,GAAQA,oCAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,eAAe,EACb,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGC,4BAAAA,QAAmB,CAAC,CAAC;CAAG,EACjI;CACA,kBAAkB,EAChB,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGA,4BAAAA,QAAmB,CAAC,CAAC;CAAG,EACjI;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAAA,QAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGC,sCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,MAAsC;IAAE,OAAO,CAAC,GAAGC,qBAAAA,SAAU,cAAc,CAAC;GAAG;GACnF,IAAI,WAAgD;IAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGH,4BAAAA,QAAmB,CAAC,CAAC;GAAG;GAC/H,IAAI,WAAgD;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,GAAGI,8BAAAA,SAAoB,cAAc,CAAC,CAAC;GAAG;GACtI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,kCAAAA,SAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,mBAAmB,GAAG,GAAGC,gCAAAA,SAAqB,cAAc,CAAC,CAAC;GAAG;GACtN,IAAI,QAA0C;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,iCAAAA,SAAqB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAGC,kCAAAA,SAAsB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,gCAAAA,SAAoB,cAAc,CAAC;IAAC;GAAG;GAChS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.cts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAoBa,qDAAK"}
1
+ {"version":3,"file":"server.d.cts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAmBa,qDAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAoBa,qDAAK"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAmBa,qDAAK"}
@@ -4,7 +4,6 @@ import route_server_default from "../src/extensions/workspaces/sessions/(backend
4
4
  import computer_use_server_default$1 from "../src/extensions/workspaces/sessions/(backend)/command/computer-use.server.mjs";
5
5
  import before_agent_start_server_default from "../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.mjs";
6
6
  import session_shutdown_server_default from "../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.mjs";
7
- import computer_use_server_default$2 from "../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.mjs";
8
7
  import _00_computer_state_server_default from "../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server.mjs";
9
8
  import _10_computer_action_server_default from "../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server.mjs";
10
9
  import _20_computer_exec_server_default from "../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server.mjs";
@@ -44,9 +43,6 @@ const facet = defineServerPlugin({
44
43
  get hooks() {
45
44
  return [via({ event: "before_agent_start" }, at(before_agent_start_server_default, contextSession)), via({ event: "session_shutdown" }, at(session_shutdown_server_default, contextSession))];
46
45
  },
47
- get toolRestrictions() {
48
- return [at(computer_use_server_default$2, contextSession)];
49
- },
50
46
  get tools() {
51
47
  return [
52
48
  via({ name: "00_computer_state" }, at(_00_computer_state_server_default, contextSession)),
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":["channelComputerUse","rootSession","apiRoute","commandComputerUse","hookBeforeAgentStart","hookSessionShutdown","toolRestrictionComputerUse","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../generated/server.ts"],"sourcesContent":["// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extension-file';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelComputerUse from '../src/extensions/(backend)/channel/computer-use.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/computer-use/route.server';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookSessionShutdown from '../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server';\nimport toolRestrictionComputerUse from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-computer-use',\n global: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n workspace: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n get commands(): DoomServerSessionPlugin['commands'] { return [via({ name: 'computer-use' }, at(commandComputerUse, contextSession))]; },\n get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_shutdown' }, at(hookSessionShutdown, contextSession))]; },\n get toolRestrictions(): DoomServerSessionPlugin['toolRestrictions'] { return [at(toolRestrictionComputerUse, contextSession)]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: '00_computer_state' }, at(tool00ComputerState, contextSession)), via({ name: '10_computer_action' }, at(tool10ComputerAction, contextSession)), via({ name: '20_computer_exec' }, at(tool20ComputerExec, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;;A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cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,kCAAoB,cAAc,CAAC;IAAC;GAAG;GAChS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":["channelComputerUse","rootSession","apiRoute","commandComputerUse","hookBeforeAgentStart","hookSessionShutdown","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../generated/server.ts"],"sourcesContent":["// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extension-file';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelComputerUse from '../src/extensions/(backend)/channel/computer-use.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/computer-use/route.server';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookSessionShutdown from '../src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.server';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.server';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-computer-use',\n global: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n workspace: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'computer_use' }, channelComputerUse())]; },\n get commands(): DoomServerSessionPlugin['commands'] { return [via({ name: 'computer-use' }, at(commandComputerUse, contextSession))]; },\n get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_shutdown' }, at(hookSessionShutdown, contextSession))]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: '00_computer_state' }, at(tool00ComputerState, contextSession)), via({ name: '10_computer_action' }, at(tool10ComputerAction, contextSession)), via({ name: '20_computer_exec' }, at(tool20ComputerExec, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,QAAQ,mBAAmB;CACtC,MAAM;CACN,eAAe,EACb,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGA,4BAAmB,CAAC,CAAC;CAAG,EACjI;CACA,kBAAkB,EAChB,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGA,4BAAmB,CAAC,CAAC;CAAG,EACjI;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,GAAG,iBAAiB,YAAY;GAChC,IAAI,MAAsC;IAAE,OAAO,CAAC,GAAGC,sBAAU,cAAc,CAAC;GAAG;GACnF,IAAI,WAAgD;IAAE,OAAO,OAAO,IAAI,EAAE,WAAW,eAAe,GAAGF,4BAAmB,CAAC,CAAC;GAAG;GAC/H,IAAI,WAAgD;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,GAAGG,+BAAoB,cAAc,CAAC,CAAC;GAAG;GACtI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,mCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,mBAAmB,GAAG,GAAGC,iCAAqB,cAAc,CAAC,CAAC;GAAG;GACtN,IAAI,QAA0C;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,mCAAqB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAGC,oCAAsB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,kCAAoB,cAAc,CAAC;IAAC;GAAG;GAChS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
@@ -139,10 +139,6 @@ function createComputerUseServer(host) {
139
139
  }).createOwner(void 0);
140
140
  return {
141
141
  services: [(0, _agimon_ai_doompi_minor_mode.serverMinorModes)([modeOwner])],
142
- toolRestrictions: [{
143
- when: { state: { "minor-mode": require_computerUseApi.COMPUTER_USE_MODE_ID } },
144
- allowedTools: [...require_computerUse.COMPUTER_USE_TOOL_NAMES]
145
- }],
146
142
  activities: [{
147
143
  when: {
148
144
  state: { "minor-mode": require_computerUseApi.COMPUTER_USE_MODE_ID },
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createComputerUseSessionClient","path","ComputerScriptRunner","DefaultComputerUseExtensionService","COMPUTER_USE_MODE_ID","COMPUTER_USE_STATUS_KEY","defineMinorMode","modeState","serverMinorModes","COMPUTER_USE_TOOL_NAMES","COMMAND_NAME","COMMAND_DESCRIPTION"],"sources":["../../../../src/services/computerUseServer/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\nimport { serverMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner } from '@agimon-ai/doompi-minor-mode';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport { COMPUTER_USE_TOOL_NAMES } from '../../constants/computerUse';\nimport { modeState } from '../../models/computerUseMode';\nimport { ComputerScriptRunner } from '../../services/computerScriptRunner';\nimport { DefaultComputerUseExtensionService } from '../../services/extensionService';\nimport { createComputerUseSessionClient } from '../../services/sessionApiClient';\nimport type { ComputerUseAction, ComputerUseObservation } from '../../types/computerUse';\nimport { COMPUTER_USE_MODE_ID, COMPUTER_USE_STATUS_KEY } from '../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../types/computerUseApi';\n\n/** This package's identity for mode, activity and restriction ownership, not a status key. */\nconst SOURCE = '@agimon-ai/doompi-computer-use';\n\nconst SCRIPT_PATHS_ENV = 'DOOMPI_COMPUTER_USE_SCRIPT_PATHS';\nconst GUIDANCE =\n '[COMPUTER USE ACTIVE]\\nUse computer_state before acting and after any action that may change the interface. Use only element refs and snapshot ids returned by computer_state. Never infer coordinates or bypass secure elements.';\n\nfunction output(value: unknown, isError = false): DoomHeadlessToolResult {\n return {\n content: [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value, null, 2) }],\n details: value,\n ...(isError ? { isError: true } : {}),\n };\n}\n\nfunction observationOutput(value: ComputerUseObservation): DoomHeadlessToolResult {\n return {\n content: [\n { type: 'text', text: JSON.stringify({ ...value, screenshot: undefined }, null, 2) },\n { type: 'image', data: value.screenshot.data, mimeType: value.screenshot.mimeType },\n ],\n details: value,\n };\n}\n\nimport {\n type DoomHeadlessHostService,\n type DoomHeadlessTool,\n type DoomHeadlessCommand,\n} from '@agimon-ai/doompi-core/headless';\nimport { type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nexport function createComputerUseServer(host: DoomHeadlessHostService): Omit<\n DoomServerSessionPlugin,\n 'tools' | 'commands'\n> & {\n tools: readonly DoomHeadlessTool[];\n commands: readonly DoomHeadlessCommand[];\n} {\n const client = createComputerUseSessionClient();\n const allowedScriptPaths = (host.context.environment[SCRIPT_PATHS_ENV] ?? '')\n .split(path.delimiter)\n .filter((entry) => entry.length > 0);\n const scriptRunner = client === undefined ? undefined : new ComputerScriptRunner({ client, allowedScriptPaths });\n const service = new DefaultComputerUseExtensionService(client);\n const dependencies = { client, scriptRunner, service };\n let state: ComputerUseSessionView | undefined;\n let stopActivity: (() => void) | undefined;\n let modeOwner: MinorModeOwner | undefined;\n const modeSelected = (): boolean =>\n (host.context.selection.state?.['minor-mode'] ?? []).includes(COMPUTER_USE_MODE_ID);\n const publishMode = (): void => modeOwner?.publish();\n const applyState = (next: ComputerUseSessionView | undefined): void => {\n state = next;\n host.context.client.setStatus(\n COMPUTER_USE_STATUS_KEY,\n next === undefined || next.phase === 'inactive' ? undefined : `computer use: ${next.phase}`,\n );\n publishMode();\n };\n const selectMode = async (enabled: boolean): Promise<void> => {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, COMPUTER_USE_MODE_ID] : modes,\n });\n publishMode();\n };\n const refresh = async (signal?: AbortSignal): Promise<void> => {\n if (!client) {\n applyState(undefined);\n return;\n }\n try {\n applyState(await client.state(signal));\n } catch {\n applyState(undefined);\n }\n };\n const requireActive = (): NonNullable<typeof client> => {\n if (!client || state?.phase !== 'active') throw new Error('Computer use is not active for this session.');\n return client;\n };\n modeOwner = defineMinorMode<undefined>({\n descriptor: {\n source: SOURCE,\n id: COMPUTER_USE_MODE_ID,\n label: 'Computer Use',\n description: 'Session-scoped semantic control through DoomPi Desktop.',\n order: 450,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Enable computer use for this session.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, modeSelected()),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n execution.signal.throwIfAborted();\n if (actionId === 'activate') {\n if (!client) throw new Error('DoomPi Desktop computer use is unavailable.');\n await selectMode(true);\n await refresh(execution.signal);\n return { message: 'Computer use activated.' };\n }\n if (actionId === 'doctor') {\n await refresh(execution.signal);\n return {\n message: client\n ? `Computer use is ${state?.phase ?? 'unavailable'}.`\n : 'DoomPi Desktop session API is unavailable.',\n };\n }\n if (actionId === 'deactivate') {\n if (client && state?.phase !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n await selectMode(false);\n await refresh(execution.signal);\n return { message: 'Computer use deactivated.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n toolRestrictions: [\n {\n when: { state: { 'minor-mode': COMPUTER_USE_MODE_ID } },\n allowedTools: [...COMPUTER_USE_TOOL_NAMES],\n },\n ],\n activities: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: SOURCE,\n async start() {\n await refresh();\n const unsubscribe = client?.subscribeStatus?.(applyState);\n stopActivity = () => {\n unsubscribe?.();\n applyState(undefined);\n };\n return () => {\n stopActivity?.();\n stopActivity = undefined;\n };\n },\n },\n ],\n tools: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return semantic accessibility state.',\n parameters: { type: 'object', properties: {}, additionalProperties: false },\n executionMode: 'serial',\n async execute(_toolCallId, _parameters, signal) {\n try {\n const session = requireActive();\n const observation = await session.observe(signal);\n return observationOutput(observation);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string', minLength: 1 },\n elementRef: { type: 'string', minLength: 1 },\n value: { type: 'string' },\n direction: { type: 'string', enum: ['up', 'down', 'left', 'right'] },\n amount: { type: 'string', enum: ['line', 'page'] },\n },\n required: ['kind', 'snapshotId', 'elementRef'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n const result = await requireActive().act(parameters as unknown as ComputerUseAction, signal);\n await refresh(signal);\n return output(result);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_exec',\n label: 'Computer Script',\n description:\n 'Run a trusted, explicitly allowed local TypeScript script against the authorized application session.',\n parameters: {\n type: 'object',\n properties: { scriptPath: { type: 'string', minLength: 1 }, input: {} },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n if (!dependencies.scriptRunner) throw new Error('Computer script execution is unavailable.');\n const input = parameters as { scriptPath: string; input: unknown };\n return output(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal));\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n ],\n commands: [\n {\n name: COMMAND_NAME,\n description: COMMAND_DESCRIPTION,\n async execute(args, execution) {\n const result = await dependencies.service.execute();\n await execution.client.notify({ body: result.message, level: result.level });\n if (args.trim() === 'deactivate' && client && state?.phase !== 'inactive' && state?.phase !== 'failed') {\n await client.stop();\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: (execution.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID),\n });\n await refresh();\n }\n },\n },\n ],\n hooks: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'before_agent_start',\n handle(event) {\n if (state?.phase !== 'active') return undefined;\n const prompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${prompt}\\n\\n${GUIDANCE}`.trim() };\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'session_shutdown',\n handle: async () => {\n stopActivity?.();\n if (client && state?.phase !== 'inactive' && state?.phase !== 'failed') await client.stop();\n },\n },\n ],\n onDispose() {\n stopActivity?.();\n stopActivity = undefined;\n host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,SAAS;AAEf,MAAM,mBAAmB;AACzB,MAAM,WACJ;AAEF,SAA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E,MAAM;IACJ,OAAO,EAAE,cAAcA,uBAAAA,qBAAqB;IAC5C,aAAa;KAAE,MAAM;KAAS,MAAMA,uBAAAA;IAAqB;GAC3D;GACA,OAAO;GACP,QAAQ,YAAY;IAClB,eAAe;IACf,IAAI,UAAU,OAAO,UAAU,cAAc,OAAO,UAAU,UAAU,MAAM,OAAO,KAAK;GAC5F;EACF,CACF;EACA,YAAY;GACV,eAAe;GACf,eAAe,KAAA;GACf,KAAK,QAAQ,OAAO,UAAUC,uBAAAA,yBAAyB,KAAA,CAAS;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["createComputerUseSessionClient","path","ComputerScriptRunner","DefaultComputerUseExtensionService","COMPUTER_USE_MODE_ID","COMPUTER_USE_STATUS_KEY","defineMinorMode","modeState","serverMinorModes","COMMAND_NAME","COMMAND_DESCRIPTION"],"sources":["../../../../src/services/computerUseServer/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\nimport { serverMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner } from '@agimon-ai/doompi-minor-mode';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport { modeState } from '../../models/computerUseMode';\nimport { ComputerScriptRunner } from '../../services/computerScriptRunner';\nimport { DefaultComputerUseExtensionService } from '../../services/extensionService';\nimport { createComputerUseSessionClient } from '../../services/sessionApiClient';\nimport type { ComputerUseAction, ComputerUseObservation } from '../../types/computerUse';\nimport { COMPUTER_USE_MODE_ID, COMPUTER_USE_STATUS_KEY } from '../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../types/computerUseApi';\n\n/** This package's identity for mode, activity and restriction ownership, not a status key. */\nconst SOURCE = '@agimon-ai/doompi-computer-use';\n\nconst SCRIPT_PATHS_ENV = 'DOOMPI_COMPUTER_USE_SCRIPT_PATHS';\nconst GUIDANCE =\n '[COMPUTER USE ACTIVE]\\nUse computer_state before acting and after any action that may change the interface. Use only element refs and snapshot ids returned by computer_state. Never infer coordinates or bypass secure elements.';\n\nfunction output(value: unknown, isError = false): DoomHeadlessToolResult {\n return {\n content: [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value, null, 2) }],\n details: value,\n ...(isError ? { isError: true } : {}),\n };\n}\n\nfunction observationOutput(value: ComputerUseObservation): DoomHeadlessToolResult {\n return {\n content: [\n { type: 'text', text: JSON.stringify({ ...value, screenshot: undefined }, null, 2) },\n { type: 'image', data: value.screenshot.data, mimeType: value.screenshot.mimeType },\n ],\n details: value,\n };\n}\n\nimport {\n type DoomHeadlessHostService,\n type DoomHeadlessTool,\n type DoomHeadlessCommand,\n} from '@agimon-ai/doompi-core/headless';\nimport { type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nexport function createComputerUseServer(host: DoomHeadlessHostService): Omit<\n DoomServerSessionPlugin,\n 'tools' | 'commands'\n> & {\n tools: readonly DoomHeadlessTool[];\n commands: readonly DoomHeadlessCommand[];\n} {\n const client = createComputerUseSessionClient();\n const allowedScriptPaths = (host.context.environment[SCRIPT_PATHS_ENV] ?? '')\n .split(path.delimiter)\n .filter((entry) => entry.length > 0);\n const scriptRunner = client === undefined ? undefined : new ComputerScriptRunner({ client, allowedScriptPaths });\n const service = new DefaultComputerUseExtensionService(client);\n const dependencies = { client, scriptRunner, service };\n let state: ComputerUseSessionView | undefined;\n let stopActivity: (() => void) | undefined;\n let modeOwner: MinorModeOwner | undefined;\n const modeSelected = (): boolean =>\n (host.context.selection.state?.['minor-mode'] ?? []).includes(COMPUTER_USE_MODE_ID);\n const publishMode = (): void => modeOwner?.publish();\n const applyState = (next: ComputerUseSessionView | undefined): void => {\n state = next;\n host.context.client.setStatus(\n COMPUTER_USE_STATUS_KEY,\n next === undefined || next.phase === 'inactive' ? undefined : `computer use: ${next.phase}`,\n );\n publishMode();\n };\n const selectMode = async (enabled: boolean): Promise<void> => {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, COMPUTER_USE_MODE_ID] : modes,\n });\n publishMode();\n };\n const refresh = async (signal?: AbortSignal): Promise<void> => {\n if (!client) {\n applyState(undefined);\n return;\n }\n try {\n applyState(await client.state(signal));\n } catch {\n applyState(undefined);\n }\n };\n const requireActive = (): NonNullable<typeof client> => {\n if (!client || state?.phase !== 'active') throw new Error('Computer use is not active for this session.');\n return client;\n };\n modeOwner = defineMinorMode<undefined>({\n descriptor: {\n source: SOURCE,\n id: COMPUTER_USE_MODE_ID,\n label: 'Computer Use',\n description: 'Session-scoped semantic control through DoomPi Desktop.',\n order: 450,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Enable computer use for this session.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, modeSelected()),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n execution.signal.throwIfAborted();\n if (actionId === 'activate') {\n if (!client) throw new Error('DoomPi Desktop computer use is unavailable.');\n await selectMode(true);\n await refresh(execution.signal);\n return { message: 'Computer use activated.' };\n }\n if (actionId === 'doctor') {\n await refresh(execution.signal);\n return {\n message: client\n ? `Computer use is ${state?.phase ?? 'unavailable'}.`\n : 'DoomPi Desktop session API is unavailable.',\n };\n }\n if (actionId === 'deactivate') {\n if (client && state?.phase !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n await selectMode(false);\n await refresh(execution.signal);\n return { message: 'Computer use deactivated.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n activities: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: SOURCE,\n async start() {\n await refresh();\n const unsubscribe = client?.subscribeStatus?.(applyState);\n stopActivity = () => {\n unsubscribe?.();\n applyState(undefined);\n };\n return () => {\n stopActivity?.();\n stopActivity = undefined;\n };\n },\n },\n ],\n tools: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return semantic accessibility state.',\n parameters: { type: 'object', properties: {}, additionalProperties: false },\n executionMode: 'serial',\n async execute(_toolCallId, _parameters, signal) {\n try {\n const session = requireActive();\n const observation = await session.observe(signal);\n return observationOutput(observation);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string', minLength: 1 },\n elementRef: { type: 'string', minLength: 1 },\n value: { type: 'string' },\n direction: { type: 'string', enum: ['up', 'down', 'left', 'right'] },\n amount: { type: 'string', enum: ['line', 'page'] },\n },\n required: ['kind', 'snapshotId', 'elementRef'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n const result = await requireActive().act(parameters as unknown as ComputerUseAction, signal);\n await refresh(signal);\n return output(result);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_exec',\n label: 'Computer Script',\n description:\n 'Run a trusted, explicitly allowed local TypeScript script against the authorized application session.',\n parameters: {\n type: 'object',\n properties: { scriptPath: { type: 'string', minLength: 1 }, input: {} },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n if (!dependencies.scriptRunner) throw new Error('Computer script execution is unavailable.');\n const input = parameters as { scriptPath: string; input: unknown };\n return output(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal));\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n ],\n commands: [\n {\n name: COMMAND_NAME,\n description: COMMAND_DESCRIPTION,\n async execute(args, execution) {\n const result = await dependencies.service.execute();\n await execution.client.notify({ body: result.message, level: result.level });\n if (args.trim() === 'deactivate' && client && state?.phase !== 'inactive' && state?.phase !== 'failed') {\n await client.stop();\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: (execution.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID),\n });\n await refresh();\n }\n },\n },\n ],\n hooks: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'before_agent_start',\n handle(event) {\n if (state?.phase !== 'active') return undefined;\n const prompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${prompt}\\n\\n${GUIDANCE}`.trim() };\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'session_shutdown',\n handle: async () => {\n stopActivity?.();\n if (client && state?.phase !== 'inactive' && state?.phase !== 'failed') await client.stop();\n },\n },\n ],\n onDispose() {\n stopActivity?.();\n stopActivity = undefined;\n host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n },\n };\n}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A,qBAAqB;IAC5C,aAAa;KAAE,MAAM;KAAS,MAAMA,uBAAAA;IAAqB;GAC3D;GACA,OAAO;GACP,QAAQ,YAAY;IAClB,eAAe;IACf,IAAI,UAAU,OAAO,UAAU,cAAc,OAAO,UAAU,UAAU,MAAM,OAAO,KAAK;GAC5F;EACF,CACF;EACA,YAAY;GACV,eAAe;GACf,eAAe,KAAA;GACf,KAAK,QAAQ,OAAO,UAAUC,uBAAAA,yBAAyB,KAAA,CAAS;EAClE;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { COMMAND_DESCRIPTION, COMMAND_NAME, COMPUTER_USE_TOOL_NAMES } from "../../constants/computerUse.mjs";
1
+ import { COMMAND_DESCRIPTION, COMMAND_NAME } from "../../constants/computerUse.mjs";
2
2
  import { createComputerUseSessionClient } from "../sessionApiClient/index.mjs";
3
3
  import { ComputerScriptRunner } from "../computerScriptRunner/index.mjs";
4
4
  import { DefaultComputerUseExtensionService } from "../extensionService/index.mjs";
@@ -137,10 +137,6 @@ function createComputerUseServer(host) {
137
137
  }).createOwner(void 0);
138
138
  return {
139
139
  services: [serverMinorModes([modeOwner])],
140
- toolRestrictions: [{
141
- when: { state: { "minor-mode": COMPUTER_USE_MODE_ID } },
142
- allowedTools: [...COMPUTER_USE_TOOL_NAMES]
143
- }],
144
140
  activities: [{
145
141
  when: {
146
142
  state: { "minor-mode": COMPUTER_USE_MODE_ID },
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/computerUseServer/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\nimport { serverMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner } from '@agimon-ai/doompi-minor-mode';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport { COMPUTER_USE_TOOL_NAMES } from '../../constants/computerUse';\nimport { modeState } from '../../models/computerUseMode';\nimport { ComputerScriptRunner } from '../../services/computerScriptRunner';\nimport { DefaultComputerUseExtensionService } from '../../services/extensionService';\nimport { createComputerUseSessionClient } from '../../services/sessionApiClient';\nimport type { ComputerUseAction, ComputerUseObservation } from '../../types/computerUse';\nimport { COMPUTER_USE_MODE_ID, COMPUTER_USE_STATUS_KEY } from '../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../types/computerUseApi';\n\n/** This package's identity for mode, activity and restriction ownership, not a status key. */\nconst SOURCE = '@agimon-ai/doompi-computer-use';\n\nconst SCRIPT_PATHS_ENV = 'DOOMPI_COMPUTER_USE_SCRIPT_PATHS';\nconst GUIDANCE =\n '[COMPUTER USE ACTIVE]\\nUse computer_state before acting and after any action that may change the interface. Use only element refs and snapshot ids returned by computer_state. Never infer coordinates or bypass secure elements.';\n\nfunction output(value: unknown, isError = false): DoomHeadlessToolResult {\n return {\n content: [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value, null, 2) }],\n details: value,\n ...(isError ? { isError: true } : {}),\n };\n}\n\nfunction observationOutput(value: ComputerUseObservation): DoomHeadlessToolResult {\n return {\n content: [\n { type: 'text', text: JSON.stringify({ ...value, screenshot: undefined }, null, 2) },\n { type: 'image', data: value.screenshot.data, mimeType: value.screenshot.mimeType },\n ],\n details: value,\n };\n}\n\nimport {\n type DoomHeadlessHostService,\n type DoomHeadlessTool,\n type DoomHeadlessCommand,\n} from '@agimon-ai/doompi-core/headless';\nimport { type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nexport function createComputerUseServer(host: DoomHeadlessHostService): Omit<\n DoomServerSessionPlugin,\n 'tools' | 'commands'\n> & {\n tools: readonly DoomHeadlessTool[];\n commands: readonly DoomHeadlessCommand[];\n} {\n const client = createComputerUseSessionClient();\n const allowedScriptPaths = (host.context.environment[SCRIPT_PATHS_ENV] ?? '')\n .split(path.delimiter)\n .filter((entry) => entry.length > 0);\n const scriptRunner = client === undefined ? undefined : new ComputerScriptRunner({ client, allowedScriptPaths });\n const service = new DefaultComputerUseExtensionService(client);\n const dependencies = { client, scriptRunner, service };\n let state: ComputerUseSessionView | undefined;\n let stopActivity: (() => void) | undefined;\n let modeOwner: MinorModeOwner | undefined;\n const modeSelected = (): boolean =>\n (host.context.selection.state?.['minor-mode'] ?? []).includes(COMPUTER_USE_MODE_ID);\n const publishMode = (): void => modeOwner?.publish();\n const applyState = (next: ComputerUseSessionView | undefined): void => {\n state = next;\n host.context.client.setStatus(\n COMPUTER_USE_STATUS_KEY,\n next === undefined || next.phase === 'inactive' ? undefined : `computer use: ${next.phase}`,\n );\n publishMode();\n };\n const selectMode = async (enabled: boolean): Promise<void> => {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, COMPUTER_USE_MODE_ID] : modes,\n });\n publishMode();\n };\n const refresh = async (signal?: AbortSignal): Promise<void> => {\n if (!client) {\n applyState(undefined);\n return;\n }\n try {\n applyState(await client.state(signal));\n } catch {\n applyState(undefined);\n }\n };\n const requireActive = (): NonNullable<typeof client> => {\n if (!client || state?.phase !== 'active') throw new Error('Computer use is not active for this session.');\n return client;\n };\n modeOwner = defineMinorMode<undefined>({\n descriptor: {\n source: SOURCE,\n id: COMPUTER_USE_MODE_ID,\n label: 'Computer Use',\n description: 'Session-scoped semantic control through DoomPi Desktop.',\n order: 450,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Enable computer use for this session.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, modeSelected()),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n execution.signal.throwIfAborted();\n if (actionId === 'activate') {\n if (!client) throw new Error('DoomPi Desktop computer use is unavailable.');\n await selectMode(true);\n await refresh(execution.signal);\n return { message: 'Computer use activated.' };\n }\n if (actionId === 'doctor') {\n await refresh(execution.signal);\n return {\n message: client\n ? `Computer use is ${state?.phase ?? 'unavailable'}.`\n : 'DoomPi Desktop session API is unavailable.',\n };\n }\n if (actionId === 'deactivate') {\n if (client && state?.phase !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n await selectMode(false);\n await refresh(execution.signal);\n return { message: 'Computer use deactivated.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n toolRestrictions: [\n {\n when: { state: { 'minor-mode': COMPUTER_USE_MODE_ID } },\n allowedTools: [...COMPUTER_USE_TOOL_NAMES],\n },\n ],\n activities: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: SOURCE,\n async start() {\n await refresh();\n const unsubscribe = client?.subscribeStatus?.(applyState);\n stopActivity = () => {\n unsubscribe?.();\n applyState(undefined);\n };\n return () => {\n stopActivity?.();\n stopActivity = undefined;\n };\n },\n },\n ],\n tools: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return semantic accessibility state.',\n parameters: { type: 'object', properties: {}, additionalProperties: false },\n executionMode: 'serial',\n async execute(_toolCallId, _parameters, signal) {\n try {\n const session = requireActive();\n const observation = await session.observe(signal);\n return observationOutput(observation);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string', minLength: 1 },\n elementRef: { type: 'string', minLength: 1 },\n value: { type: 'string' },\n direction: { type: 'string', enum: ['up', 'down', 'left', 'right'] },\n amount: { type: 'string', enum: ['line', 'page'] },\n },\n required: ['kind', 'snapshotId', 'elementRef'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n const result = await requireActive().act(parameters as unknown as ComputerUseAction, signal);\n await refresh(signal);\n return output(result);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_exec',\n label: 'Computer Script',\n description:\n 'Run a trusted, explicitly allowed local TypeScript script against the authorized application session.',\n parameters: {\n type: 'object',\n properties: { scriptPath: { type: 'string', minLength: 1 }, input: {} },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n if (!dependencies.scriptRunner) throw new Error('Computer script execution is unavailable.');\n const input = parameters as { scriptPath: string; input: unknown };\n return output(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal));\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n ],\n commands: [\n {\n name: COMMAND_NAME,\n description: COMMAND_DESCRIPTION,\n async execute(args, execution) {\n const result = await dependencies.service.execute();\n await execution.client.notify({ body: result.message, level: result.level });\n if (args.trim() === 'deactivate' && client && state?.phase !== 'inactive' && state?.phase !== 'failed') {\n await client.stop();\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: (execution.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID),\n });\n await refresh();\n }\n },\n },\n ],\n hooks: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'before_agent_start',\n handle(event) {\n if (state?.phase !== 'active') return undefined;\n const prompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${prompt}\\n\\n${GUIDANCE}`.trim() };\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'session_shutdown',\n handle: async () => {\n stopActivity?.();\n if (client && state?.phase !== 'inactive' && state?.phase !== 'failed') await client.stop();\n },\n },\n ],\n onDispose() {\n stopActivity?.();\n stopActivity = undefined;\n host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,SAAS;AAEf,MAAM,mBAAmB;AACzB,MAAM,WACJ;AAEF,SAAS,OAAO,OAAgB,UAAU,OAA+B;CACvE,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,OAAO,MAAM,CAAC;EAAE,CAAC;EACpG,SAAS;EACT,GAAI,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC;AACF;AAEA,SAAS,kBAAkB,OAAuD;CAChF,OAAO;EACL,SAAS,CACP;GAAE,MAAM;GAAQ,MAAM,KAAK,UAAU;IAAE,GAAG;IAAO,YAAY,KAAA;GAAU,GAAG,MAAM,CAAC;EAAE,GACnF;GAAE,MAAM;GAAS,MAAM,MAAM,WAAW;GAAM,UAAU,MAAM,WAAW;EAAS,CACpF;EACA,SAAS;CACX;AACF;AAQA,SAAgB,wBAAwB,MAMtC;CACA,MAAM,SAAS,+BAA+B;CAC9C,MAAM,sBAAsB,KAAK,QAAQ,YAAY,qBAAqB,GAAA,CACvE,MAAM,KAAK,SAAS,CAAC,C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C;KACD,MAAM,QAAQ;IAChB;GACF;EACF,CACF;EACA,OAAO,CACL;GACE,MAAM;IACJ,OAAO,EAAE,cAAc,qBAAqB;IAC5C,aAAa;KAAE,MAAM;KAAS,MAAM;IAAqB;GAC3D;GACA,OAAO;GACP,OAAO,OAAO;IACZ,IAAI,OAAO,UAAU,UAAU,OAAO,KAAA;IAEtC,OAAO,EAAE,cAAc,GADR,OAAO,MAAM,iBAAiB,WAAW,MAAM,eAAe,GAC5C,MAAM,WAAW,KAAK,EAAE;GAC3D;EACF,GACA;GACE,MAAM;IACJ,OAAO,EAAE,cAAc,qBAAqB;IAC5C,aAAa;KAAE,MAAM;KAAS,MAAM;IAAqB;GAC3D;GACA,OAAO;GACP,QAAQ,YAAY;IAClB,eAAe;IACf,IAAI,UAAU,OAAO,UAAU,cAAc,OAAO,UAAU,UAAU,MAAM,OAAO,KAAK;GAC5F;EACF,CACF;EACA,YAAY;GACV,eAAe;GACf,eAAe,KAAA;GACf,KAAK,QAAQ,OAAO,UAAU,yBAAyB,KAAA,CAAS;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/computerUseServer/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\nimport { serverMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner } from '@agimon-ai/doompi-minor-mode';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport { modeState } from '../../models/computerUseMode';\nimport { ComputerScriptRunner } from '../../services/computerScriptRunner';\nimport { DefaultComputerUseExtensionService } from '../../services/extensionService';\nimport { createComputerUseSessionClient } from '../../services/sessionApiClient';\nimport type { ComputerUseAction, ComputerUseObservation } from '../../types/computerUse';\nimport { COMPUTER_USE_MODE_ID, COMPUTER_USE_STATUS_KEY } from '../../types/computerUseApi';\nimport type { ComputerUseSessionView } from '../../types/computerUseApi';\n\n/** This package's identity for mode, activity and restriction ownership, not a status key. */\nconst SOURCE = '@agimon-ai/doompi-computer-use';\n\nconst SCRIPT_PATHS_ENV = 'DOOMPI_COMPUTER_USE_SCRIPT_PATHS';\nconst GUIDANCE =\n '[COMPUTER USE ACTIVE]\\nUse computer_state before acting and after any action that may change the interface. Use only element refs and snapshot ids returned by computer_state. Never infer coordinates or bypass secure elements.';\n\nfunction output(value: unknown, isError = false): DoomHeadlessToolResult {\n return {\n content: [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value, null, 2) }],\n details: value,\n ...(isError ? { isError: true } : {}),\n };\n}\n\nfunction observationOutput(value: ComputerUseObservation): DoomHeadlessToolResult {\n return {\n content: [\n { type: 'text', text: JSON.stringify({ ...value, screenshot: undefined }, null, 2) },\n { type: 'image', data: value.screenshot.data, mimeType: value.screenshot.mimeType },\n ],\n details: value,\n };\n}\n\nimport {\n type DoomHeadlessHostService,\n type DoomHeadlessTool,\n type DoomHeadlessCommand,\n} from '@agimon-ai/doompi-core/headless';\nimport { type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/server-facet';\nexport function createComputerUseServer(host: DoomHeadlessHostService): Omit<\n DoomServerSessionPlugin,\n 'tools' | 'commands'\n> & {\n tools: readonly DoomHeadlessTool[];\n commands: readonly DoomHeadlessCommand[];\n} {\n const client = createComputerUseSessionClient();\n const allowedScriptPaths = (host.context.environment[SCRIPT_PATHS_ENV] ?? '')\n .split(path.delimiter)\n .filter((entry) => entry.length > 0);\n const scriptRunner = client === undefined ? undefined : new ComputerScriptRunner({ client, allowedScriptPaths });\n const service = new DefaultComputerUseExtensionService(client);\n const dependencies = { client, scriptRunner, service };\n let state: ComputerUseSessionView | undefined;\n let stopActivity: (() => void) | undefined;\n let modeOwner: MinorModeOwner | undefined;\n const modeSelected = (): boolean =>\n (host.context.selection.state?.['minor-mode'] ?? []).includes(COMPUTER_USE_MODE_ID);\n const publishMode = (): void => modeOwner?.publish();\n const applyState = (next: ComputerUseSessionView | undefined): void => {\n state = next;\n host.context.client.setStatus(\n COMPUTER_USE_STATUS_KEY,\n next === undefined || next.phase === 'inactive' ? undefined : `computer use: ${next.phase}`,\n );\n publishMode();\n };\n const selectMode = async (enabled: boolean): Promise<void> => {\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, COMPUTER_USE_MODE_ID] : modes,\n });\n publishMode();\n };\n const refresh = async (signal?: AbortSignal): Promise<void> => {\n if (!client) {\n applyState(undefined);\n return;\n }\n try {\n applyState(await client.state(signal));\n } catch {\n applyState(undefined);\n }\n };\n const requireActive = (): NonNullable<typeof client> => {\n if (!client || state?.phase !== 'active') throw new Error('Computer use is not active for this session.');\n return client;\n };\n modeOwner = defineMinorMode<undefined>({\n descriptor: {\n source: SOURCE,\n id: COMPUTER_USE_MODE_ID,\n label: 'Computer Use',\n description: 'Session-scoped semantic control through DoomPi Desktop.',\n order: 450,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Enable computer use for this session.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, modeSelected()),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n execution.signal.throwIfAborted();\n if (actionId === 'activate') {\n if (!client) throw new Error('DoomPi Desktop computer use is unavailable.');\n await selectMode(true);\n await refresh(execution.signal);\n return { message: 'Computer use activated.' };\n }\n if (actionId === 'doctor') {\n await refresh(execution.signal);\n return {\n message: client\n ? `Computer use is ${state?.phase ?? 'unavailable'}.`\n : 'DoomPi Desktop session API is unavailable.',\n };\n }\n if (actionId === 'deactivate') {\n if (client && state?.phase !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n await selectMode(false);\n await refresh(execution.signal);\n return { message: 'Computer use deactivated.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n activities: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: SOURCE,\n async start() {\n await refresh();\n const unsubscribe = client?.subscribeStatus?.(applyState);\n stopActivity = () => {\n unsubscribe?.();\n applyState(undefined);\n };\n return () => {\n stopActivity?.();\n stopActivity = undefined;\n };\n },\n },\n ],\n tools: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return semantic accessibility state.',\n parameters: { type: 'object', properties: {}, additionalProperties: false },\n executionMode: 'serial',\n async execute(_toolCallId, _parameters, signal) {\n try {\n const session = requireActive();\n const observation = await session.observe(signal);\n return observationOutput(observation);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string', minLength: 1 },\n elementRef: { type: 'string', minLength: 1 },\n value: { type: 'string' },\n direction: { type: 'string', enum: ['up', 'down', 'left', 'right'] },\n amount: { type: 'string', enum: ['line', 'page'] },\n },\n required: ['kind', 'snapshotId', 'elementRef'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n const result = await requireActive().act(parameters as unknown as ComputerUseAction, signal);\n await refresh(signal);\n return output(result);\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n name: 'computer_exec',\n label: 'Computer Script',\n description:\n 'Run a trusted, explicitly allowed local TypeScript script against the authorized application session.',\n parameters: {\n type: 'object',\n properties: { scriptPath: { type: 'string', minLength: 1 }, input: {} },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n try {\n if (!dependencies.scriptRunner) throw new Error('Computer script execution is unavailable.');\n const input = parameters as { scriptPath: string; input: unknown };\n return output(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal));\n } catch (error) {\n return output(error instanceof Error ? error.message : String(error), true);\n }\n },\n },\n ],\n commands: [\n {\n name: COMMAND_NAME,\n description: COMMAND_DESCRIPTION,\n async execute(args, execution) {\n const result = await dependencies.service.execute();\n await execution.client.notify({ body: result.message, level: result.level });\n if (args.trim() === 'deactivate' && client && state?.phase !== 'inactive' && state?.phase !== 'failed') {\n await client.stop();\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: (execution.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== COMPUTER_USE_MODE_ID),\n });\n await refresh();\n }\n },\n },\n ],\n hooks: [\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'before_agent_start',\n handle(event) {\n if (state?.phase !== 'active') return undefined;\n const prompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${prompt}\\n\\n${GUIDANCE}`.trim() };\n },\n },\n {\n when: {\n state: { 'minor-mode': COMPUTER_USE_MODE_ID },\n attribution: { kind: 'minor', mode: COMPUTER_USE_MODE_ID },\n },\n event: 'session_shutdown',\n handle: async () => {\n stopActivity?.();\n if (client && state?.phase !== 'inactive' && state?.phase !== 'failed') await client.stop();\n },\n },\n ],\n onDispose() {\n stopActivity?.();\n stopActivity = undefined;\n host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,SAAS;AAEf,MAAM,mBAAmB;AACzB,MAAM,WACJ;AAEF,SAAS,OAAO,OAAgB,UAAU,OAA+B;CACvE,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,OAAO,MAAM,CAAC;EAAE,CAAC;EACpG,SAAS;EACT,GAAI,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC;AACF;AAEA,SAAS,kBAAkB,OAAuD;CAChF,OAAO;EACL,SAAS,CACP;GAAE,MAAM;GAAQ,MAAM,KAAK,UAAU;IAAE,GAAG;IAAO,YAAY,KAAA;GAAU,GAAG,MAAM,CAAC;EAAE,GACnF;GAAE,MAAM;GAAS,MAAM,MAAM,WAAW;GAAM,UAAU,MAAM,WAAW;EAAS,CACpF;EACA,SAAS;CACX;AACF;AAQA,SAAgB,wBAAwB,MAMtC;CACA,MAAM,SAAS,+BAA+B;CAC9C,MAAM,sBAAsB,KAAK,QAAQ,YAAY,qBAAqB,GAAA,CACvE,MAAM,KAAK,SAAS,CAAC,CACrB,QAAQ,UAAU,MAAM,SAAS,CAAC;CAGrC,MAAM,eAAe;EAAE;EAAQ,cAFV,WAAW,KAAA,IAAY,KAAA,IAAY,IAAI,qBAAqB;GAAE;GAAQ;EAAmB,CAAC;EAElE,SAAA,IADzB,mCAAmC,MACJ;CAAE;CACrD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,sBACH,KAAK,QAAQ,UAAU,QAAQ,iBAAiB,CAAC,EAAA,CAAG,SAAS,oBAAoB;CACpF,MAAM,oBAA0B,WAAW,QAAQ;CACnD,MAAM,cAAc,SAAmD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f,IAAI,UAAU,OAAO,UAAU,cAAc,OAAO,UAAU,UAAU,MAAM,OAAO,KAAK;GAC5F;EACF,CACF;EACA,YAAY;GACV,eAAe;GACf,eAAe,KAAA;GACf,KAAK,QAAQ,OAAO,UAAU,yBAAyB,KAAA,CAAS;EAClE;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/doompi-computer-use",
3
- "version": "0.0.1-alpha.22",
3
+ "version": "0.0.1-alpha.24",
4
4
  "description": "Session scoped semantic computer control through the DoomPi Desktop capability.",
5
5
  "keywords": [
6
6
  "ai",
@@ -64,28 +64,28 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@agimon-ai/doompi-config": "0.0.1-alpha.77",
68
- "@agimon-ai/doompi-core": "0.0.1-alpha.78",
69
- "@agimon-ai/doompi-minor-mode": "0.0.1-alpha.78",
70
- "@agimon-ai/doompi-web-components": "0.0.1-alpha.36",
71
- "@agimon-ai/doompi-web-security": "0.0.1-alpha.38",
67
+ "@agimon-ai/doompi-config": "0.0.1-alpha.79",
68
+ "@agimon-ai/doompi-core": "0.0.1-alpha.80",
69
+ "@agimon-ai/doompi-minor-mode": "0.0.1-alpha.80",
70
+ "@agimon-ai/doompi-web-components": "0.0.1-alpha.38",
71
+ "@agimon-ai/doompi-web-security": "0.0.1-alpha.40",
72
72
  "@deepseek-ai/cordis": "4.0.2",
73
- "typebox": "1.3.30"
73
+ "typebox": "1.3.34"
74
74
  },
75
75
  "devDependencies": {
76
- "@agimon-ai/doompi-build": "0.0.1-alpha.7",
77
- "@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.73",
76
+ "@agimon-ai/doompi-build": "0.0.1-alpha.9",
77
+ "@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.75",
78
78
  "@earendil-works/pi-coding-agent": "0.86.0",
79
79
  "@tanstack/react-store": "0.11.1",
80
80
  "@tanstack/store": "0.11.1",
81
- "@types/node": "26.5.1",
81
+ "@types/node": "26.6.1",
82
82
  "@types/react": "19.3.0",
83
- "@vitest/coverage-v8": "5.0.0",
83
+ "@vitest/coverage-v8": "5.0.1",
84
84
  "react": "19.3.0",
85
85
  "react-dom": "19.3.0",
86
86
  "tsdown": "0.23.0",
87
87
  "typescript": "7.0.2",
88
- "vitest": "5.0.0"
88
+ "vitest": "5.0.1"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@earendil-works/pi-coding-agent": "0.86.0"
@@ -1,6 +0,0 @@
1
- //#region src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.ts
2
- var computer_use_server_default = (0, require("@agimon-ai/doompi-core/extension-file").defineToolRestriction)((context) => context.root.toolRestrictions[0]);
3
- //#endregion
4
- exports.default = computer_use_server_default;
5
-
6
- //# sourceMappingURL=computer-use.server.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computer-use.server.cjs","names":["defineToolRestriction"],"sources":["../../../../../../../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.ts"],"sourcesContent":["import { defineToolRestriction, type WithRoot } from '@agimon-ai/doompi-core/extension-file';\ntype Runtime = Awaited<ReturnType<typeof import('../root.server').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineToolRestriction((context: Context) => context.root.toolRestrictions![0]!);\n"],"mappings":";AAIA,IAAA,+BAAA,kDAAeA,CAAAA,CAAAA,sBAAAA,EAAuB,YAAqB,QAAQ,KAAK,iBAAkB,EAAG"}
@@ -1,7 +0,0 @@
1
- import { defineToolRestriction } from "@agimon-ai/doompi-core/extension-file";
2
- //#region src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.ts
3
- var computer_use_server_default = defineToolRestriction((context) => context.root.toolRestrictions[0]);
4
- //#endregion
5
- export { computer_use_server_default as default };
6
-
7
- //# sourceMappingURL=computer-use.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computer-use.server.mjs","names":[],"sources":["../../../../../../../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.server.ts"],"sourcesContent":["import { defineToolRestriction, type WithRoot } from '@agimon-ai/doompi-core/extension-file';\ntype Runtime = Awaited<ReturnType<typeof import('../root.server').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineToolRestriction((context: Context) => context.root.toolRestrictions![0]!);\n"],"mappings":";;AAIA,IAAA,8BAAe,uBAAuB,YAAqB,QAAQ,KAAK,iBAAkB,EAAG"}