@tangle-network/agent-runtime 0.202.0 → 0.203.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/dist/{activation-D4oFb8Lt.js → activation-C8Ilw0IX.js} +2 -2
- package/dist/{activation-D4oFb8Lt.js.map → activation-C8Ilw0IX.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/{improvement-cycle-RpIiIKjM.js → improvement-cycle-BVS0odHN.js} +75 -17
- package/dist/improvement-cycle-BVS0odHN.js.map +1 -0
- package/dist/{index-BLaGPXGh.d.ts → index-prZR0SAw.d.ts} +60 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/intelligence.js +2 -2
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +3 -3
- package/dist/{loop-runner-bin-CqXOUcrz.js → loop-runner-bin-CSMc1AQ5.js} +2 -2
- package/dist/{loop-runner-bin-CqXOUcrz.js.map → loop-runner-bin-CSMc1AQ5.js.map} +1 -1
- package/dist/{loop-runner-bin-CkmHiZgU.d.ts → loop-runner-bin-CdLhMvhw.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/{runtime-Dc-Aem9j.js → runtime-B4HhRqE8.js} +97 -20
- package/dist/runtime-B4HhRqE8.js.map +1 -0
- package/dist/{structural-rollout-Zbntz3jo.js → structural-rollout-DPwqGLUp.js} +87 -50
- package/dist/structural-rollout-DPwqGLUp.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +9 -9
- package/dist/tui/index.d.ts +1 -1
- package/package.json +6 -6
- package/dist/improvement-cycle-RpIiIKjM.js.map +0 -1
- package/dist/runtime-Dc-Aem9j.js.map +0 -1
- package/dist/structural-rollout-Zbntz3jo.js.map +0 -1
|
@@ -1525,14 +1525,28 @@ function errorMessage(error) {
|
|
|
1525
1525
|
* - `learned` — durable facts written to the cross-run `Corpus` so the NEXT
|
|
1526
1526
|
* run starts smarter (the continuous half of "continuous self-improvement").
|
|
1527
1527
|
*
|
|
1528
|
-
*
|
|
1529
|
-
*
|
|
1528
|
+
* The default analyst produces production observations from execution evidence.
|
|
1529
|
+
* Injected analyses preserve their explicit proposal origins and evidence references.
|
|
1530
|
+
* The observer is harness-agnostic: it
|
|
1530
1531
|
* reads a trace + an output, so it watches opencode, codex, hermes, or a BYO
|
|
1531
1532
|
* agent identically.
|
|
1532
1533
|
*/
|
|
1533
1534
|
const observerId = "observe/trace";
|
|
1534
1535
|
/** The default observer instruction — exported so an optimizer can seed its population. */
|
|
1535
1536
|
const defaultAnalystInstruction = "You are a third-person OBSERVER watching an AI agent work. You see its TRACE (what it did), not its grader. From the trace, name SPECIFIC, behavior-grounded findings: wasted/duplicated tool calls, thrash/retries, token/cost waste, missing verification, failure patterns. For each, a concrete recommended_action, and whether the AGENT (fix its skills/prompt/tools) or the OPERATOR (fix framing/decomposition/config) should act. Only claim what the trace shows. No findings if the run was clean.";
|
|
1537
|
+
/** Analysis can fail after paid work; its measured subtotal must remain recoverable. */
|
|
1538
|
+
var ObservationError = class extends Error {
|
|
1539
|
+
usage;
|
|
1540
|
+
constructor(message, usage, options) {
|
|
1541
|
+
super(message, options);
|
|
1542
|
+
this.usage = usage;
|
|
1543
|
+
validateUsage(usage);
|
|
1544
|
+
this.name = "ObservationError";
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
function validateUsage(usage) {
|
|
1548
|
+
if (!Number.isSafeInteger(usage.input) || usage.input < 0 || !Number.isSafeInteger(usage.output) || usage.output < 0 || typeof usage.known !== "boolean") throw new TypeError("observation usage requires nonnegative safe integer subtotals and explicit known status");
|
|
1549
|
+
}
|
|
1536
1550
|
/** Compact the trace into the lines the observer reasons over — tool calls,
|
|
1537
1551
|
* errors, and statuses, in order. Keeps the model call bounded + grounded. */
|
|
1538
1552
|
function summarizeTrace(trace, maxLines) {
|
|
@@ -1609,7 +1623,9 @@ const findingsSchema = {
|
|
|
1609
1623
|
}
|
|
1610
1624
|
};
|
|
1611
1625
|
/** The third-person trace analyst: read a worker's trace and produce steer findings for the next attempt plus durable `learned` facts for the cross-run corpus. */
|
|
1612
|
-
async function
|
|
1626
|
+
async function analyzeWithProfile(input, opts) {
|
|
1627
|
+
if (opts.proposalOrigin !== void 0 && !["production", "search"].includes(opts.proposalOrigin)) throw new TypeError("observer proposal origin must be production or search");
|
|
1628
|
+
for (const limit of [opts.maxTraceLines, opts.maxOutputChars]) if (limit !== void 0 && (!Number.isSafeInteger(limit) || limit < 0)) throw new TypeError("observer context limits must be nonnegative safe integers");
|
|
1613
1629
|
const traceSummary = summarizeTrace(input.trace, opts.maxTraceLines ?? 80);
|
|
1614
1630
|
const res = await profileChatClient({
|
|
1615
1631
|
profile: opts.profile,
|
|
@@ -1619,58 +1635,79 @@ async function observe(input, opts) {
|
|
|
1619
1635
|
jsonSchema: findingsSchema,
|
|
1620
1636
|
messages: [{
|
|
1621
1637
|
role: "user",
|
|
1622
|
-
content: `TASK: ${input.task}\n\nOUTCOME: ${input.outcome ?? "unknown"}\n\nFINAL OUTPUT
|
|
1638
|
+
content: `TASK: ${input.task}\n\nOUTCOME: ${input.outcome ?? "unknown"}\n\nFINAL OUTPUT:\n${input.output.slice(0, opts.maxOutputChars ?? 1200)}\n\nTRACE (in order; "xN" = repeated):\n${traceSummary}`
|
|
1623
1639
|
}]
|
|
1624
1640
|
}, { ...opts.signal ? { signal: opts.signal } : {} });
|
|
1625
|
-
const
|
|
1626
|
-
const
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
proposal_origin: "production",
|
|
1637
|
-
metadata: { audience: f.audience },
|
|
1638
|
-
...input.runId ? { subject: input.runId } : {}
|
|
1639
|
-
})), "observe findings");
|
|
1640
|
-
const learned = [];
|
|
1641
|
-
if (opts.corpus) for (const f of findings) {
|
|
1642
|
-
const record = {
|
|
1643
|
-
schemaVersion: "1.0.0",
|
|
1644
|
-
id: f.finding_id,
|
|
1645
|
-
runId: input.runId ?? observerId,
|
|
1646
|
-
producedAt: f.produced_at ?? producedAt,
|
|
1641
|
+
const inputTokens = res.usage?.promptTokens;
|
|
1642
|
+
const outputTokens = res.usage?.completionTokens;
|
|
1643
|
+
const usage = {
|
|
1644
|
+
input: inputTokens ?? 0,
|
|
1645
|
+
output: outputTokens ?? 0,
|
|
1646
|
+
known: res.usage?.captured !== false && typeof inputTokens === "number" && typeof outputTokens === "number"
|
|
1647
|
+
};
|
|
1648
|
+
validateUsage(usage);
|
|
1649
|
+
try {
|
|
1650
|
+
const findings = assertProposalFindings(parseFindings(res.content).map((f) => makeProposalFinding({
|
|
1651
|
+
analyst_id: observerId,
|
|
1647
1652
|
area: f.area,
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1653
|
+
severity: f.severity,
|
|
1654
|
+
claim: f.claim,
|
|
1655
|
+
recommended_action: f.recommended_action,
|
|
1651
1656
|
confidence: f.confidence,
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
}
|
|
1657
|
+
evidence_refs: [...input.evidenceRefs ?? []],
|
|
1658
|
+
derived_from_judge: false,
|
|
1659
|
+
proposal_origin: opts.proposalOrigin ?? "production",
|
|
1660
|
+
metadata: { audience: f.audience },
|
|
1661
|
+
...input.runId ? { subject: input.runId } : {}
|
|
1662
|
+
})), "observe findings");
|
|
1663
|
+
return {
|
|
1664
|
+
findings: [...findings],
|
|
1665
|
+
report: renderReport(findings),
|
|
1666
|
+
usage
|
|
1656
1667
|
};
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
learned.push(record);
|
|
1668
|
+
} catch (cause) {
|
|
1669
|
+
throw new ObservationError(cause instanceof Error ? cause.message : String(cause), usage, { cause });
|
|
1660
1670
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1671
|
+
}
|
|
1672
|
+
/** Analyze through the selected implementation, then retain its validated findings in the corpus. */
|
|
1673
|
+
async function observe(input, opts) {
|
|
1674
|
+
opts.signal?.throwIfAborted();
|
|
1675
|
+
const analysis = opts.analysis ? await opts.analysis(input, { ...opts.signal ? { signal: opts.signal } : {} }) : await analyzeWithProfile(input, opts);
|
|
1676
|
+
validateUsage(analysis.usage);
|
|
1677
|
+
const learned = [];
|
|
1678
|
+
try {
|
|
1679
|
+
opts.signal?.throwIfAborted();
|
|
1680
|
+
const findings = assertProposalFindings(analysis.findings, "observe findings");
|
|
1681
|
+
const producedAt = input.runId ?? observerId;
|
|
1682
|
+
if (opts.corpus) for (const f of findings) {
|
|
1683
|
+
opts.signal?.throwIfAborted();
|
|
1684
|
+
const record = {
|
|
1685
|
+
schemaVersion: "1.0.0",
|
|
1686
|
+
id: f.finding_id,
|
|
1687
|
+
runId: input.runId ?? observerId,
|
|
1688
|
+
producedAt: f.produced_at ?? producedAt,
|
|
1689
|
+
area: f.area,
|
|
1690
|
+
claim: f.recommended_action ?? f.claim,
|
|
1691
|
+
...f.claim ? { rationale: f.claim } : {},
|
|
1692
|
+
tags: [...opts.tags ?? [], `audience:${f.metadata?.audience ?? "agent"}`],
|
|
1693
|
+
confidence: f.confidence,
|
|
1694
|
+
evidence: [{
|
|
1695
|
+
kind: "finding",
|
|
1696
|
+
uri: f.finding_id
|
|
1697
|
+
}, ...f.evidence_refs]
|
|
1698
|
+
};
|
|
1699
|
+
const r = await opts.corpus.append(record);
|
|
1700
|
+
if (!r.succeeded) throw new Error(`observe corpus append failed for '${record.id}' after storing ${learned.length}/${findings.length} findings: ${r.error}`);
|
|
1701
|
+
learned.push(record);
|
|
1672
1702
|
}
|
|
1673
|
-
|
|
1703
|
+
return {
|
|
1704
|
+
...analysis,
|
|
1705
|
+
findings: [...findings],
|
|
1706
|
+
learned
|
|
1707
|
+
};
|
|
1708
|
+
} catch (cause) {
|
|
1709
|
+
throw new ObservationError(cause instanceof Error ? cause.message : String(cause), analysis.usage, { cause });
|
|
1710
|
+
}
|
|
1674
1711
|
}
|
|
1675
1712
|
function parseFindings(content) {
|
|
1676
1713
|
let obj;
|
|
@@ -2803,6 +2840,6 @@ function structuralRollout(config = {}) {
|
|
|
2803
2840
|
});
|
|
2804
2841
|
}
|
|
2805
2842
|
//#endregion
|
|
2806
|
-
export {
|
|
2843
|
+
export { collectAgentTurn as A, defaultAnalystInstruction as C, profileOptimizerModelCall as D, profileChatClient as E, InMemoryRuntimeSessionStore as F, newRuntimeSession as I, nowIso as L, createIterableBackend as M, createSandboxPromptBackend as N, optimizerMethod as O, normalizeBackendStreamEvent as P, startOrResumeRuntimeSession as R, ObservationError as S, renderReport as T, depthStrategy as _, defaultStructuralRolloutPolicy as a, sample as b, officialChecksFromMeta as c, selectBestIndex as d, structuralRollout as f, defineStrategy as g, breadthStrategy as h, defaultExtractCandidate as i, streamAgentTurn as j, strategyAuthorMethod as k, resolveEntrySymbol as l, adaptiveRefine as m, compareCheckOutcomes as n, filterAuthoredAsserts as o, visibleCheckScore as p, composeCheckSources as r, modelAuthoredChecks as s, canDisplace as t, sandboxCheckRunner as u, refine as v, observe as w, sampleThenRefine as x, runAgentic as y, touchSession as z };
|
|
2807
2844
|
|
|
2808
|
-
//# sourceMappingURL=structural-rollout-
|
|
2845
|
+
//# sourceMappingURL=structural-rollout-DPwqGLUp.js.map
|