@ai-agent-forge/plugin-desktop-macos-input 0.0.0-stage → 0.88.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.js","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQzD,SAAS,kBAAkB,CAAC,KAA8B,EAA8C;IACvG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAClB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QACnH,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAAA,CAChB;AAED,SAAS,aAAa,CAAC,KAAc,EAAiD;IACrF,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACnH,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CA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,CAAC,CAAC;gBAChG,CAAC;gBACD,IAAI,CAAC;oBACJ,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC/B,OAAO,MAAM,EAAE,OAAO;wBACrB,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,iCAAiC,EAAE,WAAW,CAAC;wBAC1F,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBAC7C,CAAC;gBAAC,MAAM,CAAC;oBACR,OAAO,cAAc,CAAC,WAAW,EAAE,wBAAwB,EAAE,qCAAqC,CAAC,CAAC;gBACrG,CAAC;YAAA,CACD;SACD,CAAC,CAAC;IAAA,CACH,CAAC;AAAA,CACF","sourcesContent":["/**\n * Bounded desktop input capability factory, mirroring the Windows package's\n * `capability.ts` (migrated from agent-forge\n * `src/profile/runtime-capabilities-desktop-input.ts`,\n * `desktopInputFactory`, D-075 S3 extraction). Differences from the Windows\n * copy:\n * - The runtime type is the macOS full-control adapter from `types.ts`.\n * - The target union gains the `coordinates` variant (`x`/`y` integer,\n * non-negative screen coordinates); the coordinate target is accepted for\n * the `click` action only — any other action kind with a coordinate target\n * is rejected as `desktop_input_invalid` (same ruling the Windows package\n * implements for its coordinate click).\n * Tool names, parameters, budgets, result shapes, the readonly-mode refusal\n * to register input tools, and the optional replay registration when the\n * runtime exposes a replay method are unchanged; the shipped macOS facade\n * exposes no replay, so only `desktop_execute` registers out of the box.\n */\nimport type { CapabilityPluginSyncFactory } from \"@agent-forge/plugin-sdk\";\nimport { Type } from \"typebox\";\nimport {\n\tDESKTOP_MAX_POSTCONDITIONS_V1,\n\tDESKTOP_MAX_REPLAY_ACTIONS_V1,\n\tDESKTOP_MAX_STRING_CHARS_V1,\n\tDESKTOP_MAX_TYPE_TEXT_CHARS_V1,\n\tdesktopBoundedString,\n\tdesktopFailure,\n\tdesktopRequiredString,\n\tdesktopResultWithinBudget,\n\tprojectDesktopObservation,\n} from \"./projection.ts\";\nimport { signalFrom, toolInvocation } from \"./shared.ts\";\nimport type {\n\tDesktopFullControlAdapterV1,\n\tDesktopOperationRequestV1,\n\tDesktopPostconditionV1,\n\tDesktopReplayRequestV1,\n} from \"./types.ts\";\n\nfunction desktopCoordinates(input: Record<string, unknown>): { readonly x: number; readonly y: number } {\n\tconst x = input.x;\n\tconst y = input.y;\n\tif (typeof x !== \"number\" || typeof y !== \"number\" || !Number.isInteger(x) || !Number.isInteger(y) || x < 0 || y < 0)\n\t\tthrow new Error(\"desktop-target-invalid\");\n\treturn { x, y };\n}\n\nfunction desktopTarget(input: unknown): DesktopOperationRequestV1[\"action\"][\"target\"] {\n\tif (input === null || typeof input !== \"object\" || Array.isArray(input)) throw new Error(\"desktop-target-invalid\");\n\tconst target = input as Record<string, unknown>;\n\tif (target.kind === \"window\") {\n\t\tdesktopExactKeys(target, [\"kind\", \"windowId\"]);\n\t\treturn { kind: \"window\", windowId: desktopRequiredString(target.windowId, \"windowId\") };\n\t}\n\tif (target.kind === \"control\") {\n\t\tdesktopExactKeys(target, [\"kind\", \"controlId\", \"windowId\"]);\n\t\treturn {\n\t\t\tkind: \"control\",\n\t\t\tcontrolId: desktopRequiredString(target.controlId, \"controlId\"),\n\t\t\t...(target.windowId === undefined ? {} : { windowId: desktopRequiredString(target.windowId, \"windowId\") }),\n\t\t};\n\t}\n\tif (target.kind === \"coordinates\") {\n\t\tdesktopExactKeys(target, [\"kind\", \"x\", \"y\"]);\n\t\treturn { kind: \"coordinates\", ...desktopCoordinates(target) };\n\t}\n\tthrow new Error(\"desktop-target-invalid\");\n}\n\nfunction desktopExactKeys(value: Record<string, unknown>, allowed: readonly string[]): void {\n\tif (Object.keys(value).some((key) => !allowed.includes(key))) throw new Error(\"desktop-input-invalid\");\n}\n\nfunction desktopPostconditions(input: unknown): readonly DesktopPostconditionV1[] | undefined {\n\tif (input === undefined) return undefined;\n\tif (!Array.isArray(input) || input.length > DESKTOP_MAX_POSTCONDITIONS_V1)\n\t\tthrow new Error(\"desktop-postconditions-invalid\");\n\treturn input.map((entry) => {\n\t\tif (entry === null || typeof entry !== \"object\" || Array.isArray(entry))\n\t\t\tthrow new Error(\"desktop-postcondition-invalid\");\n\t\tconst value = entry as Record<string, unknown>;\n\t\tif (value.kind === \"window-exists\") {\n\t\t\tdesktopExactKeys(value, [\"kind\", \"windowId\"]);\n\t\t\treturn { kind: \"window-exists\", windowId: desktopRequiredString(value.windowId, \"windowId\") } as const;\n\t\t}\n\t\tif (value.kind === \"control-exists\") {\n\t\t\tdesktopExactKeys(value, [\"kind\", \"controlId\"]);\n\t\t\treturn { kind: \"control-exists\", controlId: desktopRequiredString(value.controlId, \"controlId\") } as const;\n\t\t}\n\t\tif (value.kind === \"focused\") {\n\t\t\tdesktopExactKeys(value, [\"kind\", \"controlId\"]);\n\t\t\treturn { kind: \"focused\", controlId: desktopRequiredString(value.controlId, \"controlId\") } as const;\n\t\t}\n\t\tif (value.kind === \"property-equals\") {\n\t\t\tdesktopExactKeys(value, [\"kind\", \"target\", \"property\", \"expected\"]);\n\t\t\tif (value.property !== \"enabled\" && value.property !== \"value\" && value.property !== \"name\")\n\t\t\t\tthrow new Error(\"desktop-postcondition-invalid\");\n\t\t\tif (\n\t\t\t\t(value.property === \"enabled\" && typeof value.expected !== \"boolean\") ||\n\t\t\t\t(value.property !== \"enabled\" && typeof value.expected !== \"string\")\n\t\t\t)\n\t\t\t\tthrow new Error(\"desktop-postcondition-invalid\");\n\t\t\treturn {\n\t\t\t\tkind: \"property-equals\",\n\t\t\t\ttarget: desktopTarget(value.target),\n\t\t\t\tproperty: value.property,\n\t\t\t\texpected:\n\t\t\t\t\ttypeof value.expected === \"string\"\n\t\t\t\t\t\t? desktopBoundedString(value.expected, \"postcondition expected\")\n\t\t\t\t\t\t: value.expected,\n\t\t\t} as DesktopPostconditionV1;\n\t\t}\n\t\tthrow new Error(\"desktop-postcondition-invalid\");\n\t});\n}\n\nfunction desktopExecuteRequest(input: Record<string, unknown>, operationId: string): DesktopOperationRequestV1 {\n\tdesktopExactKeys(input, [\"sessionId\", \"action\", \"postconditions\"]);\n\tconst actionInput = input.action;\n\tif (actionInput === null || typeof actionInput !== \"object\" || Array.isArray(actionInput))\n\t\tthrow new Error(\"desktop-action-invalid\");\n\tconst action = actionInput as Record<string, unknown>;\n\tdesktopExactKeys(action, [\"kind\", \"target\", \"text\", \"key\"]);\n\tif (\n\t\taction.kind !== \"focus\" &&\n\t\taction.kind !== \"click\" &&\n\t\taction.kind !== \"type\" &&\n\t\taction.kind !== \"key\" &&\n\t\taction.kind !== \"scroll\"\n\t)\n\t\tthrow new Error(\"desktop-action-invalid\");\n\tconst target = desktopTarget(action.target);\n\tif (target === undefined) throw new Error(\"desktop-target-invalid\");\n\t// Coordinate targets are a click-only affordance: pointing elsewhere is a\n\t// caller contract violation, not a fallback path.\n\tif (target.kind === \"coordinates\" && action.kind !== \"click\") throw new Error(\"desktop-coordinates-click-only\");\n\tconst text =\n\t\taction.kind === \"type\" || action.kind === \"scroll\" ? desktopBoundedString(action.text, \"text\") : undefined;\n\tif (text !== undefined && text.length > DESKTOP_MAX_TYPE_TEXT_CHARS_V1) throw new Error(\"desktop-type-text-budget\");\n\tconst key = action.kind === \"key\" ? desktopBoundedString(action.key, \"key\") : undefined;\n\tif (key !== undefined && key.length > DESKTOP_MAX_TYPE_TEXT_CHARS_V1) throw new Error(\"desktop-type-text-budget\");\n\tconst postconditions = desktopPostconditions(input.postconditions);\n\treturn {\n\t\tversion: 1,\n\t\toperationId,\n\t\tsessionId: desktopRequiredString(input.sessionId, \"sessionId\"),\n\t\taction: {\n\t\t\tversion: 1,\n\t\t\tkind: action.kind,\n\t\t\ttarget,\n\t\t\t...(text === undefined ? {} : { text }),\n\t\t\t...(key === undefined ? {} : { key }),\n\t\t},\n\t\t...(postconditions === undefined ? {} : { postconditions }),\n\t\t// Input plugin operations always request a fresh observation; callers may\n\t\t// not turn this off because target identity otherwise goes stale.\n\t\treobserveAfterAction: true,\n\t};\n}\n\nfunction desktopVerification(\n\tvalue: unknown,\n): { readonly status: \"passed\" | \"failed\" | \"unknown\"; readonly checks: readonly string[] } | undefined {\n\tif (value === undefined) return undefined;\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst verification = value as Record<string, unknown>;\n\tif (\n\t\t(verification.status !== \"passed\" && verification.status !== \"failed\" && verification.status !== \"unknown\") ||\n\t\t!Array.isArray(verification.checks) ||\n\t\tverification.checks.length > DESKTOP_MAX_POSTCONDITIONS_V1\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\treturn {\n\t\tstatus: verification.status,\n\t\tchecks: verification.checks.map((check) => desktopBoundedString(check, \"verification check\")),\n\t};\n}\n\nfunction desktopExecuteResult(value: unknown, request: DesktopOperationRequestV1) {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst result = value as Record<string, unknown>;\n\tif (\n\t\tresult.version !== 1 ||\n\t\tresult.operationId !== request.operationId ||\n\t\t(result.status !== \"succeeded\" &&\n\t\t\tresult.status !== \"failed\" &&\n\t\t\tresult.status !== \"cancelled\" &&\n\t\t\tresult.status !== \"needs_user\" &&\n\t\t\tresult.status !== \"unsupported\")\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\tconst observation = result.observation === undefined ? undefined : projectDesktopObservation(result.observation);\n\tif (\n\t\tresult.status === \"succeeded\" &&\n\t\t(observation === undefined || observation.observation.sessionId !== request.sessionId)\n\t) {\n\t\treturn desktopFailure(\n\t\t\trequest.operationId,\n\t\t\t\"verification_unavailable\",\n\t\t\t\"Desktop action did not produce a fresh observation\",\n\t\t);\n\t}\n\tconst base = {\n\t\tversion: 1 as const,\n\t\toperationId: request.operationId,\n\t\tstatus: result.status,\n\t\tsummary: result.status === \"succeeded\" ? \"Desktop action completed\" : \"Desktop action could not be completed\",\n\t\t...(observation === undefined ? {} : observation),\n\t\t...(desktopVerification(result.verification) === undefined\n\t\t\t? {}\n\t\t\t: { verification: desktopVerification(result.verification) }),\n\t};\n\tif (result.status === \"succeeded\") return desktopResultWithinBudget(base);\n\tconst error = result.error;\n\tif (error === null || typeof error !== \"object\" || Array.isArray(error)) throw new Error(\"desktop-result-invalid\");\n\tconst errorValue = error as Record<string, unknown>;\n\tconst causeCode =\n\t\tresult.status === \"needs_user\" && typeof errorValue.causeCode === \"string\"\n\t\t\t? desktopBoundedString(errorValue.causeCode, \"error causeCode\")\n\t\t\t: undefined;\n\treturn desktopResultWithinBudget({\n\t\t...base,\n\t\terror: {\n\t\t\tversion: 1 as const,\n\t\t\tcode: result.status === \"needs_user\" ? \"needs_user\" : \"desktop_action_failed\",\n\t\t\tmessage: result.status === \"needs_user\" ? \"Desktop action requires user action\" : \"Desktop action failed\",\n\t\t\t...(causeCode === undefined ? {} : { causeCode }),\n\t\t},\n\t});\n}\n\nfunction desktopReplayActionInput(raw: unknown): DesktopOperationRequestV1[\"action\"] {\n\tif (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) throw new Error(\"desktop-action-invalid\");\n\tconst action = raw as Record<string, unknown>;\n\tdesktopExactKeys(action, [\"kind\", \"target\", \"text\", \"key\"]);\n\tif (\n\t\taction.kind !== \"focus\" &&\n\t\taction.kind !== \"click\" &&\n\t\taction.kind !== \"type\" &&\n\t\taction.kind !== \"key\" &&\n\t\taction.kind !== \"scroll\"\n\t)\n\t\tthrow new Error(\"desktop-action-invalid\");\n\tconst target = desktopTarget(action.target);\n\tif (target === undefined) throw new Error(\"desktop-target-invalid\");\n\tif (target.kind === \"coordinates\" && action.kind !== \"click\") throw new Error(\"desktop-coordinates-click-only\");\n\tconst text =\n\t\taction.kind === \"type\" || action.kind === \"scroll\" ? desktopBoundedString(action.text, \"text\") : undefined;\n\tif (text !== undefined && text.length > DESKTOP_MAX_TYPE_TEXT_CHARS_V1) throw new Error(\"desktop-type-text-budget\");\n\tconst key = action.kind === \"key\" ? desktopBoundedString(action.key, \"key\") : undefined;\n\tif (key !== undefined && key.length > DESKTOP_MAX_TYPE_TEXT_CHARS_V1) throw new Error(\"desktop-type-text-budget\");\n\treturn {\n\t\tversion: 1,\n\t\tkind: action.kind,\n\t\ttarget,\n\t\t...(text === undefined ? {} : { text }),\n\t\t...(key === undefined ? {} : { key }),\n\t};\n}\n\nfunction desktopReplayRequest(input: Record<string, unknown>, operationId: string): DesktopReplayRequestV1 {\n\tdesktopExactKeys(input, [\"sessionId\", \"actions\", \"stopOnFailure\"]);\n\tif (\n\t\t!Array.isArray(input.actions) ||\n\t\tinput.actions.length === 0 ||\n\t\tinput.actions.length > DESKTOP_MAX_REPLAY_ACTIONS_V1\n\t)\n\t\tthrow new Error(\"desktop-replay-actions-invalid\");\n\tconst sessionId = desktopRequiredString(input.sessionId, \"sessionId\");\n\tconst operations = input.actions.map((raw, index) => {\n\t\tconst action = desktopReplayActionInput(raw);\n\t\treturn {\n\t\t\tversion: 1 as const,\n\t\t\toperationId: `${operationId}-${index}`,\n\t\t\tsessionId,\n\t\t\taction,\n\t\t\t// Replay always re-observes so per-action results carry fresh state.\n\t\t\treobserveAfterAction: true,\n\t\t} satisfies DesktopOperationRequestV1;\n\t});\n\treturn {\n\t\tversion: 1,\n\t\tsessionId,\n\t\toperations,\n\t\tstopOnFailure: input.stopOnFailure === undefined ? true : input.stopOnFailure === true,\n\t};\n}\n\nfunction desktopReplayResult(value: unknown, operationId: string): unknown {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst result = value as Record<string, unknown>;\n\tif (\n\t\tresult.version !== 1 ||\n\t\t(result.status !== \"succeeded\" &&\n\t\t\tresult.status !== \"failed\" &&\n\t\t\tresult.status !== \"cancelled\" &&\n\t\t\tresult.status !== \"needs_user\") ||\n\t\t!Array.isArray(result.results)\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\tconst results = result.results.map((entry) => {\n\t\tif (entry === null || typeof entry !== \"object\" || Array.isArray(entry))\n\t\t\tthrow new Error(\"desktop-result-invalid\");\n\t\tconst record = entry as Record<string, unknown>;\n\t\tif (\n\t\t\trecord.version !== 1 ||\n\t\t\ttypeof record.operationId !== \"string\" ||\n\t\t\t(record.status !== \"succeeded\" &&\n\t\t\t\trecord.status !== \"failed\" &&\n\t\t\t\trecord.status !== \"cancelled\" &&\n\t\t\t\trecord.status !== \"needs_user\" &&\n\t\t\t\trecord.status !== \"unsupported\")\n\t\t)\n\t\t\tthrow new Error(\"desktop-result-invalid\");\n\t\treturn {\n\t\t\toperationId: desktopBoundedString(record.operationId, \"replay operationId\"),\n\t\t\tstatus: record.status,\n\t\t\tsummary: desktopBoundedString(record.summary, \"replay summary\"),\n\t\t};\n\t});\n\tconst last = result.results[result.results.length - 1] as Record<string, unknown> | undefined;\n\tconst observation =\n\t\tlast?.observation === undefined ? undefined : projectDesktopObservation(last.observation).observation;\n\tconst needsUser = result.results.find((entry) => (entry as Record<string, unknown>).status === \"needs_user\") as\n\t\t| Record<string, unknown>\n\t\t| undefined;\n\tconst causeCode =\n\t\tneedsUser !== undefined &&\n\t\tneedsUser.error !== null &&\n\t\ttypeof needsUser.error === \"object\" &&\n\t\t\"causeCode\" in needsUser.error &&\n\t\ttypeof (needsUser.error as Record<string, unknown>).causeCode === \"string\"\n\t\t\t? desktopBoundedString((needsUser.error as Record<string, unknown>).causeCode, \"replay causeCode\")\n\t\t\t: undefined;\n\treturn desktopResultWithinBudget({\n\t\tversion: 1,\n\t\toperationId,\n\t\tstatus: result.status,\n\t\tsummary: result.status === \"succeeded\" ? \"Desktop replay completed\" : \"Desktop replay stopped before completion\",\n\t\tresults,\n\t\t...(observation === undefined ? {} : { observation }),\n\t\t...(result.status === \"needs_user\" && causeCode !== undefined\n\t\t\t? {\n\t\t\t\t\terror: {\n\t\t\t\t\t\tversion: 1 as const,\n\t\t\t\t\t\tcode: \"needs_user\",\n\t\t\t\t\t\tmessage: \"Desktop replay requires user action\",\n\t\t\t\t\t\tcauseCode,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n}\n\nexport function createDesktopInputCapabilityFactoryV1(\n\truntime: DesktopFullControlAdapterV1,\n): CapabilityPluginSyncFactory {\n\treturn (api) => {\n\t\tif (api.host.mode === \"readonly\") return;\n\t\tapi.registerTool({\n\t\t\tname: \"desktop_execute\",\n\t\t\tlabel: \"Execute desktop action\",\n\t\t\tdescription:\n\t\t\t\t\"Execute one bounded Accessibility focus, click, type, key, or scroll action against an observed target (click also accepts screen coordinates) and return a fresh bounded observation\",\n\t\t\tparameters: Type.Object(\n\t\t\t\t{\n\t\t\t\t\tsessionId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\taction: Type.Object(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: Type.Union([\n\t\t\t\t\t\t\t\tType.Literal(\"focus\"),\n\t\t\t\t\t\t\t\tType.Literal(\"click\"),\n\t\t\t\t\t\t\t\tType.Literal(\"type\"),\n\t\t\t\t\t\t\t\tType.Literal(\"key\"),\n\t\t\t\t\t\t\t\tType.Literal(\"scroll\"),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\ttarget: Type.Union([\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"window\"),\n\t\t\t\t\t\t\t\t\t\twindowId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"control\"),\n\t\t\t\t\t\t\t\t\t\tcontrolId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\twindowId: Type.Optional(\n\t\t\t\t\t\t\t\t\t\t\tType.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"coordinates\"),\n\t\t\t\t\t\t\t\t\t\tx: Type.Integer({ minimum: 0 }),\n\t\t\t\t\t\t\t\t\t\ty: Type.Integer({ minimum: 0 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\ttext: Type.Optional(Type.String({ maxLength: DESKTOP_MAX_TYPE_TEXT_CHARS_V1 })),\n\t\t\t\t\t\t\tkey: Type.Optional(Type.String({ minLength: 1, maxLength: DESKTOP_MAX_TYPE_TEXT_CHARS_V1 })),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t),\n\t\t\t\t\tpostconditions: Type.Optional(\n\t\t\t\t\t\tType.Array(\n\t\t\t\t\t\t\tType.Union([\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"window-exists\"),\n\t\t\t\t\t\t\t\t\t\twindowId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"control-exists\"),\n\t\t\t\t\t\t\t\t\t\tcontrolId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"focused\"),\n\t\t\t\t\t\t\t\t\t\tcontrolId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"property-equals\"),\n\t\t\t\t\t\t\t\t\t\ttarget: Type.Union([\n\t\t\t\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"window\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\twindowId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"control\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontrolId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t\t\t\twindowId: Type.Optional(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tType.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\tproperty: Type.Union([\n\t\t\t\t\t\t\t\t\t\t\tType.Literal(\"enabled\"),\n\t\t\t\t\t\t\t\t\t\t\tType.Literal(\"value\"),\n\t\t\t\t\t\t\t\t\t\t\tType.Literal(\"name\"),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\texpected: Type.Union([\n\t\t\t\t\t\t\t\t\t\t\tType.Boolean(),\n\t\t\t\t\t\t\t\t\t\t\tType.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t{ maxItems: DESKTOP_MAX_POSTCONDITIONS_V1 },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t\texecute: async (first: unknown, second?: unknown, third?: unknown) => {\n\t\t\t\tconst { input, operationId } = toolInvocation(first, second);\n\t\t\t\tconst signal = signalFrom(third);\n\t\t\t\tif (signal?.aborted)\n\t\t\t\t\treturn desktopFailure(operationId, \"cancelled\", \"Desktop operation was cancelled\", \"cancelled\");\n\t\t\t\tlet request: DesktopOperationRequestV1;\n\t\t\t\ttry {\n\t\t\t\t\trequest = desktopExecuteRequest(input, operationId);\n\t\t\t\t} catch {\n\t\t\t\t\treturn desktopFailure(operationId, \"desktop_input_invalid\", \"Desktop action input is invalid\");\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst result = runtime.execute(request);\n\t\t\t\t\treturn signal?.aborted\n\t\t\t\t\t\t? desktopFailure(operationId, \"cancelled\", \"Desktop operation was cancelled\", \"cancelled\")\n\t\t\t\t\t\t: desktopExecuteResult(result, request);\n\t\t\t\t} catch {\n\t\t\t\t\treturn desktopFailure(operationId, \"desktop_adapter_failed\", \"The selected desktop adapter failed\");\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tconst replay = runtime.replay;\n\t\tif (replay === undefined) return;\n\t\tapi.registerTool({\n\t\t\tname: \"desktop_replay\",\n\t\t\tlabel: \"Replay desktop actions\",\n\t\t\tdescription:\n\t\t\t\t\"Replay a bounded sequence of desktop actions against one session; stops at the first failure, cancellation, or user-confirmation pause by default\",\n\t\t\tparameters: Type.Object(\n\t\t\t\t{\n\t\t\t\t\tsessionId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\tactions: Type.Array(\n\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: Type.Union([\n\t\t\t\t\t\t\t\t\tType.Literal(\"focus\"),\n\t\t\t\t\t\t\t\t\tType.Literal(\"click\"),\n\t\t\t\t\t\t\t\t\tType.Literal(\"type\"),\n\t\t\t\t\t\t\t\t\tType.Literal(\"key\"),\n\t\t\t\t\t\t\t\t\tType.Literal(\"scroll\"),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\ttarget: Type.Union([\n\t\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"window\"),\n\t\t\t\t\t\t\t\t\t\t\twindowId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"control\"),\n\t\t\t\t\t\t\t\t\t\t\tcontrolId: Type.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t\twindowId: Type.Optional(\n\t\t\t\t\t\t\t\t\t\t\t\tType.String({ minLength: 1, maxLength: DESKTOP_MAX_STRING_CHARS_V1 }),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tType.Object(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tkind: Type.Literal(\"coordinates\"),\n\t\t\t\t\t\t\t\t\t\t\tx: Type.Integer({ minimum: 0 }),\n\t\t\t\t\t\t\t\t\t\t\ty: Type.Integer({ minimum: 0 }),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\ttext: Type.Optional(Type.String({ maxLength: DESKTOP_MAX_TYPE_TEXT_CHARS_V1 })),\n\t\t\t\t\t\t\t\tkey: Type.Optional(Type.String({ minLength: 1, maxLength: DESKTOP_MAX_TYPE_TEXT_CHARS_V1 })),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ minItems: 1, maxItems: DESKTOP_MAX_REPLAY_ACTIONS_V1 },\n\t\t\t\t\t),\n\t\t\t\t\tstopOnFailure: Type.Optional(Type.Boolean()),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t\texecute: async (first: unknown, second?: unknown, third?: unknown) => {\n\t\t\t\tconst { input, operationId } = toolInvocation(first, second);\n\t\t\t\tconst signal = signalFrom(third);\n\t\t\t\tif (signal?.aborted)\n\t\t\t\t\treturn desktopFailure(operationId, \"cancelled\", \"Desktop operation was cancelled\", \"cancelled\");\n\t\t\t\tlet request: DesktopReplayRequestV1;\n\t\t\t\ttry {\n\t\t\t\t\trequest = desktopReplayRequest(input, operationId);\n\t\t\t\t} catch {\n\t\t\t\t\treturn desktopFailure(operationId, \"desktop_input_invalid\", \"Desktop replay input is invalid\");\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst result = replay(request);\n\t\t\t\t\treturn signal?.aborted\n\t\t\t\t\t\t? desktopFailure(operationId, \"cancelled\", \"Desktop operation was cancelled\", \"cancelled\")\n\t\t\t\t\t\t: desktopReplayResult(result, operationId);\n\t\t\t\t} catch {\n\t\t\t\t\treturn desktopFailure(operationId, \"desktop_adapter_failed\", \"The selected desktop adapter failed\");\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.
3
+ *
4
+ * The adapter is the production input facade: one `DesktopMacosInputAdapter`
5
+ * over the default `MacosAccessibilityDriver` (osascript, 15s timeout,
6
+ * `process.platform`), the same default construction the Windows package's
7
+ * entry uses. It deliberately exposes no replay method, so only
8
+ * `desktop_execute` registers; hosts that want replay inject their own
9
+ * adapter through the library surface. Non-macOS platforms never throw at
10
+ * import or call time: the driver probe reports unavailable and tools return
11
+ * explicit `unsupported` results. A readonly host mode registers no input
12
+ * tools at all.
13
+ */
14
+ declare const _default: import("@agent-forge/plugin-sdk").CapabilityPluginSyncFactory;
15
+ export default _default;
16
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;;AACH,wBAAqF","sourcesContent":["import { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nimport { DesktopMacosInputAdapter } from \"./macos-ax-adapter.ts\";\n\n/**\n * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.\n *\n * The adapter is the production input facade: one `DesktopMacosInputAdapter`\n * over the default `MacosAccessibilityDriver` (osascript, 15s timeout,\n * `process.platform`), the same default construction the Windows package's\n * entry uses. It deliberately exposes no replay method, so only\n * `desktop_execute` registers; hosts that want replay inject their own\n * adapter through the library surface. Non-macOS platforms never throw at\n * import or call time: the driver probe reports unavailable and tools return\n * explicit `unsupported` results. A readonly host mode registers no input\n * tools at all.\n */\nexport default createDesktopInputCapabilityFactoryV1(new DesktopMacosInputAdapter());\n"]}
package/dist/entry.js ADDED
@@ -0,0 +1,17 @@
1
+ import { createDesktopInputCapabilityFactoryV1 } from "./capability.js";
2
+ import { DesktopMacosInputAdapter } from "./macos-ax-adapter.js";
3
+ /**
4
+ * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.
5
+ *
6
+ * The adapter is the production input facade: one `DesktopMacosInputAdapter`
7
+ * over the default `MacosAccessibilityDriver` (osascript, 15s timeout,
8
+ * `process.platform`), the same default construction the Windows package's
9
+ * entry uses. It deliberately exposes no replay method, so only
10
+ * `desktop_execute` registers; hosts that want replay inject their own
11
+ * adapter through the library surface. Non-macOS platforms never throw at
12
+ * import or call time: the driver probe reports unavailable and tools return
13
+ * explicit `unsupported` results. A readonly host mode registers no input
14
+ * tools at all.
15
+ */
16
+ export default createDesktopInputCapabilityFactoryV1(new DesktopMacosInputAdapter());
17
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAe,qCAAqC,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["import { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nimport { DesktopMacosInputAdapter } from \"./macos-ax-adapter.ts\";\n\n/**\n * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.\n *\n * The adapter is the production input facade: one `DesktopMacosInputAdapter`\n * over the default `MacosAccessibilityDriver` (osascript, 15s timeout,\n * `process.platform`), the same default construction the Windows package's\n * entry uses. It deliberately exposes no replay method, so only\n * `desktop_execute` registers; hosts that want replay inject their own\n * adapter through the library surface. Non-macOS platforms never throw at\n * import or call time: the driver probe reports unavailable and tools return\n * explicit `unsupported` results. A readonly host mode registers no input\n * tools at all.\n */\nexport default createDesktopInputCapabilityFactoryV1(new DesktopMacosInputAdapter());\n"]}
@@ -0,0 +1,6 @@
1
+ export { createDesktopInputCapabilityFactoryV1 } from "./capability.ts";
2
+ export type { MacosAccessibilityDriverOptions } from "./macos-ax-adapter.ts";
3
+ export { DesktopMacosInputAdapter, MacosAccessibilityDriver } from "./macos-ax-adapter.ts";
4
+ export { DESKTOP_MAX_POSTCONDITIONS_V1, DESKTOP_MAX_REPLAY_ACTIONS_V1, DESKTOP_MAX_STRING_CHARS_V1, DESKTOP_MAX_TYPE_TEXT_CHARS_V1, desktopBoundedString, desktopClampedString, desktopFailure, desktopRequiredString, desktopResultWithinBudget, projectDesktopObservation, } from "./projection.ts";
5
+ export type * from "./types.ts";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,iBAAiB,CAAC;AACxE,YAAY,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,iBAAiB,CAAC;AACzB,mBAAmB,YAAY,CAAC","sourcesContent":["export { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nexport type { MacosAccessibilityDriverOptions } from \"./macos-ax-adapter.ts\";\nexport { DesktopMacosInputAdapter, MacosAccessibilityDriver } from \"./macos-ax-adapter.ts\";\nexport {\n\tDESKTOP_MAX_POSTCONDITIONS_V1,\n\tDESKTOP_MAX_REPLAY_ACTIONS_V1,\n\tDESKTOP_MAX_STRING_CHARS_V1,\n\tDESKTOP_MAX_TYPE_TEXT_CHARS_V1,\n\tdesktopBoundedString,\n\tdesktopClampedString,\n\tdesktopFailure,\n\tdesktopRequiredString,\n\tdesktopResultWithinBudget,\n\tprojectDesktopObservation,\n} from \"./projection.ts\";\nexport type * from \"./types.ts\";\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { createDesktopInputCapabilityFactoryV1 } from "./capability.js";
2
+ export { DesktopMacosInputAdapter, MacosAccessibilityDriver } from "./macos-ax-adapter.js";
3
+ export { DESKTOP_MAX_POSTCONDITIONS_V1, DESKTOP_MAX_REPLAY_ACTIONS_V1, DESKTOP_MAX_STRING_CHARS_V1, DESKTOP_MAX_TYPE_TEXT_CHARS_V1, desktopBoundedString, desktopClampedString, desktopFailure, desktopRequiredString, desktopResultWithinBudget, projectDesktopObservation, } from "./projection.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,iBAAiB,CAAC","sourcesContent":["export { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nexport type { MacosAccessibilityDriverOptions } from \"./macos-ax-adapter.ts\";\nexport { DesktopMacosInputAdapter, MacosAccessibilityDriver } from \"./macos-ax-adapter.ts\";\nexport {\n\tDESKTOP_MAX_POSTCONDITIONS_V1,\n\tDESKTOP_MAX_REPLAY_ACTIONS_V1,\n\tDESKTOP_MAX_STRING_CHARS_V1,\n\tDESKTOP_MAX_TYPE_TEXT_CHARS_V1,\n\tdesktopBoundedString,\n\tdesktopClampedString,\n\tdesktopFailure,\n\tdesktopRequiredString,\n\tdesktopResultWithinBudget,\n\tprojectDesktopObservation,\n} from \"./projection.ts\";\nexport type * from \"./types.ts\";\n"]}
@@ -0,0 +1,72 @@
1
+ import type { DesktopFullControlAdapterV1, DesktopMacosDriverV1, DesktopMacosProbeV1, DesktopObservationV1, DesktopOperationRequestV1, DesktopOperationResultV1, DesktopSessionRequestV1, DesktopSessionResultV1, DesktopSessionV1 } from "./types.ts";
2
+ type MacosSpawnResult = {
3
+ readonly error?: Error;
4
+ readonly status: number | null;
5
+ readonly stdout: string;
6
+ readonly stderr?: string;
7
+ };
8
+ type MacosSpawn = (command: string, args: readonly string[], options: {
9
+ readonly encoding: "utf8";
10
+ readonly timeout: number;
11
+ readonly windowsHide: boolean;
12
+ readonly env: NodeJS.ProcessEnv;
13
+ }) => MacosSpawnResult;
14
+ export interface MacosAccessibilityDriverOptions {
15
+ /** Override the osascript executable for a brokered host or test harness. */
16
+ readonly command?: string;
17
+ readonly timeoutMs?: number;
18
+ /** Injectable host boundary for deterministic tests and brokered deployments. */
19
+ readonly spawnSync?: MacosSpawn;
20
+ /** Override the platform reported to the driver; intended for host adapters/tests. */
21
+ readonly platform?: NodeJS.Platform;
22
+ }
23
+ export declare class MacosAccessibilityDriver implements DesktopMacosDriverV1 {
24
+ readonly driverId = "macos-ax";
25
+ readonly driverVersion = "1.0.0";
26
+ private readonly command;
27
+ private readonly timeoutMs;
28
+ private readonly platform;
29
+ private readonly spawn;
30
+ private readonly sessions;
31
+ private readonly targets;
32
+ private readonly sessionTargetKeys;
33
+ private readonly latestObservationIds;
34
+ private readonly observedSessions;
35
+ private nextSessionId;
36
+ private nextObservationId;
37
+ constructor(options?: MacosAccessibilityDriverOptions);
38
+ probe(): DesktopMacosProbeV1;
39
+ openSession(request: DesktopSessionRequestV1): DesktopSessionResultV1;
40
+ observe(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1;
41
+ execute(request: DesktopOperationRequestV1): DesktopOperationResultV1;
42
+ stop(sessionId: string): DesktopSessionV1 | DesktopOperationResultV1;
43
+ private actionPayload;
44
+ private run;
45
+ private toObservation;
46
+ private resolveTarget;
47
+ private targetKey;
48
+ private invalidateObservation;
49
+ private verifyPostconditions;
50
+ private checkPostcondition;
51
+ private failed;
52
+ private cancelled;
53
+ }
54
+ /**
55
+ * The production input facade intentionally exposes no replay method. The
56
+ * driver remains responsible for using observed Accessibility identities
57
+ * (or explicit click coordinates) rather than global keyboard injection.
58
+ */
59
+ export declare class DesktopMacosInputAdapter implements DesktopFullControlAdapterV1 {
60
+ readonly adapterId = "desktop-macos-ax";
61
+ readonly adapterVersion = "1.0.0";
62
+ private readonly driver;
63
+ constructor(driver?: DesktopMacosDriverV1);
64
+ probe(): DesktopMacosProbeV1;
65
+ openSession(request: DesktopSessionRequestV1): DesktopSessionResultV1;
66
+ observe(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1;
67
+ reobserve(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1;
68
+ execute(request: DesktopOperationRequestV1): DesktopOperationResultV1;
69
+ stop(sessionId: string): DesktopSessionV1 | DesktopOperationResultV1;
70
+ }
71
+ export {};
72
+ //# sourceMappingURL=macos-ax-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macos-ax-adapter.d.ts","sourceRoot":"","sources":["../src/macos-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WAAW,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAEpE;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,GAAG,wBAAwB,CAE1E;IAED,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,GAAG,wBAAwB,CAE5E;IAED,OAAO,CAAC,OAAO,EAAE,yBAAyB,GAAG,wBAAwB,CAgBpE;IAED,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,wBAAwB,CAEnE;CACD","sourcesContent":["/**\n * macOS Accessibility driver (query + bounded input actions) and the input\n * adapter facade for this package. Structurally mirrors the Windows package's\n * `windows-uia-adapter.ts` + `windows-input-adapter.ts` (inlined from\n * agent-forge `src/plugins/desktop/*`, D-075 S3) with these deliberate\n * differences:\n * - Driver boundary is `osascript -l JavaScript -e <script>` (JXA) instead of\n * PowerShell UIA. The query script walks the System Events accessibility\n * tree (`Application(\"com.apple.systemevents\")`); the action script re-locates the\n * observed target by its deterministic enumeration identity\n * (`window-<pid>-<windowIndex>` / `<windowId>:<role>:<childIndex>`; Windows\n * uses native HWND handles instead — mac AX exposes no stable handles).\n * - Bounded actions: focus (frontmost + AXRaise / AXFocused), click\n * (AXPress with a CGEvent coordinate-click fallback, plus screen-coordinate\n * click targets — click-only by ruling), type (focus + System Events\n * keystroke), key (System Events keyCode/keystroke over a minimal SendKeys\n * aligned table, parsed host-side), scroll (CGEvent scroll wheel).\n * - The facade exposes no replay method (this package ships no replay);\n * sensitive actions stay behind the shared `requiresDesktopUserConfirmation`\n * fail-closed gate.\n * - Non-darwin platforms never throw at import or call time: probe reports\n * `{available:false, reason:\"macOS Accessibility requires darwin\"}` and\n * every tool returns an explicit `unsupported` result. Missing\n * Accessibility (assistive access) permission is reported fail-closed as\n * `accessibility-permission-required`; no degraded mode.\n * This file is a deliberate copy shared (not imported) with the observe\n * package's adapter; the observe copy carries the query script only.\n */\nimport { spawnSync as nodeSpawnSync } from \"node:child_process\";\nimport { detachedFreeze } from \"@agent-forge/plugin-sdk\";\nimport type {\n\tDesktopActionV1,\n\tDesktopCapabilityIdV1,\n\tDesktopControlIdentityV1,\n\tDesktopErrorV1,\n\tDesktopFullControlAdapterV1,\n\tDesktopMacosDriverV1,\n\tDesktopMacosProbeV1,\n\tDesktopObservationV1,\n\tDesktopOperationRequestV1,\n\tDesktopOperationResultV1,\n\tDesktopPostconditionV1,\n\tDesktopSessionRequestV1,\n\tDesktopSessionResultV1,\n\tDesktopSessionV1,\n\tDesktopTargetRefV1,\n\tDesktopVerificationV1,\n\tDesktopWindowIdentityV1,\n} from \"./types.ts\";\nimport { requiresDesktopUserConfirmation } from \"./types.ts\";\n\ntype RawWindow = {\n\tid?: string;\n\tprocessId?: number;\n\tprocessName?: string;\n\tname?: string;\n\tx?: number;\n\ty?: number;\n\twidth?: number;\n\theight?: number;\n};\ntype RawControl = {\n\twindowId?: string;\n\tcontrolId?: string;\n\trole?: string;\n\tname?: string;\n\tenabled?: boolean;\n\tvalue?: string;\n\tx?: number;\n\ty?: number;\n\twidth?: number;\n\theight?: number;\n};\ntype RawSnapshot = {\n\tavailable?: boolean;\n\treason?: string;\n\twindows?: RawWindow[];\n\tcontrols?: RawControl[];\n\tfocusedControlId?: string;\n};\n\ntype MacosSpawnResult = {\n\treadonly error?: Error;\n\treadonly status: number | null;\n\treadonly stdout: string;\n\treadonly stderr?: string;\n};\n\ntype MacosSpawn = (\n\tcommand: string,\n\targs: readonly string[],\n\toptions: {\n\t\treadonly encoding: \"utf8\";\n\t\treadonly timeout: number;\n\t\treadonly windowsHide: boolean;\n\t\treadonly env: NodeJS.ProcessEnv;\n\t},\n) => MacosSpawnResult;\n\nexport interface MacosAccessibilityDriverOptions {\n\t/** Override the osascript executable for a brokered host or test harness. */\n\treadonly command?: string;\n\treadonly timeoutMs?: number;\n\t/** Injectable host boundary for deterministic tests and brokered deployments. */\n\treadonly spawnSync?: MacosSpawn;\n\t/** Override the platform reported to the driver; intended for host adapters/tests. */\n\treadonly platform?: NodeJS.Platform;\n}\n\nconst READONLY_CAPABILITIES: readonly DesktopCapabilityIdV1[] = [\"desktop-session\", \"desktop-uia\", \"desktop-input\"];\nconst SUPPORTED_ACTIONS: readonly DesktopActionV1[\"kind\"][] = [\"focus\", \"click\", \"type\", \"key\", \"scroll\"];\n\nconst error = (code: string, message: string, causeCode?: string): DesktopErrorV1 => ({\n\tversion: 1,\n\tcode,\n\tmessage,\n\t...(causeCode === undefined ? {} : { causeCode }),\n});\n\nconst unsupported = (\n\toperationId: string,\n\treason: string,\n\tcauseCode = \"platform-unavailable\",\n): DesktopOperationResultV1 => ({\n\tversion: 1,\n\toperationId,\n\tstatus: \"unsupported\",\n\tsummary: reason,\n\terror: error(causeCode === \"action-unsupported\" ? \"action_unsupported\" : \"platform_unavailable\", reason, causeCode),\n});\n\nconst rectangle = (raw: { x?: number; y?: number; width?: number; height?: number }) => ({\n\tx: Number.isFinite(raw.x) ? Number(raw.x) : 0,\n\ty: Number.isFinite(raw.y) ? Number(raw.y) : 0,\n\twidth: Number.isFinite(raw.width) ? Number(raw.width) : 0,\n\theight: Number.isFinite(raw.height) ? Number(raw.height) : 0,\n});\n\nconst isPermissionReason = (value: string): boolean =>\n\t/assistive access|not authorized|accessibility-permission-required/i.test(value);\n\n/**\n * JXA observation script. Enumerates every non-background System Events\n * process's windows (caps: 64 windows, 256 controls total, mirroring the\n * projection budgets) with role/name/position/size/enabled/value per control,\n * plus the frontmost process's focused element matched by role and frame.\n * Permission or automation failures are reported in-band as\n * `{available:false, reason:...}` so the probe can classify them; the reason\n * literal `accessibility-permission-required` is reserved for missing\n * Accessibility (assistive access) grants.\n */\nconst QUERY_SCRIPT = `\nvar se = Application('com.apple.systemevents');\nfunction safe(fn) { try { return fn(); } catch (e) { return undefined; } }\nfunction rectOf(el) {\n var p = safe(function() { return el.position(); });\n var z = safe(function() { return el.size(); });\n if (p === undefined || z === undefined || p.length < 2 || z.length < 2) return {x: 0, y: 0, width: 0, height: 0};\n return {x: Math.round(p[0]), y: Math.round(p[1]), width: Math.round(z[0]), height: Math.round(z[1])};\n}\nfunction axReason(e) {\n var msg = String(e && e.message !== undefined ? e.message : e);\n var num = e && typeof e.errorNumber === 'number' ? e.errorNumber : 0;\n if (msg.indexOf('assistive access') !== -1 || msg.indexOf('not authorized') !== -1 ||\n num === -25211 || num === -1719 || num === -1743) return 'accessibility-permission-required';\n return msg;\n}\ntry {\n var out = {available: true, windows: [], controls: [], focusedControlId: null};\n var procs = se.processes();\n var focused = null;\n for (var fi = 0; fi < procs.length; fi++) {\n var fp = procs[fi];\n if (safe(function() { return fp.frontmost(); }) !== true) continue;\n var fe = safe(function() { return fp.attributes['AXFocusedUIElement'].value(); });\n if (fe !== undefined) focused = {role: safe(function() { return fe.role(); }), rect: rectOf(fe)};\n break;\n }\n var windowCount = 0;\n var controlCount = 0;\n for (var pi = 0; pi < procs.length && windowCount < 64; pi++) {\n var proc = procs[pi];\n if (safe(function() { return proc.backgroundOnly(); }) === true) continue;\n var wins = safe(function() { return proc.windows(); });\n if (wins === undefined || wins.length === 0) continue;\n var pid = safe(function() { return proc.unixId(); });\n var pname = safe(function() { return proc.name(); });\n if (typeof pname !== 'string' || pname.length === 0) pname = 'unknown';\n for (var wi = 0; wi < wins.length && windowCount < 64; wi++) {\n var win = wins[wi];\n var winRect = rectOf(win);\n var winId = 'window-' + pid + '-' + wi;\n windowCount++;\n out.windows.push({id: winId, processId: pid, processName: pname,\n name: safe(function() { return win.name(); }) || '', x: winRect.x, y: winRect.y,\n width: winRect.width, height: winRect.height});\n var contents = safe(function() { return win.entireContents(); });\n if (contents === undefined) continue;\n for (var ci = 0; ci < contents.length && controlCount < 256; ci++) {\n var el = contents[ci];\n var role = safe(function() { return el.role(); });\n if (typeof role !== 'string' || role.length === 0) continue;\n var r = rectOf(el);\n var controlId = winId + ':' + role + ':' + ci;\n var value = safe(function() { return el.value(); });\n out.controls.push({windowId: winId, controlId: controlId, role: role,\n name: safe(function() { return el.name(); }) || safe(function() { return el.title(); }) || '',\n enabled: safe(function() { return el.enabled(); }) !== false,\n value: typeof value === 'string' && value.length > 0 ? value : undefined,\n x: r.x, y: r.y, width: r.width, height: r.height});\n controlCount++;\n if (focused !== null && out.focusedControlId === null && role === focused.role &&\n r.x === focused.rect.x && r.y === focused.rect.y &&\n r.width === focused.rect.width && r.height === focused.rect.height) {\n out.focusedControlId = controlId;\n }\n }\n }\n }\n JSON.stringify(out);\n} catch (e) {\n JSON.stringify({available: false, reason: axReason(e)});\n}`;\n\n/**\n * JXA bounded-input script. Reads the JSON payload from\n * `AGENT_FORGE_MACOS_AX_INPUT`: `{kind, target:{windowId?, controlId?,\n * coordinates?}, text?, key:{keyCode?, text?, modifiers?},\n * scroll:{up, lines}}`. The target is re-located through the same\n * deterministic enumeration the query script used; an unfound identity is a\n * stale target. Output: `{ok:true}` or `{ok:false, code, reason}`.\n */\nconst ACTION_SCRIPT = `\nObjC.import('CoreGraphics');\nvar se = Application('com.apple.systemevents');\nfunction safe(fn) { try { return fn(); } catch (e) { return undefined; } }\nfunction rectOf(el) {\n var p = safe(function() { return el.position(); });\n var z = safe(function() { return el.size(); });\n if (p === undefined || z === undefined || p.length < 2 || z.length < 2) return {x: 0, y: 0, width: 0, height: 0};\n return {x: Math.round(p[0]), y: Math.round(p[1]), width: Math.round(z[0]), height: Math.round(z[1])};\n}\nfunction findProcess(pid) {\n var procs = se.processes();\n for (var i = 0; i < procs.length; i++) {\n if (safe(function() { return procs[i].unixId(); }) === pid) return procs[i];\n }\n return undefined;\n}\nfunction parseWindowId(windowId) {\n var m = /^window-(\\\\d+)-(\\\\d+)$/.exec(String(windowId));\n return m === null ? undefined : {pid: Number(m[1]), index: Number(m[2])};\n}\nfunction findWindow(windowId) {\n var parsed = parseWindowId(windowId);\n if (parsed === undefined) return undefined;\n var proc = findProcess(parsed.pid);\n if (proc === undefined) return undefined;\n var wins = safe(function() { return proc.windows(); });\n if (wins === undefined || parsed.index >= wins.length) return undefined;\n return {proc: proc, win: wins[parsed.index]};\n}\nfunction findControl(windowId, controlId) {\n var located = findWindow(windowId);\n if (located === undefined) return undefined;\n var parts = String(controlId).split(':');\n if (parts.length < 3) return undefined;\n var index = Number(parts[parts.length - 1]);\n var role = parts[parts.length - 2];\n var contents = safe(function() { return located.win.entireContents(); });\n if (contents === undefined || index >= contents.length) return undefined;\n var el = contents[index];\n if (safe(function() { return el.role(); }) !== role) return undefined;\n return {proc: located.proc, win: located.win, el: el};\n}\nfunction cgClick(x, y) {\n var pt = {x: x, y: y};\n var move = $.CGEventCreateMouseEvent($(), $.kCGEventMouseMoved, pt, $.kCGMouseButtonLeft);\n $.CGEventPost($.kCGHIDEventTap, move);\n var down = $.CGEventCreateMouseEvent($(), $.kCGEventLeftMouseDown, pt, $.kCGMouseButtonLeft);\n $.CGEventPost($.kCGHIDEventTap, down);\n var up = $.CGEventCreateMouseEvent($(), $.kCGEventLeftMouseUp, pt, $.kCGMouseButtonLeft);\n $.CGEventPost($.kCGHIDEventTap, up);\n}\nfunction cgScroll(x, y, lines, up) {\n var pt = {x: x, y: y};\n var move = $.CGEventCreateMouseEvent($(), $.kCGEventMouseMoved, pt, $.kCGMouseButtonLeft);\n $.CGEventPost($.kCGHIDEventTap, move);\n var ev = $.CGEventCreateScrollWheelEvent($(), $.kCGScrollEventUnitLine, 1, up ? lines : -lines);\n $.CGEventPost($.kCGHIDEventTap, ev);\n}\nfunction setFocused(el) {\n try { el.focused = true; return true; } catch (e) { return false; }\n}\ntry {\n var payload = JSON.parse($.NSProcessInfo.processInfo.environment.objectForKey('AGENT_FORGE_MACOS_AX_INPUT').js);\n var target = payload.target || {};\n var el = undefined;\n var win = undefined;\n var proc = undefined;\n if (target.windowId !== undefined && target.controlId !== undefined) {\n var control = findControl(target.windowId, target.controlId);\n if (control === undefined) throw {stale: true};\n el = control.el; win = control.win; proc = control.proc;\n } else if (target.windowId !== undefined) {\n var located = findWindow(target.windowId);\n if (located === undefined) throw {stale: true};\n win = located.win; proc = located.proc;\n }\n if (payload.kind === 'focus') {\n if (el !== undefined) {\n if (!setFocused(el)) throw {reason: 'focus_failed'};\n } else if (win !== undefined) {\n try { proc.frontmost = true; } catch (e) {}\n if (safe(function() { return win.actions['AXRaise'].perform(); }) === undefined && safe(function() { return proc.frontmost(); }) !== true) {\n throw {reason: 'focus_failed'};\n }\n } else {\n throw {reason: 'ax_action_exception'};\n }\n } else if (payload.kind === 'click') {\n if (target.coordinates !== undefined) {\n cgClick(Number(target.coordinates.x), Number(target.coordinates.y));\n } else if (el !== undefined) {\n var performed = false;\n try { el.actions['AXPress'].perform(); performed = true; } catch (e) {}\n if (!performed) {\n var r = rectOf(el);\n if (r.width <= 0 && r.height <= 0) throw {reason: 'press_unavailable'};\n cgClick(r.x + Math.floor(r.width / 2), r.y + Math.floor(r.height / 2));\n }\n } else if (win !== undefined) {\n var wr = rectOf(win);\n cgClick(wr.x + Math.floor(wr.width / 2), wr.y + Math.floor(wr.height / 2));\n } else {\n throw {reason: 'ax_action_exception'};\n }\n } else if (payload.kind === 'type') {\n if (el !== undefined && !setFocused(el)) throw {reason: 'focus_failed'};\n if (el === undefined && win !== undefined) {\n try { proc.frontmost = true; } catch (e) {}\n }\n se.keystroke(String(payload.text));\n } else if (payload.kind === 'key') {\n if (el !== undefined && !setFocused(el)) throw {reason: 'focus_failed'};\n var using = Array.isArray(payload.key.modifiers) && payload.key.modifiers.length > 0 ? {using: payload.key.modifiers} : {};\n if (typeof payload.key.keyCode === 'number') {\n se.keyCode(payload.key.keyCode, using);\n } else {\n se.keystroke(String(payload.key.text), using);\n }\n } else if (payload.kind === 'scroll') {\n var center = target.coordinates !== undefined\n ? {x: Number(target.coordinates.x), y: Number(target.coordinates.y)}\n : (el !== undefined ? rectOf(el) : (win !== undefined ? rectOf(win) : {x: 0, y: 0, width: 0, height: 0}));\n cgScroll(center.x + Math.floor((center.width || 0) / 2), center.y + Math.floor((center.height || 0) / 2),\n Number(payload.scroll.lines), payload.scroll.up === true);\n } else {\n throw {reason: 'ax_action_exception'};\n }\n JSON.stringify({ok: true});\n} catch (e) {\n if (e && e.stale === true) {\n JSON.stringify({ok: false, code: 'stale_target', reason: 'ax_action_exception'});\n } else {\n var reason = e && typeof e.reason === 'string' ? e.reason : 'ax_action_exception';\n JSON.stringify({ok: false, code: 'action_failed', reason: reason});\n }\n}`;\n\nconst parseJson = (stdout: string): Record<string, unknown> | undefined => {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(stdout.trim());\n\t\treturn typeof parsed === \"object\" && parsed !== null ? (parsed as Record<string, unknown>) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Minimal SendKeys-aligned key grammar, parsed host-side because JXA has no\n * SendKeys equivalent. Grammar: optional modifier prefixes (`+` shift,\n * `^` control, `%` option — the Windows SendKeys mapping) followed by either\n * one `{NAME}` special key or exactly one literal character.\n */\nconst MAC_KEY_CODES: Readonly<Record<string, number>> = Object.freeze({\n\tRETURN: 36,\n\tENTER: 36,\n\tTAB: 48,\n\tESC: 53,\n\tESCAPE: 53,\n\tDEL: 117,\n\tDELETE: 117,\n\tBS: 51,\n\tBKSP: 51,\n\tBACKSPACE: 51,\n\tUP: 126,\n\tDOWN: 125,\n\tLEFT: 123,\n\tRIGHT: 124,\n\tHOME: 115,\n\tEND: 119,\n\tPGUP: 116,\n\tPAGEUP: 116,\n\tPGDN: 121,\n\tPAGEDOWN: 121,\n\tSPACE: 49,\n\tF1: 122,\n\tF2: 120,\n\tF3: 99,\n\tF4: 118,\n\tF5: 96,\n\tF6: 97,\n\tF7: 98,\n\tF8: 100,\n\tF9: 101,\n\tF10: 109,\n\tF11: 103,\n\tF12: 111,\n});\n\ntype MacosKeyStroke = {\n\treadonly keyCode?: number;\n\treadonly text?: string;\n\treadonly modifiers?: readonly string[];\n};\n\nconst parseMacKey = (key: string): MacosKeyStroke | undefined => {\n\tconst modifiers: string[] = [];\n\tlet index = 0;\n\tfor (; index < key.length; index += 1) {\n\t\tconst modifier = key[index];\n\t\tif (modifier === \"+\") modifiers.push(\"shift down\");\n\t\telse if (modifier === \"^\") modifiers.push(\"control down\");\n\t\telse if (modifier === \"%\") modifiers.push(\"option down\");\n\t\telse break;\n\t}\n\tconst unit = key.slice(index);\n\tconst braced = /^\\{([A-Z0-9]+)\\}$/.exec(unit);\n\tif (braced !== null) {\n\t\tconst keyCode = MAC_KEY_CODES[braced[1] ?? \"\"];\n\t\tif (keyCode === undefined) return undefined;\n\t\treturn { keyCode, ...(modifiers.length === 0 ? {} : { modifiers }) };\n\t}\n\tif (unit.length !== 1) return undefined;\n\treturn { text: unit, ...(modifiers.length === 0 ? {} : { modifiers }) };\n};\n\nconst parseMacScroll = (text: string): { readonly up: boolean; readonly lines: number } | undefined => {\n\tconst match = /^(up|down)(?::(\\d+))?$/.exec(text);\n\tif (match === null) return undefined;\n\tconst lines = match[2] === undefined ? 3 : Number(match[2]);\n\tif (lines < 1 || lines > 100) return undefined;\n\treturn { up: match[1] === \"up\", lines };\n};\n\nexport class MacosAccessibilityDriver implements DesktopMacosDriverV1 {\n\treadonly driverId = \"macos-ax\";\n\treadonly driverVersion = \"1.0.0\";\n\tprivate readonly command: string;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly platform: NodeJS.Platform;\n\tprivate readonly spawn: MacosSpawn;\n\tprivate readonly sessions = new Map<string, DesktopSessionV1>();\n\tprivate readonly targets = new Map<\n\t\tstring,\n\t\t{\n\t\t\treadonly sessionId: string;\n\t\t\treadonly observationId: string;\n\t\t\treadonly windowId: string;\n\t\t\treadonly controlId?: string;\n\t\t}\n\t>();\n\tprivate readonly sessionTargetKeys = new Map<string, Set<string>>();\n\tprivate readonly latestObservationIds = new Map<string, string>();\n\tprivate readonly observedSessions = new Set<string>();\n\tprivate nextSessionId = 1;\n\tprivate nextObservationId = 1;\n\n\tconstructor(options: MacosAccessibilityDriverOptions = {}) {\n\t\tthis.command = options.command ?? \"osascript\";\n\t\t// 60s: Apple events from an SSH (Background launchd) session run ~100x\n\t\t// slower than a GUI session — one full enumeration measured 38s there;\n\t\t// GUI sessions complete in seconds and stay unaffected by the raise.\n\t\tthis.timeoutMs = options.timeoutMs ?? 60_000;\n\t\tthis.platform = options.platform ?? process.platform;\n\t\tthis.spawn =\n\t\t\toptions.spawnSync ??\n\t\t\t((command, args, spawnOptions) => nodeSpawnSync(command, args, spawnOptions) as unknown as MacosSpawnResult);\n\t}\n\n\tprobe(): DesktopMacosProbeV1 {\n\t\tif (this.platform !== \"darwin\") {\n\t\t\treturn {\n\t\t\t\tavailable: false,\n\t\t\t\tplatform: this.platform,\n\t\t\t\tdriver: \"macos-ax\",\n\t\t\t\treason: \"macOS Accessibility requires darwin\",\n\t\t\t};\n\t\t}\n\t\tconst run = this.run(QUERY_SCRIPT);\n\t\tif (run === undefined)\n\t\t\treturn {\n\t\t\t\tavailable: false,\n\t\t\t\tplatform: this.platform,\n\t\t\t\tdriver: \"macos-ax\",\n\t\t\t\treason: \"macOS Accessibility requires darwin\",\n\t\t\t};\n\t\tif (run.failed)\n\t\t\treturn {\n\t\t\t\tavailable: false,\n\t\t\t\tplatform: this.platform,\n\t\t\t\tdriver: \"macos-ax\",\n\t\t\t\treason: isPermissionReason(run.stderr) ? \"accessibility-permission-required\" : \"osascript is unavailable\",\n\t\t\t};\n\t\tconst raw = parseJson(run.stdout);\n\t\tif (raw === undefined)\n\t\t\treturn {\n\t\t\t\tavailable: false,\n\t\t\t\tplatform: this.platform,\n\t\t\t\tdriver: \"macos-ax\",\n\t\t\t\treason: \"osascript is unavailable\",\n\t\t\t};\n\t\tif (raw.available === true)\n\t\t\treturn {\n\t\t\t\tavailable: true,\n\t\t\t\tplatform: this.platform,\n\t\t\t\tdriver: \"macos-ax\",\n\t\t\t\tcapabilities: READONLY_CAPABILITIES,\n\t\t\t};\n\t\tconst reason =\n\t\t\ttypeof raw.reason === \"string\" && raw.reason.trim() !== \"\" ? raw.reason : \"macOS Accessibility probe failed\";\n\t\treturn { available: false, platform: this.platform, driver: \"macos-ax\", reason };\n\t}\n\n\topenSession(request: DesktopSessionRequestV1): DesktopSessionResultV1 {\n\t\tconst probe = this.probe();\n\t\tif (!probe.available)\n\t\t\treturn {\n\t\t\t\tstatus: \"unsupported\",\n\t\t\t\terror: error(\n\t\t\t\t\t\"platform_unavailable\",\n\t\t\t\t\tprobe.reason ?? \"macOS Accessibility is unavailable\",\n\t\t\t\t\t\"platform-unavailable\",\n\t\t\t\t),\n\t\t\t};\n\t\tconst session = detachedFreeze({\n\t\t\tversion: 1 as const,\n\t\t\tsessionId: `desktop-macos-session-${this.nextSessionId++}`,\n\t\t\tisolation: request.isolation,\n\t\t\tstatus: \"ready\" as const,\n\t\t\t...(request.applicationId === undefined ? {} : { applicationId: request.applicationId }),\n\t\t});\n\t\tthis.sessions.set(session.sessionId, session);\n\t\treturn { status: \"succeeded\", session };\n\t}\n\n\tobserve(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1 {\n\t\tconst session = this.sessions.get(sessionId);\n\t\tif (session === undefined) return this.failed(\"observe\", \"session_not_found\", \"Session does not exist\");\n\t\tif (session.status === \"stopped\") return this.cancelled(\"observe\", \"Session has been stopped\");\n\t\tconst run = this.run(QUERY_SCRIPT);\n\t\tconst raw = run === undefined || run.failed ? undefined : parseJson(run.stdout);\n\t\tif (raw === undefined || raw.available !== true) {\n\t\t\tthis.invalidateObservation(sessionId);\n\t\t\treturn unsupported(\"observe\", \"macOS Accessibility observation failed\");\n\t\t}\n\t\treturn this.toObservation(session, raw as unknown as RawSnapshot);\n\t}\n\n\texecute(request: DesktopOperationRequestV1): DesktopOperationResultV1 {\n\t\tconst session = this.sessions.get(request.sessionId);\n\t\tif (session === undefined) return this.failed(request.operationId, \"session_not_found\", \"Session does not exist\");\n\t\tif (session.status === \"stopped\") return this.cancelled(request.operationId, \"Session has been stopped\");\n\t\tif (requiresDesktopUserConfirmation(request.action.kind))\n\t\t\treturn {\n\t\t\t\tversion: 1,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tstatus: \"needs_user\",\n\t\t\t\tsummary: `User confirmation required for ${request.action.kind}`,\n\t\t\t\terror: error(\"needs_user\", `The ${request.action.kind} action is paused for the user`, request.action.kind),\n\t\t\t};\n\t\tif (!SUPPORTED_ACTIONS.includes(request.action.kind))\n\t\t\treturn unsupported(\n\t\t\t\trequest.operationId,\n\t\t\t\t\"The selected macOS Accessibility adapter does not support this action\",\n\t\t\t\t\"action-unsupported\",\n\t\t\t);\n\t\tif (request.action.target === undefined)\n\t\t\treturn this.failed(request.operationId, \"target_required\", \"This desktop action requires an observed target\");\n\t\tif (request.action.target.kind === \"coordinates\" && request.action.kind !== \"click\")\n\t\t\treturn this.failed(\n\t\t\t\trequest.operationId,\n\t\t\t\t\"coordinates_unsupported\",\n\t\t\t\t\"Coordinate targets are supported by the click action only\",\n\t\t\t);\n\t\tif (request.action.kind === \"type\" && typeof request.action.text !== \"string\")\n\t\t\treturn this.failed(request.operationId, \"text_required\", \"Type action requires text\");\n\t\tif (request.action.kind === \"key\" && typeof request.action.key !== \"string\")\n\t\t\treturn this.failed(request.operationId, \"key_required\", \"Key action requires a key sequence\");\n\t\tif (request.action.kind === \"scroll\" && typeof request.action.text !== \"string\")\n\t\t\treturn this.failed(request.operationId, \"direction_required\", \"Scroll action requires an up/down direction\");\n\t\tconst postconditions = request.postconditions ?? [];\n\t\tif (postconditions.length > 0 && request.reobserveAfterAction === false)\n\t\t\treturn this.failed(\n\t\t\t\trequest.operationId,\n\t\t\t\t\"reobserve_required\",\n\t\t\t\t\"Postconditions require an action re-observation\",\n\t\t\t);\n\t\tconst payload = this.actionPayload(request);\n\t\tif (payload === undefined)\n\t\t\treturn this.failed(request.operationId, payloadErrorCode(request.action), payloadErrorMessage(request.action));\n\t\tconst raw = this.run(ACTION_SCRIPT, payload);\n\t\tif (raw === undefined || raw.failed) return unsupported(request.operationId, \"macOS Accessibility action failed\");\n\t\tconst parsed = parseJson(raw.stdout);\n\t\tif (parsed === undefined) return unsupported(request.operationId, \"macOS Accessibility action failed\");\n\t\tif (parsed.ok !== true) {\n\t\t\tif (parsed.code === \"stale_target\") {\n\t\t\t\tthis.invalidateObservation(request.sessionId);\n\t\t\t\treturn this.failed(\n\t\t\t\t\trequest.operationId,\n\t\t\t\t\t\"stale_target\",\n\t\t\t\t\t\"Target identity is stale; reobserve the desktop before retrying\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst causeCode =\n\t\t\t\ttypeof parsed.reason === \"string\" &&\n\t\t\t\t[\"focus_failed\", \"press_unavailable\", \"coordinate_click_failed\", \"ax_action_exception\"].includes(\n\t\t\t\t\tparsed.reason,\n\t\t\t\t)\n\t\t\t\t\t? parsed.reason\n\t\t\t\t\t: \"ax_action_exception\";\n\t\t\treturn this.failed(request.operationId, \"action_failed\", \"Accessibility action failed\", causeCode);\n\t\t}\n\t\tconst observation = request.reobserveAfterAction === false ? undefined : this.observe(request.sessionId);\n\t\tconst verification = this.verifyPostconditions(postconditions, observation);\n\t\tif (postconditions.length > 0 && verification.status === \"unknown\")\n\t\t\treturn {\n\t\t\t\tversion: 1,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tsummary: \"Desktop action completed but could not be re-observed\",\n\t\t\t\tverification,\n\t\t\t\terror: error(\n\t\t\t\t\t\"verification_unavailable\",\n\t\t\t\t\t\"The requested desktop state could not be re-observed\",\n\t\t\t\t\t\"reobserve-failed\",\n\t\t\t\t),\n\t\t\t};\n\t\tif (verification.status === \"failed\")\n\t\t\treturn {\n\t\t\t\tversion: 1,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tsummary: \"Desktop action completed but a postcondition failed\",\n\t\t\t\t...(observation !== undefined && \"observationId\" in observation ? { observation } : {}),\n\t\t\t\tverification,\n\t\t\t\terror: error(\"postcondition_failed\", \"The requested desktop state was not observed\", \"verification-failed\"),\n\t\t\t};\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\toperationId: request.operationId,\n\t\t\tstatus: \"succeeded\",\n\t\t\tsummary: \"Desktop action completed through macOS Accessibility\",\n\t\t\t...(observation !== undefined && \"observationId\" in observation ? { observation } : {}),\n\t\t\tverification,\n\t\t};\n\t}\n\n\tstop(sessionId: string): DesktopSessionV1 | DesktopOperationResultV1 {\n\t\tconst session = this.sessions.get(sessionId);\n\t\tif (session === undefined) return this.failed(\"stop\", \"session_not_found\", \"Session does not exist\");\n\t\tconst stopped = detachedFreeze({ ...session, status: \"stopped\" as const });\n\t\tthis.sessions.set(sessionId, stopped);\n\t\tthis.invalidateObservation(sessionId);\n\t\treturn stopped;\n\t}\n\n\tprivate actionPayload(request: DesktopOperationRequestV1):\n\t\t| {\n\t\t\t\treadonly kind: DesktopActionV1[\"kind\"];\n\t\t\t\treadonly target: {\n\t\t\t\t\treadonly windowId?: string;\n\t\t\t\t\treadonly controlId?: string;\n\t\t\t\t\treadonly coordinates?: { readonly x: number; readonly y: number };\n\t\t\t\t};\n\t\t\t\treadonly text?: string;\n\t\t\t\treadonly key?: MacosKeyStroke;\n\t\t\t\treadonly scroll?: { readonly up: boolean; readonly lines: number };\n\t\t }\n\t\t| undefined {\n\t\tconst target = request.action.target;\n\t\tif (target === undefined) return undefined;\n\t\tconst resolvedTarget =\n\t\t\ttarget.kind === \"coordinates\"\n\t\t\t\t? { coordinates: { x: target.x, y: target.y } }\n\t\t\t\t: (this.resolveTarget(request.sessionId, target) ?? undefined);\n\t\tif (resolvedTarget === undefined) return undefined;\n\t\tif (request.action.kind === \"key\") {\n\t\t\tconst key = parseMacKey(request.action.key ?? \"\");\n\t\t\tif (key === undefined) return undefined;\n\t\t\treturn { kind: request.action.kind, target: resolvedTarget, key };\n\t\t}\n\t\tif (request.action.kind === \"scroll\") {\n\t\t\tconst scroll = parseMacScroll(request.action.text ?? \"\");\n\t\t\tif (scroll === undefined) return undefined;\n\t\t\treturn { kind: request.action.kind, target: resolvedTarget, scroll };\n\t\t}\n\t\treturn {\n\t\t\tkind: request.action.kind,\n\t\t\ttarget: resolvedTarget,\n\t\t\t...(request.action.text === undefined ? {} : { text: request.action.text }),\n\t\t};\n\t}\n\n\tprivate run(\n\t\tscript: string,\n\t\tpayload?: unknown,\n\t): { readonly stdout: string; readonly stderr: string; readonly failed: boolean } | undefined {\n\t\tif (this.platform !== \"darwin\") return undefined;\n\t\tconst env: NodeJS.ProcessEnv = {};\n\t\tfor (const key of [\"PATH\", \"HOME\", \"TMPDIR\", \"USER\", \"LOGNAME\"] as const) {\n\t\t\tconst value = process.env[key];\n\t\t\tif (value !== undefined) env[key] = value;\n\t\t}\n\t\tif (payload !== undefined) env.AGENT_FORGE_MACOS_AX_INPUT = JSON.stringify(payload);\n\t\tconst result = this.spawn(this.command, [\"-l\", \"JavaScript\", \"-e\", script], {\n\t\t\tencoding: \"utf8\",\n\t\t\ttimeout: this.timeoutMs,\n\t\t\twindowsHide: true,\n\t\t\tenv,\n\t\t});\n\t\tif (result.error !== undefined || result.status !== 0)\n\t\t\treturn { stdout: result.stdout, stderr: result.stderr ?? \"\", failed: true };\n\t\treturn { stdout: result.stdout, stderr: result.stderr ?? \"\", failed: false };\n\t}\n\n\tprivate toObservation(session: DesktopSessionV1, raw: RawSnapshot): DesktopObservationV1 {\n\t\tthis.invalidateObservation(session.sessionId);\n\t\tconst observationId = `desktop-macos-observation-${this.nextObservationId++}`;\n\t\tconst targetKeys = new Set<string>();\n\t\tthis.sessionTargetKeys.set(session.sessionId, targetKeys);\n\t\tconst windows: DesktopWindowIdentityV1[] = [];\n\t\tfor (const item of raw.windows ?? []) {\n\t\t\tif (typeof item.id !== \"string\" || item.id === \"\") continue;\n\t\t\tconst windowId = item.id;\n\t\t\twindows.push({\n\t\t\t\tversion: 1,\n\t\t\t\twindowId,\n\t\t\t\tappId: `process:${Number(item.processId ?? 0)}`,\n\t\t\t\ttitle: item.name ?? \"\",\n\t\t\t\tbounds: rectangle(item),\n\t\t\t});\n\t\t}\n\t\tconst visibleWindows =\n\t\t\tsession.applicationId === undefined\n\t\t\t\t? windows\n\t\t\t\t: windows.filter((window) => window.appId === session.applicationId);\n\t\tfor (const window of visibleWindows) {\n\t\t\tconst key = this.targetKey(session.sessionId, \"window\", window.windowId);\n\t\t\tthis.targets.set(key, { sessionId: session.sessionId, observationId, windowId: window.windowId });\n\t\t\ttargetKeys.add(key);\n\t\t}\n\t\tconst controls: DesktopControlIdentityV1[] = [];\n\t\tfor (const item of raw.controls ?? []) {\n\t\t\tif (typeof item.windowId !== \"string\" || !visibleWindows.some((window) => window.windowId === item.windowId))\n\t\t\t\tcontinue;\n\t\t\tconst controlId = item.controlId ?? \"\";\n\t\t\tconst key = this.targetKey(session.sessionId, \"control\", controlId);\n\t\t\tthis.targets.set(key, {\n\t\t\t\tsessionId: session.sessionId,\n\t\t\t\tobservationId,\n\t\t\t\twindowId: item.windowId,\n\t\t\t\tcontrolId,\n\t\t\t});\n\t\t\ttargetKeys.add(key);\n\t\t\tcontrols.push({\n\t\t\t\tversion: 1,\n\t\t\t\tcontrolId,\n\t\t\t\twindowId: item.windowId,\n\t\t\t\trole: item.role ?? \"\",\n\t\t\t\tname: item.name ?? \"\",\n\t\t\t\tbounds: rectangle(item),\n\t\t\t\tenabled: item.enabled !== false,\n\t\t\t\t...(typeof item.value === \"string\" && item.value.length > 0 ? { value: item.value } : {}),\n\t\t\t});\n\t\t}\n\t\tconst focusedControlId =\n\t\t\ttypeof raw.focusedControlId === \"string\" &&\n\t\t\tcontrols.some((control) => control.controlId === raw.focusedControlId)\n\t\t\t\t? raw.focusedControlId\n\t\t\t\t: undefined;\n\t\tconst observation = detachedFreeze({\n\t\t\tversion: 1 as const,\n\t\t\tsessionId: session.sessionId,\n\t\t\tobservationId,\n\t\t\tsource: \"macos-ax\" as const,\n\t\t\twindows: visibleWindows,\n\t\t\tcontrols,\n\t\t\t...(focusedControlId !== undefined ? { focusedControlId } : {}),\n\t\t});\n\t\tthis.latestObservationIds.set(session.sessionId, observationId);\n\t\tthis.observedSessions.add(session.sessionId);\n\t\treturn observation;\n\t}\n\n\tprivate resolveTarget(\n\t\tsessionId: string,\n\t\ttarget: Exclude<DesktopTargetRefV1, { kind: \"coordinates\" }>,\n\t): { windowId?: string; controlId?: string } | undefined {\n\t\tconst identity = target.kind === \"control\" ? target.controlId : target.windowId;\n\t\tconst record = this.targets.get(this.targetKey(sessionId, target.kind, identity));\n\t\tif (\n\t\t\trecord === undefined ||\n\t\t\trecord.sessionId !== sessionId ||\n\t\t\trecord.observationId !== this.latestObservationIds.get(sessionId)\n\t\t)\n\t\t\treturn undefined;\n\t\treturn {\n\t\t\twindowId: record.windowId,\n\t\t\t...(record.controlId === undefined ? {} : { controlId: record.controlId }),\n\t\t};\n\t}\n\n\tprivate targetKey(sessionId: string, kind: DesktopTargetRefV1[\"kind\"], identity: string): string {\n\t\treturn `${sessionId}:${kind}:${identity}`;\n\t}\n\n\tprivate invalidateObservation(sessionId: string): void {\n\t\tfor (const key of this.sessionTargetKeys.get(sessionId) ?? []) this.targets.delete(key);\n\t\tthis.sessionTargetKeys.delete(sessionId);\n\t\tthis.latestObservationIds.delete(sessionId);\n\t}\n\n\tprivate verifyPostconditions(\n\t\tpostconditions: readonly DesktopPostconditionV1[],\n\t\tobservation: DesktopObservationV1 | DesktopOperationResultV1 | undefined,\n\t): DesktopVerificationV1 {\n\t\tif (postconditions.length === 0) return { status: \"passed\", checks: [] };\n\t\tif (observation === undefined || !(\"observationId\" in observation))\n\t\t\treturn { status: \"unknown\", checks: [\"observation-unavailable\"] };\n\t\tconst checks: string[] = [];\n\t\tfor (const condition of postconditions) {\n\t\t\tconst passed = this.checkPostcondition(condition, observation);\n\t\t\tchecks.push(`${condition.kind}:${passed ? \"passed\" : \"failed\"}`);\n\t\t\tif (!passed) return { status: \"failed\", checks };\n\t\t}\n\t\treturn { status: \"passed\", checks };\n\t}\n\n\tprivate checkPostcondition(condition: DesktopPostconditionV1, observation: DesktopObservationV1): boolean {\n\t\tif (condition.kind === \"window-exists\")\n\t\t\treturn observation.windows.some((window) => window.windowId === condition.windowId);\n\t\tif (condition.kind === \"control-exists\")\n\t\t\treturn observation.controls.some((control) => control.controlId === condition.controlId);\n\t\tif (condition.kind === \"focused\") return observation.focusedControlId === condition.controlId;\n\t\tconst target = condition.target;\n\t\tif (target.kind === \"window\") {\n\t\t\tconst window = observation.windows.find((item) => item.windowId === target.windowId);\n\t\t\tif (window === undefined || condition.property !== \"name\") return false;\n\t\t\treturn window.title === condition.expected;\n\t\t}\n\t\t// A coordinate target identifies no observed control, so it can never\n\t\t// satisfy a property-equals postcondition.\n\t\tif (target.kind === \"coordinates\") return false;\n\t\tconst control = observation.controls.find((item) => {\n\t\t\tif (item.controlId !== target.controlId) return false;\n\t\t\treturn target.windowId === undefined || item.windowId === target.windowId;\n\t\t});\n\t\tif (control === undefined) return false;\n\t\tif (condition.property === \"enabled\") return control.enabled === condition.expected;\n\t\tif (condition.property === \"name\") return control.name === condition.expected;\n\t\treturn control.value === condition.expected;\n\t}\n\n\tprivate failed(operationId: string, code: string, message: string, causeCode?: string): DesktopOperationResultV1 {\n\t\treturn { version: 1, operationId, status: \"failed\", summary: message, error: error(code, message, causeCode) };\n\t}\n\tprivate cancelled(operationId: string, message: string): DesktopOperationResultV1 {\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\toperationId,\n\t\t\tstatus: \"cancelled\",\n\t\t\tsummary: message,\n\t\t\terror: error(\"cancelled\", message, \"stopped\"),\n\t\t};\n\t}\n}\n\nconst payloadErrorCode = (action: DesktopActionV1): string => {\n\tif (action.kind === \"key\") return \"key_unsupported\";\n\tif (action.kind === \"scroll\") return \"direction_invalid\";\n\treturn \"target_not_found\";\n};\n\nconst payloadErrorMessage = (action: DesktopActionV1): string => {\n\tif (action.kind === \"key\") return \"Key sequence does not match the supported macOS key grammar\";\n\tif (action.kind === \"scroll\") return \"Scroll direction must be up or down with optional :lines\";\n\treturn \"Target identity was not observed by macOS Accessibility\";\n};\n\n/**\n * The production input facade intentionally exposes no replay method. The\n * driver remains responsible for using observed Accessibility identities\n * (or explicit click coordinates) rather than global keyboard injection.\n */\nexport class DesktopMacosInputAdapter implements DesktopFullControlAdapterV1 {\n\treadonly adapterId = \"desktop-macos-ax\";\n\treadonly adapterVersion = \"1.0.0\";\n\tprivate readonly driver: DesktopMacosDriverV1;\n\n\tconstructor(driver: DesktopMacosDriverV1 = new MacosAccessibilityDriver()) {\n\t\tthis.driver = driver;\n\t}\n\n\tprobe(): DesktopMacosProbeV1 {\n\t\treturn this.driver.probe();\n\t}\n\n\topenSession(request: DesktopSessionRequestV1): DesktopSessionResultV1 {\n\t\treturn this.driver.openSession(request);\n\t}\n\n\tobserve(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1 {\n\t\treturn this.driver.observe(sessionId);\n\t}\n\n\treobserve(sessionId: string): DesktopObservationV1 | DesktopOperationResultV1 {\n\t\treturn this.driver.observe(sessionId);\n\t}\n\n\texecute(request: DesktopOperationRequestV1): DesktopOperationResultV1 {\n\t\tif (requiresDesktopUserConfirmation(request.action.kind)) {\n\t\t\treturn {\n\t\t\t\tversion: 1,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tstatus: \"needs_user\",\n\t\t\t\tsummary: `User confirmation required for ${request.action.kind}`,\n\t\t\t\terror: {\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tcode: \"needs_user\",\n\t\t\t\t\tmessage: `The ${request.action.kind} action is paused for the user`,\n\t\t\t\t\tcauseCode: request.action.kind,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn this.driver.execute(request);\n\t}\n\n\tstop(sessionId: string): DesktopSessionV1 | DesktopOperationResultV1 {\n\t\treturn this.driver.stop(sessionId);\n\t}\n}\n"]}