@tangle-network/agent-runtime 0.92.1 → 0.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -4
- package/dist/candidate-execution/index.d.ts +48 -4
- package/dist/candidate-execution/index.js +6 -2
- package/dist/{chunk-A62TP7SK.js → chunk-26WCEARH.js} +295 -40
- package/dist/chunk-26WCEARH.js.map +1 -0
- package/dist/{chunk-PH65PR4F.js → chunk-3VU2OWOY.js} +106 -2
- package/dist/chunk-3VU2OWOY.js.map +1 -0
- package/dist/{chunk-4FPXIMSI.js → chunk-VMHKMNEU.js} +38 -9
- package/dist/chunk-VMHKMNEU.js.map +1 -0
- package/dist/{improve-CUVCq7xg.d.ts → improve-DDhQaaJT.d.ts} +17 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +6 -8
- package/dist/intelligence.js +23 -131
- package/dist/intelligence.js.map +1 -1
- package/dist/{prepare-Z08a4heC.d.ts → prepare-DiVGKcwS.d.ts} +7 -2
- package/package.json +4 -4
- package/skills/build-with-agent-runtime/SKILL.md +2 -1
- package/dist/chunk-4FPXIMSI.js.map +0 -1
- package/dist/chunk-A62TP7SK.js.map +0 -1
- package/dist/chunk-PH65PR4F.js.map +0 -1
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentProfile, AgentCandidateBundle, Sha256Digest, AgentProfileDiff, AgentProfileMcpServer } from '@tangle-network/agent-interface';
|
|
2
2
|
import { g as LoopTraceEvent, b as RuntimeStreamEvent } from './types-B00NtbCs.js';
|
|
3
3
|
import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-C9go6tXj.js';
|
|
4
4
|
import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
|
|
5
5
|
import { Scenario, SelfImproveResult } from '@tangle-network/agent-eval/contract';
|
|
6
6
|
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
|
|
7
|
-
import { A as AgentCandidateTaskExecution, a as AgentCandidateExecutionPorts, P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, b as AgentCandidateRunFinalization } from './prepare-
|
|
8
|
-
import { I as ImproveSurface, a as ImproveOptions, b as ImproveResult } from './improve-
|
|
7
|
+
import { A as AgentCandidateTaskExecution, a as AgentCandidateExecutionPorts, P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, b as AgentCandidateRunFinalization, c as AgentCandidateBundleInput } from './prepare-DiVGKcwS.js';
|
|
8
|
+
import { I as ImproveSurface, a as ImproveOptions, b as ImproveResult } from './improve-DDhQaaJT.js';
|
|
9
9
|
import '@tangle-network/agent-eval';
|
|
10
10
|
import '@tangle-network/sandbox';
|
|
11
11
|
import './local-harness-dcD5WTTr.js';
|
|
@@ -126,8 +126,6 @@ interface EffortOverridesCompiled {
|
|
|
126
126
|
*/
|
|
127
127
|
declare function compileEffort(settings: EffortSettings): EffortOverridesCompiled;
|
|
128
128
|
|
|
129
|
-
type AgentCandidateBundleInput = Omit<AgentCandidateBundle, 'digest'>;
|
|
130
|
-
|
|
131
129
|
type AgentImprovementEvaluation<TScenario extends Scenario, TArtifact> = Pick<SelfImproveResult<TScenario, TArtifact>, 'baseline' | 'winner' | 'lift' | 'diff' | 'provenance' | 'gateDecision' | 'generationsExplored' | 'durationMs' | 'totalCostUsd' | 'insight' | 'power'>;
|
|
132
130
|
interface AgentImprovementProposal<TScenario extends Scenario = Scenario, TArtifact = unknown> {
|
|
133
131
|
schemaVersion: 1;
|
|
@@ -173,13 +171,13 @@ interface ProposeAgentImprovementOptions<TScenario extends Scenario, TArtifact>
|
|
|
173
171
|
improvement: ImproveOptions<TScenario, TArtifact>;
|
|
174
172
|
/**
|
|
175
173
|
* Optional environment adapter that freezes an executable bundle after the
|
|
176
|
-
* measured comparison recommends the candidate.
|
|
177
|
-
*
|
|
174
|
+
* measured comparison recommends the candidate. Return the sealed output of
|
|
175
|
+
* `buildAgentCandidateBundle` directly, or a low-level digest-free input.
|
|
178
176
|
*/
|
|
179
177
|
buildCandidate?: (input: {
|
|
180
178
|
analysis: RunAnalystLoopResult;
|
|
181
179
|
improvement: ImproveResult<TScenario, TArtifact>;
|
|
182
|
-
}) => AgentCandidateBundleInput | Promise<AgentCandidateBundleInput>;
|
|
180
|
+
}) => AgentCandidateBundleInput | AgentCandidateBundle | Promise<AgentCandidateBundleInput | AgentCandidateBundle>;
|
|
183
181
|
now?: () => Date;
|
|
184
182
|
}
|
|
185
183
|
interface ProposeAgentImprovementResult<TScenario extends Scenario, TArtifact> {
|
package/dist/intelligence.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
improve
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VMHKMNEU.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
assertCandidateProfileBinding,
|
|
6
6
|
canonicalCandidateDigest,
|
|
7
7
|
canonicalCandidateDocument,
|
|
8
8
|
executePreparedAgentCandidate,
|
|
9
9
|
immutableCandidateValue,
|
|
10
10
|
omitTopLevelDigest,
|
|
11
|
+
parseExactAgentProfile,
|
|
11
12
|
prepareAgentCandidateExecution,
|
|
13
|
+
sealAgentCandidateBundle,
|
|
12
14
|
verifyAgentCandidateBundle
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-26WCEARH.js";
|
|
14
16
|
import "./chunk-FDJ7AHXG.js";
|
|
15
17
|
import {
|
|
16
18
|
runAnalystLoop
|
|
@@ -414,24 +416,13 @@ function isJsonSchema(v) {
|
|
|
414
416
|
|
|
415
417
|
// src/intelligence/improvement-cycle.ts
|
|
416
418
|
import { assertNoJudgeVerdict } from "@tangle-network/agent-eval/analyst";
|
|
417
|
-
import { agentCandidateBundleSchema as agentCandidateBundleSchema2, agentProfileSchema } from "@tangle-network/agent-interface";
|
|
418
|
-
|
|
419
|
-
// src/candidate-execution/bundle.ts
|
|
420
419
|
import { agentCandidateBundleSchema } from "@tangle-network/agent-interface";
|
|
421
|
-
function sealAgentCandidateBundle(input) {
|
|
422
|
-
const digest = canonicalCandidateDigest(input);
|
|
423
|
-
const parsed = agentCandidateBundleSchema.parse({ ...input, digest });
|
|
424
|
-
const parsedDigest = canonicalCandidateDigest(omitTopLevelDigest(parsed));
|
|
425
|
-
if (parsedDigest !== digest) {
|
|
426
|
-
throw new Error("candidate bundle changed while validating its canonical wire shape");
|
|
427
|
-
}
|
|
428
|
-
return immutableCandidateValue(parsed);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// src/intelligence/improvement-cycle.ts
|
|
432
420
|
async function proposeAgentImprovement(options) {
|
|
433
|
-
|
|
434
|
-
|
|
421
|
+
const writeBackSurface = options.improvement.skills?.writeBack ? "skill" : options.improvement.memory?.writeBack ? "memory" : null;
|
|
422
|
+
if (writeBackSurface) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
`proposeAgentImprovement cannot write ${writeBackSurface} before human approval`
|
|
425
|
+
);
|
|
435
426
|
}
|
|
436
427
|
const analysis = await runAnalystLoop({
|
|
437
428
|
...options.analysis,
|
|
@@ -442,7 +433,7 @@ async function proposeAgentImprovement(options) {
|
|
|
442
433
|
"proposeAgentImprovement findings"
|
|
443
434
|
);
|
|
444
435
|
const improvement = await improve(options.profile, [...findings], options.improvement);
|
|
445
|
-
const candidateBundle = improvement.shipped && options.buildCandidate ?
|
|
436
|
+
const candidateBundle = improvement.shipped && options.buildCandidate ? sealBuiltCandidate(await options.buildCandidate({ analysis, improvement })) : void 0;
|
|
446
437
|
if (candidateBundle) assertCandidateProfileBinding(improvement.profile, candidateBundle.profile);
|
|
447
438
|
const surface = options.improvement.surface ?? "prompt";
|
|
448
439
|
const evaluation = canonicalJsonValue(improvementEvaluation(improvement.raw));
|
|
@@ -530,14 +521,17 @@ function verifyAgentImprovementProposal(input) {
|
|
|
530
521
|
throw new Error("invalid agent improvement proposal");
|
|
531
522
|
}
|
|
532
523
|
const proposal = input;
|
|
533
|
-
const parsedProfile = parseExactAgentProfile(
|
|
524
|
+
const parsedProfile = parseExactAgentProfile(
|
|
525
|
+
proposal.candidateProfile,
|
|
526
|
+
"proposal candidate profile"
|
|
527
|
+
);
|
|
534
528
|
if (proposal.candidateProfileHash !== canonicalCandidateDigest(parsedProfile)) {
|
|
535
529
|
throw new Error("proposal candidateProfileHash does not match candidateProfile");
|
|
536
530
|
}
|
|
537
531
|
if (!Array.isArray(proposal.findings)) throw new Error("proposal findings must be an array");
|
|
538
532
|
if (!isSha256Digest(proposal.digest)) throw new Error("proposal digest is invalid");
|
|
539
533
|
if (proposal.candidateBundle) {
|
|
540
|
-
const parsedBundle =
|
|
534
|
+
const parsedBundle = agentCandidateBundleSchema.parse(proposal.candidateBundle);
|
|
541
535
|
const sealed = sealAgentCandidateBundle(omitTopLevelDigest(parsedBundle));
|
|
542
536
|
if (sealed.digest !== parsedBundle.digest)
|
|
543
537
|
throw new Error("proposal candidate bundle digest is invalid");
|
|
@@ -548,116 +542,14 @@ function verifyAgentImprovementProposal(input) {
|
|
|
548
542
|
throw new Error("agent improvement proposal digest does not match");
|
|
549
543
|
return immutableCandidateValue(proposal);
|
|
550
544
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
)
|
|
556
|
-
throw new Error("
|
|
557
|
-
}
|
|
558
|
-
return parsed;
|
|
559
|
-
}
|
|
560
|
-
function assertCandidateProfileBinding(measuredInput, bundled) {
|
|
561
|
-
const measured = parseExactAgentProfile(measuredInput);
|
|
562
|
-
if (measured.connections || measured.metadata || measured.extensions) {
|
|
563
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
564
|
-
}
|
|
565
|
-
const normalized = candidateProfileAsAgentProfile(bundled);
|
|
566
|
-
if (canonicalCandidateDigest(measured) !== canonicalCandidateDigest(normalized)) {
|
|
567
|
-
throw new Error("proposal candidateProfile does not match candidateBundle.profile");
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
function candidateProfileAsAgentProfile(candidate) {
|
|
571
|
-
const value = candidate;
|
|
572
|
-
const output = {};
|
|
573
|
-
for (const key of [
|
|
574
|
-
"name",
|
|
575
|
-
"description",
|
|
576
|
-
"version",
|
|
577
|
-
"tags",
|
|
578
|
-
"prompt",
|
|
579
|
-
"harness",
|
|
580
|
-
"permissions",
|
|
581
|
-
"tools",
|
|
582
|
-
"confidential"
|
|
583
|
-
]) {
|
|
584
|
-
if (value[key] !== void 0) output[key] = value[key];
|
|
585
|
-
}
|
|
586
|
-
if (candidate.model) output.model = { ...candidate.model };
|
|
587
|
-
if (candidate.mcp) {
|
|
588
|
-
output.mcp = Object.fromEntries(
|
|
589
|
-
Object.entries(candidate.mcp).map(([name, server]) => [
|
|
590
|
-
name,
|
|
591
|
-
{
|
|
592
|
-
...server,
|
|
593
|
-
...server.args ? { args: server.args.map(publicValue) } : {},
|
|
594
|
-
...server.env ? { env: mapPublicValues(server.env) } : {}
|
|
595
|
-
}
|
|
596
|
-
])
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
if (candidate.subagents) output.subagents = mapRecord(candidate.subagents);
|
|
600
|
-
if (candidate.modes) output.modes = mapRecord(candidate.modes);
|
|
601
|
-
if (candidate.hooks) {
|
|
602
|
-
output.hooks = Object.fromEntries(
|
|
603
|
-
Object.entries(candidate.hooks).map(([event, hooks]) => [
|
|
604
|
-
event,
|
|
605
|
-
hooks.map((hook) => ({
|
|
606
|
-
...hook,
|
|
607
|
-
command: [hook.executable, ...(hook.args ?? []).map(publicValue)].map(shellQuote).join(" "),
|
|
608
|
-
...hook.env ? { env: mapPublicValues(hook.env) } : {}
|
|
609
|
-
}))
|
|
610
|
-
])
|
|
611
|
-
);
|
|
612
|
-
}
|
|
613
|
-
if (candidate.resources) {
|
|
614
|
-
if (candidate.resources.failOnError !== true) {
|
|
615
|
-
throw new Error("proposal candidate profile contains fields unsupported by sealed candidates");
|
|
616
|
-
}
|
|
617
|
-
output.resources = {
|
|
618
|
-
failOnError: true,
|
|
619
|
-
...candidate.resources.files ? {
|
|
620
|
-
files: candidate.resources.files.map((file) => ({
|
|
621
|
-
...file,
|
|
622
|
-
resource: publicResource(file.resource)
|
|
623
|
-
}))
|
|
624
|
-
} : {},
|
|
625
|
-
...candidate.resources.tools ? { tools: candidate.resources.tools.map(publicResource) } : {},
|
|
626
|
-
...candidate.resources.skills ? { skills: candidate.resources.skills.map(publicResource) } : {},
|
|
627
|
-
...candidate.resources.agents ? { agents: candidate.resources.agents.map(publicResource) } : {},
|
|
628
|
-
...candidate.resources.commands ? { commands: candidate.resources.commands.map(publicResource) } : {},
|
|
629
|
-
...candidate.resources.instructions !== void 0 ? {
|
|
630
|
-
instructions: typeof candidate.resources.instructions === "string" ? candidate.resources.instructions : publicResource(candidate.resources.instructions)
|
|
631
|
-
} : {}
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
return output;
|
|
635
|
-
}
|
|
636
|
-
function publicResource(resource) {
|
|
637
|
-
if (resource.kind === "inline") {
|
|
638
|
-
return { kind: "inline", name: resource.name, content: resource.content };
|
|
545
|
+
function sealBuiltCandidate(input) {
|
|
546
|
+
if (!("digest" in input)) return sealAgentCandidateBundle(input);
|
|
547
|
+
const parsed = agentCandidateBundleSchema.parse(input);
|
|
548
|
+
const sealed = sealAgentCandidateBundle(omitTopLevelDigest(parsed));
|
|
549
|
+
if (sealed.digest !== parsed.digest) {
|
|
550
|
+
throw new Error("built candidate bundle digest is invalid");
|
|
639
551
|
}
|
|
640
|
-
return
|
|
641
|
-
kind: "github",
|
|
642
|
-
repository: `${resource.repository.owner}/${resource.repository.repo}`,
|
|
643
|
-
path: resource.path,
|
|
644
|
-
ref: resource.commit,
|
|
645
|
-
...resource.name ? { name: resource.name } : {}
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
function publicValue(value) {
|
|
649
|
-
return value.value;
|
|
650
|
-
}
|
|
651
|
-
function mapPublicValues(values) {
|
|
652
|
-
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, publicValue(value)]));
|
|
653
|
-
}
|
|
654
|
-
function mapRecord(values) {
|
|
655
|
-
return Object.fromEntries(
|
|
656
|
-
Object.entries(values).map(([key, value]) => [key, { ...value }])
|
|
657
|
-
);
|
|
658
|
-
}
|
|
659
|
-
function shellQuote(value) {
|
|
660
|
-
return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
552
|
+
return sealed;
|
|
661
553
|
}
|
|
662
554
|
function verifyAgentImprovementReview(input) {
|
|
663
555
|
if (!isRecord(input) || input.kind !== "agent-improvement-review" || input.schemaVersion !== 1) {
|