@tangle-network/agent-runtime 0.95.0 → 0.97.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.
Files changed (86) hide show
  1. package/README.md +64 -15
  2. package/dist/activation-B0ZD7nfX.d.ts +63 -0
  3. package/dist/agent.d.ts +5 -169
  4. package/dist/agent.js +8 -229
  5. package/dist/agent.js.map +1 -1
  6. package/dist/analyst-loop.d.ts +6 -9
  7. package/dist/analyst-loop.js +1 -2
  8. package/dist/candidate-execution/index.js +6 -7
  9. package/dist/chunk-3XKSBI2U.js +474 -0
  10. package/dist/chunk-3XKSBI2U.js.map +1 -0
  11. package/dist/{chunk-6YBA64Z2.js → chunk-6XKPVJAZ.js} +5 -18
  12. package/dist/chunk-6XKPVJAZ.js.map +1 -0
  13. package/dist/{chunk-MKGRLDWB.js → chunk-BLQIYRVR.js} +17 -2
  14. package/dist/chunk-BLQIYRVR.js.map +1 -0
  15. package/dist/{chunk-QDSOD7RC.js → chunk-FD2MBMOH.js} +13 -101
  16. package/dist/chunk-FD2MBMOH.js.map +1 -0
  17. package/dist/{chunk-YLUOTX6U.js → chunk-FXF2OL34.js} +7 -7
  18. package/dist/{chunk-EP6RVHMX.js → chunk-HZDEXTSL.js} +848 -2
  19. package/dist/chunk-HZDEXTSL.js.map +1 -0
  20. package/dist/chunk-PSOCBNM3.js +2069 -0
  21. package/dist/chunk-PSOCBNM3.js.map +1 -0
  22. package/dist/{chunk-BPGXIKK7.js → chunk-SGQ4YIQW.js} +4 -4
  23. package/dist/{chunk-IADLKE7I.js → chunk-UQ6PNNXM.js} +5 -7
  24. package/dist/{chunk-IADLKE7I.js.map → chunk-UQ6PNNXM.js.map} +1 -1
  25. package/dist/{chunk-Z5I642SY.js → chunk-WYC2XJF2.js} +2 -2
  26. package/dist/{chunk-ZEYAT33L.js → chunk-Y3SRWZMP.js} +2 -2
  27. package/dist/{chunk-WTZ37EQY.js → chunk-YOLKCWRV.js} +197 -90
  28. package/dist/chunk-YOLKCWRV.js.map +1 -0
  29. package/dist/conversation.js +0 -1
  30. package/dist/environment-provider.js +0 -1
  31. package/dist/{agentic-generator-hCaQRAes.d.ts → improve-g75IE2Cx.d.ts} +152 -3
  32. package/dist/{improvement-adapter-BieWeK5J.d.ts → improvement-adapter-HAZz-7vK.d.ts} +8 -31
  33. package/dist/index.d.ts +41 -11
  34. package/dist/index.js +180 -51
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +16 -9
  37. package/dist/intelligence.js +13 -8
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +30 -13
  40. package/dist/knowledge.js +11 -10
  41. package/dist/{loop-runner-bin-BIQldFS8.d.ts → loop-runner-bin-Cn1N2rRo.d.ts} +1 -1
  42. package/dist/loop-runner-bin.d.ts +2 -2
  43. package/dist/loop-runner-bin.js +6 -8
  44. package/dist/loops.d.ts +1 -1
  45. package/dist/loops.js +4 -6
  46. package/dist/mcp/bin.js +3 -5
  47. package/dist/mcp/bin.js.map +1 -1
  48. package/dist/mcp/index.js +10 -12
  49. package/dist/mcp/index.js.map +1 -1
  50. package/dist/platform.js +0 -2
  51. package/dist/platform.js.map +1 -1
  52. package/dist/primeintellect/index.js +0 -1
  53. package/dist/primeintellect/index.js.map +1 -1
  54. package/dist/profiles.js +0 -1
  55. package/dist/profiles.js.map +1 -1
  56. package/dist/{types-BC3bZpH0.d.ts → types-CmYCMbFT.d.ts} +12 -54
  57. package/package.json +8 -13
  58. package/skills/build-with-agent-runtime/SKILL.md +122 -213
  59. package/dist/chunk-6O73TRHW.js +0 -142
  60. package/dist/chunk-6O73TRHW.js.map +0 -1
  61. package/dist/chunk-6YBA64Z2.js.map +0 -1
  62. package/dist/chunk-AP7CPGMZ.js +0 -334
  63. package/dist/chunk-AP7CPGMZ.js.map +0 -1
  64. package/dist/chunk-DGUM43GV.js +0 -11
  65. package/dist/chunk-DGUM43GV.js.map +0 -1
  66. package/dist/chunk-DHCHL6OG.js +0 -625
  67. package/dist/chunk-DHCHL6OG.js.map +0 -1
  68. package/dist/chunk-EP6RVHMX.js.map +0 -1
  69. package/dist/chunk-G55QE4IQ.js +0 -1137
  70. package/dist/chunk-G55QE4IQ.js.map +0 -1
  71. package/dist/chunk-ISTDY47H.js +0 -849
  72. package/dist/chunk-ISTDY47H.js.map +0 -1
  73. package/dist/chunk-MKGRLDWB.js.map +0 -1
  74. package/dist/chunk-QDSOD7RC.js.map +0 -1
  75. package/dist/chunk-WTZ37EQY.js.map +0 -1
  76. package/dist/generator-YkAQrOoD.d.ts +0 -382
  77. package/dist/improve-B-UYaEH5.d.ts +0 -172
  78. package/dist/lifecycle.d.ts +0 -870
  79. package/dist/lifecycle.js +0 -981
  80. package/dist/lifecycle.js.map +0 -1
  81. package/dist/mcp-serve-verifier-Bs_n0xPc.d.ts +0 -34
  82. package/skills/agent-runtime-adoption/SKILL.md +0 -246
  83. /package/dist/{chunk-YLUOTX6U.js.map → chunk-FXF2OL34.js.map} +0 -0
  84. /package/dist/{chunk-BPGXIKK7.js.map → chunk-SGQ4YIQW.js.map} +0 -0
  85. /package/dist/{chunk-Z5I642SY.js.map → chunk-WYC2XJF2.js.map} +0 -0
  86. /package/dist/{chunk-ZEYAT33L.js.map → chunk-Y3SRWZMP.js.map} +0 -0
package/dist/agent.js CHANGED
@@ -1,23 +1,19 @@
1
- import "./chunk-YLUOTX6U.js";
1
+ import "./chunk-FXF2OL34.js";
2
+ import "./chunk-Q2JSAVQ3.js";
2
3
  import {
3
4
  createSandboxForSpec
4
- } from "./chunk-IADLKE7I.js";
5
+ } from "./chunk-UQ6PNNXM.js";
5
6
  import "./chunk-DPEUKJRO.js";
6
- import "./chunk-Q2JSAVQ3.js";
7
- import "./chunk-ISTDY47H.js";
7
+ import "./chunk-HZDEXTSL.js";
8
8
  import "./chunk-IMSNJSXH.js";
9
9
  import "./chunk-M6MD6JBS.js";
10
10
  import "./chunk-3MDZX7YU.js";
11
11
  import {
12
12
  mapSandboxEvent
13
13
  } from "./chunk-M22PL4GH.js";
14
- import "./chunk-EP6RVHMX.js";
15
14
  import {
16
15
  ValidationError
17
16
  } from "./chunk-YEJR7IXO.js";
18
- import {
19
- __require
20
- } from "./chunk-DGUM43GV.js";
21
17
 
22
18
  // src/agent/surfaces.ts
23
19
  import { existsSync, statSync } from "fs";
@@ -277,7 +273,7 @@ function defineAgent(manifest) {
277
273
  }
278
274
 
279
275
  // src/agent/improvement-adapter.ts
280
- import { spawnSync } from "child_process";
276
+ import { createHash } from "crypto";
281
277
  import { readFileSync } from "fs";
282
278
  import { parseFindingSubject } from "@tangle-network/agent-eval/analyst";
283
279
  var DEFAULT_CREATE_KINDS = [
@@ -286,11 +282,7 @@ var DEFAULT_CREATE_KINDS = [
286
282
  "knowledge.raw",
287
283
  "new-tool"
288
284
  ];
289
- function createSurfaceImprovementAdapter(opts) {
290
- const mode = opts.mode ?? "none";
291
- if (mode === "open-pr" && !opts.ghRepo) {
292
- throw new Error("createSurfaceImprovementAdapter: mode=open-pr requires `ghRepo`");
293
- }
285
+ function createSurfaceImprovementProposer(opts) {
294
286
  const allowCreate = opts.allowCreateForKinds ?? DEFAULT_CREATE_KINDS;
295
287
  return {
296
288
  async proposeFromFindings(findings) {
@@ -366,222 +358,11 @@ function createSurfaceImprovementAdapter(opts) {
366
358
  });
367
359
  }
368
360
  return { edits, skipped, errors };
369
- },
370
- async apply(edits) {
371
- const applied = [];
372
- const warnings = [];
373
- if (mode === "none") {
374
- warnings.push(
375
- "createSurfaceImprovementAdapter: mode=none; no edits applied \u2014 configure mode=write or mode=open-pr"
376
- );
377
- return { applied, warnings };
378
- }
379
- for (const edit of edits) {
380
- const current = edit.target.exists ? readFileSync(edit.target.absolutePath, "utf-8") : "";
381
- if (sha256(current) !== edit.baseSha256) {
382
- warnings.push(
383
- `${edit.target.repoRelativePath}: base SHA mismatch; file changed after draft. Skipping.`
384
- );
385
- continue;
386
- }
387
- const ok = applyPatchInPlace(edit, opts.repoRoot);
388
- if (!ok) {
389
- warnings.push(`${edit.target.repoRelativePath}: git apply failed`);
390
- continue;
391
- }
392
- applied.push(edit.target.repoRelativePath);
393
- }
394
- if (mode === "open-pr" && applied.length > 0 && opts.ghRepo) {
395
- const prUrl = openPullRequest(
396
- applied,
397
- edits.filter((e) => applied.includes(e.target.repoRelativePath)),
398
- opts.repoRoot,
399
- opts.ghRepo,
400
- opts.baseBranch ?? "main"
401
- );
402
- if (prUrl) warnings.push(`opened PR: ${prUrl}`);
403
- else warnings.push("PR creation failed; edits are committed to a local branch only");
404
- }
405
- return { applied, warnings };
406
361
  }
407
362
  };
408
363
  }
409
- function applyPatchInPlace(edit, repoRoot) {
410
- const result = spawnSync("git", ["apply", "--whitespace=fix", "-p0", "-"], {
411
- cwd: repoRoot,
412
- input: edit.patch,
413
- encoding: "utf-8"
414
- });
415
- return result.status === 0;
416
- }
417
- function openPullRequest(paths, edits, repoRoot, ghRepo, baseBranch) {
418
- const branch = `analyst-loop/${Date.now()}-${edits[0]?.sourceFindingId.slice(0, 12) ?? "edits"}`;
419
- const checkout = spawnSync("git", ["checkout", "-b", branch], { cwd: repoRoot });
420
- if (checkout.status !== 0) return null;
421
- const add = spawnSync("git", ["add", ...paths], { cwd: repoRoot });
422
- if (add.status !== 0) return null;
423
- const title = `analyst-loop: ${edits[0]?.summary ?? `${edits.length} improvement edits`}`;
424
- const body = [
425
- `Automated analyst-loop edits \u2014 review carefully before merge.`,
426
- "",
427
- `Source findings:`,
428
- ...edits.map(
429
- (e) => ` - ${e.sourceFindingId} (confidence ${e.confidence.toFixed(2)}, severity ${e.severity})`
430
- ),
431
- "",
432
- "Rationales:",
433
- ...edits.map((e) => `
434
- ## ${e.target.repoRelativePath}
435
-
436
- ${e.rationale}`)
437
- ].join("\n");
438
- const commit = spawnSync("git", ["commit", "-m", title, "-m", body], { cwd: repoRoot });
439
- if (commit.status !== 0) return null;
440
- const push = spawnSync("git", ["push", "-u", "origin", branch], { cwd: repoRoot });
441
- if (push.status !== 0) return null;
442
- const pr = spawnSync(
443
- "gh",
444
- [
445
- "pr",
446
- "create",
447
- "--repo",
448
- ghRepo,
449
- "--title",
450
- title,
451
- "--body",
452
- body,
453
- "--base",
454
- baseBranch,
455
- "--head",
456
- branch
457
- ],
458
- { cwd: repoRoot, encoding: "utf-8" }
459
- );
460
- if (pr.status !== 0) return null;
461
- return pr.stdout.trim();
462
- }
463
364
  function sha256(s) {
464
- const crypto = __require("crypto");
465
- return crypto.createHash("sha256").update(s, "utf-8").digest("hex");
466
- }
467
-
468
- // src/agent/knowledge-adapter.ts
469
- function createSurfaceKnowledgeAdapter(opts, deps) {
470
- return {
471
- proposeFromFindings(findings) {
472
- const batch = deps.proposeFromFindings(findings);
473
- return {
474
- proposals: batch.proposals,
475
- skipped: batch.skipped,
476
- errors: batch.errors
477
- };
478
- },
479
- async apply(proposals) {
480
- const written = [];
481
- const warnings = [];
482
- for (const p of proposals) {
483
- const proposalText = renderProposalAsWriteBlock(p);
484
- if (proposalText === null) {
485
- warnings.push(
486
- `proposal has no writeBlocks/content; skipping (sourceFindingId=${getSourceFindingId(p)})`
487
- );
488
- continue;
489
- }
490
- try {
491
- const r = await deps.applyKnowledgeWriteBlocks(opts.knowledgeRoot, proposalText);
492
- written.push(...r.written);
493
- warnings.push(...r.warnings);
494
- } catch (err) {
495
- warnings.push(
496
- `applyKnowledgeWriteBlocks failed: ${err instanceof Error ? err.message : String(err)}`
497
- );
498
- }
499
- }
500
- if (deps.lintAfterApply && written.length > 0) {
501
- try {
502
- const lintIssues = await deps.lintAfterApply(opts.knowledgeRoot);
503
- for (const issue of lintIssues) warnings.push(`lint: ${issue}`);
504
- } catch (err) {
505
- warnings.push(
506
- `lintAfterApply failed: ${err instanceof Error ? err.message : String(err)}`
507
- );
508
- }
509
- }
510
- return { written, warnings };
511
- }
512
- };
513
- }
514
- function renderProposalAsWriteBlock(p) {
515
- if (!p || typeof p !== "object") return null;
516
- const obj = p;
517
- if (Array.isArray(obj.writeBlocks)) {
518
- const blocks = obj.writeBlocks;
519
- if (blocks.length === 0) return null;
520
- return blocks.map((b) => typeof b.content === "string" ? b.content : "").filter((s) => s.length > 0).join("\n\n");
521
- }
522
- if (typeof obj.proposalText === "string") return obj.proposalText;
523
- if (typeof obj.content === "string") return obj.content;
524
- return null;
525
- }
526
- function getSourceFindingId(p) {
527
- if (!p || typeof p !== "object") return "<unknown>";
528
- const obj = p;
529
- if (typeof obj.sourceFindingId === "string") return obj.sourceFindingId;
530
- if (typeof obj.id === "string") return obj.id;
531
- return "<unknown>";
532
- }
533
-
534
- // src/agent/outcome.ts
535
- async function measureOutcome(result, opts) {
536
- const applied = result.knowledge?.applied ?? [];
537
- const improvementsApplied = result.improvement?.applied ?? [];
538
- const allApplied = [...applied, ...improvementsApplied];
539
- if (allApplied.length === 0) {
540
- return {
541
- ...result,
542
- outcome: {
543
- baselineComposite: meanComposite(opts.baseline),
544
- afterComposite: meanComposite(opts.baseline),
545
- delta: 0,
546
- perPersona: opts.baseline.map((b) => ({
547
- personaId: b.personaId,
548
- before: b.composite,
549
- after: b.composite,
550
- delta: 0
551
- })),
552
- rolledBackPaths: []
553
- }
554
- };
555
- }
556
- const personaIds = opts.baseline.map((b) => b.personaId);
557
- const after = await opts.reRunCohort(personaIds);
558
- const afterByPersona = new Map(after.map((r) => [r.personaId, r.composite]));
559
- const perPersona = opts.baseline.map((b) => {
560
- const a = afterByPersona.get(b.personaId) ?? b.composite;
561
- return { personaId: b.personaId, before: b.composite, after: a, delta: a - b.composite };
562
- });
563
- const baselineComposite = meanComposite(opts.baseline);
564
- const afterComposite = meanComposite(after);
565
- const delta = afterComposite - baselineComposite;
566
- let rolledBackPaths = [];
567
- if (delta < 0 && opts.rollbackOnRegression && opts.revert) {
568
- await opts.revert(allApplied);
569
- rolledBackPaths = [...allApplied];
570
- }
571
- return {
572
- ...result,
573
- outcome: {
574
- baselineComposite,
575
- afterComposite,
576
- delta,
577
- perPersona,
578
- rolledBackPaths
579
- }
580
- };
581
- }
582
- function meanComposite(rows) {
583
- if (rows.length === 0) return 0;
584
- return rows.reduce((acc, r) => acc + r.composite, 0) / rows.length;
365
+ return createHash("sha256").update(s, "utf-8").digest("hex");
585
366
  }
586
367
 
587
368
  // src/agent/profile-materialization.ts
@@ -798,11 +579,9 @@ export {
798
579
  assertProfileMaterialization,
799
580
  collectAgentRun,
800
581
  createSandboxAct,
801
- createSurfaceImprovementAdapter,
802
- createSurfaceKnowledgeAdapter,
582
+ createSurfaceImprovementProposer,
803
583
  defineAgent,
804
584
  defineProfileMaterializationContract,
805
- measureOutcome,
806
585
  promptOnlyProfileMaterialization,
807
586
  promptResourceProfileMaterialization,
808
587
  renderProfileMaterializationIssues,