@openacp/cli 2026.403.6 → 2026.403.8
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 +163 -65
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +124 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1486,6 +1486,15 @@ declare class Session extends TypedEmitter<SessionEvents> {
|
|
|
1486
1486
|
private autoName;
|
|
1487
1487
|
setInitialConfigOptions(options: ConfigOption[]): void;
|
|
1488
1488
|
setAgentCapabilities(caps: AgentCapabilities | undefined): void;
|
|
1489
|
+
/**
|
|
1490
|
+
* Hydrate configOptions and agentCapabilities from a spawn response.
|
|
1491
|
+
* Handles both the native configOptions format and legacy modes/models fields.
|
|
1492
|
+
*/
|
|
1493
|
+
applySpawnResponse(resp: {
|
|
1494
|
+
modes?: unknown;
|
|
1495
|
+
configOptions?: unknown;
|
|
1496
|
+
models?: unknown;
|
|
1497
|
+
} | undefined, caps: AgentCapabilities | undefined): void;
|
|
1489
1498
|
getConfigOption(id: string): ConfigOption | undefined;
|
|
1490
1499
|
getConfigByCategory(category: string): ConfigOption | undefined;
|
|
1491
1500
|
getConfigValue(id: string): string | undefined;
|
|
@@ -2008,6 +2017,7 @@ declare class SessionFactory {
|
|
|
2008
2017
|
private lazyResume;
|
|
2009
2018
|
handleNewSession(channelId: string, agentName?: string, workspacePath?: string, options?: {
|
|
2010
2019
|
createThread?: boolean;
|
|
2020
|
+
threadId?: string;
|
|
2011
2021
|
}): Promise<Session>;
|
|
2012
2022
|
/** NOTE: handleNewChat is currently dead code — never called outside core.ts itself.
|
|
2013
2023
|
* Moving it anyway for completeness; can be removed in a future cleanup. */
|
|
@@ -2019,6 +2029,7 @@ declare class SessionFactory {
|
|
|
2019
2029
|
contextQuery: ContextQuery;
|
|
2020
2030
|
contextOptions?: ContextOptions;
|
|
2021
2031
|
createThread?: boolean;
|
|
2032
|
+
threadId?: string;
|
|
2022
2033
|
}): Promise<{
|
|
2023
2034
|
session: Session;
|
|
2024
2035
|
contextResult: ContextResult | null;
|
|
@@ -2154,6 +2165,7 @@ interface AssistantManagerCore {
|
|
|
2154
2165
|
workingDirectory: string;
|
|
2155
2166
|
initialName?: string;
|
|
2156
2167
|
isAssistant?: boolean;
|
|
2168
|
+
threadId?: string;
|
|
2157
2169
|
}): Promise<Session>;
|
|
2158
2170
|
connectSessionBridge(session: Session): void;
|
|
2159
2171
|
configManager: {
|
|
@@ -2258,6 +2270,7 @@ declare class OpenACPCore {
|
|
|
2258
2270
|
}): Promise<Session>;
|
|
2259
2271
|
handleNewSession(channelId: string, agentName?: string, workspacePath?: string, options?: {
|
|
2260
2272
|
createThread?: boolean;
|
|
2273
|
+
threadId?: string;
|
|
2261
2274
|
}): Promise<Session>;
|
|
2262
2275
|
adoptSession(agentName: string, agentSessionId: string, cwd: string, channelId?: string): Promise<{
|
|
2263
2276
|
ok: true;
|
|
@@ -2277,6 +2290,7 @@ declare class OpenACPCore {
|
|
|
2277
2290
|
contextQuery: ContextQuery;
|
|
2278
2291
|
contextOptions?: ContextOptions;
|
|
2279
2292
|
createThread?: boolean;
|
|
2293
|
+
threadId?: string;
|
|
2280
2294
|
}): Promise<{
|
|
2281
2295
|
session: Session;
|
|
2282
2296
|
contextResult: ContextResult | null;
|
package/dist/index.js
CHANGED
|
@@ -1078,7 +1078,7 @@ var BYPASS_KEYWORDS;
|
|
|
1078
1078
|
var init_bypass_detection = __esm({
|
|
1079
1079
|
"src/core/utils/bypass-detection.ts"() {
|
|
1080
1080
|
"use strict";
|
|
1081
|
-
BYPASS_KEYWORDS = ["bypass", "dangerous", "auto_accept"];
|
|
1081
|
+
BYPASS_KEYWORDS = ["bypass", "dangerous", "auto_accept", "yolo"];
|
|
1082
1082
|
}
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
@@ -6311,9 +6311,7 @@ async function createSessionDirect(ctx, core, chatId, agentName, workspace, onCo
|
|
|
6311
6311
|
message_thread_id: threadId,
|
|
6312
6312
|
parse_mode: "HTML"
|
|
6313
6313
|
});
|
|
6314
|
-
const session = await core.handleNewSession("telegram", agentName, workspace);
|
|
6315
|
-
session.threadId = String(threadId);
|
|
6316
|
-
await core.sessionManager.patchRecord(session.id, { platform: { topicId: threadId } });
|
|
6314
|
+
const session = await core.handleNewSession("telegram", agentName, workspace, { threadId: String(threadId) });
|
|
6317
6315
|
const finalName = `\u{1F504} ${session.agentName} \u2014 New Session`;
|
|
6318
6316
|
try {
|
|
6319
6317
|
await ctx.api.editForumTopic(chatId, threadId, { name: finalName });
|
|
@@ -11213,12 +11211,18 @@ ${stderr}`
|
|
|
11213
11211
|
cwd: workingDirectory,
|
|
11214
11212
|
mcpServers: resolvedMcp
|
|
11215
11213
|
});
|
|
11214
|
+
log4.info(response, "newSession response");
|
|
11216
11215
|
instance.sessionId = response.sessionId;
|
|
11217
11216
|
instance.initialSessionResponse = response;
|
|
11218
11217
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
11219
11218
|
instance.setupCrashDetection();
|
|
11220
11219
|
log4.info(
|
|
11221
|
-
{
|
|
11220
|
+
{
|
|
11221
|
+
sessionId: response.sessionId,
|
|
11222
|
+
durationMs: Date.now() - spawnStart,
|
|
11223
|
+
configOptions: response.configOptions ?? [],
|
|
11224
|
+
agentCapabilities: instance.agentCapabilities ?? null
|
|
11225
|
+
},
|
|
11222
11226
|
"Agent spawn complete"
|
|
11223
11227
|
);
|
|
11224
11228
|
return instance;
|
|
@@ -11230,24 +11234,47 @@ ${stderr}`
|
|
|
11230
11234
|
agentDef,
|
|
11231
11235
|
workingDirectory
|
|
11232
11236
|
);
|
|
11237
|
+
const resolvedMcp = _AgentInstance.mcpManager.resolve(mcpServers);
|
|
11233
11238
|
try {
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11239
|
+
if (instance.agentCapabilities?.loadSession) {
|
|
11240
|
+
const response = await instance.connection.loadSession({
|
|
11241
|
+
sessionId: agentSessionId,
|
|
11242
|
+
cwd: workingDirectory,
|
|
11243
|
+
mcpServers: resolvedMcp
|
|
11244
|
+
});
|
|
11245
|
+
instance.sessionId = agentSessionId;
|
|
11246
|
+
instance.initialSessionResponse = response;
|
|
11247
|
+
instance.debugTracer = createDebugTracer(agentSessionId, workingDirectory);
|
|
11248
|
+
log4.info(
|
|
11249
|
+
{
|
|
11250
|
+
sessionId: agentSessionId,
|
|
11251
|
+
durationMs: Date.now() - spawnStart,
|
|
11252
|
+
agentCapabilities: instance.agentCapabilities ?? null
|
|
11253
|
+
},
|
|
11254
|
+
"Agent load complete"
|
|
11255
|
+
);
|
|
11256
|
+
} else {
|
|
11257
|
+
const response = await instance.connection.unstable_resumeSession({
|
|
11258
|
+
sessionId: agentSessionId,
|
|
11259
|
+
cwd: workingDirectory
|
|
11260
|
+
});
|
|
11261
|
+
instance.sessionId = response.sessionId;
|
|
11262
|
+
instance.initialSessionResponse = response;
|
|
11263
|
+
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
11264
|
+
log4.info(
|
|
11265
|
+
{
|
|
11266
|
+
sessionId: response.sessionId,
|
|
11267
|
+
durationMs: Date.now() - spawnStart,
|
|
11268
|
+
agentCapabilities: instance.agentCapabilities ?? null
|
|
11269
|
+
},
|
|
11270
|
+
"Agent resume complete"
|
|
11271
|
+
);
|
|
11272
|
+
}
|
|
11245
11273
|
} catch (err) {
|
|
11246
11274
|
log4.warn(
|
|
11247
11275
|
{ err, agentSessionId },
|
|
11248
11276
|
"Resume failed, falling back to new session"
|
|
11249
11277
|
);
|
|
11250
|
-
const resolvedMcp = _AgentInstance.mcpManager.resolve(mcpServers);
|
|
11251
11278
|
const response = await instance.connection.newSession({
|
|
11252
11279
|
cwd: workingDirectory,
|
|
11253
11280
|
mcpServers: resolvedMcp
|
|
@@ -11478,11 +11505,31 @@ ${stderr}`
|
|
|
11478
11505
|
}
|
|
11479
11506
|
// ── New ACP methods ──────────────────────────────────────────────────
|
|
11480
11507
|
async setConfigOption(configId, value) {
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11508
|
+
try {
|
|
11509
|
+
return await this.connection.setSessionConfigOption({
|
|
11510
|
+
sessionId: this.sessionId,
|
|
11511
|
+
configId,
|
|
11512
|
+
...value
|
|
11513
|
+
});
|
|
11514
|
+
} catch (err) {
|
|
11515
|
+
if (typeof err === "object" && err !== null && err.code === -32601) {
|
|
11516
|
+
if (configId === "mode" && value.type === "select") {
|
|
11517
|
+
await this.connection.setSessionMode({
|
|
11518
|
+
sessionId: this.sessionId,
|
|
11519
|
+
modeId: value.value
|
|
11520
|
+
});
|
|
11521
|
+
return { configOptions: [] };
|
|
11522
|
+
}
|
|
11523
|
+
if (configId === "model" && value.type === "select") {
|
|
11524
|
+
await this.connection.unstable_setSessionModel({
|
|
11525
|
+
sessionId: this.sessionId,
|
|
11526
|
+
modelId: value.value
|
|
11527
|
+
});
|
|
11528
|
+
return { configOptions: [] };
|
|
11529
|
+
}
|
|
11530
|
+
}
|
|
11531
|
+
throw err;
|
|
11532
|
+
}
|
|
11486
11533
|
}
|
|
11487
11534
|
async listSessions(cwd, cursor) {
|
|
11488
11535
|
return await this.connection.listSessions({
|
|
@@ -11800,8 +11847,10 @@ var Session = class extends TypedEmitter {
|
|
|
11800
11847
|
this.queue = new PromptQueue(
|
|
11801
11848
|
(text3, attachments) => this.processPrompt(text3, attachments),
|
|
11802
11849
|
(err) => {
|
|
11803
|
-
this.fail("Prompt execution failed");
|
|
11804
11850
|
this.log.error({ err }, "Prompt execution failed");
|
|
11851
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
11852
|
+
this.fail(message);
|
|
11853
|
+
this.emit("agent_event", { type: "error", message: `Prompt execution failed: ${message}` });
|
|
11805
11854
|
}
|
|
11806
11855
|
);
|
|
11807
11856
|
this.agentInstance.on("agent_event", (event) => {
|
|
@@ -12055,6 +12104,42 @@ ${result.text}` : result.text;
|
|
|
12055
12104
|
setAgentCapabilities(caps) {
|
|
12056
12105
|
this.agentCapabilities = caps;
|
|
12057
12106
|
}
|
|
12107
|
+
/**
|
|
12108
|
+
* Hydrate configOptions and agentCapabilities from a spawn response.
|
|
12109
|
+
* Handles both the native configOptions format and legacy modes/models fields.
|
|
12110
|
+
*/
|
|
12111
|
+
applySpawnResponse(resp, caps) {
|
|
12112
|
+
if (caps) this.agentCapabilities = caps;
|
|
12113
|
+
if (!resp) return;
|
|
12114
|
+
if (resp.configOptions) {
|
|
12115
|
+
this.configOptions = resp.configOptions;
|
|
12116
|
+
return;
|
|
12117
|
+
}
|
|
12118
|
+
const legacyOptions = [];
|
|
12119
|
+
if (resp.modes) {
|
|
12120
|
+
const m = resp.modes;
|
|
12121
|
+
legacyOptions.push({
|
|
12122
|
+
id: "mode",
|
|
12123
|
+
name: "Mode",
|
|
12124
|
+
category: "mode",
|
|
12125
|
+
type: "select",
|
|
12126
|
+
currentValue: m.currentModeId,
|
|
12127
|
+
options: m.availableModes.map((x) => ({ value: x.id, name: x.name, description: x.description }))
|
|
12128
|
+
});
|
|
12129
|
+
}
|
|
12130
|
+
if (resp.models) {
|
|
12131
|
+
const m = resp.models;
|
|
12132
|
+
legacyOptions.push({
|
|
12133
|
+
id: "model",
|
|
12134
|
+
name: "Model",
|
|
12135
|
+
category: "model",
|
|
12136
|
+
type: "select",
|
|
12137
|
+
currentValue: m.currentModelId,
|
|
12138
|
+
options: m.availableModels.map((x) => ({ value: x.modelId ?? x.id, name: x.name, description: x.description }))
|
|
12139
|
+
});
|
|
12140
|
+
}
|
|
12141
|
+
if (legacyOptions.length > 0) this.configOptions = legacyOptions;
|
|
12142
|
+
}
|
|
12058
12143
|
getConfigOption(id) {
|
|
12059
12144
|
return this.configOptions.find((o) => o.id === id);
|
|
12060
12145
|
}
|
|
@@ -12074,8 +12159,13 @@ ${result.text}` : result.text;
|
|
|
12074
12159
|
/** Send a config option change to the agent and update local state from the response. */
|
|
12075
12160
|
async setConfigOption(configId, value) {
|
|
12076
12161
|
const response = await this.agentInstance.setConfigOption(configId, value);
|
|
12077
|
-
if (response.configOptions) {
|
|
12162
|
+
if (response.configOptions && response.configOptions.length > 0) {
|
|
12078
12163
|
await this.updateConfigOptions(response.configOptions);
|
|
12164
|
+
} else if (value.type === "select") {
|
|
12165
|
+
const updated = this.configOptions.map(
|
|
12166
|
+
(o) => o.id === configId && o.type === "select" ? { ...o, currentValue: value.value } : o
|
|
12167
|
+
);
|
|
12168
|
+
await this.updateConfigOptions(updated);
|
|
12079
12169
|
}
|
|
12080
12170
|
}
|
|
12081
12171
|
async updateConfigOptions(options) {
|
|
@@ -12139,6 +12229,8 @@ ${result.text}` : result.text;
|
|
|
12139
12229
|
this.promptCount = 0;
|
|
12140
12230
|
this.agentCapabilities = void 0;
|
|
12141
12231
|
this.configOptions = [];
|
|
12232
|
+
this.latestCommands = null;
|
|
12233
|
+
this.applySpawnResponse(newAgent.initialSessionResponse, newAgent.agentCapabilities);
|
|
12142
12234
|
this.log.info({ from: this.agentSwitchHistory.at(-1).agentName, to: agentName }, "Agent switched");
|
|
12143
12235
|
}
|
|
12144
12236
|
async destroy() {
|
|
@@ -12815,6 +12907,9 @@ var SessionBridge = class {
|
|
|
12815
12907
|
if (this.session.latestCommands !== null) {
|
|
12816
12908
|
this.session.emit("agent_event", { type: "commands_update", commands: this.session.latestCommands });
|
|
12817
12909
|
}
|
|
12910
|
+
if (this.session.configOptions.length > 0) {
|
|
12911
|
+
this.session.emit("agent_event", { type: "config_option_update", options: this.session.configOptions });
|
|
12912
|
+
}
|
|
12818
12913
|
}
|
|
12819
12914
|
disconnect() {
|
|
12820
12915
|
if (!this.connected) return;
|
|
@@ -13185,17 +13280,7 @@ var SessionFactory = class {
|
|
|
13185
13280
|
if (createParams.initialName) {
|
|
13186
13281
|
session.name = createParams.initialName;
|
|
13187
13282
|
}
|
|
13188
|
-
|
|
13189
|
-
if (resp) {
|
|
13190
|
-
if (resp.configOptions) {
|
|
13191
|
-
session.setInitialConfigOptions(resp.configOptions);
|
|
13192
|
-
}
|
|
13193
|
-
if (agentInstance.agentCapabilities) {
|
|
13194
|
-
session.setAgentCapabilities(agentInstance.agentCapabilities);
|
|
13195
|
-
}
|
|
13196
|
-
} else if (agentInstance.agentCapabilities) {
|
|
13197
|
-
session.setAgentCapabilities(agentInstance.agentCapabilities);
|
|
13198
|
-
}
|
|
13283
|
+
session.applySpawnResponse(agentInstance.initialSessionResponse, agentInstance.agentCapabilities);
|
|
13199
13284
|
this.sessionManager.registerSession(session);
|
|
13200
13285
|
this.eventBus.emit("session:created", {
|
|
13201
13286
|
sessionId: session.id,
|
|
@@ -13348,7 +13433,8 @@ var SessionFactory = class {
|
|
|
13348
13433
|
channelId: params.channelId,
|
|
13349
13434
|
agentName: params.agentName,
|
|
13350
13435
|
workingDirectory: params.workingDirectory,
|
|
13351
|
-
createThread: params.createThread
|
|
13436
|
+
createThread: params.createThread,
|
|
13437
|
+
threadId: params.threadId
|
|
13352
13438
|
});
|
|
13353
13439
|
if (contextResult) {
|
|
13354
13440
|
session.setContext(contextResult.markdown);
|
|
@@ -14911,9 +14997,9 @@ var AssistantManager = class {
|
|
|
14911
14997
|
agentName: this.core.configManager.get().defaultAgent,
|
|
14912
14998
|
workingDirectory: this.core.configManager.resolveWorkspace(),
|
|
14913
14999
|
initialName: "Assistant",
|
|
14914
|
-
isAssistant: true
|
|
15000
|
+
isAssistant: true,
|
|
15001
|
+
threadId
|
|
14915
15002
|
});
|
|
14916
|
-
session.threadId = threadId;
|
|
14917
15003
|
this.sessions.set(channelId, session);
|
|
14918
15004
|
const systemPrompt = this.registry.buildSystemPrompt(channelId);
|
|
14919
15005
|
this.pendingSystemPrompts.set(channelId, systemPrompt);
|