dsh-codex-subscription 3.1.2 → 3.1.4
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.en.md +4 -4
- package/README.md +4 -4
- package/lib/client.js +87 -15
- package/lib/index.js +717 -31
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
3
3
|
import { closeOpenAICodexWebSocketSessions, getOpenAICodexWebSocketDebugStats, resetOpenAICodexWebSocketDebugStats } from "@earendil-works/pi-ai/api/openai-codex-responses";
|
|
4
4
|
import { execFile, spawn } from "node:child_process";
|
|
5
|
-
import { appendFileSync, constants, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { appendFileSync, constants, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { request } from "node:https";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -17,7 +17,7 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
17
17
|
import * as dshLlm from "@deepseek-ai/dsh-llm";
|
|
18
18
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
19
19
|
import * as dshCredentials from "@deepseek-ai/dsh-credentials";
|
|
20
|
-
import { hostname } from "node:os";
|
|
20
|
+
import { homedir, hostname } from "node:os";
|
|
21
21
|
import { dshHomePath, resolveDshHome } from "@deepseek-ai/dsh-home-paths";
|
|
22
22
|
import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
23
23
|
import { openaiCodexProvider as createOpenAICodexProvider } from "@earendil-works/pi-ai/providers/openai-codex";
|
|
@@ -85,6 +85,78 @@ function observeAdapter(adapter, provider) {
|
|
|
85
85
|
} });
|
|
86
86
|
}
|
|
87
87
|
//#endregion
|
|
88
|
+
//#region src/hidden-model-directory.js
|
|
89
|
+
/**
|
|
90
|
+
* Shares the subscription settings' hidden-model list with the host model
|
|
91
|
+
* directory (what other pickers read through `llm.listModels`).
|
|
92
|
+
*
|
|
93
|
+
* `listModels` is also the host's send-time availability check, so a hidden
|
|
94
|
+
* model stays listed while something still depends on it. Only the list is
|
|
95
|
+
* filtered: `resolveModel`, `prepareCall` and `stream` keep resolving against
|
|
96
|
+
* the unfiltered catalog, so an old session on a hidden model keeps working.
|
|
97
|
+
*/
|
|
98
|
+
const ids = (models) => models.map((model) => model.id);
|
|
99
|
+
const same = (left, right) => left.length === right.length && left.every((id, index) => id === right[index]);
|
|
100
|
+
/**
|
|
101
|
+
* @param disabled - returns the user's hidden model ids (stale ids are harmless).
|
|
102
|
+
* @param pinned - returns model ids that must stay listed: models of open
|
|
103
|
+
* sessions, the default model, and this plugin's own configured models.
|
|
104
|
+
* @param fallback - returns the default model id, kept when everything is hidden.
|
|
105
|
+
*/
|
|
106
|
+
function visibleModels(models, { disabled, pinned = () => [], fallback = () => void 0 }) {
|
|
107
|
+
const hidden = new Set(disabled());
|
|
108
|
+
if (hidden.size === 0) return models;
|
|
109
|
+
const keep = new Set(pinned());
|
|
110
|
+
const visible = models.filter((model) => !hidden.has(model.id) || keep.has(model.id));
|
|
111
|
+
if (visible.length > 0 || models.length === 0) return visible;
|
|
112
|
+
const preferred = fallback();
|
|
113
|
+
return [models.find((model) => model.id === preferred) ?? models[0]];
|
|
114
|
+
}
|
|
115
|
+
function createHiddenModelDirectory({ provider, disabled, pinned, fallback, emit }) {
|
|
116
|
+
const options = {
|
|
117
|
+
disabled,
|
|
118
|
+
pinned: () => {
|
|
119
|
+
try {
|
|
120
|
+
return pinned?.() ?? [];
|
|
121
|
+
} catch {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
fallback
|
|
126
|
+
};
|
|
127
|
+
let catalog;
|
|
128
|
+
let emitted;
|
|
129
|
+
const filtered = (models) => visibleModels(models, options);
|
|
130
|
+
const wrap = (adapter) => new Proxy(adapter, { get(target, property) {
|
|
131
|
+
if (property === "listModels") return async (requested, ...rest) => {
|
|
132
|
+
const models = await target.listModels(requested, ...rest);
|
|
133
|
+
if (requested !== provider || !Array.isArray(models)) return models;
|
|
134
|
+
catalog = models;
|
|
135
|
+
const visible = filtered(models);
|
|
136
|
+
emitted = ids(visible);
|
|
137
|
+
return visible;
|
|
138
|
+
};
|
|
139
|
+
const value = Reflect.get(target, property, target);
|
|
140
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
141
|
+
} });
|
|
142
|
+
return {
|
|
143
|
+
wrap,
|
|
144
|
+
/** The hidden list changed: tell the host to reload its directory. */
|
|
145
|
+
settingsChanged: (value, previous) => {
|
|
146
|
+
if (same([...value ?? []].sort(), [...previous ?? []].sort())) return false;
|
|
147
|
+
emit();
|
|
148
|
+
return true;
|
|
149
|
+
},
|
|
150
|
+
/** Something a hidden model depends on may have changed; emit only if the listed set would differ. */
|
|
151
|
+
dependenciesChanged: () => {
|
|
152
|
+
if (catalog === void 0 || emitted === void 0) return false;
|
|
153
|
+
if (same(ids(filtered(catalog)), emitted)) return false;
|
|
154
|
+
emit();
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
88
160
|
//#region src/default-model.js
|
|
89
161
|
/**
|
|
90
162
|
* DSH owns the model a freshly created agent starts on. This module is the
|
|
@@ -1392,6 +1464,7 @@ const RPC_ENDPOINTS = Object.freeze([
|
|
|
1392
1464
|
"voice/start",
|
|
1393
1465
|
"voice/stop",
|
|
1394
1466
|
"voice/status",
|
|
1467
|
+
"voice/interrupt",
|
|
1395
1468
|
"voice/preview",
|
|
1396
1469
|
"voice/catalog",
|
|
1397
1470
|
"remote/status",
|
|
@@ -2413,7 +2486,7 @@ function inheritedOriginalImageRef(session, assetId) {
|
|
|
2413
2486
|
}
|
|
2414
2487
|
//#endregion
|
|
2415
2488
|
//#region src/version.js
|
|
2416
|
-
const PACKAGE_VERSION = "3.1.
|
|
2489
|
+
const PACKAGE_VERSION = "3.1.4";
|
|
2417
2490
|
const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
|
|
2418
2491
|
//#endregion
|
|
2419
2492
|
//#region src/http-failure.js
|
|
@@ -3020,7 +3093,7 @@ const MAX_REFERENCE_BYTES = 14e5;
|
|
|
3020
3093
|
function createSketchAgentTool(bridge, attachments, getSessionMessages = () => []) {
|
|
3021
3094
|
return defineTool({
|
|
3022
3095
|
name: "codex_sketch",
|
|
3023
|
-
description: "Edit the sketch board in this session using native editable strokes and layers. Use for @sketch requests and explicit follow-up edits to that drawing. The toolbar pen button is for manual drawing; do not require the user to open it. Start with inspect for the runId, documentId, revision and command reference. Draw with the svg op whenever possible: one SVG document per stage (paths, shapes, groups, transforms; see the reference from inspect) is far faster and richer than hand-placed strokes, and still becomes native editable strokes. Draw with depth, not flat colour: skies, skin, metal and glass take real linear/radial gradients (fill=\"url(#id)\"), glows, shadows, haze and distant things take a feGaussianBlur filter (soft edge), and light comes from a consistent direction with a darker shade, a lighter highlight and a reflected-light edge on each form. Draw the shapes, hair, clothing and lettering outlines of every layer with svg; use stroke commands only for small corrections and native text. Apply atomic batches and preview between stages. When the user attached a reference image, call reference with its attachmentId once after inspect to put it on the board as a hidden picture layer. To reproduce a reference faithfully, draw it yourself in stages, from big to small: 1) write a short plan (parts, drawing order, rough position and size of each), using preview with grid and measure with palette and regions to read proportions, key positions and the main colours, and measure scan along a few rows and columns to find exact edges; 2) block in the silhouette and the big colour areas (hair, clothes, skin, background) as filled shapes; 3) after every apply read progress (error, previous error, worst cells) and use preview mode side or diff, with box to zoom into a part, to see what is off; 4) fix the worst area first (position and size before colour, colour before detail), 5) then shading, then outlines and small details (eyes, headphones, patterns). Read exact colours from the reference with measure points instead of guessing. If a stage raised the error or looks wrong, undo it instead of painting over it. When the whole picture is roughly right, do refinement passes region by region instead of stopping: split the picture into its parts (for a figure: head and face, each mass of hair, torso, each arm, each leg, shoes and small accessories). For every part, call preview mode side with box set to that part and grid on (zoomed up to 3x) and look at reference and drawing next to each other, then measure with box on the same part and use scan along an edge to read exact positions; list the three biggest differences (edge position, size, colour, missing detail), fix them with targeted object updates or a replacement shape, and check progress. A part is done when its error stops falling or the zoomed pair looks the same; then go to the next part. Make at least one pass over every part before you finish, and never end with the first full draft. Stop when every part has had its pass and the error stops improving. When a reference picture is on the board, keep its layer hidden while drawing (compare shows it anyway), measure its key positions with preview grid, draw big shapes first, and after each stage check preview compare and fix the largest offset before adding detail. For repeated details such as hair strands or lace, generate the SVG with a script instead of placing each one by hand. and call finish to save the finished draft and release the editing lock. save is only a checkpoint. Closing the board does not stop drawing. If the user stops drawing, do not retry. Never generates AI images
|
|
3096
|
+
description: "Edit the sketch board in this session using native editable strokes and layers. Use for @sketch requests and explicit follow-up edits to that drawing. The toolbar pen button is for manual drawing; do not require the user to open it. Start with inspect for the runId, documentId, revision and command reference. Draw with the svg op whenever possible: one SVG document per stage (paths, shapes, groups, transforms; see the reference from inspect) is far faster and richer than hand-placed strokes, and still becomes native editable strokes. Draw with depth, not flat colour: skies, skin, metal and glass take real linear/radial gradients (fill=\"url(#id)\"), glows, shadows, haze and distant things take a feGaussianBlur filter (soft edge), and light comes from a consistent direction with a darker shade, a lighter highlight and a reflected-light edge on each form. Draw the shapes, hair, clothing and lettering outlines of every layer with svg; use stroke commands only for small corrections and native text. Apply atomic batches and preview between stages. When the user attached a reference image, call reference with its attachmentId once after inspect to put it on the board as a hidden picture layer. To reproduce a reference faithfully, draw it yourself in stages, from big to small: 1) write a short plan (parts, drawing order, rough position and size of each), using preview with grid and measure with palette and regions to read proportions, key positions and the main colours, and measure scan along a few rows and columns to find exact edges; 2) block in the silhouette and the big colour areas (hair, clothes, skin, background) as filled shapes; 3) after every apply read progress (error, previous error, worst cells) and use preview mode side or diff, with box to zoom into a part, to see what is off; 4) fix the worst area first (position and size before colour, colour before detail), 5) then shading, then outlines and small details (eyes, headphones, patterns). Read exact colours from the reference with measure points instead of guessing. If a stage raised the error or looks wrong, undo it instead of painting over it. When the whole picture is roughly right, do refinement passes region by region instead of stopping: split the picture into its parts (for a figure: head and face, each mass of hair, torso, each arm, each leg, shoes and small accessories). For every part, call preview mode side with box set to that part and grid on (zoomed up to 3x) and look at reference and drawing next to each other, then measure with box on the same part and use scan along an edge to read exact positions; list the three biggest differences (edge position, size, colour, missing detail), fix them with targeted object updates or a replacement shape, and check progress. A part is done when its error stops falling or the zoomed pair looks the same; then go to the next part. Make at least one pass over every part before you finish, and never end with the first full draft. Stop when every part has had its pass and the error stops improving. When a reference picture is on the board, keep its layer hidden while drawing (compare shows it anyway), measure its key positions with preview grid, draw big shapes first, and after each stage check preview compare and fix the largest offset before adding detail. For repeated details such as hair strands or lace, generate the SVG with a script instead of placing each one by hand. and call finish to save the finished draft and release the editing lock. save is only a checkpoint. Closing the board does not stop drawing. If the user stops drawing, do not retry. Never generates AI images or sends messages. Finish returns the saved drawing as a native image attachment displayed by DSH. Refer to that attachment; never invent a Markdown image URL or use a shell-output/log path as an image. Inspect automatically opens the board in the currently viewed session. Do not ask the user to open it first. If the session is not visible in DSH, ask them to switch to it. On timeout inspect before retrying; reuse the exact requestId only for the same request.",
|
|
3024
3097
|
parameters: {
|
|
3025
3098
|
action: {
|
|
3026
3099
|
type: "string",
|
|
@@ -3202,17 +3275,34 @@ function createSketchAgentTool(bridge, attachments, getSessionMessages = () => [
|
|
|
3202
3275
|
request.name = image.name ?? "reference";
|
|
3203
3276
|
}
|
|
3204
3277
|
const value = await bridge.request(sessionId, request, exec.signal);
|
|
3278
|
+
if (args.action === "finish" && !value.png) throw Error("The board returned no final image. Reload DSH to load the current sketch client, then inspect the saved drawing before retrying.");
|
|
3205
3279
|
if (value.png) {
|
|
3206
3280
|
if (!/^data:image\/png;base64,/.test(value.png) || value.png.length > 8 * 1024 * 1024) throw Error("Invalid sketch preview");
|
|
3281
|
+
const data = Buffer.from(value.png.split(",")[1], "base64");
|
|
3282
|
+
if (!data.subarray(0, 8).equals(Buffer.from([
|
|
3283
|
+
137,
|
|
3284
|
+
80,
|
|
3285
|
+
78,
|
|
3286
|
+
71,
|
|
3287
|
+
13,
|
|
3288
|
+
10,
|
|
3289
|
+
26,
|
|
3290
|
+
10
|
|
3291
|
+
]))) throw Error("Invalid sketch preview: expected PNG bytes");
|
|
3207
3292
|
const image = await attachments.saveImage({
|
|
3208
|
-
data: new Uint8Array(
|
|
3293
|
+
data: new Uint8Array(data),
|
|
3209
3294
|
mediaType: "image/png",
|
|
3210
|
-
name: "sketch-preview.png"
|
|
3295
|
+
name: args.action === "finish" ? "sketch-finished.png" : "sketch-preview.png"
|
|
3211
3296
|
});
|
|
3212
3297
|
const { png, ...snapshot } = value;
|
|
3213
3298
|
return {
|
|
3214
3299
|
...snapshot,
|
|
3215
|
-
image
|
|
3300
|
+
image,
|
|
3301
|
+
...args.action === "finish" ? { delivery: {
|
|
3302
|
+
...value.delivery,
|
|
3303
|
+
image,
|
|
3304
|
+
note: "The saved drawing is attached and displayed by DSH. Refer to the attached image directly; never use a shell-output/log path as an image."
|
|
3305
|
+
} } : {}
|
|
3216
3306
|
};
|
|
3217
3307
|
}
|
|
3218
3308
|
return value;
|
|
@@ -3222,6 +3312,11 @@ function createSketchAgentTool(bridge, attachments, getSessionMessages = () => [
|
|
|
3222
3312
|
type: "object",
|
|
3223
3313
|
additionalProperties: true
|
|
3224
3314
|
},
|
|
3315
|
+
presentationMeta: (args, value) => ({
|
|
3316
|
+
kind: args.action === "finish" && value.image ? "codex-subscription-sketch-finish" : "codex-subscription-sketch",
|
|
3317
|
+
documentId: value.documentId,
|
|
3318
|
+
revision: value.revision
|
|
3319
|
+
}),
|
|
3225
3320
|
render: (_args, value) => [{
|
|
3226
3321
|
type: "text",
|
|
3227
3322
|
text: JSON.stringify({
|
|
@@ -4155,6 +4250,26 @@ const TEXTUAL = /* @__PURE__ */ new Set([
|
|
|
4155
4250
|
"diff-files",
|
|
4156
4251
|
"diff-index"
|
|
4157
4252
|
]);
|
|
4253
|
+
/**
|
|
4254
|
+
* The phone's folder picker first asks the host for its home folder with one fixed PowerShell line. Nothing is run for it:
|
|
4255
|
+
* when the request is exactly that line, the answer is this machine's home folder.
|
|
4256
|
+
*/
|
|
4257
|
+
function homeFolderAnswer(command, home = homedir()) {
|
|
4258
|
+
if (!Array.isArray(command) || command.length !== 5 || command.some((part) => typeof part !== "string")) return void 0;
|
|
4259
|
+
const [exe, ...flags] = command;
|
|
4260
|
+
if (!/^(?:powershell|pwsh)(?:\.exe)?$/iu.test(basename(exe))) return void 0;
|
|
4261
|
+
if (JSON.stringify(flags) !== JSON.stringify([
|
|
4262
|
+
"-NoProfile",
|
|
4263
|
+
"-NonInteractive",
|
|
4264
|
+
"-Command",
|
|
4265
|
+
"(Resolve-Path -LiteralPath $HOME).Path"
|
|
4266
|
+
])) return void 0;
|
|
4267
|
+
return {
|
|
4268
|
+
exitCode: 0,
|
|
4269
|
+
stdout: `${home}\r\n`,
|
|
4270
|
+
stderr: ""
|
|
4271
|
+
};
|
|
4272
|
+
}
|
|
4158
4273
|
/** The argv to run for a phone request, or a reason it is refused. */
|
|
4159
4274
|
function gitArguments(command) {
|
|
4160
4275
|
if (!Array.isArray(command) || command.length < 2 || command.some((part) => typeof part !== "string" || part.length > 4096 || part.includes("\0"))) return { error: "not a git command" };
|
|
@@ -4164,7 +4279,7 @@ function gitArguments(command) {
|
|
|
4164
4279
|
const [subcommand, ...args] = rest;
|
|
4165
4280
|
if (subcommand === void 0) return { error: "no git subcommand" };
|
|
4166
4281
|
if (args.some((arg) => FORBIDDEN.test(arg))) return { error: `option not allowed with git ${subcommand}` };
|
|
4167
|
-
const exact = EXACT.some((form) => form.length === rest.length && form.every((part, index) => part === rest[index]));
|
|
4282
|
+
const exact = EXACT.some((form) => form.length === rest.length && form.every((part, index) => part === rest[index])) || subcommand === "symbolic-ref" && args.length === 2 && args[0] === "--short" && /^refs\/remotes\/[^\0\r\n]+\/HEAD$/u.test(args[1]);
|
|
4168
4283
|
if (!READ_ONLY.has(subcommand) && !exact) return { error: `git ${subcommand} is not available` };
|
|
4169
4284
|
return { argv: [
|
|
4170
4285
|
"-c",
|
|
@@ -4180,8 +4295,12 @@ function gitArguments(command) {
|
|
|
4180
4295
|
] };
|
|
4181
4296
|
}
|
|
4182
4297
|
const inside = (folder, root) => {
|
|
4183
|
-
|
|
4184
|
-
|
|
4298
|
+
try {
|
|
4299
|
+
const path = relative(realpathSync.native(root), folder);
|
|
4300
|
+
return path === "" || path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
|
|
4301
|
+
} catch {
|
|
4302
|
+
return false;
|
|
4303
|
+
}
|
|
4185
4304
|
};
|
|
4186
4305
|
/**
|
|
4187
4306
|
* @param {{ command: string[], cwd?: string, timeoutMs?: number, outputBytesCap?: number, tty?: boolean, streamStdin?: boolean, streamStdoutStderr?: boolean }} params
|
|
@@ -4191,12 +4310,18 @@ function runGit(params, { folders, run = execFile }) {
|
|
|
4191
4310
|
const parsed = gitArguments(params?.command);
|
|
4192
4311
|
if (parsed.error) return Promise.reject(Object.assign(new Error(parsed.error), { code: "not-allowed" }));
|
|
4193
4312
|
if (params.tty || params.streamStdin || params.streamStdoutStderr) return Promise.reject(Object.assign(/* @__PURE__ */ new Error("streaming is not available"), { code: "not-allowed" }));
|
|
4194
|
-
|
|
4313
|
+
let cwd = localFolder(params.cwd);
|
|
4314
|
+
try {
|
|
4315
|
+
cwd = cwd && realpathSync.native(cwd);
|
|
4316
|
+
} catch {
|
|
4317
|
+
cwd = void 0;
|
|
4318
|
+
}
|
|
4195
4319
|
if (!cwd || !folders.some((root) => inside(cwd, root))) return Promise.reject(Object.assign(/* @__PURE__ */ new Error("git only runs in a DSH conversation folder"), { code: "not-allowed" }));
|
|
4196
4320
|
const timeout = Math.min(Number.isFinite(params.timeoutMs) && params.timeoutMs > 0 ? params.timeoutMs : DEFAULT_TIMEOUT_MS$2, MAX_TIMEOUT_MS);
|
|
4197
4321
|
const cap = Math.min(Number.isInteger(params.outputBytesCap) && params.outputBytesCap > 0 ? params.outputBytesCap : DEFAULT_OUTPUT_BYTES, MAX_OUTPUT_BYTES);
|
|
4198
4322
|
const env = {
|
|
4199
4323
|
...process.env,
|
|
4324
|
+
GIT_LITERAL_PATHSPECS: "1",
|
|
4200
4325
|
GIT_OPTIONAL_LOCKS: "0",
|
|
4201
4326
|
GIT_TERMINAL_PROMPT: "0",
|
|
4202
4327
|
GIT_PAGER: "cat",
|
|
@@ -4222,6 +4347,218 @@ function runGit(params, { folders, run = execFile }) {
|
|
|
4222
4347
|
});
|
|
4223
4348
|
}
|
|
4224
4349
|
//#endregion
|
|
4350
|
+
//#region src/remote-control-git-probes.js
|
|
4351
|
+
const BRANCHES = "14c4c9e1481287733dd399473326c75c648339069226c3cfecdbabe7d7d87934";
|
|
4352
|
+
const DIFF = "ae570abfe66a30a882028df76ef000b1ed543cbf5e4c9d24e49a4d434a58cbe6";
|
|
4353
|
+
const WRAPPER = [
|
|
4354
|
+
"/bin/bash",
|
|
4355
|
+
"--noprofile",
|
|
4356
|
+
"--norc",
|
|
4357
|
+
"-p",
|
|
4358
|
+
"-c",
|
|
4359
|
+
"printf '\\0'; exec \"$@\"",
|
|
4360
|
+
"codex-workspace-diff",
|
|
4361
|
+
"/bin/bash",
|
|
4362
|
+
"-lc"
|
|
4363
|
+
];
|
|
4364
|
+
const probeDigest = (value) => typeof value === "string" ? createHash("sha256").update(value).digest("hex") : "";
|
|
4365
|
+
const denied = (message) => Object.assign(new Error(message), { code: "not-allowed" });
|
|
4366
|
+
const lines$1 = (value) => value.trim().split("\n").filter(Boolean);
|
|
4367
|
+
const encoded = (label, value) => `${label}\0${Buffer.from(value).toString("base64")}\0`;
|
|
4368
|
+
/** Returns undefined for every command other than the two captured phone probes. */
|
|
4369
|
+
function phoneGitProbe(command) {
|
|
4370
|
+
if (!Array.isArray(command)) return void 0;
|
|
4371
|
+
if (command.length === 3 && command[0] === "/bin/sh" && command[1] === "-lc" && probeDigest(command[2]) === BRANCHES) return { kind: "branches" };
|
|
4372
|
+
if (command.length !== 18 || !WRAPPER.every((part, index) => command[index] === part) || probeDigest(command[9]) !== DIFF || command[10] !== "codex-workspace-diff") return void 0;
|
|
4373
|
+
const [ref, source, required, remote, contents, perFile, total] = command.slice(11);
|
|
4374
|
+
if (typeof ref !== "string" || ref.length > 1024 || ref.startsWith("-") || /[\0\r\n]/u.test(ref) || ![
|
|
4375
|
+
"branch",
|
|
4376
|
+
"staged",
|
|
4377
|
+
"unstaged"
|
|
4378
|
+
].includes(source)) return void 0;
|
|
4379
|
+
if (![
|
|
4380
|
+
required,
|
|
4381
|
+
remote,
|
|
4382
|
+
contents
|
|
4383
|
+
].every((value) => value === "true" || value === "false") || ![perFile, total].every((value) => typeof value === "string" && /^\d{1,7}$/u.test(value))) return void 0;
|
|
4384
|
+
return {
|
|
4385
|
+
kind: "diff",
|
|
4386
|
+
ref,
|
|
4387
|
+
source,
|
|
4388
|
+
required: required === "true",
|
|
4389
|
+
contents: contents === "true",
|
|
4390
|
+
perFile: Number(perFile),
|
|
4391
|
+
total: Number(total)
|
|
4392
|
+
};
|
|
4393
|
+
}
|
|
4394
|
+
async function runPhoneGitProbe(params, { folders, notify, signal } = {}) {
|
|
4395
|
+
const probe = phoneGitProbe(params?.command);
|
|
4396
|
+
if (!probe) throw denied("unknown phone git probe");
|
|
4397
|
+
if (params.tty || params.streamStdin || params.streamStdoutStderr && (typeof params.processId !== "string" || !params.processId)) throw denied("unsupported phone git stream");
|
|
4398
|
+
const deadline = Date.now() + Math.min(params.timeoutMs > 0 ? params.timeoutMs : 15e3, 3e4);
|
|
4399
|
+
const cap = Math.min(Number.isInteger(params.outputBytesCap) && params.outputBytesCap > 0 ? params.outputBytesCap : 1024 * 1024, 4 * 1024 * 1024);
|
|
4400
|
+
const git = async (...args) => {
|
|
4401
|
+
signal?.throwIfAborted();
|
|
4402
|
+
if (Date.now() >= deadline) throw new Error("phone git query timed out");
|
|
4403
|
+
return runGit({
|
|
4404
|
+
command: ["git", ...args],
|
|
4405
|
+
cwd: params.cwd,
|
|
4406
|
+
timeoutMs: deadline - Date.now(),
|
|
4407
|
+
outputBytesCap: cap
|
|
4408
|
+
}, { folders });
|
|
4409
|
+
};
|
|
4410
|
+
const read = async (...args) => {
|
|
4411
|
+
const result = await git(...args);
|
|
4412
|
+
if (result.exitCode !== 0) throw new Error(result.stderr || "git query failed");
|
|
4413
|
+
return result.stdout;
|
|
4414
|
+
};
|
|
4415
|
+
const exists = async (ref) => (await git("rev-parse", "--verify", "--quiet", ref)).exitCode === 0;
|
|
4416
|
+
const localDefault = async () => {
|
|
4417
|
+
if (await exists("refs/heads/main")) return "main";
|
|
4418
|
+
if (await exists("refs/heads/master")) return "master";
|
|
4419
|
+
return "";
|
|
4420
|
+
};
|
|
4421
|
+
let stdout;
|
|
4422
|
+
if (probe.kind === "branches") {
|
|
4423
|
+
const current = (await read("branch", "--show-current")).trim();
|
|
4424
|
+
const remote = await git("symbolic-ref", "--short", "refs/remotes/origin/HEAD");
|
|
4425
|
+
const ref = remote.exitCode === 0 ? remote.stdout.trim() : await localDefault();
|
|
4426
|
+
const preferred = ref.replace(/^origin\//u, "");
|
|
4427
|
+
const first = preferred && await exists(`refs/heads/${preferred}`) ? preferred : await localDefault();
|
|
4428
|
+
const recent = lines$1(await read("for-each-ref", "--sort=-committerdate", "--format=%(refname:short)", "refs/heads"));
|
|
4429
|
+
const label = (name) => {
|
|
4430
|
+
const value = params.env?.[`CODEX_DRAFT_OUTPUT_${name}`];
|
|
4431
|
+
if (typeof value !== "string" || value.length > 100 || /[\0\r\n\t]/u.test(value)) throw denied("invalid branch output label");
|
|
4432
|
+
return value;
|
|
4433
|
+
};
|
|
4434
|
+
stdout = `${label("CURRENT")}\t${current}\n${label("DEFAULT")}\t${ref}\n` + [first, ...recent.filter((branch) => branch !== first)].filter(Boolean).slice(0, 8).map((branch) => `${label("BRANCH")}\t${branch}\n`).join("");
|
|
4435
|
+
} else {
|
|
4436
|
+
const root = await git("rev-parse", "--show-toplevel");
|
|
4437
|
+
if (root.exitCode !== 0) stdout = "\0notGitRepository\0";
|
|
4438
|
+
else {
|
|
4439
|
+
const cwd = root.stdout.trim();
|
|
4440
|
+
params = {
|
|
4441
|
+
...params,
|
|
4442
|
+
cwd
|
|
4443
|
+
};
|
|
4444
|
+
await git("rev-parse", "--show-toplevel");
|
|
4445
|
+
let base = [], comparison = "", failure = "";
|
|
4446
|
+
stdout = `\0git\0${cwd}\0`;
|
|
4447
|
+
if (probe.source === "branch") {
|
|
4448
|
+
if (await exists("HEAD")) {
|
|
4449
|
+
const remotes = lines$1(await read("remote")).sort((a, b) => Number(b === "origin") - Number(a === "origin"));
|
|
4450
|
+
if (probe.required) comparison = probe.ref && await exists(`${probe.ref}^{commit}`) ? probe.ref : "";
|
|
4451
|
+
else {
|
|
4452
|
+
for (const remote of remotes) {
|
|
4453
|
+
const symbolic = await git("symbolic-ref", "--short", `refs/remotes/${remote}/HEAD`);
|
|
4454
|
+
const candidates = [
|
|
4455
|
+
symbolic.exitCode === 0 ? symbolic.stdout.trim() : "",
|
|
4456
|
+
probe.ref.startsWith(`${remote}/`) ? probe.ref : "",
|
|
4457
|
+
`${remote}/main`,
|
|
4458
|
+
`${remote}/master`
|
|
4459
|
+
];
|
|
4460
|
+
for (const ref of candidates.filter(Boolean)) if (await exists(`refs/remotes/${ref}`)) {
|
|
4461
|
+
comparison = ref;
|
|
4462
|
+
break;
|
|
4463
|
+
}
|
|
4464
|
+
if (comparison) break;
|
|
4465
|
+
}
|
|
4466
|
+
if (!comparison && probe.ref && await exists(`${probe.ref}^{commit}`)) comparison = probe.ref;
|
|
4467
|
+
}
|
|
4468
|
+
const merge = comparison ? await git("merge-base", "HEAD", comparison) : void 0;
|
|
4469
|
+
if (probe.required && !comparison) failure = "comparisonBranchUnavailable";
|
|
4470
|
+
else if (probe.required && merge?.exitCode !== 0) failure = "comparisonBranchDoesNotShareHistory";
|
|
4471
|
+
base = [merge?.exitCode === 0 ? merge.stdout.trim() : "HEAD"];
|
|
4472
|
+
} else base = ["4b825dc642cb6eb9a060e54bf8d69288fbee4904"];
|
|
4473
|
+
stdout += `currentBranch\0${(await git("symbolic-ref", "--short", "HEAD")).stdout.trim()}\0` + lines$1(await read("for-each-ref", "--count=8", "--sort=-committerdate", "--format=%(refname:short)", "refs/heads")).map((branch) => `recentBranch\0${branch}\0`).join("");
|
|
4474
|
+
if (comparison) stdout += `comparisonRef\0${comparison}\0`;
|
|
4475
|
+
} else if (probe.source === "staged") base = ["--cached"];
|
|
4476
|
+
if (failure) stdout = "\0" + encoded("commandFailed", failure);
|
|
4477
|
+
else {
|
|
4478
|
+
const parts = [{
|
|
4479
|
+
stats: await read("diff", "--find-renames", "--numstat", "-z", ...base, "--"),
|
|
4480
|
+
base
|
|
4481
|
+
}];
|
|
4482
|
+
if (probe.source !== "staged") for (const file of (await read("ls-files", "--others", "--exclude-standard", "-z")).split("\0").filter(Boolean)) {
|
|
4483
|
+
if (!(await lstat(join(cwd, file))).isFile()) continue;
|
|
4484
|
+
const result = await git("diff", "--no-index", "--numstat", "-z", "--", "/dev/null", file);
|
|
4485
|
+
if (result.exitCode > 1) throw new Error(result.stderr || "git query failed");
|
|
4486
|
+
parts.push({
|
|
4487
|
+
stats: result.stdout.replace(/\t\0\/dev\/null\0/u, " "),
|
|
4488
|
+
file
|
|
4489
|
+
});
|
|
4490
|
+
}
|
|
4491
|
+
stdout += encoded("trackedNumstat", parts.map((part) => part.stats).join(""));
|
|
4492
|
+
if (probe.contents) {
|
|
4493
|
+
let changed = 0;
|
|
4494
|
+
const selected = parts.map((part) => {
|
|
4495
|
+
const paths = [], entries = part.stats.split("\0");
|
|
4496
|
+
for (let index = 0; index < entries.length; index++) {
|
|
4497
|
+
const match = /^(\d+|-)\t(\d+|-)\t([\s\S]*)$/u.exec(entries[index]);
|
|
4498
|
+
if (!match) continue;
|
|
4499
|
+
const names = match[3] ? [match[3]] : [entries[++index], entries[++index]];
|
|
4500
|
+
const count = (Number(match[1]) || 0) + (Number(match[2]) || 0);
|
|
4501
|
+
if (count > 0 && count <= probe.perFile) {
|
|
4502
|
+
changed += count;
|
|
4503
|
+
paths.push(...names);
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
return {
|
|
4507
|
+
...part,
|
|
4508
|
+
paths
|
|
4509
|
+
};
|
|
4510
|
+
});
|
|
4511
|
+
if (changed <= probe.total) {
|
|
4512
|
+
let diff = "";
|
|
4513
|
+
for (const part of selected.filter((part) => part.paths.length)) {
|
|
4514
|
+
const result = await git(...[
|
|
4515
|
+
"diff",
|
|
4516
|
+
"--find-renames",
|
|
4517
|
+
"--src-prefix=a/",
|
|
4518
|
+
"--dst-prefix=b/",
|
|
4519
|
+
"--unified=2",
|
|
4520
|
+
...part.file ? [
|
|
4521
|
+
"--no-index",
|
|
4522
|
+
"--",
|
|
4523
|
+
"/dev/null",
|
|
4524
|
+
part.file
|
|
4525
|
+
] : [
|
|
4526
|
+
...part.base,
|
|
4527
|
+
"--",
|
|
4528
|
+
...part.paths
|
|
4529
|
+
]
|
|
4530
|
+
]);
|
|
4531
|
+
if (result.exitCode > (part.file ? 1 : 0)) throw new Error(result.stderr || "git query failed");
|
|
4532
|
+
diff += result.stdout;
|
|
4533
|
+
}
|
|
4534
|
+
if (diff) stdout += encoded("trackedDiff", diff);
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
const bytes = Buffer.from(stdout);
|
|
4541
|
+
if (bytes.length > cap) throw new Error("phone git output exceeds the requested limit");
|
|
4542
|
+
if (params.streamStdoutStderr) {
|
|
4543
|
+
await notify("command/exec/outputDelta", {
|
|
4544
|
+
processId: params.processId,
|
|
4545
|
+
stream: "stdout",
|
|
4546
|
+
deltaBase64: bytes.toString("base64"),
|
|
4547
|
+
capReached: false
|
|
4548
|
+
});
|
|
4549
|
+
return {
|
|
4550
|
+
exitCode: 0,
|
|
4551
|
+
stdout: "",
|
|
4552
|
+
stderr: ""
|
|
4553
|
+
};
|
|
4554
|
+
}
|
|
4555
|
+
return {
|
|
4556
|
+
exitCode: 0,
|
|
4557
|
+
stdout,
|
|
4558
|
+
stderr: ""
|
|
4559
|
+
};
|
|
4560
|
+
}
|
|
4561
|
+
//#endregion
|
|
4225
4562
|
//#region src/remote-control-files.js
|
|
4226
4563
|
const SKIP = /* @__PURE__ */ new Set([
|
|
4227
4564
|
"node_modules",
|
|
@@ -4310,6 +4647,231 @@ async function searchFiles({ roots, query, folders, now = Date.now }) {
|
|
|
4310
4647
|
return found.sort((a, b) => b.score - a.score || a.path.length - b.path.length).slice(0, RESULTS);
|
|
4311
4648
|
}
|
|
4312
4649
|
//#endregion
|
|
4650
|
+
//#region src/voice-questions.js
|
|
4651
|
+
const normal = (value) => String(value).normalize("NFKC").toLocaleLowerCase().replaceAll("個", "个").replaceAll("項", "项").replaceAll("號", "号").replace(/[\s\p{P}\p{S}]/gu, "");
|
|
4652
|
+
const ordinals = [
|
|
4653
|
+
[
|
|
4654
|
+
"1",
|
|
4655
|
+
"一",
|
|
4656
|
+
"壹",
|
|
4657
|
+
"first",
|
|
4658
|
+
"one",
|
|
4659
|
+
"いち",
|
|
4660
|
+
"ひとつめ",
|
|
4661
|
+
"첫번째",
|
|
4662
|
+
"하나",
|
|
4663
|
+
"primero",
|
|
4664
|
+
"premier",
|
|
4665
|
+
"erste",
|
|
4666
|
+
"primeiro",
|
|
4667
|
+
"первый"
|
|
4668
|
+
],
|
|
4669
|
+
[
|
|
4670
|
+
"2",
|
|
4671
|
+
"二",
|
|
4672
|
+
"两",
|
|
4673
|
+
"second",
|
|
4674
|
+
"two",
|
|
4675
|
+
"に",
|
|
4676
|
+
"ふたつめ",
|
|
4677
|
+
"두번째",
|
|
4678
|
+
"둘",
|
|
4679
|
+
"segundo",
|
|
4680
|
+
"deuxième",
|
|
4681
|
+
"zweite",
|
|
4682
|
+
"второй"
|
|
4683
|
+
],
|
|
4684
|
+
[
|
|
4685
|
+
"3",
|
|
4686
|
+
"三",
|
|
4687
|
+
"third",
|
|
4688
|
+
"three",
|
|
4689
|
+
"さん",
|
|
4690
|
+
"みっつめ",
|
|
4691
|
+
"세번째",
|
|
4692
|
+
"셋",
|
|
4693
|
+
"tercero",
|
|
4694
|
+
"troisième",
|
|
4695
|
+
"dritte",
|
|
4696
|
+
"terceiro",
|
|
4697
|
+
"третий"
|
|
4698
|
+
],
|
|
4699
|
+
[
|
|
4700
|
+
"4",
|
|
4701
|
+
"四",
|
|
4702
|
+
"fourth",
|
|
4703
|
+
"four",
|
|
4704
|
+
"よん",
|
|
4705
|
+
"네번째",
|
|
4706
|
+
"cuarto",
|
|
4707
|
+
"quatrième",
|
|
4708
|
+
"vierte",
|
|
4709
|
+
"quarto",
|
|
4710
|
+
"четвертый"
|
|
4711
|
+
],
|
|
4712
|
+
[
|
|
4713
|
+
"5",
|
|
4714
|
+
"五",
|
|
4715
|
+
"fifth",
|
|
4716
|
+
"five",
|
|
4717
|
+
"ご",
|
|
4718
|
+
"다섯번째",
|
|
4719
|
+
"quinto",
|
|
4720
|
+
"cinquième",
|
|
4721
|
+
"fünfte",
|
|
4722
|
+
"пятый"
|
|
4723
|
+
],
|
|
4724
|
+
[
|
|
4725
|
+
"6",
|
|
4726
|
+
"六",
|
|
4727
|
+
"sixth",
|
|
4728
|
+
"six",
|
|
4729
|
+
"ろく",
|
|
4730
|
+
"여섯번째",
|
|
4731
|
+
"sexto",
|
|
4732
|
+
"sixième",
|
|
4733
|
+
"sechste",
|
|
4734
|
+
"шестой"
|
|
4735
|
+
],
|
|
4736
|
+
[
|
|
4737
|
+
"7",
|
|
4738
|
+
"七",
|
|
4739
|
+
"seventh",
|
|
4740
|
+
"seven",
|
|
4741
|
+
"なな",
|
|
4742
|
+
"일곱번째",
|
|
4743
|
+
"séptimo",
|
|
4744
|
+
"septième",
|
|
4745
|
+
"siebte",
|
|
4746
|
+
"sétimo",
|
|
4747
|
+
"седьмой"
|
|
4748
|
+
],
|
|
4749
|
+
[
|
|
4750
|
+
"8",
|
|
4751
|
+
"八",
|
|
4752
|
+
"eighth",
|
|
4753
|
+
"eight",
|
|
4754
|
+
"はち",
|
|
4755
|
+
"여덟번째",
|
|
4756
|
+
"octavo",
|
|
4757
|
+
"huitième",
|
|
4758
|
+
"achte",
|
|
4759
|
+
"oitavo",
|
|
4760
|
+
"восьмой"
|
|
4761
|
+
],
|
|
4762
|
+
[
|
|
4763
|
+
"9",
|
|
4764
|
+
"九",
|
|
4765
|
+
"ninth",
|
|
4766
|
+
"nine",
|
|
4767
|
+
"きゅう",
|
|
4768
|
+
"아홉번째",
|
|
4769
|
+
"noveno",
|
|
4770
|
+
"neuvième",
|
|
4771
|
+
"neunte",
|
|
4772
|
+
"nono",
|
|
4773
|
+
"девятый"
|
|
4774
|
+
]
|
|
4775
|
+
];
|
|
4776
|
+
/** Match an explicit label or ordinal; ambiguous speech leaves the question open. */
|
|
4777
|
+
function spokenChoice(text, question) {
|
|
4778
|
+
const said = normal(text);
|
|
4779
|
+
const options = question.options ?? [];
|
|
4780
|
+
const exact = options.filter((option) => normal(option.label) === said);
|
|
4781
|
+
if (exact.length === 1) return {
|
|
4782
|
+
id: question.id,
|
|
4783
|
+
selected: [exact[0].label]
|
|
4784
|
+
};
|
|
4785
|
+
const ordinal = said.replace(/^(?:我选|我要选|选择|选|第|option|choose|ichoose|number|the|el|le|die|opção|вариант)/u, "").replace(/^(?:第|option|number|the)/u, "").replace(/(?:个|项|号|番目|番|の選択肢|option|please|です|にして|でお願いします)$/u, "");
|
|
4786
|
+
const index = ordinals.findIndex((words) => words.some((word) => normal(word) === ordinal));
|
|
4787
|
+
if (index >= 0 && options.length) return index < options.length ? {
|
|
4788
|
+
id: question.id,
|
|
4789
|
+
selected: [options[index].label]
|
|
4790
|
+
} : void 0;
|
|
4791
|
+
if (options.length === 0 && String(text).trim()) return {
|
|
4792
|
+
id: question.id,
|
|
4793
|
+
selected: [],
|
|
4794
|
+
custom: String(text).trim()
|
|
4795
|
+
};
|
|
4796
|
+
const custom = /^(?:其他[::,,\s]*|其它[::,,\s]*|other[::,,\s]+)(.+)$/iu.exec(String(text).trim());
|
|
4797
|
+
if (custom) return {
|
|
4798
|
+
id: question.id,
|
|
4799
|
+
selected: [],
|
|
4800
|
+
custom: custom[1].trim()
|
|
4801
|
+
};
|
|
4802
|
+
}
|
|
4803
|
+
function createVoiceQuestions({ speak, now = Date.now }) {
|
|
4804
|
+
let pending;
|
|
4805
|
+
let recent = [];
|
|
4806
|
+
const finish = (value, error) => {
|
|
4807
|
+
const current = pending;
|
|
4808
|
+
if (!current) return;
|
|
4809
|
+
pending = void 0;
|
|
4810
|
+
current.signal?.removeEventListener("abort", current.abort);
|
|
4811
|
+
if (error) current.reject(error);
|
|
4812
|
+
else current.resolve(value);
|
|
4813
|
+
};
|
|
4814
|
+
const prompt = () => {
|
|
4815
|
+
const question = pending.questions[pending.answers.length];
|
|
4816
|
+
speak(`[COMPLETE] Ask the user this question in the conversation's language and read every option with its number, then wait. A spoken option number or label is handled by the application; do not delegate it as a new task. Question: ${JSON.stringify({
|
|
4817
|
+
question: question.question,
|
|
4818
|
+
detail: question.detail,
|
|
4819
|
+
options: question.options?.map((option, index) => ({
|
|
4820
|
+
number: index + 1,
|
|
4821
|
+
label: option.label,
|
|
4822
|
+
description: option.description
|
|
4823
|
+
}))
|
|
4824
|
+
})}`);
|
|
4825
|
+
};
|
|
4826
|
+
return {
|
|
4827
|
+
ask(request) {
|
|
4828
|
+
if (pending) return Promise.reject(/* @__PURE__ */ new Error("Another voice question is still open"));
|
|
4829
|
+
if (request.signal?.aborted) return Promise.reject(request.signal.reason ?? /* @__PURE__ */ new Error("Question aborted"));
|
|
4830
|
+
return new Promise((resolve, reject) => {
|
|
4831
|
+
pending = {
|
|
4832
|
+
questions: request.questions,
|
|
4833
|
+
answers: [],
|
|
4834
|
+
signal: request.signal,
|
|
4835
|
+
resolve,
|
|
4836
|
+
reject
|
|
4837
|
+
};
|
|
4838
|
+
pending.abort = () => finish(void 0, request.signal.reason ?? /* @__PURE__ */ new Error("Question aborted"));
|
|
4839
|
+
request.signal?.addEventListener("abort", pending.abort, { once: true });
|
|
4840
|
+
prompt();
|
|
4841
|
+
});
|
|
4842
|
+
},
|
|
4843
|
+
consume(text, { delegation = false } = {}) {
|
|
4844
|
+
recent = recent.filter((item) => now() - item.at < 1e4);
|
|
4845
|
+
const echo = recent.find((item) => item.text === normal(text) && (delegation || item.delegation));
|
|
4846
|
+
if (echo) {
|
|
4847
|
+
if (!delegation) recent = recent.filter((item) => item !== echo);
|
|
4848
|
+
return true;
|
|
4849
|
+
}
|
|
4850
|
+
if (!pending) return false;
|
|
4851
|
+
const answer = spokenChoice(text, pending.questions[pending.answers.length]);
|
|
4852
|
+
if (!answer) {
|
|
4853
|
+
prompt();
|
|
4854
|
+
return true;
|
|
4855
|
+
}
|
|
4856
|
+
recent.push({
|
|
4857
|
+
text: normal(text),
|
|
4858
|
+
at: now(),
|
|
4859
|
+
delegation
|
|
4860
|
+
});
|
|
4861
|
+
pending.answers.push(answer);
|
|
4862
|
+
if (pending.answers.length === pending.questions.length) finish({ answers: pending.answers });
|
|
4863
|
+
else prompt();
|
|
4864
|
+
return true;
|
|
4865
|
+
},
|
|
4866
|
+
close() {
|
|
4867
|
+
finish(void 0, /* @__PURE__ */ new Error("Voice question connection closed"));
|
|
4868
|
+
},
|
|
4869
|
+
get active() {
|
|
4870
|
+
return pending !== void 0;
|
|
4871
|
+
}
|
|
4872
|
+
};
|
|
4873
|
+
}
|
|
4874
|
+
//#endregion
|
|
4313
4875
|
//#region src/remote-control-realtime.js
|
|
4314
4876
|
const SIDEBAND_BASES = ["wss://api.openai.com/v1/live", "wss://realtime.chatgpt.com/v1/live"];
|
|
4315
4877
|
const ACTIVATION_RETRY_MS = [
|
|
@@ -4385,7 +4947,12 @@ const outbound = {
|
|
|
4385
4947
|
...channel ? { channel } : {},
|
|
4386
4948
|
content: content(text)
|
|
4387
4949
|
}),
|
|
4388
|
-
close: () => ({ type: "session.close" })
|
|
4950
|
+
close: () => ({ type: "session.close" }),
|
|
4951
|
+
interrupt: () => ({
|
|
4952
|
+
type: "session.context.append",
|
|
4953
|
+
channel: "developer",
|
|
4954
|
+
content: content("The user has started speaking. Stop your current speech immediately and listen. Do not finish or repeat the interrupted answer. Respond to the user when they finish speaking.")
|
|
4955
|
+
})
|
|
4389
4956
|
};
|
|
4390
4957
|
/** What the voice service sends, as the phone-facing notifications and the work to do. */
|
|
4391
4958
|
function parseEvent(payload) {
|
|
@@ -4563,6 +5130,7 @@ function createRealtimeVoice(options) {
|
|
|
4563
5130
|
clearTimeout(session.goodbye);
|
|
4564
5131
|
clearTimeout(session.unhandledTimer);
|
|
4565
5132
|
clearTimeout(session.closeTimer);
|
|
5133
|
+
session.questions?.close();
|
|
4566
5134
|
flushTail(threadId, session);
|
|
4567
5135
|
try {
|
|
4568
5136
|
session.ws.send(JSON.stringify(outbound.close()));
|
|
@@ -4599,6 +5167,7 @@ function createRealtimeVoice(options) {
|
|
|
4599
5167
|
tail: [],
|
|
4600
5168
|
lines: [],
|
|
4601
5169
|
working: 0,
|
|
5170
|
+
controls: /* @__PURE__ */ new Set(),
|
|
4602
5171
|
flushTail: params.flushTranscriptTailOnSessionEnd !== false,
|
|
4603
5172
|
silent: params.silentTailRecord === true,
|
|
4604
5173
|
hangUp: params.hangUpOnGoodbye === true
|
|
@@ -4617,7 +5186,9 @@ function createRealtimeVoice(options) {
|
|
|
4617
5186
|
for (const piece of appendChunks(text)) send(delegationId ? outbound.delegationAppend(delegationId, piece, channel) : outbound.sessionAppend(piece, channel));
|
|
4618
5187
|
};
|
|
4619
5188
|
session.speak = speak;
|
|
5189
|
+
session.questions = createVoiceQuestions({ speak: (text) => speak(void 0, text) });
|
|
4620
5190
|
const runRequest = (input, delegationId) => {
|
|
5191
|
+
if (session.questions.consume(input, { delegation: true })) return;
|
|
4621
5192
|
session.chain = session.chain.then(async () => {
|
|
4622
5193
|
if (session.ended) return;
|
|
4623
5194
|
try {
|
|
@@ -4653,6 +5224,14 @@ function createRealtimeVoice(options) {
|
|
|
4653
5224
|
};
|
|
4654
5225
|
const seenTypes = /* @__PURE__ */ new Set();
|
|
4655
5226
|
ws.on("message", (data) => {
|
|
5227
|
+
try {
|
|
5228
|
+
const value = JSON.parse(String(data));
|
|
5229
|
+
const id = value.client_event_id ?? value.error?.event_id;
|
|
5230
|
+
if (id && session.controls.delete(id)) {
|
|
5231
|
+
if (value.type === "error") log.warn("voice", "the voice service refused an interruption command", String(value.error?.message ?? "").slice(0, 200));
|
|
5232
|
+
return;
|
|
5233
|
+
}
|
|
5234
|
+
} catch {}
|
|
4656
5235
|
const event = parseEvent(String(data));
|
|
4657
5236
|
if (!event) try {
|
|
4658
5237
|
const type = JSON.parse(String(data))?.type;
|
|
@@ -4690,6 +5269,7 @@ function createRealtimeVoice(options) {
|
|
|
4690
5269
|
at: Date.now()
|
|
4691
5270
|
};
|
|
4692
5271
|
else if (event.role === "user" && event.text.trim() !== "" && !(session.hangUp && isGoodbye(event.text))) {
|
|
5272
|
+
if (session.questions.consume(event.text.trim())) return;
|
|
4693
5273
|
session.unhandled.push({
|
|
4694
5274
|
text: event.text.trim(),
|
|
4695
5275
|
at: Date.now()
|
|
@@ -4726,6 +5306,7 @@ function createRealtimeVoice(options) {
|
|
|
4726
5306
|
if (session.ended || sessions.get(threadId) !== session) return;
|
|
4727
5307
|
sessions.delete(threadId);
|
|
4728
5308
|
session.ended = true;
|
|
5309
|
+
session.questions.close();
|
|
4729
5310
|
flushTail(threadId, session);
|
|
4730
5311
|
log.warn("voice", "the voice call closed");
|
|
4731
5312
|
notify("thread/realtime/closed", {
|
|
@@ -4752,6 +5333,27 @@ function createRealtimeVoice(options) {
|
|
|
4752
5333
|
return true;
|
|
4753
5334
|
};
|
|
4754
5335
|
return {
|
|
5336
|
+
askQuestion(threadId, request) {
|
|
5337
|
+
const session = sessions.get(threadId);
|
|
5338
|
+
return session ? session.questions.ask(request) : Promise.reject(/* @__PURE__ */ new Error("No voice call is active"));
|
|
5339
|
+
},
|
|
5340
|
+
interrupt(threadId) {
|
|
5341
|
+
const session = sessions.get(threadId);
|
|
5342
|
+
if (!session) return false;
|
|
5343
|
+
const event_id = crypto.randomUUID();
|
|
5344
|
+
if (session.controls.size > 20) session.controls.delete(session.controls.values().next().value);
|
|
5345
|
+
session.controls.add(event_id);
|
|
5346
|
+
try {
|
|
5347
|
+
session.ws.send(JSON.stringify({
|
|
5348
|
+
...outbound.interrupt(),
|
|
5349
|
+
event_id
|
|
5350
|
+
}));
|
|
5351
|
+
return true;
|
|
5352
|
+
} catch {
|
|
5353
|
+
session.controls.delete(event_id);
|
|
5354
|
+
return false;
|
|
5355
|
+
}
|
|
5356
|
+
},
|
|
4755
5357
|
start,
|
|
4756
5358
|
stop,
|
|
4757
5359
|
appendText: (threadId, text) => append(threadId, text, void 0),
|
|
@@ -4797,6 +5399,19 @@ function localFolder(value) {
|
|
|
4797
5399
|
return;
|
|
4798
5400
|
}
|
|
4799
5401
|
}
|
|
5402
|
+
/** Whether two local folders are the same one: real paths compared, separators unified, case ignored on Windows. */
|
|
5403
|
+
function samePath(left, right) {
|
|
5404
|
+
if (typeof left !== "string" || typeof right !== "string" || left === "" || right === "") return false;
|
|
5405
|
+
const normal = (value) => {
|
|
5406
|
+
let resolved = value;
|
|
5407
|
+
try {
|
|
5408
|
+
resolved = realpathSync.native(value);
|
|
5409
|
+
} catch {}
|
|
5410
|
+
resolved = resolved.replace(/\\/gu, "/").replace(/(?<=.)\/+$/u, "");
|
|
5411
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
5412
|
+
};
|
|
5413
|
+
return normal(left) === normal(right);
|
|
5414
|
+
}
|
|
4800
5415
|
/** One image the phone attached, sent inline as a data URL (its own file paths mean nothing on this machine). */
|
|
4801
5416
|
function dataImage(url) {
|
|
4802
5417
|
const match = typeof url === "string" ? /^data:(image\/[A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=\s]+)$/u.exec(url) : null;
|
|
@@ -5678,7 +6293,7 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
5678
6293
|
const turn = emptyTurn();
|
|
5679
6294
|
const userItem = {
|
|
5680
6295
|
type: "userMessage",
|
|
5681
|
-
id: randomUUID(),
|
|
6296
|
+
id: params.clientUserMessageId ?? randomUUID(),
|
|
5682
6297
|
clientId: params.clientUserMessageId ?? null,
|
|
5683
6298
|
content: [...text === "" ? [] : [{
|
|
5684
6299
|
type: "text",
|
|
@@ -5698,6 +6313,7 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
5698
6313
|
threadId: id,
|
|
5699
6314
|
turn
|
|
5700
6315
|
});
|
|
6316
|
+
turn.items.push(userItem);
|
|
5701
6317
|
emit(id, "thread/status/changed", {
|
|
5702
6318
|
threadId: id,
|
|
5703
6319
|
status: {
|
|
@@ -5959,10 +6575,16 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
5959
6575
|
overriddenMetadata: null
|
|
5960
6576
|
};
|
|
5961
6577
|
},
|
|
5962
|
-
"command/exec": async (params) => {
|
|
6578
|
+
"command/exec": async (params, { notify, signal }) => {
|
|
6579
|
+
const home = homeFolderAnswer(params?.command);
|
|
6580
|
+
if (home !== void 0) return home;
|
|
5963
6581
|
const folders = await conversationFolders();
|
|
5964
6582
|
try {
|
|
5965
|
-
return await
|
|
6583
|
+
return phoneGitProbe(params?.command) ? await runPhoneGitProbe(params, {
|
|
6584
|
+
folders,
|
|
6585
|
+
notify,
|
|
6586
|
+
signal
|
|
6587
|
+
}) : await runGit(params, { folders });
|
|
5966
6588
|
} catch (error) {
|
|
5967
6589
|
trace({
|
|
5968
6590
|
method: "command/exec:refused",
|
|
@@ -6228,7 +6850,16 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
6228
6850
|
if (params?.ephemeral === true) return titleThread(params);
|
|
6229
6851
|
const cwd = localFolder(params?.cwd);
|
|
6230
6852
|
const project = typeof params?.projectId === "string" ? workspaceList().find((entry) => String(entry.id) === params.projectId) : void 0;
|
|
6231
|
-
const
|
|
6853
|
+
const workspace = !project && cwd ? workspaceList().find((entry) => samePath(entry.path, cwd)) : void 0;
|
|
6854
|
+
let created;
|
|
6855
|
+
if (project) created = await service().create({ workspaceId: project.id });
|
|
6856
|
+
else if (workspace) try {
|
|
6857
|
+
created = await service().create({ workspaceId: workspace.id });
|
|
6858
|
+
} catch (error) {
|
|
6859
|
+
const made = error?.details?.sessionId;
|
|
6860
|
+
created = typeof made === "string" && made !== "" ? { sessionId: made } : await service().create({ cwd });
|
|
6861
|
+
}
|
|
6862
|
+
else created = await service().create(cwd ? { cwd } : {});
|
|
6232
6863
|
if (typeof params?.threadSource === "string" && params.threadSource !== "") threadSources.set(created.sessionId, params.threadSource.slice(0, 64));
|
|
6233
6864
|
const agent = await agentFor(created.sessionId);
|
|
6234
6865
|
const saved = phoneConfig.read();
|
|
@@ -6480,6 +7111,11 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
6480
7111
|
};
|
|
6481
7112
|
/** DSH's ask-user tool: show the questions on the phone that drives the turn, else leave them to DSH. */
|
|
6482
7113
|
const onQuestion = (request, next) => {
|
|
7114
|
+
const threadId = request.agent?.session?.id;
|
|
7115
|
+
if (realtimeVoice?.active(threadId)) return realtimeVoice.askQuestion(threadId, request).catch((error) => {
|
|
7116
|
+
if (request.signal?.aborted) throw error;
|
|
7117
|
+
return next();
|
|
7118
|
+
});
|
|
6483
7119
|
const found = phoneFor(request);
|
|
6484
7120
|
trace({
|
|
6485
7121
|
method: "hook:user-questions",
|
|
@@ -6781,6 +7417,7 @@ function createDshRemoteControl({ controller, agents, permissions = () => void 0
|
|
|
6781
7417
|
return { answer };
|
|
6782
7418
|
},
|
|
6783
7419
|
stop: (sessionId) => realtimeVoice.stop(sessionId),
|
|
7420
|
+
interrupt: (sessionId) => realtimeVoice.interrupt(sessionId),
|
|
6784
7421
|
end: (sessionId) => realtimeVoice.requestClose(sessionId),
|
|
6785
7422
|
status: (sessionId) => realtimeVoice.status(sessionId)
|
|
6786
7423
|
}),
|
|
@@ -11385,6 +12022,17 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
|
|
|
11385
12022
|
if (error?.code === "unavailable") return publicError("unavailable", endpoint === "default-model/status" ? "The default model is unavailable" : "Could not save the default model");
|
|
11386
12023
|
return publicError("internal", endpoint === "default-model/status" ? "Could not read the default model" : "Could not save the default model");
|
|
11387
12024
|
}
|
|
12025
|
+
if (endpoint === "voice/interrupt") try {
|
|
12026
|
+
signal.throwIfAborted();
|
|
12027
|
+
if (typeof desktopVoice?.interrupt !== "function" || typeof payload?.sessionId !== "string") return publicError("unavailable", "Voice is unavailable");
|
|
12028
|
+
return {
|
|
12029
|
+
ok: true,
|
|
12030
|
+
value: { interrupted: desktopVoice.interrupt(payload.sessionId) }
|
|
12031
|
+
};
|
|
12032
|
+
} catch (error) {
|
|
12033
|
+
if (signal.aborted) throw error;
|
|
12034
|
+
return publicError("operation-error", "Could not interrupt voice");
|
|
12035
|
+
}
|
|
11388
12036
|
if (endpoint === "voice/status") try {
|
|
11389
12037
|
signal.throwIfAborted();
|
|
11390
12038
|
if (!desktopVoice || typeof payload?.sessionId !== "string") return publicError("unavailable", "Voice is unavailable");
|
|
@@ -11427,9 +12075,9 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
|
|
|
11427
12075
|
if (!voicePreview) return publicError("unavailable", "Voice preview is unavailable");
|
|
11428
12076
|
if (endpoint === "voice/catalog") return {
|
|
11429
12077
|
ok: true,
|
|
11430
|
-
value: { voices: await voicePreview.available() }
|
|
12078
|
+
value: { voices: await voicePreview.available(payload?.language) }
|
|
11431
12079
|
};
|
|
11432
|
-
const value = await voicePreview.preview(payload?.voice);
|
|
12080
|
+
const value = await voicePreview.preview(payload?.voice, payload?.language);
|
|
11433
12081
|
return value === void 0 ? publicError("not-found", "No sample for this voice") : {
|
|
11434
12082
|
ok: true,
|
|
11435
12083
|
value
|
|
@@ -11709,12 +12357,17 @@ const CATALOG_TTL_MS = 10 * 6e4;
|
|
|
11709
12357
|
const MAX_CLIP_BYTES = 2 * 1024 * 1024;
|
|
11710
12358
|
const PREVIEW_HOSTS = /^https:\/\/[a-z0-9.-]*oaistatic\.com\//u;
|
|
11711
12359
|
function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, base = BASE }) {
|
|
11712
|
-
|
|
12360
|
+
const catalogs = /* @__PURE__ */ new Map();
|
|
11713
12361
|
const clips = /* @__PURE__ */ new Map();
|
|
11714
|
-
const
|
|
12362
|
+
const languageOf = (value) => {
|
|
12363
|
+
const language = normalizeVoiceLanguage(value);
|
|
12364
|
+
return language === "auto" ? "en" : language;
|
|
12365
|
+
};
|
|
12366
|
+
const readCatalog = async (language) => {
|
|
12367
|
+
const catalog = catalogs.get(language);
|
|
11715
12368
|
if (catalog && now() - catalog.at < CATALOG_TTL_MS) return catalog.voices;
|
|
11716
12369
|
const { access, accountId } = await credentials();
|
|
11717
|
-
const response = await fetch(`${base}/settings/voices`, {
|
|
12370
|
+
const response = await fetch(`${base}/settings/voices?spoken_language=${language}`, {
|
|
11718
12371
|
headers: {
|
|
11719
12372
|
authorization: `Bearer ${access}`,
|
|
11720
12373
|
"chatgpt-account-id": accountId,
|
|
@@ -11726,22 +12379,24 @@ function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, bas
|
|
|
11726
12379
|
if (!response.ok) throw new Error(`voice catalog HTTP ${response.status}`);
|
|
11727
12380
|
const value = await response.json();
|
|
11728
12381
|
const voices = (Array.isArray(value?.voices) ? value.voices : []).filter((entry) => typeof entry?.name === "string" && typeof entry?.preview_url === "string" && PREVIEW_HOSTS.test(entry.preview_url));
|
|
11729
|
-
|
|
12382
|
+
catalogs.set(language, {
|
|
11730
12383
|
at: now(),
|
|
11731
12384
|
voices
|
|
11732
|
-
};
|
|
12385
|
+
});
|
|
11733
12386
|
return voices;
|
|
11734
12387
|
};
|
|
11735
12388
|
return {
|
|
11736
12389
|
/** Which voices ChatGPT's own catalog offers right now (lower-case names), so the settings can mark the others unavailable. */
|
|
11737
|
-
async available() {
|
|
11738
|
-
return (await readCatalog()).map((entry) => entry.name.toLowerCase());
|
|
12390
|
+
async available(language) {
|
|
12391
|
+
return (await readCatalog(languageOf(language))).map((entry) => entry.name.toLowerCase());
|
|
11739
12392
|
},
|
|
11740
12393
|
/** The clip of one voice (by its Codex name, e.g. "spruce") as a data URL, with the catalog's description. */
|
|
11741
|
-
async preview(voice) {
|
|
12394
|
+
async preview(voice, selectedLanguage) {
|
|
11742
12395
|
if (typeof voice !== "string" || !/^[a-z]{2,16}$/u.test(voice)) return void 0;
|
|
11743
|
-
|
|
11744
|
-
const
|
|
12396
|
+
const language = languageOf(selectedLanguage);
|
|
12397
|
+
const key = `${language}:${voice}`;
|
|
12398
|
+
if (clips.has(key)) return clips.get(key);
|
|
12399
|
+
const entry = (await readCatalog(language)).find((item) => item.name.toLowerCase() === voice || item.voice === voice);
|
|
11745
12400
|
if (!entry) return void 0;
|
|
11746
12401
|
const response = await fetch(entry.preview_url, { signal: AbortSignal.timeout(15e3) });
|
|
11747
12402
|
if (!response.ok) throw new Error(`voice sample HTTP ${response.status}`);
|
|
@@ -11754,7 +12409,7 @@ function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, bas
|
|
|
11754
12409
|
accent: typeof entry.accent === "string" ? entry.accent.slice(0, 60) : "",
|
|
11755
12410
|
audio: `data:${type};base64,${bytes.toString("base64")}`
|
|
11756
12411
|
};
|
|
11757
|
-
if (clips.size < 40) clips.set(
|
|
12412
|
+
if (clips.size < 40) clips.set(key, result);
|
|
11758
12413
|
return result;
|
|
11759
12414
|
}
|
|
11760
12415
|
};
|
|
@@ -11823,6 +12478,7 @@ function withEndCallTool(desktopVoice, register) {
|
|
|
11823
12478
|
return result;
|
|
11824
12479
|
},
|
|
11825
12480
|
end: (sessionId) => desktopVoice.end(sessionId),
|
|
12481
|
+
interrupt: (sessionId) => desktopVoice.interrupt(sessionId),
|
|
11826
12482
|
status: (sessionId) => desktopVoice.status(sessionId)
|
|
11827
12483
|
});
|
|
11828
12484
|
}
|
|
@@ -11846,6 +12502,11 @@ const LEGACY_CREDENTIAL_REF = dshCredentials.credentialRef("WSL043_OPENAI_CODEX_
|
|
|
11846
12502
|
const ACCOUNT_VAULT_KEY = dshCredentials.credentialKey("codex-subscription", "accounts");
|
|
11847
12503
|
const WEB_ENTRY_ID = "web";
|
|
11848
12504
|
const DSH_SEARCH_PROVIDER_FALLBACK = "deepseek-official";
|
|
12505
|
+
const SUBSCRIPTION_SEARCH_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
12506
|
+
CODEX_SEARCH_PROVIDER_ID,
|
|
12507
|
+
CODEX_AUTO_SEARCH_PROVIDER_ID,
|
|
12508
|
+
DSH_ACCOUNT_SEARCH_PROVIDER_ID
|
|
12509
|
+
]);
|
|
11849
12510
|
const MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
11850
12511
|
const REQUEST_IMAGE_PIXEL_BUDGET = 2048 * 2048;
|
|
11851
12512
|
const REQUEST_IMAGE_MAX_BYTES = 1024 * 1024;
|
|
@@ -11853,7 +12514,7 @@ function createSearchProviderSwitcher(loader) {
|
|
|
11853
12514
|
const webEntry = () => [...loader.entries()].find((entry) => entry.options?.id === WEB_ENTRY_ID);
|
|
11854
12515
|
const dshProviderId = () => {
|
|
11855
12516
|
const configured = webEntry()?.options?.config?.searchProvider;
|
|
11856
|
-
return typeof configured === "string" && configured.length > 0 ? configured : DSH_SEARCH_PROVIDER_FALLBACK;
|
|
12517
|
+
return typeof configured === "string" && configured.length > 0 && !SUBSCRIPTION_SEARCH_PROVIDER_IDS.has(configured) ? configured : DSH_SEARCH_PROVIDER_FALLBACK;
|
|
11857
12518
|
};
|
|
11858
12519
|
const current = () => {
|
|
11859
12520
|
const value = webEntry()?.fiber?.config?.searchProvider;
|
|
@@ -12188,7 +12849,32 @@ function apply(ctx, config = {}) {
|
|
|
12188
12849
|
auth: adapterAuth,
|
|
12189
12850
|
resolveAttachments: () => ctx.get?.("attachments")
|
|
12190
12851
|
});
|
|
12191
|
-
|
|
12852
|
+
const hiddenDirectory = createHiddenModelDirectory({
|
|
12853
|
+
provider: PROVIDER,
|
|
12854
|
+
disabled: () => normalizeDisabledModels(settings.get()[DISABLED_MODELS_FIELD]),
|
|
12855
|
+
pinned: () => {
|
|
12856
|
+
const keep = [];
|
|
12857
|
+
try {
|
|
12858
|
+
for (const session of ctx.get?.("sessions")?.list?.() ?? []) {
|
|
12859
|
+
const route = session.requestContext?.();
|
|
12860
|
+
if (route?.provider === PROVIDER && typeof route.model === "string") keep.push(route.model);
|
|
12861
|
+
}
|
|
12862
|
+
} catch {}
|
|
12863
|
+
const selection = defaultModel.status();
|
|
12864
|
+
if (selection.managed) keep.push(selection.model);
|
|
12865
|
+
return keep;
|
|
12866
|
+
},
|
|
12867
|
+
fallback: () => {
|
|
12868
|
+
const selection = defaultModel.status();
|
|
12869
|
+
return selection.managed ? selection.model : void 0;
|
|
12870
|
+
},
|
|
12871
|
+
emit: () => ctx.llm.emitAdaptersUpdated?.()
|
|
12872
|
+
});
|
|
12873
|
+
ctx.effect(() => settings.watch((value, previous) => hiddenDirectory.settingsChanged(normalizeDisabledModels(value[DISABLED_MODELS_FIELD]), normalizeDisabledModels(previous[DISABLED_MODELS_FIELD]))), "codex-subscription: hidden model directory");
|
|
12874
|
+
ctx.effect(() => ctx.on?.("session/event", (_session, event) => {
|
|
12875
|
+
if (event?.type === "request/context") hiddenDirectory.dependenciesChanged();
|
|
12876
|
+
}), "codex-subscription: hidden model dependencies");
|
|
12877
|
+
ctx.llm.registerAdapter([PROVIDER], hiddenDirectory.wrap(observeAdapter(compaction.wrapAdapter(adapter), provider)));
|
|
12192
12878
|
const currentAgent = () => ctx.get?.("agents")?.currentInitiator?.();
|
|
12193
12879
|
const servesCurrentModel = () => {
|
|
12194
12880
|
if (settings.get().otherModels !== "off") return true;
|