@mininglamp-oss/octo-runtime 1.1.13 → 1.1.15

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 (96) hide show
  1. package/apps/cli/dist/adapters.js +1 -5
  2. package/apps/cli/dist/build-info.json +2 -2
  3. package/dist/public/protocol.d.ts +1 -1
  4. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  5. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +19 -4
  6. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -29
  7. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  8. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +0 -1
  9. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  10. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +23 -24
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +1 -2
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +25 -30
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +0 -2
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-RIZUXNZ2.js} +115 -40
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +2 -6
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +9 -9
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.d.ts +5 -2
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +0 -2
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +8 -18
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +1 -12
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +16 -2
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +1 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +16 -2
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +1 -2
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +16 -2
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +1 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +0 -4
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +2 -3
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +6 -3
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +16 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +1 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -2
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +1 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -3
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +2 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +6 -28
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +0 -2
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +2 -7
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +1 -5
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  65. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
  66. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
  67. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +2 -2
  68. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +42 -624
  69. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  70. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +97 -12
  71. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +189 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +0 -1
  74. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +3 -4
  75. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  76. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
  77. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  78. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
  79. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +1 -5
  80. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +0 -3
  81. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +1 -26
  82. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +3 -12
  84. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +16 -240
  85. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -5
  86. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +2 -12
  87. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +0 -12
  88. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  89. package/package.json +24 -24
  90. package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -624
  91. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
  92. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
  93. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
  94. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
  95. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
  96. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
@@ -2,7 +2,7 @@ import {
2
2
  DshError,
3
3
  nativeCode,
4
4
  record
5
- } from "./chunk-H3S6WM37.js";
5
+ } from "./chunk-NGR74QLF.js";
6
6
 
7
7
  // packages/octo-runtime-adapter-dsh/dist/trajectory.js
8
8
  import { createHash } from "node:crypto";
@@ -33,7 +33,10 @@ var DshTrajectory = class {
33
33
  #receipts = /* @__PURE__ */ new Set();
34
34
  #lastReason;
35
35
  #lastNativeCode;
36
- #lastAnswer = false;
36
+ // 原生 commit 早于工具执行,甚至早于后续 turn。只暂存一个 root 候选,发布后不改分类。
37
+ #pendingText = [];
38
+ #pendingBytes = 0;
39
+ #pendingStep;
37
40
  #objects = 0;
38
41
  constructor(sessionId, maxTextBytes) {
39
42
  this.sessionId = sessionId;
@@ -51,26 +54,53 @@ var DshTrajectory = class {
51
54
  const parentSessionId = this.#sessions.get(sessionId)?.parent;
52
55
  return { providerSessionId: sessionId, ...parentSessionId ? { parentSessionId } : {} };
53
56
  }
57
+ #flushText(channel) {
58
+ const events = this.#pendingText.map((value) => event(value.type, { ...value.payload, channel }));
59
+ this.#pendingText = [];
60
+ this.#pendingBytes = 0;
61
+ return events;
62
+ }
63
+ #settleStep(channel, status) {
64
+ const output = this.#flushText(channel);
65
+ if (this.#pendingStep) {
66
+ const value = this.#pendingStep.event;
67
+ output.push(event(value.type, {
68
+ ...value.payload,
69
+ ...status ? { status } : {},
70
+ ...channel === "final" ? { finishReason: "stop" } : {}
71
+ }));
72
+ this.#pendingStep = void 0;
73
+ }
74
+ return output;
75
+ }
54
76
  accept(notification) {
55
77
  const { method, params } = notification;
56
78
  if (method === "subagent.started") {
57
- if (!this.#sessions.has(String(params.parentSessionId)))
79
+ const parent = this.#sessions.get(String(params.parentSessionId));
80
+ if (!parent || parent.activity?.finished)
58
81
  return [];
59
82
  required(identifier(params.childSessionId) && identifier(params.parentSessionId));
60
83
  const child = this.#sessions.get(params.childSessionId);
84
+ let generation = 0;
61
85
  if (child) {
62
86
  required(child.parent === params.parentSessionId);
63
- return [];
87
+ if (!child.activity?.finished)
88
+ return [];
89
+ this.#bound();
90
+ generation = child.activity.generation + 1;
91
+ child.activity = { generation, finished: false };
92
+ } else {
93
+ required(this.#sessions.size < 128 && params.childSessionId !== this.sessionId);
94
+ this.#sessions.set(params.childSessionId, {
95
+ parent: params.parentSessionId,
96
+ seq: -1,
97
+ digest: "",
98
+ activity: { generation, finished: false }
99
+ });
64
100
  }
65
- required(this.#sessions.size < 128 && params.childSessionId !== this.sessionId);
66
- this.#sessions.set(params.childSessionId, {
67
- parent: params.parentSessionId,
68
- seq: -1,
69
- digest: ""
70
- });
71
101
  return [
72
102
  event("activity.started", {
73
- activityId: this.#id(params.childSessionId, "agent", 0),
103
+ activityId: this.#id(params.childSessionId, "agent", generation),
74
104
  kind: "working",
75
105
  subject: { type: "run" },
76
106
  source: "provider",
@@ -85,12 +115,15 @@ var DshTrajectory = class {
85
115
  }
86
116
  if (method === "subagent.finished") {
87
117
  const child = typeof params.childSessionId === "string" ? this.#sessions.get(params.childSessionId) : void 0;
88
- if (!child)
118
+ if (!child?.activity)
89
119
  return [];
90
120
  required(child.parent === params.parentSessionId && ["ok", "error"].includes(String(params.status)));
121
+ if (child.activity.finished)
122
+ return [];
123
+ child.activity.finished = true;
91
124
  return [
92
125
  event("activity.finished", {
93
- activityId: this.#id(String(params.childSessionId), "agent", 0),
126
+ activityId: this.#id(String(params.childSessionId), "agent", child.activity.generation),
94
127
  status: params.status === "ok" ? "completed" : "failed"
95
128
  })
96
129
  ];
@@ -100,7 +133,7 @@ var DshTrajectory = class {
100
133
  required(identifier(params.sessionId));
101
134
  const sessionId = params.sessionId;
102
135
  const state = this.#sessions.get(sessionId);
103
- if (!state)
136
+ if (!state || state.activity?.finished)
104
137
  return [];
105
138
  const source = params.event;
106
139
  required(record(source) && identifier(source.type) && integer(source.seq) && integer(source.time) && record(source.data));
@@ -132,8 +165,8 @@ var DshTrajectory = class {
132
165
  required(integer(data.turn) && !this.#turns.has(sessionId));
133
166
  this.#turns.set(sessionId, data.turn);
134
167
  if (sessionId === this.sessionId) {
168
+ output.push(...this.#settleStep("commentary"));
135
169
  this.#lastReason = void 0;
136
- this.#lastAnswer = false;
137
170
  }
138
171
  output.push(event("activity.started", {
139
172
  activityId: this.#id(sessionId, "turn", data.turn),
@@ -147,21 +180,38 @@ var DshTrajectory = class {
147
180
  case "step/start":
148
181
  required(integer(data.turn) && integer(data.step) && this.#turns.get(sessionId) === data.turn && !this.#steps.has(sessionId));
149
182
  this.#bound();
150
- this.#steps.set(sessionId, stepId);
183
+ if (sessionId === this.sessionId)
184
+ output.push(...this.#settleStep("commentary"));
185
+ this.#steps.set(sessionId, {
186
+ id: stepId,
187
+ tools: false,
188
+ committed: false,
189
+ answer: false,
190
+ interrupted: false
191
+ });
151
192
  output.push(event("model_step.started", { stepId, startedAtMs: source.time, ...lineage }));
152
193
  break;
153
- case "step/end":
154
- required(this.#steps.get(sessionId) === stepId);
194
+ case "step/end": {
195
+ const step = this.#steps.get(sessionId);
196
+ required(step?.id === stepId && !this.#messages.has(sessionId));
197
+ required(![...this.#tools.values()].some((tool) => tool.stepId === stepId));
155
198
  this.#steps.delete(sessionId);
156
- output.push(event("model_step.finished", {
199
+ const finished = event("model_step.finished", {
157
200
  stepId,
158
- status: "completed",
201
+ status: step.interrupted ? "cancelled" : "completed",
202
+ ...step.tools ? { finishReason: "tool-calls" } : {},
159
203
  endedAtMs: source.time,
160
204
  ...lineage
161
- }));
205
+ });
206
+ if (sessionId === this.sessionId && !step.tools)
207
+ this.#pendingStep = { event: finished, answer: step.answer && !step.interrupted };
208
+ else
209
+ output.push(finished);
162
210
  break;
211
+ }
163
212
  case "assistant/chunk": {
164
- required(this.#steps.get(sessionId) === stepId && record(data.chunk));
213
+ const step = this.#steps.get(sessionId);
214
+ required(step?.id === stepId && !step.committed && record(data.chunk));
165
215
  const chunk = data.chunk;
166
216
  if (chunk.type !== "text-delta")
167
217
  break;
@@ -182,7 +232,8 @@ var DshTrajectory = class {
182
232
  break;
183
233
  }
184
234
  case "assistant/message": {
185
- required(this.#steps.get(sessionId) === stepId && record(data.message) && Array.isArray(data.message.content));
235
+ const step = this.#steps.get(sessionId);
236
+ required(step?.id === stepId && !step.committed && record(data.message) && Array.isArray(data.message.content));
186
237
  const blocks = data.message.content;
187
238
  required(blocks.every((block) => record(block) && typeof block.type === "string"));
188
239
  const text = blocks.filter((block) => block.type === "text").map((block) => {
@@ -197,7 +248,7 @@ var DshTrajectory = class {
197
248
  if (reasoning) {
198
249
  required(Buffer.byteLength(reasoning) <= this.maxTextBytes);
199
250
  const analysis = {
200
- id: this.#id(sessionId, "analysis", source.seq),
251
+ messageId: this.#id(sessionId, "analysis", source.seq),
201
252
  role: "assistant",
202
253
  channel: "analysis",
203
254
  exposure: "private_reasoning",
@@ -215,20 +266,24 @@ var DshTrajectory = class {
215
266
  status: "streaming"
216
267
  }));
217
268
  let sent = existing?.text ?? "";
218
- if (!existing && data.stream !== void 0) {
269
+ if (data.stream !== void 0) {
219
270
  required(Array.isArray(data.stream));
271
+ let recorded = "";
220
272
  for (const part of data.stream) {
221
273
  required(record(part) && typeof part.type === "string");
222
274
  if (part.type !== "text-chunks")
223
275
  continue;
224
276
  required(Array.isArray(part.texts) && part.texts.every((item) => typeof item === "string"));
225
277
  for (const delta of part.texts) {
226
- sent += delta;
227
- required(Buffer.byteLength(sent) <= this.maxTextBytes);
228
- if (delta)
278
+ recorded += delta;
279
+ required(Buffer.byteLength(recorded) <= this.maxTextBytes);
280
+ if (!existing && delta)
229
281
  output.push(this.#messageEvent("message.delta", messageId, sessionId, stepId, { text: delta }));
230
282
  }
231
283
  }
284
+ required(text.startsWith(recorded));
285
+ if (!existing)
286
+ sent = recorded;
232
287
  }
233
288
  required(text.startsWith(sent));
234
289
  if (text.length > sent.length)
@@ -241,8 +296,9 @@ var DshTrajectory = class {
241
296
  }));
242
297
  this.#messages.delete(sessionId);
243
298
  this.#bound();
244
- if (sessionId === this.sessionId)
245
- this.#lastAnswer = text.trim().length > 0 && data.interrupted !== true;
299
+ step.committed = true;
300
+ step.answer = text.trim().length > 0;
301
+ step.interrupted = data.interrupted === true;
246
302
  if (record(data.usage)) {
247
303
  const usage = Object.fromEntries(Object.entries(data.usage).filter(([, value]) => integer(value)));
248
304
  if (Object.keys(usage).length)
@@ -259,12 +315,15 @@ var DshTrajectory = class {
259
315
  throw new DshError("DSH_TRAJECTORY_INVALID");
260
316
  }
261
317
  }
262
- required(this.#steps.get(sessionId) === stepId && identifier(data.callId) && identifier(data.name) && record(args));
318
+ required(this.#steps.get(sessionId)?.id === stepId && this.#steps.get(sessionId)?.committed && identifier(data.callId) && identifier(data.name) && record(args));
263
319
  const key = `${sessionId}\0${data.callId}`;
264
320
  required(!this.#tools.has(key));
265
321
  this.#bound();
266
322
  const id = this.#id(sessionId, "tool", hash(data.callId));
267
- this.#tools.set(key, { id, sessionId, time: source.time });
323
+ this.#tools.set(key, { id, stepId, time: source.time });
324
+ this.#steps.get(sessionId).tools = true;
325
+ if (sessionId === this.sessionId)
326
+ output.push(...this.#flushText("commentary"));
268
327
  output.push(event("tool_call.create", {
269
328
  id,
270
329
  name: data.name,
@@ -279,7 +338,7 @@ var DshTrajectory = class {
279
338
  required(record(data.message) && identifier(data.message.toolCallId));
280
339
  const key = `${sessionId}\0${data.message.toolCallId}`;
281
340
  const tool = this.#tools.get(key);
282
- required(tool && this.#steps.get(sessionId) === stepId && Array.isArray(data.message.content));
341
+ required(tool && tool.stepId === stepId && this.#steps.get(sessionId)?.id === stepId && Array.isArray(data.message.content));
283
342
  required(data.message.isError === void 0 || typeof data.message.isError === "boolean");
284
343
  this.#tools.delete(key);
285
344
  output.push(event("tool_call.update", {
@@ -295,10 +354,13 @@ var DshTrajectory = class {
295
354
  case "turn/end": {
296
355
  required(integer(data.turn) && this.#turns.get(sessionId) === data.turn && record(data.reason) && ["completed", "error", "aborted", "max-tokens"].includes(String(data.reason.kind)));
297
356
  this.#turns.delete(sessionId);
357
+ required(!this.#steps.has(sessionId) && !this.#messages.has(sessionId));
298
358
  if (sessionId === this.sessionId) {
299
359
  this.#lastReason = String(data.reason.kind);
300
360
  const code = record(data.reason.error) ? nativeCode(data.reason.error.code) : void 0;
301
361
  this.#lastNativeCode = code;
362
+ if (data.reason.kind !== "completed")
363
+ output.push(...this.#settleStep("commentary", data.reason.kind === "aborted" ? "cancelled" : "failed"));
302
364
  }
303
365
  output.push(event("activity.finished", {
304
366
  activityId: this.#id(sessionId, "turn", data.turn),
@@ -308,30 +370,43 @@ var DshTrajectory = class {
308
370
  break;
309
371
  }
310
372
  }
311
- return output;
373
+ if (source.type !== "assistant/chunk" && source.type !== "assistant/message")
374
+ return output;
375
+ return output.filter((value) => {
376
+ if (!value.type.startsWith("message.") || value.payload.channel !== "commentary" || value.payload.providerSessionId !== this.sessionId || this.#steps.get(sessionId)?.tools)
377
+ return true;
378
+ required(this.#pendingText.length < 4096);
379
+ this.#pendingBytes += Buffer.byteLength(value.payload.text ?? "");
380
+ required(this.#pendingBytes <= this.maxTextBytes);
381
+ this.#pendingText.push(value);
382
+ return false;
383
+ });
312
384
  }
313
385
  #messageEvent(type, id, sessionId, stepId, data) {
314
386
  return event(type, {
315
- id,
316
- channel: sessionId === this.sessionId ? "final" : "commentary",
387
+ messageId: id,
388
+ channel: "commentary",
317
389
  stepId,
318
390
  ...this.#lineage(sessionId),
319
391
  ...data
320
392
  });
321
393
  }
322
- /** wait 只证明 idle;receipt、durable terminal 和已提交回答分别验证。 */
394
+ /**
395
+ * wait 只证明 idle;receipt、durable terminal 和已提交回答分别验证。
396
+ * 返回已确认的正文/步骤与尾部 run 终态;调用方仍须等资源清理后再发布尾项。
397
+ */
323
398
  finish(receiptId) {
324
399
  if (!this.#receipts.has(receiptId) || !this.#lastReason || this.#turns.size || this.#steps.size || this.#tools.size || this.#messages.size)
325
400
  throw new DshError("DSH_TRAJECTORY_INVALID");
326
401
  if (this.#lastReason === "aborted")
327
- return event("run.cancelled", { reason: "provider_aborted" });
402
+ return [event("run.cancelled", { reason: "provider_aborted" })];
328
403
  if (this.#lastReason !== "completed")
329
404
  throw new DshError("DSH_EXECUTION_FAILED", {
330
405
  ...this.#lastNativeCode === void 0 ? {} : { nativeCode: this.#lastNativeCode }
331
406
  });
332
- if (!this.#lastAnswer)
407
+ if (!this.#pendingStep?.answer)
333
408
  throw new DshError("DSH_NO_FINAL_OUTPUT");
334
- return event("run.completed", {});
409
+ return [...this.#settleStep("final"), event("run.completed", {})];
335
410
  }
336
411
  };
337
412
 
@@ -3,7 +3,7 @@ import {
3
3
  DshError,
4
4
  dshError,
5
5
  nativeCode
6
- } from "./chunk-H3S6WM37.js";
6
+ } from "./chunk-NGR74QLF.js";
7
7
 
8
8
  // packages/octo-runtime-adapter-dsh/dist/launch.js
9
9
  import { spawn } from "node:child_process";
@@ -3,7 +3,6 @@ export declare const DSH_MIN_VERSION = "0.2.1-rc.4";
3
3
  export declare const DSH_VERSION = "0.2.1-rc.4";
4
4
  declare const messages: {
5
5
  readonly DSH_CONFIG_INVALID: "DeepSeek Harness configuration is invalid for this invocation.";
6
- readonly DSH_ACTMODE_UNSUPPORTED: "DeepSeek Harness supports only the default actmode.";
7
6
  readonly PROVIDER_MESSAGE_TOO_LARGE: "DeepSeek Harness protocol line exceeded the configured limit.";
8
7
  readonly STREAM_QUEUE_ITEM_TOO_LARGE: "DeepSeek Harness event exceeded the configured queue item limit.";
9
8
  readonly STREAM_QUEUE_BYTES_EXCEEDED: "DeepSeek Harness event queue exceeded the configured byte limit.";
@@ -5,7 +5,7 @@ import {
5
5
  dshError,
6
6
  nativeCode,
7
7
  record
8
- } from "./chunk-H3S6WM37.js";
8
+ } from "./chunk-NGR74QLF.js";
9
9
  export {
10
10
  DSH_MIN_VERSION,
11
11
  DSH_VERSION,
@@ -12,7 +12,6 @@ export interface DshAdapterOptions {
12
12
  export declare function createDshAdapter(options?: DshAdapterOptions): Readonly<Omit<{
13
13
  metadata: {
14
14
  type: string;
15
- agentSources: "provisioned"[];
16
15
  };
17
16
  probe(probeOptions?: {
18
17
  providerOptions?: Record<string, string>;
@@ -24,7 +23,7 @@ export declare function createDshAdapter(options?: DshAdapterOptions): Readonly<
24
23
  } | {
25
24
  available: false;
26
25
  command: string;
27
- reason: "DSH_CONFIG_INVALID" | "DSH_ACTMODE_UNSUPPORTED" | "PROVIDER_MESSAGE_TOO_LARGE" | "STREAM_QUEUE_ITEM_TOO_LARGE" | "STREAM_QUEUE_BYTES_EXCEEDED" | "STREAM_QUEUE_ITEMS_EXCEEDED" | "DSH_EXECUTABLE_NOT_FOUND" | "DSH_VERSION_UNSUPPORTED" | "DSH_START_FAILED" | "DSH_INITIALIZE_TIMEOUT" | "DSH_RPC_ERROR" | "DSH_REQUEST_TIMEOUT" | "DSH_TRANSPORT_CLOSED" | "DSH_PROTOCOL_ERROR" | "DSH_TRAJECTORY_INVALID" | "DSH_SESSION_RESUME_FAILED" | "DSH_SESSION_BUSY" | "DSH_EXECUTION_FAILED" | "DSH_NO_FINAL_OUTPUT" | "DSH_CANCEL_FAILED" | "DSH_CLEANUP_FAILED";
26
+ reason: "DSH_CONFIG_INVALID" | "PROVIDER_MESSAGE_TOO_LARGE" | "STREAM_QUEUE_ITEM_TOO_LARGE" | "STREAM_QUEUE_BYTES_EXCEEDED" | "STREAM_QUEUE_ITEMS_EXCEEDED" | "DSH_EXECUTABLE_NOT_FOUND" | "DSH_VERSION_UNSUPPORTED" | "DSH_START_FAILED" | "DSH_INITIALIZE_TIMEOUT" | "DSH_RPC_ERROR" | "DSH_REQUEST_TIMEOUT" | "DSH_TRANSPORT_CLOSED" | "DSH_PROTOCOL_ERROR" | "DSH_TRAJECTORY_INVALID" | "DSH_SESSION_RESUME_FAILED" | "DSH_SESSION_BUSY" | "DSH_EXECUTION_FAILED" | "DSH_NO_FINAL_OUTPUT" | "DSH_CANCEL_FAILED" | "DSH_CLEANUP_FAILED";
28
27
  version?: undefined;
29
28
  }>;
30
29
  invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
@@ -32,7 +31,6 @@ export declare function createDshAdapter(options?: DshAdapterOptions): Readonly<
32
31
  readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
33
32
  metadata: Omit<{
34
33
  type: string;
35
- agentSources: "provisioned"[];
36
34
  }, "protocolSupport"> & {
37
35
  protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
38
36
  };
@@ -40,7 +38,6 @@ export declare function createDshAdapter(options?: DshAdapterOptions): Readonly<
40
38
  export declare const dshAdapter: Readonly<Omit<{
41
39
  metadata: {
42
40
  type: string;
43
- agentSources: "provisioned"[];
44
41
  };
45
42
  probe(probeOptions?: {
46
43
  providerOptions?: Record<string, string>;
@@ -52,7 +49,7 @@ export declare const dshAdapter: Readonly<Omit<{
52
49
  } | {
53
50
  available: false;
54
51
  command: string;
55
- reason: "DSH_CONFIG_INVALID" | "DSH_ACTMODE_UNSUPPORTED" | "PROVIDER_MESSAGE_TOO_LARGE" | "STREAM_QUEUE_ITEM_TOO_LARGE" | "STREAM_QUEUE_BYTES_EXCEEDED" | "STREAM_QUEUE_ITEMS_EXCEEDED" | "DSH_EXECUTABLE_NOT_FOUND" | "DSH_VERSION_UNSUPPORTED" | "DSH_START_FAILED" | "DSH_INITIALIZE_TIMEOUT" | "DSH_RPC_ERROR" | "DSH_REQUEST_TIMEOUT" | "DSH_TRANSPORT_CLOSED" | "DSH_PROTOCOL_ERROR" | "DSH_TRAJECTORY_INVALID" | "DSH_SESSION_RESUME_FAILED" | "DSH_SESSION_BUSY" | "DSH_EXECUTION_FAILED" | "DSH_NO_FINAL_OUTPUT" | "DSH_CANCEL_FAILED" | "DSH_CLEANUP_FAILED";
52
+ reason: "DSH_CONFIG_INVALID" | "PROVIDER_MESSAGE_TOO_LARGE" | "STREAM_QUEUE_ITEM_TOO_LARGE" | "STREAM_QUEUE_BYTES_EXCEEDED" | "STREAM_QUEUE_ITEMS_EXCEEDED" | "DSH_EXECUTABLE_NOT_FOUND" | "DSH_VERSION_UNSUPPORTED" | "DSH_START_FAILED" | "DSH_INITIALIZE_TIMEOUT" | "DSH_RPC_ERROR" | "DSH_REQUEST_TIMEOUT" | "DSH_TRANSPORT_CLOSED" | "DSH_PROTOCOL_ERROR" | "DSH_TRAJECTORY_INVALID" | "DSH_SESSION_RESUME_FAILED" | "DSH_SESSION_BUSY" | "DSH_EXECUTION_FAILED" | "DSH_NO_FINAL_OUTPUT" | "DSH_CANCEL_FAILED" | "DSH_CLEANUP_FAILED";
56
53
  version?: undefined;
57
54
  }>;
58
55
  invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
@@ -60,7 +57,6 @@ export declare const dshAdapter: Readonly<Omit<{
60
57
  readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
61
58
  metadata: Omit<{
62
59
  type: string;
63
- agentSources: "provisioned"[];
64
60
  }, "protocolSupport"> & {
65
61
  protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
66
62
  };
@@ -2,10 +2,10 @@ import {
2
2
  resolveDshLaunch,
3
3
  stringOption,
4
4
  timeoutOption
5
- } from "./chunk-RISQ6NGV.js";
5
+ } from "./chunk-XIUZ6GXG.js";
6
6
  import {
7
7
  DshTrajectory
8
- } from "./chunk-SMTJTIN7.js";
8
+ } from "./chunk-RIZUXNZ2.js";
9
9
  import {
10
10
  DSH_MIN_VERSION,
11
11
  DSH_VERSION,
@@ -13,14 +13,14 @@ import {
13
13
  HarnessClient,
14
14
  dshError,
15
15
  record
16
- } from "./chunk-H3S6WM37.js";
16
+ } from "./chunk-NGR74QLF.js";
17
17
 
18
18
  // packages/octo-runtime-adapter-dsh/dist/index.js
19
19
  import { invocationOption, invocationProviderOptions, invocationModel, invocationApprovalMode, invocationRuntimeLimits, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
20
20
  import { randomUUID } from "node:crypto";
21
21
  import { realpath } from "node:fs/promises";
22
22
  import { defineAdapter, invocationEnvironment, providerInputParts, DriverQueue, noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
23
- import { contextActmode, DEFAULT_STREAM_LIMIT_POLICY, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
23
+ import { DEFAULT_STREAM_LIMIT_POLICY, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
24
24
  function failureEvent(error, diagnostics) {
25
25
  return {
26
26
  protocolVersion: 2,
@@ -38,7 +38,7 @@ function createDshAdapter(options = {}) {
38
38
  const sessions = /* @__PURE__ */ new Set();
39
39
  const log = options.log ?? noopRuntimeLog;
40
40
  return defineAdapter({
41
- metadata: { type: "dsh", agentSources: ["provisioned"] },
41
+ metadata: { type: "dsh" },
42
42
  async probe(probeOptions) {
43
43
  try {
44
44
  const launch = await resolveDshLaunch(probeOptions?.providerOptions ?? {}, {
@@ -61,9 +61,6 @@ function createDshAdapter(options = {}) {
61
61
  let sessionId;
62
62
  let requestedId;
63
63
  try {
64
- const actmode = contextActmode(request.agentEnv);
65
- if (actmode !== void 0 && actmode !== "default")
66
- throw new DshError("DSH_ACTMODE_UNSUPPORTED");
67
64
  if (invocationOption(request, "sandbox", "dsh") !== void 0 && invocationOption(request, "sandbox", "dsh") !== "danger-full-access")
68
65
  throw new DshError("DSH_CONFIG_INVALID");
69
66
  const configured = invocationProviderOptions(request, "dsh") ?? {};
@@ -232,7 +229,10 @@ function createDshAdapter(options = {}) {
232
229
  receiptId = receipt;
233
230
  phase = "wait";
234
231
  await owned.request("session/wait", { sessionId }, runTimeoutMs);
235
- terminal = trajectory.finish(receiptId);
232
+ const finished = trajectory.finish(receiptId);
233
+ terminal = finished.pop();
234
+ for (const value of finished)
235
+ queue.push(value);
236
236
  queue.close();
237
237
  } catch (error) {
238
238
  const failure = dshError(error, "DSH_EXECUTION_FAILED");
@@ -3,8 +3,8 @@ import {
3
3
  resolveDshLaunch,
4
4
  stringOption,
5
5
  timeoutOption
6
- } from "./chunk-RISQ6NGV.js";
7
- import "./chunk-H3S6WM37.js";
6
+ } from "./chunk-XIUZ6GXG.js";
7
+ import "./chunk-NGR74QLF.js";
8
8
  export {
9
9
  DSH_PROCESS_GRACE_MS,
10
10
  resolveDshLaunch,
@@ -7,6 +7,9 @@ export declare class DshTrajectory {
7
7
  private readonly maxTextBytes;
8
8
  constructor(sessionId: string, maxTextBytes: number);
9
9
  accept(notification: HarnessNotification): CanonicalEvent[];
10
- /** wait 只证明 idle;receipt、durable terminal 和已提交回答分别验证。 */
11
- finish(receiptId: string): CanonicalEvent;
10
+ /**
11
+ * wait 只证明 idle;receipt、durable terminal 和已提交回答分别验证。
12
+ * 返回已确认的正文/步骤与尾部 run 终态;调用方仍须等资源清理后再发布尾项。
13
+ */
14
+ finish(receiptId: string): CanonicalEvent[];
12
15
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DshTrajectory
3
- } from "./chunk-SMTJTIN7.js";
4
- import "./chunk-H3S6WM37.js";
3
+ } from "./chunk-RIZUXNZ2.js";
4
+ import "./chunk-NGR74QLF.js";
5
5
  export {
6
6
  DshTrajectory
7
7
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-dsh",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "semver": "7.8.6",
13
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13",
14
- "@mininglamp-oss/octo-runtime-protocol": "1.1.13"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.15",
14
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.15"
15
15
  }
16
16
  }
@@ -1,7 +1,6 @@
1
1
  import type { AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { spawnGrokBuildAcpClient as spawnAcpClient, type SpawnGrokBuildClientOptions as SpawnAcpClientOptions } from "./client.js";
3
3
  import { GrokBuildInteractionBridge as AcpApprovalBridge } from "./interactions.js";
4
- import { acpActmodeSelectionRequest } from "@mininglamp-oss/octo-runtime-adapter-acp";
5
4
  import { type AcpClient, type AcpUpdate } from "@mininglamp-oss/octo-runtime-acp-client";
6
5
  import { type ProbeResult, type ReasoningLevelMap, type AdapterInvocationContext, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
7
6
  import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
@@ -21,7 +20,6 @@ export interface AcpAdapterDefinition {
21
20
  sessionParams?: (params: JsonRecord, request: InvokeRequest, fresh: boolean) => JsonRecord;
22
21
  isMissingSessionError?: (error: unknown) => boolean;
23
22
  configureSession?: (client: AcpClient, session: JsonRecord, sessionId: string, request: InvokeRequest) => AsyncIterable<CanonicalEvent>;
24
- selectActmode?: typeof acpActmodeSelectionRequest;
25
23
  reasoningLevels?: ReasoningLevelMap;
26
24
  clientOptions?: (request: InvokeRequest, bridge: AcpApprovalBridge) => Pick<SpawnAcpClientOptions, "requestHandler" | "onRequestResponseWritten" | "onRequestResponseFailed">;
27
25
  validatePromptResult?: (update: StandardAcpUpdate) => CanonicalEvent[];
@@ -1,10 +1,11 @@
1
+ import { grokModeId } from "./agent-env.js";
1
2
  import { invocationModel, invocationApprovalMode, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
3
  import { spawnGrokBuildAcpClient as spawnAcpClient } from "./client.js";
3
4
  import { GrokBuildInteractionBridge as AcpApprovalBridge } from "./interactions.js";
4
- import { acpModelSelectionRequest, acpActmodeSelectionRequest, normalizeAcpUpdate } from "@mininglamp-oss/octo-runtime-adapter-acp";
5
+ import { acpModelSelectionRequest, normalizeAcpUpdate } from "@mininglamp-oss/octo-runtime-adapter-acp";
5
6
  import { acpLoadSessionParams, acpNewSessionParams, acpPromptParams } from "@mininglamp-oss/octo-runtime-acp-client";
6
- import { actmodeEvidence, AcpTurnNormalizer, defineAdapter, invocationEnvironment, invocationMcpServers, assertMcpOptions, probeCommand, snapshotProviderLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk";
7
- import { canonicalTerminalStatus, contextActmode, providerInputParts } from "@mininglamp-oss/octo-runtime-protocol";
7
+ import { AcpTurnNormalizer, defineAdapter, invocationEnvironment, invocationMcpServers, assertMcpOptions, probeCommand, snapshotProviderLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk";
8
+ import { canonicalTerminalStatus, providerInputParts } from "@mininglamp-oss/octo-runtime-protocol";
8
9
  function sessionModel(session) {
9
10
  const modelOption = arrayField(session, "configOptions")
10
11
  .map(recordValue)
@@ -21,8 +22,7 @@ export function createGrokBuildAcpAdapter(definition, { acpClientFactory = spawn
21
22
  return defineAdapter({
22
23
  metadata: definition.metadata ?? {
23
24
  mcp: true,
24
- type: definition.type,
25
- agentSources: ["provisioned"]
25
+ type: definition.type
26
26
  },
27
27
  probe: definition.probe ??
28
28
  (acpClientFactory === spawnAcpClient
@@ -168,20 +168,10 @@ export function createGrokBuildAcpAdapter(definition, { acpClientFactory = spawn
168
168
  : (requestedSessionId ?? stringField(sessionResult, "sessionId"));
169
169
  if (!sessionId)
170
170
  throw new Error("ACP session/new returned no sessionId");
171
- const requestedMode = contextActmode(request.agentEnv);
171
+ const requestedMode = grokModeId(request);
172
172
  if (requestedMode !== undefined) {
173
- const selection = (definition.selectActmode ?? acpActmodeSelectionRequest)(sessionResult, sessionId, requestedMode);
174
- if (!selection.unchanged)
175
- await client.request(selection.method, selection.params);
176
- yield actmodeEvidence({
177
- requested: requestedMode,
178
- effective: selection.effective,
179
- nativeMode: selection.nativeMode,
180
- status: selection.effective === requestedMode ? "applied" : "fallback",
181
- ...(selection.effective !== requestedMode
182
- ? { reason: "provider_unsupported" }
183
- : {})
184
- });
173
+ // Grok 原生实现 set_mode 但不广告 modes;此约定仅在本包生效。
174
+ await client.request("session/set_mode", { sessionId, modeId: requestedMode });
185
175
  }
186
176
  const requestedModel = nonEmptyString(invocationModel(request));
187
177
  if (requestedModel) {
@@ -0,0 +1,3 @@
1
+ import { type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ /** 只读本轮私有 item;省略不补模式,非法显式值在原生映射前拒绝。 */
3
+ export declare function grokModeId(request: InvokeRequest): "default" | "plan" | undefined;
@@ -0,0 +1,10 @@
1
+ import { agentEnvItem } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ /** 只读本轮私有 item;省略不补模式,非法显式值在原生映射前拒绝。 */
3
+ export function grokModeId(request) {
4
+ const value = agentEnvItem(request.agentEnv, "adapter.grok-build", "options")?.modeId;
5
+ if (value === undefined)
6
+ return undefined;
7
+ if (value !== "default" && value !== "plan")
8
+ throw new TypeError("ADAPTER_OPTION_INVALID: grok-build.modeId");
9
+ return value;
10
+ }
@@ -5,8 +5,7 @@ import { invocationEnvironment, invocationMcpServers, probeCommand, snapshotProv
5
5
  export const GROK_BUILD_TESTED_VERSION = "1.0.67";
6
6
  export const grokBuildMetadata = {
7
7
  type: "grok-build",
8
- mcp: true,
9
- agentSources: ["provisioned"]
8
+ mcp: true
10
9
  };
11
10
  const levels = { low: "low", medium: "medium", high: "high", xhigh: "xhigh" };
12
11
  function supportedVersion(version) {
@@ -76,16 +75,6 @@ export function createGrokBuildAdapter({ command, acpClientFactory = spawnGrokBu
76
75
  isMissingSessionError: (error) => error instanceof GrokBuildRpcError &&
77
76
  error.code === -32603 &&
78
77
  record(error.data).code === "FS_NOT_FOUND",
79
- selectActmode(_session, sessionId, requested) {
80
- // 1.0.67 不发布 modes,但实现标准 set_mode(default/plan);成功响应后才发布 applied。
81
- return {
82
- method: "session/set_mode",
83
- params: { sessionId, modeId: requested },
84
- effective: requested,
85
- nativeMode: requested,
86
- unchanged: false
87
- };
88
- },
89
78
  async *configureSession(client, session, sessionId, request) {
90
79
  const requested = invocationEffort(request);
91
80
  if (requested === undefined)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-grok-build",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,9 +9,9 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.13",
13
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.13",
14
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13",
15
- "@mininglamp-oss/octo-runtime-protocol": "1.1.13"
12
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.15",
13
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.15",
14
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.15",
15
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.15"
16
16
  }
17
17
  }