@buildautomaton/cli 0.1.6 → 0.1.7
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/dist/cli.js +655 -97
- package/dist/cli.js.map +4 -4
- package/dist/index.js +653 -95
- package/dist/index.js.map +4 -4
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -22148,6 +22148,284 @@ function sendWsMessage(ws, payload) {
|
|
|
22148
22148
|
}
|
|
22149
22149
|
}
|
|
22150
22150
|
|
|
22151
|
+
// ../types/dist/index.js
|
|
22152
|
+
init_zod();
|
|
22153
|
+
init_zod();
|
|
22154
|
+
init_zod();
|
|
22155
|
+
init_zod();
|
|
22156
|
+
init_zod();
|
|
22157
|
+
init_zod();
|
|
22158
|
+
init_zod();
|
|
22159
|
+
init_zod();
|
|
22160
|
+
init_zod();
|
|
22161
|
+
init_zod();
|
|
22162
|
+
init_zod();
|
|
22163
|
+
init_zod();
|
|
22164
|
+
var WorkItemStatusSchema = external_exports.enum(["backlog", "in-progress", "completed"]);
|
|
22165
|
+
var WorkItemProgressSchema = external_exports.object({
|
|
22166
|
+
remainingCriteria: external_exports.array(external_exports.string()).default([]),
|
|
22167
|
+
openQuestions: external_exports.array(external_exports.string()).default([]),
|
|
22168
|
+
assignedTo: external_exports.enum(["agent", "human-product", "human-expert"]).optional()
|
|
22169
|
+
});
|
|
22170
|
+
var ChangeSchema = external_exports.object({
|
|
22171
|
+
id: external_exports.string(),
|
|
22172
|
+
description: external_exports.string(),
|
|
22173
|
+
buildingBlockId: external_exports.string(),
|
|
22174
|
+
buildingBlockType: external_exports.enum(["function", "workflow", "connector", "ui-component", "app-fragment", "application", "project"]),
|
|
22175
|
+
action: external_exports.enum(["create", "update", "split", "combine"])
|
|
22176
|
+
});
|
|
22177
|
+
var CompletionCriterionSchema = external_exports.object({
|
|
22178
|
+
id: external_exports.string(),
|
|
22179
|
+
description: external_exports.string(),
|
|
22180
|
+
type: external_exports.enum(["write-code", "write-tests", "verify-tests", "other"]),
|
|
22181
|
+
verified: external_exports.boolean().default(false)
|
|
22182
|
+
});
|
|
22183
|
+
var WorkItemPrioritySchema = external_exports.enum(["low", "medium", "high", "critical"]);
|
|
22184
|
+
var IterationPhaseSchema = external_exports.enum(["analysis", "implementation", "verify", "reprioritize", "completed"]);
|
|
22185
|
+
var WorkItemDependencySchema = external_exports.object({
|
|
22186
|
+
type: external_exports.enum(["work-item"]),
|
|
22187
|
+
id: external_exports.string()
|
|
22188
|
+
});
|
|
22189
|
+
var WorkItemSchema = external_exports.object({
|
|
22190
|
+
id: external_exports.string(),
|
|
22191
|
+
sessionId: external_exports.string().optional(),
|
|
22192
|
+
summary: external_exports.string().optional(),
|
|
22193
|
+
description: external_exports.string(),
|
|
22194
|
+
status: WorkItemStatusSchema,
|
|
22195
|
+
buildingBlockId: external_exports.string().optional(),
|
|
22196
|
+
buildingBlockType: external_exports.enum(["function", "workflow", "connector", "ui-component", "app-fragment", "application", "project"]),
|
|
22197
|
+
changes: external_exports.array(ChangeSchema).default([]),
|
|
22198
|
+
completionCriteria: external_exports.array(CompletionCriterionSchema).default([]),
|
|
22199
|
+
priority: WorkItemPrioritySchema.default("medium"),
|
|
22200
|
+
dependencies: external_exports.array(WorkItemDependencySchema).default([]),
|
|
22201
|
+
assignedToUserId: external_exports.string().optional()
|
|
22202
|
+
});
|
|
22203
|
+
var UserWorkspaceProfileSchema = external_exports.object({
|
|
22204
|
+
id: external_exports.string(),
|
|
22205
|
+
workspaceId: external_exports.string(),
|
|
22206
|
+
userId: external_exports.string(),
|
|
22207
|
+
roleDescription: external_exports.string().optional(),
|
|
22208
|
+
expertiseAreas: external_exports.array(external_exports.string()),
|
|
22209
|
+
preferences: external_exports.record(external_exports.unknown()).optional(),
|
|
22210
|
+
learnings: external_exports.array(external_exports.string())
|
|
22211
|
+
});
|
|
22212
|
+
var WorkspaceOwnerInfoSchema = external_exports.object({
|
|
22213
|
+
ownerId: external_exports.string(),
|
|
22214
|
+
ownerName: external_exports.string().optional(),
|
|
22215
|
+
ownerEmail: external_exports.string().optional(),
|
|
22216
|
+
ownerProfilePictureUrl: external_exports.string().optional()
|
|
22217
|
+
});
|
|
22218
|
+
var WorkspaceRuntimeEntrySchema = external_exports.object({
|
|
22219
|
+
workspaceId: external_exports.string(),
|
|
22220
|
+
path: external_exports.string(),
|
|
22221
|
+
name: external_exports.string().optional(),
|
|
22222
|
+
owner: WorkspaceOwnerInfoSchema.optional(),
|
|
22223
|
+
isOwner: external_exports.boolean().optional()
|
|
22224
|
+
});
|
|
22225
|
+
var ProjectContextSchema = external_exports.object({
|
|
22226
|
+
projectId: external_exports.string(),
|
|
22227
|
+
context: external_exports.record(external_exports.unknown()).default({}),
|
|
22228
|
+
updatedAt: external_exports.string()
|
|
22229
|
+
});
|
|
22230
|
+
var WebSocketMessageTypeSchema = external_exports.enum([
|
|
22231
|
+
"plan-update",
|
|
22232
|
+
"work-item-update",
|
|
22233
|
+
"work-item-added",
|
|
22234
|
+
"work-item-removed",
|
|
22235
|
+
"project-processing-start",
|
|
22236
|
+
"project-processing-update",
|
|
22237
|
+
"project-processing-complete",
|
|
22238
|
+
"project-processing-error",
|
|
22239
|
+
"file-tool-request",
|
|
22240
|
+
"file-tool-response",
|
|
22241
|
+
"file-generated"
|
|
22242
|
+
]);
|
|
22243
|
+
var WebSocketMessageSchema = external_exports.object({
|
|
22244
|
+
type: WebSocketMessageTypeSchema,
|
|
22245
|
+
contextId: external_exports.string().optional(),
|
|
22246
|
+
data: external_exports.any().optional(),
|
|
22247
|
+
error: external_exports.string().optional()
|
|
22248
|
+
});
|
|
22249
|
+
var CheckpointKindSchema = external_exports.enum(["daily", "weekly", "overall"]);
|
|
22250
|
+
var CheckpointSummarySchema = external_exports.object({
|
|
22251
|
+
id: external_exports.string(),
|
|
22252
|
+
kind: CheckpointKindSchema,
|
|
22253
|
+
/** ISO date for daily (YYYY-MM-DD), ISO week for weekly, null for overall */
|
|
22254
|
+
periodKey: external_exports.string().nullable(),
|
|
22255
|
+
summary: external_exports.string(),
|
|
22256
|
+
createdAt: external_exports.string(),
|
|
22257
|
+
updatedAt: external_exports.string()
|
|
22258
|
+
});
|
|
22259
|
+
var ThreadMetaSchema = external_exports.object({
|
|
22260
|
+
threadId: external_exports.string(),
|
|
22261
|
+
workspaceId: external_exports.string(),
|
|
22262
|
+
/** External source (e.g. slack, discord); null if internal-only */
|
|
22263
|
+
externalSource: external_exports.string().nullable(),
|
|
22264
|
+
/** Id in the external system (e.g. channel_id + thread_ts) */
|
|
22265
|
+
externalId: external_exports.string().nullable(),
|
|
22266
|
+
title: external_exports.string().optional(),
|
|
22267
|
+
createdAt: external_exports.string(),
|
|
22268
|
+
updatedAt: external_exports.string()
|
|
22269
|
+
});
|
|
22270
|
+
var ThreadMessageSchema = external_exports.object({
|
|
22271
|
+
messageId: external_exports.string(),
|
|
22272
|
+
threadId: external_exports.string(),
|
|
22273
|
+
/** Role: user, assistant, system */
|
|
22274
|
+
role: external_exports.enum(["user", "assistant", "system"]),
|
|
22275
|
+
content: external_exports.string(),
|
|
22276
|
+
/** Optional reference to a ContentItem (e.g. doc, Notion page) */
|
|
22277
|
+
contentItemId: external_exports.string().nullable(),
|
|
22278
|
+
/** External message id if synced from external chat */
|
|
22279
|
+
externalId: external_exports.string().nullable(),
|
|
22280
|
+
createdAt: external_exports.string(),
|
|
22281
|
+
updatedAt: external_exports.string()
|
|
22282
|
+
});
|
|
22283
|
+
var ThreadCheckpointSummarySchema = CheckpointSummarySchema.extend({
|
|
22284
|
+
threadId: external_exports.string()
|
|
22285
|
+
});
|
|
22286
|
+
var ContentSourceSchema = external_exports.enum(["notion", "doc", "slack_thread", "other"]);
|
|
22287
|
+
var ContentItemMetaSchema = external_exports.object({
|
|
22288
|
+
contentId: external_exports.string(),
|
|
22289
|
+
workspaceId: external_exports.string(),
|
|
22290
|
+
source: ContentSourceSchema,
|
|
22291
|
+
/** Id in the external system (e.g. Notion page id, doc url) */
|
|
22292
|
+
externalId: external_exports.string(),
|
|
22293
|
+
/** If source is slack_thread, points to Thread DO id */
|
|
22294
|
+
threadId: external_exports.string().nullable(),
|
|
22295
|
+
title: external_exports.string().optional(),
|
|
22296
|
+
createdAt: external_exports.string(),
|
|
22297
|
+
updatedAt: external_exports.string()
|
|
22298
|
+
});
|
|
22299
|
+
var ContentStorageRefSchema = external_exports.object({
|
|
22300
|
+
storageKey: external_exports.string(),
|
|
22301
|
+
/** Optional: mime type or format hint */
|
|
22302
|
+
contentType: external_exports.string().optional()
|
|
22303
|
+
});
|
|
22304
|
+
var ContentCheckpointSummarySchema = CheckpointSummarySchema.extend({
|
|
22305
|
+
contentId: external_exports.string()
|
|
22306
|
+
});
|
|
22307
|
+
var StoryMetaSchema = external_exports.object({
|
|
22308
|
+
storyId: external_exports.string(),
|
|
22309
|
+
workspaceId: external_exports.string(),
|
|
22310
|
+
title: external_exports.string(),
|
|
22311
|
+
/** feature | bug | epic */
|
|
22312
|
+
kind: external_exports.enum(["feature", "bug", "epic"]).default("feature"),
|
|
22313
|
+
createdAt: external_exports.string(),
|
|
22314
|
+
updatedAt: external_exports.string()
|
|
22315
|
+
});
|
|
22316
|
+
var StoryContentItemRefSchema = external_exports.object({
|
|
22317
|
+
id: external_exports.string(),
|
|
22318
|
+
storyId: external_exports.string(),
|
|
22319
|
+
contentItemId: external_exports.string(),
|
|
22320
|
+
/** Snapshot summary when added to story (or updated) */
|
|
22321
|
+
summary: external_exports.string(),
|
|
22322
|
+
orderIndex: external_exports.number().default(0),
|
|
22323
|
+
createdAt: external_exports.string(),
|
|
22324
|
+
updatedAt: external_exports.string()
|
|
22325
|
+
});
|
|
22326
|
+
var StoryCheckpointSummarySchema = CheckpointSummarySchema.extend({
|
|
22327
|
+
storyId: external_exports.string()
|
|
22328
|
+
});
|
|
22329
|
+
var SessionMetaSchema = external_exports.object({
|
|
22330
|
+
sessionId: external_exports.string(),
|
|
22331
|
+
workspaceId: external_exports.string(),
|
|
22332
|
+
title: external_exports.string().optional(),
|
|
22333
|
+
createdAt: external_exports.string(),
|
|
22334
|
+
updatedAt: external_exports.string()
|
|
22335
|
+
});
|
|
22336
|
+
var SessionPromptSchema = external_exports.object({
|
|
22337
|
+
id: external_exports.string(),
|
|
22338
|
+
sessionId: external_exports.string(),
|
|
22339
|
+
/** text | resource */
|
|
22340
|
+
type: external_exports.enum(["text", "resource"]).default("text"),
|
|
22341
|
+
text: external_exports.string().optional(),
|
|
22342
|
+
resourceUri: external_exports.string().optional(),
|
|
22343
|
+
createdAt: external_exports.string()
|
|
22344
|
+
});
|
|
22345
|
+
var SessionResponseSchema = external_exports.object({
|
|
22346
|
+
id: external_exports.string(),
|
|
22347
|
+
sessionId: external_exports.string(),
|
|
22348
|
+
promptId: external_exports.string(),
|
|
22349
|
+
/** message | completion */
|
|
22350
|
+
kind: external_exports.enum(["message", "completion"]),
|
|
22351
|
+
content: external_exports.string().optional(),
|
|
22352
|
+
/** For completion: stopReason etc. */
|
|
22353
|
+
stopReason: external_exports.string().optional(),
|
|
22354
|
+
createdAt: external_exports.string()
|
|
22355
|
+
});
|
|
22356
|
+
var SessionToolCallSchema = external_exports.object({
|
|
22357
|
+
id: external_exports.string(),
|
|
22358
|
+
sessionId: external_exports.string(),
|
|
22359
|
+
promptId: external_exports.string(),
|
|
22360
|
+
name: external_exports.string(),
|
|
22361
|
+
params: external_exports.record(external_exports.unknown()).optional(),
|
|
22362
|
+
result: external_exports.record(external_exports.unknown()).optional(),
|
|
22363
|
+
createdAt: external_exports.string()
|
|
22364
|
+
});
|
|
22365
|
+
var SessionThreadRefSchema = external_exports.object({
|
|
22366
|
+
sessionId: external_exports.string(),
|
|
22367
|
+
threadId: external_exports.string(),
|
|
22368
|
+
addedAt: external_exports.string()
|
|
22369
|
+
});
|
|
22370
|
+
var ArtifactMetaSchema = external_exports.object({
|
|
22371
|
+
artifactId: external_exports.string(),
|
|
22372
|
+
workspaceId: external_exports.string(),
|
|
22373
|
+
/** Slug for permalink: /workspaces/:wid/artifacts/:slug */
|
|
22374
|
+
permalinkSlug: external_exports.string(),
|
|
22375
|
+
title: external_exports.string(),
|
|
22376
|
+
/** e.g. summary_report, build_log */
|
|
22377
|
+
type: external_exports.string().default("report"),
|
|
22378
|
+
/** Optional session that produced this artifact */
|
|
22379
|
+
sessionId: external_exports.string().nullable(),
|
|
22380
|
+
createdAt: external_exports.string(),
|
|
22381
|
+
updatedAt: external_exports.string()
|
|
22382
|
+
});
|
|
22383
|
+
var TemplateMetaSchema = external_exports.object({
|
|
22384
|
+
templateId: external_exports.string(),
|
|
22385
|
+
workspaceId: external_exports.string(),
|
|
22386
|
+
name: external_exports.string(),
|
|
22387
|
+
/** e.g. summary_report, build_log */
|
|
22388
|
+
artifactType: external_exports.string().optional(),
|
|
22389
|
+
createdAt: external_exports.string(),
|
|
22390
|
+
updatedAt: external_exports.string()
|
|
22391
|
+
});
|
|
22392
|
+
var GitRepoMetaSchema = external_exports.object({
|
|
22393
|
+
/** Stable id for the repo (e.g. hash of normalized canonical URL). Used for DO idFromName. */
|
|
22394
|
+
repoId: external_exports.string(),
|
|
22395
|
+
/** Canonical external URL (e.g. https://github.com/org/repo). Normalize before storing. */
|
|
22396
|
+
canonicalUrl: external_exports.string().url(),
|
|
22397
|
+
/** Optional workspace this repo was first linked in. */
|
|
22398
|
+
workspaceId: external_exports.string().nullable(),
|
|
22399
|
+
displayName: external_exports.string().optional(),
|
|
22400
|
+
createdAt: external_exports.string(),
|
|
22401
|
+
updatedAt: external_exports.string()
|
|
22402
|
+
});
|
|
22403
|
+
var LOCAL_AGENT_AUTH_ERROR_HINTS = {
|
|
22404
|
+
"kiro-acp": [/not logged in/i, /kiro-cli\s+login/i, /log in with kiro-cli/i],
|
|
22405
|
+
"cursor-cli": [/cursor_login/i, /authenticate.*cursor/i, /not logged in.*cursor/i, /run:\s*agent\s+login/i],
|
|
22406
|
+
"codex-acp": [
|
|
22407
|
+
/authentication failed/i,
|
|
22408
|
+
/not authenticated/i,
|
|
22409
|
+
/invalid.*api key/i,
|
|
22410
|
+
/sign in.*openai/i,
|
|
22411
|
+
/login.*openai/i,
|
|
22412
|
+
/unauthorized/i
|
|
22413
|
+
],
|
|
22414
|
+
"claude-code": [
|
|
22415
|
+
/ANTHROPIC_API_KEY/i,
|
|
22416
|
+
/not authenticated/i,
|
|
22417
|
+
/authentication failed/i,
|
|
22418
|
+
/claude\s+login/i,
|
|
22419
|
+
/please run.*claude.*login/i
|
|
22420
|
+
]
|
|
22421
|
+
};
|
|
22422
|
+
function localAgentErrorSuggestsAuth(agentType, errorText) {
|
|
22423
|
+
if (agentType == null || agentType === "" || errorText == null || !String(errorText).trim()) return false;
|
|
22424
|
+
const hints = LOCAL_AGENT_AUTH_ERROR_HINTS[agentType];
|
|
22425
|
+
if (!hints?.length) return false;
|
|
22426
|
+
return hints.some((re) => re.test(String(errorText)));
|
|
22427
|
+
}
|
|
22428
|
+
|
|
22151
22429
|
// src/acp/clients/sdk-stdio-acp-client.ts
|
|
22152
22430
|
import { spawn } from "node:child_process";
|
|
22153
22431
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -22228,6 +22506,83 @@ function toDisplayPathRelativeToCwd(cwd, absolutePath) {
|
|
|
22228
22506
|
return rel.split(path2.sep).join("/");
|
|
22229
22507
|
}
|
|
22230
22508
|
|
|
22509
|
+
// src/acp/clients/agent-stderr-capture.ts
|
|
22510
|
+
var STDERR_CAPTURE_MAX = 48e3;
|
|
22511
|
+
function createStderrCapture(child) {
|
|
22512
|
+
const chunks = [];
|
|
22513
|
+
let total = 0;
|
|
22514
|
+
return {
|
|
22515
|
+
append(chunk) {
|
|
22516
|
+
try {
|
|
22517
|
+
process.stderr.write(chunk);
|
|
22518
|
+
} catch {
|
|
22519
|
+
}
|
|
22520
|
+
if (total >= STDERR_CAPTURE_MAX) return;
|
|
22521
|
+
const n = Math.min(chunk.length, STDERR_CAPTURE_MAX - total);
|
|
22522
|
+
if (n <= 0) return;
|
|
22523
|
+
chunks.push(n === chunk.length ? chunk : chunk.subarray(0, n));
|
|
22524
|
+
total += n;
|
|
22525
|
+
},
|
|
22526
|
+
getText() {
|
|
22527
|
+
return Buffer.concat(chunks).toString("utf8").trim();
|
|
22528
|
+
}
|
|
22529
|
+
};
|
|
22530
|
+
}
|
|
22531
|
+
function formatJsonRpcStyleError(err) {
|
|
22532
|
+
if (err instanceof Error) return err.message;
|
|
22533
|
+
if (err != null && typeof err === "object") {
|
|
22534
|
+
const o = err;
|
|
22535
|
+
const msg = typeof o.message === "string" ? o.message : null;
|
|
22536
|
+
const code = o.code != null ? String(o.code) : "";
|
|
22537
|
+
if (msg) return code ? `[${code}] ${msg}` : msg;
|
|
22538
|
+
}
|
|
22539
|
+
if (typeof err === "string") return err;
|
|
22540
|
+
try {
|
|
22541
|
+
return JSON.stringify(err);
|
|
22542
|
+
} catch {
|
|
22543
|
+
return String(err);
|
|
22544
|
+
}
|
|
22545
|
+
}
|
|
22546
|
+
function mergeErrorWithStderr(primary, stderrText) {
|
|
22547
|
+
const s = stderrText.trim();
|
|
22548
|
+
const p = (primary ?? "").trim();
|
|
22549
|
+
if (!s) return p;
|
|
22550
|
+
if (!p) return s;
|
|
22551
|
+
if (p.includes(s) || s.includes(p)) return p.length >= s.length ? p : s;
|
|
22552
|
+
return `${p}
|
|
22553
|
+
${s}`;
|
|
22554
|
+
}
|
|
22555
|
+
|
|
22556
|
+
// src/acp/clients/kiro-sdk-ext-notifications.ts
|
|
22557
|
+
function createKiroSdkExtNotificationHandler(options) {
|
|
22558
|
+
const { onSessionUpdate } = options;
|
|
22559
|
+
return async (method, params) => {
|
|
22560
|
+
if (method === "_kiro.dev/metadata") {
|
|
22561
|
+
const p = params && typeof params === "object" ? params : {};
|
|
22562
|
+
const pct = p.contextUsagePercentage;
|
|
22563
|
+
if (typeof pct !== "number" || !Number.isFinite(pct) || !onSessionUpdate) return;
|
|
22564
|
+
onSessionUpdate({
|
|
22565
|
+
sessionUpdate: "context_usage",
|
|
22566
|
+
contextUsagePercentage: pct
|
|
22567
|
+
});
|
|
22568
|
+
return;
|
|
22569
|
+
}
|
|
22570
|
+
};
|
|
22571
|
+
}
|
|
22572
|
+
|
|
22573
|
+
// src/acp/clients/sdk-stdio-ext-notifications.ts
|
|
22574
|
+
var noopExtNotification = async () => {
|
|
22575
|
+
};
|
|
22576
|
+
function createSdkStdioExtNotificationHandler(options) {
|
|
22577
|
+
const { backendAgentType, onSessionUpdate } = options;
|
|
22578
|
+
switch (backendAgentType) {
|
|
22579
|
+
case "kiro-acp":
|
|
22580
|
+
return createKiroSdkExtNotificationHandler({ onSessionUpdate });
|
|
22581
|
+
default:
|
|
22582
|
+
return noopExtNotification;
|
|
22583
|
+
}
|
|
22584
|
+
}
|
|
22585
|
+
|
|
22231
22586
|
// src/acp/clients/sdk-stdio-acp-client.ts
|
|
22232
22587
|
function formatSpawnError(err, command) {
|
|
22233
22588
|
if (err.code === "ENOENT") {
|
|
@@ -22235,14 +22590,6 @@ function formatSpawnError(err, command) {
|
|
|
22235
22590
|
}
|
|
22236
22591
|
return err.message || String(err);
|
|
22237
22592
|
}
|
|
22238
|
-
function toErrorMessage(err) {
|
|
22239
|
-
if (err instanceof Error) return err.message;
|
|
22240
|
-
if (err != null && typeof err === "object" && "message" in err)
|
|
22241
|
-
return String(err.message);
|
|
22242
|
-
if (typeof err === "string") return err;
|
|
22243
|
-
if (err != null && typeof err === "object") return JSON.stringify(err);
|
|
22244
|
-
return String(err);
|
|
22245
|
-
}
|
|
22246
22593
|
function sliceFileContentRange(content, line, limit) {
|
|
22247
22594
|
if (line == null && limit == null) return content;
|
|
22248
22595
|
const lines = content.split("\n");
|
|
@@ -22258,6 +22605,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22258
22605
|
const {
|
|
22259
22606
|
command,
|
|
22260
22607
|
cwd = getBridgeWorkspaceDirectory(),
|
|
22608
|
+
backendAgentType,
|
|
22261
22609
|
onSessionUpdate,
|
|
22262
22610
|
onFileChange,
|
|
22263
22611
|
killSubprocessAfterCancelMs,
|
|
@@ -22266,23 +22614,50 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22266
22614
|
const isWindows = process.platform === "win32";
|
|
22267
22615
|
const child = spawn(command[0], command.slice(1), {
|
|
22268
22616
|
cwd,
|
|
22269
|
-
stdio: ["pipe", "pipe", "
|
|
22617
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
22270
22618
|
env: process.env,
|
|
22271
22619
|
shell: isWindows
|
|
22272
22620
|
});
|
|
22621
|
+
const stderrCapture = createStderrCapture(child);
|
|
22273
22622
|
child.once("close", (code, signal) => {
|
|
22274
22623
|
onAgentSubprocessExit?.({ code, signal });
|
|
22275
22624
|
});
|
|
22276
22625
|
return new Promise((resolve14, reject) => {
|
|
22626
|
+
let initSettled = false;
|
|
22627
|
+
const settleReject = (err) => {
|
|
22628
|
+
if (initSettled) return;
|
|
22629
|
+
initSettled = true;
|
|
22630
|
+
try {
|
|
22631
|
+
child.kill();
|
|
22632
|
+
} catch {
|
|
22633
|
+
}
|
|
22634
|
+
reject(err);
|
|
22635
|
+
};
|
|
22636
|
+
const settleResolve = (handle) => {
|
|
22637
|
+
if (initSettled) return;
|
|
22638
|
+
initSettled = true;
|
|
22639
|
+
resolve14(handle);
|
|
22640
|
+
};
|
|
22277
22641
|
child.on("error", (err) => {
|
|
22278
|
-
|
|
22279
|
-
|
|
22642
|
+
settleReject(new Error(formatSpawnError(err, command[0])));
|
|
22643
|
+
});
|
|
22644
|
+
child.stderr?.on("data", (chunk) => {
|
|
22645
|
+
stderrCapture.append(chunk);
|
|
22646
|
+
if (initSettled) return;
|
|
22647
|
+
const stderrText = stderrCapture.getText();
|
|
22648
|
+
if (backendAgentType && stderrText.trim() && localAgentErrorSuggestsAuth(backendAgentType, stderrText)) {
|
|
22649
|
+
settleReject(new Error(stderrText.trim()));
|
|
22650
|
+
}
|
|
22280
22651
|
});
|
|
22281
22652
|
(async () => {
|
|
22282
22653
|
try {
|
|
22283
22654
|
const writable = Writable.toWeb(child.stdin);
|
|
22284
22655
|
const readable = Readable.toWeb(child.stdout);
|
|
22285
22656
|
const stream = ndJsonStream2(writable, readable);
|
|
22657
|
+
const extNotification = createSdkStdioExtNotificationHandler({
|
|
22658
|
+
backendAgentType,
|
|
22659
|
+
onSessionUpdate
|
|
22660
|
+
});
|
|
22286
22661
|
const client = (_agent) => ({
|
|
22287
22662
|
async requestPermission(params) {
|
|
22288
22663
|
const opt = params?.options?.[0];
|
|
@@ -22321,6 +22696,9 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22321
22696
|
},
|
|
22322
22697
|
async sessionUpdate(params) {
|
|
22323
22698
|
onSessionUpdate?.(bridgePayloadFromSdkSessionNotification(params));
|
|
22699
|
+
},
|
|
22700
|
+
async extNotification(method, params) {
|
|
22701
|
+
await extNotification(method, params);
|
|
22324
22702
|
}
|
|
22325
22703
|
});
|
|
22326
22704
|
const connection = new ClientSideConnection2(client, stream);
|
|
@@ -22336,7 +22714,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22336
22714
|
});
|
|
22337
22715
|
const newSessionRes = await connection.newSession({ cwd, mcpServers: [] });
|
|
22338
22716
|
const sessionId = newSessionRes.sessionId;
|
|
22339
|
-
|
|
22717
|
+
settleResolve({
|
|
22340
22718
|
sessionId,
|
|
22341
22719
|
async sendPrompt(prompt, _options) {
|
|
22342
22720
|
try {
|
|
@@ -22344,18 +22722,51 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22344
22722
|
sessionId,
|
|
22345
22723
|
prompt: [{ type: "text", text: prompt }]
|
|
22346
22724
|
});
|
|
22725
|
+
await new Promise((r2) => setImmediate(r2));
|
|
22347
22726
|
const r = response;
|
|
22348
|
-
const
|
|
22727
|
+
const stopReason = (r?.stopReason ?? "").toLowerCase();
|
|
22728
|
+
const cancelled = stopReason === "cancelled";
|
|
22729
|
+
const refusal = stopReason === "refusal";
|
|
22730
|
+
const stderrAfter = stderrCapture.getText();
|
|
22731
|
+
const agentType = backendAgentType ?? null;
|
|
22732
|
+
const stderrEvaluated = Boolean(stderrAfter && agentType);
|
|
22733
|
+
const stderrSuggestsAuth = stderrEvaluated ? localAgentErrorSuggestsAuth(agentType, stderrAfter) : false;
|
|
22734
|
+
if (cancelled) {
|
|
22735
|
+
return {
|
|
22736
|
+
success: false,
|
|
22737
|
+
stopReason: r?.stopReason,
|
|
22738
|
+
output: r?.output,
|
|
22739
|
+
error: mergeErrorWithStderr("Stopped by user", stderrAfter)
|
|
22740
|
+
};
|
|
22741
|
+
}
|
|
22742
|
+
if (refusal) {
|
|
22743
|
+
return {
|
|
22744
|
+
success: false,
|
|
22745
|
+
stopReason: r?.stopReason,
|
|
22746
|
+
output: r?.output,
|
|
22747
|
+
error: mergeErrorWithStderr("The agent refused the request.", stderrAfter)
|
|
22748
|
+
};
|
|
22749
|
+
}
|
|
22750
|
+
if (stderrSuggestsAuth) {
|
|
22751
|
+
return {
|
|
22752
|
+
success: false,
|
|
22753
|
+
stopReason: r?.stopReason,
|
|
22754
|
+
output: r?.output,
|
|
22755
|
+
error: stderrAfter
|
|
22756
|
+
};
|
|
22757
|
+
}
|
|
22349
22758
|
return {
|
|
22350
|
-
success:
|
|
22759
|
+
success: true,
|
|
22351
22760
|
stopReason: r?.stopReason,
|
|
22352
|
-
output: r?.output
|
|
22353
|
-
...cancelled ? { error: "Stopped by user" } : {}
|
|
22761
|
+
output: r?.output
|
|
22354
22762
|
};
|
|
22355
22763
|
} catch (err) {
|
|
22764
|
+
await new Promise((r) => setImmediate(r));
|
|
22765
|
+
const stderrAfter = stderrCapture.getText();
|
|
22766
|
+
const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrAfter);
|
|
22356
22767
|
return {
|
|
22357
22768
|
success: false,
|
|
22358
|
-
error:
|
|
22769
|
+
error: merged
|
|
22359
22770
|
};
|
|
22360
22771
|
}
|
|
22361
22772
|
},
|
|
@@ -22380,8 +22791,14 @@ async function createSdkStdioAcpClient(options) {
|
|
|
22380
22791
|
}
|
|
22381
22792
|
});
|
|
22382
22793
|
} catch (err) {
|
|
22383
|
-
|
|
22384
|
-
|
|
22794
|
+
if (initSettled) return;
|
|
22795
|
+
try {
|
|
22796
|
+
child.kill();
|
|
22797
|
+
} catch {
|
|
22798
|
+
}
|
|
22799
|
+
const stderrText = stderrCapture.getText();
|
|
22800
|
+
const base = formatJsonRpcStyleError(err);
|
|
22801
|
+
settleReject(new Error(mergeErrorWithStderr(base, stderrText)));
|
|
22385
22802
|
}
|
|
22386
22803
|
})();
|
|
22387
22804
|
});
|
|
@@ -27993,11 +28410,20 @@ async function sendPromptToAgent(options) {
|
|
|
27993
28410
|
promptId,
|
|
27994
28411
|
sessionId,
|
|
27995
28412
|
runId,
|
|
28413
|
+
agentType,
|
|
27996
28414
|
agentCwd,
|
|
27997
28415
|
sendResult,
|
|
27998
28416
|
sendSessionUpdate,
|
|
27999
28417
|
log: log2
|
|
28000
28418
|
} = options;
|
|
28419
|
+
function augmentAuthFields(errorText) {
|
|
28420
|
+
const err = errorText ?? "";
|
|
28421
|
+
const at = agentType ?? null;
|
|
28422
|
+
const evaluated = Boolean(at && err.trim());
|
|
28423
|
+
const suggestsAuth = evaluated && at ? localAgentErrorSuggestsAuth(at, err) : false;
|
|
28424
|
+
if (!suggestsAuth || !agentType) return {};
|
|
28425
|
+
return { agentAuthRequired: true, agentType };
|
|
28426
|
+
}
|
|
28001
28427
|
try {
|
|
28002
28428
|
const result = await handle.sendPrompt(promptText, {});
|
|
28003
28429
|
if (sessionId && runId && sendSessionUpdate && agentCwd && result.success) {
|
|
@@ -28009,12 +28435,14 @@ async function sendPromptToAgent(options) {
|
|
|
28009
28435
|
log: log2
|
|
28010
28436
|
});
|
|
28011
28437
|
}
|
|
28438
|
+
const errStr = typeof result.error === "string" ? result.error : void 0;
|
|
28012
28439
|
sendResult({
|
|
28013
28440
|
type: "prompt_result",
|
|
28014
28441
|
id: promptId,
|
|
28015
28442
|
...sessionId ? { sessionId } : {},
|
|
28016
28443
|
...runId ? { runId } : {},
|
|
28017
|
-
...result
|
|
28444
|
+
...result,
|
|
28445
|
+
...augmentAuthFields(errStr)
|
|
28018
28446
|
});
|
|
28019
28447
|
if (!result.success) {
|
|
28020
28448
|
log2(`[Agent] ${result.error ?? "Error"}`);
|
|
@@ -28028,7 +28456,8 @@ async function sendPromptToAgent(options) {
|
|
|
28028
28456
|
...sessionId ? { sessionId } : {},
|
|
28029
28457
|
...runId ? { runId } : {},
|
|
28030
28458
|
success: false,
|
|
28031
|
-
error: errMsg
|
|
28459
|
+
error: errMsg,
|
|
28460
|
+
...augmentAuthFields(errMsg)
|
|
28032
28461
|
});
|
|
28033
28462
|
}
|
|
28034
28463
|
}
|
|
@@ -28047,22 +28476,42 @@ function errorMessage(err) {
|
|
|
28047
28476
|
return String(err);
|
|
28048
28477
|
}
|
|
28049
28478
|
|
|
28050
|
-
// src/acp/clients/
|
|
28051
|
-
var
|
|
28052
|
-
|
|
28053
|
-
|
|
28054
|
-
|
|
28055
|
-
|
|
28056
|
-
|
|
28057
|
-
|
|
28058
|
-
}
|
|
28059
|
-
|
|
28060
|
-
|
|
28061
|
-
|
|
28062
|
-
|
|
28479
|
+
// src/acp/clients/claude-code-acp-client.ts
|
|
28480
|
+
var claude_code_acp_client_exports = {};
|
|
28481
|
+
__export(claude_code_acp_client_exports, {
|
|
28482
|
+
BACKEND_LOCAL_AGENT_TYPE: () => BACKEND_LOCAL_AGENT_TYPE,
|
|
28483
|
+
buildClaudeCodeAcpSpawnCommand: () => buildClaudeCodeAcpSpawnCommand,
|
|
28484
|
+
createClaudeCodeAcpClient: () => createClaudeCodeAcpClient,
|
|
28485
|
+
detectLocalAgentPresence: () => detectLocalAgentPresence
|
|
28486
|
+
});
|
|
28487
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
28488
|
+
import { promisify as promisify4 } from "node:util";
|
|
28489
|
+
|
|
28490
|
+
// src/acp/clients/detect-command-on-path.ts
|
|
28491
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
28492
|
+
import { promisify as promisify3 } from "node:util";
|
|
28493
|
+
var execFileAsync3 = promisify3(execFile3);
|
|
28494
|
+
async function isCommandOnPath(command, timeoutMs = 4e3) {
|
|
28495
|
+
try {
|
|
28496
|
+
await execFileAsync3("which", [command], { timeout: timeoutMs });
|
|
28497
|
+
return true;
|
|
28498
|
+
} catch {
|
|
28499
|
+
return false;
|
|
28500
|
+
}
|
|
28063
28501
|
}
|
|
28064
28502
|
|
|
28065
28503
|
// src/acp/clients/claude-code-acp-client.ts
|
|
28504
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
28505
|
+
var BACKEND_LOCAL_AGENT_TYPE = "claude-code";
|
|
28506
|
+
async function detectLocalAgentPresence() {
|
|
28507
|
+
if (await isCommandOnPath("claude")) return true;
|
|
28508
|
+
try {
|
|
28509
|
+
await execFileAsync4("npx", ["--yes", "@anthropic-ai/claude-code", "--version"], { timeout: 25e3 });
|
|
28510
|
+
return true;
|
|
28511
|
+
} catch {
|
|
28512
|
+
return false;
|
|
28513
|
+
}
|
|
28514
|
+
}
|
|
28066
28515
|
function buildClaudeCodeAcpSpawnCommand(base, sessionMode) {
|
|
28067
28516
|
if (!sessionMode) return [...base];
|
|
28068
28517
|
const m = sessionMode.trim();
|
|
@@ -28079,7 +28528,42 @@ async function createClaudeCodeAcpClient(options) {
|
|
|
28079
28528
|
});
|
|
28080
28529
|
}
|
|
28081
28530
|
|
|
28531
|
+
// src/acp/clients/codex-acp-client.ts
|
|
28532
|
+
var codex_acp_client_exports = {};
|
|
28533
|
+
__export(codex_acp_client_exports, {
|
|
28534
|
+
BACKEND_LOCAL_AGENT_TYPE: () => BACKEND_LOCAL_AGENT_TYPE2,
|
|
28535
|
+
DEFAULT_CODEX_ACP_COMMAND: () => DEFAULT_CODEX_ACP_COMMAND,
|
|
28536
|
+
buildCodexAcpSpawnCommand: () => buildCodexAcpSpawnCommand,
|
|
28537
|
+
createCodexAcpClient: () => createCodexAcpClient,
|
|
28538
|
+
detectLocalAgentPresence: () => detectLocalAgentPresence2,
|
|
28539
|
+
isCodexAcpCommand: () => isCodexAcpCommand
|
|
28540
|
+
});
|
|
28541
|
+
var BACKEND_LOCAL_AGENT_TYPE2 = "codex-acp";
|
|
28542
|
+
async function detectLocalAgentPresence2() {
|
|
28543
|
+
return isCommandOnPath("codex");
|
|
28544
|
+
}
|
|
28545
|
+
var DEFAULT_CODEX_ACP_COMMAND = ["npx", "--yes", "@zed-industries/codex-acp"];
|
|
28546
|
+
function isCodexAcpCommand(command) {
|
|
28547
|
+
const i = command.indexOf("@zed-industries/codex-acp");
|
|
28548
|
+
return i >= 0 && (i === 0 || command[i - 1] === "npx" || command[i - 1] === "bunx");
|
|
28549
|
+
}
|
|
28550
|
+
function buildCodexAcpSpawnCommand(base, _sessionMode) {
|
|
28551
|
+
return [...base];
|
|
28552
|
+
}
|
|
28553
|
+
async function createCodexAcpClient(options) {
|
|
28554
|
+
const base = options.command?.length && options.command.some((a) => a.includes("codex-acp")) ? options.command : [...DEFAULT_CODEX_ACP_COMMAND];
|
|
28555
|
+
const command = buildCodexAcpSpawnCommand(base, options.sessionMode);
|
|
28556
|
+
return createSdkStdioAcpClient({ ...options, command });
|
|
28557
|
+
}
|
|
28558
|
+
|
|
28082
28559
|
// src/acp/clients/cursor-acp-client.ts
|
|
28560
|
+
var cursor_acp_client_exports = {};
|
|
28561
|
+
__export(cursor_acp_client_exports, {
|
|
28562
|
+
BACKEND_LOCAL_AGENT_TYPE: () => BACKEND_LOCAL_AGENT_TYPE3,
|
|
28563
|
+
buildCursorAcpSpawnCommand: () => buildCursorAcpSpawnCommand,
|
|
28564
|
+
createCursorAcpClient: () => createCursorAcpClient,
|
|
28565
|
+
detectLocalAgentPresence: () => detectLocalAgentPresence3
|
|
28566
|
+
});
|
|
28083
28567
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "node:fs";
|
|
28084
28568
|
import { dirname as dirname2 } from "node:path";
|
|
28085
28569
|
import { spawn as spawn4 } from "node:child_process";
|
|
@@ -28130,15 +28614,23 @@ function buildCursorAcpSpawnCommand(base, sessionMode) {
|
|
|
28130
28614
|
}
|
|
28131
28615
|
async function createCursorAcpClient(options) {
|
|
28132
28616
|
const command = buildCursorAcpSpawnCommand(options.command, options.sessionMode);
|
|
28133
|
-
const {
|
|
28617
|
+
const {
|
|
28618
|
+
cwd = getBridgeWorkspaceDirectory(),
|
|
28619
|
+
backendAgentType,
|
|
28620
|
+
onSessionUpdate,
|
|
28621
|
+
onRequest,
|
|
28622
|
+
onFileChange
|
|
28623
|
+
} = options;
|
|
28134
28624
|
const dbgFs = process.env.BUILDAMATON_DEBUG_ACP_FS === "1";
|
|
28135
28625
|
const isWindows = process.platform === "win32";
|
|
28136
28626
|
const child = spawn4(command[0], command.slice(1), {
|
|
28137
28627
|
cwd,
|
|
28138
|
-
stdio: ["pipe", "pipe", "
|
|
28628
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
28139
28629
|
env: process.env,
|
|
28140
28630
|
shell: isWindows
|
|
28141
28631
|
});
|
|
28632
|
+
const stderrCapture = createStderrCapture(child);
|
|
28633
|
+
child.stderr?.on("data", (chunk) => stderrCapture.append(chunk));
|
|
28142
28634
|
return new Promise((resolve14, reject) => {
|
|
28143
28635
|
child.on("error", (err) => {
|
|
28144
28636
|
child.kill();
|
|
@@ -28322,17 +28814,52 @@ async function createCursorAcpClient(options) {
|
|
|
28322
28814
|
sessionId,
|
|
28323
28815
|
prompt: [{ type: "text", text: prompt }]
|
|
28324
28816
|
});
|
|
28817
|
+
await new Promise((r) => setImmediate(r));
|
|
28325
28818
|
const output = (result?.output ?? promptOutputBuffer) || void 0;
|
|
28326
|
-
const
|
|
28819
|
+
const stopReason = (result?.stopReason ?? "").toLowerCase();
|
|
28820
|
+
const cancelled = stopReason === "cancelled";
|
|
28821
|
+
const refusal = stopReason === "refusal";
|
|
28822
|
+
const stderrAfter = stderrCapture.getText();
|
|
28823
|
+
const agentType = backendAgentType ?? null;
|
|
28824
|
+
const stderrEvaluated = Boolean(stderrAfter && agentType);
|
|
28825
|
+
const stderrSuggestsAuth = stderrEvaluated ? localAgentErrorSuggestsAuth(agentType, stderrAfter) : false;
|
|
28826
|
+
if (cancelled) {
|
|
28827
|
+
return {
|
|
28828
|
+
success: false,
|
|
28829
|
+
stopReason: result?.stopReason,
|
|
28830
|
+
output: output || void 0,
|
|
28831
|
+
error: mergeErrorWithStderr("Stopped by user", stderrAfter)
|
|
28832
|
+
};
|
|
28833
|
+
}
|
|
28834
|
+
if (refusal) {
|
|
28835
|
+
return {
|
|
28836
|
+
success: false,
|
|
28837
|
+
stopReason: result?.stopReason,
|
|
28838
|
+
output: output || void 0,
|
|
28839
|
+
error: mergeErrorWithStderr("The agent refused the request.", stderrAfter)
|
|
28840
|
+
};
|
|
28841
|
+
}
|
|
28842
|
+
if (stderrSuggestsAuth) {
|
|
28843
|
+
return {
|
|
28844
|
+
success: false,
|
|
28845
|
+
stopReason: result?.stopReason,
|
|
28846
|
+
output: output || void 0,
|
|
28847
|
+
error: stderrAfter
|
|
28848
|
+
};
|
|
28849
|
+
}
|
|
28327
28850
|
return {
|
|
28328
|
-
success:
|
|
28851
|
+
success: true,
|
|
28329
28852
|
stopReason: result?.stopReason,
|
|
28330
|
-
output: output || void 0
|
|
28331
|
-
...cancelled ? { error: "Stopped by user" } : {}
|
|
28853
|
+
output: output || void 0
|
|
28332
28854
|
};
|
|
28333
28855
|
} catch (err) {
|
|
28334
|
-
|
|
28335
|
-
|
|
28856
|
+
await new Promise((r) => setImmediate(r));
|
|
28857
|
+
const stderrAfter = stderrCapture.getText();
|
|
28858
|
+
const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrAfter);
|
|
28859
|
+
return {
|
|
28860
|
+
success: false,
|
|
28861
|
+
error: merged
|
|
28862
|
+
};
|
|
28336
28863
|
}
|
|
28337
28864
|
},
|
|
28338
28865
|
async cancel() {
|
|
@@ -28351,23 +28878,62 @@ async function createCursorAcpClient(options) {
|
|
|
28351
28878
|
});
|
|
28352
28879
|
} catch (err) {
|
|
28353
28880
|
child.kill();
|
|
28354
|
-
|
|
28881
|
+
const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrCapture.getText());
|
|
28882
|
+
reject(merged ? new Error(merged) : err instanceof Error ? err : new Error(String(err)));
|
|
28355
28883
|
}
|
|
28356
28884
|
})();
|
|
28357
28885
|
});
|
|
28358
28886
|
}
|
|
28887
|
+
var BACKEND_LOCAL_AGENT_TYPE3 = "cursor-cli";
|
|
28888
|
+
async function detectLocalAgentPresence3() {
|
|
28889
|
+
return isCommandOnPath("agent");
|
|
28890
|
+
}
|
|
28891
|
+
|
|
28892
|
+
// src/acp/clients/kiro-acp-client.ts
|
|
28893
|
+
var kiro_acp_client_exports = {};
|
|
28894
|
+
__export(kiro_acp_client_exports, {
|
|
28895
|
+
BACKEND_LOCAL_AGENT_TYPE: () => BACKEND_LOCAL_AGENT_TYPE4,
|
|
28896
|
+
DEFAULT_KIRO_ACP_COMMAND: () => DEFAULT_KIRO_ACP_COMMAND,
|
|
28897
|
+
buildKiroAcpSpawnCommand: () => buildKiroAcpSpawnCommand,
|
|
28898
|
+
createKiroAcpClient: () => createKiroAcpClient,
|
|
28899
|
+
detectLocalAgentPresence: () => detectLocalAgentPresence4,
|
|
28900
|
+
isKiroAcpCommand: () => isKiroAcpCommand
|
|
28901
|
+
});
|
|
28902
|
+
var BACKEND_LOCAL_AGENT_TYPE4 = "kiro-acp";
|
|
28903
|
+
async function detectLocalAgentPresence4() {
|
|
28904
|
+
return isCommandOnPath("kiro-cli");
|
|
28905
|
+
}
|
|
28906
|
+
var DEFAULT_KIRO_ACP_COMMAND = ["kiro-cli", "acp"];
|
|
28907
|
+
function isKiroAcpCommand(command) {
|
|
28908
|
+
if (command.length < 2) return false;
|
|
28909
|
+
if (command[command.length - 1] !== "acp") return false;
|
|
28910
|
+
return command.slice(0, -1).some(
|
|
28911
|
+
(a) => a === "kiro-cli" || /[/\\]kiro-cli(\.exe)?$/i.test(a)
|
|
28912
|
+
);
|
|
28913
|
+
}
|
|
28914
|
+
function buildKiroAcpSpawnCommand(base, _sessionMode) {
|
|
28915
|
+
return [...base];
|
|
28916
|
+
}
|
|
28917
|
+
async function createKiroAcpClient(options) {
|
|
28918
|
+
const base = options.command?.length && isKiroAcpCommand(options.command) ? options.command : [...DEFAULT_KIRO_ACP_COMMAND];
|
|
28919
|
+
const command = buildKiroAcpSpawnCommand(base, options.sessionMode);
|
|
28920
|
+
return createSdkStdioAcpClient({ ...options, command });
|
|
28921
|
+
}
|
|
28359
28922
|
|
|
28360
28923
|
// src/acp/resolve-agent-command.ts
|
|
28361
28924
|
var AGENT_TYPE_DEFAULT_COMMANDS = {
|
|
28362
|
-
|
|
28363
|
-
|
|
28925
|
+
[BACKEND_LOCAL_AGENT_TYPE3]: ["agent", "acp"],
|
|
28926
|
+
[BACKEND_LOCAL_AGENT_TYPE2]: [...DEFAULT_CODEX_ACP_COMMAND],
|
|
28364
28927
|
/** ACP stdio agent; `@anthropic-ai/claude-code` is the interactive CLI and does not speak ACP on stdout. */
|
|
28365
|
-
|
|
28928
|
+
[BACKEND_LOCAL_AGENT_TYPE]: ["npx", "--yes", "@agentclientprotocol/claude-agent-acp"],
|
|
28929
|
+
/** [Kiro CLI ACP](https://kiro.dev/docs/cli/acp/) — use full path to `kiro-cli` in PATH if the IDE cannot find it. */
|
|
28930
|
+
[BACKEND_LOCAL_AGENT_TYPE4]: [...DEFAULT_KIRO_ACP_COMMAND]
|
|
28366
28931
|
};
|
|
28367
28932
|
var AGENT_TYPE_DISPLAY_NAMES = {
|
|
28368
|
-
|
|
28369
|
-
|
|
28370
|
-
|
|
28933
|
+
[BACKEND_LOCAL_AGENT_TYPE3]: "Cursor",
|
|
28934
|
+
[BACKEND_LOCAL_AGENT_TYPE2]: "Codex",
|
|
28935
|
+
[BACKEND_LOCAL_AGENT_TYPE]: "Claude Code",
|
|
28936
|
+
[BACKEND_LOCAL_AGENT_TYPE4]: "Kiro"
|
|
28371
28937
|
};
|
|
28372
28938
|
function getAgentTypeDisplayName(agentType) {
|
|
28373
28939
|
if (agentType == null || agentType === "") return "Unknown agent";
|
|
@@ -28376,13 +28942,17 @@ function getAgentTypeDisplayName(agentType) {
|
|
|
28376
28942
|
return agentType.split(/[-_]/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
|
|
28377
28943
|
}
|
|
28378
28944
|
function useCursorAcp(agentType, command) {
|
|
28379
|
-
if (agentType ===
|
|
28945
|
+
if (agentType === BACKEND_LOCAL_AGENT_TYPE3) return true;
|
|
28380
28946
|
return command[0] === "agent" && command[1] === "acp";
|
|
28381
28947
|
}
|
|
28382
28948
|
function useCodexAcp(agentType, command) {
|
|
28383
|
-
if (agentType ===
|
|
28949
|
+
if (agentType === BACKEND_LOCAL_AGENT_TYPE2) return true;
|
|
28384
28950
|
return isCodexAcpCommand(command);
|
|
28385
28951
|
}
|
|
28952
|
+
function useKiroAcp(agentType, command) {
|
|
28953
|
+
if (agentType === BACKEND_LOCAL_AGENT_TYPE4) return true;
|
|
28954
|
+
return isKiroAcpCommand(command);
|
|
28955
|
+
}
|
|
28386
28956
|
function resolveAgentCommand(preferredAgentType) {
|
|
28387
28957
|
if (!preferredAgentType) return null;
|
|
28388
28958
|
const command = AGENT_TYPE_DEFAULT_COMMANDS[preferredAgentType];
|
|
@@ -28403,6 +28973,14 @@ function resolveAgentCommand(preferredAgentType) {
|
|
|
28403
28973
|
spawnCommandForSession: (sessionMode) => buildCodexAcpSpawnCommand(command, sessionMode)
|
|
28404
28974
|
};
|
|
28405
28975
|
}
|
|
28976
|
+
if (useKiroAcp(preferredAgentType, command)) {
|
|
28977
|
+
return {
|
|
28978
|
+
command,
|
|
28979
|
+
label: preferredAgentType,
|
|
28980
|
+
createClient: createKiroAcpClient,
|
|
28981
|
+
spawnCommandForSession: (sessionMode) => buildKiroAcpSpawnCommand(command, sessionMode)
|
|
28982
|
+
};
|
|
28983
|
+
}
|
|
28406
28984
|
return {
|
|
28407
28985
|
command,
|
|
28408
28986
|
label: preferredAgentType,
|
|
@@ -29106,6 +29684,7 @@ async function ensureAcpClient(options) {
|
|
|
29106
29684
|
command: resolved.command,
|
|
29107
29685
|
sessionMode: mode,
|
|
29108
29686
|
cwd: targetCwd,
|
|
29687
|
+
backendAgentType: preferredAgentType,
|
|
29109
29688
|
onAgentSubprocessExit: () => {
|
|
29110
29689
|
state.acpHandle = null;
|
|
29111
29690
|
state.acpStartPromise = null;
|
|
@@ -29186,17 +29765,24 @@ async function createAcpManager(options) {
|
|
|
29186
29765
|
log: log2
|
|
29187
29766
|
});
|
|
29188
29767
|
if (!handle) {
|
|
29768
|
+
const errMsg = state.lastAcpStartError || "No agent configured. Register local agents on this bridge in the app.";
|
|
29769
|
+
const evaluated = Boolean(preferredForPrompt && errMsg.trim());
|
|
29770
|
+
const suggestsAuth = evaluated ? localAgentErrorSuggestsAuth(preferredForPrompt, errMsg) : false;
|
|
29771
|
+
const auth = suggestsAuth && preferredForPrompt ? { agentAuthRequired: true, agentType: preferredForPrompt } : {};
|
|
29189
29772
|
sendResult({
|
|
29190
29773
|
type: "prompt_result",
|
|
29191
29774
|
id: promptId,
|
|
29192
29775
|
...sessionId ? { sessionId } : {},
|
|
29193
29776
|
...runId ? { runId } : {},
|
|
29194
29777
|
success: false,
|
|
29195
|
-
error:
|
|
29778
|
+
error: errMsg,
|
|
29779
|
+
...auth
|
|
29196
29780
|
});
|
|
29197
29781
|
return;
|
|
29198
29782
|
}
|
|
29199
|
-
if (promptRouting.sessionId !== sessionId || promptRouting.runId !== runId)
|
|
29783
|
+
if (promptRouting.sessionId !== sessionId || promptRouting.runId !== runId) {
|
|
29784
|
+
return;
|
|
29785
|
+
}
|
|
29200
29786
|
if (runId && pendingCancelRunId === runId) {
|
|
29201
29787
|
pendingCancelRunId = void 0;
|
|
29202
29788
|
try {
|
|
@@ -29220,6 +29806,7 @@ async function createAcpManager(options) {
|
|
|
29220
29806
|
promptId,
|
|
29221
29807
|
sessionId,
|
|
29222
29808
|
runId,
|
|
29809
|
+
agentType: preferredForPrompt,
|
|
29223
29810
|
agentCwd: cwd,
|
|
29224
29811
|
sendResult,
|
|
29225
29812
|
sendSessionUpdate,
|
|
@@ -29317,8 +29904,8 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
29317
29904
|
|
|
29318
29905
|
// src/acp/from-bridge/handle-bridge-prompt.ts
|
|
29319
29906
|
import * as path11 from "node:path";
|
|
29320
|
-
import { execFile as
|
|
29321
|
-
import { promisify as
|
|
29907
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
29908
|
+
import { promisify as promisify5 } from "node:util";
|
|
29322
29909
|
|
|
29323
29910
|
// src/git/bridge-queue-key.ts
|
|
29324
29911
|
import * as path10 from "node:path";
|
|
@@ -29376,10 +29963,10 @@ async function resolveBridgeQueueBindFields(options) {
|
|
|
29376
29963
|
}
|
|
29377
29964
|
|
|
29378
29965
|
// src/acp/from-bridge/handle-bridge-prompt.ts
|
|
29379
|
-
var
|
|
29966
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
29380
29967
|
async function readGitBranch(cwd) {
|
|
29381
29968
|
try {
|
|
29382
|
-
const { stdout } = await
|
|
29969
|
+
const { stdout } = await execFileAsync5("git", ["branch", "--show-current"], { cwd, maxBuffer: 64 * 1024 });
|
|
29383
29970
|
const b = stdout.trim();
|
|
29384
29971
|
return b || null;
|
|
29385
29972
|
} catch {
|
|
@@ -31813,48 +32400,19 @@ function createOnBridgeIdentified(opts) {
|
|
|
31813
32400
|
};
|
|
31814
32401
|
}
|
|
31815
32402
|
|
|
31816
|
-
// src/
|
|
31817
|
-
|
|
31818
|
-
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
await execFileAsync4("which", ["agent"], { timeout: 4e3 });
|
|
31824
|
-
return true;
|
|
31825
|
-
} catch {
|
|
31826
|
-
return false;
|
|
31827
|
-
}
|
|
31828
|
-
},
|
|
31829
|
-
"codex-acp": async () => {
|
|
31830
|
-
try {
|
|
31831
|
-
await execFileAsync4("which", ["codex"], { timeout: 4e3 });
|
|
31832
|
-
return true;
|
|
31833
|
-
} catch {
|
|
31834
|
-
return false;
|
|
31835
|
-
}
|
|
31836
|
-
},
|
|
31837
|
-
/** Bridge spawns `@agentclientprotocol/claude-agent-acp` via npx; detection is “Claude toolchain likely present”. */
|
|
31838
|
-
"claude-code": async () => {
|
|
31839
|
-
try {
|
|
31840
|
-
await execFileAsync4("which", ["claude"], { timeout: 4e3 });
|
|
31841
|
-
return true;
|
|
31842
|
-
} catch {
|
|
31843
|
-
try {
|
|
31844
|
-
await execFileAsync4("npx", ["--yes", "@anthropic-ai/claude-code", "--version"], { timeout: 25e3 });
|
|
31845
|
-
return true;
|
|
31846
|
-
} catch {
|
|
31847
|
-
return false;
|
|
31848
|
-
}
|
|
31849
|
-
}
|
|
31850
|
-
}
|
|
31851
|
-
};
|
|
32403
|
+
// src/acp/detect-local-agent-types.ts
|
|
32404
|
+
var LOCAL_AGENT_ACP_MODULES = [
|
|
32405
|
+
cursor_acp_client_exports,
|
|
32406
|
+
codex_acp_client_exports,
|
|
32407
|
+
kiro_acp_client_exports,
|
|
32408
|
+
claude_code_acp_client_exports
|
|
32409
|
+
];
|
|
31852
32410
|
async function detectLocalAgentTypes() {
|
|
31853
32411
|
try {
|
|
31854
32412
|
const out = [];
|
|
31855
|
-
for (const
|
|
32413
|
+
for (const mod of LOCAL_AGENT_ACP_MODULES) {
|
|
31856
32414
|
try {
|
|
31857
|
-
if (await
|
|
32415
|
+
if (await mod.detectLocalAgentPresence()) out.push(mod.BACKEND_LOCAL_AGENT_TYPE);
|
|
31858
32416
|
} catch {
|
|
31859
32417
|
}
|
|
31860
32418
|
}
|