@odla-ai/harness 0.1.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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -0
  3. package/dist/chunk-ATKV6VTU.js +168 -0
  4. package/dist/chunk-ATKV6VTU.js.map +1 -0
  5. package/dist/chunk-GE6CCN7W.js +93 -0
  6. package/dist/chunk-GE6CCN7W.js.map +1 -0
  7. package/dist/chunk-GMVZ4LZH.js +1769 -0
  8. package/dist/chunk-GMVZ4LZH.js.map +1 -0
  9. package/dist/chunk-PHXQH4YM.js +550 -0
  10. package/dist/chunk-PHXQH4YM.js.map +1 -0
  11. package/dist/chunk-PTXZVYD4.js +81 -0
  12. package/dist/chunk-PTXZVYD4.js.map +1 -0
  13. package/dist/chunk-QTUEF2HZ.js +9 -0
  14. package/dist/chunk-QTUEF2HZ.js.map +1 -0
  15. package/dist/cli.cjs +795 -0
  16. package/dist/cli.cjs.map +1 -0
  17. package/dist/cli.d.cts +1 -0
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.js +98 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/code-runtime-cli.cjs +2341 -0
  22. package/dist/code-runtime-cli.cjs.map +1 -0
  23. package/dist/code-runtime-cli.d.cts +1 -0
  24. package/dist/code-runtime-cli.d.ts +1 -0
  25. package/dist/code-runtime-cli.js +133 -0
  26. package/dist/code-runtime-cli.js.map +1 -0
  27. package/dist/index.cjs +228 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +44 -0
  30. package/dist/index.d.ts +44 -0
  31. package/dist/index.js +46 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/node.cjs +2580 -0
  34. package/dist/node.cjs.map +1 -0
  35. package/dist/node.d.cts +544 -0
  36. package/dist/node.d.ts +544 -0
  37. package/dist/node.js +71 -0
  38. package/dist/node.js.map +1 -0
  39. package/dist/testing.cjs +106 -0
  40. package/dist/testing.cjs.map +1 -0
  41. package/dist/testing.d.cts +25 -0
  42. package/dist/testing.d.ts +25 -0
  43. package/dist/testing.js +79 -0
  44. package/dist/testing.js.map +1 -0
  45. package/dist/types-D12vK3K9.d.cts +249 -0
  46. package/dist/types-D12vK3K9.d.ts +249 -0
  47. package/package.json +84 -0
@@ -0,0 +1,249 @@
1
+ import { OracleResponse, ChatInput } from '@odla-ai/ai';
2
+
3
+ /** Current JSONL protocol version exchanged between a runner and an agent container. */
4
+ declare const HARNESS_PROTOCOL_VERSION: 1;
5
+ /** Default control-plane route used for model inference requested by coding agents. */
6
+ declare const DEFAULT_AI_ROUTE: "coding";
7
+ /** Lifecycle state reported for a harness task and its active attempt. */
8
+ type HarnessTaskStatus = "queued" | "running" | "cancel_requested" | "completed" | "failed" | "cancelled";
9
+ /** Lifecycle state of one execution attempt for a task. */
10
+ type HarnessAttemptStatus = HarnessTaskStatus;
11
+ /** Trusted or untrusted participant that emitted a harness event. */
12
+ type HarnessActor = "operator" | "runner" | "agent" | "model" | "system";
13
+ /** Resource and isolation limits enforced while an untrusted task executes. */
14
+ interface HarnessPolicy {
15
+ network: "none";
16
+ timeoutMs: number;
17
+ maxOutputBytes: number;
18
+ maxPatchBytes: number;
19
+ }
20
+ /** Immutable task instructions and execution policy delivered with a lease. */
21
+ interface HarnessTaskSpec {
22
+ taskId: string;
23
+ attemptId: string;
24
+ title: string;
25
+ prompt: string;
26
+ workspace: string;
27
+ aiRoute: string;
28
+ policy: HarnessPolicy;
29
+ parentAttemptId?: string | null;
30
+ checkpointSeq?: number | null;
31
+ }
32
+ /** Time-bound assignment authorizing a runner to execute one task attempt. */
33
+ interface HarnessLease {
34
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
35
+ leaseId: string;
36
+ generation: number;
37
+ expiresAt: number;
38
+ task: HarnessTaskSpec;
39
+ }
40
+ /** Runner-supplied event before the control plane assigns sequence and task metadata. */
41
+ interface HarnessEventInput {
42
+ eventId: string;
43
+ kind: string;
44
+ actor: HarnessActor;
45
+ payload: unknown;
46
+ createdAt: number;
47
+ }
48
+ /** Persisted, ordered event associated with a specific task attempt. */
49
+ interface HarnessEvent extends HarnessEventInput {
50
+ seq: number;
51
+ taskId: string;
52
+ attemptId: string;
53
+ }
54
+ /** List-view metadata for a task and its current attempt. */
55
+ interface HarnessTaskSummary {
56
+ taskId: string;
57
+ attemptId: string;
58
+ appId: string;
59
+ env: string;
60
+ title: string;
61
+ prompt: string;
62
+ workspace: string;
63
+ aiRoute: string;
64
+ status: HarnessTaskStatus;
65
+ parentAttemptId: string | null;
66
+ checkpointSeq: number | null;
67
+ runnerId: string | null;
68
+ generation: number;
69
+ createdAt: number;
70
+ updatedAt: number;
71
+ }
72
+ /** List-view metadata for one attempt, including retry ancestry and runner ownership. */
73
+ interface HarnessAttemptSummary {
74
+ attemptId: string;
75
+ taskId: string;
76
+ parentAttemptId: string | null;
77
+ checkpointSeq: number | null;
78
+ status: HarnessAttemptStatus;
79
+ runnerId: string | null;
80
+ generation: number;
81
+ createdAt: number;
82
+ updatedAt: number;
83
+ }
84
+ /** Complete task view including attempts, events, result, and generated patch. */
85
+ interface HarnessTaskDetail extends HarnessTaskSummary {
86
+ attempts: HarnessAttemptSummary[];
87
+ events: HarnessEvent[];
88
+ patch: string | null;
89
+ result: unknown;
90
+ }
91
+ /** Public control-plane view of a registered harness runner. */
92
+ interface HarnessRunnerView {
93
+ runnerId: string;
94
+ appId: string;
95
+ env: string;
96
+ name: string;
97
+ createdAt: number;
98
+ lastSeenAt: number | null;
99
+ revokedAt: number | null;
100
+ }
101
+ /** Credential-free normalized model request sent from an agent through the runner. */
102
+ interface HarnessInferenceRequest {
103
+ requestId: string;
104
+ /** Exact initial, follow-up, or resume command whose budget this call consumes. */
105
+ interactionId?: string;
106
+ call: ChatInput;
107
+ }
108
+ /** Normalized model response plus auditable provider, policy, and token metadata. */
109
+ interface HarnessInferenceResponse {
110
+ requestId: string;
111
+ response: OracleResponse;
112
+ receipt: {
113
+ provider: string;
114
+ model: string;
115
+ policyVersion: number;
116
+ inputTokens: number;
117
+ outputTokens: number;
118
+ };
119
+ }
120
+ /** Bounded, content-free session activity emitted by a Code runtime. Message
121
+ * bodies are projected separately into the app's owner-private odla-db chat. */
122
+ type CodeSessionEventData = {
123
+ type: "message";
124
+ actor: "agent" | "system";
125
+ body: string;
126
+ } | {
127
+ type: "diagnostic";
128
+ level: "error";
129
+ message: string;
130
+ } | {
131
+ type: "thinking";
132
+ available: true;
133
+ durationMs: number;
134
+ } | {
135
+ type: "tool";
136
+ phase: "started";
137
+ tool: HarnessToolName;
138
+ } | {
139
+ type: "tool";
140
+ phase: "completed";
141
+ tool: HarnessToolName;
142
+ ok: boolean;
143
+ durationMs: number;
144
+ } | {
145
+ type: "usage";
146
+ provider: string;
147
+ model: string;
148
+ inputTokens: number;
149
+ outputTokens: number;
150
+ durationMs: number;
151
+ interactionId?: string;
152
+ interactionTokens?: number;
153
+ interactionMaxTokens?: number;
154
+ } | {
155
+ type: "status";
156
+ status: "running" | "idle" | "failed" | "checkpointed";
157
+ durationMs?: number;
158
+ };
159
+ /** Registry-assigned cursor and timestamp for an owner-visible Code event. */
160
+ type CodeSessionEvent = CodeSessionEventData & {
161
+ eventId: string;
162
+ sequence: number;
163
+ createdAt: number;
164
+ };
165
+ /** Closed set of effects an agent container may request from its trusted broker. */
166
+ type HarnessToolName = "sandbox.read" | "sandbox.apply_patch" | "sandbox.run_recipe";
167
+ /** Correlated, structured tool request emitted by an untrusted agent container. */
168
+ interface HarnessToolRequest {
169
+ requestId: string;
170
+ tool: HarnessToolName;
171
+ input: Record<string, unknown>;
172
+ }
173
+ /** Bounded tool result returned to an agent after trusted policy evaluation. */
174
+ interface HarnessToolResponse {
175
+ requestId: string;
176
+ ok: boolean;
177
+ content: string;
178
+ details?: Record<string, unknown>;
179
+ }
180
+ /** Validated JSONL message emitted by an untrusted agent container. */
181
+ type HarnessAgentOutput = {
182
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
183
+ type: "event";
184
+ kind: string;
185
+ payload?: unknown;
186
+ } | {
187
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
188
+ type: "inference.request";
189
+ requestId: string;
190
+ call: ChatInput;
191
+ } | ({
192
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
193
+ type: "tool.request";
194
+ } & HarnessToolRequest) | {
195
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
196
+ type: "attempt.complete";
197
+ status: "completed" | "failed" | "cancelled";
198
+ result?: unknown;
199
+ };
200
+ /** JSONL command or inference result written by the trusted runner to an agent. */
201
+ type HarnessAgentInput = {
202
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
203
+ type: "task.start";
204
+ task: HarnessTaskSpec;
205
+ } | {
206
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
207
+ type: "inference.response";
208
+ requestId: string;
209
+ response: OracleResponse;
210
+ } | ({
211
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
212
+ type: "tool.response";
213
+ } & HarnessToolResponse) | {
214
+ protocolVersion: typeof HARNESS_PROTOCOL_VERSION;
215
+ type: "attempt.cancel";
216
+ reason: string;
217
+ };
218
+ /** Terminal attempt report submitted by a runner to the control plane. */
219
+ interface HarnessCompletion {
220
+ status: "completed" | "failed" | "cancelled";
221
+ result?: unknown;
222
+ patch?: string;
223
+ error?: string;
224
+ }
225
+ /** Operations a credentialed runner may perform against the harness control plane. */
226
+ interface HarnessControlPlane {
227
+ lease(workspaces: string[]): Promise<HarnessLease | null>;
228
+ heartbeat(attemptId: string, leaseId: string): Promise<{
229
+ cancelRequested: boolean;
230
+ expiresAt: number;
231
+ }>;
232
+ appendEvents(attemptId: string, leaseId: string, events: HarnessEventInput[]): Promise<void>;
233
+ infer(attemptId: string, leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;
234
+ complete(attemptId: string, leaseId: string, completion: HarnessCompletion): Promise<void>;
235
+ }
236
+ /** Trusted inference bridge used to keep model credentials outside agent containers. */
237
+ interface HarnessAiConnection {
238
+ infer(request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;
239
+ }
240
+ /** Trusted tool boundary. Implementations must evaluate CaMeL policy before effects. */
241
+ interface HarnessToolBroker {
242
+ execute(context: {
243
+ lease: HarnessLease;
244
+ workspaceDir: string;
245
+ signal?: AbortSignal;
246
+ }, request: HarnessToolRequest): Promise<HarnessToolResponse>;
247
+ }
248
+
249
+ export { type CodeSessionEvent as C, DEFAULT_AI_ROUTE as D, type HarnessControlPlane as H, type HarnessLease as a, type HarnessEventInput as b, type HarnessCompletion as c, type HarnessInferenceRequest as d, type HarnessInferenceResponse as e, type HarnessAgentInput as f, type HarnessAgentOutput as g, type HarnessAiConnection as h, type CodeSessionEventData as i, HARNESS_PROTOCOL_VERSION as j, type HarnessActor as k, type HarnessAttemptStatus as l, type HarnessAttemptSummary as m, type HarnessEvent as n, type HarnessPolicy as o, type HarnessRunnerView as p, type HarnessTaskDetail as q, type HarnessTaskSpec as r, type HarnessTaskStatus as s, type HarnessTaskSummary as t, type HarnessToolBroker as u, type HarnessToolName as v, type HarnessToolRequest as w, type HarnessToolResponse as x };
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@odla-ai/harness",
3
+ "version": "0.1.0",
4
+ "description": "Safe, inspectable coding-task protocol and credentialless container runner for odla Studio.",
5
+ "license": "MIT",
6
+ "homepage": "https://odla.ai/docs/packages/harness",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/cory/odla-ai.git",
10
+ "directory": "packages/harness"
11
+ },
12
+ "type": "module",
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./node": {
23
+ "types": "./dist/node.d.ts",
24
+ "import": "./dist/node.js",
25
+ "require": "./dist/node.cjs"
26
+ },
27
+ "./testing": {
28
+ "types": "./dist/testing.d.ts",
29
+ "import": "./dist/testing.js",
30
+ "require": "./dist/testing.cjs"
31
+ }
32
+ },
33
+ "bin": {
34
+ "odla-harness": "./dist/cli.js",
35
+ "odla-code-runtime": "./dist/code-runtime-cli.js"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "sideEffects": false,
43
+ "engines": {
44
+ "node": ">=20"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "provenance": false
49
+ },
50
+ "keywords": [
51
+ "odla",
52
+ "odla-ai",
53
+ "coding-agent",
54
+ "container",
55
+ "sandbox",
56
+ "harness"
57
+ ],
58
+ "scripts": {
59
+ "build": "tsup",
60
+ "clean": "rm -rf dist",
61
+ "typecheck": "tsc --noEmit",
62
+ "test": "vitest run",
63
+ "test:container": "ODLA_HARNESS_CONTAINER_TEST=1 vitest run test/container.integration.test.ts",
64
+ "prepublishOnly": "npm run test && npm run typecheck && npm run build"
65
+ },
66
+ "peerDependencies": {
67
+ "@odla-ai/ai": ">=0.4.0 <1.0.0"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@odla-ai/ai": {
71
+ "optional": true
72
+ }
73
+ },
74
+ "dependencies": {
75
+ "@odla-ai/camel": "*"
76
+ },
77
+ "devDependencies": {
78
+ "@odla-ai/ai": "*",
79
+ "@types/node": "^26.1.0",
80
+ "tsup": "^8.5.1",
81
+ "typescript": "^6.0.3",
82
+ "vitest": "^4.1.9"
83
+ }
84
+ }