@mininglamp-oss/octo-runtime 1.1.12 → 1.1.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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/apps/cli/dist/adapters.d.ts +19 -1
  3. package/apps/cli/dist/adapters.js +153 -23
  4. package/apps/cli/dist/build-info.json +2 -2
  5. package/apps/cli/dist/codex.d.ts +5 -0
  6. package/apps/cli/dist/codex.js +36 -0
  7. package/apps/cli/dist/kernel.d.ts +4 -0
  8. package/apps/cli/dist/kernel.js +84 -0
  9. package/apps/cli/dist/main.js +8 -7
  10. package/apps/cli/dist/manifest.json +33 -22
  11. package/apps/cli/dist/output.d.ts +1 -0
  12. package/apps/cli/dist/output.js +8 -4
  13. package/apps/cli/dist/playboard.js +21 -12
  14. package/apps/cli/dist/provider-launch.d.ts +28 -0
  15. package/apps/cli/dist/provider-launch.js +52 -0
  16. package/apps/cli/dist/providers.d.ts +182 -0
  17. package/apps/cli/dist/providers.js +34 -0
  18. package/dist/public/adapter-sdk.d.ts +2 -0
  19. package/dist/public/adapter-sdk.js +2 -0
  20. package/dist/public/protocol.d.ts +1 -1
  21. package/dist/public/protocol.js +1 -1
  22. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
  23. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +15 -14
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -28
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +22 -29
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +60 -43
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -31
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +29 -18
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -5
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +32 -26
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +104 -216
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +4 -2
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +12 -14
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +14 -14
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +23 -30
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +48 -26
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +16 -14
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +15 -7
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +16 -14
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +14 -6
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +16 -14
  64. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +15 -7
  65. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  66. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +7 -3
  67. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +27 -29
  68. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  69. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
  70. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +109 -178
  71. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  72. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +16 -14
  73. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +15 -6
  74. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
  75. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -14
  76. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +15 -6
  77. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
  78. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
  79. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +49 -0
  80. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +256 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
  82. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
  83. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
  84. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -12
  85. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +116 -58
  86. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
  87. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
  88. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
  89. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
  92. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  93. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
  94. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +153 -23
  95. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  96. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
  98. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
  99. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
  101. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
  102. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
  104. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
  105. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
  106. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
  107. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
  108. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
  109. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
  110. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
  111. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +2 -2
  112. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
  113. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
  114. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +173 -1295
  115. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  116. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
  117. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +26 -54
  118. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
  119. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
  120. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -1
  121. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +5 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  123. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
  124. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
  125. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
  127. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
  128. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  129. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +0 -2
  130. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
  131. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
  132. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -5
  133. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
  134. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -2
  135. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -267
  136. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
  137. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +17 -3
  138. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +102 -396
  139. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
  140. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +6 -15
  141. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +33 -178
  142. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
  143. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
  144. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
  145. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
  146. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -28
  147. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
  148. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  149. package/package.json +34 -37
  150. package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
  151. package/packages/octo-runtime-protocol/schema/protocol.schema.json +173 -1295
  152. package/dist/public/codex.d.ts +0 -1
  153. package/dist/public/codex.js +0 -1
  154. package/dist/public/dsh.d.ts +0 -2
  155. package/dist/public/dsh.js +0 -1
  156. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
  157. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
  158. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
  159. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
  160. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
  161. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
  162. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
  163. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
  164. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
  165. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
  166. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
  167. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
  168. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
  169. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
  170. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
  171. /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
  172. /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
@@ -1,4 +1,11 @@
1
- import { initialControlInstructions, defineAdapter, hasImageInput, invocationEnvironment, mapReasoningEffort, parseJsonLine, probeCommand, providerInputText, spawnJsonLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
1
+ export const antigravityMetadata = {
2
+ type: "antigravity",
3
+ agentSources: ["provisioned"],
4
+ processModel: "subprocess-per-invocation",
5
+ transport: "ndjson/stdio"
6
+ };
7
+ import { invocationEffort, invocationModel, invocationApprovalMode, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
8
+ import { defineAdapter, hasImageInput, invocationEnvironment, mapReasoningEffort, parseJsonLine, probeCommand, snapshotProviderLaunch, providerInputText, spawnJsonLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
9
  import { isStreamCapacityReason } from "@mininglamp-oss/octo-runtime-protocol";
3
10
  import { mkdtemp, readFile, rm } from "node:fs/promises";
4
11
  import { tmpdir } from "node:os";
@@ -275,7 +282,7 @@ const managedFlags = new Set([
275
282
  "--sandbox"
276
283
  ]);
277
284
  export function buildAntigravityCommand(request, command = "agy", commandArgsPrefix = [], logPath) {
278
- if (request.approvalMode !== "full_access")
285
+ if (invocationApprovalMode(request) !== "full_access")
279
286
  throw new Error("APPROVAL_MODE_UNSUPPORTED: antigravity only supports full_access");
280
287
  if (request.signal?.aborted)
281
288
  throw new Error("ANTIGRAVITY_CANCELLED_BEFORE_START");
@@ -285,7 +292,7 @@ export function buildAntigravityCommand(request, command = "agy", commandArgsPre
285
292
  if (managedFlags.has(arg.split("=")[0]) || /^-[pic].+/.test(arg))
286
293
  throw new Error(`ANTIGRAVITY_MANAGED_ARGUMENT: ${arg.split("=")[0]}`);
287
294
  }
288
- const effort = mapReasoningEffort("antigravity", request.agentConfig.effort);
295
+ const effort = mapReasoningEffort("antigravity", invocationEffort(request));
289
296
  const args = [
290
297
  ...commandArgsPrefix,
291
298
  "--input-format",
@@ -302,22 +309,14 @@ export function buildAntigravityCommand(request, command = "agy", commandArgsPre
302
309
  args.push("--log-file", logPath);
303
310
  if (request.providerSession?.sessionId)
304
311
  args.push("--conversation", request.providerSession.sessionId);
305
- if (request.agentConfig.model)
306
- args.push("--model", request.agentConfig.model);
312
+ const model = invocationModel(request);
313
+ if (model)
314
+ args.push("--model", model);
307
315
  if (effort)
308
316
  args.push("--effort", effort);
309
- // agy has no system-prompt flag. Keep the documented user-channel degradation explicit and never rewrite AGENTS.md.
310
- const content = initialControlInstructions(request)
311
- ? [
312
- {
313
- type: "text",
314
- text: `Runtime control instructions (apply throughout this session):\n${initialControlInstructions(request)}`
315
- },
316
- { type: "text", text: `User input:\n${providerInputText(request)}` }
317
- ]
318
- : providerInputText(request);
317
+ const content = providerInputText(request);
319
318
  const input = `${JSON.stringify({ event: "user", message: { content } })}\n`;
320
- return { command, args, input, cwd: request.workdir };
319
+ return { command, args, input, cwd: invocationWorkdir(request) };
321
320
  }
322
321
  export function antigravityLogError(log) {
323
322
  if (/timed out waiting for response/i.test(log))
@@ -327,22 +326,18 @@ export function antigravityLogError(log) {
327
326
  return "ANTIGRAVITY_AUTH_REQUIRED: agy could not read the signed-in account; open agy in your terminal and check the active account";
328
327
  return match ? `ANTIGRAVITY_PROVIDER_ERROR: ${match[1].slice(0, 1000)}` : undefined;
329
328
  }
330
- export function createAntigravityAdapter({ command = "agy", commandArgsPrefix = [] } = {}) {
329
+ export function createAntigravityAdapter({ command, commandArgsPrefix = [], env = {} }) {
330
+ const launch = snapshotProviderLaunch({ command, args: commandArgsPrefix, env });
331
331
  return defineAdapter({
332
- metadata: {
333
- type: "antigravity",
334
- agentSources: ["provisioned"],
335
- processModel: "subprocess-per-invocation",
336
- transport: "ndjson/stdio"
337
- },
332
+ metadata: antigravityMetadata,
338
333
  probe: async () => {
339
- const result = await probeCommand(command);
334
+ const result = await probeCommand(launch.command, { args: launch.args, env: launch.env });
340
335
  if (result.available && (!result.version || compareVersion(result.version, "1.3.3") < 0))
341
336
  return { ...result, available: false, reason: "provider_version_unsupported" };
342
337
  return result;
343
338
  },
344
339
  async *invoke(request, context) {
345
- buildAntigravityCommand(request, command, commandArgsPrefix);
340
+ buildAntigravityCommand(request, launch.command, [...launch.args]);
346
341
  const directory = await mkdtemp(join(tmpdir(), "octo-runtime-antigravity-"));
347
342
  const logPath = join(directory, "cli.log");
348
343
  const controller = new AbortController();
@@ -381,11 +376,11 @@ export function createAntigravityAdapter({ command = "agy", commandArgsPrefix =
381
376
  void checkLog();
382
377
  }, 250);
383
378
  timer.unref();
384
- const spec = buildAntigravityCommand(request, command, commandArgsPrefix, logPath);
379
+ const spec = buildAntigravityCommand(request, launch.command, [...launch.args], logPath);
385
380
  try {
386
381
  for await (const native of spawnJsonLines({
387
382
  ...spec,
388
- env: invocationEnvironment(request, spec.env),
383
+ env: invocationEnvironment(request, spec.env, launch.env),
389
384
  signal: controller.signal,
390
385
  rawMessageMaxBytes: context?.streamLimits?.rawMessageMaxBytes,
391
386
  parseLine: (line) => {
@@ -433,5 +428,3 @@ function compareVersion(version, minimum) {
433
428
  }
434
429
  return 0;
435
430
  }
436
- export const antigravityAdapter = createAntigravityAdapter();
437
- export default antigravityAdapter;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-antigravity",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "README.md"
11
11
  ],
12
12
  "dependencies": {
13
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.12",
14
- "@mininglamp-oss/octo-runtime-protocol": "1.1.12"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13",
14
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.13"
15
15
  }
16
16
  }
@@ -1,3 +1,5 @@
1
+ import type { AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ export declare const claudeCodeMetadata: AdapterMetadata;
1
3
  /**
2
4
  * Claude Code local CLI transport and event normalization layer.
3
5
  *
@@ -59,19 +61,16 @@ interface ClaudeNativeEvent {
59
61
  };
60
62
  }
61
63
  /**
62
- * Build the Claude CLI argv and stdin for one invocation.
63
- *
64
- * The system/control prompt is written to a private temp file passed via
65
- * `--append-system-prompt-file`, while the user prompt stays on stdin, so the
66
- * two never get conflated. Returns a `cleanup` that removes the temp directory.
64
+ * 构造本轮 Claude CLI 参数和普通输入;临时文件仅承载显式 MCP 配置,
65
+ * 返回的 cleanup 负责回收该配置目录。
67
66
  */
68
- export declare function buildClaudeCommand(req: InvokeRequest, command?: string, commandArgsPrefix?: string[]): Promise<{
67
+ export declare function buildClaudeCommand(req: InvokeRequest, command?: string, commandArgsPrefix?: string[], inherited?: NodeJS.ProcessEnv): Promise<{
69
68
  command: string;
70
69
  args: string[];
71
70
  input: string;
72
71
  cleanup: () => Promise<void>;
73
72
  }>;
74
- export declare function claudePermissionMode(mode: InvokeRequest["approvalMode"]): string;
73
+ export declare function claudePermissionMode(mode: "ask" | "assisted" | "full_access"): string;
75
74
  /**
76
75
  * Translates Claude's native stream into canonical events for one invocation.
77
76
  *
@@ -87,73 +86,20 @@ export declare class ClaudeEventNormalizer {
87
86
  /** Compatibility entry for a single complete event; a partial sequence must reuse one ClaudeEventNormalizer. */
88
87
  export declare function normalizeClaudeEvent(native: ClaudeNativeEvent): CanonicalEvent[];
89
88
  /** Create a Claude Code adapter bound to a resolved CLI command and optional argv prefix. */
90
- export declare function createClaudeCodeAdapter({ command, commandArgsPrefix }?: {
91
- command?: string;
89
+ export declare function createClaudeCodeAdapter({ command, commandArgsPrefix, env }: {
90
+ command: string;
92
91
  commandArgsPrefix?: string[];
92
+ env?: NodeJS.ProcessEnv;
93
93
  }): Readonly<Omit<{
94
- metadata: {
95
- mcp: true;
96
- protocolSupport: {
97
- protocol: string;
98
- modes: ["native", "canonical"];
99
- nativeMethods: string[];
100
- };
101
- type: string;
102
- agentSources: "provisioned"[];
103
- processModel: string;
104
- transport: string;
105
- };
106
- probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
107
- respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
108
- respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
109
- invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<AdapterOutput>;
110
- }, "metadata"> & {
111
- metadata: Omit<{
112
- mcp: true;
113
- protocolSupport: {
114
- protocol: string;
115
- modes: ["native", "canonical"];
116
- nativeMethods: string[];
117
- };
118
- type: string;
119
- agentSources: "provisioned"[];
120
- processModel: string;
121
- transport: string;
122
- }, "protocolSupport"> & {
123
- protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
124
- };
125
- }>;
126
- export declare const claudeCodeAdapter: Readonly<Omit<{
127
- metadata: {
128
- mcp: true;
129
- protocolSupport: {
130
- protocol: string;
131
- modes: ["native", "canonical"];
132
- nativeMethods: string[];
133
- };
134
- type: string;
135
- agentSources: "provisioned"[];
136
- processModel: string;
137
- transport: string;
138
- };
94
+ metadata: AdapterMetadata;
139
95
  probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
140
96
  respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
141
97
  respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
142
98
  invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<AdapterOutput>;
143
- }, "metadata"> & {
144
- metadata: Omit<{
145
- mcp: true;
146
- protocolSupport: {
147
- protocol: string;
148
- modes: ["native", "canonical"];
149
- nativeMethods: string[];
150
- };
151
- type: string;
152
- agentSources: "provisioned"[];
153
- processModel: string;
154
- transport: string;
155
- }, "protocolSupport"> & {
99
+ }, "metadata" | "defaultAgentEnv"> & {
100
+ readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
101
+ metadata: Omit<AdapterMetadata, "protocolSupport"> & {
156
102
  protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
157
103
  };
158
104
  }>;
159
- export default claudeCodeAdapter;
105
+ export {};
@@ -1,4 +1,17 @@
1
- import { initialControlInstructions, hasImageInput, invocationEnvironment, invocationMcpServers, assertMcpOptions, actmodeEvidence, mapReasoningEffort } from "@mininglamp-oss/octo-runtime-adapter-sdk";
1
+ export const claudeCodeMetadata = {
2
+ mcp: true,
3
+ protocolSupport: {
4
+ protocol: "claude.stream-json",
5
+ modes: ["native", "canonical"],
6
+ nativeMethods: ["managed-turn", "can_use_tool", "control_response", "cancel"]
7
+ },
8
+ type: "claude-code",
9
+ agentSources: ["provisioned"],
10
+ processModel: "subprocess-per-invocation",
11
+ transport: "ndjson/stdio"
12
+ };
13
+ import { invocationModel, invocationEffort, invocationApprovalMode, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
14
+ import { hasImageInput, invocationEnvironment, invocationMcpServers, assertMcpOptions, actmodeEvidence, mapReasoningEffort } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
15
  import { canonicalTerminalStatus, contextActmode } from "@mininglamp-oss/octo-runtime-protocol";
3
16
  /**
4
17
  * Claude Code local CLI transport and event normalization layer.
@@ -10,35 +23,31 @@ import { canonicalTerminalStatus, contextActmode } from "@mininglamp-oss/octo-ru
10
23
  * carries no tool_use id of its own, so every invocation must own an
11
24
  * independent ClaudeEventNormalizer state.
12
25
  */
13
- import { AcpApprovalBridge, NativeInteractionBridge, defineAdapter, parseJsonLine, probeCommand, providerInputText, spawnJsonLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
26
+ import { AcpApprovalBridge, NativeInteractionBridge, defineAdapter, parseJsonLine, probeCommand, snapshotProviderLaunch, providerInputText, spawnJsonLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
14
27
  import { protocolError } from "@mininglamp-oss/octo-runtime-protocol";
15
28
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
16
29
  import { tmpdir } from "node:os";
17
30
  import { join } from "node:path";
18
31
  const MAX_STEP_PUBLIC_TEXT_CHARS = 1_000;
19
32
  /**
20
- * Build the Claude CLI argv and stdin for one invocation.
21
- *
22
- * The system/control prompt is written to a private temp file passed via
23
- * `--append-system-prompt-file`, while the user prompt stays on stdin, so the
24
- * two never get conflated. Returns a `cleanup` that removes the temp directory.
33
+ * 构造本轮 Claude CLI 参数和普通输入;临时文件仅承载显式 MCP 配置,
34
+ * 返回的 cleanup 负责回收该配置目录。
25
35
  */
26
- export async function buildClaudeCommand(req, command = "claude", commandArgsPrefix = []) {
36
+ export async function buildClaudeCommand(req, command = "claude", commandArgsPrefix = [], inherited = {}) {
27
37
  if (hasImageInput(req))
28
38
  throw new Error("UNSUPPORTED_INPUT_MODALITY: claude-code does not encode image input");
29
- const mode = contextActmode(req.context) === "plan" ? "plan" : claudePermissionMode(req.approvalMode);
30
- const servers = invocationMcpServers(req);
39
+ const mode = contextActmode(req.agentEnv) === "plan"
40
+ ? "plan"
41
+ : claudePermissionMode(invocationApprovalMode(req));
42
+ const servers = invocationMcpServers(req, invocationEnvironment(req, {}, inherited));
31
43
  assertMcpOptions(servers, "claude-code", []);
32
44
  // Native Claude expands placeholders again at connection time. Reject values
33
45
  // it cannot preserve instead of silently changing a resolved literal/token.
34
46
  if (Object.values(servers).some((server) => JSON.stringify(server).includes("${")))
35
47
  throw new Error("MCP_LITERAL_UNSUPPORTED: claude-code cannot preserve resolved placeholder text");
36
- const directory = await mkdtemp(join(tmpdir(), "octo-runtime-claude-"));
37
- const promptFile = join(directory, "system-prompt.txt");
38
- // The control prompt goes through Claude's dedicated file argument while the
39
- // user prompt is still fed via stdin, so the two never get conflated.
40
- await writeFile(promptFile, initialControlInstructions(req), { mode: 0o600 });
48
+ let directory;
41
49
  if (Object.keys(servers).length) {
50
+ directory = await mkdtemp(join(tmpdir(), "octo-runtime-claude-"));
42
51
  const mcpFile = join(directory, "mcp.json");
43
52
  const mcpServers = Object.fromEntries(Object.entries(servers).map(([name, server]) => [
44
53
  name,
@@ -51,7 +60,24 @@ export async function buildClaudeCommand(req, command = "claude", commandArgsPre
51
60
  }
52
61
  : { type: "http", url: server.url, headers: server.headers ?? {} }
53
62
  ]));
54
- await writeFile(mcpFile, JSON.stringify({ mcpServers }), { mode: 0o600 });
63
+ // 临时文件只承载本轮 MCP;准备失败由本层回收,成功后归命令执行者清理。
64
+ try {
65
+ await writeFile(mcpFile, JSON.stringify({ mcpServers }), { mode: 0o600 });
66
+ }
67
+ catch (error) {
68
+ let cleanupFailure;
69
+ try {
70
+ await rm(directory, { recursive: true, force: true });
71
+ }
72
+ catch (cleanupError) {
73
+ cleanupFailure = { error: cleanupError };
74
+ }
75
+ if (cleanupFailure)
76
+ throw new AggregateError([error, cleanupFailure.error], "Claude MCP preparation and cleanup failed", {
77
+ cause: error
78
+ });
79
+ throw error;
80
+ }
55
81
  commandArgsPrefix = [...commandArgsPrefix, "--mcp-config", mcpFile];
56
82
  }
57
83
  // Only --include-partial-messages produces thinking/text/input_json deltas;
@@ -65,17 +91,17 @@ export async function buildClaudeCommand(req, command = "claude", commandArgsPre
65
91
  "--output-format",
66
92
  "stream-json",
67
93
  "--verbose",
68
- "--include-partial-messages",
69
- ...(initialControlInstructions(req) ? ["--append-system-prompt-file", promptFile] : [])
94
+ "--include-partial-messages"
70
95
  ];
71
96
  if (req.providerSession?.sessionId)
72
97
  args.push("--resume", req.providerSession.sessionId);
73
98
  // --name 是展示标题;不能替换原生 UUID,也不在 resume 时覆盖既有名称。
74
99
  else if (req.sessionName)
75
100
  args.push("--name", req.sessionName);
76
- if (req.agentConfig?.model)
77
- args.push("--model", req.agentConfig.model);
78
- const effort = mapReasoningEffort("claude-code", req.agentConfig?.effort);
101
+ const model = invocationModel(req);
102
+ if (model)
103
+ args.push("--model", model);
104
+ const effort = mapReasoningEffort("claude-code", invocationEffort(req));
79
105
  if (effort)
80
106
  args.push("--effort", effort);
81
107
  args.push("--permission-mode", mode);
@@ -87,7 +113,10 @@ export async function buildClaudeCommand(req, command = "claude", commandArgsPre
87
113
  command,
88
114
  args,
89
115
  input,
90
- cleanup: () => rm(directory, { recursive: true, force: true })
116
+ cleanup: async () => {
117
+ if (directory)
118
+ await rm(directory, { recursive: true, force: true });
119
+ }
91
120
  };
92
121
  }
93
122
  export function claudePermissionMode(mode) {
@@ -541,23 +570,13 @@ function claudeToolResultOutput(content) {
541
570
  return text || content;
542
571
  }
543
572
  /** Create a Claude Code adapter bound to a resolved CLI command and optional argv prefix. */
544
- export function createClaudeCodeAdapter({ command = "claude", commandArgsPrefix = [] } = {}) {
573
+ export function createClaudeCodeAdapter({ command, commandArgsPrefix = [], env = {} }) {
574
+ const launch = snapshotProviderLaunch({ command, args: commandArgsPrefix, env });
545
575
  const responders = new Map();
546
576
  const nativeResponders = new Map();
547
577
  return defineAdapter({
548
- metadata: {
549
- mcp: true,
550
- protocolSupport: {
551
- protocol: "claude.stream-json",
552
- modes: ["native", "canonical"],
553
- nativeMethods: ["managed-turn", "can_use_tool", "control_response", "cancel"]
554
- },
555
- type: "claude-code",
556
- agentSources: ["provisioned"],
557
- processModel: "subprocess-per-invocation",
558
- transport: "ndjson/stdio"
559
- },
560
- probe: () => probeCommand(command),
578
+ metadata: claudeCodeMetadata,
579
+ probe: () => probeCommand(launch.command, { args: launch.args, env: launch.env }),
561
580
  async respondNative(invocationId, response) {
562
581
  const bridge = nativeResponders.get(invocationId);
563
582
  if (!bridge)
@@ -606,10 +625,10 @@ export function createClaudeCodeAdapter({ command = "claude", commandArgsPrefix
606
625
  }
607
626
  });
608
627
  async function* execute(request, permissions, context) {
609
- const spec = await buildClaudeCommand(request, command, commandArgsPrefix);
628
+ const spec = await buildClaudeCommand(request, launch.command, [...launch.args], launch.env);
610
629
  // The normalizer must not be hoisted to an adapter singleton: one adapter may run several invocations concurrently.
611
630
  const normalizer = permissions instanceof NativeInteractionBridge ? undefined : new ClaudeEventNormalizer();
612
- const requestedMode = contextActmode(request.context);
631
+ const requestedMode = contextActmode(request.agentEnv);
613
632
  let modeReported = false;
614
633
  try {
615
634
  if (normalizer)
@@ -620,8 +639,8 @@ export function createClaudeCodeAdapter({ command = "claude", commandArgsPrefix
620
639
  };
621
640
  for await (const native of spawnJsonLines({
622
641
  ...spec,
623
- cwd: request.workdir,
624
- env: invocationEnvironment(request),
642
+ cwd: invocationWorkdir(request),
643
+ env: invocationEnvironment(request, {}, launch.env),
625
644
  signal: request.signal,
626
645
  rawMessageMaxBytes: context?.streamLimits?.rawMessageMaxBytes,
627
646
  onSpawn: (close) => permissions.bindTransport(close),
@@ -662,7 +681,7 @@ export function createClaudeCodeAdapter({ command = "claude", commandArgsPrefix
662
681
  decision.interrupt !== false))
663
682
  throw protocolError("NATIVE_RESPONSE_INVALID");
664
683
  };
665
- permissions.request(requestId, native, write, validate, request.approvalMode === "full_access"
684
+ permissions.request(requestId, native, write, validate, invocationApprovalMode(request) === "full_access"
666
685
  ? {
667
686
  type: "control_response",
668
687
  response: {
@@ -796,5 +815,3 @@ export function createClaudeCodeAdapter({ command = "claude", commandArgsPrefix
796
815
  }
797
816
  }
798
817
  }
799
- export const claudeCodeAdapter = createClaudeCodeAdapter();
800
- export default claudeCodeAdapter;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-claude-code",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.1.12",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.12"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.13",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -1,3 +1,5 @@
1
+ import type { AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ export declare const codeBuddyMetadata: AdapterMetadata;
1
3
  import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
2
4
  /**
3
5
  * CodeBuddy adapter: wraps the CodeBuddy CLI spoken over ACP (Agent Client
@@ -6,7 +8,7 @@ import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol"
6
8
  */
7
9
  import type { AcpUpdate } from "@mininglamp-oss/octo-runtime-acp-client";
8
10
  import { spawnAcpClient } from "@mininglamp-oss/octo-runtime-acp-client";
9
- import { type AdapterInvocationContext, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
11
+ import { type ProbeResult, type AdapterInvocationContext, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
10
12
  /** One ACP `session/update` notification; fields are optional because their presence depends on `sessionUpdate`. */
11
13
  interface CodeBuddyUpdate extends AcpUpdate {
12
14
  sessionUpdate?: string;
@@ -27,40 +29,26 @@ export declare function normalizeCodeBuddyUpdate(update: CodeBuddyUpdate): Canon
27
29
  * adapter 将 Provider 结果映射为唯一终态并负责关闭 client;Core 独立确认清理完成。
28
30
  * 显式模型在 prompt 前按本次原生目录设置并确认;回执只取确认值,Provider 失败优先于部分输出及空输出检查。
29
31
  */
30
- export declare function createCodeBuddyAdapter({ acpClientFactory, command }?: {
32
+ export declare function createCodeBuddyAdapter({ acpClientFactory, command, commandArgsPrefix, env, probe }: {
31
33
  acpClientFactory?: typeof spawnAcpClient;
32
- command?: string;
34
+ command: string;
35
+ commandArgsPrefix?: readonly string[];
36
+ env?: NodeJS.ProcessEnv;
37
+ probe?: () => Promise<ProbeResult>;
33
38
  }): Readonly<Omit<{
34
- metadata: {
35
- type: string;
36
- agentSources: "provisioned"[];
37
- };
38
- probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
39
- respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
40
- invoke(req: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
41
- }, "metadata"> & {
42
- metadata: Omit<{
43
- type: string;
44
- agentSources: "provisioned"[];
45
- }, "protocolSupport"> & {
46
- protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
47
- };
48
- }>;
49
- export declare function codeBuddyPermissionMode(mode: InvokeRequest["approvalMode"]): string;
50
- export declare const codebuddyAdapter: Readonly<Omit<{
51
- metadata: {
52
- type: string;
53
- agentSources: "provisioned"[];
54
- };
55
- probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
39
+ metadata: AdapterMetadata;
40
+ probe: (() => Promise<ProbeResult>) | (() => Promise<{
41
+ available: false;
42
+ command: string;
43
+ reason: string;
44
+ }>);
56
45
  respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
57
46
  invoke(req: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
58
- }, "metadata"> & {
59
- metadata: Omit<{
60
- type: string;
61
- agentSources: "provisioned"[];
62
- }, "protocolSupport"> & {
47
+ }, "metadata" | "defaultAgentEnv"> & {
48
+ readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
49
+ metadata: Omit<AdapterMetadata, "protocolSupport"> & {
63
50
  protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
64
51
  };
65
52
  }>;
66
- export default codebuddyAdapter;
53
+ export declare function codeBuddyPermissionMode(mode: "ask" | "assisted" | "full_access"): string;
54
+ export {};
@@ -1,7 +1,12 @@
1
- import { initialControlInstructions, invocationEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
1
+ export const codeBuddyMetadata = {
2
+ type: "codebuddy",
3
+ agentSources: ["provisioned"]
4
+ };
5
+ import { invocationModel, invocationApprovalMode, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
6
+ import { invocationEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
7
  import { canonicalTerminalStatus, failureMessage, hasImageInput } from "@mininglamp-oss/octo-runtime-protocol";
3
8
  import { acpLoadSessionParams, acpNewSessionParams, acpPromptParams, spawnAcpClient } from "@mininglamp-oss/octo-runtime-acp-client";
4
- import { AcpApprovalBridge, AcpTurnNormalizer, acpToolTerminalStatus, defineAdapter, normalizeAcpToolUpdate, probeCommand, providerInputText } from "@mininglamp-oss/octo-runtime-adapter-sdk";
9
+ import { AcpApprovalBridge, AcpTurnNormalizer, acpToolTerminalStatus, defineAdapter, normalizeAcpToolUpdate, probeCommand, snapshotProviderLaunch, providerInputText } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
10
  /** Translate one ACP update into canonical events; unrecognized update kinds yield nothing. */
6
11
  export function normalizeCodeBuddyUpdate(update) {
7
12
  const type = update.sessionUpdate ?? update.type;
@@ -164,14 +169,17 @@ function promptResultText(update) {
164
169
  * adapter 将 Provider 结果映射为唯一终态并负责关闭 client;Core 独立确认清理完成。
165
170
  * 显式模型在 prompt 前按本次原生目录设置并确认;回执只取确认值,Provider 失败优先于部分输出及空输出检查。
166
171
  */
167
- export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, command = "codebuddy" } = {}) {
172
+ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, command, commandArgsPrefix = [], env = {}, probe }) {
173
+ const launch = acpClientFactory === spawnAcpClient
174
+ ? snapshotProviderLaunch({ command, args: commandArgsPrefix, env })
175
+ : { command, args: [...commandArgsPrefix], env: { ...env } };
168
176
  const responders = new Map();
169
177
  return defineAdapter({
170
- metadata: {
171
- type: "codebuddy",
172
- agentSources: ["provisioned"]
173
- },
174
- probe: () => probeCommand(command),
178
+ metadata: codeBuddyMetadata,
179
+ probe: probe ??
180
+ (acpClientFactory === spawnAcpClient
181
+ ? () => probeCommand(launch.command, { args: launch.args, env: launch.env })
182
+ : () => Promise.resolve({ available: false, command, reason: "probe_missing" })),
175
183
  async respondInteraction(invocationId, response) {
176
184
  const bridge = responders.get(invocationId);
177
185
  if (!bridge)
@@ -187,10 +195,15 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
187
195
  responders.set(req.invocationId, permissions);
188
196
  async function* execute() {
189
197
  const client = await Promise.resolve(acpClientFactory({
190
- command,
191
- args: ["--acp", "--permission-mode", codeBuddyPermissionMode(req.approvalMode)],
192
- env: invocationEnvironment(req),
193
- cwd: req.workdir,
198
+ command: launch.command,
199
+ args: [
200
+ ...launch.args,
201
+ "--acp",
202
+ "--permission-mode",
203
+ codeBuddyPermissionMode(invocationApprovalMode(req))
204
+ ],
205
+ env: invocationEnvironment(req, {}, launch.env),
206
+ cwd: invocationWorkdir(req),
194
207
  signal: req.signal,
195
208
  permissionHandler: (params) => permissions.requestPermission(params),
196
209
  onPermissionResponseWritten: (params) => permissions.responseWritten(params),
@@ -203,8 +216,8 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
203
216
  const requestedSessionId = req.providerSession?.sessionId;
204
217
  const sessionMethod = requestedSessionId ? "session/load" : "session/new";
205
218
  const sessionParams = requestedSessionId
206
- ? acpLoadSessionParams(requestedSessionId, { cwd: req.workdir })
207
- : acpNewSessionParams({ cwd: req.workdir });
219
+ ? acpLoadSessionParams(requestedSessionId, { cwd: invocationWorkdir(req) })
220
+ : acpNewSessionParams({ cwd: invocationWorkdir(req) });
208
221
  const sessionRequestId = client.reserveRequestId();
209
222
  let session;
210
223
  const requestOptions = {
@@ -224,7 +237,7 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
224
237
  session = { id: sessionId };
225
238
  }
226
239
  let model = confirmedSessionModel(sessionResult);
227
- const requestedModel = req.agentConfig?.model;
240
+ const requestedModel = invocationModel(req);
228
241
  if (requestedModel) {
229
242
  const selection = modelSelection(sessionResult, session.id, requestedModel);
230
243
  if (selection) {
@@ -249,7 +262,7 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
249
262
  }
250
263
  }
251
264
  };
252
- const prompt = `${providerInputText(req)}\n\n${initialControlInstructions(req)}`;
265
+ const prompt = providerInputText(req);
253
266
  const promptParams = acpPromptParams(session.id, prompt);
254
267
  const promptRequestId = client.reserveRequestId();
255
268
  let promptStopReason;
@@ -368,5 +381,3 @@ export function codeBuddyPermissionMode(mode) {
368
381
  function isRecord(value) {
369
382
  return value !== null && typeof value === "object" && !Array.isArray(value);
370
383
  }
371
- export const codebuddyAdapter = createCodeBuddyAdapter();
372
- export default codebuddyAdapter;
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-codebuddy",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.1.12",
9
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.12",
10
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.12"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.13",
9
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.13",
10
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.13"
11
11
  },
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [