@nylorun/core 0.23.0-beta → 0.25.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 +37 -0
- package/dist/compatibility.d.ts +127 -59
- package/dist/compatibility.js +128 -60
- package/dist/contracts.d.ts +2413 -893
- package/dist/contracts.js +1144 -491
- package/dist/define.d.ts +1 -0
- package/dist/define.js +1 -0
- package/dist/definition/approval.d.ts +1 -1
- package/dist/definition/bound.d.ts +2 -0
- package/dist/definition/builder.d.ts +2 -2
- package/dist/definition/builder.js +1 -1
- package/dist/definition/code-tools.d.ts +1 -1
- package/dist/definition/declaration.js +3 -0
- package/dist/definition/delegate.d.ts +1 -1
- package/dist/definition/delegate.js +1 -1
- package/dist/definition/from.d.ts +2 -2
- package/dist/definition/from.js +1 -1
- package/dist/definition/http-tool.d.ts +3 -3
- package/dist/definition/mcp.d.ts +4 -4
- package/dist/definition/mcp.js +3 -3
- package/dist/definition/removed.d.ts +7 -0
- package/dist/definition/removed.js +21 -1
- package/dist/definition/sections.d.ts +64 -0
- package/dist/definition/sections.js +227 -0
- package/dist/definition/variant.d.ts +1 -1
- package/dist/definition/variant.js +4 -4
- package/dist/harness-api/entries.d.ts +1 -1
- package/dist/harness-api/entries.js +1 -1
- package/dist/harness-api/gates.d.ts +1 -1
- package/dist/harness-api/gates.js +1 -1
- package/dist/harness-api/harness-api.schema.json +182 -6
- package/dist/harness-api/index.d.ts +3 -3
- package/dist/harness-api/index.js +3 -3
- package/dist/harness-api/json-schema.d.ts +1 -1
- package/dist/harness-api/json-schema.js +3 -3
- package/dist/harness-api/mcp.js +1 -1
- package/dist/harness-api/messages.d.ts +10 -8
- package/dist/harness-api/messages.js +1 -1
- package/dist/harness-api/schema.d.ts +82 -13
- package/dist/harness-api/schema.js +63 -19
- package/dist/harness-api/transcript.d.ts +1 -1
- package/dist/harness-api/transport.d.ts +1 -1
- package/dist/harness-api/transport.js +1 -1
- package/dist/manifest-schemas.d.ts +9 -5
- package/dist/manifest-schemas.js +24 -27
- package/dist/schemas/agent-manifest.schema.json +1534 -250
- package/dist/schemas/harness-manifest.schema.json +1273 -0
- package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +109 -68
- package/dist/types/manifest.d.ts +87 -15
- package/dist/types/manifest.js +4 -0
- package/dist/types/model.d.ts +5 -0
- package/dist/types/observe.d.ts +1 -1
- package/dist/types/part.d.ts +5 -0
- package/dist/types/tool.d.ts +4 -4
- package/dist/utils/definition-files.d.ts +3 -2
- package/dist/utils/definition-files.js +4 -3
- package/dist/utils/file-systems.d.ts +1 -1
- package/dist/utils/file-systems.js +1 -1
- package/dist/utils/harness-id.d.ts +1 -1
- package/dist/utils/harness-id.js +1 -1
- package/dist/utils/memory.d.ts +64 -0
- package/dist/utils/memory.js +139 -0
- package/dist/utils/runtime-limits.d.ts +55 -4
- package/dist/utils/runtime-limits.js +106 -3
- package/dist/utils/runtime-tools.d.ts +3 -3
- package/dist/utils/runtime-tools.js +3 -3
- package/package.json +6 -5
package/dist/define.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export { bindTool } from "./definition/bind-tool.js";
|
|
|
44
44
|
export { bindOutputContract } from "./definition/output-contract.js";
|
|
45
45
|
export type { TurnOutputContract } from "./definition/output-contract.js";
|
|
46
46
|
export { agentFrom } from "./definition/from.js";
|
|
47
|
+
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, type SandboxNeed, } from "./definition/sections.js";
|
|
47
48
|
export { mediaReferenceOf, type MediaReference } from "./definition/media-reference.js";
|
|
48
49
|
export type { SessionToolRef } from "./definition/from.js";
|
|
49
50
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
package/dist/define.js
CHANGED
|
@@ -23,6 +23,7 @@ export { isVariantOf } from "./definition/variant.js";
|
|
|
23
23
|
export { bindTool } from "./definition/bind-tool.js";
|
|
24
24
|
export { bindOutputContract } from "./definition/output-contract.js";
|
|
25
25
|
export { agentFrom } from "./definition/from.js";
|
|
26
|
+
export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, } from "./definition/sections.js";
|
|
26
27
|
export { mediaReferenceOf } from "./definition/media-reference.js";
|
|
27
28
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
|
28
29
|
export { normalizeSchema } from "./definition/schema.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `approval` in a manifest
|
|
2
|
+
* `approval` in a manifest. Tool approvals are the Tenant's tool policy now, decided
|
|
3
3
|
* at the Runtime's Tool Gate for every harness: `PUT /v1/tenant/tool-policy`, a rule with
|
|
4
4
|
* `effect: "ask"`. So `PUT /v1/agents/:id` and a turn's manifest refuse a definition that sets
|
|
5
5
|
* `approval` on an HTTP tool, an MCP server or an MCP tool's settings, and the SDK refuses it
|
|
@@ -29,6 +29,8 @@ export interface DefinitionPart {
|
|
|
29
29
|
readonly skills?: Readonly<Record<string, SkillManifest>>;
|
|
30
30
|
/** Each skill file's bytes, by `sha256:<hex>`. Not a manifest field. */
|
|
31
31
|
readonly skillFiles?: Readonly<Record<string, SkillFileSource>>;
|
|
32
|
+
/** The secret slots each skill's scripts read, by skill name. Not a manifest field. */
|
|
33
|
+
readonly skillSecrets?: Readonly<Record<string, readonly string[]>>;
|
|
32
34
|
readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
|
|
33
35
|
readonly sandbox?: SandboxManifest;
|
|
34
36
|
}
|
|
@@ -32,7 +32,7 @@ interface BuilderSnapshot {
|
|
|
32
32
|
readonly metadata?: JsonObject;
|
|
33
33
|
readonly outputSchema?: ToolSchemaSource;
|
|
34
34
|
readonly inputSchema?: ToolSchemaSource;
|
|
35
|
-
/** What the agent needs of its session's Environment
|
|
35
|
+
/** What the agent needs of its session's Environment. */
|
|
36
36
|
readonly requires?: AgentRequirements;
|
|
37
37
|
readonly entries: readonly DefinitionPart[];
|
|
38
38
|
/** Builder-level problems, reported with the assembly diagnostics. */
|
|
@@ -101,7 +101,7 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
|
|
|
101
101
|
/** The structured output. Set once. */
|
|
102
102
|
output<S extends ToolSchemaSource>(schema: S): AgentBuilder<Info, S, Id>;
|
|
103
103
|
/**
|
|
104
|
-
* What the agent needs of the Environment its session opens on (protocol 14
|
|
104
|
+
* What the agent needs of the Environment its session opens on (protocol 14): a sandbox
|
|
105
105
|
* (`any` or `pod`) and secret names its skills' scripts read. A session whose Environment lacks
|
|
106
106
|
* them is refused when it opens. The agent still names no Environment. Set once.
|
|
107
107
|
*/
|
|
@@ -145,7 +145,7 @@ export class AgentBuilder {
|
|
|
145
145
|
return this.spawn({ ...snapshot, outputSchema: schema });
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
-
* What the agent needs of the Environment its session opens on (protocol 14
|
|
148
|
+
* What the agent needs of the Environment its session opens on (protocol 14): a sandbox
|
|
149
149
|
* (`any` or `pod`) and secret names its skills' scripts read. A session whose Environment lacks
|
|
150
150
|
* them is refused when it opens. The agent still names no Environment. Set once.
|
|
151
151
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tools that would run the developer's code
|
|
2
|
+
* Tools that would run the developer's code: an agent's own tool with no `http`
|
|
3
3
|
* and no `agent`, and a flow agent's `tool` stage without `http`. The tools in a pinned
|
|
4
4
|
* manifest's `runtime` block are the Runtime's own. The
|
|
5
5
|
* Runtime runs agents from their manifests alone, so `PUT /v1/agents/:id` refuses a definition
|
|
@@ -20,6 +20,9 @@ export function compileDeclaration(declaration) {
|
|
|
20
20
|
...(declaration.skillFiles === undefined || Object.keys(declaration.skillFiles).length === 0
|
|
21
21
|
? {}
|
|
22
22
|
: { skillFiles: declaration.skillFiles }),
|
|
23
|
+
...(declaration.skillSecrets === undefined || Object.keys(declaration.skillSecrets).length === 0
|
|
24
|
+
? {}
|
|
25
|
+
: { skillSecrets: declaration.skillSecrets }),
|
|
23
26
|
...(declaration.mcpServers === undefined || Object.keys(declaration.mcpServers).length === 0
|
|
24
27
|
? {}
|
|
25
28
|
: { mcpServers: declaration.mcpServers }),
|
|
@@ -21,7 +21,7 @@ export declare function isFlowDelegate(delegate: Delegate): delegate is Delegate
|
|
|
21
21
|
readonly manifest: WorkflowManifest;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* The longest tool name every model provider accepts
|
|
24
|
+
* The longest tool name every model provider accepts: OpenAI's and Anthropic's
|
|
25
25
|
* `^[a-zA-Z0-9_-]{1,64}$`. A provider's ceiling, not a setting.
|
|
26
26
|
*/
|
|
27
27
|
export declare const MODEL_TOOL_NAME_MAX = 64;
|
|
@@ -9,7 +9,7 @@ export function isFlowDelegate(delegate) {
|
|
|
9
9
|
return delegate.manifest.kind === "workflow";
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* The longest tool name every model provider accepts
|
|
12
|
+
* The longest tool name every model provider accepts: OpenAI's and Anthropic's
|
|
13
13
|
* `^[a-zA-Z0-9_-]{1,64}$`. A provider's ceiling, not a setting.
|
|
14
14
|
*/
|
|
15
15
|
export const MODEL_TOOL_NAME_MAX = 64;
|
|
@@ -7,12 +7,12 @@ export interface SessionToolRef {
|
|
|
7
7
|
readonly name: string;
|
|
8
8
|
/**
|
|
9
9
|
* Text the model reads while the tool is advertised, such as `tool_search`'s note of the
|
|
10
|
-
* servers whose tools are deferred
|
|
10
|
+
* servers whose tools are deferred. Not hashed.
|
|
11
11
|
*/
|
|
12
12
|
readonly instructions?: readonly string[];
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Rebuild an agent from its manifest and the code of its tools, by name
|
|
15
|
+
* Rebuild an agent from its manifest and the code of its tools, by name. Agents used as
|
|
16
16
|
* tools and HTTP tools need no code. A session tool (`sessionTools`) is offered in the session
|
|
17
17
|
* part, after the agent's own, with `sessionInstructions` (text not tied to one tool) before its
|
|
18
18
|
* tools' own; it needs its code, and its name may not be one of the agent's tools.
|
package/dist/definition/from.js
CHANGED
|
@@ -7,7 +7,7 @@ import { httpToolFromManifest, httpToolOf } from "./http-tool.js";
|
|
|
7
7
|
import { SESSION_PART_ID } from "./manifest.js";
|
|
8
8
|
import { AgentManifestSchema } from "../contracts.js";
|
|
9
9
|
/**
|
|
10
|
-
* Rebuild an agent from its manifest and the code of its tools, by name
|
|
10
|
+
* Rebuild an agent from its manifest and the code of its tools, by name. Agents used as
|
|
11
11
|
* tools and HTTP tools need no code. A session tool (`sessionTools`) is offered in the session
|
|
12
12
|
* part, after the agent's own, with `sessionInstructions` (text not tied to one tool) before its
|
|
13
13
|
* tools' own; it needs its code, and its name may not be one of the agent's tools.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP tools
|
|
2
|
+
* HTTP tools: a tool the manifest describes as one HTTP request, which the Runtime makes
|
|
3
3
|
* itself through its Tool Gate. No developer code runs for it: the tool value carries its target
|
|
4
4
|
* (`http`) into the manifest, and its `execute` only says where it runs. Whether a call waits for
|
|
5
|
-
* a person is the Tenant's tool policy, decided at the Tool Gate
|
|
5
|
+
* a person is the Tenant's tool policy, decided at the Tool Gate, never the tool's.
|
|
6
6
|
* An HTTP tool is also a flow stage. `http({ url })` without a name and an input is a bare
|
|
7
7
|
* target, a Loop's HTTP verifier: its manifest form is itself, `{ http: { url, … } }`.
|
|
8
8
|
*
|
|
@@ -29,7 +29,7 @@ export declare const HTTP_TOOL_DEFAULT_TIMEOUT_MS = 60000;
|
|
|
29
29
|
export interface HttpTool {
|
|
30
30
|
readonly http: HttpToolTarget;
|
|
31
31
|
/**
|
|
32
|
-
* @deprecated A pinned manifest's `approval`, from before
|
|
32
|
+
* @deprecated A pinned manifest's `approval`, from before the Tenant's tool policy: kept so the rebuilt
|
|
33
33
|
* definition hashes as pinned, and held by the Tool Gate. Nothing asks for it here, and
|
|
34
34
|
* `http()` refuses it.
|
|
35
35
|
*/
|
package/dist/definition/mcp.d.ts
CHANGED
|
@@ -14,17 +14,17 @@ export declare class McpError extends Error {
|
|
|
14
14
|
export declare function stdioMcpRefusal(name: string): string;
|
|
15
15
|
/** Validate a map of MCP servers and fill each `name` from its key. */
|
|
16
16
|
export declare function normalizeMcpServers(servers: Readonly<Record<string, McpServerSpec>>, caller?: string): Readonly<Record<string, McpServerManifest>>;
|
|
17
|
-
/** The key of an MCP server's `tools` map that sets every tool without an entry
|
|
17
|
+
/** The key of an MCP server's `tools` map that sets every tool without an entry. */
|
|
18
18
|
export declare const MCP_TOOL_DEFAULTS = "*";
|
|
19
|
-
/** A tool's settings once resolved
|
|
19
|
+
/** A tool's settings once resolved: its entry, then `"*"`, then the server, then the default. */
|
|
20
20
|
export interface ResolvedMcpToolSettings {
|
|
21
21
|
readonly enabled: boolean;
|
|
22
22
|
readonly approval: ApprovalMode;
|
|
23
|
-
/** Undefined: nothing sets it, and the harness decides (
|
|
23
|
+
/** Undefined: nothing sets it, and the harness decides (automatic deferral). */
|
|
24
24
|
readonly deferred?: boolean;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* The settings of the server's tool named `serverToolName` (its own name, before
|
|
27
|
+
* The settings of the server's tool named `serverToolName` (its own name, before renaming):
|
|
28
28
|
* from the tool's entry in `tools`, then the `"*"` entry, then the server, then the default
|
|
29
29
|
* (enabled, approval `never`, deferral automatic).
|
|
30
30
|
*/
|
package/dist/definition/mcp.js
CHANGED
|
@@ -40,10 +40,10 @@ export function normalizeMcpServers(servers, caller = "mcp()") {
|
|
|
40
40
|
}
|
|
41
41
|
return Object.freeze(mcpServers);
|
|
42
42
|
}
|
|
43
|
-
/** The key of an MCP server's `tools` map that sets every tool without an entry
|
|
43
|
+
/** The key of an MCP server's `tools` map that sets every tool without an entry. */
|
|
44
44
|
export const MCP_TOOL_DEFAULTS = "*";
|
|
45
45
|
/**
|
|
46
|
-
* The settings of the server's tool named `serverToolName` (its own name, before
|
|
46
|
+
* The settings of the server's tool named `serverToolName` (its own name, before renaming):
|
|
47
47
|
* from the tool's entry in `tools`, then the `"*"` entry, then the server, then the default
|
|
48
48
|
* (enabled, approval `never`, deferral automatic).
|
|
49
49
|
*/
|
|
@@ -91,7 +91,7 @@ function isMcpServer(value) {
|
|
|
91
91
|
(value.tools === undefined || isToolSettingsMap(value.tools)));
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
|
-
/** A server, or one of its tools' settings, that sets `approval` (removed
|
|
94
|
+
/** A server, or one of its tools' settings, that sets `approval` (removed with the Tenant's tool policy). */
|
|
95
95
|
function setsApproval(server) {
|
|
96
96
|
if (server.approval !== undefined)
|
|
97
97
|
return true;
|
|
@@ -6,3 +6,10 @@ export declare const REMOVED_MANIFEST_FIELDS: Readonly<Record<string, string>>;
|
|
|
6
6
|
export declare function manifestVersionIssue(version: unknown): string | undefined;
|
|
7
7
|
/** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */
|
|
8
8
|
export declare function workflowVersionIssue(version: unknown): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Why an agent manifest with this `manifestSchemaVersion` is refused at
|
|
11
|
+
* `/v1/agent-manifests/{name}` (protocol 16), or undefined for version 8.
|
|
12
|
+
*/
|
|
13
|
+
export declare function agentManifestVersionIssue(version: unknown): string | undefined;
|
|
14
|
+
/** Fields an environment manifest had that the runtime section of agent manifest v8 refuses. */
|
|
15
|
+
export declare const REMOVED_RUNTIME_SECTION_FIELDS: Readonly<Record<string, string>>;
|
|
@@ -9,7 +9,7 @@ export const REMOVED_MANIFEST_FIELDS = Object.freeze({
|
|
|
9
9
|
model: "Manifest must not include top-level model; Runtime owns model resolution",
|
|
10
10
|
hooks: "hooks were removed: the Runtime runs agents from their manifests alone. Use an HTTP tool, the Tenant's tool policy, or a loop verifier instead (see MIGRATION.md)",
|
|
11
11
|
capabilities: "Manifest v7 has no capabilities: the agent's instructions, tools, skills and mcpServers are top-level fields. Rebuild the agent with the current SDK (see MIGRATION.md)",
|
|
12
|
-
runtime: "
|
|
12
|
+
runtime: "This is a pre-v8 runtime block: since protocol 15 the harness writes the model's instructions and defines the sandbox and skill tools. In agent manifest v8, runtime is a top-level section beside harness and says what the Runtime provides (see MIGRATION.md)",
|
|
13
13
|
});
|
|
14
14
|
/** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 7. */
|
|
15
15
|
export function manifestVersionIssue(version) {
|
|
@@ -27,3 +27,23 @@ export function workflowVersionIssue(version) {
|
|
|
27
27
|
return `workflowSchemaVersion ${version} is no longer supported: flows run no code since manifest v5 (no input, on, verify or decide functions). Rebuild the flow with the current SDK (see MIGRATION.md)`;
|
|
28
28
|
return `Unsupported workflowSchemaVersion ${String(version)}`;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Why an agent manifest with this `manifestSchemaVersion` is refused at
|
|
32
|
+
* `/v1/agent-manifests/{name}` (protocol 16), or undefined for version 8.
|
|
33
|
+
*/
|
|
34
|
+
export function agentManifestVersionIssue(version) {
|
|
35
|
+
if (version === 8)
|
|
36
|
+
return undefined;
|
|
37
|
+
if (version === 7)
|
|
38
|
+
return "manifestSchemaVersion 7 is no longer saved: agent manifest v8 holds a harness and a runtime section. Rebuild it with nylorun migrate v8 (see MIGRATION.md)";
|
|
39
|
+
if (typeof version === "number" && version >= 3 && version <= 6)
|
|
40
|
+
return `manifestSchemaVersion ${version} is no longer supported. Rebuild the agent with the current SDK, then run nylorun migrate v8 (see MIGRATION.md)`;
|
|
41
|
+
return `Unsupported manifestSchemaVersion ${String(version)}: use 8`;
|
|
42
|
+
}
|
|
43
|
+
/** Fields an environment manifest had that the runtime section of agent manifest v8 refuses. */
|
|
44
|
+
export const REMOVED_RUNTIME_SECTION_FIELDS = Object.freeze({
|
|
45
|
+
harness: "runtime.harness moved to harness.id in agent manifest v8: the harness section names the harness that runs the loop",
|
|
46
|
+
manifestSchemaVersion: "manifestSchemaVersion belongs at the top of the agent manifest, not in runtime",
|
|
47
|
+
name: "name belongs at the top of the agent manifest, not in runtime",
|
|
48
|
+
description: "description belongs at the top of the agent manifest, not in runtime",
|
|
49
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent manifest v8's two sections against each other (protocol 16). The Runtime sees
|
|
3
|
+
* both sections when a manifest is saved, so it checks there what `requires` used to check when a
|
|
4
|
+
* session opened: every gap is named in one `422 manifest_inconsistent`, and a dry run reports
|
|
5
|
+
* them as plan errors. The CLI and the SDK run the same checks while they compose the files.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentManifestV8, RuntimeSection } from "../contracts.js";
|
|
8
|
+
import type { AgentHarnessSection, AgentManifest, HarnessSection, WorkflowHarnessSection } from "../types/manifest.js";
|
|
9
|
+
import type { WorkflowManifest } from "../types/workflow.js";
|
|
10
|
+
/** What the loop needs of the runtime: a pod, any sandbox (`virtual` or `pod`), or nothing. */
|
|
11
|
+
export type SandboxNeed = "pod" | "sandbox" | "none";
|
|
12
|
+
export declare function isWorkflowHarness(harness: HarnessSection): harness is WorkflowHarnessSection;
|
|
13
|
+
/** The harness that runs the loop: `harness.id`, else ours. */
|
|
14
|
+
export declare function harnessIdOf(harness: HarnessSection): string;
|
|
15
|
+
/**
|
|
16
|
+
* What the harness section needs of the runtime, derived rather than declared: a custom harness
|
|
17
|
+
* needs a pod (it runs from the pod's image); skills need a sandbox to be mounted in; otherwise
|
|
18
|
+
* nothing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sandboxNeedOf(harness: HarnessSection): SandboxNeed;
|
|
21
|
+
/** Whether a runtime of `kind` gives the loop what it needs. */
|
|
22
|
+
export declare function kindMeets(kind: RuntimeSection["kind"], need: SandboxNeed): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A credential URL as the vault compares it: origin, path and query, with the default port and
|
|
25
|
+
* no fragment. Undefined for a URL the vault would refuse. The vault binds a `bearer` or
|
|
26
|
+
* `headers` credential to one URL and sends it to a server or HTTP tool declared at exactly that
|
|
27
|
+
* URL, so a slot covers a server when the two normalize the same.
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeCredentialUrl(input: string): string | undefined;
|
|
30
|
+
/** The runtime section an Agent made from `manifest` has: `kind: "none"` when it is absent. */
|
|
31
|
+
export declare function runtimeOf(manifest: Pick<AgentManifestV8, "runtime">): RuntimeSection;
|
|
32
|
+
/**
|
|
33
|
+
* Every gap between the harness and runtime sections, worded for a person, in the manifest's
|
|
34
|
+
* order. Empty when they fit:
|
|
35
|
+
*
|
|
36
|
+
* 1. A custom harness (`harness.id` not `nylorun`) needs `runtime.kind` `pod` with an `image`.
|
|
37
|
+
* 2. Every credential the harness names is a declared slot of the right type: an MCP server's,
|
|
38
|
+
* HTTP tool's, flow HTTP stage's or HTTP verifier's `credential` (an embedded agent's too) a
|
|
39
|
+
* `bearer` or `headers` slot bound to its URL, a skill's `secrets` `environment_secret` or
|
|
40
|
+
* `environment_variable` slots.
|
|
41
|
+
* 3. The runtime's kind gives the harness the sandbox it needs (`sandboxNeedOf`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function sectionGaps(manifest: Pick<AgentManifestV8, "harness" | "runtime">): string[];
|
|
44
|
+
/**
|
|
45
|
+
* The loop manifest the harness runs for a version of an agent manifest: the harness section
|
|
46
|
+
* with the manifest's name as its id, in the shape the engine reads (agent manifest v7, workflow
|
|
47
|
+
* manifest v3). The fields only the Runtime reads (`credential`, a skill's `secrets`, `plugins`,
|
|
48
|
+
* `loop`, the harness id) stay out.
|
|
49
|
+
*/
|
|
50
|
+
export declare function loopManifestOf(manifest: Pick<AgentManifestV8, "name" | "description" | "metadata" | "harness">): AgentManifest | WorkflowManifest;
|
|
51
|
+
/**
|
|
52
|
+
* The harness section a loop manifest makes (an SDK-built agent or flow, or a v7 manifest being
|
|
53
|
+
* migrated): its loop fields, without its identity, which the agent manifest holds. A v7
|
|
54
|
+
* manifest's `requires.secrets` become no skill's: the composer asks for them by name.
|
|
55
|
+
*/
|
|
56
|
+
export declare function harnessSectionOf(loop: AgentManifest | WorkflowManifest, options?: {
|
|
57
|
+
harness?: string;
|
|
58
|
+
plugins?: AgentHarnessSection["plugins"];
|
|
59
|
+
}): HarnessSection;
|
|
60
|
+
/** The Agent Plugins whose labels a loop manifest's skills and servers carry, each once, by name. */
|
|
61
|
+
export declare function pluginsOf(loop: AgentManifest | WorkflowManifest): {
|
|
62
|
+
name: string;
|
|
63
|
+
version?: string;
|
|
64
|
+
}[];
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { DEFAULT_HARNESS } from "../utils/harness-id.js";
|
|
2
|
+
import { forEachFlowNode } from "./flow/paths.js";
|
|
3
|
+
export function isWorkflowHarness(harness) {
|
|
4
|
+
return harness.kind === "workflow";
|
|
5
|
+
}
|
|
6
|
+
/** The harness that runs the loop: `harness.id`, else ours. */
|
|
7
|
+
export function harnessIdOf(harness) {
|
|
8
|
+
return harness.id ?? DEFAULT_HARNESS;
|
|
9
|
+
}
|
|
10
|
+
/** Whether a loop manifest, or any agent it embeds or delegates to, carries skills. */
|
|
11
|
+
function hasSkills(manifest) {
|
|
12
|
+
if ("kind" in manifest)
|
|
13
|
+
return Object.values(manifest.agents).some(hasSkills);
|
|
14
|
+
if (Object.keys(manifest.skills ?? {}).length > 0)
|
|
15
|
+
return true;
|
|
16
|
+
return (manifest.tools ?? []).some((tool) => tool.agent !== undefined && hasSkills(tool.agent));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the harness section needs of the runtime, derived rather than declared: a custom harness
|
|
20
|
+
* needs a pod (it runs from the pod's image); skills need a sandbox to be mounted in; otherwise
|
|
21
|
+
* nothing.
|
|
22
|
+
*/
|
|
23
|
+
export function sandboxNeedOf(harness) {
|
|
24
|
+
if (harnessIdOf(harness) !== DEFAULT_HARNESS)
|
|
25
|
+
return "pod";
|
|
26
|
+
if (isWorkflowHarness(harness))
|
|
27
|
+
return Object.values(harness.agents).some(hasSkills) ? "sandbox" : "none";
|
|
28
|
+
if (Object.keys(harness.skills ?? {}).length > 0)
|
|
29
|
+
return "sandbox";
|
|
30
|
+
return (harness.tools ?? []).some((tool) => tool.agent !== undefined && hasSkills(tool.agent)) ? "sandbox" : "none";
|
|
31
|
+
}
|
|
32
|
+
/** Whether a runtime of `kind` gives the loop what it needs. */
|
|
33
|
+
export function kindMeets(kind, need) {
|
|
34
|
+
if (need === "pod")
|
|
35
|
+
return kind === "pod";
|
|
36
|
+
if (need === "sandbox")
|
|
37
|
+
return kind === "virtual" || kind === "pod";
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A credential URL as the vault compares it: origin, path and query, with the default port and
|
|
42
|
+
* no fragment. Undefined for a URL the vault would refuse. The vault binds a `bearer` or
|
|
43
|
+
* `headers` credential to one URL and sends it to a server or HTTP tool declared at exactly that
|
|
44
|
+
* URL, so a slot covers a server when the two normalize the same.
|
|
45
|
+
*/
|
|
46
|
+
export function normalizeCredentialUrl(input) {
|
|
47
|
+
let url;
|
|
48
|
+
try {
|
|
49
|
+
url = new URL(input);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (url.username !== "" || url.password !== "" || url.hash !== "")
|
|
55
|
+
return undefined;
|
|
56
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
57
|
+
return undefined;
|
|
58
|
+
if ((url.protocol === "https:" && url.port === "443") || (url.protocol === "http:" && url.port === "80"))
|
|
59
|
+
url.port = "";
|
|
60
|
+
return `${url.origin}${url.pathname}${url.search}`;
|
|
61
|
+
}
|
|
62
|
+
const quoted = (value) => JSON.stringify(value);
|
|
63
|
+
/** The runtime section an Agent made from `manifest` has: `kind: "none"` when it is absent. */
|
|
64
|
+
export function runtimeOf(manifest) {
|
|
65
|
+
return manifest.runtime ?? { kind: "none" };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Every gap between the harness and runtime sections, worded for a person, in the manifest's
|
|
69
|
+
* order. Empty when they fit:
|
|
70
|
+
*
|
|
71
|
+
* 1. A custom harness (`harness.id` not `nylorun`) needs `runtime.kind` `pod` with an `image`.
|
|
72
|
+
* 2. Every credential the harness names is a declared slot of the right type: an MCP server's,
|
|
73
|
+
* HTTP tool's, flow HTTP stage's or HTTP verifier's `credential` (an embedded agent's too) a
|
|
74
|
+
* `bearer` or `headers` slot bound to its URL, a skill's `secrets` `environment_secret` or
|
|
75
|
+
* `environment_variable` slots.
|
|
76
|
+
* 3. The runtime's kind gives the harness the sandbox it needs (`sandboxNeedOf`).
|
|
77
|
+
*/
|
|
78
|
+
export function sectionGaps(manifest) {
|
|
79
|
+
const { harness } = manifest;
|
|
80
|
+
const runtime = runtimeOf(manifest);
|
|
81
|
+
const gaps = [];
|
|
82
|
+
const kindText = manifest.runtime === undefined ? "the manifest has no runtime section" : `the runtime is ${quoted(runtime.kind)}`;
|
|
83
|
+
// 1. A custom harness runs from its pod's image.
|
|
84
|
+
const harnessId = harnessIdOf(harness);
|
|
85
|
+
if (harnessId !== DEFAULT_HARNESS) {
|
|
86
|
+
if (runtime.kind !== "pod")
|
|
87
|
+
gaps.push(`harness.id ${quoted(harnessId)} needs runtime.kind "pod"; ${kindText}`);
|
|
88
|
+
else if (runtime.image === undefined)
|
|
89
|
+
gaps.push(`harness.id ${quoted(harnessId)} needs runtime.image: a custom harness runs from its pod's image`);
|
|
90
|
+
}
|
|
91
|
+
// 2. Credentials name declared slots of the right type.
|
|
92
|
+
const slots = runtime.secrets ?? {};
|
|
93
|
+
const urlSlot = (where, name, url, what) => {
|
|
94
|
+
const slot = slots[name];
|
|
95
|
+
if (slot === undefined) {
|
|
96
|
+
gaps.push(`${where} ${quoted(name)} is not a secret slot in runtime.secrets`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (slot.type !== "bearer" && slot.type !== "headers") {
|
|
100
|
+
gaps.push(`${where} ${quoted(name)} is a slot of type ${slot.type}; ${what} needs a bearer or headers slot`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const want = normalizeCredentialUrl(url);
|
|
104
|
+
if (want === undefined || normalizeCredentialUrl(slot.url) !== want)
|
|
105
|
+
gaps.push(`${where} ${quoted(name)} is bound to ${slot.url}, not to ${what}'s URL ${url}`);
|
|
106
|
+
};
|
|
107
|
+
// The Tool Gate sends an HTTP target's `credential` from the vault by that name, wherever the
|
|
108
|
+
// target sits: an agent's HTTP tool, a flow's HTTP stage or HTTP verifier, or one of an
|
|
109
|
+
// embedded agent's.
|
|
110
|
+
const agentTools = (tools, at) => {
|
|
111
|
+
for (const tool of tools ?? []) {
|
|
112
|
+
if (tool.http?.credential !== undefined)
|
|
113
|
+
urlSlot(`${at}.tools.${tool.name}.http.credential`, tool.http.credential, tool.http.url, "an HTTP tool");
|
|
114
|
+
if (tool.agent !== undefined)
|
|
115
|
+
embedded(tool.agent, `${at}.tools.${tool.name}.agent`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const flowStages = (flow, at) => {
|
|
119
|
+
forEachFlowNode(flow.root, ({ node, key, role }) => {
|
|
120
|
+
const http = "http" in node ? node.http : "tool" in node ? node.tool.http : undefined;
|
|
121
|
+
if (http?.credential !== undefined)
|
|
122
|
+
urlSlot(`${at}.root stage ${quoted(key)} http.credential`, http.credential, http.url, role === "verify" ? "an HTTP verifier" : "an HTTP stage");
|
|
123
|
+
});
|
|
124
|
+
for (const [id, agent] of Object.entries(flow.agents))
|
|
125
|
+
embedded(agent, `${at}.agents.${id}`);
|
|
126
|
+
};
|
|
127
|
+
const embedded = (agent, at) => "kind" in agent ? flowStages(agent, at) : agentTools(agent.tools, at);
|
|
128
|
+
if (isWorkflowHarness(harness))
|
|
129
|
+
flowStages(harness, "harness");
|
|
130
|
+
else {
|
|
131
|
+
for (const [key, server] of Object.entries(harness.mcpServers ?? {}))
|
|
132
|
+
if (server.credential !== undefined)
|
|
133
|
+
urlSlot(`harness.mcpServers.${key}.credential`, server.credential, server.url, "an MCP server");
|
|
134
|
+
agentTools(harness.tools, "harness");
|
|
135
|
+
for (const [key, skill] of Object.entries(harness.skills ?? {}))
|
|
136
|
+
for (const name of skill.secrets ?? []) {
|
|
137
|
+
const slot = slots[name];
|
|
138
|
+
if (slot === undefined)
|
|
139
|
+
gaps.push(`harness.skills.${key}.secrets ${quoted(name)} is not a secret slot in runtime.secrets`);
|
|
140
|
+
else if (slot.type !== "environment_secret" && slot.type !== "environment_variable")
|
|
141
|
+
gaps.push(`harness.skills.${key}.secrets ${quoted(name)} is a slot of type ${slot.type}; a skill reads environment_secret or environment_variable slots`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// 3. The sandbox the loop needs. A custom harness's pod is gap 1.
|
|
145
|
+
const need = sandboxNeedOf(harness);
|
|
146
|
+
if (need === "sandbox" && !kindMeets(runtime.kind, need)) {
|
|
147
|
+
const what = isWorkflowHarness(harness) ? "harness.agents carry skills, which need" : "harness.skills needs";
|
|
148
|
+
gaps.push(manifest.runtime === undefined
|
|
149
|
+
? `${what} a sandbox; the manifest has no runtime section, so an Agent made from it has none`
|
|
150
|
+
: `${what} a sandbox; runtime.kind ${quoted(runtime.kind)} has none`);
|
|
151
|
+
}
|
|
152
|
+
return gaps;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The loop manifest the harness runs for a version of an agent manifest: the harness section
|
|
156
|
+
* with the manifest's name as its id, in the shape the engine reads (agent manifest v7, workflow
|
|
157
|
+
* manifest v3). The fields only the Runtime reads (`credential`, a skill's `secrets`, `plugins`,
|
|
158
|
+
* `loop`, the harness id) stay out.
|
|
159
|
+
*/
|
|
160
|
+
export function loopManifestOf(manifest) {
|
|
161
|
+
const { harness } = manifest;
|
|
162
|
+
const identity = {
|
|
163
|
+
id: manifest.name,
|
|
164
|
+
...(manifest.description === undefined ? {} : { description: manifest.description }),
|
|
165
|
+
...(manifest.metadata === undefined ? {} : { metadata: manifest.metadata }),
|
|
166
|
+
};
|
|
167
|
+
if (isWorkflowHarness(harness))
|
|
168
|
+
return {
|
|
169
|
+
kind: "workflow",
|
|
170
|
+
workflowSchemaVersion: 3,
|
|
171
|
+
...identity,
|
|
172
|
+
...(harness.inputSchema === undefined ? {} : { inputSchema: harness.inputSchema }),
|
|
173
|
+
...(harness.outputSchema === undefined ? {} : { outputSchema: harness.outputSchema }),
|
|
174
|
+
root: harness.root,
|
|
175
|
+
agents: harness.agents,
|
|
176
|
+
};
|
|
177
|
+
const skills = Object.entries(harness.skills ?? {}).map(([key, { secrets: _, ...skill }]) => [key, skill]);
|
|
178
|
+
const servers = Object.entries(harness.mcpServers ?? {}).map(([key, { credential: _, ...server }]) => [key, server]);
|
|
179
|
+
return {
|
|
180
|
+
manifestSchemaVersion: 7,
|
|
181
|
+
...identity,
|
|
182
|
+
...(harness.outputSchema === undefined ? {} : { outputSchema: harness.outputSchema }),
|
|
183
|
+
...(harness.instructions === undefined ? {} : { instructions: harness.instructions }),
|
|
184
|
+
...(harness.tools === undefined ? {} : { tools: harness.tools }),
|
|
185
|
+
...(skills.length === 0 ? {} : { skills: Object.fromEntries(skills) }),
|
|
186
|
+
...(servers.length === 0 ? {} : { mcpServers: Object.fromEntries(servers) }),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The harness section a loop manifest makes (an SDK-built agent or flow, or a v7 manifest being
|
|
191
|
+
* migrated): its loop fields, without its identity, which the agent manifest holds. A v7
|
|
192
|
+
* manifest's `requires.secrets` become no skill's: the composer asks for them by name.
|
|
193
|
+
*/
|
|
194
|
+
export function harnessSectionOf(loop, options = {}) {
|
|
195
|
+
const plugins = options.plugins ?? pluginsOf(loop);
|
|
196
|
+
const extra = {
|
|
197
|
+
...(options.harness === undefined || options.harness === DEFAULT_HARNESS ? {} : { id: options.harness }),
|
|
198
|
+
...(plugins.length === 0 ? {} : { plugins }),
|
|
199
|
+
};
|
|
200
|
+
if ("kind" in loop)
|
|
201
|
+
return {
|
|
202
|
+
kind: "workflow",
|
|
203
|
+
...extra,
|
|
204
|
+
...(loop.inputSchema === undefined ? {} : { inputSchema: loop.inputSchema }),
|
|
205
|
+
...(loop.outputSchema === undefined ? {} : { outputSchema: loop.outputSchema }),
|
|
206
|
+
root: loop.root,
|
|
207
|
+
agents: loop.agents,
|
|
208
|
+
};
|
|
209
|
+
return {
|
|
210
|
+
...extra,
|
|
211
|
+
...(loop.instructions === undefined ? {} : { instructions: loop.instructions }),
|
|
212
|
+
...(loop.tools === undefined ? {} : { tools: loop.tools }),
|
|
213
|
+
...(loop.skills === undefined ? {} : { skills: loop.skills }),
|
|
214
|
+
...(loop.mcpServers === undefined ? {} : { mcpServers: loop.mcpServers }),
|
|
215
|
+
...(loop.outputSchema === undefined ? {} : { outputSchema: loop.outputSchema }),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/** The Agent Plugins whose labels a loop manifest's skills and servers carry, each once, by name. */
|
|
219
|
+
export function pluginsOf(loop) {
|
|
220
|
+
if ("kind" in loop)
|
|
221
|
+
return [];
|
|
222
|
+
const byName = new Map();
|
|
223
|
+
for (const item of [...Object.values(loop.skills ?? {}), ...Object.values(loop.mcpServers ?? {})])
|
|
224
|
+
if (item.plugin !== undefined && !byName.has(item.plugin.name))
|
|
225
|
+
byName.set(item.plugin.name, { ...item.plugin });
|
|
226
|
+
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
227
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { AgentManifest } from "../types/manifest.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Whether `candidate` is a valid turn-manifest variant of the session's pinned manifest
|
|
4
4
|
* (`loops.md` §3.4). A variant may remove tools (agents used as tools and HTTP tools included),
|
|
5
|
-
* tighten its MCP servers' tool settings
|
|
5
|
+
* tighten its MCP servers' tool settings, and change its instructions, name,
|
|
6
6
|
* description and metadata. Its skills and servers are setup: the sandbox holds the skills from
|
|
7
7
|
* the session's start.
|
|
8
8
|
*/
|
|
@@ -19,10 +19,10 @@ function removeOnlyTools(pinned, candidate) {
|
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* One tool setting, or the `"*"` entry, only tightened
|
|
22
|
+
* One tool setting, or the `"*"` entry, only tightened: `enabled` kept or set to
|
|
23
23
|
* `false`, `approval` and `deferred` kept. Each level of a tool's resolution (its entry, then
|
|
24
24
|
* `"*"`) either keeps its value or tightens it, so the tool does too. A variant adds no
|
|
25
|
-
* approval: tool approvals are the Tenant's tool policy
|
|
25
|
+
* approval: tool approvals are the Tenant's tool policy.
|
|
26
26
|
*/
|
|
27
27
|
function tightensSettings(prior, next) {
|
|
28
28
|
return ((next.enabled === prior?.enabled || next.enabled === false) &&
|
|
@@ -31,7 +31,7 @@ function tightensSettings(prior, next) {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* The servers of a turn variant: the pinned ones, the same but for their `tools` maps, where a
|
|
34
|
-
* variant may only disable a tool
|
|
34
|
+
* variant may only disable a tool. An entry the pin has
|
|
35
35
|
* stays, since dropping one could widen.
|
|
36
36
|
*/
|
|
37
37
|
function tightensServers(pinned, candidate) {
|
|
@@ -56,7 +56,7 @@ function tightensServers(pinned, candidate) {
|
|
|
56
56
|
/**
|
|
57
57
|
* Whether `candidate` is a valid turn-manifest variant of the session's pinned manifest
|
|
58
58
|
* (`loops.md` §3.4). A variant may remove tools (agents used as tools and HTTP tools included),
|
|
59
|
-
* tighten its MCP servers' tool settings
|
|
59
|
+
* tighten its MCP servers' tool settings, and change its instructions, name,
|
|
60
60
|
* description and metadata. Its skills and servers are setup: the sandbox holds the skills from
|
|
61
61
|
* the session's start.
|
|
62
62
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a harness writes into the session's record besides its effects
|
|
2
|
+
* What a harness writes into the session's record besides its effects: transcript
|
|
3
3
|
* entries, and the effect id rule replays depend on.
|
|
4
4
|
*
|
|
5
5
|
* Transcript. A session's transcript is shared by every turn: a run reads it once
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a harness writes into the session's record besides its effects
|
|
2
|
+
* What a harness writes into the session's record besides its effects: transcript
|
|
3
3
|
* entries, and the effect id rule replays depend on.
|
|
4
4
|
*
|
|
5
5
|
* Transcript. A session's transcript is shared by every turn: a run reads it once
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The gates a harness calls
|
|
2
|
+
* The gates a harness calls: the Model Gate and the Tool Gate, on the gateway's port. A
|
|
3
3
|
* harness never holds a model or tool credential: it presents the run token of the run it holds
|
|
4
4
|
* (`RunGrant.token`) as `Authorization: Bearer`, and the gate takes the session, turn and agent
|
|
5
5
|
* from the token. Every call is keyed by its effect id, sent as `Idempotency-Key`: a re-send
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The gates a harness calls
|
|
2
|
+
* The gates a harness calls: the Model Gate and the Tool Gate, on the gateway's port. A
|
|
3
3
|
* harness never holds a model or tool credential: it presents the run token of the run it holds
|
|
4
4
|
* (`RunGrant.token`) as `Authorization: Bearer`, and the gate takes the session, turn and agent
|
|
5
5
|
* from the token. Every call is keyed by its effect id, sent as `Idempotency-Key`: a re-send
|