@nylorun/core 0.17.0-beta → 0.18.0-beta
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/CHANGELOG.md +20 -0
- package/README.md +10 -0
- package/dist/contracts.d.ts +12 -2
- package/dist/contracts.js +46 -31
- package/dist/definition/from.js +22 -188
- package/dist/definition/removed.d.ts +4 -2
- package/dist/definition/removed.js +8 -2
- package/dist/harness-api/messages.d.ts +30 -352
- package/dist/harness-api/messages.js +2 -6
- package/dist/harness-api/schema.d.ts +701 -13
- package/dist/harness-api/schema.js +129 -53
- package/dist/harness-api/transcript.d.ts +3 -5
- package/dist/harness-api/transcript.js +0 -5
- package/dist/project.d.ts +67 -0
- package/dist/project.js +210 -0
- package/dist/transport.d.ts +52 -0
- package/dist/transport.js +73 -0
- package/package.json +9 -1
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* between core and a harness. A run is a lease on one session's segment; core records, the
|
|
4
4
|
* harness runs the engine. Who executes what: the harness runs model, MCP, HTTP and sandbox
|
|
5
5
|
* calls; core runs flow work, linked sessions, delegation journaling, `save_artifact`, the
|
|
6
|
-
* skill tools, settle and takeover.
|
|
6
|
+
* skill tools, settle and takeover. Each message's type is inferred from its schema
|
|
7
|
+
* (`schema.ts`), which a socket validates it with.
|
|
7
8
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type { TranscriptUpdate } from "./transcript.js";
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import type { EffectIntentSchema, IntentAnswerSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, ReleaseReasonSchema, RequestTypes, RunGrantSchema, RunRoutingSchema, TurnOutputSchema, TurnStartSchema, WorkspaceBytesCallSchema, WorkspaceCallSchema, WorkspaceListCallSchema, WorkspaceRecordSchema, WorkspaceSessionSchema, coreMessages, coreRequests, harnessRequests } from "./schema.js";
|
|
11
11
|
export declare const HARNESS_API_VERSION = 2;
|
|
12
12
|
/** Why core stopped a run. Matches the advance's abort kinds. */
|
|
13
|
-
export
|
|
14
|
-
export
|
|
13
|
+
export declare const ABORT_REASONS: readonly ["cancel", "shutdown", "deadline", "ownership.lost"];
|
|
14
|
+
export type AbortReason = (typeof ABORT_REASONS)[number];
|
|
15
15
|
/** Why a harness gave a run back without an output. */
|
|
16
|
-
export type ReleaseReason =
|
|
16
|
+
export type ReleaseReason = z.infer<typeof ReleaseReasonSchema>;
|
|
17
17
|
/**
|
|
18
18
|
* Events a harness may claim: for a run it holds, or for a workspace request core sent it. A
|
|
19
19
|
* `sandbox.state` claim carries the workspace's compute record, which core keeps.
|
|
@@ -23,365 +23,43 @@ export type HarnessClaim = (typeof HARNESS_CLAIMS)[number];
|
|
|
23
23
|
export declare const HARNESS_ERROR_CODES: readonly ["run_not_held", "turn_cancelled", "ownership_lost", "effect_drift", "invalid", "unavailable", "internal"];
|
|
24
24
|
export type HarnessErrorCode = (typeof HARNESS_ERROR_CODES)[number];
|
|
25
25
|
/** One effect the engine asks for: a `HostEffect`, by structure. Model intents carry no `input`. */
|
|
26
|
-
export
|
|
27
|
-
readonly effectId: string;
|
|
28
|
-
readonly sessionId: string;
|
|
29
|
-
readonly turnId: string;
|
|
30
|
-
readonly agentId: string;
|
|
31
|
-
readonly manifestHash: string;
|
|
32
|
-
readonly kind: "model" | "tool" | "delegation" | "agent";
|
|
33
|
-
readonly agent?: AgentRef;
|
|
34
|
-
readonly capabilityId?: string;
|
|
35
|
-
readonly toolName?: string;
|
|
36
|
-
readonly path?: string;
|
|
37
|
-
readonly key?: string;
|
|
38
|
-
readonly iterations?: string;
|
|
39
|
-
readonly input?: unknown;
|
|
40
|
-
readonly context: Record<string, unknown>;
|
|
41
|
-
}
|
|
26
|
+
export type EffectIntent = z.infer<typeof EffectIntentSchema>;
|
|
42
27
|
/** A completed outcome of the segment, with the hash of the request it answered. */
|
|
43
|
-
export
|
|
44
|
-
readonly effectId: string;
|
|
45
|
-
readonly requestHash: string;
|
|
46
|
-
readonly outcome: EffectOutcome;
|
|
47
|
-
}
|
|
28
|
+
export type RecordedOutcome = z.infer<typeof RecordedOutcomeSchema>;
|
|
48
29
|
/** The lease on one run. `token` is the run token (F5) when the gates require one. */
|
|
49
|
-
export
|
|
50
|
-
readonly runId: string;
|
|
51
|
-
readonly sessionId: string;
|
|
52
|
-
readonly turnId: string;
|
|
53
|
-
readonly epoch: number;
|
|
54
|
-
readonly token?: string;
|
|
55
|
-
readonly tokenExpiresAt?: string;
|
|
56
|
-
}
|
|
30
|
+
export type RunGrant = z.infer<typeof RunGrantSchema>;
|
|
57
31
|
/** Where a harness sends the session's tool calls. */
|
|
58
|
-
export
|
|
59
|
-
/** The session's pinned manifest: an effect's agent resolves against it. */
|
|
60
|
-
readonly rootManifest: unknown;
|
|
61
|
-
readonly mcpSnapshot?: unknown;
|
|
62
|
-
/** The session that owns the tree's sandbox, and the sandbox resource it is attached to. */
|
|
63
|
-
readonly sandbox?: {
|
|
64
|
-
readonly ownerId: string;
|
|
65
|
-
readonly sandboxId?: string;
|
|
66
|
-
readonly spec?: unknown;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
32
|
+
export type RunRouting = z.infer<typeof RunRoutingSchema>;
|
|
69
33
|
/** What a run starts from: `turn.start` (message, continue, resume) or `approval.answer`. */
|
|
70
|
-
export
|
|
71
|
-
readonly type: "turn.start" | "approval.answer";
|
|
72
|
-
readonly engine: "agent" | "flow";
|
|
73
|
-
/** The turn's manifest (agent) or the workflow manifest (flow). */
|
|
74
|
-
readonly manifest: unknown;
|
|
75
|
-
/** The segment's checkpoint; an agent's state has no transcript (`transcript.cursor`). */
|
|
76
|
-
readonly checkpoint: unknown;
|
|
77
|
-
readonly sessionTools?: readonly unknown[];
|
|
78
|
-
/** Completed outcomes of this segment, resolved without asking core. */
|
|
79
|
-
readonly outcomes: readonly RecordedOutcome[];
|
|
80
|
-
/** The record position the session's transcript was folded at. */
|
|
81
|
-
readonly transcript: {
|
|
82
|
-
readonly cursor: number;
|
|
83
|
-
};
|
|
84
|
-
readonly options: {
|
|
85
|
-
readonly yieldAfter?: {
|
|
86
|
-
readonly steps?: number;
|
|
87
|
-
readonly ms?: number;
|
|
88
|
-
};
|
|
89
|
-
readonly flowLimits?: unknown;
|
|
90
|
-
readonly fixtureModel: boolean;
|
|
91
|
-
};
|
|
92
|
-
readonly routing: RunRouting;
|
|
93
|
-
}
|
|
94
|
-
/** How a segment ended, as the harness reports it. */
|
|
95
|
-
export type TurnStatus = "completed" | "paused" | "yielded" | "waiting" | "uncertain" | "failed" | "cancelled";
|
|
34
|
+
export type TurnStart = z.infer<typeof TurnStartSchema>;
|
|
96
35
|
/**
|
|
97
36
|
* A segment's end. `state` is the agent's engine state without its transcript; `transcript`
|
|
98
37
|
* edits the transcript the segment started from. `thrown` reports an engine that threw.
|
|
99
38
|
*/
|
|
100
|
-
export
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
readonly state?: unknown;
|
|
104
|
-
readonly output?: unknown;
|
|
105
|
-
readonly pending?: unknown;
|
|
106
|
-
readonly error?: unknown;
|
|
107
|
-
readonly effectIds?: readonly string[];
|
|
108
|
-
readonly cancelEffectIds?: readonly string[];
|
|
109
|
-
readonly transcript?: readonly TranscriptUpdate[];
|
|
110
|
-
readonly thrown?: {
|
|
111
|
-
readonly code?: string;
|
|
112
|
-
readonly message: string;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
39
|
+
export type TurnOutput = z.infer<typeof TurnOutputSchema>;
|
|
40
|
+
/** How a segment ended, as the harness reports it. */
|
|
41
|
+
export type TurnStatus = NonNullable<TurnOutput["status"]>;
|
|
115
42
|
export type OutputMethod = "turn.completed" | "turn.paused" | "turn.waiting" | "turn.failed" | "checkpoint";
|
|
116
|
-
export type IntentAnswer =
|
|
117
|
-
|
|
118
|
-
readonly outcome: EffectOutcome;
|
|
119
|
-
} | {
|
|
120
|
-
readonly status: "pending" | "uncertain";
|
|
121
|
-
} | {
|
|
122
|
-
readonly status: "execute";
|
|
123
|
-
readonly rejoin?: true;
|
|
124
|
-
};
|
|
125
|
-
export type OutcomeAnswer = {
|
|
126
|
-
readonly status: "completed";
|
|
127
|
-
readonly outcome: EffectOutcome;
|
|
128
|
-
} | {
|
|
129
|
-
readonly status: "uncertain";
|
|
130
|
-
};
|
|
43
|
+
export type IntentAnswer = z.infer<typeof IntentAnswerSchema>;
|
|
44
|
+
export type OutcomeAnswer = z.infer<typeof OutcomeAnswerSchema>;
|
|
131
45
|
/** Requests a harness sends to core, with their answers. */
|
|
132
|
-
export
|
|
133
|
-
/**
|
|
134
|
-
* `capabilities.workspace` declares that the harness serves the Tenant's workspaces (F6.2):
|
|
135
|
-
* core then sends it the `workspace.*` requests. The answer names the Tenant (its workspace
|
|
136
|
-
* keys are scoped by it) and the sandbox backend preference the harness selects with.
|
|
137
|
-
*/
|
|
138
|
-
hello: {
|
|
139
|
-
params: {
|
|
140
|
-
api: number;
|
|
141
|
-
name: string;
|
|
142
|
-
version: string;
|
|
143
|
-
capabilities: {
|
|
144
|
-
workspace?: unknown;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
result: {
|
|
148
|
-
api: number;
|
|
149
|
-
tenantId: string;
|
|
150
|
-
sandbox: {
|
|
151
|
-
backend: string | null;
|
|
152
|
-
};
|
|
153
|
-
renewEveryMs: number;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
lease: {
|
|
157
|
-
params: {
|
|
158
|
-
slots?: number;
|
|
159
|
-
};
|
|
160
|
-
result: {
|
|
161
|
-
run: RunGrant;
|
|
162
|
-
input: TurnStart;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
"lease.renew": {
|
|
166
|
-
params: {
|
|
167
|
-
runId: string;
|
|
168
|
-
};
|
|
169
|
-
result: {
|
|
170
|
-
ok: true;
|
|
171
|
-
token?: string;
|
|
172
|
-
tokenExpiresAt?: string;
|
|
173
|
-
} | {
|
|
174
|
-
ok: false;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
"lease.release": {
|
|
178
|
-
params: {
|
|
179
|
-
runId: string;
|
|
180
|
-
reason: ReleaseReason;
|
|
181
|
-
};
|
|
182
|
-
result: Record<string, never>;
|
|
183
|
-
};
|
|
184
|
-
"effect.intent": {
|
|
185
|
-
params: {
|
|
186
|
-
runId: string;
|
|
187
|
-
effect: EffectIntent;
|
|
188
|
-
requestHash: string;
|
|
189
|
-
};
|
|
190
|
-
result: IntentAnswer;
|
|
191
|
-
};
|
|
192
|
-
"effect.outcome": {
|
|
193
|
-
params: {
|
|
194
|
-
runId: string;
|
|
195
|
-
effectId: string;
|
|
196
|
-
value: unknown;
|
|
197
|
-
} | {
|
|
198
|
-
runId: string;
|
|
199
|
-
effectId: string;
|
|
200
|
-
error: string;
|
|
201
|
-
};
|
|
202
|
-
result: OutcomeAnswer;
|
|
203
|
-
};
|
|
204
|
-
"transcript.read": {
|
|
205
|
-
params: {
|
|
206
|
-
runId: string;
|
|
207
|
-
};
|
|
208
|
-
result: {
|
|
209
|
-
cursor: number;
|
|
210
|
-
entries: unknown[];
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
event: {
|
|
214
|
-
params: {
|
|
215
|
-
runId?: string;
|
|
216
|
-
sessionId: string;
|
|
217
|
-
turnId: string | null;
|
|
218
|
-
type: HarnessClaim;
|
|
219
|
-
payload: unknown;
|
|
220
|
-
/** With `sandbox.state`: the workspace's compute record as it is now. */
|
|
221
|
-
record?: WorkspaceRecord;
|
|
222
|
-
};
|
|
223
|
-
result: Record<string, never>;
|
|
224
|
-
};
|
|
225
|
-
"session.mcp": {
|
|
226
|
-
params: {
|
|
227
|
-
runId: string;
|
|
228
|
-
snapshot?: unknown;
|
|
229
|
-
diagnostics: unknown[];
|
|
230
|
-
};
|
|
231
|
-
result: {
|
|
232
|
-
snapshot: unknown;
|
|
233
|
-
sessionTools: unknown[];
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* A definition file's bytes, base64 (track R2 M4): one the run's definition names, for the
|
|
238
|
-
* skills its sandbox mounts.
|
|
239
|
-
*/
|
|
240
|
-
"definition.file": {
|
|
241
|
-
params: {
|
|
242
|
-
runId: string;
|
|
243
|
-
sha256: string;
|
|
244
|
-
};
|
|
245
|
-
result: {
|
|
246
|
-
base64: string;
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
"turn.completed": {
|
|
250
|
-
params: TurnOutput;
|
|
251
|
-
result: {
|
|
252
|
-
cursor?: number;
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
"turn.paused": {
|
|
256
|
-
params: TurnOutput;
|
|
257
|
-
result: {
|
|
258
|
-
cursor?: number;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
"turn.waiting": {
|
|
262
|
-
params: TurnOutput;
|
|
263
|
-
result: {
|
|
264
|
-
cursor?: number;
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
"turn.failed": {
|
|
268
|
-
params: TurnOutput;
|
|
269
|
-
result: {
|
|
270
|
-
cursor?: number;
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
/** A yielded segment's state: ends the run, the turn goes on in the next. */
|
|
274
|
-
checkpoint: {
|
|
275
|
-
params: TurnOutput;
|
|
276
|
-
result: {
|
|
277
|
-
cursor?: number;
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
}
|
|
46
|
+
export type HarnessRequests = RequestTypes<typeof harnessRequests>;
|
|
281
47
|
/** The session a workspace request acts for: the workspace's owner and its sandbox resource. */
|
|
282
|
-
export
|
|
283
|
-
/** The session that owns the workspace: its log records the workspace's events. */
|
|
284
|
-
readonly ownerId: string;
|
|
285
|
-
readonly sandboxId?: string;
|
|
286
|
-
readonly activeTurnId: string | null;
|
|
287
|
-
}
|
|
48
|
+
export type WorkspaceSession = z.infer<typeof WorkspaceSessionSchema>;
|
|
288
49
|
/** A workspace's compute record, as the harness keeps it. */
|
|
289
|
-
export
|
|
290
|
-
readonly key: string;
|
|
291
|
-
readonly sessionId: string;
|
|
292
|
-
readonly sandboxId?: string;
|
|
293
|
-
readonly backend: string;
|
|
294
|
-
readonly image: string;
|
|
295
|
-
readonly state: "creating" | "running" | "stopped";
|
|
296
|
-
readonly createdAt: string;
|
|
297
|
-
readonly updatedAt: string;
|
|
298
|
-
}
|
|
50
|
+
export type WorkspaceRecord = z.infer<typeof WorkspaceRecordSchema>;
|
|
299
51
|
/** A sandbox tool call core sends to the harness that serves workspaces. */
|
|
300
|
-
export
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* A file of a workspace read as bytes (`save_artifact`, F8.1), at most `maxBytes`. The answer is
|
|
309
|
-
* `{kind: "read", path, base64}`, `{kind: "missing", path}` or a failed tool outcome.
|
|
310
|
-
*/
|
|
311
|
-
export interface WorkspaceBytesCall {
|
|
312
|
-
readonly session: WorkspaceSession;
|
|
313
|
-
readonly spec: unknown;
|
|
314
|
-
readonly bytes: {
|
|
315
|
-
readonly path: string;
|
|
316
|
-
readonly maxBytes: number;
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* The regular files under a directory of a workspace, recursively, at most `maxEntries + 1`
|
|
321
|
-
* (the turn-end export, F8.2). The answer is `{kind: "listed", path, listing: {entries,
|
|
322
|
-
* truncated}}`, `{kind: "missing", path}` (no sandbox yet, or not a directory) or a failed tool
|
|
323
|
-
* outcome.
|
|
324
|
-
*/
|
|
325
|
-
export interface WorkspaceListCall {
|
|
326
|
-
readonly session: WorkspaceSession;
|
|
327
|
-
readonly spec: unknown;
|
|
328
|
-
readonly list: {
|
|
329
|
-
readonly dir: string;
|
|
330
|
-
readonly maxEntries: number;
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Requests core sends to a harness that declared `workspace` (F6.2), with their answers. A
|
|
335
|
-
* sandbox tool's answer is its `SandboxToolOutcome`; the harness claims its `sandbox.*` events
|
|
336
|
-
* while the request is in flight. `workspace.read` stays generic: F8.2 exports outputs
|
|
337
|
-
* through it.
|
|
338
|
-
*/
|
|
339
|
-
export interface CoreRequests {
|
|
340
|
-
"workspace.read": {
|
|
341
|
-
params: WorkspaceCall | WorkspaceBytesCall | WorkspaceListCall;
|
|
342
|
-
result: Record<string, unknown>;
|
|
343
|
-
};
|
|
344
|
-
"workspace.write": {
|
|
345
|
-
params: WorkspaceCall;
|
|
346
|
-
result: Record<string, unknown>;
|
|
347
|
-
};
|
|
348
|
-
"workspace.exec": {
|
|
349
|
-
params: WorkspaceCall;
|
|
350
|
-
result: Record<string, unknown>;
|
|
351
|
-
};
|
|
352
|
-
/** The harness's sandbox selection report (`GET /v1/tenant/sandbox`, Tenant status). */
|
|
353
|
-
"workspace.report": {
|
|
354
|
-
params: Record<string, never>;
|
|
355
|
-
result: Record<string, unknown>;
|
|
356
|
-
};
|
|
357
|
-
/** Stops idle workspaces, then lists every workspace the harness keeps. */
|
|
358
|
-
"workspace.sweep": {
|
|
359
|
-
params: {
|
|
360
|
-
now?: number;
|
|
361
|
-
};
|
|
362
|
-
result: {
|
|
363
|
-
workspaces: WorkspaceRecord[];
|
|
364
|
-
};
|
|
365
|
-
};
|
|
366
|
-
/** Deletes workspaces with their files: by key, by sandbox resource, or all of them. */
|
|
367
|
-
"workspace.remove": {
|
|
368
|
-
params: {
|
|
369
|
-
keys?: string[];
|
|
370
|
-
sandboxIds?: string[];
|
|
371
|
-
all?: true;
|
|
372
|
-
};
|
|
373
|
-
result: Record<string, never>;
|
|
374
|
-
};
|
|
375
|
-
}
|
|
52
|
+
export type WorkspaceCall = z.infer<typeof WorkspaceCallSchema>;
|
|
53
|
+
/** A file of a workspace read as bytes (`save_artifact`, F8.1), at most `maxBytes`. */
|
|
54
|
+
export type WorkspaceBytesCall = z.infer<typeof WorkspaceBytesCallSchema>;
|
|
55
|
+
/** The regular files under a directory of a workspace (the turn-end export, F8.2). */
|
|
56
|
+
export type WorkspaceListCall = z.infer<typeof WorkspaceListCallSchema>;
|
|
57
|
+
/** Requests core sends to a harness that declared `workspace` (F6.2), with their answers. */
|
|
58
|
+
export type CoreRequests = RequestTypes<typeof coreRequests>;
|
|
376
59
|
/** Messages core sends to a harness, without an answer. */
|
|
377
|
-
export
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
runId: string;
|
|
381
|
-
reason: AbortReason;
|
|
382
|
-
message?: string;
|
|
383
|
-
};
|
|
384
|
-
}
|
|
60
|
+
export type CoreMessages = {
|
|
61
|
+
[M in keyof typeof coreMessages]: z.infer<(typeof coreMessages)[M]>;
|
|
62
|
+
};
|
|
385
63
|
export type HarnessMethod = keyof HarnessRequests;
|
|
386
64
|
export type CoreMethod = keyof CoreRequests;
|
|
387
65
|
export type CoreMessage = keyof CoreMessages;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export const HARNESS_API_VERSION = 2;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"shutdown",
|
|
5
|
-
"deadline",
|
|
6
|
-
"ownership.lost",
|
|
7
|
-
];
|
|
2
|
+
/** Why core stopped a run. Matches the advance's abort kinds. */
|
|
3
|
+
export const ABORT_REASONS = ["cancel", "shutdown", "deadline", "ownership.lost"];
|
|
8
4
|
/**
|
|
9
5
|
* Events a harness may claim: for a run it holds, or for a workspace request core sent it. A
|
|
10
6
|
* `sandbox.state` claim carries the workspace's compute record, which core keeps.
|