@tangle-network/agent-runtime 0.89.0 → 0.90.1
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/README.md +51 -18
- package/dist/agent.d.ts +53 -2
- package/dist/agent.js +168 -6
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/chunk-5QOB7H74.js +387 -0
- package/dist/chunk-5QOB7H74.js.map +1 -0
- package/dist/{chunk-4WXGK6GV.js → chunk-7ON74BQO.js} +2 -2
- package/dist/{chunk-7LO5GMAO.js → chunk-CMYMTRGA.js} +14 -5
- package/dist/chunk-CMYMTRGA.js.map +1 -0
- package/dist/{chunk-UD4BHQMI.js → chunk-IVGYLCFH.js} +2 -2
- package/dist/{chunk-UD4BHQMI.js.map → chunk-IVGYLCFH.js.map} +1 -1
- package/dist/{chunk-VNOOH22O.js → chunk-OOL3675H.js} +85 -4
- package/dist/chunk-OOL3675H.js.map +1 -0
- package/dist/{chunk-5AVV7KAH.js → chunk-QK4DV5PR.js} +2 -2
- package/dist/chunk-R2VAJGR3.js +214 -0
- package/dist/chunk-R2VAJGR3.js.map +1 -0
- package/dist/{chunk-N7EJV7N3.js → chunk-RYBVU4M3.js} +3592 -3562
- package/dist/chunk-RYBVU4M3.js.map +1 -0
- package/dist/{chunk-BQPFZE2C.js → chunk-WRUSWK4F.js} +5 -5
- package/dist/{chunk-PIPPLSOF.js → chunk-ZV4LXYCJ.js} +451 -24
- package/dist/chunk-ZV4LXYCJ.js.map +1 -0
- package/dist/{worktree-harness-CX_McRLp.d.ts → completion-gate-DkAnUmpb.d.ts} +45 -45
- package/dist/{coordination-CuDLO8wj.d.ts → coordination-rRj5hjJK.d.ts} +415 -227
- package/dist/environment-provider.d.ts +3 -3
- package/dist/index.d.ts +255 -16
- package/dist/index.js +463 -72
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +228 -84
- package/dist/intelligence.js +259 -166
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +120 -0
- package/dist/knowledge.js +28 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.js +2 -2
- package/dist/{local-harness-sI0S_XNA.d.ts → local-harness-dcD5WTTr.d.ts} +3 -0
- package/dist/{loop-runner-bin-hQDUL8Ld.d.ts → loop-runner-bin-DTbZVGfM.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +6 -6
- package/dist/loop-runner-bin.js +7 -7
- package/dist/loops.d.ts +34 -369
- package/dist/loops.js +31 -5
- package/dist/mcp/bin.js +5 -5
- package/dist/mcp/index.d.ts +10 -11
- package/dist/mcp/index.js +10 -10
- package/dist/{mcp-serve-verifier-FL7-ZEb_.d.ts → mcp-serve-verifier-XsX8rkB9.d.ts} +12 -1
- package/dist/{openai-tools-BnrOmGjN.d.ts → openai-tools-C4ZfUD4L.d.ts} +1 -1
- package/dist/profiles.d.ts +196 -5
- package/dist/profiles.js +8 -0
- package/dist/profiles.js.map +1 -1
- package/dist/{router-client-r8y_VFVM.d.ts → router-client-DJImUDlm.d.ts} +1 -1
- package/dist/structural-rollout-MwlpgQ-6.d.ts +446 -0
- package/dist/supervise-DPmYPk0j.d.ts +131 -0
- package/dist/{types-ESeMOj94.d.ts → types-SyuwunY_.d.ts} +1 -1
- package/dist/{types-Driepl87.d.ts → types-eMNgWgFi.d.ts} +2 -2
- package/dist/{worktree-fanout-D6xR2CIA.d.ts → worktree-fanout-BDFQIO-Y.d.ts} +234 -234
- package/package.json +12 -4
- package/skills/agent-runtime-adoption/SKILL.md +74 -24
- package/skills/build-with-agent-runtime/SKILL.md +23 -20
- package/skills/loop-writer/SKILL.md +6 -5
- package/skills/supervise/SKILL.md +2 -2
- package/dist/chunk-7LO5GMAO.js.map +0 -1
- package/dist/chunk-N7EJV7N3.js.map +0 -1
- package/dist/chunk-PIPPLSOF.js.map +0 -1
- package/dist/chunk-VNOOH22O.js.map +0 -1
- package/dist/otel-export-BKmNwiCb.d.ts +0 -180
- /package/dist/{chunk-4WXGK6GV.js.map → chunk-7ON74BQO.js.map} +0 -0
- /package/dist/{chunk-5AVV7KAH.js.map → chunk-QK4DV5PR.js.map} +0 -0
- /package/dist/{chunk-BQPFZE2C.js.map → chunk-WRUSWK4F.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
# @tangle-network/agent-runtime
|
|
2
2
|
|
|
3
|
-
The engine Tangle's AI agents run on. It runs an agent
|
|
3
|
+
The engine Tangle's AI agents run on. It runs an agent as a **chat turn**, a **one-shot task**, or a **team of agents** working toward a goal, records every run, and uses those records to **measure and improve** agents against real pass/fail checks.
|
|
4
4
|
|
|
5
|
-
One loop, used
|
|
5
|
+
One loop, used four common ways. Domain behavior (models, tools, knowledge) plugs in as adapters; the scoring statistics and the ship decision come from [`@tangle-network/agent-eval`](https://www.npmjs.com/package/@tangle-network/agent-eval); sandboxed execution from [`@tangle-network/sandbox`](https://www.npmjs.com/package/@tangle-network/sandbox).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
pnpm add @tangle-network/agent-runtime @tangle-network/agent-eval @tangle-network/sandbox
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Contents
|
|
12
|
+
|
|
13
|
+
- [What you do with it](#what-you-do-with-it)
|
|
14
|
+
- [Run a chat turn](#run-a-chat-turn)
|
|
15
|
+
- [Supervise a team of agents](#supervise-a-team-of-agents)
|
|
16
|
+
- [Improve an agent](#improve-an-agent)
|
|
17
|
+
- [Improve a knowledge base](#improve-a-knowledge-base)
|
|
18
|
+
- [How it works](#how-it-works-the-short-version)
|
|
19
|
+
- [Examples](#examples)
|
|
20
|
+
- [Where to go next](#where-to-go-next)
|
|
21
|
+
|
|
22
|
+
**See it run in 30 seconds** (offline, no keys): the one move everything else builds on, a driver reading a worker's output and composing the next step from it:
|
|
12
23
|
|
|
13
24
|
```bash
|
|
14
25
|
pnpm tsx examples/driver-loop/driver-loop.ts
|
|
@@ -18,9 +29,10 @@ pnpm tsx examples/driver-loop/driver-loop.ts
|
|
|
18
29
|
|
|
19
30
|
| You want to… | Call |
|
|
20
31
|
|---|---|
|
|
21
|
-
| Run a **chat turn**
|
|
32
|
+
| Run a **chat turn** for a production product agent | `handleChatTurn(...)` |
|
|
22
33
|
| Have one agent **supervise a team of agents** toward a goal | `supervise(profile, task, opts)` |
|
|
23
34
|
| **Improve** an agent and prove the gain on fresh tasks | `improve(profile, findings, opts)` |
|
|
35
|
+
| **Improve** a knowledge base with agents, checks, and safe promotion | `runKnowledgeImprovementJob(...)` |
|
|
24
36
|
|
|
25
37
|
### Run a chat turn
|
|
26
38
|
|
|
@@ -56,7 +68,7 @@ const result = await supervise(
|
|
|
56
68
|
|
|
57
69
|
### Improve an agent
|
|
58
70
|
|
|
59
|
-
`improve` optimizes one part of an agent (its prompt, skills, or code) and **only ships a change if it beats the current agent on tasks it never practiced on
|
|
71
|
+
`improve` optimizes one part of an agent (its prompt, skills, or code) and **only ships a change if it beats the current agent on tasks it never practiced on**. Registering an agent for self-improvement cannot ship a worse candidate unless the caller supplies a bad measurement.
|
|
60
72
|
|
|
61
73
|
```ts
|
|
62
74
|
import { improve } from '@tangle-network/agent-runtime'
|
|
@@ -68,16 +80,36 @@ const { profile, shipped, lift } = await improve(baseProfile, findings, {
|
|
|
68
80
|
})
|
|
69
81
|
```
|
|
70
82
|
|
|
83
|
+
### Improve a knowledge base
|
|
84
|
+
|
|
85
|
+
`runKnowledgeImprovementJob` is the runtime-owned front door for KB, wiki, memory-backed, and RAG improvement jobs. It creates a candidate copy, runs supervised agents against it, checks readiness through `@tangle-network/agent-knowledge`, measures spend and timing, and promotes only when the candidate passes.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { runKnowledgeImprovementJob } from '@tangle-network/agent-runtime/knowledge'
|
|
89
|
+
|
|
90
|
+
const result = await runKnowledgeImprovementJob({
|
|
91
|
+
root: './kb',
|
|
92
|
+
goal: 'Improve support refund-policy knowledge',
|
|
93
|
+
readinessSpecs,
|
|
94
|
+
budget: { maxIterations: 8, maxTokens: 120_000, maxUsd: 10 },
|
|
95
|
+
backend,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
console.log(result.promoted, result.measurement.supervisedSpent)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use it when the product needs one knob for "make this knowledge base better" instead of wiring `improveKnowledgeBase`, a runtime supervisor, candidate workspaces, readiness checks, and promotion tracking by hand.
|
|
102
|
+
|
|
71
103
|
## How it works (the short version)
|
|
72
104
|
|
|
73
|
-
- **One agent, run two ways.** The same agent runs at "do the task" speed and at "get better at the task" speed. "Driver", "worker", and "coordinator"
|
|
74
|
-
- **Everything is measured.** Every run is a trace: tokens, dollars, time, and a pass/fail score from a real check. "Better" is a number with a denominator, not a vibe
|
|
75
|
-
- **Improvement is gated.** A change ships only after it beats the current agent on fresh tasks no tuning step ever saw, with a statistical test
|
|
76
|
-
- **The grader is honest.** Whatever gives feedback never sees the answer key, and scores are recomputed from the attempts actually run
|
|
105
|
+
- **One agent, run two ways.** The same agent runs at "do the task" speed and at "get better at the task" speed. "Driver", "worker", and "coordinator" are roles one agent plays, not separate types.
|
|
106
|
+
- **Everything is measured.** Every run is a trace: tokens, dollars, time, and a pass/fail score from a real check. "Better" is a number with a denominator, not a vibe, and "equally good but cheaper" is a result you can prove.
|
|
107
|
+
- **Improvement is gated.** A change ships only after it beats the current agent on fresh tasks no tuning step ever saw, with a statistical test, not a single lucky run.
|
|
108
|
+
- **The grader is honest.** Whatever gives feedback never sees the answer key, and scores are recomputed from the attempts actually run. An agent cannot fabricate its own win.
|
|
77
109
|
|
|
78
110
|
## Examples
|
|
79
111
|
|
|
80
|
-
Runnable, grouped by what they show
|
|
112
|
+
Runnable, grouped by what they show. Copy the one nearest your task:
|
|
81
113
|
|
|
82
114
|
| Do this | Example |
|
|
83
115
|
|---|---|
|
|
@@ -85,20 +117,21 @@ Runnable, grouped by what they show — copy the one nearest your task:
|
|
|
85
117
|
| Drive a team of agents to a goal | [`supervise`](./examples/supervise) · [`recursive-supervisor`](./examples/recursive-supervisor) |
|
|
86
118
|
| Benchmark strategies on your own domain | [`coding-benchmark`](./examples/coding-benchmark) |
|
|
87
119
|
| Benchmark **harnesses × models** over a real task suite (the real WebCode dataset) | [`webcode-matrix`](./examples/webcode-matrix) |
|
|
88
|
-
| Render a **multi-profile leaderboard**
|
|
120
|
+
| Render a **multi-profile leaderboard** with ranked board, score matrix, and SVG/HTML charts | `leaderboard(records)` → `renderLeaderboardMarkdown` / `Svg` / `Html` |
|
|
89
121
|
| Trace + bill + effort-gate the WebCode benchmark (the Intelligence SDK) | [`intelligence-webcode`](./examples/intelligence-webcode) |
|
|
90
122
|
| Self-improve an agent, gated on a held-out set | [`improve`](./examples/improve) · [`self-improving-coder`](./examples/self-improving-coder) |
|
|
123
|
+
| Improve a KB, wiki, or RAG corpus with runtime agents | [`docs/canonical-api.md`](./docs/canonical-api.md) |
|
|
91
124
|
| Study coordination vs raw compute | [`ablation-suite`](./examples/ablation-suite) |
|
|
92
125
|
|
|
93
|
-
All
|
|
126
|
+
All 29 live in [`examples/`](./examples).
|
|
94
127
|
|
|
95
128
|
## Where to go next
|
|
96
129
|
|
|
97
|
-
- New here? [`docs/concepts.md`](./docs/concepts.md)
|
|
98
|
-
- [`docs/canonical-api.md`](./docs/canonical-api.md)
|
|
99
|
-
- [`docs/api/primitive-catalog.md`](./docs/api/primitive-catalog.md)
|
|
100
|
-
- Import subpaths: the root export is the product surface (`handleChatTurn`, `improve`); deeper capabilities ship as subpaths
|
|
101
|
-
- [`docs/architecture.md`](./docs/architecture.md)
|
|
102
|
-
- [`bench/HARNESS.md`](./bench/HARNESS.md)
|
|
130
|
+
- New here? [`docs/concepts.md`](./docs/concepts.md), the mental model in plain terms.
|
|
131
|
+
- [`docs/canonical-api.md`](./docs/canonical-api.md), find the primitive: "I want to ___ → use ___".
|
|
132
|
+
- [`docs/api/primitive-catalog.md`](./docs/api/primitive-catalog.md), every export in one generated, never-stale list with its import path. Check it before building anything new.
|
|
133
|
+
- Import subpaths: the root export is the product surface (`handleChatTurn`, `improve`); deeper capabilities ship as subpaths: `/loops` (multi-agent + the loop kernel), `/knowledge` (KB improvement), `/mcp` (tool servers), `/intelligence` (observability drop-in), `/lifecycle`, `/agent`, `/profiles`, `/platform`, `/analyst-loop`, `/environment-provider`.
|
|
134
|
+
- [`docs/architecture.md`](./docs/architecture.md), the design, end to end.
|
|
135
|
+
- [`bench/HARNESS.md`](./bench/HARNESS.md), the experiment harness and how to run a benchmark.
|
|
103
136
|
|
|
104
137
|
**Contributing:** `pnpm i && pnpm test` gets you running; the full local gate is the [`package.json`](./package.json) scripts (`lint`, `typecheck`, `docs:check`).
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tangle_network_agent_eval from '@tangle-network/agent-eval';
|
|
2
2
|
import { TraceAnalystKindSpec, AnalystFinding } from '@tangle-network/agent-eval';
|
|
3
3
|
import { A as ArtifactKind, C as CandidateGenerator, P as PromotionGate } from './generator-YkAQrOoD.js';
|
|
4
|
-
import {
|
|
4
|
+
import { b as RuntimeStreamEvent, S as SandboxClient, c as OutputAdapter, A as AgentRunSpec } from './types-SyuwunY_.js';
|
|
5
5
|
import { A as AgentSurfaces } from './improvement-adapter-CDR8QNVM.js';
|
|
6
6
|
export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-CDR8QNVM.js';
|
|
7
7
|
import { K as KnowledgeAdapter, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
|
|
@@ -415,6 +415,55 @@ declare function measureOutcome<TProposal, TEdit>(result: RunAnalystLoopResult<T
|
|
|
415
415
|
outcome: OutcomeMeasurement;
|
|
416
416
|
}>;
|
|
417
417
|
|
|
418
|
+
/** Known AgentProfile axes a run path may or may not carry into execution. */
|
|
419
|
+
declare const AGENT_PROFILE_MATERIALIZATION_AXES: readonly ["identity", "name", "model", "prompt", "systemPrompt", "instructions", "resources", "files", "resourceInstructions", "skills", "resourceTools", "resourceAgents", "commands", "tools", "permissions", "mcp", "mcpConnections", "connections", "subagents", "hooks", "modes", "confidential", "metadata", "extensions"];
|
|
420
|
+
type KnownAgentProfileMaterializationAxis = (typeof AGENT_PROFILE_MATERIALIZATION_AXES)[number];
|
|
421
|
+
/** AgentProfile axis name, with `custom:<name>` reserved for caller-owned extensions. */
|
|
422
|
+
type AgentProfileMaterializationAxis = KnownAgentProfileMaterializationAxis | `custom:${string}`;
|
|
423
|
+
/** Declares which AgentProfile axes a concrete run path really carries. */
|
|
424
|
+
interface ProfileMaterializationContract {
|
|
425
|
+
/** Human-readable run path, e.g. `createSandboxAct` or `prompt-only-message`. */
|
|
426
|
+
name: string;
|
|
427
|
+
/** Profile axes this run path actually carries into execution. */
|
|
428
|
+
axes: readonly AgentProfileMaterializationAxis[];
|
|
429
|
+
}
|
|
430
|
+
/** One changed AgentProfile axis that would be dropped by a run path. */
|
|
431
|
+
interface ProfileMaterializationIssue {
|
|
432
|
+
contract: string;
|
|
433
|
+
axis: AgentProfileMaterializationAxis;
|
|
434
|
+
reason: 'unsupported-axis';
|
|
435
|
+
supportedAxes: readonly AgentProfileMaterializationAxis[];
|
|
436
|
+
}
|
|
437
|
+
/** Input for declaring a run path's profile-axis support. */
|
|
438
|
+
interface DefineProfileMaterializationContractOptions {
|
|
439
|
+
name: string;
|
|
440
|
+
axes: readonly AgentProfileMaterializationAxis[];
|
|
441
|
+
}
|
|
442
|
+
/** Input for checking a candidate diff against a run path. */
|
|
443
|
+
interface ValidateProfileMaterializationOptions {
|
|
444
|
+
contract: ProfileMaterializationContract;
|
|
445
|
+
changedAxes: readonly AgentProfileMaterializationAxis[];
|
|
446
|
+
}
|
|
447
|
+
/** Input for throwing on dropped profile axes. */
|
|
448
|
+
interface AssertProfileMaterializationOptions extends ValidateProfileMaterializationOptions {
|
|
449
|
+
/** Extra label included in the thrown error, usually the caller or run id. */
|
|
450
|
+
context?: string;
|
|
451
|
+
}
|
|
452
|
+
/** Materialization contract for `createSandboxAct`, which forwards the full AgentProfile. */
|
|
453
|
+
declare const sandboxActProfileMaterialization: ProfileMaterializationContract;
|
|
454
|
+
/** Materialization contract for a run path that only injects prompt text. */
|
|
455
|
+
declare const promptOnlyProfileMaterialization: ProfileMaterializationContract;
|
|
456
|
+
/** Materialization contract for a run path that injects prompt text plus inline resources. */
|
|
457
|
+
declare const promptResourceProfileMaterialization: ProfileMaterializationContract;
|
|
458
|
+
/** Define the profile axes a concrete run path actually carries into execution. */
|
|
459
|
+
declare function defineProfileMaterializationContract(options: DefineProfileMaterializationContractOptions): ProfileMaterializationContract;
|
|
460
|
+
/** Return every changed profile axis that the selected run path would drop. */
|
|
461
|
+
declare function validateProfileMaterialization(options: ValidateProfileMaterializationOptions): readonly ProfileMaterializationIssue[];
|
|
462
|
+
/** Throw when a candidate changes axes the selected run path cannot carry. */
|
|
463
|
+
declare function assertProfileMaterialization(options: AssertProfileMaterializationOptions): void;
|
|
464
|
+
/** Format profile-axis drop issues into a concise operator-facing error. */
|
|
465
|
+
declare function renderProfileMaterializationIssues(issues: readonly ProfileMaterializationIssue[], context?: string): string;
|
|
466
|
+
|
|
418
467
|
/**
|
|
419
468
|
* Sandbox bridge for `AgentRuntime.act` — prod-faithful eval execution.
|
|
420
469
|
*
|
|
@@ -464,6 +513,8 @@ interface CreateSandboxActOptions<TPersona, TRunOutput> {
|
|
|
464
513
|
compose?: (persona: TPersona) => SandboxActComposeOverrides;
|
|
465
514
|
/** Sandbox-SDK overrides forwarded to `createSandboxForSpec`. */
|
|
466
515
|
sandboxOverrides?: AgentRunSpec<unknown>['sandboxOverrides'];
|
|
516
|
+
/** Optional changed axes the caller expects this path to carry. */
|
|
517
|
+
requiredProfileAxes?: readonly AgentProfileMaterializationAxis[];
|
|
467
518
|
/** Stable run name surfaced in mapped `llm_call` events. */
|
|
468
519
|
name?: string;
|
|
469
520
|
/** Override the `SandboxEvent → RuntimeStreamEvent` mapper. */
|
|
@@ -479,4 +530,4 @@ interface CreateSandboxActOptions<TPersona, TRunOutput> {
|
|
|
479
530
|
*/
|
|
480
531
|
declare function createSandboxAct<TPersona, TRunOutput>(options: CreateSandboxActOptions<TPersona, TRunOutput>): (persona: TPersona, ctx: AgentRunContext) => AgentRunInvocation<TRunOutput>;
|
|
481
532
|
|
|
482
|
-
export { type AgentManifest, AgentManifestError, type AgentRubric, type AgentRunContext, type AgentRunInvocation, type AgentRuntime, AgentSurfaces, type AnalystConfig, type AutoApplyPolicy, type CreateSandboxActOptions, type CreateSurfaceKnowledgeAdapterOpts, type JudgeConfig, type KnowledgeAdapterDeps, type OutcomeMeasurement, type OutcomeMeasurementOpts, type RubricDimension, type SurfaceLifecycle, collectAgentRun, createSandboxAct, createSurfaceKnowledgeAdapter, defineAgent, measureOutcome, unimplementedAgentRun };
|
|
533
|
+
export { AGENT_PROFILE_MATERIALIZATION_AXES, type AgentManifest, AgentManifestError, type AgentProfileMaterializationAxis, type AgentRubric, type AgentRunContext, type AgentRunInvocation, type AgentRuntime, AgentSurfaces, type AnalystConfig, type AssertProfileMaterializationOptions, type AutoApplyPolicy, type CreateSandboxActOptions, type CreateSurfaceKnowledgeAdapterOpts, type DefineProfileMaterializationContractOptions, type JudgeConfig, type KnowledgeAdapterDeps, type KnownAgentProfileMaterializationAxis, type OutcomeMeasurement, type OutcomeMeasurementOpts, type ProfileMaterializationContract, type ProfileMaterializationIssue, type RubricDimension, type SurfaceLifecycle, type ValidateProfileMaterializationOptions, assertProfileMaterialization, collectAgentRun, createSandboxAct, createSurfaceKnowledgeAdapter, defineAgent, defineProfileMaterializationContract, measureOutcome, promptOnlyProfileMaterialization, promptResourceProfileMaterialization, renderProfileMaterializationIssues, sandboxActProfileMaterialization, unimplementedAgentRun, validateProfileMaterialization };
|
package/dist/agent.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-ZV4LXYCJ.js";
|
|
2
2
|
import {
|
|
3
3
|
createSandboxForSpec
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-RYBVU4M3.js";
|
|
5
|
+
import "./chunk-DPEUKJRO.js";
|
|
6
|
+
import "./chunk-IVGYLCFH.js";
|
|
6
7
|
import "./chunk-BZF3KQ6G.js";
|
|
7
8
|
import {
|
|
8
9
|
mapSandboxEvent
|
|
9
10
|
} from "./chunk-FVJ7M3DA.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import
|
|
12
|
-
|
|
11
|
+
import "./chunk-CMYMTRGA.js";
|
|
12
|
+
import {
|
|
13
|
+
ValidationError
|
|
14
|
+
} from "./chunk-YEJR7IXO.js";
|
|
13
15
|
import {
|
|
14
16
|
__require
|
|
15
17
|
} from "./chunk-DGUM43GV.js";
|
|
@@ -504,8 +506,160 @@ function meanComposite(rows) {
|
|
|
504
506
|
return rows.reduce((acc, r) => acc + r.composite, 0) / rows.length;
|
|
505
507
|
}
|
|
506
508
|
|
|
509
|
+
// src/agent/profile-materialization.ts
|
|
510
|
+
var AGENT_PROFILE_MATERIALIZATION_AXES = [
|
|
511
|
+
"identity",
|
|
512
|
+
"name",
|
|
513
|
+
"model",
|
|
514
|
+
"prompt",
|
|
515
|
+
"systemPrompt",
|
|
516
|
+
"instructions",
|
|
517
|
+
"resources",
|
|
518
|
+
"files",
|
|
519
|
+
"resourceInstructions",
|
|
520
|
+
"skills",
|
|
521
|
+
"resourceTools",
|
|
522
|
+
"resourceAgents",
|
|
523
|
+
"commands",
|
|
524
|
+
"tools",
|
|
525
|
+
"permissions",
|
|
526
|
+
"mcp",
|
|
527
|
+
"mcpConnections",
|
|
528
|
+
"connections",
|
|
529
|
+
"subagents",
|
|
530
|
+
"hooks",
|
|
531
|
+
"modes",
|
|
532
|
+
"confidential",
|
|
533
|
+
"metadata",
|
|
534
|
+
"extensions"
|
|
535
|
+
];
|
|
536
|
+
var KNOWN_AXIS_SET = new Set(AGENT_PROFILE_MATERIALIZATION_AXES);
|
|
537
|
+
var AXIS_PARENTS = {
|
|
538
|
+
name: "identity",
|
|
539
|
+
systemPrompt: "prompt",
|
|
540
|
+
instructions: "prompt",
|
|
541
|
+
files: "resources",
|
|
542
|
+
resourceInstructions: "resources",
|
|
543
|
+
skills: "resources",
|
|
544
|
+
resourceTools: "resources",
|
|
545
|
+
resourceAgents: "resources",
|
|
546
|
+
commands: "resources",
|
|
547
|
+
mcpConnections: "mcp"
|
|
548
|
+
};
|
|
549
|
+
var sandboxActProfileMaterialization = defineProfileMaterializationContract({
|
|
550
|
+
name: "createSandboxAct",
|
|
551
|
+
axes: [
|
|
552
|
+
"identity",
|
|
553
|
+
"model",
|
|
554
|
+
"prompt",
|
|
555
|
+
"resources",
|
|
556
|
+
"tools",
|
|
557
|
+
"permissions",
|
|
558
|
+
"mcp",
|
|
559
|
+
"connections",
|
|
560
|
+
"subagents",
|
|
561
|
+
"hooks",
|
|
562
|
+
"modes",
|
|
563
|
+
"confidential",
|
|
564
|
+
"metadata",
|
|
565
|
+
"extensions"
|
|
566
|
+
]
|
|
567
|
+
});
|
|
568
|
+
var promptOnlyProfileMaterialization = defineProfileMaterializationContract({
|
|
569
|
+
name: "prompt-only-message",
|
|
570
|
+
axes: ["prompt"]
|
|
571
|
+
});
|
|
572
|
+
var promptResourceProfileMaterialization = defineProfileMaterializationContract({
|
|
573
|
+
name: "prompt-resource-attachment",
|
|
574
|
+
axes: ["prompt", "resources"]
|
|
575
|
+
});
|
|
576
|
+
function defineProfileMaterializationContract(options) {
|
|
577
|
+
const name = options.name.trim();
|
|
578
|
+
if (!name) {
|
|
579
|
+
throw new ValidationError("defineProfileMaterializationContract: name is required");
|
|
580
|
+
}
|
|
581
|
+
return {
|
|
582
|
+
name,
|
|
583
|
+
axes: normalizeAxes(options.axes, `${name}.axes`)
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function validateProfileMaterialization(options) {
|
|
587
|
+
const changedAxes = normalizeAxes(options.changedAxes, "changedAxes");
|
|
588
|
+
const supported = new Set(
|
|
589
|
+
normalizeAxes(options.contract.axes, `${options.contract.name}.axes`)
|
|
590
|
+
);
|
|
591
|
+
const issues = [];
|
|
592
|
+
for (const axis of changedAxes) {
|
|
593
|
+
if (isAxisSupported(axis, supported)) continue;
|
|
594
|
+
issues.push({
|
|
595
|
+
contract: options.contract.name,
|
|
596
|
+
axis,
|
|
597
|
+
reason: "unsupported-axis",
|
|
598
|
+
supportedAxes: [...supported]
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
return issues;
|
|
602
|
+
}
|
|
603
|
+
function assertProfileMaterialization(options) {
|
|
604
|
+
const issues = validateProfileMaterialization(options);
|
|
605
|
+
if (issues.length === 0) return;
|
|
606
|
+
throw new ValidationError(renderProfileMaterializationIssues(issues, options.context));
|
|
607
|
+
}
|
|
608
|
+
function renderProfileMaterializationIssues(issues, context) {
|
|
609
|
+
if (issues.length === 0) return "";
|
|
610
|
+
const contract = issues[0]?.contract ?? "<unknown>";
|
|
611
|
+
const prefix = context ? `${context}: ` : "";
|
|
612
|
+
const droppedAxes = issues.map((issue) => issue.axis).join(", ");
|
|
613
|
+
const supportedAxes = issues[0]?.supportedAxes.join(", ") || "<none>";
|
|
614
|
+
return [
|
|
615
|
+
`${prefix}profile materialization would drop axis changes on "${contract}": ${droppedAxes}.`,
|
|
616
|
+
`Supported axes: ${supportedAxes}.`,
|
|
617
|
+
"Use a run path that carries those AgentProfile axes, or remove them from the candidate."
|
|
618
|
+
].join("\n");
|
|
619
|
+
}
|
|
620
|
+
function normalizeAxes(axes, label) {
|
|
621
|
+
const out = [];
|
|
622
|
+
const seen = /* @__PURE__ */ new Set();
|
|
623
|
+
for (const raw of axes) {
|
|
624
|
+
const axis = normalizeAxis(raw, label);
|
|
625
|
+
if (seen.has(axis)) continue;
|
|
626
|
+
seen.add(axis);
|
|
627
|
+
out.push(axis);
|
|
628
|
+
}
|
|
629
|
+
return out;
|
|
630
|
+
}
|
|
631
|
+
function normalizeAxis(raw, label) {
|
|
632
|
+
if (typeof raw !== "string") {
|
|
633
|
+
throw new ValidationError(`${label}: profile axis must be a string`);
|
|
634
|
+
}
|
|
635
|
+
const axis = raw.trim();
|
|
636
|
+
if (!axis) {
|
|
637
|
+
throw new ValidationError(`${label}: profile axis must be non-empty`);
|
|
638
|
+
}
|
|
639
|
+
if (!KNOWN_AXIS_SET.has(axis) && !axis.startsWith("custom:")) {
|
|
640
|
+
throw new ValidationError(
|
|
641
|
+
`${label}: unknown profile axis "${axis}". Use a known axis or custom:<name>.`
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
return axis;
|
|
645
|
+
}
|
|
646
|
+
function isAxisSupported(axis, supported) {
|
|
647
|
+
if (supported.has(axis)) return true;
|
|
648
|
+
let parent = AXIS_PARENTS[axis];
|
|
649
|
+
while (parent) {
|
|
650
|
+
if (supported.has(parent)) return true;
|
|
651
|
+
parent = AXIS_PARENTS[parent];
|
|
652
|
+
}
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
|
|
507
656
|
// src/agent/sandbox-act.ts
|
|
508
657
|
function createSandboxAct(options) {
|
|
658
|
+
assertProfileMaterialization({
|
|
659
|
+
contract: sandboxActProfileMaterialization,
|
|
660
|
+
changedAxes: options.requiredProfileAxes ?? [],
|
|
661
|
+
context: "createSandboxAct"
|
|
662
|
+
});
|
|
509
663
|
const mapEvent = options.mapEvent ?? mapSandboxEvent;
|
|
510
664
|
return (persona, ctx) => {
|
|
511
665
|
const profile = applyComposeOverrides(options.baseProfile, options.compose?.(persona));
|
|
@@ -561,16 +715,24 @@ function applyComposeOverrides(base, overrides) {
|
|
|
561
715
|
};
|
|
562
716
|
}
|
|
563
717
|
export {
|
|
718
|
+
AGENT_PROFILE_MATERIALIZATION_AXES,
|
|
564
719
|
AgentManifestError,
|
|
720
|
+
assertProfileMaterialization,
|
|
565
721
|
collectAgentRun,
|
|
566
722
|
createSandboxAct,
|
|
567
723
|
createSurfaceImprovementAdapter,
|
|
568
724
|
createSurfaceKnowledgeAdapter,
|
|
569
725
|
defineAgent,
|
|
726
|
+
defineProfileMaterializationContract,
|
|
570
727
|
measureOutcome,
|
|
728
|
+
promptOnlyProfileMaterialization,
|
|
729
|
+
promptResourceProfileMaterialization,
|
|
730
|
+
renderProfileMaterializationIssues,
|
|
571
731
|
renderSurfaceIssues,
|
|
572
732
|
resolveSubjectPath,
|
|
733
|
+
sandboxActProfileMaterialization,
|
|
573
734
|
unimplementedAgentRun,
|
|
735
|
+
validateProfileMaterialization,
|
|
574
736
|
validateSurfaces
|
|
575
737
|
};
|
|
576
738
|
//# sourceMappingURL=agent.js.map
|