@tangle-network/agent-runtime 0.98.0 → 0.100.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.
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  captureAgentCandidateWorkspace,
6
6
  sealAgentCandidateBundle
7
- } from "./chunk-BLQIYRVR.js";
7
+ } from "./chunk-BXZ7GPL4.js";
8
8
  import {
9
9
  createAgentImprovementActivationResult
10
- } from "./chunk-3K2TXWF4.js";
10
+ } from "./chunk-VOPHC4LB.js";
11
11
  import {
12
12
  canonicalCandidateBytes,
13
13
  embeddedCandidateArtifact,
14
14
  omitTopLevelDigest,
15
15
  persistCandidateOutputArtifact
16
- } from "./chunk-YOLKCWRV.js";
16
+ } from "./chunk-HGSHPVJ6.js";
17
17
  import {
18
18
  supervise
19
19
  } from "./chunk-UQ6PNNXM.js";
@@ -471,4 +471,4 @@ export {
471
471
  runKnowledgeImprovementJob,
472
472
  buildKnowledgeImprovementExperimentBundles
473
473
  };
474
- //# sourceMappingURL=chunk-WUNFYMEV.js.map
474
+ //# sourceMappingURL=chunk-LV6WCT43.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sealAgentCandidateBundle
3
- } from "./chunk-BLQIYRVR.js";
3
+ } from "./chunk-BXZ7GPL4.js";
4
4
  import {
5
5
  RecoveryAgentCandidateTraceStore,
6
6
  applyExactAgentProfileDiff,
@@ -36,7 +36,7 @@ import {
36
36
  terminalRecord,
37
37
  usdToNanos,
38
38
  withinCandidateCleanupDeadline
39
- } from "./chunk-YOLKCWRV.js";
39
+ } from "./chunk-HGSHPVJ6.js";
40
40
 
41
41
  // src/candidate-execution/builder.ts
42
42
  import { verifyCodeSurface } from "@tangle-network/agent-eval/campaign";
@@ -1007,4 +1007,4 @@ export {
1007
1007
  createProtectedAgentCandidateModelPort,
1008
1008
  recoverExpiredAgentCandidateExecution
1009
1009
  };
1010
- //# sourceMappingURL=chunk-6XKPVJAZ.js.map
1010
+ //# sourceMappingURL=chunk-U4PRAATQ.js.map
@@ -9,12 +9,14 @@ import {
9
9
  executePreparedAgentCandidate,
10
10
  immutableCandidateValue,
11
11
  omitTopLevelDigest,
12
+ omitUndefinedObjectFields,
12
13
  parseAgentCandidateProfileActivation,
14
+ parseExactAgentProfile,
13
15
  prepareAgentCandidateExecution,
14
16
  verifiedResourceTextByDigest,
15
17
  verifyAgentCandidateBundle,
16
18
  verifyCanonicalCandidateDocument
17
- } from "./chunk-YOLKCWRV.js";
19
+ } from "./chunk-HGSHPVJ6.js";
18
20
  import {
19
21
  assertModelAllowed,
20
22
  harnessInvocation,
@@ -1340,6 +1342,11 @@ async function improve(profile, findings, opts) {
1340
1342
  }
1341
1343
 
1342
1344
  // src/intelligence/improvement-surfaces.ts
1345
+ import {
1346
+ agentProfileDiffSchema,
1347
+ agentProfileSchema as agentProfileSchema2,
1348
+ defineAgentProfileDiff
1349
+ } from "@tangle-network/agent-interface";
1343
1350
  var changedSurfaceOrder = [
1344
1351
  "prompt",
1345
1352
  "skills",
@@ -1352,6 +1359,14 @@ var changedSurfaceOrder = [
1352
1359
  "code",
1353
1360
  "knowledge"
1354
1361
  ];
1362
+ var AGENT_IMPROVEMENT_PROFILE_SURFACES = [
1363
+ "prompt",
1364
+ "skills",
1365
+ "tools",
1366
+ "mcp",
1367
+ "hooks",
1368
+ "subagents"
1369
+ ];
1355
1370
  function deriveChangedSurfaces(baselineBundle, candidateBundle) {
1356
1371
  if (baselineBundle.knowledge || candidateBundle.knowledge) {
1357
1372
  assertKnowledgeCandidatePair(baselineBundle, candidateBundle);
@@ -1395,6 +1410,145 @@ function agentImprovementTargetDigest(experiment, arm, surface) {
1395
1410
  function agentImprovementTargetInput(bundle, surface) {
1396
1411
  return improvementSurfaceValues(bundle)[surface];
1397
1412
  }
1413
+ function isAgentImprovementProfileSurface(surface) {
1414
+ return AGENT_IMPROVEMENT_PROFILE_SURFACES.includes(surface);
1415
+ }
1416
+ function agentImprovementProfileSurfaceInput(profile, surface) {
1417
+ const parsed = parseExactAgentProfile(
1418
+ omitUndefinedObjectFields(profile, "agent improvement profile"),
1419
+ "agent improvement profile"
1420
+ );
1421
+ return immutableCandidateValue(profileSurfaceInput(parsed, surface));
1422
+ }
1423
+ function profileSurfaceInput(profile, surface) {
1424
+ switch (surface) {
1425
+ case "prompt":
1426
+ return { prompt: profile.prompt ?? null };
1427
+ case "skills":
1428
+ return profile.resources?.skills ?? null;
1429
+ case "tools":
1430
+ return {
1431
+ tools: profile.tools ?? null,
1432
+ resources: profile.resources?.tools ?? null
1433
+ };
1434
+ case "mcp":
1435
+ return profile.mcp ?? null;
1436
+ case "hooks":
1437
+ return profile.hooks ?? null;
1438
+ case "subagents":
1439
+ return {
1440
+ subagents: profile.subagents ?? null,
1441
+ resources: profile.resources?.agents ?? null
1442
+ };
1443
+ }
1444
+ }
1445
+ function agentImprovementProfileSurfaceDigest(profile, surface) {
1446
+ return canonicalCandidateDigest(agentImprovementProfileSurfaceInput(profile, surface));
1447
+ }
1448
+ function agentImprovementTargetProfileDiffs(target, options) {
1449
+ const { remove, set } = improvementSurfaceReplacement(target);
1450
+ const common = {
1451
+ kind: "agent-profile-diff",
1452
+ ...options.source ? { source: options.source } : {},
1453
+ metadata: {
1454
+ ...options.metadata ?? {},
1455
+ surface: target.surface
1456
+ }
1457
+ };
1458
+ const reset = agentProfileDiffSchema.parse(
1459
+ defineAgentProfileDiff({
1460
+ ...common,
1461
+ id: `${options.id}:${target.surface}:reset`,
1462
+ title: `Replace active ${target.surface}`,
1463
+ remove
1464
+ })
1465
+ );
1466
+ if (!set) return [reset];
1467
+ const replacement = agentProfileDiffSchema.parse(
1468
+ defineAgentProfileDiff({
1469
+ ...common,
1470
+ id: `${options.id}:${target.surface}:set`,
1471
+ title: `Activate measured ${target.surface}`,
1472
+ set
1473
+ })
1474
+ );
1475
+ return [reset, replacement];
1476
+ }
1477
+ function improvementSurfaceReplacement(target) {
1478
+ const value = target.desiredInput;
1479
+ switch (target.surface) {
1480
+ case "prompt": {
1481
+ const prompt = exactObject(value, ["prompt"], "prompt activation input").prompt;
1482
+ assertDefined(prompt, "prompt activation input.prompt");
1483
+ return {
1484
+ remove: { prompt: true },
1485
+ ...prompt === null ? {} : { set: parseProfileSet({ prompt }) }
1486
+ };
1487
+ }
1488
+ case "skills":
1489
+ assertDefined(value, "skills activation input");
1490
+ return {
1491
+ remove: { resources: { skills: true } },
1492
+ ...value === null ? {} : { set: parseProfileSet({ resources: { skills: value } }) }
1493
+ };
1494
+ case "tools": {
1495
+ const parsed = exactObject(value, ["tools", "resources"], "tools activation input");
1496
+ assertDefined(parsed.tools, "tools activation input.tools");
1497
+ assertDefined(parsed.resources, "tools activation input.resources");
1498
+ const set = {
1499
+ ...parsed.tools === null ? {} : { tools: parsed.tools },
1500
+ ...parsed.resources === null ? {} : { resources: { tools: parsed.resources } }
1501
+ };
1502
+ return {
1503
+ remove: { tools: true, resources: { tools: true } },
1504
+ ...Object.keys(set).length === 0 ? {} : { set: parseProfileSet(set) }
1505
+ };
1506
+ }
1507
+ case "mcp":
1508
+ assertDefined(value, "mcp activation input");
1509
+ return {
1510
+ remove: { mcp: true },
1511
+ ...value === null ? {} : { set: parseProfileSet({ mcp: value }) }
1512
+ };
1513
+ case "hooks":
1514
+ assertDefined(value, "hooks activation input");
1515
+ return {
1516
+ remove: { hooks: true },
1517
+ ...value === null ? {} : { set: parseProfileSet({ hooks: value }) }
1518
+ };
1519
+ case "subagents": {
1520
+ const parsed = exactObject(value, ["subagents", "resources"], "subagents activation input");
1521
+ assertDefined(parsed.subagents, "subagents activation input.subagents");
1522
+ assertDefined(parsed.resources, "subagents activation input.resources");
1523
+ const set = {
1524
+ ...parsed.subagents === null ? {} : { subagents: parsed.subagents },
1525
+ ...parsed.resources === null ? {} : { resources: { agents: parsed.resources } }
1526
+ };
1527
+ return {
1528
+ remove: { subagents: true, resources: { agents: true } },
1529
+ ...Object.keys(set).length === 0 ? {} : { set: parseProfileSet(set) }
1530
+ };
1531
+ }
1532
+ }
1533
+ }
1534
+ function assertDefined(value, label) {
1535
+ if (value === void 0) throw new Error(`${label} must not be undefined`);
1536
+ }
1537
+ function exactObject(value, keys, label) {
1538
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1539
+ throw new Error(`${label} must be an object`);
1540
+ }
1541
+ const record = value;
1542
+ const actual = Object.keys(record).sort();
1543
+ const expected = [...keys].sort();
1544
+ if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index])) {
1545
+ throw new Error(`${label} must contain exactly: ${expected.join(", ")}`);
1546
+ }
1547
+ return record;
1548
+ }
1549
+ function parseProfileSet(value) {
1550
+ return agentProfileSchema2.parse(value);
1551
+ }
1398
1552
  function assertKnowledgeCandidatePair(baselineBundle, candidateBundle) {
1399
1553
  const baseline = baselineBundle.knowledge;
1400
1554
  const candidate = candidateBundle.knowledge;
@@ -1425,20 +1579,12 @@ function assertCodeCandidatePair(baselineBundle, candidateBundle) {
1425
1579
  function improvementSurfaceValues(bundle) {
1426
1580
  const profile = agentCandidateProfileAsAgentProfile(bundle.profile);
1427
1581
  return {
1428
- prompt: {
1429
- prompt: profile.prompt ?? null
1430
- },
1431
- skills: profile.resources?.skills ?? null,
1432
- tools: {
1433
- tools: profile.tools ?? null,
1434
- resources: profile.resources?.tools ?? null
1435
- },
1436
- mcp: profile.mcp ?? null,
1437
- hooks: profile.hooks ?? null,
1438
- subagents: {
1439
- subagents: profile.subagents ?? null,
1440
- resources: profile.resources?.agents ?? null
1441
- },
1582
+ prompt: agentImprovementProfileSurfaceInput(profile, "prompt"),
1583
+ skills: agentImprovementProfileSurfaceInput(profile, "skills"),
1584
+ tools: agentImprovementProfileSurfaceInput(profile, "tools"),
1585
+ mcp: agentImprovementProfileSurfaceInput(profile, "mcp"),
1586
+ hooks: agentImprovementProfileSurfaceInput(profile, "hooks"),
1587
+ subagents: agentImprovementProfileSurfaceInput(profile, "subagents"),
1442
1588
  "agent-profile": { profile: opaqueProfileSlice(profile), execution: bundle.execution },
1443
1589
  memory: {
1444
1590
  instructions: profile.resources?.instructions ?? null,
@@ -2056,7 +2202,12 @@ export {
2056
2202
  improvementDriver,
2057
2203
  rawTraceDistiller,
2058
2204
  improve,
2205
+ AGENT_IMPROVEMENT_PROFILE_SURFACES,
2059
2206
  buildAgentImprovementActivationTargets,
2207
+ isAgentImprovementProfileSurface,
2208
+ agentImprovementProfileSurfaceInput,
2209
+ agentImprovementProfileSurfaceDigest,
2210
+ agentImprovementTargetProfileDiffs,
2060
2211
  AgentCandidateExperimentCellExecutionError,
2061
2212
  runAgentCandidateExperiment,
2062
2213
  executeAgentCandidateExperimentCell,
@@ -2073,4 +2224,4 @@ export {
2073
2224
  verifyAgentImprovementActivationResult,
2074
2225
  executeAgentImprovementActivation
2075
2226
  };
2076
- //# sourceMappingURL=chunk-3K2TXWF4.js.map
2227
+ //# sourceMappingURL=chunk-VOPHC4LB.js.map