@nylorun/core 0.21.0-beta → 0.23.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 +124 -0
- package/README.md +1 -1
- package/dist/compatibility.d.ts +37 -20
- package/dist/compatibility.js +38 -21
- package/dist/contracts.d.ts +531 -88
- package/dist/contracts.js +315 -204
- package/dist/define.d.ts +8 -12
- package/dist/define.js +7 -11
- package/dist/definition/assemble.d.ts +1 -3
- package/dist/definition/assemble.js +4 -8
- package/dist/definition/bound.d.ts +1 -1
- package/dist/definition/delegate.d.ts +5 -0
- package/dist/definition/delegate.js +6 -1
- package/dist/definition/from.d.ts +4 -2
- package/dist/definition/from.js +11 -29
- package/dist/definition/http-tool.d.ts +54 -8
- package/dist/definition/http-tool.js +175 -10
- package/dist/definition/manifest.d.ts +7 -6
- package/dist/definition/manifest.js +7 -6
- package/dist/definition/mcp.d.ts +1 -1
- package/dist/definition/media-reference.d.ts +2 -11
- package/dist/definition/media-reference.js +0 -12
- package/dist/definition/model-failure.js +1 -0
- package/dist/definition/removed.js +1 -0
- package/dist/definition/trace.d.ts +0 -7
- package/dist/definition/trace.js +0 -34
- package/dist/definition/variant.d.ts +1 -1
- package/dist/definition/variant.js +1 -3
- package/dist/harness-api/artifacts.d.ts +84 -0
- package/dist/harness-api/artifacts.js +128 -0
- package/dist/harness-api/gates.d.ts +0 -4
- package/dist/harness-api/gates.js +0 -4
- package/dist/harness-api/harness-api.schema.json +2422 -924
- package/dist/harness-api/index.d.ts +9 -6
- package/dist/harness-api/index.js +9 -6
- package/dist/harness-api/json-schema.js +5 -2
- package/dist/harness-api/mcp.d.ts +77 -30
- package/dist/harness-api/mcp.js +42 -25
- package/dist/harness-api/messages.d.ts +45 -17
- package/dist/harness-api/messages.js +20 -5
- package/dist/harness-api/schema.d.ts +538 -198
- package/dist/harness-api/schema.js +298 -59
- package/dist/harness-api/transcript.d.ts +8 -10
- package/dist/harness-api/transcript.js +27 -11
- package/dist/harness-api/transport.d.ts +7 -1
- package/dist/harness-api/transport.js +10 -7
- package/dist/manifest-schemas.js +14 -2
- package/dist/schemas/agent-manifest.schema.json +14 -147
- package/dist/schemas/environment-manifest.schema.json +76 -16
- package/dist/types/manifest.d.ts +17 -18
- package/dist/types/model.d.ts +10 -5
- package/dist/utils/definition-files.d.ts +20 -6
- package/dist/utils/definition-files.js +31 -17
- package/dist/utils/file-systems.d.ts +20 -0
- package/dist/utils/file-systems.js +20 -0
- package/dist/utils/harness-id.d.ts +4 -1
- package/dist/utils/harness-id.js +4 -1
- package/dist/utils/media-types.d.ts +30 -0
- package/dist/utils/media-types.js +128 -0
- package/dist/utils/runtime-limits.d.ts +229 -0
- package/dist/utils/runtime-limits.js +482 -0
- package/dist/utils/runtime-tools.d.ts +8 -16
- package/dist/utils/runtime-tools.js +8 -27
- package/dist/utils/sandbox.d.ts +4 -1
- package/dist/utils/sandbox.js +4 -1
- package/package.json +1 -1
- package/dist/definition/deferred-tools.d.ts +0 -27
- package/dist/definition/deferred-tools.js +0 -82
- package/dist/definition/runtime-manifest.d.ts +0 -30
- package/dist/definition/runtime-manifest.js +0 -132
- package/dist/definition/sandbox-tools.d.ts +0 -5
- package/dist/definition/sandbox-tools.js +0 -109
- package/dist/definition/skill-tools.d.ts +0 -23
- package/dist/definition/skill-tools.js +0 -76
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nylorun/core/harness-api`: the public contract between core and a harness (Harness API
|
|
2
|
+
* `@nylorun/core/harness-api`: the public contract between core and a harness (Harness API 4).
|
|
3
3
|
* Everything a harness sends or reads has a schema here, and the Runtime validates with the same
|
|
4
4
|
* schemas, so these types are the enforced ones: the frames and messages (`schema.ts`), the
|
|
5
5
|
* transport and the pod join (`transport.ts`), the Model and Tool Gate bodies (`gates.ts`), the
|
|
6
|
-
* MCP snapshot (`mcp.ts`),
|
|
7
|
-
* request hash and transcript edits. No engine and
|
|
6
|
+
* MCP snapshot (`mcp.ts`), the artifact seam's client (`artifacts.ts`), transcript entries and
|
|
7
|
+
* the effect id rule (`entries.ts`), the effect request hash and transcript edits. No engine and
|
|
8
|
+
* no I/O.
|
|
8
9
|
*
|
|
9
10
|
* Three version numbers apply: the transport (path and header, 1), the messages
|
|
10
|
-
* (`HARNESS_API_VERSION`,
|
|
11
|
+
* (`HARNESS_API_VERSION`, 4) and the Runtime protocol, which only the Runtime's own APIs carry.
|
|
11
12
|
*/
|
|
12
13
|
export * from "./messages.js";
|
|
13
14
|
export { HarnessApiError } from "./errors.js";
|
|
14
15
|
export { effectRequestHash, requestIdentity } from "./hash.js";
|
|
15
|
-
export {
|
|
16
|
+
export { TranscriptFoldError, applyUpdate, applyUpdates, transcriptOf, transcriptUpdates, withTranscript, type TranscriptUpdate, } from "./transcript.js";
|
|
16
17
|
export { createChannel, memoryChannels, memoryPorts, type Frame, type HarnessChannel, type MemoryPortsOptions, type MessageListener, type Port, type RequestHandler, } from "./rpc.js";
|
|
17
|
-
export { EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema,
|
|
18
|
+
export { ArtifactMetaSchema, CompactionFactsSchema, EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema, ModelDescriptorSchema, EffectTargetSchema, TurnEnvironmentSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, RunGrantSchema, RunRoutingSchema, TraceContextSchema, TranscriptUpdateSchema, TurnOutputSchema, TurnStartSchema, coreMessages, coreRequests, harnessRequests, validateFrame, validateMessage, validateParams, validateResult, } from "./schema.js";
|
|
18
19
|
export * from "./transport.js";
|
|
19
20
|
export * from "./gates.js";
|
|
20
21
|
export * from "./mcp.js";
|
|
@@ -23,4 +24,6 @@ export type { ModelCall, ModelCallTool, ModelCandidate, ModelFailureCode, ModelF
|
|
|
23
24
|
export type { InputEvent, TranscriptEntry } from "../types/transcript.js";
|
|
24
25
|
export type { ToolResult } from "../types/tool.js";
|
|
25
26
|
export { harnessApiJsonSchema, harnessApiSchemas } from "./json-schema.js";
|
|
27
|
+
export { fromBase64, openArtifactWrite, readArtifact, toBase64, writeArtifactBytes, type ArtifactRequester, type ArtifactWriteOptions, type OpenArtifactWrite, type ReadArtifact, type ReadArtifactOptions, type WrittenArtifact, } from "./artifacts.js";
|
|
26
28
|
export { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId } from "../utils/harness-id.js";
|
|
29
|
+
export { HARNESS_LIMIT_DEFAULTS, HarnessLimitsSchema, RUNTIME_LIMIT_CEILINGS, RUNTIME_LIMIT_DEFAULTS, RuntimeLimitsSchema, harnessLimitsOf, type HarnessLimit, type HarnessLimits, type RuntimeLimit, type RuntimeLimits, } from "../utils/runtime-limits.js";
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nylorun/core/harness-api`: the public contract between core and a harness (Harness API
|
|
2
|
+
* `@nylorun/core/harness-api`: the public contract between core and a harness (Harness API 4).
|
|
3
3
|
* Everything a harness sends or reads has a schema here, and the Runtime validates with the same
|
|
4
4
|
* schemas, so these types are the enforced ones: the frames and messages (`schema.ts`), the
|
|
5
5
|
* transport and the pod join (`transport.ts`), the Model and Tool Gate bodies (`gates.ts`), the
|
|
6
|
-
* MCP snapshot (`mcp.ts`),
|
|
7
|
-
* request hash and transcript edits. No engine and
|
|
6
|
+
* MCP snapshot (`mcp.ts`), the artifact seam's client (`artifacts.ts`), transcript entries and
|
|
7
|
+
* the effect id rule (`entries.ts`), the effect request hash and transcript edits. No engine and
|
|
8
|
+
* no I/O.
|
|
8
9
|
*
|
|
9
10
|
* Three version numbers apply: the transport (path and header, 1), the messages
|
|
10
|
-
* (`HARNESS_API_VERSION`,
|
|
11
|
+
* (`HARNESS_API_VERSION`, 4) and the Runtime protocol, which only the Runtime's own APIs carry.
|
|
11
12
|
*/
|
|
12
13
|
export * from "./messages.js";
|
|
13
14
|
export { HarnessApiError } from "./errors.js";
|
|
14
15
|
export { effectRequestHash, requestIdentity } from "./hash.js";
|
|
15
|
-
export {
|
|
16
|
+
export { TranscriptFoldError, applyUpdate, applyUpdates, transcriptOf, transcriptUpdates, withTranscript, } from "./transcript.js";
|
|
16
17
|
export { createChannel, memoryChannels, memoryPorts, } from "./rpc.js";
|
|
17
|
-
export { EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema,
|
|
18
|
+
export { ArtifactMetaSchema, CompactionFactsSchema, EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema, ModelDescriptorSchema, EffectTargetSchema, TurnEnvironmentSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, RunGrantSchema, RunRoutingSchema, TraceContextSchema, TranscriptUpdateSchema, TurnOutputSchema, TurnStartSchema, coreMessages, coreRequests, harnessRequests, validateFrame, validateMessage, validateParams, validateResult, } from "./schema.js";
|
|
18
19
|
export * from "./transport.js";
|
|
19
20
|
export * from "./gates.js";
|
|
20
21
|
export * from "./mcp.js";
|
|
21
22
|
export * from "./entries.js";
|
|
22
23
|
export { harnessApiJsonSchema, harnessApiSchemas } from "./json-schema.js";
|
|
24
|
+
export { fromBase64, openArtifactWrite, readArtifact, toBase64, writeArtifactBytes, } from "./artifacts.js";
|
|
23
25
|
export { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId } from "../utils/harness-id.js";
|
|
26
|
+
export { HARNESS_LIMIT_DEFAULTS, HarnessLimitsSchema, RUNTIME_LIMIT_CEILINGS, RUNTIME_LIMIT_DEFAULTS, RuntimeLimitsSchema, harnessLimitsOf, } from "../utils/runtime-limits.js";
|
|
@@ -11,13 +11,16 @@ import * as mcp from "./mcp.js";
|
|
|
11
11
|
import * as entries from "./entries.js";
|
|
12
12
|
import * as transport from "./transport.js";
|
|
13
13
|
import { HARNESS_API_VERSION } from "./messages.js";
|
|
14
|
-
import { EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema,
|
|
14
|
+
import { ArtifactMetaSchema, EffectIntentSchema, FrameSchema, HarnessCheckpointSchema, IntentAnswerSchema, ModelDescriptorSchema, EffectTargetSchema, TurnEnvironmentSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, RunGrantSchema, RunRoutingSchema, TraceContextSchema, TranscriptUpdateSchema, TurnOutputSchema, TurnStartSchema, coreMessages, coreRequests, harnessRequests, } from "./schema.js";
|
|
15
15
|
const named = {
|
|
16
|
+
ArtifactMetaSchema,
|
|
16
17
|
EffectIntentSchema,
|
|
17
18
|
FrameSchema,
|
|
18
19
|
HarnessCheckpointSchema,
|
|
19
20
|
IntentAnswerSchema,
|
|
20
|
-
|
|
21
|
+
ModelDescriptorSchema,
|
|
22
|
+
EffectTargetSchema,
|
|
23
|
+
TurnEnvironmentSchema,
|
|
21
24
|
OutcomeAnswerSchema,
|
|
22
25
|
RecordedOutcomeSchema,
|
|
23
26
|
RunGrantSchema,
|
|
@@ -1,57 +1,104 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A session's MCP
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* A session's MCP discovery (protocol 15), in two shapes:
|
|
3
|
+
*
|
|
4
|
+
* - the **snapshot** (`McpSnapshotSchema`): what the session's remote MCP servers said at
|
|
5
|
+
* discovery, as they said it (raw tool names, schemas and instructions, credential values
|
|
6
|
+
* scrubbed). A harness records it once per session (`session.mcp`, the first recorded wins), and
|
|
7
|
+
* the Runtime keeps it pinned on the session;
|
|
8
|
+
* - the **facts** (`McpFactsSchema`): the snapshot as one turn sees it, in `turn.start.mcp` and the
|
|
9
|
+
* `session.mcp` answer. Each tool says whether the turn's manifest leaves it `enabled` (the
|
|
10
|
+
* record refuses a call of one it does not, `tool.disabled`) and whether the manifest asks for it
|
|
11
|
+
* to be `deferred` (a hint; absent, the harness decides).
|
|
12
|
+
*
|
|
13
|
+
* The harness names each tool for the model (Nylorun's engine: `server__tool`, within 64
|
|
14
|
+
* characters), decides which to defer, and calls one by its identity: an effect's target
|
|
15
|
+
* `{kind: "mcp", server, tool}`, and the Tool Gate's body `{server: {agentId?, serverName}, name}`.
|
|
6
16
|
*/
|
|
7
17
|
import { z } from "zod";
|
|
18
|
+
/** One tool a server listed, as it listed it. */
|
|
8
19
|
export declare const McpToolRecordSchema: z.ZodObject<{
|
|
9
|
-
agentId: z.ZodOptional<z.ZodString>;
|
|
10
|
-
serverName: z.ZodString;
|
|
11
|
-
serverToolName: z.ZodString;
|
|
12
20
|
name: z.ZodString;
|
|
13
21
|
description: z.ZodOptional<z.ZodString>;
|
|
14
22
|
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
15
23
|
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
|
-
annotations: z.ZodOptional<z.
|
|
17
|
-
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
deferred: z.ZodOptional<z.ZodLiteral<true>>;
|
|
24
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
25
|
}, z.core.$strip>;
|
|
22
|
-
/**
|
|
23
|
-
export declare const
|
|
26
|
+
/** One server that connected at discovery, with what it said. */
|
|
27
|
+
export declare const McpServerRecordSchema: z.ZodObject<{
|
|
24
28
|
agentId: z.ZodOptional<z.ZodString>;
|
|
25
|
-
|
|
26
|
-
instructions: z.ZodString
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
31
|
+
tools: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
35
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
36
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
37
|
+
}, z.core.$strip>>>;
|
|
27
38
|
}, z.core.$strip>;
|
|
28
39
|
export declare const McpSnapshotSchema: z.ZodObject<{
|
|
29
|
-
snapshotSchemaVersion: z.ZodLiteral<
|
|
40
|
+
snapshotSchemaVersion: z.ZodLiteral<2>;
|
|
30
41
|
manifestHash: z.ZodString;
|
|
31
|
-
|
|
42
|
+
servers: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
32
43
|
agentId: z.ZodOptional<z.ZodString>;
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
46
|
+
tools: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
description: z.ZodOptional<z.ZodString>;
|
|
49
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
50
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
51
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
52
|
+
}, z.core.$strip>>>;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
/** One tool of a server, as a turn sees it. */
|
|
56
|
+
export declare const McpToolFactSchema: z.ZodObject<{
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
description: z.ZodOptional<z.ZodString>;
|
|
59
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
60
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
61
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
62
|
+
enabled: z.ZodBoolean;
|
|
63
|
+
deferred: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export declare const McpServerFactSchema: z.ZodObject<{
|
|
66
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
69
|
+
tools: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
35
70
|
name: z.ZodString;
|
|
36
71
|
description: z.ZodOptional<z.ZodString>;
|
|
37
72
|
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
38
73
|
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
-
annotations: z.ZodOptional<z.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, z.core.$strip>>;
|
|
43
|
-
deferred: z.ZodOptional<z.ZodLiteral<true>>;
|
|
74
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
|
+
enabled: z.ZodBoolean;
|
|
76
|
+
deferred: z.ZodOptional<z.ZodBoolean>;
|
|
44
77
|
}, z.core.$strip>>>;
|
|
45
|
-
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const McpFactsSchema: z.ZodObject<{
|
|
80
|
+
servers: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
46
81
|
agentId: z.ZodOptional<z.ZodString>;
|
|
47
|
-
|
|
48
|
-
instructions: z.ZodString
|
|
49
|
-
|
|
82
|
+
name: z.ZodString;
|
|
83
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
84
|
+
tools: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
description: z.ZodOptional<z.ZodString>;
|
|
87
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
88
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
enabled: z.ZodBoolean;
|
|
91
|
+
deferred: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
}, z.core.$strip>>>;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
50
94
|
}, z.core.$strip>;
|
|
51
95
|
type DeepReadonly<T> = T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
|
|
52
96
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
53
97
|
} : T;
|
|
54
98
|
export type McpToolRecord = DeepReadonly<z.infer<typeof McpToolRecordSchema>>;
|
|
55
|
-
export type
|
|
99
|
+
export type McpServerRecord = DeepReadonly<z.infer<typeof McpServerRecordSchema>>;
|
|
56
100
|
export type McpSnapshot = DeepReadonly<z.infer<typeof McpSnapshotSchema>>;
|
|
101
|
+
export type McpToolFact = DeepReadonly<z.infer<typeof McpToolFactSchema>>;
|
|
102
|
+
export type McpServerFact = DeepReadonly<z.infer<typeof McpServerFactSchema>>;
|
|
103
|
+
export type McpFacts = DeepReadonly<z.infer<typeof McpFactsSchema>>;
|
|
57
104
|
export {};
|
package/dist/harness-api/mcp.js
CHANGED
|
@@ -1,39 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A session's MCP
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* A session's MCP discovery (protocol 15), in two shapes:
|
|
3
|
+
*
|
|
4
|
+
* - the **snapshot** (`McpSnapshotSchema`): what the session's remote MCP servers said at
|
|
5
|
+
* discovery, as they said it (raw tool names, schemas and instructions, credential values
|
|
6
|
+
* scrubbed). A harness records it once per session (`session.mcp`, the first recorded wins), and
|
|
7
|
+
* the Runtime keeps it pinned on the session;
|
|
8
|
+
* - the **facts** (`McpFactsSchema`): the snapshot as one turn sees it, in `turn.start.mcp` and the
|
|
9
|
+
* `session.mcp` answer. Each tool says whether the turn's manifest leaves it `enabled` (the
|
|
10
|
+
* record refuses a call of one it does not, `tool.disabled`) and whether the manifest asks for it
|
|
11
|
+
* to be `deferred` (a hint; absent, the harness decides).
|
|
12
|
+
*
|
|
13
|
+
* The harness names each tool for the model (Nylorun's engine: `server__tool`, within 64
|
|
14
|
+
* characters), decides which to defer, and calls one by its identity: an effect's target
|
|
15
|
+
* `{kind: "mcp", server, tool}`, and the Tool Gate's body `{server: {agentId?, serverName}, name}`.
|
|
6
16
|
*/
|
|
7
17
|
import { z } from "zod";
|
|
8
18
|
const jsonObject = z.record(z.string(), z.unknown());
|
|
19
|
+
/** One tool a server listed, as it listed it. */
|
|
9
20
|
export const McpToolRecordSchema = z.object({
|
|
10
|
-
/** The
|
|
11
|
-
|
|
12
|
-
serverName: z.string(),
|
|
13
|
-
/** The tool's name on its server, which the call sends. */
|
|
14
|
-
serverToolName: z.string(),
|
|
15
|
-
/** The name the model knows it by. */
|
|
16
|
-
name: z.string(),
|
|
21
|
+
/** The tool's name on its server: what the call sends, and its identity. */
|
|
22
|
+
name: z.string().min(1),
|
|
17
23
|
description: z.string().optional(),
|
|
18
24
|
inputSchema: jsonObject,
|
|
19
25
|
outputSchema: jsonObject.optional(),
|
|
20
|
-
/** The server's
|
|
21
|
-
annotations:
|
|
22
|
-
.object({ readOnlyHint: z.boolean().optional(), idempotentHint: z.boolean().optional() })
|
|
23
|
-
.optional(),
|
|
24
|
-
/** Out of the model's tool list for the session's life; found through the deferred-tools tool. */
|
|
25
|
-
deferred: z.literal(true).optional(),
|
|
26
|
+
/** The server's annotations of the tool (`readOnlyHint`, `idempotentHint`, `title`, …). */
|
|
27
|
+
annotations: jsonObject.optional(),
|
|
26
28
|
});
|
|
27
|
-
/**
|
|
28
|
-
export const
|
|
29
|
+
/** One server that connected at discovery, with what it said. */
|
|
30
|
+
export const McpServerRecordSchema = z.object({
|
|
31
|
+
/** The agent used as a tool that declares the server; absent for the session's root agent. */
|
|
29
32
|
agentId: z.string().optional(),
|
|
30
|
-
|
|
31
|
-
instructions
|
|
33
|
+
name: z.string().min(1),
|
|
34
|
+
/** The server's own instructions (MCP `initialize`), scrubbed and uncut. */
|
|
35
|
+
instructions: z.string().optional(),
|
|
36
|
+
tools: z.array(McpToolRecordSchema).readonly(),
|
|
32
37
|
});
|
|
33
38
|
export const McpSnapshotSchema = z.object({
|
|
34
|
-
snapshotSchemaVersion: z.literal(
|
|
39
|
+
snapshotSchemaVersion: z.literal(2),
|
|
35
40
|
manifestHash: z.string(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
servers: z.array(McpServerRecordSchema).readonly(),
|
|
42
|
+
});
|
|
43
|
+
/** One tool of a server, as a turn sees it. */
|
|
44
|
+
export const McpToolFactSchema = McpToolRecordSchema.extend({
|
|
45
|
+
/** False when the turn's manifest disables it (R2b C9): the record refuses its calls. */
|
|
46
|
+
enabled: z.boolean(),
|
|
47
|
+
/** The manifest's `deferred` setting of the tool; absent, the harness decides. */
|
|
48
|
+
deferred: z.boolean().optional(),
|
|
49
|
+
});
|
|
50
|
+
export const McpServerFactSchema = z.object({
|
|
51
|
+
agentId: z.string().optional(),
|
|
52
|
+
name: z.string().min(1),
|
|
53
|
+
instructions: z.string().optional(),
|
|
54
|
+
tools: z.array(McpToolFactSchema).readonly(),
|
|
39
55
|
});
|
|
56
|
+
export const McpFactsSchema = z.object({ servers: z.array(McpServerFactSchema).readonly() });
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Harness API
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Harness API v4 (blueprint D37–D42; the harness boundary, protocol 15): the messages between
|
|
3
|
+
* core and a harness. A run is a lease on one session's segment; core records, the harness runs
|
|
4
|
+
* the engine. Who executes what: the harness runs model, MCP, HTTP and sandbox calls and its own
|
|
5
|
+
* tools (our engine's skill, artifact and deferred-tool tools among them, over the
|
|
6
|
+
* `definition.file` and artifact seams), writes the model's instructions, names the session's MCP
|
|
7
|
+
* tools and shapes tool results; core runs flow work, linked sessions, delegation journaling,
|
|
8
|
+
* settle and takeover, and routes each tool call by its target (`EffectTarget`: its kind, and an
|
|
9
|
+
* MCP or HTTP tool's identity). Each message's type is inferred from its schema (`schema.ts`),
|
|
10
|
+
* which a socket validates it with.
|
|
8
11
|
*/
|
|
9
12
|
import type { z } from "zod";
|
|
10
|
-
import type { EffectIntentSchema, IntentAnswerSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, ReleaseReasonSchema, RequestTypes, RunGrantSchema, RunRoutingSchema, TraceContextSchema, TurnOutputSchema, TurnStartSchema,
|
|
11
|
-
export declare const HARNESS_API_VERSION =
|
|
12
|
-
/** The most state a custom harness may keep per session (R4.2): its serialized JSON, in bytes. */
|
|
13
|
-
export declare const MAX_HARNESS_STATE_BYTES: number;
|
|
13
|
+
import type { ArtifactMetaSchema, CompactionFactsSchema, EffectIntentSchema, EffectTargetSchema, IntentAnswerSchema, ModelDescriptorSchema, OutcomeAnswerSchema, RecordedOutcomeSchema, ReleaseReasonSchema, RequestTypes, RunGrantSchema, RunRoutingSchema, TraceContextSchema, TurnEnvironmentSchema, TurnOutputSchema, TurnStartSchema, WorkspaceCallSchema, WorkspaceDiskCallSchema, WorkspaceRecordSchema, WorkspaceSessionSchema, coreMessages, coreRequests, harnessRequests } from "./schema.js";
|
|
14
|
+
export declare const HARNESS_API_VERSION = 4;
|
|
14
15
|
/** Why core stopped a run. Matches the advance's abort kinds. */
|
|
15
16
|
export declare const ABORT_REASONS: readonly ["cancel", "shutdown", "deadline", "ownership.lost"];
|
|
16
17
|
export type AbortReason = (typeof ABORT_REASONS)[number];
|
|
@@ -18,14 +19,43 @@ export type AbortReason = (typeof ABORT_REASONS)[number];
|
|
|
18
19
|
export type ReleaseReason = z.infer<typeof ReleaseReasonSchema>;
|
|
19
20
|
/**
|
|
20
21
|
* Events a harness may claim: for a run it holds, or for a workspace request core sent it. A
|
|
21
|
-
* `environment.state` claim carries the workspace's compute record, which core keeps.
|
|
22
|
+
* `environment.state` claim carries the workspace's compute record, which core keeps. Our engine
|
|
23
|
+
* claims `artifact.export.skipped` and `artifact.export.failed` when the turn-end save of its
|
|
24
|
+
* outputs folder stores nothing (protocol 15).
|
|
22
25
|
*/
|
|
23
|
-
export declare const HARNESS_CLAIMS: readonly ["environment.state", "environment.exec"];
|
|
26
|
+
export declare const HARNESS_CLAIMS: readonly ["environment.state", "environment.exec", "artifact.export.skipped", "artifact.export.failed"];
|
|
24
27
|
export type HarnessClaim = (typeof HARNESS_CLAIMS)[number];
|
|
25
|
-
export declare const HARNESS_ERROR_CODES: readonly ["run_not_held", "turn_cancelled", "ownership_lost", "effect_drift", "invalid", "unavailable", "internal"
|
|
28
|
+
export declare const HARNESS_ERROR_CODES: readonly ["run_not_held", "turn_cancelled", "ownership_lost", "effect_drift", "invalid", "unavailable", "internal",
|
|
29
|
+
/**
|
|
30
|
+
* What the request names is not there for this run: an artifact that is missing, another
|
|
31
|
+
* session's, or Tenant-wide and never named by the session's messages, all alike.
|
|
32
|
+
*/
|
|
33
|
+
"not_found",
|
|
34
|
+
/**
|
|
35
|
+
* What the harness sent passes a Runtime limit (`turn.start.limits`): the message names the
|
|
36
|
+
* limit and its value.
|
|
37
|
+
*/
|
|
38
|
+
"limit_exceeded"];
|
|
26
39
|
export type HarnessErrorCode = (typeof HARNESS_ERROR_CODES)[number];
|
|
27
40
|
/** One effect the engine asks for: a `HostEffect`, by structure. Model intents carry no `input`. */
|
|
28
41
|
export type EffectIntent = z.infer<typeof EffectIntentSchema>;
|
|
42
|
+
/** What a tool call runs: the record routes it by `kind` (protocol 15). */
|
|
43
|
+
export type EffectTarget = z.infer<typeof EffectTargetSchema>;
|
|
44
|
+
/** The Environment a turn runs in (`turn.start.environment`, protocol 15). */
|
|
45
|
+
export type TurnEnvironment = z.infer<typeof TurnEnvironmentSchema>;
|
|
46
|
+
/** An artifact as the artifact seam shows it to a harness (`artifact.read`, `artifact.write`). */
|
|
47
|
+
export type ArtifactMeta = z.infer<typeof ArtifactMetaSchema>;
|
|
48
|
+
/** One `artifact.read` answer: the artifact, and up to one chunk of its bytes from `offset`. */
|
|
49
|
+
export type ArtifactReadResult = ResultOf<"artifact.read">;
|
|
50
|
+
/** One `artifact.write` request: `begin`, `chunk`, `commit` or `abort`; a folder's `file` too. */
|
|
51
|
+
export type ArtifactWriteParams = ParamsOf<"artifact.write">;
|
|
52
|
+
/**
|
|
53
|
+
* One `artifact.write` answer: the upload `open`, the artifact `written`, a folder version
|
|
54
|
+
* `refused` (past a total), or `aborted`.
|
|
55
|
+
*/
|
|
56
|
+
export type ArtifactWriteResult = ResultOf<"artifact.write">;
|
|
57
|
+
/** What a harness says of a compaction it made (`transcript.updated` with `kind: "compaction"`). */
|
|
58
|
+
export type CompactionFacts = z.infer<typeof CompactionFactsSchema>;
|
|
29
59
|
/** A completed outcome of the segment, with the hash of the request it answered. */
|
|
30
60
|
export type RecordedOutcome = z.infer<typeof RecordedOutcomeSchema>;
|
|
31
61
|
/** The lease on one run. `token` is the run token (F5) when the gates require one. */
|
|
@@ -34,6 +64,8 @@ export type RunGrant = z.infer<typeof RunGrantSchema>;
|
|
|
34
64
|
export type RunRouting = z.infer<typeof RunRoutingSchema>;
|
|
35
65
|
/** W3C trace context a turn carries (R4.10). */
|
|
36
66
|
export type TraceContext = z.infer<typeof TraceContextSchema>;
|
|
67
|
+
/** The model a turn's calls use when they name none (`turn.start.model`, protocol 15). */
|
|
68
|
+
export type ModelDescriptor = z.infer<typeof ModelDescriptorSchema>;
|
|
37
69
|
/** What a run starts from: `turn.start` (message, continue, resume) or `approval.answer`. */
|
|
38
70
|
export type TurnStart = z.infer<typeof TurnStartSchema>;
|
|
39
71
|
/**
|
|
@@ -54,10 +86,6 @@ export type WorkspaceSession = z.infer<typeof WorkspaceSessionSchema>;
|
|
|
54
86
|
export type WorkspaceRecord = z.infer<typeof WorkspaceRecordSchema>;
|
|
55
87
|
/** A sandbox tool call core sends to the harness that serves workspaces. */
|
|
56
88
|
export type WorkspaceCall = z.infer<typeof WorkspaceCallSchema>;
|
|
57
|
-
/** A file of a workspace read as bytes (`save_artifact`, F8.1), at most `maxBytes`. */
|
|
58
|
-
export type WorkspaceBytesCall = z.infer<typeof WorkspaceBytesCallSchema>;
|
|
59
|
-
/** The regular files under a directory of a workspace (the turn-end export, F8.2). */
|
|
60
|
-
export type WorkspaceListCall = z.infer<typeof WorkspaceListCallSchema>;
|
|
61
89
|
/** One operation on a workspace's disk (R2d step 3). */
|
|
62
90
|
export type WorkspaceDiskCall = z.infer<typeof WorkspaceDiskCallSchema>;
|
|
63
91
|
/** Requests core sends to a harness that declared `workspace` (F6.2), with their answers. */
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
export const HARNESS_API_VERSION =
|
|
2
|
-
/** The most state a custom harness may keep per session (R4.2): its serialized JSON, in bytes. */
|
|
3
|
-
export const MAX_HARNESS_STATE_BYTES = 256 * 1024;
|
|
1
|
+
export const HARNESS_API_VERSION = 4;
|
|
4
2
|
/** Why core stopped a run. Matches the advance's abort kinds. */
|
|
5
3
|
export const ABORT_REASONS = ["cancel", "shutdown", "deadline", "ownership.lost"];
|
|
6
4
|
/**
|
|
7
5
|
* Events a harness may claim: for a run it holds, or for a workspace request core sent it. A
|
|
8
|
-
* `environment.state` claim carries the workspace's compute record, which core keeps.
|
|
6
|
+
* `environment.state` claim carries the workspace's compute record, which core keeps. Our engine
|
|
7
|
+
* claims `artifact.export.skipped` and `artifact.export.failed` when the turn-end save of its
|
|
8
|
+
* outputs folder stores nothing (protocol 15).
|
|
9
9
|
*/
|
|
10
|
-
export const HARNESS_CLAIMS = [
|
|
10
|
+
export const HARNESS_CLAIMS = [
|
|
11
|
+
"environment.state",
|
|
12
|
+
"environment.exec",
|
|
13
|
+
"artifact.export.skipped",
|
|
14
|
+
"artifact.export.failed",
|
|
15
|
+
];
|
|
11
16
|
export const HARNESS_ERROR_CODES = [
|
|
12
17
|
"run_not_held",
|
|
13
18
|
"turn_cancelled",
|
|
@@ -16,4 +21,14 @@ export const HARNESS_ERROR_CODES = [
|
|
|
16
21
|
"invalid",
|
|
17
22
|
"unavailable",
|
|
18
23
|
"internal",
|
|
24
|
+
/**
|
|
25
|
+
* What the request names is not there for this run: an artifact that is missing, another
|
|
26
|
+
* session's, or Tenant-wide and never named by the session's messages, all alike.
|
|
27
|
+
*/
|
|
28
|
+
"not_found",
|
|
29
|
+
/**
|
|
30
|
+
* What the harness sent passes a Runtime limit (`turn.start.limits`): the message names the
|
|
31
|
+
* limit and its value.
|
|
32
|
+
*/
|
|
33
|
+
"limit_exceeded",
|
|
19
34
|
];
|