@agimon-ai/doompi-computer-use 0.0.1-alpha.26 → 0.0.1-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -10
- package/dist/{computerUseMode-BgtaVx_z.cjs → computerUseMode-CHpbP7yo.cjs} +81 -2
- package/dist/computerUseMode-CHpbP7yo.cjs.map +1 -0
- package/dist/{computerUseMode-nb6yoF4Y.mjs → computerUseMode-DTXNRobA.mjs} +64 -3
- package/dist/computerUseMode-DTXNRobA.mjs.map +1 -0
- package/dist/{dependencies-CuOzd5Pm.cjs → dependencies-Dub2ybTN.cjs} +15 -3
- package/dist/dependencies-Dub2ybTN.cjs.map +1 -0
- package/dist/{dependencies-gtxIMe7d.mjs → dependencies-Y1TS7gGv.mjs} +9 -3
- package/dist/dependencies-Y1TS7gGv.mjs.map +1 -0
- package/dist/extensionService-BJXeNc4R.mjs +434 -0
- package/dist/extensionService-BJXeNc4R.mjs.map +1 -0
- package/dist/extensionService-CZS-zDP0.cjs +504 -0
- package/dist/extensionService-CZS-zDP0.cjs.map +1 -0
- package/dist/extensions/mcp.cjs +11 -8
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts.map +1 -1
- package/dist/extensions/mcp.mjs +12 -9
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/pi.cjs +23 -26
- package/dist/extensions/pi.cjs.map +1 -1
- package/dist/extensions/pi.d.mts +1 -1
- package/dist/extensions/pi.d.mts.map +1 -1
- package/dist/extensions/pi.mjs +23 -26
- package/dist/extensions/pi.mjs.map +1 -1
- package/dist/extensions/server.cjs +246 -82
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +247 -83
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +5 -2
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/{index-CazCNSuR.d.mts → index-0S6V4EU9.d.mts} +116 -98
- package/dist/index-0S6V4EU9.d.mts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/docs/computer-scripts.md +58 -23
- package/package.json +9 -8
- package/src/prompts/doompi-use-computer-use/SKILL.md +25 -11
- package/src/types/computerUse.ts +15 -1
- package/dist/computerUseMode-BgtaVx_z.cjs.map +0 -1
- package/dist/computerUseMode-nb6yoF4Y.mjs.map +0 -1
- package/dist/dependencies-CuOzd5Pm.cjs.map +0 -1
- package/dist/dependencies-gtxIMe7d.mjs.map +0 -1
- package/dist/extensionService-44mLS5b_.cjs +0 -275
- package/dist/extensionService-44mLS5b_.cjs.map +0 -1
- package/dist/extensionService-nFT_46iM.mjs +0 -206
- package/dist/extensionService-nFT_46iM.mjs.map +0 -1
- package/dist/index-CazCNSuR.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.cjs","names":["
|
|
1
|
+
{"version":3,"file":"mcp.cjs","names":["defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineMcpPlugin","toolComputerAction","toolComputerExec","toolComputerState"],"sources":["../../src/types/computerUseApi.ts","../../src/services/mcpTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { DoomApiCaller } from '@agimon-ai/doompi-core/packageApi';\n\nexport const API_BASE_PATH = 'computer-use';\nexport const computerUseChannelType = 'computer_use_state';\nexport const COMPUTER_USE_MODE_ID = 'computer-use';\nexport const COMPUTER_USE_STATUS_KEY = 'doom-computer-use';\nexport const COMPUTER_USE_MODE_STATUS_KEY = 'doom-computer-use-mode';\nexport const COMPUTER_USE_MAX_DURATION_MS = 1_800 * 1_000;\nexport const COMPUTER_USE_DEFAULT_DURATION_MS = 300 * 1_000;\nexport const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 2 * 60 * 1_000;\n\n/**\n * Every path this API answers on, below its mount.\n *\n * The typed route table in `./apiRoutes` is built from this, the dispatcher\n * reads that table, and the hub channel addresses the broker with these same\n * strings, so a route cannot move on one side alone.\n */\nexport const COMPUTER_USE_ROUTES = {\n activate: '/activate',\n agentState: '/agent/state',\n agentObserve: '/agent/observe',\n agentAction: '/agent/action',\n agentStop: '/agent/stop',\n hubState: '/hub/state',\n hubActivation: '/hub/activation',\n hubAuthorization: '/hub/authorization',\n hubNext: '/hub/next',\n hubComplete: '/hub/complete',\n hubStop: '/hub/stop',\n} as const;\n\nexport const COMPUTER_USE_WAKE_LIMIT = 1_000_000;\n\nexport interface ComputerUseArtifactView {\n readonly artifactId: string;\n readonly status: 'ready' | 'failed';\n readonly downloadUrl?: string;\n readonly previewUrl?: string;\n readonly actionCount?: number;\n readonly completedAt?: string;\n readonly failure?: { readonly code: string; readonly message: string };\n}\n\nexport interface ComputerUseSessionView {\n readonly sessionId: string;\n readonly revision: number;\n readonly wake: number;\n readonly phase: 'inactive' | 'awaiting_confirmation' | 'activating' | 'active' | 'stopping' | 'failed';\n readonly requestId?: string;\n readonly target?: Record<string, unknown>;\n readonly durationMs?: number;\n readonly expiresAt?: number;\n readonly failure?: { readonly code: string; readonly message: string };\n readonly artifact?: ComputerUseArtifactView;\n}\n\nexport interface ComputerUseActivationRequest {\n readonly requestId: string;\n readonly target: Record<string, unknown>;\n readonly durationSeconds: number;\n readonly createdAt: number;\n readonly confirmationExpiresAt: number;\n readonly caller: DoomApiCaller;\n}\n\nexport interface ComputerUseBrokerRequest {\n readonly id: string;\n readonly operation: 'observe' | 'act';\n readonly payload?: unknown;\n readonly grantId: string;\n readonly sequence?: number;\n}\n\nexport interface ComputerUseChannelPayload {\n readonly state: ComputerUseSessionView;\n readonly targets: readonly Record<string, unknown>[];\n readonly busy?: true;\n}\n\nexport type ComputerUseBrowserCommand = { readonly action: 'status' | 'targets' | 'stop' | 'artifacts' };\n","import type { DoomHeadlessTool } from '@agimon-ai/doompi-core/headless';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { COMPUTER_USE_MODE_ID } from '../../types/computerUseApi';\n\nexport const COMPUTER_USE_MCP_TOOLS_SERVICE = 'doom/computer-use-mcp-tools';\n\nconst MODE_LABEL = 'Computer Use';\n\nexport interface McpToolCatalog {\n get(name: string): DoomHeadlessTool | undefined;\n names(): readonly string[];\n}\n\nexport function mountMcpTools(tools: readonly DoomHeadlessTool[]) {\n return (context: Context): void => {\n context.plugin((providerContext) => {\n providerContext.provide(COMPUTER_USE_MCP_TOOLS_SERVICE, {\n get: (name) => tools.find((tool) => tool.name === name),\n names: () => tools.map((tool) => tool.name),\n } satisfies McpToolCatalog);\n });\n };\n}\n\nexport function bindMcpTool(context: DoomMcpPluginContext, name: string): DoomHeadlessTool | undefined {\n const catalog = context.services.get<McpToolCatalog>(COMPUTER_USE_MCP_TOOLS_SERVICE);\n const tool = catalog?.get(name);\n if (!tool || !catalog) return undefined;\n return {\n ...tool,\n execute(toolCallId, parameters, signal, onUpdate) {\n const activeModes = context.selection.read().state?.['minor-mode'] ?? [];\n if (!activeModes.includes(COMPUTER_USE_MODE_ID)) {\n const inactiveTools = [...catalog.names()].sort().join(', ');\n throw new Error(`${MODE_LABEL} minor mode is inactive. Inactive ${MODE_LABEL} tools: ${inactiveTools}.`);\n }\n const executionSignal = AbortSignal.any([context.signal, signal ?? context.signal]);\n return tool.execute(toolCallId, parameters, executionSignal, onUpdate, context.execution);\n },\n };\n}\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_action'), {\n cardinality: 'optional',\n});\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_exec'), {\n cardinality: 'optional',\n});\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_state'), {\n cardinality: 'optional',\n});\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineMcpPlugin, type DoomMcpSessionPlugin } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport toolComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp';\nimport toolComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp';\nimport toolComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp';\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;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/doompi-computer-use',\n session: (context) => ({\n get tools(): DoomMcpSessionPlugin['tools'] { return defined([via({ name: 'computer_action' }, at(toolComputerAction, context)), via({ name: 'computer_exec' }, at(toolComputerExec, context)), via({ name: 'computer_state' }, at(toolComputerState, context))]); },\n }) satisfies DoomMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;;;;;ACMA,MAAa,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AAU,GAAI;AAAiB;AAEzE,MAAa,OAAA,GAAMC,gCAAAA,gBAAAA,CAAgB;CACjC,MAAM;CACN,UAAU,aAAa,EACrB,IAAI,QAAuC;EAAE,OAAO,QAAQ;GAAC,IAAI,EAAE,MAAM,kBAAkB,GAAG,GAAGC,6BAAoB,OAAO,CAAC;GAAG,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC;GAAG,IAAI,EAAE,MAAM,iBAAiB,GAAG,GAAGC,4BAAmB,OAAO,CAAC;EAAC,CAAC;CAAG,EACpQ;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../../generated/mcp.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../../generated/mcp.ts"],"mappings":";qBAgBa,+CAAG"}
|
package/dist/extensions/mcp.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineMcpPlugin
|
|
1
|
+
import { defineMcpPlugin } from "@agimon-ai/doompi-core/mcpFacet";
|
|
2
|
+
import { defineRoutedContribution } from "@agimon-ai/doompi-core/extensionFile";
|
|
2
3
|
//#endregion
|
|
3
4
|
//#region src/services/mcpTools/index.ts
|
|
4
5
|
const COMPUTER_USE_MCP_TOOLS_SERVICE = "doom/computer-use-mcp-tools";
|
|
@@ -6,7 +7,7 @@ const MODE_LABEL = "Computer Use";
|
|
|
6
7
|
function bindMcpTool(context, name) {
|
|
7
8
|
const catalog = context.services.get(COMPUTER_USE_MCP_TOOLS_SERVICE);
|
|
8
9
|
const tool = catalog?.get(name);
|
|
9
|
-
if (!tool || !catalog)
|
|
10
|
+
if (!tool || !catalog) return void 0;
|
|
10
11
|
return {
|
|
11
12
|
...tool,
|
|
12
13
|
execute(toolCallId, parameters, signal, onUpdate) {
|
|
@@ -21,28 +22,30 @@ function bindMcpTool(context, name) {
|
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
24
|
//#region src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp.ts
|
|
24
|
-
var computer_action_mcp_default =
|
|
25
|
+
var computer_action_mcp_default = defineRoutedContribution((context) => bindMcpTool(context, "computer_action"), { cardinality: "optional" });
|
|
25
26
|
//#endregion
|
|
26
27
|
//#region src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp.ts
|
|
27
|
-
var computer_exec_mcp_default =
|
|
28
|
+
var computer_exec_mcp_default = defineRoutedContribution((context) => bindMcpTool(context, "computer_exec"), { cardinality: "optional" });
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp.ts
|
|
30
|
-
var computer_state_mcp_default =
|
|
31
|
+
var computer_state_mcp_default = defineRoutedContribution((context) => bindMcpTool(context, "computer_state"), { cardinality: "optional" });
|
|
31
32
|
//#endregion
|
|
32
33
|
//#region generated/mcp.ts
|
|
33
34
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
34
|
-
|
|
35
|
+
/* v8 ignore next -- generated normalization branch */
|
|
36
|
+
const defined = (values) => values.filter((value) => value !== void 0);
|
|
37
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
35
38
|
...identity,
|
|
36
39
|
...value
|
|
37
|
-
}
|
|
40
|
+
};
|
|
38
41
|
const mcp = defineMcpPlugin({
|
|
39
42
|
name: "@agimon-ai/doompi-computer-use",
|
|
40
43
|
session: (context) => ({ get tools() {
|
|
41
|
-
return [
|
|
44
|
+
return defined([
|
|
42
45
|
via({ name: "computer_action" }, at(computer_action_mcp_default, context)),
|
|
43
46
|
via({ name: "computer_exec" }, at(computer_exec_mcp_default, context)),
|
|
44
47
|
via({ name: "computer_state" }, at(computer_state_mcp_default, context))
|
|
45
|
-
];
|
|
48
|
+
]);
|
|
46
49
|
} })
|
|
47
50
|
});
|
|
48
51
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.mjs","names":["toolComputerAction","toolComputerExec","toolComputerState"],"sources":["../../src/types/computerUseApi.ts","../../src/services/mcpTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { DoomApiCaller } from '@agimon-ai/doompi-core/packageApi';\n\nexport const API_BASE_PATH = 'computer-use';\nexport const computerUseChannelType = 'computer_use_state';\nexport const COMPUTER_USE_MODE_ID = 'computer-use';\nexport const COMPUTER_USE_STATUS_KEY = 'doom-computer-use';\nexport const COMPUTER_USE_MODE_STATUS_KEY = 'doom-computer-use-mode';\nexport const COMPUTER_USE_MAX_DURATION_MS = 1_800 * 1_000;\nexport const COMPUTER_USE_DEFAULT_DURATION_MS = 300 * 1_000;\nexport const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 2 * 60 * 1_000;\n\n/**\n * Every path this API answers on, below its mount.\n *\n * The typed route table in `./apiRoutes` is built from this, the dispatcher\n * reads that table, and the hub channel addresses the broker with these same\n * strings, so a route cannot move on one side alone.\n */\nexport const COMPUTER_USE_ROUTES = {\n activate: '/activate',\n agentState: '/agent/state',\n agentObserve: '/agent/observe',\n agentAction: '/agent/action',\n agentStop: '/agent/stop',\n hubState: '/hub/state',\n hubActivation: '/hub/activation',\n hubAuthorization: '/hub/authorization',\n hubNext: '/hub/next',\n hubComplete: '/hub/complete',\n hubStop: '/hub/stop',\n} as const;\n\nexport const COMPUTER_USE_WAKE_LIMIT = 1_000_000;\n\nexport interface ComputerUseArtifactView {\n readonly artifactId: string;\n readonly status: 'ready' | 'failed';\n readonly downloadUrl?: string;\n readonly previewUrl?: string;\n readonly actionCount?: number;\n readonly completedAt?: string;\n readonly failure?: { readonly code: string; readonly message: string };\n}\n\nexport interface ComputerUseSessionView {\n readonly sessionId: string;\n readonly revision: number;\n readonly wake: number;\n readonly phase: 'inactive' | 'awaiting_confirmation' | 'activating' | 'active' | 'stopping' | 'failed';\n readonly requestId?: string;\n readonly target?: Record<string, unknown>;\n readonly durationMs?: number;\n readonly expiresAt?: number;\n readonly failure?: { readonly code: string; readonly message: string };\n readonly artifact?: ComputerUseArtifactView;\n}\n\nexport interface ComputerUseActivationRequest {\n readonly requestId: string;\n readonly target: Record<string, unknown>;\n readonly durationSeconds: number;\n readonly createdAt: number;\n readonly confirmationExpiresAt: number;\n readonly caller: DoomApiCaller;\n}\n\nexport interface ComputerUseBrokerRequest {\n readonly id: string;\n readonly operation: 'observe' | 'act';\n readonly payload?: unknown;\n readonly grantId: string;\n readonly sequence?: number;\n}\n\nexport interface ComputerUseChannelPayload {\n readonly state: ComputerUseSessionView;\n readonly targets: readonly Record<string, unknown>[];\n readonly busy?: true;\n}\n\nexport type ComputerUseBrowserCommand = { readonly action: 'status' | 'targets' | 'stop' | 'artifacts' };\n","import type { DoomHeadlessTool } from '@agimon-ai/doompi-core/headless';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { COMPUTER_USE_MODE_ID } from '../../types/computerUseApi';\n\nexport const COMPUTER_USE_MCP_TOOLS_SERVICE = 'doom/computer-use-mcp-tools';\n\nconst MODE_LABEL = 'Computer Use';\n\nexport interface McpToolCatalog {\n get(name: string): DoomHeadlessTool | undefined;\n names(): readonly string[];\n}\n\nexport function mountMcpTools(tools: readonly DoomHeadlessTool[]) {\n return (context: Context): void => {\n context.plugin((providerContext) => {\n providerContext.provide(COMPUTER_USE_MCP_TOOLS_SERVICE, {\n get: (name) => tools.find((tool) => tool.name === name),\n names: () => tools.map((tool) => tool.name),\n } satisfies McpToolCatalog);\n });\n };\n}\n\nexport function bindMcpTool(context: DoomMcpPluginContext, name: string): DoomHeadlessTool {\n const catalog = context.services.get<McpToolCatalog>(COMPUTER_USE_MCP_TOOLS_SERVICE);\n const tool = catalog?.get(name);\n if (!tool || !catalog)
|
|
1
|
+
{"version":3,"file":"mcp.mjs","names":["toolComputerAction","toolComputerExec","toolComputerState"],"sources":["../../src/types/computerUseApi.ts","../../src/services/mcpTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { DoomApiCaller } from '@agimon-ai/doompi-core/packageApi';\n\nexport const API_BASE_PATH = 'computer-use';\nexport const computerUseChannelType = 'computer_use_state';\nexport const COMPUTER_USE_MODE_ID = 'computer-use';\nexport const COMPUTER_USE_STATUS_KEY = 'doom-computer-use';\nexport const COMPUTER_USE_MODE_STATUS_KEY = 'doom-computer-use-mode';\nexport const COMPUTER_USE_MAX_DURATION_MS = 1_800 * 1_000;\nexport const COMPUTER_USE_DEFAULT_DURATION_MS = 300 * 1_000;\nexport const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 2 * 60 * 1_000;\n\n/**\n * Every path this API answers on, below its mount.\n *\n * The typed route table in `./apiRoutes` is built from this, the dispatcher\n * reads that table, and the hub channel addresses the broker with these same\n * strings, so a route cannot move on one side alone.\n */\nexport const COMPUTER_USE_ROUTES = {\n activate: '/activate',\n agentState: '/agent/state',\n agentObserve: '/agent/observe',\n agentAction: '/agent/action',\n agentStop: '/agent/stop',\n hubState: '/hub/state',\n hubActivation: '/hub/activation',\n hubAuthorization: '/hub/authorization',\n hubNext: '/hub/next',\n hubComplete: '/hub/complete',\n hubStop: '/hub/stop',\n} as const;\n\nexport const COMPUTER_USE_WAKE_LIMIT = 1_000_000;\n\nexport interface ComputerUseArtifactView {\n readonly artifactId: string;\n readonly status: 'ready' | 'failed';\n readonly downloadUrl?: string;\n readonly previewUrl?: string;\n readonly actionCount?: number;\n readonly completedAt?: string;\n readonly failure?: { readonly code: string; readonly message: string };\n}\n\nexport interface ComputerUseSessionView {\n readonly sessionId: string;\n readonly revision: number;\n readonly wake: number;\n readonly phase: 'inactive' | 'awaiting_confirmation' | 'activating' | 'active' | 'stopping' | 'failed';\n readonly requestId?: string;\n readonly target?: Record<string, unknown>;\n readonly durationMs?: number;\n readonly expiresAt?: number;\n readonly failure?: { readonly code: string; readonly message: string };\n readonly artifact?: ComputerUseArtifactView;\n}\n\nexport interface ComputerUseActivationRequest {\n readonly requestId: string;\n readonly target: Record<string, unknown>;\n readonly durationSeconds: number;\n readonly createdAt: number;\n readonly confirmationExpiresAt: number;\n readonly caller: DoomApiCaller;\n}\n\nexport interface ComputerUseBrokerRequest {\n readonly id: string;\n readonly operation: 'observe' | 'act';\n readonly payload?: unknown;\n readonly grantId: string;\n readonly sequence?: number;\n}\n\nexport interface ComputerUseChannelPayload {\n readonly state: ComputerUseSessionView;\n readonly targets: readonly Record<string, unknown>[];\n readonly busy?: true;\n}\n\nexport type ComputerUseBrowserCommand = { readonly action: 'status' | 'targets' | 'stop' | 'artifacts' };\n","import type { DoomHeadlessTool } from '@agimon-ai/doompi-core/headless';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { COMPUTER_USE_MODE_ID } from '../../types/computerUseApi';\n\nexport const COMPUTER_USE_MCP_TOOLS_SERVICE = 'doom/computer-use-mcp-tools';\n\nconst MODE_LABEL = 'Computer Use';\n\nexport interface McpToolCatalog {\n get(name: string): DoomHeadlessTool | undefined;\n names(): readonly string[];\n}\n\nexport function mountMcpTools(tools: readonly DoomHeadlessTool[]) {\n return (context: Context): void => {\n context.plugin((providerContext) => {\n providerContext.provide(COMPUTER_USE_MCP_TOOLS_SERVICE, {\n get: (name) => tools.find((tool) => tool.name === name),\n names: () => tools.map((tool) => tool.name),\n } satisfies McpToolCatalog);\n });\n };\n}\n\nexport function bindMcpTool(context: DoomMcpPluginContext, name: string): DoomHeadlessTool | undefined {\n const catalog = context.services.get<McpToolCatalog>(COMPUTER_USE_MCP_TOOLS_SERVICE);\n const tool = catalog?.get(name);\n if (!tool || !catalog) return undefined;\n return {\n ...tool,\n execute(toolCallId, parameters, signal, onUpdate) {\n const activeModes = context.selection.read().state?.['minor-mode'] ?? [];\n if (!activeModes.includes(COMPUTER_USE_MODE_ID)) {\n const inactiveTools = [...catalog.names()].sort().join(', ');\n throw new Error(`${MODE_LABEL} minor mode is inactive. Inactive ${MODE_LABEL} tools: ${inactiveTools}.`);\n }\n const executionSignal = AbortSignal.any([context.signal, signal ?? context.signal]);\n return tool.execute(toolCallId, parameters, executionSignal, onUpdate, context.execution);\n },\n };\n}\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_action'), {\n cardinality: 'optional',\n});\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_exec'), {\n cardinality: 'optional',\n});\n","import { defineRoutedContribution } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineRoutedContribution((context: DoomMcpPluginContext) => bindMcpTool(context, 'computer_state'), {\n cardinality: 'optional',\n});\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineMcpPlugin, type DoomMcpSessionPlugin } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport toolComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/computer_action.mcp';\nimport toolComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/computer_exec.mcp';\nimport toolComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/computer_state.mcp';\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;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/doompi-computer-use',\n session: (context) => ({\n get tools(): DoomMcpSessionPlugin['tools'] { return defined([via({ name: 'computer_action' }, at(toolComputerAction, context)), via({ name: 'computer_exec' }, at(toolComputerExec, context)), via({ name: 'computer_state' }, at(toolComputerState, context))]); },\n }) satisfies DoomMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;ACMA,MAAa,iCAAiC;AAE9C,MAAM,aAAa;AAkBnB,SAAgB,YAAY,SAA+B,MAA4C;CACrG,MAAM,UAAU,QAAQ,SAAS,IAAoB,8BAA8B;CACnF,MAAM,OAAO,SAAS,IAAI,IAAI;CAC9B,IAAI,CAAC,QAAQ,CAAC,SAAS,OAAO,KAAA;CAC9B,OAAO;EACL,GAAG;EACH,QAAQ,YAAY,YAAY,QAAQ,UAAU;GAEhD,IAAI,EADgB,QAAQ,UAAU,KAAK,CAAC,CAAC,QAAQ,iBAAiB,CAAC,EAAA,CACtD,SAAA,cAA6B,GAAG;IAC/C,MAAM,gBAAgB,CAAC,GAAG,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;IAC3D,MAAM,IAAI,MAAM,GAAG,WAAW,oCAAoC,WAAW,UAAU,cAAc,EAAE;GACzG;GACA,MAAM,kBAAkB,YAAY,IAAI,CAAC,QAAQ,QAAQ,UAAU,QAAQ,MAAM,CAAC;GAClF,OAAO,KAAK,QAAQ,YAAY,YAAY,iBAAiB,UAAU,QAAQ,SAAS;EAC1F;CACF;AACF;;;ACrCA,IAAA,8BAAe,0BAA0B,YAAkC,YAAY,SAAS,iBAAiB,GAAG,EAClH,aAAa,WACf,CAAC;;;ACFD,IAAA,4BAAe,0BAA0B,YAAkC,YAAY,SAAS,eAAe,GAAG,EAChH,aAAa,WACf,CAAC;;;ACFD,IAAA,6BAAe,0BAA0B,YAAkC,YAAY,SAAS,gBAAgB,GAAG,EACjH,aAAa,WACf,CAAC;;;ACCD,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;;AAEpE,MAAM,WAAc,WAClB,OAAO,QAAQ,UAAsB,UAAU,KAAA,CAAS;AAC1D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,MAAM,gBAAgB;CACjC,MAAM;CACN,UAAU,aAAa,EACrB,IAAI,QAAuC;EAAE,OAAO,QAAQ;GAAC,IAAI,EAAE,MAAM,kBAAkB,GAAG,GAAGA,6BAAoB,OAAO,CAAC;GAAG,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC;GAAG,IAAI,EAAE,MAAM,iBAAiB,GAAG,GAAGC,4BAAmB,OAAO,CAAC;EAAC,CAAC;CAAG,EACpQ;AACF,CAAC"}
|
package/dist/extensions/pi.cjs
CHANGED
|
@@ -2,9 +2,9 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_extensionService = require("../extensionService-
|
|
6
|
-
const require_dependencies = require("../dependencies-
|
|
7
|
-
const require_computerUseMode = require("../computerUseMode-
|
|
5
|
+
const require_extensionService = require("../extensionService-CZS-zDP0.cjs");
|
|
6
|
+
const require_dependencies = require("../dependencies-Dub2ybTN.cjs");
|
|
7
|
+
const require_computerUseMode = require("../computerUseMode-CHpbP7yo.cjs");
|
|
8
8
|
let _agimon_ai_doompi_core_piExtension = require("@agimon-ai/doompi-core/piExtension");
|
|
9
9
|
let _agimon_ai_doompi_core_extensionFile = require("@agimon-ai/doompi-core/extensionFile");
|
|
10
10
|
let _agimon_ai_doompi_minor_mode = require("@agimon-ai/doompi-minor-mode");
|
|
@@ -167,19 +167,13 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
167
167
|
promptSnippet: "Observe the authorized application before choosing a semantic action",
|
|
168
168
|
parameters: {
|
|
169
169
|
type: "object",
|
|
170
|
-
properties: {},
|
|
170
|
+
properties: { includeScreenshot: { type: "boolean" } },
|
|
171
171
|
additionalProperties: false
|
|
172
172
|
},
|
|
173
173
|
async execute(_toolCallId, _params, signal) {
|
|
174
174
|
if (!globallyEnabled || client === void 0 || state?.phase !== "active") throw new Error("Computer use is not active for this session.");
|
|
175
|
-
const observation = await client.observe(signal);
|
|
176
|
-
return
|
|
177
|
-
content: [{
|
|
178
|
-
type: "text",
|
|
179
|
-
text: JSON.stringify(observation, null, 2)
|
|
180
|
-
}],
|
|
181
|
-
details: observation
|
|
182
|
-
};
|
|
175
|
+
const observation = await client.observe(signal, { includeScreenshot: _params.includeScreenshot !== false });
|
|
176
|
+
return require_computerUseMode.computerObservationOutput(observation);
|
|
183
177
|
}
|
|
184
178
|
},
|
|
185
179
|
{
|
|
@@ -238,13 +232,15 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
238
232
|
{
|
|
239
233
|
name: "computer_exec",
|
|
240
234
|
label: "Computer Script",
|
|
241
|
-
description: "Run a
|
|
242
|
-
promptSnippet: "
|
|
235
|
+
description: "Run a reusable function with the authorized program API. Full Node requires trusted:true and an explicitly allowlisted path.",
|
|
236
|
+
promptSnippet: "Compose small computer functions using fresh semantic observations; request screenshots only when needed",
|
|
243
237
|
parameters: {
|
|
244
238
|
type: "object",
|
|
245
239
|
properties: {
|
|
246
240
|
scriptPath: { type: "string" },
|
|
247
|
-
input: {}
|
|
241
|
+
input: {},
|
|
242
|
+
trusted: { type: "boolean" },
|
|
243
|
+
includeScreenshot: { type: "boolean" }
|
|
248
244
|
},
|
|
249
245
|
required: ["scriptPath", "input"],
|
|
250
246
|
additionalProperties: false
|
|
@@ -253,19 +249,16 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
253
249
|
if (!globallyEnabled || client === void 0 || state?.phase !== "active") throw new Error("Computer use is not active for this session.");
|
|
254
250
|
if (dependencies.scriptRunner === void 0) throw new Error("Computer script execution is unavailable.");
|
|
255
251
|
const input = params;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}],
|
|
262
|
-
details: result
|
|
263
|
-
};
|
|
252
|
+
try {
|
|
253
|
+
return require_computerUseMode.computerScriptOutput(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal, input));
|
|
254
|
+
} catch (error) {
|
|
255
|
+
return require_computerUseMode.computerScriptFailure(error);
|
|
256
|
+
}
|
|
264
257
|
}
|
|
265
258
|
}
|
|
266
259
|
],
|
|
267
260
|
services: [(0, _agimon_ai_doompi_minor_mode.piMinorModes)({
|
|
268
|
-
snapshot: () => globallyEnabled ? [mode] : [],
|
|
261
|
+
snapshot: () => globallyEnabled && client !== void 0 ? [mode] : [],
|
|
269
262
|
subscribe(listener) {
|
|
270
263
|
modeListeners.add(listener);
|
|
271
264
|
return () => {
|
|
@@ -289,6 +282,10 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
289
282
|
if (signal.aborted) return;
|
|
290
283
|
activeContext = context;
|
|
291
284
|
reconcileTools(false);
|
|
285
|
+
if (client === void 0) {
|
|
286
|
+
publish();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
292
289
|
refresh();
|
|
293
290
|
if (timer) clearInterval(timer);
|
|
294
291
|
timer = setInterval(() => void refresh(), 250);
|
|
@@ -347,10 +344,10 @@ var _20_computer_exec_cli_default = (0, _agimon_ai_doompi_core_extensionFile.def
|
|
|
347
344
|
//#endregion
|
|
348
345
|
//#region generated/pi.ts
|
|
349
346
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
350
|
-
const via = (identity, value) =>
|
|
347
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
351
348
|
...identity,
|
|
352
349
|
...value
|
|
353
|
-
}
|
|
350
|
+
};
|
|
354
351
|
const extension = (0, _agimon_ai_doompi_core_piExtension.definePiExtension)("@agimon-ai/doompi-computer-use", async (context) => {
|
|
355
352
|
const scopeSession = await root_cli_default(context);
|
|
356
353
|
const contextSession = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.cjs","names":["COMMAND_NAME","COMMAND_DESCRIPTION","computerUseRestriction","COMPUTER_USE_MODE_STATUS_KEY","COMPUTER_USE_STATUS_KEY","defineMinorMode","COMPUTER_USE_MODE_ID","modeState","piMinorModes","COMPUTER_USE_GUIDANCE","createComputerUseDependencies","defineRoot","runtime","defineCliCommand","defineCliHook","defineCliHook","defineToolRestriction","defineCliTool","defineCliTool","defineCliTool","definePiExtension","rootSession","composeRootHooks","commandComputerUse","hookBeforeAgentStart","hookSessionStart","toolRestrictionComputerUse","piToolContributions","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../src/services/computerUseCommand/index.ts","../../src/services/computerUseRuntime/index.ts","../../src/extensions/workspaces/sessions/(backend)/_runtime/index.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/command/computer-use.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.cli.ts","../../generated/pi.ts"],"sourcesContent":["// @scaffold-generated\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport type { ComputerUseExtensionService } from '../../types/extension';\n\nexport function createComputerUseCommand(\n service: ComputerUseExtensionService,\n): Parameters<ExtensionAPI['registerCommand']> {\n return [\n COMMAND_NAME,\n {\n description: COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => {\n const result = await service.execute();\n if (ctx.hasUI) ctx.ui.notify(result.message, result.level);\n },\n },\n ];\n}\n\nexport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\n","import { type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { type DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { piMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner, type MinorModeOwnerActionContext } from '@agimon-ai/doompi-minor-mode';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { COMPUTER_USE_GUIDANCE } from '../../constants/computerUse';\nimport type { ComputerUseAction } from '../../types/computerUse';\nimport {\n COMPUTER_USE_MODE_ID,\n COMPUTER_USE_MODE_STATUS_KEY,\n COMPUTER_USE_STATUS_KEY,\n type ComputerUseSessionView,\n} from '../../types/computerUseApi';\nimport type { ComputerUseExtensionDependencies } from '../../types/extension';\nimport { createComputerUseCommand } from '../computerUseCommand';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-computer-use';\nexport { COMPUTER_USE_MODE_ID };\nimport { modeState, computerUseRestriction } from '../../models/computerUseMode';\n\nexport function createComputerUseRuntime(\n dependencies: ComputerUseExtensionDependencies,\n signal: AbortSignal,\n): PiPluginContributions<ComputerUseExtensionDependencies> & {\n tools: readonly Parameters<ExtensionAPI['registerTool']>[0][];\n} {\n const client = dependencies.client;\n let state: ComputerUseSessionView | undefined;\n let enabled = false;\n let restriction: DoomToolRestriction = computerUseRestriction(false);\n const restrictionListeners = new Set<() => void>();\n const reconcileTools = (active: boolean): void => {\n restriction = computerUseRestriction(active);\n for (const listener of restrictionListeners) listener();\n };\n let globallyEnabled = false;\n let mode: MinorModeOwner<MinorModeOwnerActionContext<ExtensionContext>>;\n const modeListeners = new Set<() => void>();\n let timer: ReturnType<typeof setInterval> | undefined;\n let activeContext: ExtensionContext | undefined;\n let publishedMode = '';\n let publishedModeStatus: string | undefined;\n let publishedActivityStatus: string | undefined;\n const publish = (): void => {\n const phase = state?.phase ?? 'inactive';\n const projection = `${enabled}:${phase}:${state?.revision ?? 'none'}`;\n if (mode !== undefined && projection !== publishedMode) {\n mode.publish();\n publishedMode = projection;\n }\n const modeStatus = state === undefined ? undefined : enabled || phase !== 'inactive' ? phase : '';\n if (activeContext !== undefined && modeStatus !== publishedModeStatus) {\n activeContext.ui.setStatus(COMPUTER_USE_MODE_STATUS_KEY, modeStatus);\n publishedModeStatus = modeStatus;\n }\n const activityStatus = enabled || phase !== 'inactive' ? `computer use: ${phase}` : undefined;\n if (activeContext !== undefined && activityStatus !== publishedActivityStatus) {\n activeContext.ui.setStatus(COMPUTER_USE_STATUS_KEY, activityStatus);\n publishedActivityStatus = activityStatus;\n }\n };\n const refresh = async (): Promise<void> => {\n if (signal.aborted) return;\n let nextGloballyEnabled = false;\n try {\n nextGloballyEnabled = (await dependencies.enabled?.()) === true;\n } catch {\n nextGloballyEnabled = false;\n }\n if (signal.aborted) return;\n if (nextGloballyEnabled !== globallyEnabled) {\n globallyEnabled = nextGloballyEnabled;\n if (!globallyEnabled) {\n if (client !== undefined && state !== undefined && state.phase !== 'inactive' && state.phase !== 'failed') {\n try {\n await client.stop();\n } catch {\n // The global opt-in is still authoritative even when remote cleanup fails.\n }\n }\n enabled = false;\n state = undefined;\n reconcileTools(false);\n }\n publishedMode = '';\n for (const listener of modeListeners) listener();\n }\n if (!globallyEnabled || client === undefined) {\n state = undefined;\n reconcileTools(false);\n publish();\n return;\n }\n try {\n const nextState = await client.state(signal);\n if (signal.aborted) return;\n state = nextState;\n reconcileTools(state.phase === 'active');\n publish();\n } catch {\n state = undefined;\n reconcileTools(false);\n publish();\n }\n };\n mode = defineMinorMode<undefined, MinorModeOwnerActionContext<ExtensionContext>>({\n descriptor: {\n source: PACKAGE_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: 'Open the cockpit activation workflow and native confirmation.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, enabled),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n activeContext = execution.context;\n if (actionId === 'activate') {\n if ((await dependencies.enabled?.()) !== true) {\n await refresh();\n throw new Error('Enable computer use in global settings first.');\n }\n if (client === undefined) throw new Error('DoomPi Desktop computer use is unavailable.');\n enabled = true;\n await refresh();\n publish();\n return { message: 'Computer use is ready to configure in Activity.' };\n }\n if (actionId === 'doctor') {\n await refresh();\n return {\n message:\n client === undefined\n ? 'DoomPi Desktop session API is unavailable.'\n : `Computer use is ${state?.phase.replaceAll('_', ' ') ?? 'unavailable'}.`,\n };\n }\n if (actionId === 'deactivate') {\n if (client === undefined) throw new Error('DoomPi Desktop computer use is unavailable.');\n if (state !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n enabled = false;\n await refresh();\n publish();\n return { message: 'Computer use is off.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n commands: [createComputerUseCommand(dependencies.service)],\n tools: [\n {\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return its semantic accessibility state.',\n promptSnippet: 'Observe the authorized application before choosing a semantic action',\n parameters: { type: 'object', properties: {}, additionalProperties: false },\n async execute(_toolCallId, _params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n const observation = await client.observe(signal);\n return { content: [{ type: 'text', text: JSON.stringify(observation, null, 2) }], details: observation };\n },\n },\n {\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n promptSnippet: 'Perform one action using a current computer_state snapshot and element ref',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string' },\n elementRef: { type: 'string' },\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 async execute(_toolCallId, params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n const result = await client.act(params as unknown as ComputerUseAction, signal);\n return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], details: result };\n },\n },\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 promptSnippet: 'Run a trusted reusable computer script by its explicitly allowed path and JSON input',\n parameters: {\n type: 'object',\n properties: {\n scriptPath: { type: 'string' },\n input: {},\n },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n async execute(_toolCallId, params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n if (dependencies.scriptRunner === undefined) throw new Error('Computer script execution is unavailable.');\n const input = params as { scriptPath: string; input: unknown };\n const result = await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal);\n return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], details: result };\n },\n },\n ],\n services: [\n piMinorModes({\n snapshot: () => (globallyEnabled ? [mode] : []),\n subscribe(listener) {\n modeListeners.add(listener);\n return () => {\n modeListeners.delete(listener);\n };\n },\n }),\n ],\n toolRestrictions: [\n {\n source: PACKAGE_SOURCE,\n restrict: (incoming, available) => restriction(incoming, available),\n subscribe(listener) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n },\n ],\n events: {\n before_agent_start: (event) =>\n globallyEnabled && state?.phase === 'active'\n ? { systemPrompt: `${event.systemPrompt}\\n\\n${COMPUTER_USE_GUIDANCE}` }\n : undefined,\n session_start: (_event, context) => {\n if (signal.aborted) return;\n activeContext = context;\n reconcileTools(false);\n void refresh();\n if (timer) clearInterval(timer);\n timer = setInterval(() => void refresh(), 250);\n timer.unref?.();\n },\n },\n onStop() {\n if (timer) clearInterval(timer);\n timer = undefined;\n },\n onDispose() {\n if (timer) clearInterval(timer);\n timer = undefined;\n reconcileTools(false);\n activeContext?.ui.setStatus(COMPUTER_USE_MODE_STATUS_KEY, undefined);\n activeContext?.ui.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n activeContext = undefined;\n },\n };\n}\n","import type { PiPluginContext, PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createComputerUseRuntime } from '../../../../../services/computerUseRuntime';\nimport { createComputerUseDependencies } from '../../../../../services/dependencies';\nimport type { ComputerUseExtensionDependencies } from '../../../../../types/extension';\n\nexport default (({ options, signal }) =>\n createComputerUseRuntime(options ?? createComputerUseDependencies(), signal)) satisfies (\n context: PiPluginContext<ComputerUseExtensionDependencies>,\n) => PiPluginContributions<ComputerUseExtensionDependencies>;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport runtime from './_runtime/index.cli';\n\nexport default defineRoot((context: Parameters<typeof runtime>[0]) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineCliCommand, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliCommand((context: Context) => context.root.commands![0]!);\n","import { defineCliHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliHook((context: Context) => context.root.events!['before_agent_start']!);\n","import { defineCliHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliHook((context: Context) => context.root.events!['session_start']!);\n","import { defineToolRestriction, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineToolRestriction((context: Context) => context.root.toolRestrictions![0]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![0]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![1]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![2]!);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport toolRestrictionComputerUse from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.cli';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.cli';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.cli';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof commandComputerUse> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof toolRestrictionComputerUse> | OptionsOf<typeof tool00ComputerState> | OptionsOf<typeof tool10ComputerAction> | OptionsOf<typeof tool20ComputerExec>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\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 extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-computer-use', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PiPluginContributions['commands'] { return [at(commandComputerUse, contextSession)]; },\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionComputerUse, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-computer-use', [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 };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,yBACd,SAC6C;CAC7C,OAAO,CACLA,yBAAAA,cACA;EACE,aAAaC,yBAAAA;EACb,SAAS,OAAO,OAAO,QAAQ;GAC7B,MAAM,SAAS,MAAM,QAAQ,QAAQ;GACrC,IAAI,IAAI,OAAO,IAAI,GAAG,OAAO,OAAO,SAAS,OAAO,KAAK;EAC3D;CACF,CACF;AACF;;;ACFA,MAAM,iBAAiB;AAIvB,SAAgB,yBACd,cACA,QAGA;CACA,MAAM,SAAS,aAAa;CAC5B,IAAI;CACJ,IAAI,UAAU;CACd,IAAI,cAAmCC,wBAAAA,uBAAuB,KAAK;CACnE,MAAM,uCAAuB,IAAI,IAAgB;CACjD,MAAM,kBAAkB,WAA0B;EAChD,cAAcA,wBAAAA,uBAAuB,MAAM;EAC3C,KAAK,MAAM,YAAY,sBAAsB,SAAS;CACxD;CACA,IAAI,kBAAkB;CACtB,IAAI;CACJ,MAAM,gCAAgB,IAAI,IAAgB;CAC1C,IAAI;CACJ,IAAI;CACJ,IAAI,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S_KEY","COMPUTER_USE_STATUS_KEY","defineMinorMode","COMPUTER_USE_MODE_ID","modeState","computerObservationOutput","computerScriptOutput","computerScriptFailure","piMinorModes","COMPUTER_USE_GUIDANCE","createComputerUseDependencies","defineRoot","runtime","defineCliCommand","defineCliHook","defineCliHook","defineToolRestriction","defineCliTool","defineCliTool","defineCliTool","definePiExtension","rootSession","composeRootHooks","commandComputerUse","hookBeforeAgentStart","hookSessionStart","toolRestrictionComputerUse","piToolContributions","tool00ComputerState","tool10ComputerAction","tool20ComputerExec"],"sources":["../../src/services/computerUseCommand/index.ts","../../src/services/computerUseRuntime/index.ts","../../src/extensions/workspaces/sessions/(backend)/_runtime/index.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/command/computer-use.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.cli.ts","../../generated/pi.ts"],"sourcesContent":["// @scaffold-generated\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\nimport type { ComputerUseExtensionService } from '../../types/extension';\n\nexport function createComputerUseCommand(\n service: ComputerUseExtensionService,\n): Parameters<ExtensionAPI['registerCommand']> {\n return [\n COMMAND_NAME,\n {\n description: COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => {\n const result = await service.execute();\n if (ctx.hasUI) ctx.ui.notify(result.message, result.level);\n },\n },\n ];\n}\n\nexport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../constants/computerUse';\n","import { type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { type DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { piMinorModes } from '@agimon-ai/doompi-minor-mode';\nimport { defineMinorMode, type MinorModeOwner, type MinorModeOwnerActionContext } from '@agimon-ai/doompi-minor-mode';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { COMPUTER_USE_GUIDANCE } from '../../constants/computerUse';\nimport type { ComputerScriptExecutionOptions } from '../../types/computerScript';\nimport type { ComputerUseAction } from '../../types/computerUse';\nimport {\n COMPUTER_USE_MODE_ID,\n COMPUTER_USE_MODE_STATUS_KEY,\n COMPUTER_USE_STATUS_KEY,\n type ComputerUseSessionView,\n} from '../../types/computerUseApi';\nimport type { ComputerUseExtensionDependencies } from '../../types/extension';\nimport { computerObservationOutput, computerScriptOutput, computerScriptFailure } from '../computerToolOutput';\nimport { createComputerUseCommand } from '../computerUseCommand';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-computer-use';\nexport { COMPUTER_USE_MODE_ID };\nimport { modeState, computerUseRestriction } from '../../models/computerUseMode';\n\nexport function createComputerUseRuntime(\n dependencies: ComputerUseExtensionDependencies,\n signal: AbortSignal,\n): PiPluginContributions<ComputerUseExtensionDependencies> & {\n tools: readonly Parameters<ExtensionAPI['registerTool']>[0][];\n} {\n const client = dependencies.client;\n let state: ComputerUseSessionView | undefined;\n let enabled = false;\n let restriction: DoomToolRestriction = computerUseRestriction(false);\n const restrictionListeners = new Set<() => void>();\n const reconcileTools = (active: boolean): void => {\n restriction = computerUseRestriction(active);\n for (const listener of restrictionListeners) listener();\n };\n let globallyEnabled = false;\n let mode: MinorModeOwner<MinorModeOwnerActionContext<ExtensionContext>>;\n const modeListeners = new Set<() => void>();\n let timer: ReturnType<typeof setInterval> | undefined;\n let activeContext: ExtensionContext | undefined;\n let publishedMode = '';\n let publishedModeStatus: string | undefined;\n let publishedActivityStatus: string | undefined;\n const publish = (): void => {\n const phase = state?.phase ?? 'inactive';\n const projection = `${enabled}:${phase}:${state?.revision ?? 'none'}`;\n if (mode !== undefined && projection !== publishedMode) {\n mode.publish();\n publishedMode = projection;\n }\n const modeStatus = state === undefined ? undefined : enabled || phase !== 'inactive' ? phase : '';\n if (activeContext !== undefined && modeStatus !== publishedModeStatus) {\n activeContext.ui.setStatus(COMPUTER_USE_MODE_STATUS_KEY, modeStatus);\n publishedModeStatus = modeStatus;\n }\n const activityStatus = enabled || phase !== 'inactive' ? `computer use: ${phase}` : undefined;\n if (activeContext !== undefined && activityStatus !== publishedActivityStatus) {\n activeContext.ui.setStatus(COMPUTER_USE_STATUS_KEY, activityStatus);\n publishedActivityStatus = activityStatus;\n }\n };\n const refresh = async (): Promise<void> => {\n if (signal.aborted) return;\n let nextGloballyEnabled = false;\n try {\n nextGloballyEnabled = (await dependencies.enabled?.()) === true;\n } catch {\n nextGloballyEnabled = false;\n }\n if (signal.aborted) return;\n if (nextGloballyEnabled !== globallyEnabled) {\n globallyEnabled = nextGloballyEnabled;\n if (!globallyEnabled) {\n if (client !== undefined && state !== undefined && state.phase !== 'inactive' && state.phase !== 'failed') {\n try {\n await client.stop();\n } catch {\n // The global opt-in is still authoritative even when remote cleanup fails.\n }\n }\n enabled = false;\n state = undefined;\n reconcileTools(false);\n }\n publishedMode = '';\n for (const listener of modeListeners) listener();\n }\n if (!globallyEnabled || client === undefined) {\n state = undefined;\n reconcileTools(false);\n publish();\n return;\n }\n try {\n const nextState = await client.state(signal);\n if (signal.aborted) return;\n state = nextState;\n reconcileTools(state.phase === 'active');\n publish();\n } catch {\n state = undefined;\n reconcileTools(false);\n publish();\n }\n };\n mode = defineMinorMode<undefined, MinorModeOwnerActionContext<ExtensionContext>>({\n descriptor: {\n source: PACKAGE_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: 'Open the cockpit activation workflow and native confirmation.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Stop this session computer-use run.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n {\n id: 'doctor',\n label: 'Doctor',\n description: 'Report Desktop availability and session state.',\n contexts: ['tui', 'headless'],\n parameters: [],\n },\n ],\n },\n state: () => modeState(state, enabled),\n async handleAction(_runtime, actionId, _argumentsValue, execution) {\n activeContext = execution.context;\n if (actionId === 'activate') {\n if ((await dependencies.enabled?.()) !== true) {\n await refresh();\n throw new Error('Enable computer use in global settings first.');\n }\n if (client === undefined) throw new Error('DoomPi Desktop computer use is unavailable.');\n enabled = true;\n await refresh();\n publish();\n return { message: 'Computer use is ready to configure in Activity.' };\n }\n if (actionId === 'doctor') {\n await refresh();\n return {\n message:\n client === undefined\n ? 'DoomPi Desktop session API is unavailable.'\n : `Computer use is ${state?.phase.replaceAll('_', ' ') ?? 'unavailable'}.`,\n };\n }\n if (actionId === 'deactivate') {\n if (client === undefined) throw new Error('DoomPi Desktop computer use is unavailable.');\n if (state !== undefined && state.phase !== 'inactive' && state.phase !== 'failed')\n await client.stop(execution.signal);\n enabled = false;\n await refresh();\n publish();\n return { message: 'Computer use is off.' };\n }\n throw new Error(`Unknown computer-use action: ${actionId}`);\n },\n }).createOwner(undefined);\n return {\n commands: [createComputerUseCommand(dependencies.service)],\n tools: [\n {\n name: 'computer_state',\n label: 'Computer State',\n description: 'Observe the authorized application window and return its semantic accessibility state.',\n promptSnippet: 'Observe the authorized application before choosing a semantic action',\n parameters: {\n type: 'object',\n properties: { includeScreenshot: { type: 'boolean' } },\n additionalProperties: false,\n },\n async execute(_toolCallId, _params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n const observation = await client.observe(signal, {\n includeScreenshot: (_params as { includeScreenshot?: boolean }).includeScreenshot !== false,\n });\n return computerObservationOutput(observation);\n },\n },\n {\n name: 'computer_action',\n label: 'Computer Action',\n description: 'Perform one constrained semantic action in the authorized application window.',\n promptSnippet: 'Perform one action using a current computer_state snapshot and element ref',\n parameters: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['press', 'focus', 'set_value', 'scroll'] },\n snapshotId: { type: 'string' },\n elementRef: { type: 'string' },\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 async execute(_toolCallId, params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n const result = await client.act(params as unknown as ComputerUseAction, signal);\n return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], details: result };\n },\n },\n {\n name: 'computer_exec',\n label: 'Computer Script',\n description:\n 'Run a reusable function with the authorized program API. Full Node requires trusted:true and an explicitly allowlisted path.',\n promptSnippet:\n 'Compose small computer functions using fresh semantic observations; request screenshots only when needed',\n parameters: {\n type: 'object',\n properties: {\n scriptPath: { type: 'string' },\n input: {},\n trusted: { type: 'boolean' },\n includeScreenshot: { type: 'boolean' },\n },\n required: ['scriptPath', 'input'],\n additionalProperties: false,\n },\n async execute(_toolCallId, params, signal) {\n if (!globallyEnabled || client === undefined || state?.phase !== 'active')\n throw new Error('Computer use is not active for this session.');\n if (dependencies.scriptRunner === undefined) throw new Error('Computer script execution is unavailable.');\n const input = params as { scriptPath: string; input: unknown } & ComputerScriptExecutionOptions;\n try {\n return computerScriptOutput(\n await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal, input),\n );\n } catch (error) {\n return computerScriptFailure(error);\n }\n },\n },\n ],\n services: [\n piMinorModes({\n snapshot: () => (globallyEnabled && client !== undefined ? [mode] : []),\n subscribe(listener) {\n modeListeners.add(listener);\n return () => {\n modeListeners.delete(listener);\n };\n },\n }),\n ],\n toolRestrictions: [\n {\n source: PACKAGE_SOURCE,\n restrict: (incoming, available) => restriction(incoming, available),\n subscribe(listener) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n },\n ],\n events: {\n before_agent_start: (event) =>\n globallyEnabled && state?.phase === 'active'\n ? { systemPrompt: `${event.systemPrompt}\\n\\n${COMPUTER_USE_GUIDANCE}` }\n : undefined,\n session_start: (_event, context) => {\n if (signal.aborted) return;\n activeContext = context;\n reconcileTools(false);\n if (client === undefined) {\n publish();\n return;\n }\n void refresh();\n if (timer) clearInterval(timer);\n timer = setInterval(() => void refresh(), 250);\n timer.unref?.();\n },\n },\n onStop() {\n if (timer) clearInterval(timer);\n timer = undefined;\n },\n onDispose() {\n if (timer) clearInterval(timer);\n timer = undefined;\n reconcileTools(false);\n activeContext?.ui.setStatus(COMPUTER_USE_MODE_STATUS_KEY, undefined);\n activeContext?.ui.setStatus(COMPUTER_USE_STATUS_KEY, undefined);\n activeContext = undefined;\n },\n };\n}\n","import type { PiPluginContext, PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createComputerUseRuntime } from '../../../../../services/computerUseRuntime';\nimport { createComputerUseDependencies } from '../../../../../services/dependencies';\nimport type { ComputerUseExtensionDependencies } from '../../../../../types/extension';\n\nexport default (({ options, signal }) =>\n createComputerUseRuntime(options ?? createComputerUseDependencies(), signal)) satisfies (\n context: PiPluginContext<ComputerUseExtensionDependencies>,\n) => PiPluginContributions<ComputerUseExtensionDependencies>;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport runtime from './_runtime/index.cli';\n\nexport default defineRoot((context: Parameters<typeof runtime>[0]) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineCliCommand, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliCommand((context: Context) => context.root.commands![0]!);\n","import { defineCliHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliHook((context: Context) => context.root.events!['before_agent_start']!);\n","import { defineCliHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliHook((context: Context) => context.root.events!['session_start']!);\n","import { defineToolRestriction, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineToolRestriction((context: Context) => context.root.toolRestrictions![0]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![0]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![1]!);\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiToolContribution } from '@agimon-ai/doompi-core/piExtension';\ntype Runtime = Awaited<ReturnType<typeof import('../root.cli').default>>['value'];\n\ntype Context = WithRoot<unknown, Runtime>;\nexport default defineCliTool((context: Context): PiToolContribution => context.root.tools![2]!);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport commandComputerUse from '../src/extensions/workspaces/sessions/(backend)/command/computer-use.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport toolRestrictionComputerUse from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/computer-use.cli';\nimport tool00ComputerState from '../src/extensions/workspaces/sessions/(backend)/tool/00-computer-state.cli';\nimport tool10ComputerAction from '../src/extensions/workspaces/sessions/(backend)/tool/10-computer-action.cli';\nimport tool20ComputerExec from '../src/extensions/workspaces/sessions/(backend)/tool/20-computer-exec.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof commandComputerUse> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof toolRestrictionComputerUse> | OptionsOf<typeof tool00ComputerState> | OptionsOf<typeof tool10ComputerAction> | OptionsOf<typeof tool20ComputerExec>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\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 =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-computer-use', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PiPluginContributions['commands'] { return [at(commandComputerUse, contextSession)]; },\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionComputerUse, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-computer-use', [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 };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,yBACd,SAC6C;CAC7C,OAAO,CACLA,yBAAAA,cACA;EACE,aAAaC,yBAAAA;EACb,SAAS,OAAO,OAAO,QAAQ;GAC7B,MAAM,SAAS,MAAM,QAAQ,QAAQ;GACrC,IAAI,IAAI,OAAO,IAAI,GAAG,OAAO,OAAO,SAAS,OAAO,KAAK;EAC3D;CACF,CACF;AACF;;;ACAA,MAAM,iBAAiB;AAIvB,SAAgB,yBACd,cACA,QAGA;CACA,MAAM,SAAS,aAAa;CAC5B,IAAI;CACJ,IAAI,UAAU;CACd,IAAI,cAAmCC,wBAAAA,uBAAuB,KAAK;CACnE,MAAM,uCAAuB,IAAI,IAAgB;CACjD,MAAM,kBAAkB,WAA0B;EAChD,cAAcA,wBAAAA,uBAAuB,MAAM;EAC3C,KAAK,MAAM,YAAY,sBAAsB,SAAS;CACxD;CACA,IAAI,kBAAkB;CACtB,IAAI;CACJ,MAAM,gCAAgB,IAAI,IAAgB;CAC1C,IAAI;CACJ,IAAI;CACJ,IAAI,gBAAgB;CACpB,IAAI;CACJ,IAAI;CACJ,MAAM,gBAAsB;EAC1B,MAAM,QAAQ,OAAO,SAAS;EAC9B,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,YAAY;EAC7D,IAAI,SAAS,KA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cAAAA,EAAe,YAAyC,QAAQ,KAAK,MAAO,EAAG;;;ACA9F,IAAA,iCAAA,GAAeC,qCAAAA,cAAAA,EAAe,YAAyC,QAAQ,KAAK,MAAO,EAAG;;;ACe9F,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,aAAA,GAAYC,mCAAAA,kBAAAA,CAAoC,kCAAkC,OAAO,YAAY;CAChH,MAAM,eAAe,MAAMC,iBAAY,OAAO;CAC9C,MAAM,iBAAiB;EAAE,GAAG;EAAS,MAAM,aAAa;CAAM;CAC9D,OAAO;EACL,IAAA,GAAGC,qCAAAA,iBAAAA,CAAiB,YAAY;EAChC,IAAI,WAA8C;GAAE,OAAO,CAAC,GAAGC,4BAAoB,cAAc,CAAC;EAAG;EACrG,QAAQ;GACN,oBAAoB,GAAGC,gCAAsB,cAAc;GAC3D,eAAe,GAAGC,2BAAkB,cAAc;EACpD;EACA,IAAI,mBAA8D;GAAE,OAAO,CAAC,GAAGC,0BAA4B,cAAc,CAAC;EAAG;EAC7H,IAAA,GAAGC,mCAAAA,oBAAAA,CAAoB,kCAAkC;GAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,gCAAqB,cAAc,CAAC;GAAG,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAGC,iCAAsB,cAAc,CAAC;GAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,+BAAoB,cAAc,CAAC;EAAC,CAAC;EAChS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;CAC7C;AACF,CAAC"}
|
package/dist/extensions/pi.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ComputerUseExtensionDependencies } from "../index-
|
|
1
|
+
import { c as ComputerUseExtensionDependencies } from "../index-0S6V4EU9.mjs";
|
|
2
2
|
//#region generated/pi.d.ts
|
|
3
3
|
export declare const extension: import("@agimon-ai/doompi-core/runtimePiExtension").DefinedPiExtension<ComputerUseExtensionDependencies>;
|
|
4
4
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.mts","names":[],"sources":["../../generated/pi.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"pi.d.mts","names":[],"sources":["../../generated/pi.ts"],"mappings":";;qBAyBa,+DAAS,mBAAT"}
|
package/dist/extensions/pi.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as COMMAND_NAME, i as COMMAND_DESCRIPTION, o as COMPUTER_USE_GUIDANCE } from "../extensionService-
|
|
2
|
-
import { n as createComputerUseDependencies } from "../dependencies-
|
|
3
|
-
import {
|
|
1
|
+
import { a as COMMAND_NAME, i as COMMAND_DESCRIPTION, o as COMPUTER_USE_GUIDANCE } from "../extensionService-BJXeNc4R.mjs";
|
|
2
|
+
import { n as createComputerUseDependencies } from "../dependencies-Y1TS7gGv.mjs";
|
|
3
|
+
import { a as computerScriptOutput, f as COMPUTER_USE_STATUS_KEY, i as computerScriptFailure, l as COMPUTER_USE_MODE_ID, n as modeState, r as computerObservationOutput, t as computerUseRestriction, u as COMPUTER_USE_MODE_STATUS_KEY } from "../computerUseMode-DTXNRobA.mjs";
|
|
4
4
|
import { definePiExtension, piToolContributions } from "@agimon-ai/doompi-core/piExtension";
|
|
5
5
|
import { composeRootHooks, defineCliCommand, defineCliHook, defineCliTool, defineRoot, defineToolRestriction } from "@agimon-ai/doompi-core/extensionFile";
|
|
6
6
|
import { defineMinorMode, piMinorModes } from "@agimon-ai/doompi-minor-mode";
|
|
@@ -163,19 +163,13 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
163
163
|
promptSnippet: "Observe the authorized application before choosing a semantic action",
|
|
164
164
|
parameters: {
|
|
165
165
|
type: "object",
|
|
166
|
-
properties: {},
|
|
166
|
+
properties: { includeScreenshot: { type: "boolean" } },
|
|
167
167
|
additionalProperties: false
|
|
168
168
|
},
|
|
169
169
|
async execute(_toolCallId, _params, signal) {
|
|
170
170
|
if (!globallyEnabled || client === void 0 || state?.phase !== "active") throw new Error("Computer use is not active for this session.");
|
|
171
|
-
const observation = await client.observe(signal);
|
|
172
|
-
return
|
|
173
|
-
content: [{
|
|
174
|
-
type: "text",
|
|
175
|
-
text: JSON.stringify(observation, null, 2)
|
|
176
|
-
}],
|
|
177
|
-
details: observation
|
|
178
|
-
};
|
|
171
|
+
const observation = await client.observe(signal, { includeScreenshot: _params.includeScreenshot !== false });
|
|
172
|
+
return computerObservationOutput(observation);
|
|
179
173
|
}
|
|
180
174
|
},
|
|
181
175
|
{
|
|
@@ -234,13 +228,15 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
234
228
|
{
|
|
235
229
|
name: "computer_exec",
|
|
236
230
|
label: "Computer Script",
|
|
237
|
-
description: "Run a
|
|
238
|
-
promptSnippet: "
|
|
231
|
+
description: "Run a reusable function with the authorized program API. Full Node requires trusted:true and an explicitly allowlisted path.",
|
|
232
|
+
promptSnippet: "Compose small computer functions using fresh semantic observations; request screenshots only when needed",
|
|
239
233
|
parameters: {
|
|
240
234
|
type: "object",
|
|
241
235
|
properties: {
|
|
242
236
|
scriptPath: { type: "string" },
|
|
243
|
-
input: {}
|
|
237
|
+
input: {},
|
|
238
|
+
trusted: { type: "boolean" },
|
|
239
|
+
includeScreenshot: { type: "boolean" }
|
|
244
240
|
},
|
|
245
241
|
required: ["scriptPath", "input"],
|
|
246
242
|
additionalProperties: false
|
|
@@ -249,19 +245,16 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
249
245
|
if (!globallyEnabled || client === void 0 || state?.phase !== "active") throw new Error("Computer use is not active for this session.");
|
|
250
246
|
if (dependencies.scriptRunner === void 0) throw new Error("Computer script execution is unavailable.");
|
|
251
247
|
const input = params;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}],
|
|
258
|
-
details: result
|
|
259
|
-
};
|
|
248
|
+
try {
|
|
249
|
+
return computerScriptOutput(await dependencies.scriptRunner.execute(input.scriptPath, input.input, signal, input));
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return computerScriptFailure(error);
|
|
252
|
+
}
|
|
260
253
|
}
|
|
261
254
|
}
|
|
262
255
|
],
|
|
263
256
|
services: [piMinorModes({
|
|
264
|
-
snapshot: () => globallyEnabled ? [mode] : [],
|
|
257
|
+
snapshot: () => globallyEnabled && client !== void 0 ? [mode] : [],
|
|
265
258
|
subscribe(listener) {
|
|
266
259
|
modeListeners.add(listener);
|
|
267
260
|
return () => {
|
|
@@ -285,6 +278,10 @@ function createComputerUseRuntime(dependencies, signal) {
|
|
|
285
278
|
if (signal.aborted) return;
|
|
286
279
|
activeContext = context;
|
|
287
280
|
reconcileTools(false);
|
|
281
|
+
if (client === void 0) {
|
|
282
|
+
publish();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
288
285
|
refresh();
|
|
289
286
|
if (timer) clearInterval(timer);
|
|
290
287
|
timer = setInterval(() => void refresh(), 250);
|
|
@@ -343,10 +340,10 @@ var _20_computer_exec_cli_default = defineCliTool((context) => context.root.tool
|
|
|
343
340
|
//#endregion
|
|
344
341
|
//#region generated/pi.ts
|
|
345
342
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
346
|
-
const via = (identity, value) =>
|
|
343
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
347
344
|
...identity,
|
|
348
345
|
...value
|
|
349
|
-
}
|
|
346
|
+
};
|
|
350
347
|
const extension = definePiExtension("@agimon-ai/doompi-computer-use", async (context) => {
|
|
351
348
|
const scopeSession = await root_cli_default(context);
|
|
352
349
|
const contextSession = {
|