agentfootprint 2.11.1 → 2.11.2

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 (67) hide show
  1. package/dist/core/Agent.js +81 -1238
  2. package/dist/core/Agent.js.map +1 -1
  3. package/dist/core/agent/AgentBuilder.js +489 -0
  4. package/dist/core/agent/AgentBuilder.js.map +1 -0
  5. package/dist/core/agent/buildAgentChart.js +227 -0
  6. package/dist/core/agent/buildAgentChart.js.map +1 -0
  7. package/dist/core/agent/buildToolRegistry.js +115 -0
  8. package/dist/core/agent/buildToolRegistry.js.map +1 -0
  9. package/dist/core/agent/stages/breakFinal.js +28 -0
  10. package/dist/core/agent/stages/breakFinal.js.map +1 -0
  11. package/dist/core/agent/stages/callLLM.js +129 -0
  12. package/dist/core/agent/stages/callLLM.js.map +1 -0
  13. package/dist/core/agent/stages/iterationStart.js +24 -0
  14. package/dist/core/agent/stages/iterationStart.js.map +1 -0
  15. package/dist/core/agent/stages/prepareFinal.js +45 -0
  16. package/dist/core/agent/stages/prepareFinal.js.map +1 -0
  17. package/dist/core/agent/stages/route.js +36 -0
  18. package/dist/core/agent/stages/route.js.map +1 -0
  19. package/dist/core/agent/stages/seed.js +95 -0
  20. package/dist/core/agent/stages/seed.js.map +1 -0
  21. package/dist/core/agent/stages/toolCalls.js +250 -0
  22. package/dist/core/agent/stages/toolCalls.js.map +1 -0
  23. package/dist/esm/core/Agent.js +83 -1239
  24. package/dist/esm/core/Agent.js.map +1 -1
  25. package/dist/esm/core/agent/AgentBuilder.js +485 -0
  26. package/dist/esm/core/agent/AgentBuilder.js.map +1 -0
  27. package/dist/esm/core/agent/buildAgentChart.js +223 -0
  28. package/dist/esm/core/agent/buildAgentChart.js.map +1 -0
  29. package/dist/esm/core/agent/buildToolRegistry.js +111 -0
  30. package/dist/esm/core/agent/buildToolRegistry.js.map +1 -0
  31. package/dist/esm/core/agent/stages/breakFinal.js +24 -0
  32. package/dist/esm/core/agent/stages/breakFinal.js.map +1 -0
  33. package/dist/esm/core/agent/stages/callLLM.js +125 -0
  34. package/dist/esm/core/agent/stages/callLLM.js.map +1 -0
  35. package/dist/esm/core/agent/stages/iterationStart.js +20 -0
  36. package/dist/esm/core/agent/stages/iterationStart.js.map +1 -0
  37. package/dist/esm/core/agent/stages/prepareFinal.js +41 -0
  38. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -0
  39. package/dist/esm/core/agent/stages/route.js +32 -0
  40. package/dist/esm/core/agent/stages/route.js.map +1 -0
  41. package/dist/esm/core/agent/stages/seed.js +91 -0
  42. package/dist/esm/core/agent/stages/seed.js.map +1 -0
  43. package/dist/esm/core/agent/stages/toolCalls.js +246 -0
  44. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -0
  45. package/dist/types/core/Agent.d.ts +5 -333
  46. package/dist/types/core/Agent.d.ts.map +1 -1
  47. package/dist/types/core/agent/AgentBuilder.d.ts +348 -0
  48. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -0
  49. package/dist/types/core/agent/buildAgentChart.d.ts +74 -0
  50. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -0
  51. package/dist/types/core/agent/buildToolRegistry.d.ts +62 -0
  52. package/dist/types/core/agent/buildToolRegistry.d.ts.map +1 -0
  53. package/dist/types/core/agent/stages/breakFinal.d.ts +23 -0
  54. package/dist/types/core/agent/stages/breakFinal.d.ts.map +1 -0
  55. package/dist/types/core/agent/stages/callLLM.d.ts +54 -0
  56. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -0
  57. package/dist/types/core/agent/stages/iterationStart.d.ts +16 -0
  58. package/dist/types/core/agent/stages/iterationStart.d.ts.map +1 -0
  59. package/dist/types/core/agent/stages/prepareFinal.d.ts +20 -0
  60. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -0
  61. package/dist/types/core/agent/stages/route.d.ts +19 -0
  62. package/dist/types/core/agent/stages/route.d.ts.map +1 -0
  63. package/dist/types/core/agent/stages/seed.d.ts +54 -0
  64. package/dist/types/core/agent/stages/seed.d.ts.map +1 -0
  65. package/dist/types/core/agent/stages/toolCalls.d.ts +50 -0
  66. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -0
  67. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ /**
2
+ * seed — initial stage of the agent's chart. Initializes every mutable
3
+ * field of `AgentState` from the consumer's input.
4
+ *
5
+ * Runs once per `agent.run({ input })`. The chart is built once at
6
+ * Agent construction, so seed has access to BOTH:
7
+ *
8
+ * • CHART-BUILD-TIME constants (maxIterations, cachingDisabled,
9
+ * toolSchemas) — passed as direct values to the factory.
10
+ * • PER-RUN MUTABLE state (pendingResumeHistory from
11
+ * resumeOnError(), currentRunContext.runId set per run) —
12
+ * passed as accessor closures over the Agent instance, since
13
+ * these change between consecutive `agent.run()` invocations.
14
+ *
15
+ * The accessor pattern keeps `seed` decoupled from the Agent class
16
+ * while preserving the per-run mutability the resume + identity
17
+ * features need.
18
+ */
19
+ import type { TypedScope } from 'footprintjs';
20
+ import type { LLMMessage, LLMToolSchema } from '../../../adapters/types.js';
21
+ import type { AgentState } from '../types.js';
22
+ export interface SeedStageDeps {
23
+ /** Resolved `clampIterations(opts.maxIterations ?? 10)`. Frozen at
24
+ * chart-build time. */
25
+ readonly maxIterations: number;
26
+ /** Resolved cache kill switch from `Agent.create({ caching: 'off' })`. */
27
+ readonly cachingDisabled: boolean;
28
+ /** Static tool schemas resolved at chart-build time. The tools slot
29
+ * subflow can OVERRIDE this per-iteration via `dynamicToolSchemas`,
30
+ * but seed populates the initial value so iter 1 has it. */
31
+ readonly toolSchemas: readonly LLMToolSchema[];
32
+ /**
33
+ * Read-AND-CLEAR accessor for the resume side-channel. Called exactly
34
+ * once per `agent.run()` from inside seed. If `resumeOnError(checkpoint)`
35
+ * was invoked before `run()`, this returns the checkpointed history
36
+ * and clears the field so the NEXT `run()` starts fresh. Returns
37
+ * `undefined` for the normal (non-resume) path.
38
+ */
39
+ readonly consumePendingResumeHistory: () => readonly LLMMessage[] | undefined;
40
+ /**
41
+ * Accessor for the current run's id, used to default the memory
42
+ * identity when consumer didn't pass `agent.run({ identity })`. Set
43
+ * by RunnerBase on every `agent.run()` call before the chart starts.
44
+ * Returns `undefined` only in degenerate (test) cases.
45
+ */
46
+ readonly getCurrentRunId: () => string | undefined;
47
+ }
48
+ /**
49
+ * Build the seed stage function for an Agent instance. Captures both
50
+ * the chart-build-time constants and the per-run mutable accessors
51
+ * via the deps object.
52
+ */
53
+ export declare function buildSeedStage(deps: SeedStageDeps): (scope: TypedScope<AgentState>) => void;
54
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B;4BACwB;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC;;iEAE6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/C;;;;;;OAMG;IACH,QAAQ,CAAC,2BAA2B,EAAE,MAAM,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC;IAC9E;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAmE3F"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * toolCalls — pausable handler for executing the LLM-requested tool
3
+ * calls in the agent's ReAct loop.
4
+ *
5
+ * • `execute` iterates `scope.llmLatestToolCalls`, dispatches each
6
+ * tool, appends results to scope.history, and increments
7
+ * `scope.iteration`. If a tool throws `PauseRequest` (via
8
+ * `pauseHere()`), commits partial state and returns the pause
9
+ * payload so footprintjs captures a checkpoint.
10
+ * • `resume` runs after the consumer supplies the human's answer.
11
+ * Treats that answer as the paused tool's result, appends to
12
+ * history, then continues the ReAct iteration loop.
13
+ *
14
+ * Dispatch resolution order:
15
+ * 1. Static registry built at chart-build time (registryByName).
16
+ * 2. External `ToolProvider.list(ctx).find(...)` if a `.toolProvider()`
17
+ * was wired and the tool isn't in the static registry.
18
+ *
19
+ * Permission gate (when `permissionChecker` is configured) runs BEFORE
20
+ * `tool.execute`. Deny → tool not executed; result is a synthetic
21
+ * denial string. Allow / gate_open → execution proceeds.
22
+ *
23
+ * `read_skill` is the auto-attached activation tool — when the LLM
24
+ * calls it with a valid Skill id, the next InjectionEngine pass
25
+ * activates that Skill (lifetime: turn).
26
+ */
27
+ import type { PausableHandler, TypedScope } from 'footprintjs';
28
+ import type { PermissionChecker } from '../../../adapters/types.js';
29
+ import type { ToolProvider } from '../../../tool-providers/types.js';
30
+ import type { Tool } from '../../tools.js';
31
+ import type { AgentState } from '../types.js';
32
+ export interface ToolCallsHandlerDeps {
33
+ /** Map from tool name → Tool instance, built from the augmented
34
+ * registry (static .tool() entries + read_skill if any skills +
35
+ * shared skill tools). The dispatch primary lookup. */
36
+ readonly registryByName: ReadonlyMap<string, Tool>;
37
+ /** Optional external `.toolProvider()` for per-iteration dynamic
38
+ * tools (skill-scoped, multi-tenant, etc.). Consulted only when
39
+ * the static registry doesn't have the tool. */
40
+ readonly externalToolProvider?: ToolProvider;
41
+ /** Optional permission gate. When present, every tool dispatch
42
+ * awaits `check({capability: 'tool_call', ...})` BEFORE executing.
43
+ * Throwing checkers are treated as deny-by-default. */
44
+ readonly permissionChecker?: PermissionChecker;
45
+ }
46
+ /**
47
+ * Build the pausable tool-call handler for the agent's chart.
48
+ */
49
+ export declare function buildToolCallsHandler(deps: ToolCallsHandlerDeps): PausableHandler<TypedScope<AgentState>>;
50
+ //# sourceMappingURL=toolCalls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolCalls.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/toolCalls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGhF,OAAO,KAAK,EAAuB,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAE1F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,oBAAoB;IACnC;;4DAEwD;IACxD,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnD;;qDAEiD;IACjD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,YAAY,CAAC;IAC7C;;4DAEwD;IACxD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CAChD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,oBAAoB,GACzB,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CA2NzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",