topchester-ai 0.61.0 → 0.62.0
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/bin.mjs
CHANGED
|
@@ -9174,6 +9174,17 @@ const messagePayloadSchema = z.object({
|
|
|
9174
9174
|
text: z.string(),
|
|
9175
9175
|
meta: jsonValueSchema.optional()
|
|
9176
9176
|
});
|
|
9177
|
+
const permissionAutoApprovedPayloadSchema = z.object({
|
|
9178
|
+
kind: z.literal("permission_auto_approved"),
|
|
9179
|
+
permissionMode: z.literal("bash"),
|
|
9180
|
+
approvalMode: z.literal("auto_allow"),
|
|
9181
|
+
toolName: z.string(),
|
|
9182
|
+
command: z.string(),
|
|
9183
|
+
workdir: z.string(),
|
|
9184
|
+
reason: z.string(),
|
|
9185
|
+
label: z.string(),
|
|
9186
|
+
toolCallId: z.string().optional()
|
|
9187
|
+
});
|
|
9177
9188
|
const toolCallPayloadSchema = z.object({
|
|
9178
9189
|
kind: z.literal("tool_call"),
|
|
9179
9190
|
label: z.string(),
|
|
@@ -9251,6 +9262,7 @@ const subagentFailedPayloadSchema = subagentLifecycleBasePayloadSchema.extend({
|
|
|
9251
9262
|
});
|
|
9252
9263
|
const sessionEventPayloadSchema = z.discriminatedUnion("kind", [
|
|
9253
9264
|
messagePayloadSchema,
|
|
9265
|
+
permissionAutoApprovedPayloadSchema,
|
|
9254
9266
|
toolCallPayloadSchema,
|
|
9255
9267
|
hookStatusPayloadSchema,
|
|
9256
9268
|
taskPlanPayloadSchema,
|
|
@@ -9503,6 +9515,7 @@ function rehydrateSession(events) {
|
|
|
9503
9515
|
});
|
|
9504
9516
|
if (event.role === "user") visibleOnlyActionValues = /* @__PURE__ */ new Set();
|
|
9505
9517
|
break;
|
|
9518
|
+
case "permission_auto_approved": break;
|
|
9506
9519
|
case "tool_call":
|
|
9507
9520
|
messages.push(toolCallMessage(event.call, event.label, void 0, event.diff));
|
|
9508
9521
|
break;
|
|
@@ -10226,6 +10239,14 @@ const agentEvent = {
|
|
|
10226
10239
|
meta
|
|
10227
10240
|
};
|
|
10228
10241
|
},
|
|
10242
|
+
permissionAutoApproved(options) {
|
|
10243
|
+
return {
|
|
10244
|
+
type: "permission_auto_approved",
|
|
10245
|
+
approvalMode: "auto_allow",
|
|
10246
|
+
label: `auto-approved ${options.permissionMode} permission: ${options.command}`,
|
|
10247
|
+
...options
|
|
10248
|
+
};
|
|
10249
|
+
},
|
|
10229
10250
|
toolCall(call, label, diff) {
|
|
10230
10251
|
return diff === void 0 ? {
|
|
10231
10252
|
type: "tool_call",
|
|
@@ -12254,6 +12275,17 @@ function runtimeEventToSessionPayload(event) {
|
|
|
12254
12275
|
text: event.text,
|
|
12255
12276
|
...event.meta === void 0 ? {} : { meta: event.meta }
|
|
12256
12277
|
};
|
|
12278
|
+
case "permission_auto_approved": return {
|
|
12279
|
+
kind: "permission_auto_approved",
|
|
12280
|
+
permissionMode: event.permissionMode,
|
|
12281
|
+
approvalMode: event.approvalMode,
|
|
12282
|
+
toolName: event.toolName,
|
|
12283
|
+
command: event.command,
|
|
12284
|
+
workdir: event.workdir,
|
|
12285
|
+
reason: event.reason,
|
|
12286
|
+
label: event.label,
|
|
12287
|
+
...event.toolCallId === void 0 ? {} : { toolCallId: event.toolCallId }
|
|
12288
|
+
};
|
|
12257
12289
|
case "tool_call": return {
|
|
12258
12290
|
kind: "tool_call",
|
|
12259
12291
|
label: event.label,
|
|
@@ -13548,7 +13580,13 @@ var TopchesterAgentRuntime = class TopchesterAgentRuntime {
|
|
|
13548
13580
|
approvedCommands,
|
|
13549
13581
|
events: []
|
|
13550
13582
|
};
|
|
13551
|
-
if (!isBashApprovalRequired(decision)
|
|
13583
|
+
if (!isBashApprovalRequired(decision)) return {
|
|
13584
|
+
cancelled: false,
|
|
13585
|
+
approvedCommands,
|
|
13586
|
+
events: []
|
|
13587
|
+
};
|
|
13588
|
+
const approvalMode = options.userApprovalMode ?? "interactive";
|
|
13589
|
+
if (approvalMode !== "auto_allow" && !options.requestBashApproval) return {
|
|
13552
13590
|
cancelled: false,
|
|
13553
13591
|
approvedCommands,
|
|
13554
13592
|
events: []
|
|
@@ -13559,7 +13597,11 @@ var TopchesterAgentRuntime = class TopchesterAgentRuntime {
|
|
|
13559
13597
|
permission_mode: "bash",
|
|
13560
13598
|
command,
|
|
13561
13599
|
workdir: parsed.data.workdir,
|
|
13562
|
-
reason: decision.reason
|
|
13600
|
+
reason: decision.reason,
|
|
13601
|
+
...approvalMode === "auto_allow" ? {
|
|
13602
|
+
approval_mode: "auto_allow",
|
|
13603
|
+
auto_approved: true
|
|
13604
|
+
} : {}
|
|
13563
13605
|
}), {
|
|
13564
13606
|
toolName: call.tool,
|
|
13565
13607
|
abortSignal
|
|
@@ -13576,6 +13618,36 @@ var TopchesterAgentRuntime = class TopchesterAgentRuntime {
|
|
|
13576
13618
|
reason: actionRequiredHook.blocked.message,
|
|
13577
13619
|
events
|
|
13578
13620
|
};
|
|
13621
|
+
if (approvalMode === "auto_allow") {
|
|
13622
|
+
const event = agentEvent.permissionAutoApproved({
|
|
13623
|
+
permissionMode: "bash",
|
|
13624
|
+
toolName: call.tool,
|
|
13625
|
+
...toolCallId === void 0 ? {} : { toolCallId },
|
|
13626
|
+
command,
|
|
13627
|
+
workdir: parsed.data.workdir,
|
|
13628
|
+
reason: decision.reason
|
|
13629
|
+
});
|
|
13630
|
+
this.context.logger.info({
|
|
13631
|
+
event: "permission_auto_approved",
|
|
13632
|
+
approvalMode: "auto_allow",
|
|
13633
|
+
permissionMode: "bash",
|
|
13634
|
+
toolName: call.tool,
|
|
13635
|
+
toolCallId,
|
|
13636
|
+
command,
|
|
13637
|
+
workdir: parsed.data.workdir,
|
|
13638
|
+
reason: decision.reason
|
|
13639
|
+
}, "permission request auto-approved");
|
|
13640
|
+
return {
|
|
13641
|
+
cancelled: false,
|
|
13642
|
+
approvedCommands: [...approvedCommands, command],
|
|
13643
|
+
events: [...events, event]
|
|
13644
|
+
};
|
|
13645
|
+
}
|
|
13646
|
+
if (!options.requestBashApproval) return {
|
|
13647
|
+
cancelled: false,
|
|
13648
|
+
approvedCommands,
|
|
13649
|
+
events
|
|
13650
|
+
};
|
|
13579
13651
|
const approval = await options.requestBashApproval({
|
|
13580
13652
|
command,
|
|
13581
13653
|
workdir: parsed.data.workdir,
|
|
@@ -13738,6 +13810,7 @@ function createInstructionContextEvents(sources, persistedKeys) {
|
|
|
13738
13810
|
function renderRuntimeEvent(event) {
|
|
13739
13811
|
switch (event.type) {
|
|
13740
13812
|
case "message": return [event.role === "assistant" ? agentMessage(event.text, event.meta) : systemMessage(event.text)];
|
|
13813
|
+
case "permission_auto_approved": return [systemMessage(event.label)];
|
|
13741
13814
|
case "tool_call": return [toolCallMessage(event.call, event.label, void 0, event.diff)];
|
|
13742
13815
|
case "hook_status": return [hookStatusMessage(event.label, event.eventName, event.statusMessage)];
|
|
13743
13816
|
case "knowledge_status": return [systemMessage([`KB status: ${formatKnowledgePathStatus(event.status)}${formatKbPathSource(event.status)}`, event.guidance].filter(Boolean).join("\n"))];
|
|
@@ -15272,11 +15345,13 @@ async function executeRunCommand(context, options) {
|
|
|
15272
15345
|
promptLength: options.prompt.length,
|
|
15273
15346
|
json: Boolean(options.json),
|
|
15274
15347
|
outputJson: options.outputJson,
|
|
15275
|
-
timeoutMs
|
|
15348
|
+
timeoutMs,
|
|
15349
|
+
dangerouslyAutoApprove: Boolean(options.dangerouslyAutoApprove)
|
|
15276
15350
|
}, "run started");
|
|
15277
15351
|
pushJson(jsonEvents, runId, session.sessionId, "run.started", {
|
|
15278
15352
|
workspaceRoot: runContext.workspaceRoot,
|
|
15279
|
-
timeoutMs
|
|
15353
|
+
timeoutMs,
|
|
15354
|
+
dangerouslyAutoApprove: Boolean(options.dangerouslyAutoApprove)
|
|
15280
15355
|
});
|
|
15281
15356
|
try {
|
|
15282
15357
|
if (!options.resume) await persistStartupMessages(session, runContext);
|
|
@@ -15331,7 +15406,10 @@ async function executeRunCommand(context, options) {
|
|
|
15331
15406
|
text: options.prompt,
|
|
15332
15407
|
inputType: "prompt"
|
|
15333
15408
|
});
|
|
15334
|
-
for await (const event of runtime.submitMessageStream(conversation, options.prompt, abortController.signal, {
|
|
15409
|
+
for await (const event of runtime.submitMessageStream(conversation, options.prompt, abortController.signal, {
|
|
15410
|
+
session,
|
|
15411
|
+
userApprovalMode: options.dangerouslyAutoApprove ? "auto_allow" : "interactive"
|
|
15412
|
+
})) await applyRuntimeEvent({
|
|
15335
15413
|
event,
|
|
15336
15414
|
session,
|
|
15337
15415
|
jsonEvents,
|
|
@@ -15412,6 +15490,10 @@ function printPlainEvent(event) {
|
|
|
15412
15490
|
console.log(event.text);
|
|
15413
15491
|
return;
|
|
15414
15492
|
}
|
|
15493
|
+
if (event.type === "permission_auto_approved") {
|
|
15494
|
+
console.log(event.label);
|
|
15495
|
+
return;
|
|
15496
|
+
}
|
|
15415
15497
|
if (event.type === "tool_call") {
|
|
15416
15498
|
console.log(event.label);
|
|
15417
15499
|
return;
|
|
@@ -15782,7 +15864,7 @@ function createTopchesterProgram() {
|
|
|
15782
15864
|
process.exitCode = 1;
|
|
15783
15865
|
}
|
|
15784
15866
|
});
|
|
15785
|
-
program.command("run").description("run one prompt or slash command without opening the TUI").argument("<prompt...>", "prompt text or slash command").option("--model <model>", "override the agent.primary model for this run").option("--timeout <ms>", "timeout for the run in milliseconds", parsePositiveInteger).option("--json", "write JSONL run events to stdout").option("--output-json <path>", "write JSONL run events to a file").action(async (promptParts, options) => {
|
|
15867
|
+
program.command("run").description("run one prompt or slash command without opening the TUI").argument("<prompt...>", "prompt text or slash command").option("--model <model>", "override the agent.primary model for this run").option("--timeout <ms>", "timeout for the run in milliseconds", parsePositiveInteger).option("--json", "write JSONL run events to stdout").option("--output-json <path>", "write JSONL run events to a file").option("--dangerously-auto-approve", "auto-approve prompt-gated tool calls for this non-interactive run").action(async (promptParts, options) => {
|
|
15786
15868
|
const context = createContextFromOptions(program);
|
|
15787
15869
|
const globalOptions = program.opts();
|
|
15788
15870
|
try {
|
|
@@ -15792,7 +15874,8 @@ function createTopchesterProgram() {
|
|
|
15792
15874
|
timeoutMs: options.timeout,
|
|
15793
15875
|
json: options.json,
|
|
15794
15876
|
outputJson: options.outputJson,
|
|
15795
|
-
resume: globalOptions.resume
|
|
15877
|
+
resume: globalOptions.resume,
|
|
15878
|
+
dangerouslyAutoApprove: options.dangerouslyAutoApprove
|
|
15796
15879
|
});
|
|
15797
15880
|
} catch (error) {
|
|
15798
15881
|
console.error(formatStartupError(error));
|
|
@@ -16082,4 +16165,4 @@ function formatDryRunSyncStatus(status) {
|
|
|
16082
16165
|
//#endregion
|
|
16083
16166
|
export { runTopchesterCli as t };
|
|
16084
16167
|
|
|
16085
|
-
//# sourceMappingURL=cli-
|
|
16168
|
+
//# sourceMappingURL=cli-DfwFfA-w.mjs.map
|