codex-computer-use-mcp 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/ARCHITECTURE.md +134 -0
  2. package/CONTRIBUTING.md +16 -10
  3. package/MIGRATION.md +77 -0
  4. package/PROOF.md +114 -67
  5. package/README.md +94 -116
  6. package/SECURITY.md +43 -22
  7. package/dist/audit.d.ts +15 -14
  8. package/dist/audit.js +1 -1
  9. package/dist/audit.js.map +1 -1
  10. package/dist/config.d.ts +8 -8
  11. package/dist/config.js +8 -103
  12. package/dist/config.js.map +1 -1
  13. package/dist/direct-broker.d.ts +57 -0
  14. package/dist/direct-broker.js +638 -0
  15. package/dist/direct-broker.js.map +1 -0
  16. package/dist/direct-service.d.ts +31 -0
  17. package/dist/direct-service.js +345 -0
  18. package/dist/direct-service.js.map +1 -0
  19. package/dist/lock.d.ts +1 -0
  20. package/dist/lock.js +32 -3
  21. package/dist/lock.js.map +1 -1
  22. package/dist/mcp-server.js +46 -105
  23. package/dist/mcp-server.js.map +1 -1
  24. package/dist/system.d.ts +0 -1
  25. package/dist/system.js +12 -37
  26. package/dist/system.js.map +1 -1
  27. package/dist/tools.d.ts +78 -0
  28. package/dist/tools.js +192 -0
  29. package/dist/tools.js.map +1 -0
  30. package/integrations/pi/README.md +41 -27
  31. package/integrations/pi/index.ts +110 -123
  32. package/integrations/pi/mcp.json.example +3 -3
  33. package/npm-shrinkwrap.json +3278 -48
  34. package/package.json +40 -13
  35. package/dist/policy.d.ts +0 -42
  36. package/dist/policy.js +0 -428
  37. package/dist/policy.js.map +0 -1
  38. package/dist/prompt.d.ts +0 -62
  39. package/dist/prompt.js +0 -119
  40. package/dist/prompt.js.map +0 -1
  41. package/dist/runner.d.ts +0 -55
  42. package/dist/runner.js +0 -494
  43. package/dist/runner.js.map +0 -1
  44. package/dist/service.d.ts +0 -17
  45. package/dist/service.js +0 -382
  46. package/dist/service.js.map +0 -1
package/package.json CHANGED
@@ -1,15 +1,27 @@
1
1
  {
2
2
  "name": "codex-computer-use-mcp",
3
- "version": "0.1.0",
4
- "description": "Expose OpenAI Codex Computer Use as a background-safe MCP server for macOS.",
3
+ "version": "0.2.0",
4
+ "description": "Expose the official macOS Computer Use tools directly to Pi and MCP clients without a nested model.",
5
5
  "author": "Thomas Mustier",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "os": ["darwin"],
9
- "keywords": ["mcp", "codex", "computer-use", "macos", "automation", "openai", "pi-package"],
10
- "publishConfig": { "access": "public" },
8
+ "os": [
9
+ "darwin"
10
+ ],
11
+ "keywords": [
12
+ "computer-use",
13
+ "macos",
14
+ "automation",
15
+ "pi-package",
16
+ "mcp"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
11
21
  "pi": {
12
- "extensions": ["./integrations/pi/index.ts"]
22
+ "extensions": [
23
+ "./integrations/pi/index.ts"
24
+ ]
13
25
  },
14
26
  "bin": {
15
27
  "codex-computer-use-mcp": "dist/mcp-server.js"
@@ -20,6 +32,8 @@
20
32
  "npm-shrinkwrap.json",
21
33
  "README.md",
22
34
  "PROOF.md",
35
+ "ARCHITECTURE.md",
36
+ "MIGRATION.md",
23
37
  "SECURITY.md",
24
38
  "CONTRIBUTING.md",
25
39
  "LICENSE"
@@ -29,10 +43,13 @@
29
43
  "check": "tsc -p tsconfig.json --noEmit",
30
44
  "test": "node --test test/*.test.ts",
31
45
  "prepare": "npm run build",
32
- "prepublishOnly": "npm run check && npm test && npm run build"
46
+ "prepublishOnly": "npm run check && npm run check:pi && npm test && npm run build",
47
+ "check:pi": "npx tsc --ignoreConfig --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --skipLibCheck --types node integrations/pi/index.ts"
33
48
  },
34
49
  "dependencies": {
35
50
  "@modelcontextprotocol/sdk": "1.29.0",
51
+ "@types/node": "24.13.3",
52
+ "typescript": "7.0.2",
36
53
  "zod": "4.4.3"
37
54
  },
38
55
  "peerDependencies": {
@@ -42,14 +59,24 @@
42
59
  "typebox": "*"
43
60
  },
44
61
  "peerDependenciesMeta": {
45
- "@earendil-works/pi-ai": { "optional": true },
46
- "@earendil-works/pi-coding-agent": { "optional": true },
47
- "@earendil-works/pi-tui": { "optional": true },
48
- "typebox": { "optional": true }
62
+ "@earendil-works/pi-ai": {
63
+ "optional": true
64
+ },
65
+ "@earendil-works/pi-coding-agent": {
66
+ "optional": true
67
+ },
68
+ "@earendil-works/pi-tui": {
69
+ "optional": true
70
+ },
71
+ "typebox": {
72
+ "optional": true
73
+ }
49
74
  },
50
75
  "devDependencies": {
51
- "@types/node": "^24.0.0",
52
- "typescript": "^7.0.2"
76
+ "@earendil-works/pi-ai": "0.80.6",
77
+ "@earendil-works/pi-coding-agent": "0.80.6",
78
+ "@earendil-works/pi-tui": "0.80.6",
79
+ "typebox": "1.1.38"
53
80
  },
54
81
  "engines": {
55
82
  "node": ">=22"
package/dist/policy.d.ts DELETED
@@ -1,42 +0,0 @@
1
- export declare const MODEL = "gpt-5.6-sol";
2
- export declare const MODEL_REASONING = "xhigh";
3
- export type ReasoningEffort = "low" | "high" | "xhigh";
4
- export declare const COMPUTER_USE_TOOLS: readonly ["list_apps", "get_app_state", "click", "perform_secondary_action", "set_value", "select_text", "scroll", "drag", "press_key", "type_text"];
5
- export type ComputerUseTool = (typeof COMPUTER_USE_TOOLS)[number];
6
- export type Mode = "list" | "inspect" | "act" | "dictionary_lookup";
7
- export type PermissionMode = "safe" | "full-permissions";
8
- export declare const DICTIONARY_BUNDLE_ID = "com.apple.Dictionary";
9
- export declare const DICTIONARY_NEUTRAL_QUERY = "dictionary";
10
- export interface NativeAppInput {
11
- mode: Mode;
12
- app?: string;
13
- task?: string;
14
- query?: string;
15
- cleanup?: boolean;
16
- cleanup_instructions?: string;
17
- required_capabilities?: ComputerUseTool[];
18
- }
19
- export interface ValidatedRequest {
20
- mode: Mode;
21
- permissionMode: PermissionMode;
22
- app?: string;
23
- task?: string;
24
- query?: string;
25
- cleanup: boolean;
26
- cleanupInstructions?: string;
27
- requiredCapabilities: ComputerUseTool[];
28
- mutating: boolean;
29
- maxComputerUseCalls: number;
30
- reasoningEffort: ReasoningEffort;
31
- }
32
- export declare class PolicyError extends Error {
33
- constructor(message: string);
34
- }
35
- export declare function validateRequest(input: NativeAppInput, permissionMode?: PermissionMode): ValidatedRequest;
36
- export declare function allowedToolsForRequest(request: ValidatedRequest): ComputerUseTool[];
37
- export declare function isDictionaryAlwaysAllowed(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): boolean;
38
- export declare function requiresPiConfirmation(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): boolean;
39
- export declare function validateResolvedAppIdentity(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): void;
40
- export type ComputerUseArgumentValidator = (tool: string, args: Record<string, unknown>) => string | undefined;
41
- export declare function createDictionaryArgumentValidator(query: string): ComputerUseArgumentValidator;
42
- export declare function validateObservedMethods(request: ValidatedRequest, methods: string[]): void;
package/dist/policy.js DELETED
@@ -1,428 +0,0 @@
1
- export const MODEL = "gpt-5.6-sol";
2
- export const MODEL_REASONING = "xhigh";
3
- export const COMPUTER_USE_TOOLS = [
4
- "list_apps",
5
- "get_app_state",
6
- "click",
7
- "perform_secondary_action",
8
- "set_value",
9
- "select_text",
10
- "scroll",
11
- "drag",
12
- "press_key",
13
- "type_text",
14
- ];
15
- export const DICTIONARY_BUNDLE_ID = "com.apple.Dictionary";
16
- export const DICTIONARY_NEUTRAL_QUERY = "dictionary";
17
- export class PolicyError extends Error {
18
- constructor(message) {
19
- super(message);
20
- this.name = "PolicyError";
21
- }
22
- }
23
- const BLOCKED_APP_PATTERNS = [
24
- {
25
- pattern: /(?:^|\b)(?:terminal|iterm\w*|ghostty|cmux|warp|wezterm|alacritty|kitty|hyper|tabby)(?:\b|$)/i,
26
- category: "terminal/shell",
27
- },
28
- { pattern: /(?:^|\b)(?:chatgpt|codex)(?:\b|$)/i, category: "agent host" },
29
- { pattern: /(?:^|\b)(?:keychain|1password|bitwarden|dashlane|lastpass|password)(?:\b|$)/i, category: "credentials" },
30
- { pattern: /(?:^|\b)(?:mail|messages|slack|whatsapp|teams|discord|telegram|signal)(?:\b|$)/i, category: "communications" },
31
- {
32
- pattern: /(?:^|\b)(?:safari|chrome|firefox|arc|browser|edge|opera|vivaldi|brave|orion)(?:\b|$)/i,
33
- category: "browser",
34
- },
35
- {
36
- pattern: /(?:^|\b)(?:vscode|vs code|visual studio code|cursor|windsurf|zed)(?:\b|$)/i,
37
- category: "editor/agent host",
38
- },
39
- { pattern: /(?:^|\b)(?:system settings|system preferences|settings|wallet|app store)(?:\b|$)/i, category: "system/payment settings" },
40
- ];
41
- const BLOCKED_BUNDLE_ID_PATTERNS = [
42
- {
43
- pattern: /(?:^|\.)(?:terminal|iterm2?|ghostty|cmuxterm|warp(?:-stable)?|wezterm|alacritty|kitty|hyper|tabby)(?:\.|$)/i,
44
- category: "terminal/shell",
45
- },
46
- { pattern: /(?:^|\.)(?:chatgpt|codex|chat)(?:\.|$)/i, category: "agent host" },
47
- {
48
- pattern: /(?:^|\.)(?:keychainaccess|1password|bitwarden|dashlane\w*|lastpass\w*|passwords?)(?:\.|$)/i,
49
- category: "credentials",
50
- },
51
- {
52
- pattern: /(?:^|\.)(?:mail|mobilesms|slack(?:macgap)?|whatsapp|teams2?|discord|telegram|signal(?:-desktop)?)(?:\.|$)/i,
53
- category: "communications",
54
- },
55
- {
56
- pattern: /(?:^|\.)(?:safari|chrome|firefox|browser|edgemac|opera|vivaldi|brave|orion|kagimacos)(?:\.|$)/i,
57
- category: "browser",
58
- },
59
- { pattern: /(?:^|\.)(?:vscode\w*|cursor|windsurf|zed)(?:\.|$)/i, category: "editor/agent host" },
60
- { pattern: /(?:^|\.)(?:systempreferences|wallet|appstore)(?:\.|$)/i, category: "system/payment settings" },
61
- ];
62
- const BLOCKED_OPAQUE_BUNDLE_IDS = new Map([
63
- ["com.todesktop.230313mzl4w4u92", "editor/agent host"], // Cursor
64
- ]);
65
- function blockedSafeAppCategory(value) {
66
- for (const blocked of BLOCKED_APP_PATTERNS) {
67
- if (blocked.pattern.test(value))
68
- return blocked.category;
69
- }
70
- if (/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(value)) {
71
- const exactCategory = BLOCKED_OPAQUE_BUNDLE_IDS.get(value.toLowerCase());
72
- if (exactCategory)
73
- return exactCategory;
74
- for (const blocked of BLOCKED_BUNDLE_ID_PATTERNS) {
75
- if (blocked.pattern.test(value))
76
- return blocked.category;
77
- }
78
- }
79
- return undefined;
80
- }
81
- const BLOCKED_TASK_PATTERNS = [
82
- { pattern: /\b(?:send|post|publish|share|upload|message|email|call)\b/i, category: "external communication" },
83
- { pattern: /\b(?:buy|purchase|checkout|pay|payment|subscribe)\b/i, category: "purchase/payment" },
84
- { pattern: /\b(?:password|passcode|credential|secret|token|api key|login|log in|sign in|authenticate)\b/i, category: "credentials/authentication" },
85
- { pattern: /\b(?:sudo|admin|administrator|privacy prompt|permission prompt|tcc)\b/i, category: "admin/privacy approval" },
86
- { pattern: /\b(?:delete|erase|trash|uninstall|wipe)\b/i, category: "destructive deletion" },
87
- ];
88
- function validateSafeApp(app) {
89
- if (typeof app !== "string")
90
- throw new PolicyError("inspect/act requires an app name or bundle identifier");
91
- const trimmed = app.trim();
92
- if (!trimmed || trimmed.length > 120)
93
- throw new PolicyError("App must be 1-120 characters");
94
- if (/[\u0000-\u001f\u007f\n\r]/.test(trimmed) || trimmed.includes("/") || /:/.test(trimmed)) {
95
- throw new PolicyError("App must be a name or bundle identifier, not a path, URL, or control string");
96
- }
97
- const blockedCategory = blockedSafeAppCategory(trimmed);
98
- if (blockedCategory)
99
- throw new PolicyError(`App is blocked by the ${blockedCategory} safety policy`);
100
- return trimmed;
101
- }
102
- function validateFullApp(app) {
103
- if (typeof app !== "string")
104
- throw new PolicyError("inspect/act requires an app target");
105
- const trimmed = app.trim();
106
- if (!trimmed || trimmed.length > 500)
107
- throw new PolicyError("Full-permissions app target must be 1-500 characters");
108
- if (/[\u0000-\u001f\u007f]/.test(trimmed))
109
- throw new PolicyError("App target contains unsupported control characters");
110
- return trimmed;
111
- }
112
- function validateSafeTask(task) {
113
- if (typeof task !== "string")
114
- throw new PolicyError("act requires a concrete task");
115
- const trimmed = task.trim();
116
- if (!trimmed || trimmed.length > 1000)
117
- throw new PolicyError("Task must be 1-1000 characters");
118
- if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(trimmed)) {
119
- throw new PolicyError("Task contains unsupported control characters");
120
- }
121
- for (const blocked of BLOCKED_TASK_PATTERNS) {
122
- if (blocked.pattern.test(trimmed))
123
- throw new PolicyError(`Task is blocked as ${blocked.category}`);
124
- }
125
- return trimmed;
126
- }
127
- function isDictionarySelector(value) {
128
- if (typeof value !== "string")
129
- return false;
130
- const normalized = value.trim().toLowerCase();
131
- return normalized === "dictionary" || normalized === DICTIONARY_BUNDLE_ID.toLowerCase();
132
- }
133
- function validateFullTask(task) {
134
- if (typeof task !== "string")
135
- throw new PolicyError("act requires a concrete task");
136
- const trimmed = task.trim();
137
- if (!trimmed || trimmed.length > 4000)
138
- throw new PolicyError("Full-permissions task must be 1-4000 characters");
139
- if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(trimmed)) {
140
- throw new PolicyError("Task contains unsupported control characters");
141
- }
142
- return trimmed;
143
- }
144
- function validateDictionaryQuery(value) {
145
- if (typeof value !== "string")
146
- throw new PolicyError("dictionary_lookup requires a query");
147
- const trimmed = value.trim();
148
- if (!trimmed || trimmed.length > 200)
149
- throw new PolicyError("Dictionary query must be 1-200 characters");
150
- if (/[\u0000-\u001f\u007f]/.test(trimmed))
151
- throw new PolicyError("Dictionary query contains unsupported control characters");
152
- return trimmed;
153
- }
154
- function validateCleanupInstructions(value, permissionMode) {
155
- if (value === undefined)
156
- return undefined;
157
- if (typeof value !== "string")
158
- throw new PolicyError("cleanup_instructions must be text");
159
- const trimmed = value.trim();
160
- const maxLength = permissionMode === "full-permissions" ? 2000 : 500;
161
- if (!trimmed || trimmed.length > maxLength)
162
- throw new PolicyError(`cleanup_instructions must be 1-${maxLength} characters`);
163
- if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(trimmed)) {
164
- throw new PolicyError("Cleanup instructions contain unsupported control characters");
165
- }
166
- if (permissionMode === "safe") {
167
- for (const blocked of BLOCKED_TASK_PATTERNS) {
168
- if (blocked.pattern.test(trimmed))
169
- throw new PolicyError(`Cleanup instructions are blocked as ${blocked.category}`);
170
- }
171
- }
172
- return trimmed;
173
- }
174
- function validateRequiredCapabilities(value) {
175
- if (value === undefined)
176
- return [];
177
- if (!Array.isArray(value))
178
- throw new PolicyError("required_capabilities must be an array");
179
- const available = new Set(COMPUTER_USE_TOOLS);
180
- const result = [];
181
- for (const item of value) {
182
- if (typeof item !== "string" || !available.has(item))
183
- throw new PolicyError(`Unknown Computer Use capability: ${String(item)}`);
184
- if (item === "list_apps" || item === "get_app_state")
185
- continue;
186
- if (!result.includes(item))
187
- result.push(item);
188
- }
189
- return result;
190
- }
191
- export function validateRequest(input, permissionMode = "safe") {
192
- if (!input || typeof input !== "object")
193
- throw new PolicyError("Request must be an object");
194
- if (permissionMode !== "safe" && permissionMode !== "full-permissions")
195
- throw new PolicyError("Invalid permission mode");
196
- if (permissionMode === "safe" && input.mode !== "list") {
197
- throw new PolicyError("Standalone safe mode permits only list: target and argument checks are observable only after the signed official client dispatches a call. Enable explicit full-permissions only if that broad authorization is acceptable.");
198
- }
199
- switch (input.mode) {
200
- case "list":
201
- if (input.app !== undefined ||
202
- input.task !== undefined ||
203
- input.query !== undefined ||
204
- input.cleanup !== undefined ||
205
- input.cleanup_instructions !== undefined ||
206
- input.required_capabilities !== undefined) {
207
- throw new PolicyError("list accepts only mode");
208
- }
209
- return {
210
- mode: "list",
211
- permissionMode,
212
- cleanup: true,
213
- requiredCapabilities: [],
214
- mutating: false,
215
- maxComputerUseCalls: 1,
216
- reasoningEffort: "low",
217
- };
218
- case "inspect":
219
- if (input.task !== undefined ||
220
- input.query !== undefined ||
221
- input.cleanup !== undefined ||
222
- input.cleanup_instructions !== undefined ||
223
- input.required_capabilities !== undefined) {
224
- throw new PolicyError("inspect accepts only app");
225
- }
226
- return {
227
- mode: "inspect",
228
- permissionMode,
229
- app: permissionMode === "full-permissions" ? validateFullApp(input.app) : validateSafeApp(input.app),
230
- cleanup: true,
231
- requiredCapabilities: [],
232
- mutating: false,
233
- maxComputerUseCalls: 3,
234
- reasoningEffort: "high",
235
- };
236
- case "act": {
237
- const app = permissionMode === "full-permissions" ? validateFullApp(input.app) : validateSafeApp(input.app);
238
- if (permissionMode === "safe" && isDictionarySelector(app)) {
239
- throw new PolicyError("Dictionary is restricted to inspect or dictionary_lookup in safe mode");
240
- }
241
- if (input.query !== undefined)
242
- throw new PolicyError("act does not accept query; use task");
243
- const cleanup = input.cleanup ?? (permissionMode === "safe");
244
- if (!cleanup && input.cleanup_instructions !== undefined) {
245
- throw new PolicyError("act does not accept cleanup_instructions when cleanup is false");
246
- }
247
- return {
248
- mode: "act",
249
- permissionMode,
250
- app,
251
- task: permissionMode === "full-permissions" ? validateFullTask(input.task) : validateSafeTask(input.task),
252
- cleanup,
253
- cleanupInstructions: cleanup ? validateCleanupInstructions(input.cleanup_instructions, permissionMode) : undefined,
254
- requiredCapabilities: validateRequiredCapabilities(input.required_capabilities),
255
- mutating: true,
256
- maxComputerUseCalls: 50,
257
- reasoningEffort: "xhigh",
258
- };
259
- }
260
- case "dictionary_lookup":
261
- if (input.app !== undefined ||
262
- input.task !== undefined ||
263
- input.cleanup !== undefined ||
264
- input.cleanup_instructions !== undefined ||
265
- input.required_capabilities !== undefined) {
266
- throw new PolicyError("dictionary_lookup accepts only query");
267
- }
268
- return {
269
- mode: "dictionary_lookup",
270
- permissionMode,
271
- app: DICTIONARY_BUNDLE_ID,
272
- query: validateDictionaryQuery(input.query),
273
- cleanup: true,
274
- requiredCapabilities: ["set_value"],
275
- mutating: true,
276
- maxComputerUseCalls: 8,
277
- reasoningEffort: "high",
278
- };
279
- default:
280
- throw new PolicyError(`Unsupported mode: ${String(input.mode)}`);
281
- }
282
- }
283
- export function allowedToolsForRequest(request) {
284
- switch (request.mode) {
285
- case "list":
286
- return ["list_apps"];
287
- case "inspect":
288
- return ["list_apps", "get_app_state"];
289
- case "act":
290
- return [...COMPUTER_USE_TOOLS];
291
- case "dictionary_lookup":
292
- return ["get_app_state", "set_value", "scroll"];
293
- }
294
- }
295
- export function isDictionaryAlwaysAllowed(request, resolvedBundleId, verifiedSystemDictionary) {
296
- return (request.permissionMode === "safe" &&
297
- verifiedSystemDictionary &&
298
- resolvedBundleId === DICTIONARY_BUNDLE_ID &&
299
- (request.mode === "inspect" || request.mode === "dictionary_lookup"));
300
- }
301
- export function requiresPiConfirmation(request, resolvedBundleId, verifiedSystemDictionary) {
302
- if (request.permissionMode === "full-permissions")
303
- return false;
304
- return request.mode !== "list" && !isDictionaryAlwaysAllowed(request, resolvedBundleId, verifiedSystemDictionary);
305
- }
306
- export function validateResolvedAppIdentity(request, resolvedBundleId, verifiedSystemDictionary) {
307
- if (request.permissionMode === "safe" && resolvedBundleId) {
308
- const blockedCategory = blockedSafeAppCategory(resolvedBundleId);
309
- if (blockedCategory) {
310
- throw new PolicyError(`Resolved app is blocked by the ${blockedCategory} safety policy`);
311
- }
312
- }
313
- if (request.mode === "dictionary_lookup" && !verifiedSystemDictionary) {
314
- throw new PolicyError("Dictionary lookup requires the running Apple-signed system Dictionary at its fixed system path");
315
- }
316
- if (request.permissionMode === "safe" && request.mode === "act" && verifiedSystemDictionary) {
317
- throw new PolicyError("Generic actions against Dictionary are blocked after canonical identity resolution in safe mode");
318
- }
319
- }
320
- export function createDictionaryArgumentValidator(query) {
321
- let setCount = 0;
322
- let searchElement;
323
- return (tool, args) => {
324
- if (tool === "set_value") {
325
- if (typeof args.element_index !== "string" || typeof args.value !== "string") {
326
- return "Dictionary set_value arguments were not typed strings";
327
- }
328
- setCount += 1;
329
- if (setCount === 1) {
330
- if (args.value !== query)
331
- return "Dictionary lookup attempted to set a value other than the approved query";
332
- searchElement = args.element_index;
333
- return undefined;
334
- }
335
- if (setCount === 2) {
336
- if (args.element_index !== searchElement)
337
- return "Dictionary cleanup targeted a different element than the lookup";
338
- if (args.value !== DICTIONARY_NEUTRAL_QUERY)
339
- return "Dictionary cleanup did not restore the fixed neutral query";
340
- return undefined;
341
- }
342
- return "Dictionary lookup attempted more than two value assignments";
343
- }
344
- if (tool === "scroll") {
345
- if (!["up", "down"].includes(String(args.direction)))
346
- return "Dictionary lookup attempted a non-vertical scroll";
347
- if (args.pages !== undefined && (typeof args.pages !== "number" || args.pages <= 0 || args.pages > 3)) {
348
- return "Dictionary lookup attempted an out-of-bounds scroll";
349
- }
350
- }
351
- return undefined;
352
- };
353
- }
354
- const MUTATION_METHODS = new Set([
355
- "click",
356
- "perform_secondary_action",
357
- "set_value",
358
- "select_text",
359
- "scroll",
360
- "drag",
361
- "press_key",
362
- "type_text",
363
- ]);
364
- export function validateObservedMethods(request, methods) {
365
- if (methods.length === 0)
366
- throw new PolicyError("Codex completed without an observed Computer Use method call");
367
- if (methods.length > request.maxComputerUseCalls) {
368
- throw new PolicyError(`Computer Use call budget exceeded (${methods.length}/${request.maxComputerUseCalls})`);
369
- }
370
- const available = new Set(allowedToolsForRequest(request));
371
- for (const method of methods) {
372
- if (!available.has(method))
373
- throw new PolicyError(`Computer Use method is outside policy: ${method}`);
374
- }
375
- if (request.mode === "list") {
376
- if (methods.length !== 1 || methods[0] !== "list_apps")
377
- throw new PolicyError("list must make exactly one list_apps call");
378
- return;
379
- }
380
- if (!methods.includes("get_app_state"))
381
- throw new PolicyError(`${request.mode} must inspect app state`);
382
- if (request.mode === "inspect") {
383
- if (methods.some((method) => MUTATION_METHODS.has(method))) {
384
- throw new PolicyError("inspect attempted a mutating Computer Use method");
385
- }
386
- return;
387
- }
388
- if (request.mode === "dictionary_lookup") {
389
- const stateIndexes = methods
390
- .map((method, index) => (method === "get_app_state" ? index : -1))
391
- .filter((index) => index >= 0);
392
- const setIndexes = methods
393
- .map((method, index) => (method === "set_value" ? index : -1))
394
- .filter((index) => index >= 0);
395
- if (setIndexes.length !== 2)
396
- throw new PolicyError("dictionary_lookup must set the query once and restore the fixed neutral query once");
397
- if (stateIndexes[0] > setIndexes[0])
398
- throw new PolicyError("dictionary_lookup did not inspect Dictionary before setting the query");
399
- if (!stateIndexes.some((index) => index > setIndexes[0] && index < setIndexes[1])) {
400
- throw new PolicyError("dictionary_lookup did not inspect the lookup result before cleanup");
401
- }
402
- if (!stateIndexes.some((index) => index > setIndexes[1])) {
403
- throw new PolicyError("dictionary_lookup did not verify restoration of the fixed neutral query");
404
- }
405
- return;
406
- }
407
- const mutationIndexes = methods
408
- .map((method, index) => (MUTATION_METHODS.has(method) ? index : -1))
409
- .filter((index) => index >= 0);
410
- const stateIndexes = methods
411
- .map((method, index) => (method === "get_app_state" ? index : -1))
412
- .filter((index) => index >= 0);
413
- if (mutationIndexes.length === 0)
414
- throw new PolicyError("act completed without a mutating Computer Use method");
415
- if (stateIndexes[0] > mutationIndexes[0])
416
- throw new PolicyError("act did not inspect the target before mutation");
417
- if (!stateIndexes.some((index) => index > mutationIndexes.at(-1))) {
418
- throw new PolicyError("act did not verify target state after the final mutation");
419
- }
420
- for (const capability of request.requiredCapabilities) {
421
- if (!methods.includes(capability))
422
- throw new PolicyError(`Required Computer Use capability was not exercised: ${capability}`);
423
- }
424
- if (request.cleanup && stateIndexes.filter((index) => index > mutationIndexes[0]).length < 2) {
425
- throw new PolicyError("act did not separately verify task result and cleanup state");
426
- }
427
- }
428
- //# sourceMappingURL=policy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC;AACnC,MAAM,CA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C"}
package/dist/prompt.d.ts DELETED
@@ -1,62 +0,0 @@
1
- import { type ValidatedRequest } from "./policy.ts";
2
- export declare const RESULT_SCHEMA: {
3
- readonly type: "object";
4
- readonly additionalProperties: false;
5
- readonly required: readonly ["status", "app", "mode", "summary", "cleaned", "approvalRequired", "usedCapabilities", "apps", "message"];
6
- readonly properties: {
7
- readonly status: {
8
- readonly type: "string";
9
- readonly enum: readonly ["ok", "approval_required", "blocked", "error"];
10
- };
11
- readonly app: {
12
- readonly type: "string";
13
- readonly maxLength: 500;
14
- };
15
- readonly mode: {
16
- readonly type: "string";
17
- readonly enum: readonly ["list", "inspect", "act", "dictionary_lookup"];
18
- };
19
- readonly summary: {
20
- readonly type: "string";
21
- readonly maxLength: 1000;
22
- };
23
- readonly cleaned: {
24
- readonly type: "boolean";
25
- };
26
- readonly approvalRequired: {
27
- readonly type: "boolean";
28
- };
29
- readonly usedCapabilities: {
30
- readonly type: "array";
31
- readonly maxItems: 50;
32
- readonly items: {
33
- readonly type: "string";
34
- readonly enum: readonly ["list_apps", "get_app_state", "click", "perform_secondary_action", "set_value", "select_text", "scroll", "drag", "press_key", "type_text"];
35
- };
36
- };
37
- readonly apps: {
38
- readonly type: "array";
39
- readonly maxItems: 100;
40
- readonly items: {
41
- readonly type: "object";
42
- readonly additionalProperties: false;
43
- readonly required: readonly ["name", "bundleId"];
44
- readonly properties: {
45
- readonly name: {
46
- readonly type: "string";
47
- readonly maxLength: 120;
48
- };
49
- readonly bundleId: {
50
- readonly type: "string";
51
- readonly maxLength: 160;
52
- };
53
- };
54
- };
55
- };
56
- readonly message: {
57
- readonly type: "string";
58
- readonly maxLength: 256;
59
- };
60
- };
61
- };
62
- export declare function buildPrompt(request: ValidatedRequest, canonicalTargetApp?: string): string;