@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.
- package/LICENSE +21 -0
- package/README.md +178 -0
- package/dist/chunk-ATKV6VTU.js +168 -0
- package/dist/chunk-ATKV6VTU.js.map +1 -0
- package/dist/chunk-GE6CCN7W.js +93 -0
- package/dist/chunk-GE6CCN7W.js.map +1 -0
- package/dist/chunk-GMVZ4LZH.js +1769 -0
- package/dist/chunk-GMVZ4LZH.js.map +1 -0
- package/dist/chunk-PHXQH4YM.js +550 -0
- package/dist/chunk-PHXQH4YM.js.map +1 -0
- package/dist/chunk-PTXZVYD4.js +81 -0
- package/dist/chunk-PTXZVYD4.js.map +1 -0
- package/dist/chunk-QTUEF2HZ.js +9 -0
- package/dist/chunk-QTUEF2HZ.js.map +1 -0
- package/dist/cli.cjs +795 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +98 -0
- package/dist/cli.js.map +1 -0
- package/dist/code-runtime-cli.cjs +2341 -0
- package/dist/code-runtime-cli.cjs.map +1 -0
- package/dist/code-runtime-cli.d.cts +1 -0
- package/dist/code-runtime-cli.d.ts +1 -0
- package/dist/code-runtime-cli.js +133 -0
- package/dist/code-runtime-cli.js.map +1 -0
- package/dist/index.cjs +228 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/node.cjs +2580 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +544 -0
- package/dist/node.d.ts +544 -0
- package/dist/node.js +71 -0
- package/dist/node.js.map +1 -0
- package/dist/testing.cjs +106 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +25 -0
- package/dist/testing.d.ts +25 -0
- package/dist/testing.js +79 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-D12vK3K9.d.cts +249 -0
- package/dist/types-D12vK3K9.d.ts +249 -0
- package/package.json +84 -0
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/testing.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
FakeHarnessControlPlane: () => FakeHarnessControlPlane,
|
|
24
|
+
fixtureLease: () => fixtureLease
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(testing_exports);
|
|
27
|
+
|
|
28
|
+
// src/types.ts
|
|
29
|
+
var HARNESS_PROTOCOL_VERSION = 1;
|
|
30
|
+
|
|
31
|
+
// src/testing.ts
|
|
32
|
+
function fixtureLease(overrides = {}) {
|
|
33
|
+
return {
|
|
34
|
+
protocolVersion: HARNESS_PROTOCOL_VERSION,
|
|
35
|
+
leaseId: "lease_fixture",
|
|
36
|
+
generation: 1,
|
|
37
|
+
expiresAt: Date.now() + 6e4,
|
|
38
|
+
task: {
|
|
39
|
+
taskId: "task_fixture",
|
|
40
|
+
attemptId: "attempt_fixture",
|
|
41
|
+
title: "Fixture task",
|
|
42
|
+
prompt: "Create HARNESS_RESULT.md",
|
|
43
|
+
workspace: "fixture",
|
|
44
|
+
aiRoute: "coding",
|
|
45
|
+
policy: {
|
|
46
|
+
network: "none",
|
|
47
|
+
timeoutMs: 3e4,
|
|
48
|
+
maxOutputBytes: 1e6,
|
|
49
|
+
maxPatchBytes: 1e6
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
...overrides
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var FakeHarnessControlPlane = class {
|
|
56
|
+
leases = [];
|
|
57
|
+
events = [];
|
|
58
|
+
completions = [];
|
|
59
|
+
inferenceRequests = [];
|
|
60
|
+
cancelRequested = false;
|
|
61
|
+
response = {
|
|
62
|
+
id: "oracle_fixture",
|
|
63
|
+
model: "fixture-model",
|
|
64
|
+
provider: "openai",
|
|
65
|
+
role: "assistant",
|
|
66
|
+
content: [{ type: "text", text: "deterministic fixture response" }],
|
|
67
|
+
stopReason: "end_turn",
|
|
68
|
+
usage: { inputTokens: 5, outputTokens: 4 }
|
|
69
|
+
};
|
|
70
|
+
constructor(...leases) {
|
|
71
|
+
this.leases.push(...leases);
|
|
72
|
+
}
|
|
73
|
+
async lease(workspaces) {
|
|
74
|
+
const index = this.leases.findIndex((candidate) => workspaces.includes(candidate.task.workspace));
|
|
75
|
+
return index < 0 ? null : this.leases.splice(index, 1)[0];
|
|
76
|
+
}
|
|
77
|
+
async heartbeat() {
|
|
78
|
+
return { cancelRequested: this.cancelRequested, expiresAt: Date.now() + 6e4 };
|
|
79
|
+
}
|
|
80
|
+
async appendEvents(_attemptId, _leaseId, events) {
|
|
81
|
+
this.events.push(...events);
|
|
82
|
+
}
|
|
83
|
+
async infer(_attemptId, _leaseId, request) {
|
|
84
|
+
this.inferenceRequests.push(request);
|
|
85
|
+
return {
|
|
86
|
+
requestId: request.requestId,
|
|
87
|
+
response: this.response,
|
|
88
|
+
receipt: {
|
|
89
|
+
provider: this.response.provider,
|
|
90
|
+
model: this.response.model,
|
|
91
|
+
policyVersion: 1,
|
|
92
|
+
inputTokens: this.response.usage.inputTokens ?? 0,
|
|
93
|
+
outputTokens: this.response.usage.outputTokens ?? 0
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async complete(_attemptId, _leaseId, completion) {
|
|
98
|
+
this.completions.push(completion);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
FakeHarnessControlPlane,
|
|
104
|
+
fixtureLease
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts","../src/types.ts"],"sourcesContent":["import type { OracleResponse } from \"@odla-ai/ai\";\nimport {\n HARNESS_PROTOCOL_VERSION,\n type HarnessCompletion,\n type HarnessControlPlane,\n type HarnessEventInput,\n type HarnessInferenceRequest,\n type HarnessInferenceResponse,\n type HarnessLease,\n} from \"./types\";\n\n/** Create a deterministic, valid lease for harness unit and integration tests. */\nexport function fixtureLease(overrides: Partial<HarnessLease> = {}): HarnessLease {\n return {\n protocolVersion: HARNESS_PROTOCOL_VERSION,\n leaseId: \"lease_fixture\",\n generation: 1,\n expiresAt: Date.now() + 60_000,\n task: {\n taskId: \"task_fixture\",\n attemptId: \"attempt_fixture\",\n title: \"Fixture task\",\n prompt: \"Create HARNESS_RESULT.md\",\n workspace: \"fixture\",\n aiRoute: \"coding\",\n policy: {\n network: \"none\",\n timeoutMs: 30_000,\n maxOutputBytes: 1_000_000,\n maxPatchBytes: 1_000_000,\n },\n },\n ...overrides,\n };\n}\n\n/** In-memory control plane that records runner interactions without network access. */\nexport class FakeHarnessControlPlane implements HarnessControlPlane {\n readonly leases: HarnessLease[] = [];\n readonly events: HarnessEventInput[] = [];\n readonly completions: HarnessCompletion[] = [];\n readonly inferenceRequests: HarnessInferenceRequest[] = [];\n cancelRequested = false;\n response: OracleResponse = {\n id: \"oracle_fixture\",\n model: \"fixture-model\",\n provider: \"openai\",\n role: \"assistant\",\n content: [{ type: \"text\", text: \"deterministic fixture response\" }],\n stopReason: \"end_turn\",\n usage: { inputTokens: 5, outputTokens: 4 },\n };\n\n constructor(...leases: HarnessLease[]) { this.leases.push(...leases); }\n\n async lease(workspaces: string[]): Promise<HarnessLease | null> {\n const index = this.leases.findIndex((candidate) => workspaces.includes(candidate.task.workspace));\n return index < 0 ? null : this.leases.splice(index, 1)[0]!;\n }\n async heartbeat(): Promise<{ cancelRequested: boolean; expiresAt: number }> {\n return { cancelRequested: this.cancelRequested, expiresAt: Date.now() + 60_000 };\n }\n async appendEvents(_attemptId: string, _leaseId: string, events: HarnessEventInput[]): Promise<void> {\n this.events.push(...events);\n }\n async infer(_attemptId: string, _leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse> {\n this.inferenceRequests.push(request);\n return {\n requestId: request.requestId,\n response: this.response,\n receipt: {\n provider: this.response.provider,\n model: this.response.model,\n policyVersion: 1,\n inputTokens: this.response.usage.inputTokens ?? 0,\n outputTokens: this.response.usage.outputTokens ?? 0,\n },\n };\n }\n async complete(_attemptId: string, _leaseId: string, completion: HarnessCompletion): Promise<void> {\n this.completions.push(completion);\n }\n}\n","import type { ChatInput, OracleResponse } from \"@odla-ai/ai\";\n\n/** Current JSONL protocol version exchanged between a runner and an agent container. */\nexport const HARNESS_PROTOCOL_VERSION = 1 as const;\n\n/** Default control-plane route used for model inference requested by coding agents. */\nexport const DEFAULT_AI_ROUTE = \"coding\" as const;\n\n/** Lifecycle state reported for a harness task and its active attempt. */\nexport type HarnessTaskStatus =\n | \"queued\"\n | \"running\"\n | \"cancel_requested\"\n | \"completed\"\n | \"failed\"\n | \"cancelled\";\n\n/** Lifecycle state of one execution attempt for a task. */\nexport type HarnessAttemptStatus = HarnessTaskStatus;\n\n/** Trusted or untrusted participant that emitted a harness event. */\nexport type HarnessActor = \"operator\" | \"runner\" | \"agent\" | \"model\" | \"system\";\n\n/** Resource and isolation limits enforced while an untrusted task executes. */\nexport interface HarnessPolicy {\n network: \"none\";\n timeoutMs: number;\n maxOutputBytes: number;\n maxPatchBytes: number;\n}\n\n/** Immutable task instructions and execution policy delivered with a lease. */\nexport interface HarnessTaskSpec {\n taskId: string;\n attemptId: string;\n title: string;\n prompt: string;\n workspace: string;\n aiRoute: string;\n policy: HarnessPolicy;\n parentAttemptId?: string | null;\n checkpointSeq?: number | null;\n}\n\n/** Time-bound assignment authorizing a runner to execute one task attempt. */\nexport interface HarnessLease {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n leaseId: string;\n generation: number;\n expiresAt: number;\n task: HarnessTaskSpec;\n}\n\n/** Runner-supplied event before the control plane assigns sequence and task metadata. */\nexport interface HarnessEventInput {\n eventId: string;\n kind: string;\n actor: HarnessActor;\n payload: unknown;\n createdAt: number;\n}\n\n/** Persisted, ordered event associated with a specific task attempt. */\nexport interface HarnessEvent extends HarnessEventInput {\n seq: number;\n taskId: string;\n attemptId: string;\n}\n\n/** List-view metadata for a task and its current attempt. */\nexport interface HarnessTaskSummary {\n taskId: string;\n attemptId: string;\n appId: string;\n env: string;\n title: string;\n prompt: string;\n workspace: string;\n aiRoute: string;\n status: HarnessTaskStatus;\n parentAttemptId: string | null;\n checkpointSeq: number | null;\n runnerId: string | null;\n generation: number;\n createdAt: number;\n updatedAt: number;\n}\n\n/** List-view metadata for one attempt, including retry ancestry and runner ownership. */\nexport interface HarnessAttemptSummary {\n attemptId: string;\n taskId: string;\n parentAttemptId: string | null;\n checkpointSeq: number | null;\n status: HarnessAttemptStatus;\n runnerId: string | null;\n generation: number;\n createdAt: number;\n updatedAt: number;\n}\n\n/** Complete task view including attempts, events, result, and generated patch. */\nexport interface HarnessTaskDetail extends HarnessTaskSummary {\n attempts: HarnessAttemptSummary[];\n events: HarnessEvent[];\n patch: string | null;\n result: unknown;\n}\n\n/** Public control-plane view of a registered harness runner. */\nexport interface HarnessRunnerView {\n runnerId: string;\n appId: string;\n env: string;\n name: string;\n createdAt: number;\n lastSeenAt: number | null;\n revokedAt: number | null;\n}\n\n/** Credential-free normalized model request sent from an agent through the runner. */\nexport interface HarnessInferenceRequest {\n requestId: string;\n /** Exact initial, follow-up, or resume command whose budget this call consumes. */\n interactionId?: string;\n call: ChatInput;\n}\n\n/** Normalized model response plus auditable provider, policy, and token metadata. */\nexport interface HarnessInferenceResponse {\n requestId: string;\n response: OracleResponse;\n receipt: {\n provider: string;\n model: string;\n policyVersion: number;\n inputTokens: number;\n outputTokens: number;\n };\n}\n\n/** Bounded, content-free session activity emitted by a Code runtime. Message\n * bodies are projected separately into the app's owner-private odla-db chat. */\nexport type CodeSessionEventData =\n | { type: \"message\"; actor: \"agent\" | \"system\"; body: string }\n | { type: \"diagnostic\"; level: \"error\"; message: string }\n | { type: \"thinking\"; available: true; durationMs: number }\n | { type: \"tool\"; phase: \"started\"; tool: HarnessToolName }\n | { type: \"tool\"; phase: \"completed\"; tool: HarnessToolName; ok: boolean; durationMs: number }\n | {\n type: \"usage\"; provider: string; model: string;\n inputTokens: number; outputTokens: number; durationMs: number;\n interactionId?: string; interactionTokens?: number; interactionMaxTokens?: number;\n }\n | {\n type: \"status\"; status: \"running\" | \"idle\" | \"failed\" | \"checkpointed\";\n durationMs?: number;\n };\n\n/** Registry-assigned cursor and timestamp for an owner-visible Code event. */\nexport type CodeSessionEvent = CodeSessionEventData & {\n eventId: string; sequence: number; createdAt: number;\n};\n\n/** Closed set of effects an agent container may request from its trusted broker. */\nexport type HarnessToolName = \"sandbox.read\" | \"sandbox.apply_patch\" | \"sandbox.run_recipe\";\n/** Correlated, structured tool request emitted by an untrusted agent container. */\nexport interface HarnessToolRequest {\n requestId: string;\n tool: HarnessToolName;\n input: Record<string, unknown>;\n}\n/** Bounded tool result returned to an agent after trusted policy evaluation. */\nexport interface HarnessToolResponse {\n requestId: string;\n ok: boolean;\n content: string;\n details?: Record<string, unknown>;\n}\n\n/** Validated JSONL message emitted by an untrusted agent container. */\nexport type HarnessAgentOutput =\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"event\";\n kind: string;\n payload?: unknown;\n }\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"inference.request\";\n requestId: string;\n call: ChatInput;\n }\n | ({ protocolVersion: typeof HARNESS_PROTOCOL_VERSION; type: \"tool.request\" } & HarnessToolRequest)\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"attempt.complete\";\n status: \"completed\" | \"failed\" | \"cancelled\";\n result?: unknown;\n };\n\n/** JSONL command or inference result written by the trusted runner to an agent. */\nexport type HarnessAgentInput =\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"task.start\";\n task: HarnessTaskSpec;\n }\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"inference.response\";\n requestId: string;\n response: OracleResponse;\n }\n | ({ protocolVersion: typeof HARNESS_PROTOCOL_VERSION; type: \"tool.response\" } & HarnessToolResponse)\n | {\n protocolVersion: typeof HARNESS_PROTOCOL_VERSION;\n type: \"attempt.cancel\";\n reason: string;\n };\n\n/** Terminal attempt report submitted by a runner to the control plane. */\nexport interface HarnessCompletion {\n status: \"completed\" | \"failed\" | \"cancelled\";\n result?: unknown;\n patch?: string;\n error?: string;\n}\n\n/** Operations a credentialed runner may perform against the harness control plane. */\nexport interface HarnessControlPlane {\n lease(workspaces: string[]): Promise<HarnessLease | null>;\n heartbeat(attemptId: string, leaseId: string): Promise<{ cancelRequested: boolean; expiresAt: number }>;\n appendEvents(attemptId: string, leaseId: string, events: HarnessEventInput[]): Promise<void>;\n infer(attemptId: string, leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;\n complete(attemptId: string, leaseId: string, completion: HarnessCompletion): Promise<void>;\n}\n\n/** Trusted inference bridge used to keep model credentials outside agent containers. */\nexport interface HarnessAiConnection {\n infer(request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;\n}\n\n/** Trusted tool boundary. Implementations must evaluate CaMeL policy before effects. */\nexport interface HarnessToolBroker {\n execute(\n context: { lease: HarnessLease; workspaceDir: string; signal?: AbortSignal },\n request: HarnessToolRequest,\n ): Promise<HarnessToolResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,2BAA2B;;;ADSjC,SAAS,aAAa,YAAmC,CAAC,GAAiB;AAChF,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,KAAK,IAAI,IAAI;AAAA,IACxB,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAGO,IAAM,0BAAN,MAA6D;AAAA,EACzD,SAAyB,CAAC;AAAA,EAC1B,SAA8B,CAAC;AAAA,EAC/B,cAAmC,CAAC;AAAA,EACpC,oBAA+C,CAAC;AAAA,EACzD,kBAAkB;AAAA,EAClB,WAA2B;AAAA,IACzB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClE,YAAY;AAAA,IACZ,OAAO,EAAE,aAAa,GAAG,cAAc,EAAE;AAAA,EAC3C;AAAA,EAEA,eAAe,QAAwB;AAAE,SAAK,OAAO,KAAK,GAAG,MAAM;AAAA,EAAG;AAAA,EAEtE,MAAM,MAAM,YAAoD;AAC9D,UAAM,QAAQ,KAAK,OAAO,UAAU,CAAC,cAAc,WAAW,SAAS,UAAU,KAAK,SAAS,CAAC;AAChG,WAAO,QAAQ,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC;AAAA,EAC1D;AAAA,EACA,MAAM,YAAsE;AAC1E,WAAO,EAAE,iBAAiB,KAAK,iBAAiB,WAAW,KAAK,IAAI,IAAI,IAAO;AAAA,EACjF;AAAA,EACA,MAAM,aAAa,YAAoB,UAAkB,QAA4C;AACnG,SAAK,OAAO,KAAK,GAAG,MAAM;AAAA,EAC5B;AAAA,EACA,MAAM,MAAM,YAAoB,UAAkB,SAAqE;AACrH,SAAK,kBAAkB,KAAK,OAAO;AACnC,WAAO;AAAA,MACL,WAAW,QAAQ;AAAA,MACnB,UAAU,KAAK;AAAA,MACf,SAAS;AAAA,QACP,UAAU,KAAK,SAAS;AAAA,QACxB,OAAO,KAAK,SAAS;AAAA,QACrB,eAAe;AAAA,QACf,aAAa,KAAK,SAAS,MAAM,eAAe;AAAA,QAChD,cAAc,KAAK,SAAS,MAAM,gBAAgB;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM,SAAS,YAAoB,UAAkB,YAA8C;AACjG,SAAK,YAAY,KAAK,UAAU;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OracleResponse } from '@odla-ai/ai';
|
|
2
|
+
import { H as HarnessControlPlane, a as HarnessLease, b as HarnessEventInput, c as HarnessCompletion, d as HarnessInferenceRequest, e as HarnessInferenceResponse } from './types-D12vK3K9.cjs';
|
|
3
|
+
|
|
4
|
+
/** Create a deterministic, valid lease for harness unit and integration tests. */
|
|
5
|
+
declare function fixtureLease(overrides?: Partial<HarnessLease>): HarnessLease;
|
|
6
|
+
/** In-memory control plane that records runner interactions without network access. */
|
|
7
|
+
declare class FakeHarnessControlPlane implements HarnessControlPlane {
|
|
8
|
+
readonly leases: HarnessLease[];
|
|
9
|
+
readonly events: HarnessEventInput[];
|
|
10
|
+
readonly completions: HarnessCompletion[];
|
|
11
|
+
readonly inferenceRequests: HarnessInferenceRequest[];
|
|
12
|
+
cancelRequested: boolean;
|
|
13
|
+
response: OracleResponse;
|
|
14
|
+
constructor(...leases: HarnessLease[]);
|
|
15
|
+
lease(workspaces: string[]): Promise<HarnessLease | null>;
|
|
16
|
+
heartbeat(): Promise<{
|
|
17
|
+
cancelRequested: boolean;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
}>;
|
|
20
|
+
appendEvents(_attemptId: string, _leaseId: string, events: HarnessEventInput[]): Promise<void>;
|
|
21
|
+
infer(_attemptId: string, _leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;
|
|
22
|
+
complete(_attemptId: string, _leaseId: string, completion: HarnessCompletion): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { FakeHarnessControlPlane, fixtureLease };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OracleResponse } from '@odla-ai/ai';
|
|
2
|
+
import { H as HarnessControlPlane, a as HarnessLease, b as HarnessEventInput, c as HarnessCompletion, d as HarnessInferenceRequest, e as HarnessInferenceResponse } from './types-D12vK3K9.js';
|
|
3
|
+
|
|
4
|
+
/** Create a deterministic, valid lease for harness unit and integration tests. */
|
|
5
|
+
declare function fixtureLease(overrides?: Partial<HarnessLease>): HarnessLease;
|
|
6
|
+
/** In-memory control plane that records runner interactions without network access. */
|
|
7
|
+
declare class FakeHarnessControlPlane implements HarnessControlPlane {
|
|
8
|
+
readonly leases: HarnessLease[];
|
|
9
|
+
readonly events: HarnessEventInput[];
|
|
10
|
+
readonly completions: HarnessCompletion[];
|
|
11
|
+
readonly inferenceRequests: HarnessInferenceRequest[];
|
|
12
|
+
cancelRequested: boolean;
|
|
13
|
+
response: OracleResponse;
|
|
14
|
+
constructor(...leases: HarnessLease[]);
|
|
15
|
+
lease(workspaces: string[]): Promise<HarnessLease | null>;
|
|
16
|
+
heartbeat(): Promise<{
|
|
17
|
+
cancelRequested: boolean;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
}>;
|
|
20
|
+
appendEvents(_attemptId: string, _leaseId: string, events: HarnessEventInput[]): Promise<void>;
|
|
21
|
+
infer(_attemptId: string, _leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse>;
|
|
22
|
+
complete(_attemptId: string, _leaseId: string, completion: HarnessCompletion): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { FakeHarnessControlPlane, fixtureLease };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HARNESS_PROTOCOL_VERSION
|
|
3
|
+
} from "./chunk-QTUEF2HZ.js";
|
|
4
|
+
|
|
5
|
+
// src/testing.ts
|
|
6
|
+
function fixtureLease(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
protocolVersion: HARNESS_PROTOCOL_VERSION,
|
|
9
|
+
leaseId: "lease_fixture",
|
|
10
|
+
generation: 1,
|
|
11
|
+
expiresAt: Date.now() + 6e4,
|
|
12
|
+
task: {
|
|
13
|
+
taskId: "task_fixture",
|
|
14
|
+
attemptId: "attempt_fixture",
|
|
15
|
+
title: "Fixture task",
|
|
16
|
+
prompt: "Create HARNESS_RESULT.md",
|
|
17
|
+
workspace: "fixture",
|
|
18
|
+
aiRoute: "coding",
|
|
19
|
+
policy: {
|
|
20
|
+
network: "none",
|
|
21
|
+
timeoutMs: 3e4,
|
|
22
|
+
maxOutputBytes: 1e6,
|
|
23
|
+
maxPatchBytes: 1e6
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
...overrides
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var FakeHarnessControlPlane = class {
|
|
30
|
+
leases = [];
|
|
31
|
+
events = [];
|
|
32
|
+
completions = [];
|
|
33
|
+
inferenceRequests = [];
|
|
34
|
+
cancelRequested = false;
|
|
35
|
+
response = {
|
|
36
|
+
id: "oracle_fixture",
|
|
37
|
+
model: "fixture-model",
|
|
38
|
+
provider: "openai",
|
|
39
|
+
role: "assistant",
|
|
40
|
+
content: [{ type: "text", text: "deterministic fixture response" }],
|
|
41
|
+
stopReason: "end_turn",
|
|
42
|
+
usage: { inputTokens: 5, outputTokens: 4 }
|
|
43
|
+
};
|
|
44
|
+
constructor(...leases) {
|
|
45
|
+
this.leases.push(...leases);
|
|
46
|
+
}
|
|
47
|
+
async lease(workspaces) {
|
|
48
|
+
const index = this.leases.findIndex((candidate) => workspaces.includes(candidate.task.workspace));
|
|
49
|
+
return index < 0 ? null : this.leases.splice(index, 1)[0];
|
|
50
|
+
}
|
|
51
|
+
async heartbeat() {
|
|
52
|
+
return { cancelRequested: this.cancelRequested, expiresAt: Date.now() + 6e4 };
|
|
53
|
+
}
|
|
54
|
+
async appendEvents(_attemptId, _leaseId, events) {
|
|
55
|
+
this.events.push(...events);
|
|
56
|
+
}
|
|
57
|
+
async infer(_attemptId, _leaseId, request) {
|
|
58
|
+
this.inferenceRequests.push(request);
|
|
59
|
+
return {
|
|
60
|
+
requestId: request.requestId,
|
|
61
|
+
response: this.response,
|
|
62
|
+
receipt: {
|
|
63
|
+
provider: this.response.provider,
|
|
64
|
+
model: this.response.model,
|
|
65
|
+
policyVersion: 1,
|
|
66
|
+
inputTokens: this.response.usage.inputTokens ?? 0,
|
|
67
|
+
outputTokens: this.response.usage.outputTokens ?? 0
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async complete(_attemptId, _leaseId, completion) {
|
|
72
|
+
this.completions.push(completion);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
FakeHarnessControlPlane,
|
|
77
|
+
fixtureLease
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import type { OracleResponse } from \"@odla-ai/ai\";\nimport {\n HARNESS_PROTOCOL_VERSION,\n type HarnessCompletion,\n type HarnessControlPlane,\n type HarnessEventInput,\n type HarnessInferenceRequest,\n type HarnessInferenceResponse,\n type HarnessLease,\n} from \"./types\";\n\n/** Create a deterministic, valid lease for harness unit and integration tests. */\nexport function fixtureLease(overrides: Partial<HarnessLease> = {}): HarnessLease {\n return {\n protocolVersion: HARNESS_PROTOCOL_VERSION,\n leaseId: \"lease_fixture\",\n generation: 1,\n expiresAt: Date.now() + 60_000,\n task: {\n taskId: \"task_fixture\",\n attemptId: \"attempt_fixture\",\n title: \"Fixture task\",\n prompt: \"Create HARNESS_RESULT.md\",\n workspace: \"fixture\",\n aiRoute: \"coding\",\n policy: {\n network: \"none\",\n timeoutMs: 30_000,\n maxOutputBytes: 1_000_000,\n maxPatchBytes: 1_000_000,\n },\n },\n ...overrides,\n };\n}\n\n/** In-memory control plane that records runner interactions without network access. */\nexport class FakeHarnessControlPlane implements HarnessControlPlane {\n readonly leases: HarnessLease[] = [];\n readonly events: HarnessEventInput[] = [];\n readonly completions: HarnessCompletion[] = [];\n readonly inferenceRequests: HarnessInferenceRequest[] = [];\n cancelRequested = false;\n response: OracleResponse = {\n id: \"oracle_fixture\",\n model: \"fixture-model\",\n provider: \"openai\",\n role: \"assistant\",\n content: [{ type: \"text\", text: \"deterministic fixture response\" }],\n stopReason: \"end_turn\",\n usage: { inputTokens: 5, outputTokens: 4 },\n };\n\n constructor(...leases: HarnessLease[]) { this.leases.push(...leases); }\n\n async lease(workspaces: string[]): Promise<HarnessLease | null> {\n const index = this.leases.findIndex((candidate) => workspaces.includes(candidate.task.workspace));\n return index < 0 ? null : this.leases.splice(index, 1)[0]!;\n }\n async heartbeat(): Promise<{ cancelRequested: boolean; expiresAt: number }> {\n return { cancelRequested: this.cancelRequested, expiresAt: Date.now() + 60_000 };\n }\n async appendEvents(_attemptId: string, _leaseId: string, events: HarnessEventInput[]): Promise<void> {\n this.events.push(...events);\n }\n async infer(_attemptId: string, _leaseId: string, request: HarnessInferenceRequest): Promise<HarnessInferenceResponse> {\n this.inferenceRequests.push(request);\n return {\n requestId: request.requestId,\n response: this.response,\n receipt: {\n provider: this.response.provider,\n model: this.response.model,\n policyVersion: 1,\n inputTokens: this.response.usage.inputTokens ?? 0,\n outputTokens: this.response.usage.outputTokens ?? 0,\n },\n };\n }\n async complete(_attemptId: string, _leaseId: string, completion: HarnessCompletion): Promise<void> {\n this.completions.push(completion);\n }\n}\n"],"mappings":";;;;;AAYO,SAAS,aAAa,YAAmC,CAAC,GAAiB;AAChF,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,KAAK,IAAI,IAAI;AAAA,IACxB,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAGO,IAAM,0BAAN,MAA6D;AAAA,EACzD,SAAyB,CAAC;AAAA,EAC1B,SAA8B,CAAC;AAAA,EAC/B,cAAmC,CAAC;AAAA,EACpC,oBAA+C,CAAC;AAAA,EACzD,kBAAkB;AAAA,EAClB,WAA2B;AAAA,IACzB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClE,YAAY;AAAA,IACZ,OAAO,EAAE,aAAa,GAAG,cAAc,EAAE;AAAA,EAC3C;AAAA,EAEA,eAAe,QAAwB;AAAE,SAAK,OAAO,KAAK,GAAG,MAAM;AAAA,EAAG;AAAA,EAEtE,MAAM,MAAM,YAAoD;AAC9D,UAAM,QAAQ,KAAK,OAAO,UAAU,CAAC,cAAc,WAAW,SAAS,UAAU,KAAK,SAAS,CAAC;AAChG,WAAO,QAAQ,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC;AAAA,EAC1D;AAAA,EACA,MAAM,YAAsE;AAC1E,WAAO,EAAE,iBAAiB,KAAK,iBAAiB,WAAW,KAAK,IAAI,IAAI,IAAO;AAAA,EACjF;AAAA,EACA,MAAM,aAAa,YAAoB,UAAkB,QAA4C;AACnG,SAAK,OAAO,KAAK,GAAG,MAAM;AAAA,EAC5B;AAAA,EACA,MAAM,MAAM,YAAoB,UAAkB,SAAqE;AACrH,SAAK,kBAAkB,KAAK,OAAO;AACnC,WAAO;AAAA,MACL,WAAW,QAAQ;AAAA,MACnB,UAAU,KAAK;AAAA,MACf,SAAS;AAAA,QACP,UAAU,KAAK,SAAS;AAAA,QACxB,OAAO,KAAK,SAAS;AAAA,QACrB,eAAe;AAAA,QACf,aAAa,KAAK,SAAS,MAAM,eAAe;AAAA,QAChD,cAAc,KAAK,SAAS,MAAM,gBAAgB;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM,SAAS,YAAoB,UAAkB,YAA8C;AACjG,SAAK,YAAY,KAAK,UAAU;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -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 };
|