@ai-agent-forge/plugin-desktop-windows-input 0.85.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.
- package/README.md +42 -0
- package/agent-forge.json +17 -0
- package/dist/capability.d.ts +16 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +425 -0
- package/dist/capability.js.map +1 -0
- package/dist/entry.d.ts +15 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +16 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/projection.d.ts +39 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +117 -0
- package/dist/projection.js.map +1 -0
- package/dist/shared.d.ts +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +30 -0
- package/dist/shared.js.map +1 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/dist/windows-input-adapter.d.ts +26 -0
- package/dist/windows-input-adapter.d.ts.map +1 -0
- package/dist/windows-input-adapter.js +55 -0
- package/dist/windows-input-adapter.js.map +1 -0
- package/dist/windows-uia-adapter.d.ts +68 -0
- package/dist/windows-uia-adapter.d.ts.map +1 -0
- package/dist/windows-uia-adapter.js +711 -0
- package/dist/windows-uia-adapter.js.map +1 -0
- package/package.json +57 -0
- package/plugin.json +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.js","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAaA,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,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,CAAC;gBACjC,IAAI,MAAM,EAAE,OAAO;oBAClB,OAAO,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,iCAAiC,EAAE,WAAW,CAAC,CAAC;gBACjG,IAAI,OAA+B,CAAC;gBACpC,IAAI,CAAC;oBACJ,OAAO,GAAG,oBAAoB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;gBACpD,CAAC;gBAAC,MAAM,CAAC;oBACR,OAAO,cAAc,CAAC,WAAW,EAAE,uBAAuB,EAAE,iCAAiC,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 and replay capability factory, migrated from\n * agent-forge `src/profile/runtime-capabilities-desktop-input.ts`\n * (`desktopInputFactory`, D-075 S3 extraction). Differences from the host\n * original:\n * - The factory type is the public `CapabilityPluginSyncFactory` from the\n * plugin SDK instead of the host-internal `BuiltinCapabilityPlugin`.\n * - Projection helpers live in `projection.ts`, input helpers in `shared.ts`.\n * Tool names, parameters, budgets and result shapes are unchanged, including\n * the readonly-mode refusal to register input tools and the optional replay\n * registration when the runtime exposes a replay method.\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 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\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\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\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 UI Automation focus, click, type, key, or scroll action against an observed target 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]),\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]),\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"]}
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.
|
|
3
|
+
*
|
|
4
|
+
* The adapter is the production input facade: one `DesktopWindowsInputAdapter`
|
|
5
|
+
* over the default `WindowsUiAutomationDriver` (powershell.exe, 15s timeout,
|
|
6
|
+
* `process.platform`), the same default construction the host's profile wiring
|
|
7
|
+
* uses. It deliberately exposes no replay method, so only `desktop_execute`
|
|
8
|
+
* registers; hosts that want replay inject their own adapter through the
|
|
9
|
+
* library surface. Non-Windows platforms never throw at import or call time:
|
|
10
|
+
* the driver probe reports unavailable and tools return explicit `unsupported`
|
|
11
|
+
* results. A readonly host mode registers no input tools at all.
|
|
12
|
+
*/
|
|
13
|
+
declare const _default: import("@agent-forge/plugin-sdk").CapabilityPluginSyncFactory;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;;AACH,wBAAuF","sourcesContent":["import { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nimport { DesktopWindowsInputAdapter } from \"./windows-input-adapter.ts\";\n\n/**\n * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.\n *\n * The adapter is the production input facade: one `DesktopWindowsInputAdapter`\n * over the default `WindowsUiAutomationDriver` (powershell.exe, 15s timeout,\n * `process.platform`), the same default construction the host's profile wiring\n * uses. It deliberately exposes no replay method, so only `desktop_execute`\n * registers; hosts that want replay inject their own adapter through the\n * library surface. Non-Windows platforms never throw at import or call time:\n * the driver probe reports unavailable and tools return explicit `unsupported`\n * results. A readonly host mode registers no input tools at all.\n */\nexport default createDesktopInputCapabilityFactoryV1(new DesktopWindowsInputAdapter());\n"]}
|
package/dist/entry.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createDesktopInputCapabilityFactoryV1 } from "./capability.js";
|
|
2
|
+
import { DesktopWindowsInputAdapter } from "./windows-input-adapter.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.
|
|
5
|
+
*
|
|
6
|
+
* The adapter is the production input facade: one `DesktopWindowsInputAdapter`
|
|
7
|
+
* over the default `WindowsUiAutomationDriver` (powershell.exe, 15s timeout,
|
|
8
|
+
* `process.platform`), the same default construction the host's profile wiring
|
|
9
|
+
* uses. It deliberately exposes no replay method, so only `desktop_execute`
|
|
10
|
+
* registers; hosts that want replay inject their own adapter through the
|
|
11
|
+
* library surface. Non-Windows platforms never throw at import or call time:
|
|
12
|
+
* the driver probe reports unavailable and tools return explicit `unsupported`
|
|
13
|
+
* results. A readonly host mode registers no input tools at all.
|
|
14
|
+
*/
|
|
15
|
+
export default createDesktopInputCapabilityFactoryV1(new DesktopWindowsInputAdapter());
|
|
16
|
+
//# 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,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,eAAe,qCAAqC,CAAC,IAAI,0BAA0B,EAAE,CAAC,CAAC","sourcesContent":["import { createDesktopInputCapabilityFactoryV1 } from \"./capability.ts\";\nimport { DesktopWindowsInputAdapter } from \"./windows-input-adapter.ts\";\n\n/**\n * Default-export factory consumed by the host's `loadCapabilityPluginFromManifest`.\n *\n * The adapter is the production input facade: one `DesktopWindowsInputAdapter`\n * over the default `WindowsUiAutomationDriver` (powershell.exe, 15s timeout,\n * `process.platform`), the same default construction the host's profile wiring\n * uses. It deliberately exposes no replay method, so only `desktop_execute`\n * registers; hosts that want replay inject their own adapter through the\n * library surface. Non-Windows platforms never throw at import or call time:\n * the driver probe reports unavailable and tools return explicit `unsupported`\n * results. A readonly host mode registers no input tools at all.\n */\nexport default createDesktopInputCapabilityFactoryV1(new DesktopWindowsInputAdapter());\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDesktopInputCapabilityFactoryV1 } from "./capability.ts";
|
|
2
|
+
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";
|
|
3
|
+
export type * from "./types.ts";
|
|
4
|
+
export { DesktopWindowsInputAdapter } from "./windows-input-adapter.ts";
|
|
5
|
+
export type { WindowsUiAutomationDriverOptions } from "./windows-uia-adapter.ts";
|
|
6
|
+
export { DesktopWindowsAdapter, WindowsUiAutomationDriver } from "./windows-uia-adapter.ts";
|
|
7
|
+
//# 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,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;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,YAAY,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { createDesktopInputCapabilityFactoryV1 } from \"./capability.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\";\nexport { DesktopWindowsInputAdapter } from \"./windows-input-adapter.ts\";\nexport type { WindowsUiAutomationDriverOptions } from \"./windows-uia-adapter.ts\";\nexport { DesktopWindowsAdapter, WindowsUiAutomationDriver } from \"./windows-uia-adapter.ts\";\n"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createDesktopInputCapabilityFactoryV1 } from "./capability.js";
|
|
2
|
+
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";
|
|
3
|
+
export { DesktopWindowsInputAdapter } from "./windows-input-adapter.js";
|
|
4
|
+
export { DesktopWindowsAdapter, WindowsUiAutomationDriver } from "./windows-uia-adapter.js";
|
|
5
|
+
//# 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;AACxE,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;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { createDesktopInputCapabilityFactoryV1 } from \"./capability.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\";\nexport { DesktopWindowsInputAdapter } from \"./windows-input-adapter.ts\";\nexport type { WindowsUiAutomationDriverOptions } from \"./windows-uia-adapter.ts\";\nexport { DesktopWindowsAdapter, WindowsUiAutomationDriver } from \"./windows-uia-adapter.ts\";\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from agent-forge `src/profile/runtime-capabilities-desktop.ts`
|
|
3
|
+
* (D-075 S3 extraction) so this package keeps its dependency closure limited
|
|
4
|
+
* to the plugin SDK and typebox. Semantics are unchanged. Differences from
|
|
5
|
+
* the host original:
|
|
6
|
+
* - Desktop V1 types import from the package-local `types.ts` copy.
|
|
7
|
+
* - Only the helpers the input capability needs are carried here; the probe
|
|
8
|
+
* capability filter and the observation/session result projectors stay with
|
|
9
|
+
* the observe package (`plugins/desktop-windows-observe/src/projection.ts`).
|
|
10
|
+
* Deliberate copy shared (subset-compatible) with that file; keep both in sync.
|
|
11
|
+
*/
|
|
12
|
+
import type { DesktopObservationV1 } from "./types.ts";
|
|
13
|
+
export declare const DESKTOP_MAX_STRING_CHARS_V1 = 256;
|
|
14
|
+
export declare const DESKTOP_MAX_POSTCONDITIONS_V1 = 32;
|
|
15
|
+
export declare const DESKTOP_MAX_TYPE_TEXT_CHARS_V1 = 4096;
|
|
16
|
+
export declare const DESKTOP_MAX_REPLAY_ACTIONS_V1 = 32;
|
|
17
|
+
export declare function desktopFailure(operationId: string, code: string, message: string, status?: "failed" | "unsupported" | "cancelled" | "needs_user"): {
|
|
18
|
+
version: 1;
|
|
19
|
+
operationId: string;
|
|
20
|
+
status: "cancelled" | "failed" | "needs_user" | "unsupported";
|
|
21
|
+
summary: string;
|
|
22
|
+
error: {
|
|
23
|
+
version: 1;
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function desktopBoundedString(value: unknown, label: string): string;
|
|
29
|
+
export declare function desktopClampedString(value: unknown, label: string): string;
|
|
30
|
+
export declare function desktopRequiredString(value: unknown, label: string): string;
|
|
31
|
+
export declare function projectDesktopObservation(value: unknown): {
|
|
32
|
+
readonly observation: DesktopObservationV1;
|
|
33
|
+
readonly truncated: {
|
|
34
|
+
readonly windows: boolean;
|
|
35
|
+
readonly controls: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare function desktopResultWithinBudget<T>(value: T): T;
|
|
39
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAA4B,oBAAoB,EAA2B,MAAM,YAAY,CAAC;AAI1G,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,8BAA8B,OAAO,CAAC;AACnD,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,wBAAgB,cAAc,CAC7B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,QAAQ,GAAG,aAAa,GAAG,WAAW,GAAG,YAAuB;;;;;;;;;;EASxE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI1E;AAKD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI1E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3E;AAiDD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG;IAC1D,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CAC9E,CAgCA;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAIxD","sourcesContent":["/**\n * Inlined from agent-forge `src/profile/runtime-capabilities-desktop.ts`\n * (D-075 S3 extraction) so this package keeps its dependency closure limited\n * to the plugin SDK and typebox. Semantics are unchanged. Differences from\n * the host original:\n * - Desktop V1 types import from the package-local `types.ts` copy.\n * - Only the helpers the input capability needs are carried here; the probe\n * capability filter and the observation/session result projectors stay with\n * the observe package (`plugins/desktop-windows-observe/src/projection.ts`).\n * Deliberate copy shared (subset-compatible) with that file; keep both in sync.\n */\nimport type { DesktopControlIdentityV1, DesktopObservationV1, DesktopWindowIdentityV1 } from \"./types.ts\";\n\nconst DESKTOP_MAX_WINDOWS_V1 = 64;\nconst DESKTOP_MAX_CONTROLS_V1 = 256;\nexport const DESKTOP_MAX_STRING_CHARS_V1 = 256;\nconst DESKTOP_MAX_RESULT_BYTES_V1 = 64 * 1024;\nexport const DESKTOP_MAX_POSTCONDITIONS_V1 = 32;\nexport const DESKTOP_MAX_TYPE_TEXT_CHARS_V1 = 4096;\nexport const DESKTOP_MAX_REPLAY_ACTIONS_V1 = 32;\n\nexport function desktopFailure(\n\toperationId: string,\n\tcode: string,\n\tmessage: string,\n\tstatus: \"failed\" | \"unsupported\" | \"cancelled\" | \"needs_user\" = \"failed\",\n) {\n\treturn {\n\t\tversion: 1 as const,\n\t\toperationId,\n\t\tstatus,\n\t\tsummary: message,\n\t\terror: { version: 1 as const, code, message },\n\t};\n}\n\nexport function desktopBoundedString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\" || value.length > DESKTOP_MAX_STRING_CHARS_V1)\n\t\tthrow new Error(`desktop-result-budget:${label}`);\n\treturn value;\n}\n\n/// 观察投影专用:显示文本超长时截断而非抛异常(dogfood 2026-09-25 实测,真实桌面\n/// 单控件文本超上限很常见)。输入校验(type text/key/target)仍用 desktopBoundedString\n/// 严格拒绝——截断输入等于静默打错字。\nexport function desktopClampedString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\") throw new Error(`desktop-result-budget:${label}`);\n\tif (value.length > DESKTOP_MAX_STRING_CHARS_V1) return value.slice(0, DESKTOP_MAX_STRING_CHARS_V1);\n\treturn value;\n}\n\nexport function desktopRequiredString(value: unknown, label: string): string {\n\tconst result = desktopBoundedString(value, label);\n\tif (result.trim() === \"\") throw new Error(`desktop-result-invalid:${label}`);\n\treturn result;\n}\n\nfunction desktopBounds(value: unknown): {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly width: number;\n\treadonly height: number;\n} {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tconst bounds = { x: record.x, y: record.y, width: record.width, height: record.height };\n\tif (\n\t\tObject.values(bounds).some((item) => typeof item !== \"number\" || !Number.isFinite(item)) ||\n\t\t(bounds.width as number) < 0 ||\n\t\t(bounds.height as number) < 0\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\treturn bounds as { x: number; y: number; width: number; height: number };\n}\n\nfunction projectDesktopWindow(value: unknown): DesktopWindowIdentityV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (record.version !== 1) throw new Error(\"desktop-result-invalid\");\n\treturn {\n\t\tversion: 1,\n\t\twindowId: desktopClampedString(record.windowId, \"windowId\"),\n\t\tappId: desktopClampedString(record.appId, \"appId\"),\n\t\ttitle: desktopClampedString(record.title, \"title\"),\n\t\tbounds: desktopBounds(record.bounds),\n\t};\n}\n\nfunction projectDesktopControl(value: unknown): DesktopControlIdentityV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (record.version !== 1 || typeof record.enabled !== \"boolean\") throw new Error(\"desktop-result-invalid\");\n\treturn {\n\t\tversion: 1,\n\t\tcontrolId: desktopClampedString(record.controlId, \"controlId\"),\n\t\twindowId: desktopClampedString(record.windowId, \"windowId\"),\n\t\trole: desktopClampedString(record.role, \"role\"),\n\t\tname: desktopClampedString(record.name, \"name\"),\n\t\tbounds: desktopBounds(record.bounds),\n\t\tenabled: record.enabled,\n\t\t...(record.value === undefined ? {} : { value: desktopClampedString(record.value, \"value\") }),\n\t};\n}\n\nexport function projectDesktopObservation(value: unknown): {\n\treadonly observation: DesktopObservationV1;\n\treadonly truncated: { readonly windows: boolean; readonly controls: boolean };\n} {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\trecord.version !== 1 ||\n\t\ttypeof record.sessionId !== \"string\" ||\n\t\ttypeof record.observationId !== \"string\" ||\n\t\t(record.source !== \"mock\" && record.source !== \"windows-uia\") ||\n\t\t!Array.isArray(record.windows) ||\n\t\t!Array.isArray(record.controls)\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\tconst windows = record.windows.slice(0, DESKTOP_MAX_WINDOWS_V1).map(projectDesktopWindow);\n\tconst controls = record.controls.slice(0, DESKTOP_MAX_CONTROLS_V1).map(projectDesktopControl);\n\tconst observation = {\n\t\tversion: 1 as const,\n\t\tsessionId: desktopClampedString(record.sessionId, \"sessionId\"),\n\t\tobservationId: desktopClampedString(record.observationId, \"observationId\"),\n\t\tsource: record.source,\n\t\twindows,\n\t\tcontrols,\n\t\t...(record.focusedControlId === undefined\n\t\t\t? {}\n\t\t\t: { focusedControlId: desktopClampedString(record.focusedControlId, \"focusedControlId\") }),\n\t} satisfies DesktopObservationV1;\n\treturn {\n\t\tobservation,\n\t\ttruncated: {\n\t\t\twindows: record.windows.length > DESKTOP_MAX_WINDOWS_V1,\n\t\t\tcontrols: record.controls.length > DESKTOP_MAX_CONTROLS_V1,\n\t\t},\n\t};\n}\n\nexport function desktopResultWithinBudget<T>(value: T): T {\n\tif (new TextEncoder().encode(JSON.stringify(value)).byteLength > DESKTOP_MAX_RESULT_BYTES_V1)\n\t\tthrow new Error(\"desktop-result-budget\");\n\treturn value;\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const DESKTOP_MAX_WINDOWS_V1 = 64;
|
|
2
|
+
const DESKTOP_MAX_CONTROLS_V1 = 256;
|
|
3
|
+
export const DESKTOP_MAX_STRING_CHARS_V1 = 256;
|
|
4
|
+
const DESKTOP_MAX_RESULT_BYTES_V1 = 64 * 1024;
|
|
5
|
+
export const DESKTOP_MAX_POSTCONDITIONS_V1 = 32;
|
|
6
|
+
export const DESKTOP_MAX_TYPE_TEXT_CHARS_V1 = 4096;
|
|
7
|
+
export const DESKTOP_MAX_REPLAY_ACTIONS_V1 = 32;
|
|
8
|
+
export function desktopFailure(operationId, code, message, status = "failed") {
|
|
9
|
+
return {
|
|
10
|
+
version: 1,
|
|
11
|
+
operationId,
|
|
12
|
+
status,
|
|
13
|
+
summary: message,
|
|
14
|
+
error: { version: 1, code, message },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function desktopBoundedString(value, label) {
|
|
18
|
+
if (typeof value !== "string" || value.length > DESKTOP_MAX_STRING_CHARS_V1)
|
|
19
|
+
throw new Error(`desktop-result-budget:${label}`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
/// 观察投影专用:显示文本超长时截断而非抛异常(dogfood 2026-09-25 实测,真实桌面
|
|
23
|
+
/// 单控件文本超上限很常见)。输入校验(type text/key/target)仍用 desktopBoundedString
|
|
24
|
+
/// 严格拒绝——截断输入等于静默打错字。
|
|
25
|
+
export function desktopClampedString(value, label) {
|
|
26
|
+
if (typeof value !== "string")
|
|
27
|
+
throw new Error(`desktop-result-budget:${label}`);
|
|
28
|
+
if (value.length > DESKTOP_MAX_STRING_CHARS_V1)
|
|
29
|
+
return value.slice(0, DESKTOP_MAX_STRING_CHARS_V1);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
export function desktopRequiredString(value, label) {
|
|
33
|
+
const result = desktopBoundedString(value, label);
|
|
34
|
+
if (result.trim() === "")
|
|
35
|
+
throw new Error(`desktop-result-invalid:${label}`);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function desktopBounds(value) {
|
|
39
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
40
|
+
throw new Error("desktop-result-invalid");
|
|
41
|
+
const record = value;
|
|
42
|
+
const bounds = { x: record.x, y: record.y, width: record.width, height: record.height };
|
|
43
|
+
if (Object.values(bounds).some((item) => typeof item !== "number" || !Number.isFinite(item)) ||
|
|
44
|
+
bounds.width < 0 ||
|
|
45
|
+
bounds.height < 0)
|
|
46
|
+
throw new Error("desktop-result-invalid");
|
|
47
|
+
return bounds;
|
|
48
|
+
}
|
|
49
|
+
function projectDesktopWindow(value) {
|
|
50
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
51
|
+
throw new Error("desktop-result-invalid");
|
|
52
|
+
const record = value;
|
|
53
|
+
if (record.version !== 1)
|
|
54
|
+
throw new Error("desktop-result-invalid");
|
|
55
|
+
return {
|
|
56
|
+
version: 1,
|
|
57
|
+
windowId: desktopClampedString(record.windowId, "windowId"),
|
|
58
|
+
appId: desktopClampedString(record.appId, "appId"),
|
|
59
|
+
title: desktopClampedString(record.title, "title"),
|
|
60
|
+
bounds: desktopBounds(record.bounds),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function projectDesktopControl(value) {
|
|
64
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
65
|
+
throw new Error("desktop-result-invalid");
|
|
66
|
+
const record = value;
|
|
67
|
+
if (record.version !== 1 || typeof record.enabled !== "boolean")
|
|
68
|
+
throw new Error("desktop-result-invalid");
|
|
69
|
+
return {
|
|
70
|
+
version: 1,
|
|
71
|
+
controlId: desktopClampedString(record.controlId, "controlId"),
|
|
72
|
+
windowId: desktopClampedString(record.windowId, "windowId"),
|
|
73
|
+
role: desktopClampedString(record.role, "role"),
|
|
74
|
+
name: desktopClampedString(record.name, "name"),
|
|
75
|
+
bounds: desktopBounds(record.bounds),
|
|
76
|
+
enabled: record.enabled,
|
|
77
|
+
...(record.value === undefined ? {} : { value: desktopClampedString(record.value, "value") }),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function projectDesktopObservation(value) {
|
|
81
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
82
|
+
throw new Error("desktop-result-invalid");
|
|
83
|
+
const record = value;
|
|
84
|
+
if (record.version !== 1 ||
|
|
85
|
+
typeof record.sessionId !== "string" ||
|
|
86
|
+
typeof record.observationId !== "string" ||
|
|
87
|
+
(record.source !== "mock" && record.source !== "windows-uia") ||
|
|
88
|
+
!Array.isArray(record.windows) ||
|
|
89
|
+
!Array.isArray(record.controls))
|
|
90
|
+
throw new Error("desktop-result-invalid");
|
|
91
|
+
const windows = record.windows.slice(0, DESKTOP_MAX_WINDOWS_V1).map(projectDesktopWindow);
|
|
92
|
+
const controls = record.controls.slice(0, DESKTOP_MAX_CONTROLS_V1).map(projectDesktopControl);
|
|
93
|
+
const observation = {
|
|
94
|
+
version: 1,
|
|
95
|
+
sessionId: desktopClampedString(record.sessionId, "sessionId"),
|
|
96
|
+
observationId: desktopClampedString(record.observationId, "observationId"),
|
|
97
|
+
source: record.source,
|
|
98
|
+
windows,
|
|
99
|
+
controls,
|
|
100
|
+
...(record.focusedControlId === undefined
|
|
101
|
+
? {}
|
|
102
|
+
: { focusedControlId: desktopClampedString(record.focusedControlId, "focusedControlId") }),
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
observation,
|
|
106
|
+
truncated: {
|
|
107
|
+
windows: record.windows.length > DESKTOP_MAX_WINDOWS_V1,
|
|
108
|
+
controls: record.controls.length > DESKTOP_MAX_CONTROLS_V1,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export function desktopResultWithinBudget(value) {
|
|
113
|
+
if (new TextEncoder().encode(JSON.stringify(value)).byteLength > DESKTOP_MAX_RESULT_BYTES_V1)
|
|
114
|
+
throw new Error("desktop-result-budget");
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAaA,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AACnD,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,MAAM,UAAU,cAAc,CAC7B,WAAmB,EACnB,IAAY,EACZ,OAAe,EACf,MAAM,GAA0D,QAAQ,EACvE;IACD,OAAO;QACN,OAAO,EAAE,CAAU;QACnB,WAAW;QACX,MAAM;QACN,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,EAAE,OAAO,EAAE,CAAU,EAAE,IAAI,EAAE,OAAO,EAAE;KAC7C,CAAC;AAAA,CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,KAAa,EAAU;IAC3E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,2BAA2B;QAC1E,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AAAA,C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GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC1F,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAC9F,MAAM,WAAW,GAAG;QACnB,OAAO,EAAE,CAAU;QACnB,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC;QAC9D,aAAa,EAAE,oBAAoB,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC;QAC1E,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO;QACP,QAAQ;QACR,GAAG,CAAC,MAAM,CAAC,gBAAgB,KAAK,SAAS;YACxC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EAAE,CAAC;KAC5D,CAAC;IACjC,OAAO;QACN,WAAW;QACX,SAAS,EAAE;YACV,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,sBAAsB;YACvD,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,uBAAuB;SAC1D;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,yBAAyB,CAAI,KAAQ,EAAK;IACzD,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,2BAA2B;QAC3F,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["/**\n * Inlined from agent-forge `src/profile/runtime-capabilities-desktop.ts`\n * (D-075 S3 extraction) so this package keeps its dependency closure limited\n * to the plugin SDK and typebox. Semantics are unchanged. Differences from\n * the host original:\n * - Desktop V1 types import from the package-local `types.ts` copy.\n * - Only the helpers the input capability needs are carried here; the probe\n * capability filter and the observation/session result projectors stay with\n * the observe package (`plugins/desktop-windows-observe/src/projection.ts`).\n * Deliberate copy shared (subset-compatible) with that file; keep both in sync.\n */\nimport type { DesktopControlIdentityV1, DesktopObservationV1, DesktopWindowIdentityV1 } from \"./types.ts\";\n\nconst DESKTOP_MAX_WINDOWS_V1 = 64;\nconst DESKTOP_MAX_CONTROLS_V1 = 256;\nexport const DESKTOP_MAX_STRING_CHARS_V1 = 256;\nconst DESKTOP_MAX_RESULT_BYTES_V1 = 64 * 1024;\nexport const DESKTOP_MAX_POSTCONDITIONS_V1 = 32;\nexport const DESKTOP_MAX_TYPE_TEXT_CHARS_V1 = 4096;\nexport const DESKTOP_MAX_REPLAY_ACTIONS_V1 = 32;\n\nexport function desktopFailure(\n\toperationId: string,\n\tcode: string,\n\tmessage: string,\n\tstatus: \"failed\" | \"unsupported\" | \"cancelled\" | \"needs_user\" = \"failed\",\n) {\n\treturn {\n\t\tversion: 1 as const,\n\t\toperationId,\n\t\tstatus,\n\t\tsummary: message,\n\t\terror: { version: 1 as const, code, message },\n\t};\n}\n\nexport function desktopBoundedString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\" || value.length > DESKTOP_MAX_STRING_CHARS_V1)\n\t\tthrow new Error(`desktop-result-budget:${label}`);\n\treturn value;\n}\n\n/// 观察投影专用:显示文本超长时截断而非抛异常(dogfood 2026-09-25 实测,真实桌面\n/// 单控件文本超上限很常见)。输入校验(type text/key/target)仍用 desktopBoundedString\n/// 严格拒绝——截断输入等于静默打错字。\nexport function desktopClampedString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\") throw new Error(`desktop-result-budget:${label}`);\n\tif (value.length > DESKTOP_MAX_STRING_CHARS_V1) return value.slice(0, DESKTOP_MAX_STRING_CHARS_V1);\n\treturn value;\n}\n\nexport function desktopRequiredString(value: unknown, label: string): string {\n\tconst result = desktopBoundedString(value, label);\n\tif (result.trim() === \"\") throw new Error(`desktop-result-invalid:${label}`);\n\treturn result;\n}\n\nfunction desktopBounds(value: unknown): {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly width: number;\n\treadonly height: number;\n} {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tconst bounds = { x: record.x, y: record.y, width: record.width, height: record.height };\n\tif (\n\t\tObject.values(bounds).some((item) => typeof item !== \"number\" || !Number.isFinite(item)) ||\n\t\t(bounds.width as number) < 0 ||\n\t\t(bounds.height as number) < 0\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\treturn bounds as { x: number; y: number; width: number; height: number };\n}\n\nfunction projectDesktopWindow(value: unknown): DesktopWindowIdentityV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (record.version !== 1) throw new Error(\"desktop-result-invalid\");\n\treturn {\n\t\tversion: 1,\n\t\twindowId: desktopClampedString(record.windowId, \"windowId\"),\n\t\tappId: desktopClampedString(record.appId, \"appId\"),\n\t\ttitle: desktopClampedString(record.title, \"title\"),\n\t\tbounds: desktopBounds(record.bounds),\n\t};\n}\n\nfunction projectDesktopControl(value: unknown): DesktopControlIdentityV1 {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (record.version !== 1 || typeof record.enabled !== \"boolean\") throw new Error(\"desktop-result-invalid\");\n\treturn {\n\t\tversion: 1,\n\t\tcontrolId: desktopClampedString(record.controlId, \"controlId\"),\n\t\twindowId: desktopClampedString(record.windowId, \"windowId\"),\n\t\trole: desktopClampedString(record.role, \"role\"),\n\t\tname: desktopClampedString(record.name, \"name\"),\n\t\tbounds: desktopBounds(record.bounds),\n\t\tenabled: record.enabled,\n\t\t...(record.value === undefined ? {} : { value: desktopClampedString(record.value, \"value\") }),\n\t};\n}\n\nexport function projectDesktopObservation(value: unknown): {\n\treadonly observation: DesktopObservationV1;\n\treadonly truncated: { readonly windows: boolean; readonly controls: boolean };\n} {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"desktop-result-invalid\");\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\trecord.version !== 1 ||\n\t\ttypeof record.sessionId !== \"string\" ||\n\t\ttypeof record.observationId !== \"string\" ||\n\t\t(record.source !== \"mock\" && record.source !== \"windows-uia\") ||\n\t\t!Array.isArray(record.windows) ||\n\t\t!Array.isArray(record.controls)\n\t)\n\t\tthrow new Error(\"desktop-result-invalid\");\n\tconst windows = record.windows.slice(0, DESKTOP_MAX_WINDOWS_V1).map(projectDesktopWindow);\n\tconst controls = record.controls.slice(0, DESKTOP_MAX_CONTROLS_V1).map(projectDesktopControl);\n\tconst observation = {\n\t\tversion: 1 as const,\n\t\tsessionId: desktopClampedString(record.sessionId, \"sessionId\"),\n\t\tobservationId: desktopClampedString(record.observationId, \"observationId\"),\n\t\tsource: record.source,\n\t\twindows,\n\t\tcontrols,\n\t\t...(record.focusedControlId === undefined\n\t\t\t? {}\n\t\t\t: { focusedControlId: desktopClampedString(record.focusedControlId, \"focusedControlId\") }),\n\t} satisfies DesktopObservationV1;\n\treturn {\n\t\tobservation,\n\t\ttruncated: {\n\t\t\twindows: record.windows.length > DESKTOP_MAX_WINDOWS_V1,\n\t\t\tcontrols: record.controls.length > DESKTOP_MAX_CONTROLS_V1,\n\t\t},\n\t};\n}\n\nexport function desktopResultWithinBudget<T>(value: T): T {\n\tif (new TextEncoder().encode(JSON.stringify(value)).byteLength > DESKTOP_MAX_RESULT_BYTES_V1)\n\t\tthrow new Error(\"desktop-result-budget\");\n\treturn value;\n}\n"]}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from agent-forge `src/profile/runtime-capabilities-shared.ts`
|
|
3
|
+
* (D-075 S3 extraction) so this package keeps its dependency closure limited
|
|
4
|
+
* to the plugin SDK and typebox. Semantics are unchanged; the artifact-ref
|
|
5
|
+
* schema helpers stay host-side because desktop tools do not use them.
|
|
6
|
+
* Deliberate copy shared with `plugins/desktop-windows-observe/src/shared.ts`;
|
|
7
|
+
* keep both copies in sync.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toolInvocation(first: unknown, second: unknown): {
|
|
10
|
+
readonly input: Record<string, unknown>;
|
|
11
|
+
readonly operationId: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function signalFrom(value: unknown): AbortSignal | undefined;
|
|
14
|
+
export declare function nonEmptyString(value: unknown, label: string): string;
|
|
15
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,GACb;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAK3E;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAElE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpE","sourcesContent":["/**\n * Inlined from agent-forge `src/profile/runtime-capabilities-shared.ts`\n * (D-075 S3 extraction) so this package keeps its dependency closure limited\n * to the plugin SDK and typebox. Semantics are unchanged; the artifact-ref\n * schema helpers stay host-side because desktop tools do not use them.\n * Deliberate copy shared with `plugins/desktop-windows-observe/src/shared.ts`;\n * keep both copies in sync.\n */\n\nfunction objectInput(first: unknown, second: unknown): Record<string, unknown> {\n\tconst value = second === undefined ? first : second;\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Plugin tool input must be an object\");\n\t}\n\treturn value as Record<string, unknown>;\n}\n\nexport function toolInvocation(\n\tfirst: unknown,\n\tsecond: unknown,\n): { readonly input: Record<string, unknown>; readonly operationId: string } {\n\treturn {\n\t\tinput: objectInput(first, second),\n\t\toperationId: typeof first === \"string\" && first.trim() !== \"\" ? first : \"profile-runtime-tool-call\",\n\t};\n}\n\nexport function signalFrom(value: unknown): AbortSignal | undefined {\n\treturn value instanceof AbortSignal ? value : undefined;\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\") throw new Error(`${label} must be a non-empty string`);\n\treturn value;\n}\n"]}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from agent-forge `src/profile/runtime-capabilities-shared.ts`
|
|
3
|
+
* (D-075 S3 extraction) so this package keeps its dependency closure limited
|
|
4
|
+
* to the plugin SDK and typebox. Semantics are unchanged; the artifact-ref
|
|
5
|
+
* schema helpers stay host-side because desktop tools do not use them.
|
|
6
|
+
* Deliberate copy shared with `plugins/desktop-windows-observe/src/shared.ts`;
|
|
7
|
+
* keep both copies in sync.
|
|
8
|
+
*/
|
|
9
|
+
function objectInput(first, second) {
|
|
10
|
+
const value = second === undefined ? first : second;
|
|
11
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
12
|
+
throw new Error("Plugin tool input must be an object");
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export function toolInvocation(first, second) {
|
|
17
|
+
return {
|
|
18
|
+
input: objectInput(first, second),
|
|
19
|
+
operationId: typeof first === "string" && first.trim() !== "" ? first : "profile-runtime-tool-call",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function signalFrom(value) {
|
|
23
|
+
return value instanceof AbortSignal ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
export function nonEmptyString(value, label) {
|
|
26
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
27
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,SAAS,WAAW,CAAC,KAAc,EAAE,MAAe,EAA2B;IAC9E,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACpD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,KAAgC,CAAC;AAAA,CACxC;AAED,MAAM,UAAU,cAAc,CAC7B,KAAc,EACd,MAAe,EAC6D;IAC5E,OAAO;QACN,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QACjC,WAAW,EAAE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,2BAA2B;KACnG,CAAC;AAAA,CACF;AAED,MAAM,UAAU,UAAU,CAAC,KAAc,EAA2B;IACnE,OAAO,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CACxD;AAED,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAa,EAAU;IACrE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,6BAA6B,CAAC,CAAC;IAC7G,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["/**\n * Inlined from agent-forge `src/profile/runtime-capabilities-shared.ts`\n * (D-075 S3 extraction) so this package keeps its dependency closure limited\n * to the plugin SDK and typebox. Semantics are unchanged; the artifact-ref\n * schema helpers stay host-side because desktop tools do not use them.\n * Deliberate copy shared with `plugins/desktop-windows-observe/src/shared.ts`;\n * keep both copies in sync.\n */\n\nfunction objectInput(first: unknown, second: unknown): Record<string, unknown> {\n\tconst value = second === undefined ? first : second;\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Plugin tool input must be an object\");\n\t}\n\treturn value as Record<string, unknown>;\n}\n\nexport function toolInvocation(\n\tfirst: unknown,\n\tsecond: unknown,\n): { readonly input: Record<string, unknown>; readonly operationId: string } {\n\treturn {\n\t\tinput: objectInput(first, second),\n\t\toperationId: typeof first === \"string\" && first.trim() !== \"\" ? first : \"profile-runtime-tool-call\",\n\t};\n}\n\nexport function signalFrom(value: unknown): AbortSignal | undefined {\n\treturn value instanceof AbortSignal ? value : undefined;\n}\n\nexport function nonEmptyString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\" || value.trim() === \"\") throw new Error(`${label} must be a non-empty string`);\n\treturn value;\n}\n"]}
|