@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.
- package/README.md +1 -1
- package/apps/cli/dist/adapters.d.ts +19 -1
- package/apps/cli/dist/adapters.js +153 -23
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/codex.d.ts +5 -0
- package/apps/cli/dist/codex.js +36 -0
- package/apps/cli/dist/kernel.d.ts +4 -0
- package/apps/cli/dist/kernel.js +84 -0
- package/apps/cli/dist/main.js +8 -7
- package/apps/cli/dist/manifest.json +33 -22
- package/apps/cli/dist/output.d.ts +1 -0
- package/apps/cli/dist/output.js +8 -4
- package/apps/cli/dist/playboard.js +21 -12
- package/apps/cli/dist/provider-launch.d.ts +28 -0
- package/apps/cli/dist/provider-launch.js +52 -0
- package/apps/cli/dist/providers.d.ts +182 -0
- package/apps/cli/dist/providers.js +34 -0
- package/dist/public/adapter-sdk.d.ts +2 -0
- package/dist/public/adapter-sdk.js +2 -0
- package/dist/public/protocol.d.ts +1 -1
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +15 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +24 -28
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +22 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +60 -43
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +29 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +32 -26
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +104 -216
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +12 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +14 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +23 -30
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +48 -26
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +15 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +15 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +7 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +27 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +109 -178
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +15 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +16 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +15 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +49 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +256 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -12
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +116 -58
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +153 -23
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +173 -1295
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +26 -54
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -267
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +17 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +102 -396
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +6 -15
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +33 -178
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -28
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +34 -37
- package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +173 -1295
- package/dist/public/codex.d.ts +0 -1
- package/dist/public/codex.js +0 -1
- package/dist/public/dsh.d.ts +0 -2
- package/dist/public/dsh.js +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
- /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
- /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
306
|
-
|
|
312
|
+
const model = invocationModel(request);
|
|
313
|
+
if (model)
|
|
314
|
+
args.push("--model", model);
|
|
307
315
|
if (effort)
|
|
308
316
|
args.push("--effort", effort);
|
|
309
|
-
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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.
|
|
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.
|
|
14
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
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
|
-
*
|
|
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:
|
|
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
|
|
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
|
-
|
|
145
|
-
|
|
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
|
|
105
|
+
export {};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
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
|
-
*
|
|
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.
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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: () =>
|
|
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
|
|
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
|
-
|
|
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,
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
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
|
|
34
|
+
command: string;
|
|
35
|
+
commandArgsPrefix?: readonly string[];
|
|
36
|
+
env?: NodeJS.ProcessEnv;
|
|
37
|
+
probe?: () => Promise<ProbeResult>;
|
|
33
38
|
}): Readonly<Omit<{
|
|
34
|
-
metadata:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
|
53
|
+
export declare function codeBuddyPermissionMode(mode: "ask" | "assisted" | "full_access"): string;
|
|
54
|
+
export {};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
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 =
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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: [
|
|
192
|
-
|
|
193
|
-
|
|
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
|
|
207
|
-
: acpNewSessionParams({ cwd: req
|
|
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
|
|
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 =
|
|
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.
|
|
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.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-acp-client": "1.1.
|
|
10
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
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": [
|