@tangle-network/agent-runtime 0.85.0 → 0.86.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/agent.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./chunk-DLAEEF26.js";
1
+ import "./chunk-3TZOXS7B.js";
2
2
  import {
3
3
  createSandboxForSpec
4
- } from "./chunk-XN5TIJGP.js";
4
+ } from "./chunk-F7OO2SKB.js";
5
5
  import "./chunk-UD4BHQMI.js";
6
6
  import "./chunk-BZF3KQ6G.js";
7
7
  import {
@@ -15,7 +15,7 @@ import {
15
15
  settledToIteration,
16
16
  supervise,
17
17
  withDriverExecutor
18
- } from "./chunk-XN5TIJGP.js";
18
+ } from "./chunk-F7OO2SKB.js";
19
19
  import {
20
20
  addTokenUsage,
21
21
  isAbortError,
@@ -977,49 +977,68 @@ function defineLeaderboard(spec) {
977
977
  return p;
978
978
  };
979
979
  let shotNonce = 0;
980
- const dispatch = spec.dispatch ?? loopDispatch({
981
- sandboxClient,
982
- toLoopOptions: (scenario, profile) => {
983
- const axis = harnessAxisOf(profile);
984
- const modelId = bareModel(axis?.model ?? models[0] ?? "");
985
- return {
986
- // naiveDriver = the no-signal retry floor: re-run the same case as
987
- // an independent attempt until one scores (>0) or the shot cap.
988
- driver: naiveDriver({
989
- continuation: "",
990
- applyContinuation: (task) => task,
991
- maxIterations: shots
992
- }),
993
- agentRun: {
994
- profile,
995
- taskToPrompt: (s) => `${promptOf(s)}
980
+ const dispatch = spec.dispatch ?? ((profile, scenario, dispatchCtx) => {
981
+ const cellDispatch = loopDispatch({
982
+ sandboxClient,
983
+ toLoopOptions: (cellScenario, cellProfile) => {
984
+ const axis = harnessAxisOf(cellProfile);
985
+ const modelId = bareModel(axis?.model ?? models[0] ?? "");
986
+ return {
987
+ // naiveDriver = the no-signal retry floor: re-run the same case as
988
+ // an independent attempt until one scores (>0) or the shot cap.
989
+ driver: naiveDriver({
990
+ continuation: "",
991
+ applyContinuation: (task) => task,
992
+ maxIterations: shots
993
+ }),
994
+ agentRun: {
995
+ profile: cellProfile,
996
+ taskToPrompt: (s) => `${promptOf(s)}
996
997
 
997
998
  <!-- independent-attempt:${shotNonce++} -->`,
998
- ...axis ? {
999
- sandboxOverrides: {
1000
- backend: {
1001
- type: axis.harness,
1002
- model: { ...spec.modelBackend, model: modelId }
999
+ ...axis ? {
1000
+ sandboxOverrides: {
1001
+ backend: {
1002
+ type: axis.harness,
1003
+ model: { ...spec.modelBackend, model: modelId }
1004
+ }
1003
1005
  }
1006
+ } : {}
1007
+ },
1008
+ output: {
1009
+ parse: (events) => spec.parseOutput ? spec.parseOutput(events, cellScenario.case) : (
1010
+ // The default decode produces string — the TArtifact
1011
+ // default. A structured-TArtifact spec supplies parseOutput
1012
+ // (documented on the field), so this cast never lies.
1013
+ collectAgentResponseText(events) ?? ""
1014
+ )
1015
+ },
1016
+ validator: {
1017
+ validate: async (output) => {
1018
+ const s = normalizeScore(spec.score(output, cellScenario.case));
1019
+ return { valid: s.composite > 0, score: s.composite };
1004
1020
  }
1005
- } : {}
1006
- },
1007
- output: {
1008
- parse: (events) => {
1009
- spec.onCellEvents?.(events, scenario.case);
1010
- return spec.parseOutput ? spec.parseOutput(events, scenario.case) : collectAgentResponseText(events) ?? "";
1011
- }
1012
- },
1013
- validator: {
1014
- validate: async (output) => {
1015
- const s = normalizeScore(spec.score(output, scenario.case));
1016
- return { valid: s.composite > 0, score: s.composite };
1021
+ },
1022
+ task: cellScenario,
1023
+ maxIterations: shots
1024
+ };
1025
+ },
1026
+ toArtifact: (result) => {
1027
+ for (const iter of result.iterations) {
1028
+ spec.onCellEvents?.(iter.events, scenario.case, {
1029
+ index: iter.index,
1030
+ ...iter.error ? { error: iter.error.message } : {},
1031
+ ...iter.verdict ? { verdict: { score: iter.verdict.score } } : {}
1032
+ });
1033
+ if (spec.resolveModel) {
1034
+ const served = spec.resolveModel(iter.events);
1035
+ if (served !== void 0) dispatchCtx.cost.observeModel?.(served);
1017
1036
  }
1018
- },
1019
- task: scenario,
1020
- maxIterations: shots
1021
- };
1022
- }
1037
+ }
1038
+ return result.winner?.output;
1039
+ }
1040
+ });
1041
+ return cellDispatch(profile, scenario, dispatchCtx);
1023
1042
  });
1024
1043
  await spec.setup?.(ctx);
1025
1044
  try {
@@ -5851,4 +5870,4 @@ export {
5851
5870
  computeFindingId,
5852
5871
  makeFinding2 as makeFinding
5853
5872
  };
5854
- //# sourceMappingURL=chunk-DLAEEF26.js.map
5873
+ //# sourceMappingURL=chunk-3TZOXS7B.js.map