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

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.
@@ -13,6 +13,8 @@ export interface RuntimePipelineRunInput<TInput = unknown> {
13
13
  /** Scheduling allowance; unlike maxToolCalls this can end at a batch boundary. */
14
14
  readonly sliceToolCalls?: number;
15
15
  readonly yieldAtTurnLimit?: boolean;
16
+ /** Host scheduling request, checked at durable batch boundaries. */
17
+ readonly shouldYield?: () => boolean;
16
18
  readonly maxToolBatchCalls?: number;
17
19
  }
18
20
  export interface RuntimePipelineToolCall<TPayload = unknown> {
package/dist/pipeline.js CHANGED
@@ -81,12 +81,17 @@ export function createRuntimePipeline(options) {
81
81
  state = await options.model.initialize(input, turnContext(0));
82
82
  for (let turn = 0; turn < maxTurns; turn += 1) {
83
83
  throwIfAborted(signal);
84
+ if (input.shouldYield?.() === true)
85
+ return await yieldRun();
84
86
  turns = turn + 1;
85
87
  const currentContext = turnContext(turn);
86
88
  const outcome = await options.model.runTurn(state, currentContext);
87
89
  state = outcome.state;
88
- if (outcome.kind === 'continue')
90
+ if (outcome.kind === 'continue') {
91
+ if (input.shouldYield?.() === true)
92
+ return await yieldRun();
89
93
  continue;
94
+ }
90
95
  if (outcome.kind === 'completed') {
91
96
  await options.model.onCompleted?.(state, outcome.output, currentContext);
92
97
  if (input.streamId) {
@@ -190,7 +195,7 @@ export function createRuntimePipeline(options) {
190
195
  reason: terminalExecution.terminalReason || 'tool_requested_stop',
191
196
  };
192
197
  }
193
- if (toolCalls >= sliceToolCalls)
198
+ if (toolCalls >= sliceToolCalls || input.shouldYield?.() === true)
194
199
  return await yieldRun();
195
200
  }
196
201
  return input.yieldAtTurnLimit ? await yieldRun() : await exhaust('max_turns_exceeded');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/runtime-sdk",
3
- "version": "0.1.0-rc.11",
3
+ "version": "0.1.0-rc.13",
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/runtime-core": "^0.1.0-rc.11",
38
- "@peer-agent/protocol": "^0.1.0-rc.11"
37
+ "@peer-agent/protocol": "^0.1.0-rc.13",
38
+ "@peer-agent/runtime-core": "^0.1.0-rc.13"
39
39
  },
40
40
  "devDependencies": {
41
41
  "typescript": "^5.9.3"