@oharness/engine 0.9.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/acp/claude.d.ts +34 -0
  2. package/dist/acp/claude.js +122 -0
  3. package/dist/acp/claude.js.map +1 -0
  4. package/dist/acp/client.d.ts +193 -0
  5. package/dist/acp/client.js +279 -0
  6. package/dist/acp/client.js.map +1 -0
  7. package/dist/acp/runner.d.ts +80 -0
  8. package/dist/acp/runner.js +159 -0
  9. package/dist/acp/runner.js.map +1 -0
  10. package/dist/agent/agent.d.ts +258 -2
  11. package/dist/agent/agent.js +1010 -53
  12. package/dist/agent/agent.js.map +1 -1
  13. package/dist/agent/background.d.ts +135 -0
  14. package/dist/agent/background.js +307 -0
  15. package/dist/agent/background.js.map +1 -0
  16. package/dist/agent/compaction.d.ts +7 -0
  17. package/dist/agent/compaction.js +11 -3
  18. package/dist/agent/compaction.js.map +1 -1
  19. package/dist/agent/goal.d.ts +36 -0
  20. package/dist/agent/goal.js +71 -0
  21. package/dist/agent/goal.js.map +1 -0
  22. package/dist/agent/hooks.js +6 -6
  23. package/dist/agent/hooks.js.map +1 -1
  24. package/dist/agent/permissions.d.ts +6 -0
  25. package/dist/agent/permissions.js +2 -1
  26. package/dist/agent/permissions.js.map +1 -1
  27. package/dist/agent/session.d.ts +38 -0
  28. package/dist/agent/session.js +91 -2
  29. package/dist/agent/session.js.map +1 -1
  30. package/dist/agent/store.d.ts +25 -0
  31. package/dist/agent/store.js +21 -0
  32. package/dist/agent/store.js.map +1 -1
  33. package/dist/agent/subagent.d.ts +21 -0
  34. package/dist/agent/subagent.js +17 -1
  35. package/dist/agent/subagent.js.map +1 -1
  36. package/dist/agent/workspace.d.ts +9 -0
  37. package/dist/agent/workspace.js +59 -5
  38. package/dist/agent/workspace.js.map +1 -1
  39. package/dist/auth/index.d.ts +3 -1
  40. package/dist/auth/index.js +3 -1
  41. package/dist/auth/index.js.map +1 -1
  42. package/dist/auth/manager.d.ts +9 -0
  43. package/dist/auth/manager.js +71 -6
  44. package/dist/auth/manager.js.map +1 -1
  45. package/dist/auth/oauth.d.ts +33 -0
  46. package/dist/auth/oauth.js +59 -8
  47. package/dist/auth/oauth.js.map +1 -1
  48. package/dist/auth/providers/account.js +5 -4
  49. package/dist/auth/providers/account.js.map +1 -1
  50. package/dist/auth/providers/anthropic.d.ts +25 -5
  51. package/dist/auth/providers/anthropic.js +47 -6
  52. package/dist/auth/providers/anthropic.js.map +1 -1
  53. package/dist/auth/providers/chatgpt.d.ts +8 -0
  54. package/dist/auth/providers/chatgpt.js +180 -0
  55. package/dist/auth/providers/chatgpt.js.map +1 -0
  56. package/dist/auth/providers/openrouter.d.ts +2 -0
  57. package/dist/auth/providers/openrouter.js +101 -0
  58. package/dist/auth/providers/openrouter.js.map +1 -0
  59. package/dist/auth/types.d.ts +15 -0
  60. package/dist/auth/types.js.map +1 -1
  61. package/dist/browser/index.d.ts +1 -1
  62. package/dist/browser/plugin.d.ts +6 -1
  63. package/dist/browser/plugin.js.map +1 -1
  64. package/dist/browser/session.d.ts +47 -0
  65. package/dist/browser/session.js +177 -2
  66. package/dist/browser/session.js.map +1 -1
  67. package/dist/browser/tools.js +142 -18
  68. package/dist/browser/tools.js.map +1 -1
  69. package/dist/computer/arbiter.d.ts +69 -0
  70. package/dist/computer/arbiter.js +128 -0
  71. package/dist/computer/arbiter.js.map +1 -0
  72. package/dist/computer/cua-driver.d.ts +174 -0
  73. package/dist/computer/cua-driver.js +597 -0
  74. package/dist/computer/cua-driver.js.map +1 -0
  75. package/dist/computer/helper-client.d.ts +80 -0
  76. package/dist/computer/helper-client.js +166 -0
  77. package/dist/computer/helper-client.js.map +1 -0
  78. package/dist/computer/index.d.ts +16 -0
  79. package/dist/computer/index.js +9 -0
  80. package/dist/computer/index.js.map +1 -0
  81. package/dist/computer/mode.d.ts +34 -0
  82. package/dist/computer/mode.js +52 -0
  83. package/dist/computer/mode.js.map +1 -0
  84. package/dist/computer/plugin.d.ts +24 -0
  85. package/dist/computer/plugin.js +17 -0
  86. package/dist/computer/plugin.js.map +1 -0
  87. package/dist/computer/policy.d.ts +29 -0
  88. package/dist/computer/policy.js +127 -0
  89. package/dist/computer/policy.js.map +1 -0
  90. package/dist/computer/session.d.ts +228 -0
  91. package/dist/computer/session.js +493 -0
  92. package/dist/computer/session.js.map +1 -0
  93. package/dist/computer/target.d.ts +206 -0
  94. package/dist/computer/target.js +31 -0
  95. package/dist/computer/target.js.map +1 -0
  96. package/dist/computer/tools.d.ts +8 -0
  97. package/dist/computer/tools.js +664 -0
  98. package/dist/computer/tools.js.map +1 -0
  99. package/dist/config.d.ts +7 -0
  100. package/dist/config.js.map +1 -1
  101. package/dist/core/tokens.js +4 -0
  102. package/dist/core/tokens.js.map +1 -1
  103. package/dist/core/types.d.ts +16 -1
  104. package/dist/core/types.js.map +1 -1
  105. package/dist/harness.d.ts +128 -1
  106. package/dist/harness.js +287 -30
  107. package/dist/harness.js.map +1 -1
  108. package/dist/index.d.ts +3 -0
  109. package/dist/index.js +2 -0
  110. package/dist/index.js.map +1 -1
  111. package/dist/mcp/manager.d.ts +15 -0
  112. package/dist/mcp/manager.js +28 -1
  113. package/dist/mcp/manager.js.map +1 -1
  114. package/dist/mcp/transport.js +3 -0
  115. package/dist/mcp/transport.js.map +1 -1
  116. package/dist/providers/catalog.js +6 -0
  117. package/dist/providers/catalog.js.map +1 -1
  118. package/dist/providers/catalog.json +14 -3
  119. package/dist/providers/discovery.js +10 -2
  120. package/dist/providers/discovery.js.map +1 -1
  121. package/dist/providers/models-dev.d.ts +15 -0
  122. package/dist/providers/models-dev.js +15 -0
  123. package/dist/providers/models-dev.js.map +1 -1
  124. package/dist/providers/models-dev.json +114 -102
  125. package/dist/providers/piai.d.ts +54 -2
  126. package/dist/providers/piai.js +154 -9
  127. package/dist/providers/piai.js.map +1 -1
  128. package/dist/providers/registry.d.ts +16 -1
  129. package/dist/providers/registry.js +42 -11
  130. package/dist/providers/registry.js.map +1 -1
  131. package/dist/providers/types.d.ts +6 -0
  132. package/dist/providers/types.js.map +1 -1
  133. package/dist/runtime-plugins/builtin/studio.d.ts +7 -0
  134. package/dist/runtime-plugins/builtin/studio.js +69 -4
  135. package/dist/runtime-plugins/builtin/studio.js.map +1 -1
  136. package/dist/runtime-plugins/cloud-connector.js +5 -0
  137. package/dist/runtime-plugins/cloud-connector.js.map +1 -1
  138. package/dist/schedule/scheduler.d.ts +38 -0
  139. package/dist/schedule/scheduler.js +101 -1
  140. package/dist/schedule/scheduler.js.map +1 -1
  141. package/dist/tools/builtin/bash.d.ts +6 -0
  142. package/dist/tools/builtin/bash.js +8 -11
  143. package/dist/tools/builtin/bash.js.map +1 -1
  144. package/dist/tools/builtin/recall.js +4 -0
  145. package/dist/tools/builtin/recall.js.map +1 -1
  146. package/dist/tools/builtin/routine.d.ts +9 -0
  147. package/dist/tools/builtin/routine.js +23 -2
  148. package/dist/tools/builtin/routine.js.map +1 -1
  149. package/dist/tools/builtin/task-control.d.ts +21 -0
  150. package/dist/tools/builtin/task-control.js +120 -0
  151. package/dist/tools/builtin/task-control.js.map +1 -0
  152. package/dist/tools/builtin/task.js +50 -9
  153. package/dist/tools/builtin/task.js.map +1 -1
  154. package/dist/tools/builtin/todo.d.ts +1 -1
  155. package/dist/tools/builtin/worktree.d.ts +10 -0
  156. package/dist/tools/builtin/worktree.js +52 -0
  157. package/dist/tools/builtin/worktree.js.map +1 -0
  158. package/dist/tools/define.d.ts +4 -1
  159. package/dist/tools/define.js +2 -0
  160. package/dist/tools/define.js.map +1 -1
  161. package/dist/tools/types.d.ts +112 -0
  162. package/dist/tools/types.js.map +1 -1
  163. package/dist/util/shell.d.ts +30 -0
  164. package/dist/util/shell.js +70 -0
  165. package/dist/util/shell.js.map +1 -1
  166. package/dist/worktree/index.d.ts +109 -0
  167. package/dist/worktree/index.js +463 -0
  168. package/dist/worktree/index.js.map +1 -0
  169. package/package.json +3 -3
  170. package/skills/media-generation/SKILL.md +22 -1
@@ -0,0 +1,174 @@
1
+ import type { Logger } from "../util/logger.ts";
2
+ import type { AppInfo, AxAction, AxNode, ComputerInputEvent, ComputerPermissions, ComputerTarget, DisplayInfo, HelperInfo, Rect, Shot, WindowInfo } from "./target.ts";
3
+ /**
4
+ * A `ComputerTarget` backed by Cua Driver (github.com/trycua/cua, MIT).
5
+ *
6
+ * Cua Driver is the platform layer: ScreenCaptureKit and AX with SkyLight
7
+ * background input on macOS; UIA, MSAA, PostMessage and WGC on Windows. We
8
+ * drive its MCP server over stdio and keep everything above it — the tools
9
+ * the model sees, per-app approval, tiers, the arbiter — our own. The model
10
+ * never talks to Cua Driver directly: only this adapter does, and it calls a
11
+ * fixed handful of its 58 tools.
12
+ *
13
+ * How it is run matters:
14
+ *
15
+ * - Embedded (`CUA_DRIVER_EMBEDDED=1`) and spawned by the app itself, so
16
+ * macOS charges its TCC requests to OHarness and the person grants
17
+ * OHarness, not a second app. The driver never prompts in this mode; the
18
+ * host asks (see `requestPermissions`).
19
+ * - Telemetry and the update check off. Both default on, embedded or not.
20
+ * - `mcp --direct`: no daemon and no Cua cursor. The desktop app draws its
21
+ * own, per conversation, and keeps it out of captures.
22
+ *
23
+ * Coordinates: Cua takes pointer x/y in pixels of the window screenshot it
24
+ * last returned. The engine works in screen units (each screenshot's frame
25
+ * says where its pixels sit), so pointer events are mapped back through the
26
+ * last screenshot of that window here. Element frames already come in screen
27
+ * units.
28
+ */
29
+ export interface CuaDriverOptions {
30
+ /** The cua-driver executable. */
31
+ path: string;
32
+ /** The host app's bundle id, for Cua's own identity checks. */
33
+ hostBundleId?: string;
34
+ /** Where the driver may keep state; telemetry is off either way. */
35
+ stateDir?: string;
36
+ /**
37
+ * The Rego policy the driver enforces on every call: only the tools this
38
+ * adapter uses, and none that write files (desktop/computer-helper/cua/policy.rego).
39
+ */
40
+ policyFile?: string;
41
+ logger?: Logger;
42
+ /**
43
+ * Ask the OS for Screen Recording or Accessibility. Embedded, the driver
44
+ * never prompts: the host app has to, as itself.
45
+ */
46
+ requestPermissions?: (grant?: keyof ComputerPermissions) => Promise<void>;
47
+ /** Milliseconds since the person's last real input, from the host. */
48
+ idle?: () => Promise<number>;
49
+ /**
50
+ * Who a process is, asked live. Cua's running-app list is a snapshot that
51
+ * goes stale (see `apps`); this names the pids it is missing. Defaults to
52
+ * `lsappinfo` on macOS.
53
+ */
54
+ appForPid?: (pid: number) => Promise<{
55
+ name: string;
56
+ id: string;
57
+ } | undefined>;
58
+ /** Whether a pid is still a process. Injectable for tests. */
59
+ alive?: (pid: number) => boolean;
60
+ /**
61
+ * The monitors, from the host. Cua Driver only knows the main one, so
62
+ * without this the agent sees a single display.
63
+ */
64
+ displays?: () => Promise<DisplayInfo[]>;
65
+ /**
66
+ * Capture a display, or a region of one, as the host. Cua's desktop
67
+ * capture is the main display, whole; any other display, and any region of
68
+ * one, comes from here.
69
+ */
70
+ captureDisplay?: (opts: {
71
+ display?: string;
72
+ region?: Rect;
73
+ maxWidth: number;
74
+ }) => Promise<Shot>;
75
+ /**
76
+ * A region of a window at full pixel density, from the host. Cua's own
77
+ * zoom stops at 500 px wide, which turns a strip across a window into a
78
+ * picture too small to read; it stays the fallback.
79
+ */
80
+ captureWindow?: (opts: {
81
+ window: string;
82
+ region: Rect;
83
+ maxWidth: number;
84
+ }) => Promise<Shot>;
85
+ }
86
+ export declare class CuaDriverTarget implements ComputerTarget {
87
+ private readonly client;
88
+ private readonly opts;
89
+ private readonly pids;
90
+ private readonly shots;
91
+ private readonly refs;
92
+ /** The field typing goes to, per window, set by `axAction focus`. */
93
+ private readonly targets;
94
+ private appIds;
95
+ private version;
96
+ private constructor();
97
+ static start(opts: CuaDriverOptions): Promise<CuaDriverTarget>;
98
+ private call;
99
+ private refusal;
100
+ private pidOf;
101
+ /** Screen point → pixels of the last screenshot of this window, taking one if needed. */
102
+ private toWindowPixels;
103
+ info(): Promise<HelperInfo>;
104
+ permissions(): Promise<ComputerPermissions>;
105
+ requestPermissions(grant?: keyof ComputerPermissions): Promise<void>;
106
+ /**
107
+ * The running apps, checked against the live windows.
108
+ *
109
+ * Cua builds `list_apps` from NSWorkspace's runningApplications, which a
110
+ * process only keeps current by running its main run loop — and the driver,
111
+ * embedded and long-lived, does not. The list stays as it was when the
112
+ * driver started: an app launched since is missing, and one relaunched keeps
113
+ * its old, dead pid. Windows, from the window server, are live. So an entry
114
+ * whose process is gone is dropped, and a pid that owns a window but is not
115
+ * listed is named live — by bundle id, which is what tiers and approvals go
116
+ * by, so a browser opened after OHarness is still a browser.
117
+ */
118
+ apps(): Promise<AppInfo[]>;
119
+ private reconcile;
120
+ windows(opts?: {
121
+ pid?: number;
122
+ }): Promise<WindowInfo[]>;
123
+ displays(): Promise<DisplayInfo[]>;
124
+ screenshot(opts: {
125
+ window?: string;
126
+ display?: string;
127
+ region?: Rect;
128
+ maxWidth?: number;
129
+ }): Promise<Shot>;
130
+ /**
131
+ * A region of a window through Cua's own zoom: cropped from a full-density
132
+ * capture, padded by a fifth on each side, at most 500 px wide. It reads
133
+ * the region in pixels of the last screenshot this connection took of the
134
+ * window, and a tree read since may have replaced that one, so a refusal
135
+ * for want of it takes a screenshot the same size and tries once more.
136
+ */
137
+ private zoom;
138
+ axTree(opts: {
139
+ window: string;
140
+ depth?: number;
141
+ maxNodes?: number;
142
+ }): Promise<{
143
+ nodes: AxNode[];
144
+ truncated: boolean;
145
+ }>;
146
+ private refInfo;
147
+ /**
148
+ * Run an action on a ref, re-finding the element once if its token went
149
+ * stale. Any snapshot of a window — a screenshot included — supersedes the
150
+ * tokens of the one before, and the model reasonably reads the tree, looks
151
+ * at the window, then clicks.
152
+ */
153
+ private onRef;
154
+ axAction(ref: string, action: AxAction, value?: string): Promise<void>;
155
+ input(event: ComputerInputEvent, opts: {
156
+ window?: string;
157
+ foreground: boolean;
158
+ }): Promise<void>;
159
+ invokeMenu(window: string, path: string[]): Promise<void>;
160
+ open(app: string): Promise<{
161
+ pid?: number;
162
+ }>;
163
+ frontmost(): Promise<{
164
+ pid: number;
165
+ appId: string;
166
+ window?: string;
167
+ }>;
168
+ activate(pid: number): Promise<void>;
169
+ idle(): Promise<number>;
170
+ pointVisible(window: string, x: number, y: number): Promise<boolean>;
171
+ clipboardRead(): Promise<string>;
172
+ clipboardWrite(text: string): Promise<void>;
173
+ close(): Promise<void>;
174
+ }