@peer-agent/runtime-sdk 0.1.0-rc.10 → 0.1.0-rc.11

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.
@@ -54,6 +54,8 @@ export interface RuntimePipelineModelAdapter<TInput = unknown, TState = unknown,
54
54
  initialize(input: RuntimePipelineRunInput<TInput>, context: RuntimePipelineTurnContext<TInput>): TState | Promise<TState>;
55
55
  runTurn(state: TState, context: RuntimePipelineTurnContext<TInput>): RuntimePipelineTurnResult<TState, TCall, TOutput> | Promise<RuntimePipelineTurnResult<TState, TCall, TOutput>>;
56
56
  applyToolResults(state: TState, executions: readonly RuntimePipelineToolExecution<TCall, TToolResult>[], context: RuntimePipelineTurnContext<TInput>): TState | Promise<TState>;
57
+ /** Critical durable commit after paired tool results; failure ends execution. */
58
+ checkpoint?(state: TState, executions: readonly RuntimePipelineToolExecution<TCall, TToolResult>[], context: RuntimePipelineTurnContext<TInput>): void | Promise<void>;
57
59
  onCompleted?(state: TState, output: TOutput | undefined, context: RuntimePipelineTurnContext<TInput>): void | Promise<void>;
58
60
  onStopped?(state: TState, executions: readonly RuntimePipelineToolExecution<TCall, TToolResult>[], context: RuntimePipelineTurnContext<TInput>): void | Promise<void>;
59
61
  onCancelled?(state: TState | undefined, context: RuntimePipelineTurnContext<TInput>): void | Promise<void>;
package/dist/pipeline.js CHANGED
@@ -114,6 +114,7 @@ export function createRuntimePipeline(options) {
114
114
  if (options.tools.notExecuted) {
115
115
  const denied = await Promise.all(outcome.calls.map(call => options.tools.notExecuted(call, 'max_tool_calls_exceeded')));
116
116
  state = await options.model.applyToolResults(state, denied, currentContext);
117
+ await options.model.checkpoint?.(state, denied, currentContext);
117
118
  }
118
119
  return await exhaust('max_tool_calls_exceeded');
119
120
  }
@@ -162,6 +163,7 @@ export function createRuntimePipeline(options) {
162
163
  }
163
164
  state = await options.model.applyToolResults(state, executions, currentContext);
164
165
  throwIfAborted(signal);
166
+ await options.model.checkpoint?.(state, executions, currentContext);
165
167
  try {
166
168
  await options.lifecycle?.toolResultsApplied?.(state, executions, currentContext);
167
169
  }
package/dist/runtime.js CHANGED
@@ -130,9 +130,15 @@ export function createRuntimeSdk(options) {
130
130
  decision: mostRestrictiveHookDecision(postRecords),
131
131
  records: postRecords,
132
132
  });
133
- const result = options.host.appendHookEvidence
133
+ let result = options.host.appendHookEvidence
134
134
  ? options.host.appendHookEvidence(execution.result, [...preRecords, ...postRecords], preDecision)
135
135
  : execution.result;
136
+ // Host-only sideband must survive a Hook Evidence clone without becoming
137
+ // enumerable event/storage data. Model-supplied fields cannot create it.
138
+ const sideband = Object.getOwnPropertyDescriptor(execution.result, 'modelContext');
139
+ if (result !== execution.result && sideband && sideband.enumerable === false) {
140
+ result = Object.defineProperty({ ...result }, 'modelContext', sideband);
141
+ }
136
142
  const resolvedExecution = { ...execution, result };
137
143
  emit({ type: 'tool.completed', ...eventBase, decision: preDecision, result });
138
144
  return resolvedExecution;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/runtime-sdk",
3
- "version": "0.1.0-rc.10",
3
+ "version": "0.1.0-rc.11",
4
4
  "description": "Public host-neutral orchestration SDK for Peer Agent runtimes.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "LICENSE"
35
35
  ],
36
36
  "dependencies": {
37
- "@peer-agent/protocol": "^0.1.0-rc.10",
38
- "@peer-agent/runtime-core": "^0.1.0-rc.10"
37
+ "@peer-agent/runtime-core": "^0.1.0-rc.11",
38
+ "@peer-agent/protocol": "^0.1.0-rc.11"
39
39
  },
40
40
  "devDependencies": {
41
41
  "typescript": "^5.9.3"