@tangle-network/agent-runtime 0.108.1 → 0.109.1

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 (56) hide show
  1. package/README.md +7 -6
  2. package/dist/{activation-DRpnplEm.js → activation-CM-L6TtL.js} +2 -2
  3. package/dist/{activation-DRpnplEm.js.map → activation-CM-L6TtL.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/analyst-loop.d.ts +1 -1
  7. package/dist/{environment-provider-D0NXc4Qz.d.ts → environment-provider-CMqSAp-O.d.ts} +3 -2
  8. package/dist/environment-provider.d.ts +1 -1
  9. package/dist/{improvement-cycle-CRnDDdX0.js → improvement-cycle-9O4iVFOA.js} +3 -3
  10. package/dist/{improvement-cycle-CRnDDdX0.js.map → improvement-cycle-9O4iVFOA.js.map} +1 -1
  11. package/dist/{index-DQp3BPeC.d.ts → index-Bur6uUF4.d.ts} +6 -152
  12. package/dist/{index-cdkwHruJ.d.ts → index-Cn5TtHUG.d.ts} +3 -3
  13. package/dist/{index-BZbJWqoZ.d.ts → index-bXiMVrUv.d.ts} +8 -7
  14. package/dist/index.d.ts +8 -6
  15. package/dist/index.js +11 -635
  16. package/dist/index.js.map +1 -1
  17. package/dist/intelligence.d.ts +2 -2
  18. package/dist/intelligence.js +2 -2
  19. package/dist/{loops.d.ts → kernel.d.ts} +3 -3
  20. package/dist/{loops.js → kernel.js} +4 -4
  21. package/dist/{knowledge-rdrpPIXs.js → knowledge-1a38bcUT.js} +3 -3
  22. package/dist/{knowledge-rdrpPIXs.js.map → knowledge-1a38bcUT.js.map} +1 -1
  23. package/dist/knowledge.d.ts +1 -1
  24. package/dist/knowledge.js +1 -1
  25. package/dist/{loop-runner-bin-9-JlGqN7.d.ts → loop-runner-bin-CSzrWlgE.d.ts} +3 -3
  26. package/dist/{loop-runner-bin-B1V-XS5A.js → loop-runner-bin-V4EN9aNT.js} +3 -3
  27. package/dist/{loop-runner-bin-B1V-XS5A.js.map → loop-runner-bin-V4EN9aNT.js.map} +1 -1
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +1 -1
  31. package/dist/mcp/index.d.ts +2 -2
  32. package/dist/mcp/index.js +4 -4
  33. package/dist/{openai-tools-BjQq2TTL.js → openai-tools-DT9FH2_t.js} +2 -2
  34. package/dist/{openai-tools-BjQq2TTL.js.map → openai-tools-DT9FH2_t.js.map} +1 -1
  35. package/dist/primeintellect/index.d.ts +1 -1
  36. package/dist/profiles.d.ts +1 -1
  37. package/dist/profiles.js.map +1 -1
  38. package/dist/{runtime-CDekUROm.js → runtime-BVMyqgct.js} +8 -7
  39. package/dist/{runtime-CDekUROm.js.map → runtime-BVMyqgct.js.map} +1 -1
  40. package/dist/runtime-hooks-C7iJOWm3.js +99 -0
  41. package/dist/runtime-hooks-C7iJOWm3.js.map +1 -0
  42. package/dist/runtime-hooks-sbRpjStq.d.ts +88 -0
  43. package/dist/{structural-rollout-BC81Otmc.js → structural-rollout-ASQLr4-v.js} +2 -2
  44. package/dist/{structural-rollout-BC81Otmc.js.map → structural-rollout-ASQLr4-v.js.map} +1 -1
  45. package/dist/{supervise-JfKPwIlO.js → supervise-DyPmmhJ6.js} +6 -5
  46. package/dist/supervise-DyPmmhJ6.js.map +1 -0
  47. package/dist/{supervisor-B2LzaWRb.js → supervisor-sTJC9psT.js} +3 -98
  48. package/dist/supervisor-sTJC9psT.js.map +1 -0
  49. package/dist/testing.js +8 -8
  50. package/dist/tool-loop.d.ts +149 -0
  51. package/dist/tool-loop.js +629 -0
  52. package/dist/tool-loop.js.map +1 -0
  53. package/dist/{types-BevOjfTY.d.ts → types-DnNGJ5Gz.d.ts} +3 -88
  54. package/package.json +21 -10
  55. package/dist/supervise-JfKPwIlO.js.map +0 -1
  56. package/dist/supervisor-B2LzaWRb.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { c as RuntimeRunStateError, u as ValidationError } from "./errors-DEAvWQPy.js";
2
2
  import { f as zeroTokenUsage, t as addTokenUsage } from "./util-MVgdwuIS.js";
3
3
  import { a as contentAddress, c as replaySpawnTree, o as materializeTreeView, s as pendingWaits } from "./spawn-journal-CwPvKUTa.js";
4
+ import { i as notifyRuntimeHookEvent } from "./runtime-hooks-C7iJOWm3.js";
4
5
  import { estimateCost, isModelPriced } from "@tangle-network/agent-eval";
5
6
  import { createHash, randomUUID } from "node:crypto";
6
7
  import { applyWorkspacePlan, materializeProfile } from "@tangle-network/agent-profile-materialize";
@@ -1968,102 +1969,6 @@ function routerBrain(cfg, opts = {}) {
1968
1969
  });
1969
1970
  }
1970
1971
  //#endregion
1971
- //#region src/runtime-hooks.ts
1972
- /** Identity helper that types a {@link RuntimeHooks} literal so the fields are inferred. */
1973
- function defineRuntimeHooks(hooks) {
1974
- return hooks;
1975
- }
1976
- /**
1977
- * Merge several {@link RuntimeHooks} into one. Falsy entries are dropped (so you can
1978
- * pass `flag && hooks`), and every observer's `onEvent`/`onDecisionPoint` fires for each
1979
- * event. Use this to attach N observers to a loop instead of a second event bus.
1980
- */
1981
- function composeRuntimeHooks(...entries) {
1982
- const hooks = entries.filter((entry) => !!entry);
1983
- return {
1984
- onEvent: hooks.some((hook) => hook.onEvent) ? (event, context) => {
1985
- const pending = [];
1986
- for (const hook of hooks) {
1987
- const result = hook.onEvent?.(event, context);
1988
- if (isThenable(result)) pending.push(Promise.resolve(result));
1989
- }
1990
- if (pending.length > 0) return Promise.all(pending).then(() => void 0);
1991
- } : void 0,
1992
- onDecisionPoint: hooks.some((hook) => hook.onDecisionPoint) ? (point, context) => {
1993
- const pending = [];
1994
- for (const hook of hooks) {
1995
- const result = hook.onDecisionPoint?.(point, context);
1996
- if (isThenable(result)) pending.push(Promise.resolve(result));
1997
- }
1998
- if (pending.length > 0) return Promise.all(pending).then(() => void 0);
1999
- } : void 0,
2000
- onHookError: hooks.some((hook) => hook.onHookError) ? (error, context) => {
2001
- const pending = [];
2002
- for (const hook of hooks) {
2003
- const result = hook.onHookError?.(error, context);
2004
- if (isThenable(result)) pending.push(Promise.resolve(result));
2005
- }
2006
- if (pending.length > 0) return Promise.all(pending).then(() => void 0);
2007
- } : void 0
2008
- };
2009
- }
2010
- /** Fire `hooks.onEvent`, swallowing sync throws and surfacing async failures to `onError`. */
2011
- function notifyRuntimeHookEvent(hooks, event, context = {}) {
2012
- const onEvent = hooks?.onEvent;
2013
- if (!onEvent) return;
2014
- try {
2015
- const result = onEvent(event, context);
2016
- if (isThenable(result)) result.catch((error) => {
2017
- notifyRuntimeHookError(hooks, toError(error), {
2018
- hook: "onEvent",
2019
- eventId: event.id,
2020
- target: event.target,
2021
- phase: event.phase
2022
- });
2023
- });
2024
- } catch (error) {
2025
- notifyRuntimeHookError(hooks, toError(error), {
2026
- hook: "onEvent",
2027
- eventId: event.id,
2028
- target: event.target,
2029
- phase: event.phase
2030
- });
2031
- }
2032
- }
2033
- /** Fire `hooks.onDecisionPoint`, swallowing sync throws and surfacing async failures to `onError`. */
2034
- function notifyRuntimeDecisionPoint(hooks, point, context = {}) {
2035
- const onDecisionPoint = hooks?.onDecisionPoint;
2036
- if (!onDecisionPoint) return;
2037
- try {
2038
- const result = onDecisionPoint(point, context);
2039
- if (isThenable(result)) result.catch((error) => {
2040
- notifyRuntimeHookError(hooks, toError(error), {
2041
- hook: "onDecisionPoint",
2042
- decisionId: point.id,
2043
- decisionKind: point.kind
2044
- });
2045
- });
2046
- } catch (error) {
2047
- notifyRuntimeHookError(hooks, toError(error), {
2048
- hook: "onDecisionPoint",
2049
- decisionId: point.id,
2050
- decisionKind: point.kind
2051
- });
2052
- }
2053
- }
2054
- function notifyRuntimeHookError(hooks, error, context) {
2055
- try {
2056
- const result = hooks?.onHookError?.(error, context);
2057
- if (isThenable(result)) result.catch(() => void 0);
2058
- } catch {}
2059
- }
2060
- function isThenable(value) {
2061
- return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
2062
- }
2063
- function toError(error) {
2064
- return error instanceof Error ? error : new Error(String(error));
2065
- }
2066
- //#endregion
2067
1972
  //#region src/runtime/supervise/progress.ts
2068
1973
  /** How long a worker may produce no metered activity before a `progress()` read calls it stalled.
2069
1974
  * Deliberately generous: a coding harness routinely spends minutes inside one tool call, and a
@@ -4026,6 +3931,6 @@ function isNonEmptySpend(s) {
4026
3931
  return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0;
4027
3932
  }
4028
3933
  //#endregion
4029
- export { runSettledCommand as A, notifyRuntimeDecisionPoint as C, routerChatWithUsage as D, routerChatWithTools as E, removeWorktree as F, harnessInvocation as I, parseCodexTokenUsage as L, runWorktreeHarness as M, captureWorktreeDiff as N, routerToolLoop as O, createWorktree as P, runLocalHarness as R, defineRuntimeHooks as S, routerBrain as T, waitUntil as _, runFinalizer as a, readWorkerProgress as b, spendFromUsageEvents as c, settledToIteration as d, createWaitProbes as f, validateWaitSpec as g, timerAt as h, pickBestDelivered as i, runWorktreeChecks as j, runBrainLoop as k, withDriverExecutor as l, pollFor as m, bestDelivered as n, runTree as o, isWaitOutcome as p, collectDelivered as r, createBudgetPool as s, createSupervisor as t, createScope as u, DEFAULT_STALL_AFTER_MS as v, notifyRuntimeHookEvent as w, composeRuntimeHooks as x, createActivityLog as y, CodexExecutionDiagnosticError as z };
3934
+ export { createWorktree as A, routerChatWithUsage as C, runWorktreeChecks as D, runSettledCommand as E, CodexExecutionDiagnosticError as F, harnessInvocation as M, parseCodexTokenUsage as N, runWorktreeHarness as O, runLocalHarness as P, routerChatWithTools as S, runBrainLoop as T, waitUntil as _, runFinalizer as a, readWorkerProgress as b, spendFromUsageEvents as c, settledToIteration as d, createWaitProbes as f, validateWaitSpec as g, timerAt as h, pickBestDelivered as i, removeWorktree as j, captureWorktreeDiff as k, withDriverExecutor as l, pollFor as m, bestDelivered as n, runTree as o, isWaitOutcome as p, collectDelivered as r, createBudgetPool as s, createSupervisor as t, createScope as u, DEFAULT_STALL_AFTER_MS as v, routerToolLoop as w, routerBrain as x, createActivityLog as y };
4030
3935
 
4031
- //# sourceMappingURL=supervisor-B2LzaWRb.js.map
3936
+ //# sourceMappingURL=supervisor-sTJC9psT.js.map