@code-yeongyu/senpi-agent-core 2026.11.4-2 → 2026.11.5-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 (100) hide show
  1. package/dist/agent-loop.js +14 -140
  2. package/dist/agent.d.ts +4 -0
  3. package/dist/agent.js +4 -0
  4. package/dist/conformance/index.d.ts +7 -0
  5. package/dist/conformance/index.js +4 -0
  6. package/dist/conformance/loop-core-manifest.d.ts +1 -1
  7. package/dist/conformance/loop-core-manifest.js +17 -0
  8. package/dist/conformance/registry.js +11 -17
  9. package/dist/egress/types.d.ts +102 -0
  10. package/dist/egress/types.js +7 -0
  11. package/dist/execution/canonical-digest.d.ts +10 -0
  12. package/dist/execution/canonical-digest.js +20 -0
  13. package/dist/execution/chain-count.d.ts +26 -0
  14. package/dist/execution/chain-count.js +45 -0
  15. package/dist/execution/coordinator-plan.d.ts +1 -2
  16. package/dist/execution/coordinator-plan.js +4 -17
  17. package/dist/execution/device-files-node.js +39 -1
  18. package/dist/execution/device-files.d.ts +30 -1
  19. package/dist/execution/device-files.js +38 -1
  20. package/dist/execution/ledger-types.d.ts +3 -1
  21. package/dist/execution/ledger.d.ts +9 -3
  22. package/dist/execution/ledger.js +8 -2
  23. package/dist/execution/loop-hook-host-hand.d.ts +33 -0
  24. package/dist/execution/loop-hook-host-hand.js +71 -0
  25. package/dist/execution/loop-hook-host-protocol.d.ts +46 -0
  26. package/dist/execution/loop-hook-host-protocol.js +47 -0
  27. package/dist/execution/loop-hook-host.d.ts +40 -0
  28. package/dist/execution/loop-hook-host.js +87 -0
  29. package/dist/execution/plane-session.d.ts +56 -0
  30. package/dist/execution/plane-session.js +178 -0
  31. package/dist/execution/plane.d.ts +5 -2
  32. package/dist/execution/plane.js +1 -1
  33. package/dist/execution/prepared/executor-body.d.ts +22 -0
  34. package/dist/execution/prepared/executor-body.js +73 -0
  35. package/dist/execution/prepared/executor-freeze.d.ts +17 -0
  36. package/dist/execution/prepared/executor-freeze.js +42 -0
  37. package/dist/execution/prepared/executor-pipeline.d.ts +11 -0
  38. package/dist/execution/prepared/executor-pipeline.js +26 -0
  39. package/dist/execution/prepared/executor-types.d.ts +131 -0
  40. package/dist/execution/prepared/executor-types.js +2 -0
  41. package/dist/execution/prepared/executor.d.ts +8 -0
  42. package/dist/execution/prepared/executor.js +261 -0
  43. package/dist/execution/prepared/memory-batch-store.d.ts +4 -0
  44. package/dist/execution/prepared/memory-batch-store.js +4 -0
  45. package/dist/execution/prepared/pipeline-prepared-batch.d.ts +27 -0
  46. package/dist/execution/prepared/pipeline-prepared-batch.js +175 -0
  47. package/dist/execution/prepared/pipeline-prepared.d.ts +10 -0
  48. package/dist/execution/prepared/pipeline-prepared.js +54 -0
  49. package/dist/execution/remote-device-files.js +33 -4
  50. package/dist/execution/remote-epoch-gate.d.ts +19 -0
  51. package/dist/execution/remote-epoch-gate.js +46 -0
  52. package/dist/execution/remote-epoch.d.ts +53 -0
  53. package/dist/execution/remote-epoch.js +74 -0
  54. package/dist/execution/remote-executor.d.ts +8 -1
  55. package/dist/execution/remote-executor.js +24 -6
  56. package/dist/execution/remote-file-call.js +1 -0
  57. package/dist/execution/remote-hand-ledger.d.ts +11 -3
  58. package/dist/execution/remote-hand-ledger.js +31 -15
  59. package/dist/execution/remote-link.d.ts +6 -1
  60. package/dist/execution/remote-link.js +50 -14
  61. package/dist/execution/remote-protocol.d.ts +30 -1
  62. package/dist/execution/remote-protocol.js +30 -0
  63. package/dist/execution/remote-tool-host.d.ts +12 -0
  64. package/dist/execution/remote-tool-host.js +3 -1
  65. package/dist/execution/testing/epoch-cases.d.ts +8 -0
  66. package/dist/execution/testing/epoch-cases.js +84 -0
  67. package/dist/execution/testing/epoch-harness.d.ts +47 -0
  68. package/dist/execution/testing/epoch-harness.js +172 -0
  69. package/dist/execution/testing/epoch-registry.d.ts +3 -0
  70. package/dist/execution/testing/epoch-registry.js +17 -0
  71. package/dist/execution/testing/hand-harness.d.ts +3 -0
  72. package/dist/execution/testing/hand-harness.js +27 -22
  73. package/dist/execution/testing/hand-registry.d.ts +3 -0
  74. package/dist/execution/testing/hand-registry.js +20 -0
  75. package/dist/execution/testing/kill-epoch.d.ts +9 -0
  76. package/dist/execution/testing/kill-epoch.js +71 -0
  77. package/dist/execution/testing/kill-hook.d.ts +14 -0
  78. package/dist/execution/testing/kill-hook.js +117 -0
  79. package/dist/execution/testing/multi-epoch-cases.d.ts +4 -0
  80. package/dist/execution/testing/multi-epoch-cases.js +29 -0
  81. package/dist/execution/tool-host.d.ts +13 -1
  82. package/dist/execution/tool-host.js +18 -1
  83. package/dist/harness/agent-harness.d.ts +6 -0
  84. package/dist/harness/execution/tool-host-call.d.ts +13 -0
  85. package/dist/harness/execution/tool-host-call.js +55 -0
  86. package/dist/harness/execution/tools.d.ts +2 -1
  87. package/dist/harness/execution/tools.js +32 -17
  88. package/dist/harness/runtime/drive/tools.js +1 -1
  89. package/dist/harness/runtime/harness.js +1 -0
  90. package/dist/harness/runtime/types.d.ts +1 -0
  91. package/dist/index.d.ts +16 -2
  92. package/dist/index.js +14 -1
  93. package/dist/public-entry.d.ts +10 -0
  94. package/dist/public-entry.js +23 -0
  95. package/dist/step-commit.d.ts +24 -0
  96. package/dist/step-commit.js +24 -0
  97. package/dist/tool-name-alias.d.ts +1 -7
  98. package/dist/tool-name-alias.js +0 -17
  99. package/dist/types.d.ts +37 -1
  100. package/package.json +3 -3
package/dist/types.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import type { Api, AssistantMessage, AssistantMessageEvent, AssistantMessageEventStream, CursorExecHandlers, ImageContent, JsonValue, Message, Model, ProviderDiagnostic, SimpleStreamOptions, TextContent, ThinkingSelection, Tool, ToolResultMessage, TranscriptContext, Usage } from "@earendil-works/pi-ai";
2
2
  import type { Static, TSchema } from "typebox";
3
+ import type { DurableStore } from "./durable/store.ts";
3
4
  import type { ExecutionPipelineWitness, ExecutionScope, ToolHost } from "./execution/tool-host.ts";
5
+ /**
6
+ * Opens a new, empty store for one tool batch, which the batch claims at epoch 1. A batch never reuses another's
7
+ * store: a call's command ID is the model's call ID, and providers reuse those across turns.
8
+ */
9
+ export type BatchStoreFactory = () => DurableStore;
4
10
  export type { ExecutionPipelineWitness, ExecutionScope, ToolHost, ToolHostCall, ToolHostOptions, ToolHostResult, } from "./execution/tool-host.ts";
5
11
  /**
6
12
  * Stream function used by the agent loop. `Models.streamSimple` satisfies
@@ -135,6 +141,16 @@ export type AgentTurnDecision = {
135
141
  * with the current context. Error and aborted responses remain hard exits.
136
142
  */
137
143
  export type FinishTurn = (turn: AgentTurnContext, signal?: AbortSignal) => AgentTurnDecision | void | Promise<AgentTurnDecision | undefined> | Promise<void>;
144
+ /** One model step as the loop finished it: its terminal assistant message and the provider tool results emitted for it. */
145
+ export interface StepCommit {
146
+ readonly message: AssistantMessage;
147
+ readonly providerToolResults: readonly ToolResultMessage[];
148
+ }
149
+ /**
150
+ * Makes one finished model step durable before the loop acts on it. A rejection leaves the loop with no further
151
+ * events and no tool dispatch for that step.
152
+ */
153
+ export type StepCommitFn = (step: StepCommit) => Promise<void>;
138
154
  /** Replacement runtime state used by the agent loop before starting another provider request. */
139
155
  export interface AgentLoopTurnUpdate {
140
156
  /** Context for the next provider request. */
@@ -263,6 +279,12 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
263
279
  * hard exits.
264
280
  */
265
281
  finishTurn?: FinishTurn;
282
+ /**
283
+ * Called once per model step, after the step's provider tool results are emitted and before the loop decides
284
+ * whether the turn ends or dispatches tools; it covers success and terminal-failure messages alike. Unset on
285
+ * every local assembly; a hosted brain host sets it to commit the step durably.
286
+ */
287
+ commitStep?: StepCommitFn;
266
288
  /**
267
289
  * Called immediately before every conversational provider request, including the first.
268
290
  * Pending messages have already been appended. The returned context, model, and thinking level
@@ -324,8 +346,22 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
324
346
  * Default: "parallel"
325
347
  */
326
348
  toolExecution?: ToolExecutionMode;
327
- /** Unprepared batch boundary. Omitted selects the existing in-process legacy scheduler. */
349
+ /** Unprepared batch boundary. Omitted selects the prepared pipeline (batch coordinator + prepared executor) in this process. */
328
350
  toolHost?: ToolHost;
351
+ /**
352
+ * Opens each batch's execution ledger for the default (prepared) pipeline. The loop builds no store itself: with no
353
+ * `toolHost` and no factory, a tool batch fails closed with `BatchStoreMissingError`. The package entry's `Agent` and
354
+ * `agentLoop` default it to `openMemoryBatchStore`.
355
+ */
356
+ batchStoreFactory?: BatchStoreFactory;
357
+ /**
358
+ * Runs once per call on the prepared pipeline, after the call is frozen and before it executes, with the arguments
359
+ * object `beforeToolCall` saw and the frozen copy the tool will receive. A host whose `beforeToolCall` binds facts to
360
+ * that object (an approval, a symbol property) moves them here. Synchronous and must not throw. With no `toolHost`
361
+ * and no hook, a tool batch fails closed with `PreflightCarryMissingError`; the package entry's `Agent` and
362
+ * `agentLoop` default it to `noPreflightCarry` (senpi#5795).
363
+ */
364
+ afterToolFreeze?: (prepared: unknown, frozen: unknown) => void;
329
365
  executionScope?: ExecutionScope;
330
366
  onExecutionPipeline?: (witness: ExecutionPipelineWitness) => Promise<void> | void;
331
367
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-agent-core",
3
- "version": "2026.11.4-2",
3
+ "version": "2026.11.5-1",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -72,8 +72,8 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@earendil-works/chord": "0.99.1",
75
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.4-2",
76
- "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.11.4-2",
75
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.5-1",
76
+ "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.11.5-1",
77
77
  "diff": "9.0.0",
78
78
  "ignore": "7.0.9",
79
79
  "typebox": "1.3.34",