@chosengeneration/light-code 0.74.0 → 0.80.1
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 +1118 -148
- package/dist/client/client.css +88 -0
- package/dist/client/client.js +56 -56
- package/dist/client/index.html +17 -0
- package/dist/server.js +1117 -147
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -24482,6 +24482,8 @@ var FetchHttpClient = class {
|
|
|
24482
24482
|
init.headers = options.headers;
|
|
24483
24483
|
if (options.body !== void 0)
|
|
24484
24484
|
init.body = options.body;
|
|
24485
|
+
if (options.bodyBytes !== void 0)
|
|
24486
|
+
init.body = options.bodyBytes;
|
|
24485
24487
|
if (options.signal !== void 0)
|
|
24486
24488
|
init.signal = options.signal;
|
|
24487
24489
|
let target;
|
|
@@ -40171,6 +40173,68 @@ var mailIndexConfigSchema = external_exports.object({
|
|
|
40171
40173
|
/** Characters of body kept per message, for showing a hit without reopening Outlook. */
|
|
40172
40174
|
previewChars: external_exports.number().int().min(0).max(2e3)
|
|
40173
40175
|
}).partial();
|
|
40176
|
+
var s3ConnectionSchema = external_exports.object({
|
|
40177
|
+
id: external_exports.string().min(1),
|
|
40178
|
+
label: external_exports.string().min(1),
|
|
40179
|
+
bucket: external_exports.string().min(1),
|
|
40180
|
+
region: external_exports.string().min(1),
|
|
40181
|
+
accessKeyId: external_exports.string().min(1),
|
|
40182
|
+
secretAccessKeyRef: external_exports.string().min(1),
|
|
40183
|
+
/** Only for temporary credentials. */
|
|
40184
|
+
sessionTokenRef: external_exports.string().optional(),
|
|
40185
|
+
/** Absent means the ordinary AWS endpoint for the region. */
|
|
40186
|
+
endpoint: external_exports.string().url().optional(),
|
|
40187
|
+
/** `host/bucket/key` instead of `bucket.host/key`, which internal deployments usually need. */
|
|
40188
|
+
pathStyle: external_exports.boolean().optional(),
|
|
40189
|
+
/**
|
|
40190
|
+
* Everything is confined to this prefix, when one is set.
|
|
40191
|
+
*
|
|
40192
|
+
* Not a convenience. It is the only thing bounding what the tools can reach in a bucket that may
|
|
40193
|
+
* hold far more than this project, and it is enforced on every key rather than trusted to the
|
|
40194
|
+
* model — `confine()`'s argument applied to a bucket instead of a disk.
|
|
40195
|
+
*/
|
|
40196
|
+
prefix: external_exports.string().optional(),
|
|
40197
|
+
/** Refuses every write, so a bucket can be attached for reading with nothing to go wrong. */
|
|
40198
|
+
readOnly: external_exports.boolean().optional()
|
|
40199
|
+
});
|
|
40200
|
+
var s3MirrorSchema = external_exports.object({
|
|
40201
|
+
connectionId: external_exports.string().min(1),
|
|
40202
|
+
prefix: external_exports.string().optional(),
|
|
40203
|
+
/** Off by default: reading a bucket on every panel open is somebody's money and latency. */
|
|
40204
|
+
enabled: external_exports.boolean().optional(),
|
|
40205
|
+
/**
|
|
40206
|
+
* New skills written here are also copied up to this folder.
|
|
40207
|
+
*
|
|
40208
|
+
* At most one folder should carry it, and the bridge takes the first that does. The rest are
|
|
40209
|
+
* read-only sources, which is the same split the local folders already have: one place new
|
|
40210
|
+
* skills are saved, and any number of folders they are *also* read from. A list where every
|
|
40211
|
+
* entry was writable would make "where did that skill go" unanswerable.
|
|
40212
|
+
*/
|
|
40213
|
+
publish: external_exports.boolean().optional()
|
|
40214
|
+
});
|
|
40215
|
+
var s3ConfigSchema = external_exports.object({
|
|
40216
|
+
connections: external_exports.array(s3ConnectionSchema).max(20).optional(),
|
|
40217
|
+
/**
|
|
40218
|
+
* Where skills are kept, when they live in a bucket rather than on this disk.
|
|
40219
|
+
*
|
|
40220
|
+
* Only the *files* move. They are still loaded, watched and indexed exactly as local ones are —
|
|
40221
|
+
* indexing stays as configured — so this names a sync, not a second kind of skill.
|
|
40222
|
+
*
|
|
40223
|
+
* A **list**, because it maps onto the split the local folders already have: any number of
|
|
40224
|
+
* folders skills are read from, and one place new ones are saved. A bucket folder is one more
|
|
40225
|
+
* source, so several of them is the ordinary case rather than a special one.
|
|
40226
|
+
*/
|
|
40227
|
+
skills: external_exports.array(s3MirrorSchema).max(8).optional(),
|
|
40228
|
+
/**
|
|
40229
|
+
* The same for Python tools, with one difference that is not a detail.
|
|
40230
|
+
*
|
|
40231
|
+
* A mirrored `.py` is **not** loaded on arrival. The hash-pinned registry (§13) refuses any tool
|
|
40232
|
+
* that was not approved with its source shown, so a bucket is how a tool *reaches* a machine,
|
|
40233
|
+
* and approval still happens on each one. Anybody with write access to the bucket would
|
|
40234
|
+
* otherwise be running code as this user on every machine that syncs.
|
|
40235
|
+
*/
|
|
40236
|
+
tools: external_exports.array(s3MirrorSchema).max(8).optional()
|
|
40237
|
+
});
|
|
40174
40238
|
var configSchema = external_exports.object({
|
|
40175
40239
|
profiles: external_exports.array(providerProfileSchema),
|
|
40176
40240
|
/**
|
|
@@ -40192,6 +40256,8 @@ var configSchema = external_exports.object({
|
|
|
40192
40256
|
* embedder would exfiltrate whatever gets indexed — sharper than the existing entries,
|
|
40193
40257
|
* because the payload is source code.
|
|
40194
40258
|
*/
|
|
40259
|
+
/** User-scope only (invariant 5): it holds a bucket and a key that can write to it. */
|
|
40260
|
+
s3: s3ConfigSchema,
|
|
40195
40261
|
vectorStores: external_exports.record(external_exports.string(), vectorStoreSchema),
|
|
40196
40262
|
activeVectorStoreId: external_exports.string(),
|
|
40197
40263
|
embedder: embedderConfigSchema,
|
|
@@ -40839,6 +40905,15 @@ var USER_SCOPE_ONLY_KEYS = [
|
|
|
40839
40905
|
// Per-project settings live here, keyed by path. Same reasoning as `approvals` exactly: a repo
|
|
40840
40906
|
// that could write its own entry would choose its own vector store and model for itself.
|
|
40841
40907
|
"workspaces",
|
|
40908
|
+
/*
|
|
40909
|
+
* Holds a bucket, an endpoint and the reference to a key that can read and write it.
|
|
40910
|
+
*
|
|
40911
|
+
* The sharpest kind of entry on this list: a repository able to set it would point the upload
|
|
40912
|
+
* tool at a bucket of its choosing, and everything copied "into S3" would go to somebody else —
|
|
40913
|
+
* with the user watching a tool succeed. Same shape as `embedder`, with whatever the user
|
|
40914
|
+
* uploads as the payload.
|
|
40915
|
+
*/
|
|
40916
|
+
"s3",
|
|
40842
40917
|
// `expert.path` names an executable. A workspace able to set it would run a program of
|
|
40843
40918
|
// its choosing as soon as the panel opened — the same threat as `python.uvPath`.
|
|
40844
40919
|
// `expert.enabled` is here too, so a repo cannot switch on paid API calls by itself.
|
|
@@ -43508,6 +43583,10 @@ function isValidRoleId(id) {
|
|
|
43508
43583
|
function isAgentRole(value, custom2 = []) {
|
|
43509
43584
|
return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
|
|
43510
43585
|
}
|
|
43586
|
+
var COLOURED_NON_ROLES = ["claude"];
|
|
43587
|
+
function isColourableAgent(value, custom2 = []) {
|
|
43588
|
+
return isAgentRole(value, custom2) || COLOURED_NON_ROLES.includes(value);
|
|
43589
|
+
}
|
|
43511
43590
|
function knownRoles(custom2 = []) {
|
|
43512
43591
|
return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
|
|
43513
43592
|
}
|
|
@@ -48486,26 +48565,26 @@ Each appears in its own window. Nothing is changed or sent.`
|
|
|
48486
48565
|
async execute(params) {
|
|
48487
48566
|
const ids = idsOf(params);
|
|
48488
48567
|
const opened = [];
|
|
48489
|
-
const
|
|
48568
|
+
const failed2 = [];
|
|
48490
48569
|
for (const id of ids) {
|
|
48491
48570
|
try {
|
|
48492
48571
|
opened.push((await options.display(id)).subject);
|
|
48493
48572
|
} catch (error51) {
|
|
48494
|
-
|
|
48573
|
+
failed2.push(`${id}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48495
48574
|
}
|
|
48496
48575
|
}
|
|
48497
48576
|
if (opened.length === 0) {
|
|
48498
48577
|
return { content: `Could not open any of them.
|
|
48499
|
-
${
|
|
48578
|
+
${failed2.join("\n")}`, isError: true };
|
|
48500
48579
|
}
|
|
48501
48580
|
return {
|
|
48502
48581
|
content: [
|
|
48503
48582
|
`Opened ${String(opened.length)} message(s) in Outlook:`,
|
|
48504
48583
|
...opened.map((subject) => ` "${subject}"`),
|
|
48505
|
-
...
|
|
48584
|
+
...failed2.length === 0 ? [] : [
|
|
48506
48585
|
"",
|
|
48507
|
-
`${String(
|
|
48508
|
-
...
|
|
48586
|
+
`${String(failed2.length)} could not be opened - moved or deleted since indexing:`,
|
|
48587
|
+
...failed2.map((line) => ` ${line}`)
|
|
48509
48588
|
]
|
|
48510
48589
|
].join("\n")
|
|
48511
48590
|
};
|
|
@@ -57074,10 +57153,20 @@ function createWriteSkillTool(context) {
|
|
|
57074
57153
|
}
|
|
57075
57154
|
await fs10.writeFile(filePath, rendered, "utf8");
|
|
57076
57155
|
await context.onChanged();
|
|
57156
|
+
let publishProblem;
|
|
57157
|
+
if (context.onSaved !== void 0) {
|
|
57158
|
+
try {
|
|
57159
|
+
await context.onSaved(params.name, rendered);
|
|
57160
|
+
} catch (error51) {
|
|
57161
|
+
publishProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
57162
|
+
}
|
|
57163
|
+
}
|
|
57077
57164
|
const collision = existed ? void 0 : await collisionWarning(params.name);
|
|
57078
57165
|
return {
|
|
57079
57166
|
content: `${existed ? "Updated" : "Recorded"} the skill "${params.name}" at ${filePath}.
|
|
57080
|
-
Its summary will appear in your context from the next message onward.` + (
|
|
57167
|
+
Its summary will appear in your context from the next message onward.` + (publishProblem === void 0 ? "" : `
|
|
57168
|
+
|
|
57169
|
+
Saved here, but NOT copied to the bucket: ${publishProblem}`) + (collision === void 0 ? "" : `
|
|
57081
57170
|
|
|
57082
57171
|
${collision}`),
|
|
57083
57172
|
path: filePath
|
|
@@ -58639,8 +58728,8 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58639
58728
|
events.onToolResult(toolCall, result);
|
|
58640
58729
|
const queued = options.drainQueuedMessages?.() ?? [];
|
|
58641
58730
|
for (const message3 of queued) {
|
|
58642
|
-
conversation.addUserMessage(message3);
|
|
58643
|
-
events.onQueuedMessageConsumed?.(message3);
|
|
58731
|
+
conversation.addUserMessage(message3.text, message3.images);
|
|
58732
|
+
events.onQueuedMessageConsumed?.(message3.text);
|
|
58644
58733
|
}
|
|
58645
58734
|
if (queued.length > 0) {
|
|
58646
58735
|
iteration = -1;
|
|
@@ -61642,6 +61731,10 @@ var NodeFileSystem = class {
|
|
|
61642
61731
|
async writeFile(path32, contents) {
|
|
61643
61732
|
await fs16.writeFile(path32, contents, "utf8");
|
|
61644
61733
|
}
|
|
61734
|
+
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
61735
|
+
async writeBytes(path32, contents) {
|
|
61736
|
+
await fs16.writeFile(path32, contents);
|
|
61737
|
+
}
|
|
61645
61738
|
async stat(path32) {
|
|
61646
61739
|
const stat = await fs16.lstat(path32);
|
|
61647
61740
|
return {
|
|
@@ -61967,7 +62060,7 @@ function wireChatBridge(services) {
|
|
|
61967
62060
|
const { transport, secrets, ui, workspaceRoot, storageDir } = services;
|
|
61968
62061
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
61969
62062
|
const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
|
|
61970
|
-
const httpClient = services.httpClient ?? new FetchHttpClient();
|
|
62063
|
+
const httpClient = services.httpClient ?? new FetchHttpClient({ useEnvProxy: true });
|
|
61971
62064
|
const conversation = new Conversation(workspaceRoot !== void 0 ? buildSystemPrompt(workspaceRoot) : void 0);
|
|
61972
62065
|
let cachedSecretValues = [];
|
|
61973
62066
|
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(path23.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
@@ -62060,6 +62153,10 @@ ${preview.text}` } : {}
|
|
|
62060
62153
|
const defaultSkillsDir = workspaceRoot !== void 0 ? path23.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
62061
62154
|
let skillsDir = defaultSkillsDir;
|
|
62062
62155
|
let extraSkillDirs = [];
|
|
62156
|
+
let mirroredSkillsDirs = [];
|
|
62157
|
+
let mirroredToolsDirs = [];
|
|
62158
|
+
let cachedSkillMirrors = [];
|
|
62159
|
+
let lastSync = {};
|
|
62063
62160
|
function resolveSkillDir(entry) {
|
|
62064
62161
|
const trimmed = entry.trim();
|
|
62065
62162
|
if (trimmed.length === 0)
|
|
@@ -62261,7 +62358,15 @@ ${preview.text}` } : {}
|
|
|
62261
62358
|
}
|
|
62262
62359
|
let queuedMessages = [];
|
|
62263
62360
|
function postQueued() {
|
|
62264
|
-
post({
|
|
62361
|
+
post({
|
|
62362
|
+
type: "queued",
|
|
62363
|
+
// A count, not the attachments: the composer only needs to say one is there, and sending
|
|
62364
|
+
// the bytes back for something already on screen would be waste.
|
|
62365
|
+
messages: queuedMessages.map((entry) => ({
|
|
62366
|
+
text: entry.text,
|
|
62367
|
+
...entry.images !== void 0 && entry.images.length > 0 ? { images: entry.images.length } : {}
|
|
62368
|
+
}))
|
|
62369
|
+
});
|
|
62265
62370
|
}
|
|
62266
62371
|
let activeAbortController;
|
|
62267
62372
|
let taskCheckpoint;
|
|
@@ -62614,6 +62719,7 @@ ${preview.text}` } : {}
|
|
|
62614
62719
|
let cachedOffice = {};
|
|
62615
62720
|
let cachedMail = {};
|
|
62616
62721
|
let cachedDatasets = [];
|
|
62722
|
+
let cachedS3 = { targets: [], problems: [] };
|
|
62617
62723
|
let datasetSummaryForPrompt = [];
|
|
62618
62724
|
let cachedPythonEnabled = false;
|
|
62619
62725
|
const mailStore = new MailStore(storageDir);
|
|
@@ -62662,6 +62768,22 @@ ${preview.text}` } : {}
|
|
|
62662
62768
|
cachedOffice = config2.office ?? {};
|
|
62663
62769
|
cachedMail = config2.mail ?? {};
|
|
62664
62770
|
cachedDatasets = config2.datasets ?? [];
|
|
62771
|
+
cachedS3 = await resolveS3({
|
|
62772
|
+
config: config2.s3,
|
|
62773
|
+
http: httpClient,
|
|
62774
|
+
secrets,
|
|
62775
|
+
/*
|
|
62776
|
+
* Through the one global resolver, so a corporate root certificate reaches S3 exactly as it
|
|
62777
|
+
* reaches the gateway and the vector store. §10: do not add another place to configure a CA.
|
|
62778
|
+
*/
|
|
62779
|
+
tls: await resolveConnectionTls({
|
|
62780
|
+
...config2.tls !== void 0 ? { global: config2.tls } : {},
|
|
62781
|
+
...config2.certDir !== void 0 ? { certDir: config2.certDir } : {},
|
|
62782
|
+
onPaths: (paths) => {
|
|
62783
|
+
void Promise.all(paths.map((certPath) => denylist.add(certPath))).catch(() => void 0);
|
|
62784
|
+
}
|
|
62785
|
+
})
|
|
62786
|
+
});
|
|
62665
62787
|
cachedPythonEnabled = config2.python?.dynamicTools === "on";
|
|
62666
62788
|
datasetSummaryForPrompt = await Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
62667
62789
|
name: dataset.name,
|
|
@@ -62695,6 +62817,20 @@ ${preview.text}` } : {}
|
|
|
62695
62817
|
cachedReadRoots = (config2.filesystem?.readRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
62696
62818
|
skillsDir = (config2.skills?.dir !== void 0 ? resolveSkillDir(config2.skills.dir) : void 0) ?? defaultSkillsDir;
|
|
62697
62819
|
extraSkillDirs = (config2.skills?.paths ?? []).map(resolveSkillDir).filter((dir) => dir !== void 0);
|
|
62820
|
+
cachedSkillMirrors = config2.s3?.skills ?? [];
|
|
62821
|
+
mirroredSkillsDirs = cachedSkillMirrors.filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
|
|
62822
|
+
storageDir,
|
|
62823
|
+
connectionId: mirror.connectionId,
|
|
62824
|
+
kind: "skills",
|
|
62825
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
62826
|
+
}));
|
|
62827
|
+
extraSkillDirs.push(...mirroredSkillsDirs);
|
|
62828
|
+
mirroredToolsDirs = (config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
|
|
62829
|
+
storageDir,
|
|
62830
|
+
connectionId: mirror.connectionId,
|
|
62831
|
+
kind: "tools",
|
|
62832
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
62833
|
+
}));
|
|
62698
62834
|
return config2;
|
|
62699
62835
|
}
|
|
62700
62836
|
function announceConfigRecovery() {
|
|
@@ -62864,7 +63000,22 @@ ${preview.text}` } : {}
|
|
|
62864
63000
|
submitForReview: (request) => services.submitForReview?.({ kind: "skill", ...request }) ?? Promise.resolve("")
|
|
62865
63001
|
} : {}
|
|
62866
63002
|
};
|
|
62867
|
-
|
|
63003
|
+
const publishTo = cachedSkillMirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
|
|
63004
|
+
const skillTarget = publishTo === void 0 ? void 0 : targetById(cachedS3, publishTo.connectionId);
|
|
63005
|
+
const mirrorPrefix = publishTo?.prefix;
|
|
63006
|
+
combined.register(createWriteSkillTool({
|
|
63007
|
+
...context,
|
|
63008
|
+
...skillTarget !== void 0 && skillTarget.readOnly !== true ? {
|
|
63009
|
+
onSaved: async (name, content) => {
|
|
63010
|
+
await uploadToS3({
|
|
63011
|
+
target: skillTarget,
|
|
63012
|
+
...mirrorPrefix !== void 0 ? { prefix: mirrorPrefix } : {},
|
|
63013
|
+
relative: `${name}.md`,
|
|
63014
|
+
contents: Buffer.from(content, "utf8")
|
|
63015
|
+
});
|
|
63016
|
+
}
|
|
63017
|
+
} : {}
|
|
63018
|
+
}));
|
|
62868
63019
|
combined.register(createDeleteSkillTool(context));
|
|
62869
63020
|
}
|
|
62870
63021
|
if (workspaceRoot !== void 0) {
|
|
@@ -62899,6 +63050,8 @@ ${preview.text}` } : {}
|
|
|
62899
63050
|
if (codebase !== void 0) {
|
|
62900
63051
|
combined.register(createSearchCodebaseTool({ ...codebase, observer: searchLog }));
|
|
62901
63052
|
}
|
|
63053
|
+
for (const tool of createS3Tools(cachedS3.targets))
|
|
63054
|
+
combined.register(tool);
|
|
62902
63055
|
if (cachedDatasets.length > 0) {
|
|
62903
63056
|
combined.register(createSearchDataTool({
|
|
62904
63057
|
load: async () => Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
@@ -63332,7 +63485,25 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63332
63485
|
const drained = queuedMessages;
|
|
63333
63486
|
queuedMessages = [];
|
|
63334
63487
|
postQueued();
|
|
63335
|
-
return drained
|
|
63488
|
+
return drained.map((entry) => {
|
|
63489
|
+
const attachments = entry.images ?? [];
|
|
63490
|
+
if (attachments.length === 0)
|
|
63491
|
+
return { text: entry.text };
|
|
63492
|
+
if (!capabilities.supportsVision) {
|
|
63493
|
+
post({
|
|
63494
|
+
type: "error",
|
|
63495
|
+
message: `${profile.model} does not accept images. The attachment on a queued message was not sent \u2014 set "Supports images" in the profile's advanced settings if that is wrong.`
|
|
63496
|
+
});
|
|
63497
|
+
return { text: entry.text };
|
|
63498
|
+
}
|
|
63499
|
+
return {
|
|
63500
|
+
text: entry.text,
|
|
63501
|
+
images: attachments.map((image) => ({
|
|
63502
|
+
mediaType: image.mediaType,
|
|
63503
|
+
data: image.data
|
|
63504
|
+
}))
|
|
63505
|
+
};
|
|
63506
|
+
});
|
|
63336
63507
|
}
|
|
63337
63508
|
};
|
|
63338
63509
|
if (images !== void 0 && images.length > 0 && capabilities.supportsVision) {
|
|
@@ -63528,10 +63699,11 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63528
63699
|
await persistActiveTask();
|
|
63529
63700
|
await postTasks();
|
|
63530
63701
|
if (queuedMessages.length > 0 && activeAbortController === void 0) {
|
|
63531
|
-
const next = queuedMessages.join("\n\n");
|
|
63702
|
+
const next = queuedMessages.map((entry) => entry.text).join("\n\n");
|
|
63703
|
+
const images2 = queuedMessages.flatMap((entry) => entry.images ?? []);
|
|
63532
63704
|
queuedMessages = [];
|
|
63533
63705
|
postQueued();
|
|
63534
|
-
void handleSendMessage(next);
|
|
63706
|
+
void handleSendMessage(next, images2.length > 0 ? images2 : void 0);
|
|
63535
63707
|
}
|
|
63536
63708
|
}
|
|
63537
63709
|
}
|
|
@@ -65028,6 +65200,158 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65028
65200
|
const digest = createHash3("sha256").update(path23.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
|
|
65029
65201
|
return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
|
|
65030
65202
|
}
|
|
65203
|
+
async function postS3() {
|
|
65204
|
+
const { config: config2 } = await configManager.load();
|
|
65205
|
+
const connections = await Promise.all((config2.s3?.connections ?? []).map(async (connection) => ({
|
|
65206
|
+
id: connection.id,
|
|
65207
|
+
label: connection.label,
|
|
65208
|
+
bucket: connection.bucket,
|
|
65209
|
+
region: connection.region,
|
|
65210
|
+
accessKeyId: connection.accessKeyId,
|
|
65211
|
+
/*
|
|
65212
|
+
* Asked of the secret store rather than inferred from config holding a reference.
|
|
65213
|
+
*
|
|
65214
|
+
* Config and the store are two stores that can diverge, and letting one assert what only
|
|
65215
|
+
* the other knows is what made a vanished API key keep reading as "Set" for three
|
|
65216
|
+
* releases (section 19).
|
|
65217
|
+
*/
|
|
65218
|
+
hasSecret: await secrets.get(connection.secretAccessKeyRef) !== void 0,
|
|
65219
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
65220
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {},
|
|
65221
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
65222
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
65223
|
+
})));
|
|
65224
|
+
post({
|
|
65225
|
+
type: "s3",
|
|
65226
|
+
connections,
|
|
65227
|
+
problems: cachedS3.problems,
|
|
65228
|
+
skills: config2.s3?.skills ?? [],
|
|
65229
|
+
tools: config2.s3?.tools ?? [],
|
|
65230
|
+
skillsFolders: mirroredSkillsDirs,
|
|
65231
|
+
toolsFolders: mirroredToolsDirs,
|
|
65232
|
+
...lastSync.skills !== void 0 ? { lastSkillsSync: lastSync.skills } : {},
|
|
65233
|
+
...lastSync.tools !== void 0 ? { lastToolsSync: lastSync.tools } : {}
|
|
65234
|
+
});
|
|
65235
|
+
}
|
|
65236
|
+
const s3SecretRef = (id) => `s3:${id}:secret`;
|
|
65237
|
+
const s3TokenRef = (id) => `s3:${id}:sessionToken`;
|
|
65238
|
+
async function handleSaveS3Connection(input, secret, sessionToken) {
|
|
65239
|
+
const { config: config2 } = await configManager.load();
|
|
65240
|
+
const id = input.id ?? `s3-${Date.now().toString(36)}`;
|
|
65241
|
+
const existing = (config2.s3?.connections ?? []).find((connection) => connection.id === id);
|
|
65242
|
+
if (secret !== void 0 && secret.trim().length > 0) {
|
|
65243
|
+
await secrets.set(s3SecretRef(id), secret.trim());
|
|
65244
|
+
}
|
|
65245
|
+
if (sessionToken !== void 0 && sessionToken.trim().length > 0) {
|
|
65246
|
+
await secrets.set(s3TokenRef(id), sessionToken.trim());
|
|
65247
|
+
}
|
|
65248
|
+
const saved = {
|
|
65249
|
+
id,
|
|
65250
|
+
label: input.label.trim(),
|
|
65251
|
+
bucket: input.bucket.trim(),
|
|
65252
|
+
region: input.region.trim(),
|
|
65253
|
+
accessKeyId: input.accessKeyId.trim(),
|
|
65254
|
+
secretAccessKeyRef: s3SecretRef(id),
|
|
65255
|
+
...existing?.sessionTokenRef !== void 0 || (sessionToken ?? "").trim().length > 0 ? { sessionTokenRef: s3TokenRef(id) } : {},
|
|
65256
|
+
...input.endpoint !== void 0 && input.endpoint.trim().length > 0 ? { endpoint: input.endpoint.trim() } : {},
|
|
65257
|
+
...input.pathStyle === true ? { pathStyle: true } : {},
|
|
65258
|
+
...input.prefix !== void 0 && input.prefix.trim().length > 0 ? { prefix: input.prefix.trim() } : {},
|
|
65259
|
+
...input.readOnly === true ? { readOnly: true } : {}
|
|
65260
|
+
};
|
|
65261
|
+
const others = (config2.s3?.connections ?? []).filter((connection) => connection.id !== id);
|
|
65262
|
+
await configManager.save("user", {
|
|
65263
|
+
s3: { ...config2.s3 ?? {}, connections: [...others, saved] }
|
|
65264
|
+
});
|
|
65265
|
+
await loadSettings();
|
|
65266
|
+
await postS3();
|
|
65267
|
+
}
|
|
65268
|
+
async function handleDeleteS3Connection(id) {
|
|
65269
|
+
const { config: config2 } = await configManager.load();
|
|
65270
|
+
await secrets.delete(s3SecretRef(id)).catch(() => void 0);
|
|
65271
|
+
await secrets.delete(s3TokenRef(id)).catch(() => void 0);
|
|
65272
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65273
|
+
s3.connections = (s3.connections ?? []).filter((connection) => connection.id !== id);
|
|
65274
|
+
s3.skills = (s3.skills ?? []).filter((mirror) => mirror.connectionId !== id);
|
|
65275
|
+
s3.tools = (s3.tools ?? []).filter((mirror) => mirror.connectionId !== id);
|
|
65276
|
+
if (s3.skills.length === 0)
|
|
65277
|
+
delete s3.skills;
|
|
65278
|
+
if (s3.tools.length === 0)
|
|
65279
|
+
delete s3.tools;
|
|
65280
|
+
await configManager.save("user", { s3 });
|
|
65281
|
+
await loadSettings();
|
|
65282
|
+
await postS3();
|
|
65283
|
+
}
|
|
65284
|
+
async function handleSaveS3Mirrors(kind, mirrors) {
|
|
65285
|
+
const { config: config2 } = await configManager.load();
|
|
65286
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65287
|
+
const cleaned = mirrors.filter((mirror) => mirror.connectionId.trim().length > 0).map((mirror) => ({
|
|
65288
|
+
connectionId: mirror.connectionId.trim(),
|
|
65289
|
+
...mirror.prefix !== void 0 && mirror.prefix.trim().length > 0 ? { prefix: mirror.prefix.trim() } : {},
|
|
65290
|
+
...mirror.enabled === true ? { enabled: true } : {},
|
|
65291
|
+
...mirror.publish === true ? { publish: true } : {}
|
|
65292
|
+
}));
|
|
65293
|
+
if (cleaned.length === 0)
|
|
65294
|
+
delete s3[kind];
|
|
65295
|
+
else
|
|
65296
|
+
s3[kind] = cleaned;
|
|
65297
|
+
await configManager.save("user", { s3 });
|
|
65298
|
+
await loadSettings();
|
|
65299
|
+
if (cleaned.some((mirror) => mirror.enabled === true))
|
|
65300
|
+
await handleSyncS3(kind);
|
|
65301
|
+
else
|
|
65302
|
+
await postS3();
|
|
65303
|
+
}
|
|
65304
|
+
async function handleSyncS3(kind) {
|
|
65305
|
+
const { config: config2 } = await configManager.load();
|
|
65306
|
+
const mirrors = (config2.s3?.[kind] ?? []).filter((mirror) => mirror.enabled === true);
|
|
65307
|
+
if (mirrors.length === 0) {
|
|
65308
|
+
lastSync = { ...lastSync, [kind]: "No bucket folder is configured." };
|
|
65309
|
+
await postS3();
|
|
65310
|
+
return;
|
|
65311
|
+
}
|
|
65312
|
+
const lines = [];
|
|
65313
|
+
for (const mirror of mirrors) {
|
|
65314
|
+
const target = targetById(cachedS3, mirror.connectionId);
|
|
65315
|
+
const where = `${mirror.connectionId}/${mirror.prefix ?? ""}`;
|
|
65316
|
+
if (target === void 0) {
|
|
65317
|
+
lines.push(`${where}: connection unusable - check its key above`);
|
|
65318
|
+
continue;
|
|
65319
|
+
}
|
|
65320
|
+
const localDir = mirrorFolder({
|
|
65321
|
+
storageDir,
|
|
65322
|
+
connectionId: mirror.connectionId,
|
|
65323
|
+
kind,
|
|
65324
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
65325
|
+
});
|
|
65326
|
+
try {
|
|
65327
|
+
const result = await syncFromS3({
|
|
65328
|
+
target,
|
|
65329
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
65330
|
+
localDir,
|
|
65331
|
+
fs: new NodeFileSystem(),
|
|
65332
|
+
extensions: kind === "skills" ? [".md"] : [".py"]
|
|
65333
|
+
});
|
|
65334
|
+
const parts = [
|
|
65335
|
+
`${String(result.written.length)} updated`,
|
|
65336
|
+
`${String(result.unchanged)} unchanged`
|
|
65337
|
+
];
|
|
65338
|
+
if (result.failed.length > 0)
|
|
65339
|
+
parts.push(`${String(result.failed.length)} failed`);
|
|
65340
|
+
lines.push(`${target.label}${mirror.prefix === void 0 ? "" : `/${mirror.prefix}`}: ${parts.join(", ")}`);
|
|
65341
|
+
for (const failure of result.failed) {
|
|
65342
|
+
logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
|
|
65343
|
+
}
|
|
65344
|
+
} catch (error51) {
|
|
65345
|
+
lines.push(`${target.label}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
65346
|
+
}
|
|
65347
|
+
}
|
|
65348
|
+
lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${lines.join("; ")}` };
|
|
65349
|
+
if (kind === "skills") {
|
|
65350
|
+
await refreshSkills();
|
|
65351
|
+
postSkills();
|
|
65352
|
+
}
|
|
65353
|
+
await postS3();
|
|
65354
|
+
}
|
|
65031
65355
|
async function handleSaveSkillsAlias(aliases) {
|
|
65032
65356
|
try {
|
|
65033
65357
|
const { config: config2 } = await configManager.load();
|
|
@@ -66594,6 +66918,13 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66594
66918
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
66595
66919
|
}
|
|
66596
66920
|
}
|
|
66921
|
+
function reportFailure(operation, work) {
|
|
66922
|
+
work.catch((error51) => {
|
|
66923
|
+
const reason = error51 instanceof Error ? error51.message : String(error51);
|
|
66924
|
+
logger.warn(`${operation} failed`, reason);
|
|
66925
|
+
post({ type: "error", message: `${operation} failed: ${reason}` });
|
|
66926
|
+
});
|
|
66927
|
+
}
|
|
66597
66928
|
const unsubscribe = transport.onMessage((raw) => {
|
|
66598
66929
|
const message3 = raw;
|
|
66599
66930
|
if (message3.type === "sendMessage") {
|
|
@@ -66614,9 +66945,12 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66614
66945
|
}
|
|
66615
66946
|
})();
|
|
66616
66947
|
} else if (message3.type === "requestMentionCandidates") {
|
|
66617
|
-
|
|
66948
|
+
reportFailure("handleMentionCandidates", handleMentionCandidates(message3.query));
|
|
66618
66949
|
} else if (message3.type === "queueMessage") {
|
|
66619
|
-
queuedMessages.push(
|
|
66950
|
+
queuedMessages.push({
|
|
66951
|
+
text: message3.text,
|
|
66952
|
+
...message3.images !== void 0 && message3.images.length > 0 ? { images: message3.images } : {}
|
|
66953
|
+
});
|
|
66620
66954
|
postQueued();
|
|
66621
66955
|
} else if (message3.type === "unqueueMessage") {
|
|
66622
66956
|
queuedMessages.splice(message3.index, 1);
|
|
@@ -66637,21 +66971,21 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66637
66971
|
pendingFormFields.delete(message3.id);
|
|
66638
66972
|
}
|
|
66639
66973
|
} else if (message3.type === "approvalResponseAlways") {
|
|
66640
|
-
|
|
66974
|
+
reportFailure("handleAlwaysAllow", handleAlwaysAllow(message3.id, message3.scope));
|
|
66641
66975
|
} else if (message3.type === "rollback") {
|
|
66642
|
-
|
|
66976
|
+
reportFailure("handleRollback", handleRollback());
|
|
66643
66977
|
} else if (message3.type === "requestSettings") {
|
|
66644
|
-
|
|
66978
|
+
reportFailure("postSettings", postSettings());
|
|
66645
66979
|
} else if (message3.type === "requestTasks") {
|
|
66646
|
-
|
|
66980
|
+
reportFailure("postTasks", postTasks());
|
|
66647
66981
|
} else if (message3.type === "openTask") {
|
|
66648
|
-
|
|
66982
|
+
reportFailure("openTask", openTask(message3.id));
|
|
66649
66983
|
} else if (message3.type === "deleteTask") {
|
|
66650
|
-
|
|
66984
|
+
reportFailure("deleteTask", deleteTask(message3.id));
|
|
66651
66985
|
} else if (message3.type === "newTask") {
|
|
66652
|
-
|
|
66986
|
+
reportFailure("startNewTask", startNewTask());
|
|
66653
66987
|
} else if (message3.type === "setMode") {
|
|
66654
|
-
|
|
66988
|
+
reportFailure("handleSetMode", handleSetMode(message3.modeId));
|
|
66655
66989
|
} else if (message3.type === "setMaxIterations") {
|
|
66656
66990
|
void configManager.save("user", { maxIterations: message3.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66657
66991
|
} else if (message3.type === "setProgrammingProfile") {
|
|
@@ -66679,7 +67013,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66679
67013
|
}
|
|
66680
67014
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66681
67015
|
} else if (message3.type === "setToolTimeoutFor") {
|
|
66682
|
-
|
|
67016
|
+
reportFailure("handleSetToolTimeoutFor", handleSetToolTimeoutFor(message3.name, message3.seconds));
|
|
66683
67017
|
} else if (message3.type === "setToolTimeout") {
|
|
66684
67018
|
void configManager.save("user", {
|
|
66685
67019
|
tools: message3.seconds === void 0 ? {} : { timeoutSeconds: message3.seconds }
|
|
@@ -66701,73 +67035,73 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66701
67035
|
}
|
|
66702
67036
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66703
67037
|
} else if (message3.type === "setAutoApprove") {
|
|
66704
|
-
|
|
67038
|
+
reportFailure("handleSetAutoApprove", handleSetAutoApprove(message3.group, message3.enabled));
|
|
66705
67039
|
} else if (message3.type === "revokeAllowedTool") {
|
|
66706
|
-
|
|
67040
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66707
67041
|
...cachedApprovals,
|
|
66708
67042
|
allowedTools: removeFromAllowlist(message3.toolName, cachedApprovals.allowedTools ?? [])
|
|
66709
|
-
});
|
|
67043
|
+
}));
|
|
66710
67044
|
} else if (message3.type === "revokeAllowedCommand") {
|
|
66711
|
-
|
|
67045
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66712
67046
|
...cachedApprovals,
|
|
66713
67047
|
allowedCommands: removeFromAllowlist(message3.command, cachedApprovals.allowedCommands ?? [])
|
|
66714
|
-
});
|
|
67048
|
+
}));
|
|
66715
67049
|
} else if (message3.type === "requestMcp") {
|
|
66716
|
-
|
|
67050
|
+
reportFailure("handleRequestMcp", handleRequestMcp());
|
|
66717
67051
|
} else if (message3.type === "saveMcpServers") {
|
|
66718
|
-
|
|
67052
|
+
reportFailure("handleSaveMcpServers", handleSaveMcpServers(message3.json));
|
|
66719
67053
|
} else if (message3.type === "saveMcpServer") {
|
|
66720
|
-
|
|
67054
|
+
reportFailure("handleSaveMcpServer", handleSaveMcpServer(message3.name, message3.previousName, message3.config));
|
|
66721
67055
|
} else if (message3.type === "duplicateMcpServer") {
|
|
66722
|
-
|
|
67056
|
+
reportFailure("handleDuplicateMcpServer", handleDuplicateMcpServer(message3.name));
|
|
66723
67057
|
} else if (message3.type === "deleteMcpServer") {
|
|
66724
|
-
|
|
67058
|
+
reportFailure("handleDeleteMcpServer", handleDeleteMcpServer(message3.name));
|
|
66725
67059
|
} else if (message3.type === "browseForPath") {
|
|
66726
|
-
|
|
67060
|
+
reportFailure("handleBrowseForPath", handleBrowseForPath(message3.purpose, message3.kind, message3.extensions));
|
|
66727
67061
|
} else if (message3.type === "probePythonEnv") {
|
|
66728
|
-
|
|
67062
|
+
reportFailure("handleProbePythonEnv", handleProbePythonEnv(message3.venvDir, message3.script));
|
|
66729
67063
|
} else if (message3.type === "connectMcpServer") {
|
|
66730
67064
|
void mcp.connectServer(message3.name);
|
|
66731
67065
|
} else if (message3.type === "restartMcpServer") {
|
|
66732
67066
|
void mcp.restart(message3.name);
|
|
66733
67067
|
} else if (message3.type === "setMcpServerEnabled") {
|
|
66734
|
-
|
|
67068
|
+
reportFailure("updateMcpServer", updateMcpServer(message3.name, (entry) => ({
|
|
66735
67069
|
...entry,
|
|
66736
67070
|
disabled: !message3.enabled
|
|
66737
|
-
})).then(() => postMcp());
|
|
67071
|
+
})).then(() => postMcp()));
|
|
66738
67072
|
} else if (message3.type === "setMcpToolTimeout") {
|
|
66739
|
-
|
|
67073
|
+
reportFailure("handleSetToolTimeout", handleSetToolTimeout(message3.server, message3.tool, message3.seconds));
|
|
66740
67074
|
} else if (message3.type === "setMcpToolPermission") {
|
|
66741
|
-
|
|
67075
|
+
reportFailure("handleSetToolPermission", handleSetToolPermission(message3.server, message3.tool, message3.permission));
|
|
66742
67076
|
} else if (message3.type === "requestSearch") {
|
|
66743
|
-
|
|
66744
|
-
|
|
67077
|
+
reportFailure("postSearch", postSearch());
|
|
67078
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66745
67079
|
post({ type: "searchLog", entries: [...searchLog.list()] });
|
|
66746
67080
|
} else if (message3.type === "saveSearchConnection") {
|
|
66747
|
-
|
|
67081
|
+
reportFailure("handleSaveSearchConnection", handleSaveSearchConnection(message3.connection));
|
|
66748
67082
|
} else if (message3.type === "deleteSearchConnection") {
|
|
66749
|
-
|
|
67083
|
+
reportFailure("handleDeleteSearchConnection", handleDeleteSearchConnection(message3.id));
|
|
66750
67084
|
} else if (message3.type === "setActiveSearchConnection") {
|
|
66751
67085
|
void (message3.forProject === true ? configManager.saveForWorkspace({ activeVectorStoreId: message3.id }) : configManager.save("user", { activeVectorStoreId: message3.id })).then(async () => {
|
|
66752
67086
|
await postSearch();
|
|
66753
67087
|
await postProjectSettings();
|
|
66754
67088
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66755
67089
|
} else if (message3.type === "requestProjectSettings") {
|
|
66756
|
-
|
|
67090
|
+
reportFailure("postProjectSettings", postProjectSettings());
|
|
66757
67091
|
} else if (message3.type === "clearProjectSettings") {
|
|
66758
|
-
|
|
67092
|
+
reportFailure("handleClearProjectSettings", handleClearProjectSettings());
|
|
66759
67093
|
} else if (message3.type === "requestSearchIndexes") {
|
|
66760
|
-
|
|
67094
|
+
reportFailure("handleRequestSearchIndexes", handleRequestSearchIndexes(message3.connection));
|
|
66761
67095
|
} else if (message3.type === "testSearchConnection") {
|
|
66762
|
-
|
|
67096
|
+
reportFailure("handleTestSearchConnection", handleTestSearchConnection(message3.connection));
|
|
66763
67097
|
} else if (message3.type === "syncVectorStore") {
|
|
66764
|
-
|
|
67098
|
+
reportFailure("handleSyncVectorStore", handleSyncVectorStore(message3.fromId));
|
|
66765
67099
|
} else if (message3.type === "clearDocsIndex") {
|
|
66766
|
-
|
|
67100
|
+
reportFailure("handleClearDocsIndex", handleClearDocsIndex(message3.kind));
|
|
66767
67101
|
} else if (message3.type === "clearCodebaseIndex") {
|
|
66768
|
-
|
|
67102
|
+
reportFailure("handleClearCodebaseIndex", handleClearCodebaseIndex());
|
|
66769
67103
|
} else if (message3.type === "openStandingSkill") {
|
|
66770
|
-
|
|
67104
|
+
reportFailure("handleOpenStandingSkill", handleOpenStandingSkill());
|
|
66771
67105
|
} else if (message3.type === "setOffice") {
|
|
66772
67106
|
void configManager.load().then(async () => {
|
|
66773
67107
|
await configManager.save("user", {
|
|
@@ -66781,70 +67115,80 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66781
67115
|
}
|
|
66782
67116
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66783
67117
|
} else if (message3.type === "indexDocs") {
|
|
66784
|
-
|
|
67118
|
+
reportFailure("handleIndexDocs", handleIndexDocs(message3.kind));
|
|
66785
67119
|
} else if (message3.type === "runSearchProbe") {
|
|
66786
|
-
|
|
67120
|
+
reportFailure("handleSearchProbe", handleSearchProbe(message3.query, message3.target));
|
|
66787
67121
|
} else if (message3.type === "clearSearchLog") {
|
|
66788
67122
|
searchLog.clear();
|
|
66789
67123
|
} else if (message3.type === "setDispatcher") {
|
|
66790
|
-
|
|
66791
|
-
|
|
67124
|
+
reportFailure("saveRetrieval", saveRetrieval({ dispatcher: message3.enabled }).then(() => {
|
|
67125
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66792
67126
|
if (message3.enabled)
|
|
66793
67127
|
scheduleDocsReindex("dispatcher enabled");
|
|
66794
|
-
})
|
|
67128
|
+
}));
|
|
66795
67129
|
} else if (message3.type === "setSkillRetrieval") {
|
|
66796
|
-
|
|
66797
|
-
|
|
67130
|
+
reportFailure("saveRetrieval", saveRetrieval({ skills: message3.enabled }).then(() => {
|
|
67131
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66798
67132
|
if (message3.enabled)
|
|
66799
67133
|
scheduleDocsReindex("skill retrieval enabled");
|
|
66800
|
-
})
|
|
67134
|
+
}));
|
|
66801
67135
|
} else if (message3.type === "startIndexing") {
|
|
66802
|
-
|
|
67136
|
+
reportFailure("handleStartIndexing", handleStartIndexing());
|
|
66803
67137
|
} else if (message3.type === "attachTeamAlias") {
|
|
66804
|
-
|
|
67138
|
+
reportFailure("handleAttachTeamAlias", handleAttachTeamAlias());
|
|
66805
67139
|
} else if (message3.type === "publishTeamSkills") {
|
|
66806
|
-
|
|
67140
|
+
reportFailure("handlePublishTeamSkills", handlePublishTeamSkills());
|
|
66807
67141
|
} else if (message3.type === "syncMail") {
|
|
66808
|
-
|
|
67142
|
+
reportFailure("runMailSync", runMailSync("requested"));
|
|
66809
67143
|
} else if (message3.type === "pruneMail") {
|
|
66810
|
-
|
|
67144
|
+
reportFailure("handlePruneMail", handlePruneMail());
|
|
66811
67145
|
} else if (message3.type === "requestOutlookFolders") {
|
|
66812
|
-
|
|
67146
|
+
reportFailure("handleRequestOutlookFolders", handleRequestOutlookFolders(message3.depth, message3.force === true));
|
|
66813
67147
|
} else if (message3.type === "validateMailFolder") {
|
|
66814
|
-
|
|
67148
|
+
reportFailure("handleValidateMailFolder", handleValidateMailFolder(message3.path));
|
|
66815
67149
|
} else if (message3.type === "requestMailStatus") {
|
|
66816
|
-
|
|
67150
|
+
reportFailure("loadSettings", loadSettings().then((config2) => {
|
|
66817
67151
|
reconcileMailTimer(config2);
|
|
66818
67152
|
reconcileDatasetTimers(config2);
|
|
66819
67153
|
return postMailStatus();
|
|
66820
|
-
});
|
|
67154
|
+
}));
|
|
66821
67155
|
} else if (message3.type === "saveMailSettings") {
|
|
66822
|
-
|
|
67156
|
+
reportFailure("handleSaveMailSettings", handleSaveMailSettings({
|
|
66823
67157
|
enabled: message3.enabled,
|
|
66824
67158
|
folders: message3.folders,
|
|
66825
67159
|
includeSubfolders: message3.includeSubfolders,
|
|
66826
67160
|
syncMinutes: message3.syncMinutes,
|
|
66827
67161
|
retentionMonths: message3.retentionMonths,
|
|
66828
67162
|
...message3.storeId !== void 0 ? { storeId: message3.storeId } : {}
|
|
66829
|
-
});
|
|
67163
|
+
}));
|
|
66830
67164
|
} else if (message3.type === "clearTeamSkills") {
|
|
66831
|
-
|
|
67165
|
+
reportFailure("handleClearTeamSkills", handleClearTeamSkills());
|
|
66832
67166
|
} else if (message3.type === "refreshMail") {
|
|
66833
|
-
|
|
67167
|
+
reportFailure("handleRefreshMail", handleRefreshMail(message3.days));
|
|
66834
67168
|
} else if (message3.type === "requestDatasetStatus") {
|
|
66835
|
-
|
|
67169
|
+
reportFailure("postDatasetStatus", postDatasetStatus());
|
|
66836
67170
|
} else if (message3.type === "saveDataset") {
|
|
66837
|
-
|
|
67171
|
+
reportFailure("handleSaveDataset", handleSaveDataset(message3.dataset));
|
|
66838
67172
|
} else if (message3.type === "deleteDataset") {
|
|
66839
|
-
|
|
67173
|
+
reportFailure("handleDeleteDataset", handleDeleteDataset(message3.id));
|
|
66840
67174
|
} else if (message3.type === "syncDataset") {
|
|
66841
|
-
|
|
67175
|
+
reportFailure("runDatasetSync", runDatasetSync(message3.id, "manual"));
|
|
66842
67176
|
} else if (message3.type === "clearDataset") {
|
|
66843
|
-
|
|
67177
|
+
reportFailure("handleClearDataset", handleClearDataset(message3.id, message3.resync === true));
|
|
66844
67178
|
} else if (message3.type === "clearMailIndex") {
|
|
66845
|
-
|
|
67179
|
+
reportFailure("handleClearMailIndex", handleClearMailIndex(message3.resync === true));
|
|
67180
|
+
} else if (message3.type === "requestS3") {
|
|
67181
|
+
reportFailure("postS3", postS3());
|
|
67182
|
+
} else if (message3.type === "saveS3Connection") {
|
|
67183
|
+
reportFailure("handleSaveS3Connection", handleSaveS3Connection(message3.connection, message3.secret, message3.sessionToken));
|
|
67184
|
+
} else if (message3.type === "deleteS3Connection") {
|
|
67185
|
+
reportFailure("handleDeleteS3Connection", handleDeleteS3Connection(message3.id));
|
|
67186
|
+
} else if (message3.type === "saveS3Mirrors") {
|
|
67187
|
+
reportFailure("handleSaveS3Mirrors", handleSaveS3Mirrors(message3.kind, message3.mirrors));
|
|
67188
|
+
} else if (message3.type === "syncS3") {
|
|
67189
|
+
reportFailure("handleSyncS3", handleSyncS3(message3.kind));
|
|
66846
67190
|
} else if (message3.type === "saveSkillsAlias") {
|
|
66847
|
-
|
|
67191
|
+
reportFailure("handleSaveSkillsAlias", handleSaveSkillsAlias(message3.aliases));
|
|
66848
67192
|
} else if (message3.type === "cancelIndexing") {
|
|
66849
67193
|
if (message3.kind === void 0) {
|
|
66850
67194
|
indexingAbort?.abort();
|
|
@@ -66856,23 +67200,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66856
67200
|
indexingAborts.get(message3.kind)?.abort();
|
|
66857
67201
|
}
|
|
66858
67202
|
} else if (message3.type === "saveEmbedder") {
|
|
66859
|
-
|
|
67203
|
+
reportFailure("handleSaveEmbedder", handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases));
|
|
66860
67204
|
} else if (message3.type === "requestEmbedderModels") {
|
|
66861
|
-
|
|
67205
|
+
reportFailure("handleRequestEmbedderModels", handleRequestEmbedderModels(message3.profileId));
|
|
66862
67206
|
} else if (message3.type === "openWalkthrough") {
|
|
66863
67207
|
void ui.openWalkthrough?.();
|
|
66864
67208
|
} else if (message3.type === "requestTools") {
|
|
66865
|
-
|
|
67209
|
+
reportFailure("postTools", postTools());
|
|
66866
67210
|
} else if (message3.type === "requestSchedules") {
|
|
66867
|
-
|
|
67211
|
+
reportFailure("postSchedules", postSchedules());
|
|
66868
67212
|
} else if (message3.type === "saveSchedule") {
|
|
66869
|
-
|
|
67213
|
+
reportFailure("handleSaveSchedule", handleSaveSchedule(message3.schedule));
|
|
66870
67214
|
} else if (message3.type === "duplicateSchedule") {
|
|
66871
|
-
|
|
67215
|
+
reportFailure("handleDuplicateSchedule", handleDuplicateSchedule(message3.id));
|
|
66872
67216
|
} else if (message3.type === "deleteSchedule") {
|
|
66873
|
-
|
|
67217
|
+
reportFailure("handleDeleteSchedule", handleDeleteSchedule(message3.id));
|
|
66874
67218
|
} else if (message3.type === "setScheduleEnabled") {
|
|
66875
|
-
|
|
67219
|
+
reportFailure("handleSetScheduleEnabled", handleSetScheduleEnabled(message3.id, message3.enabled));
|
|
66876
67220
|
} else if (message3.type === "setTaskExpertLimits") {
|
|
66877
67221
|
const next = message3.maxSpendUsd === void 0 && message3.maxConsultations === void 0 ? void 0 : {
|
|
66878
67222
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
@@ -66902,7 +67246,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66902
67246
|
await postExpert({ redetect: false });
|
|
66903
67247
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66904
67248
|
} else if (message3.type === "measureExpertCost") {
|
|
66905
|
-
|
|
67249
|
+
reportFailure("handleMeasureExpertCost", handleMeasureExpertCost());
|
|
66906
67250
|
} else if (message3.type === "clearExpertPricing") {
|
|
66907
67251
|
void configManager.load().then(async ({ config: config2 }) => {
|
|
66908
67252
|
const expert = { ...config2.expert };
|
|
@@ -66912,23 +67256,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66912
67256
|
await postExpert({ redetect: false });
|
|
66913
67257
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66914
67258
|
} else if (message3.type === "assessJunior") {
|
|
66915
|
-
|
|
67259
|
+
reportFailure("handleAssessJunior", handleAssessJunior(message3.profileId));
|
|
66916
67260
|
} else if (message3.type === "clearAssessment") {
|
|
66917
|
-
|
|
67261
|
+
reportFailure("handleClearAssessment", handleClearAssessment(message3.model, message3.profileLabel));
|
|
66918
67262
|
} else if (message3.type === "restartScheduler") {
|
|
66919
67263
|
restartScheduleTimer();
|
|
66920
67264
|
logger.info("schedule timer restarted by the user");
|
|
66921
|
-
|
|
67265
|
+
reportFailure("postSchedules", postSchedules());
|
|
66922
67266
|
} else if (message3.type === "deleteScheduleRun") {
|
|
66923
|
-
|
|
67267
|
+
reportFailure("handleDeleteScheduleRun", handleDeleteScheduleRun(message3.id, message3.at));
|
|
66924
67268
|
} else if (message3.type === "clearScheduleRuns") {
|
|
66925
|
-
|
|
67269
|
+
reportFailure("handleClearScheduleRuns", handleClearScheduleRuns(message3.id));
|
|
66926
67270
|
} else if (message3.type === "openScheduleRun") {
|
|
66927
|
-
|
|
67271
|
+
reportFailure("openRunTranscript", openRunTranscript(message3.taskId, message3.title));
|
|
66928
67272
|
} else if (message3.type === "runScheduleNow") {
|
|
66929
|
-
|
|
67273
|
+
reportFailure("runSchedule", runSchedule(message3.id, "manual"));
|
|
66930
67274
|
} else if (message3.type === "requestSkills") {
|
|
66931
|
-
|
|
67275
|
+
reportFailure("postSkills", postSkills());
|
|
66932
67276
|
} else if (message3.type === "saveSkillDirs") {
|
|
66933
67277
|
void configManager.save("user", {
|
|
66934
67278
|
skills: {
|
|
@@ -66937,32 +67281,32 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66937
67281
|
}
|
|
66938
67282
|
}).then(() => postSkills()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66939
67283
|
} else if (message3.type === "openManagedFile") {
|
|
66940
|
-
|
|
67284
|
+
reportFailure("handleOpenManagedFile", handleOpenManagedFile(message3.path));
|
|
66941
67285
|
} else if (message3.type === "deletePythonTool") {
|
|
66942
|
-
|
|
67286
|
+
reportFailure("handleDeletePythonTool", handleDeletePythonTool(message3.name));
|
|
66943
67287
|
} else if (message3.type === "approvePythonTool") {
|
|
66944
|
-
|
|
67288
|
+
reportFailure("handleApprovePythonTool", handleApprovePythonTool(message3.name));
|
|
66945
67289
|
} else if (message3.type === "deleteSkillFile") {
|
|
66946
|
-
|
|
67290
|
+
reportFailure("handleDeleteSkillFile", handleDeleteSkillFile(message3.name));
|
|
66947
67291
|
} else if (message3.type === "requestPython") {
|
|
66948
|
-
|
|
67292
|
+
reportFailure("postPython", postPython());
|
|
66949
67293
|
} else if (message3.type === "setPython") {
|
|
66950
|
-
|
|
67294
|
+
reportFailure("handleSetPython", handleSetPython(message3));
|
|
66951
67295
|
} else if (message3.type === "requestNetwork") {
|
|
66952
|
-
|
|
67296
|
+
reportFailure("postNetwork", postNetwork());
|
|
66953
67297
|
} else if (message3.type === "saveNetwork") {
|
|
66954
|
-
|
|
67298
|
+
reportFailure("handleSaveNetwork", handleSaveNetwork(message3.settings));
|
|
66955
67299
|
} else if (message3.type === "requestExpert") {
|
|
66956
|
-
|
|
67300
|
+
reportFailure("postExpert", postExpert());
|
|
66957
67301
|
} else if (message3.type === "setPlan") {
|
|
66958
|
-
|
|
67302
|
+
reportFailure("applyPlan", applyPlan(message3.plan));
|
|
66959
67303
|
} else if (message3.type === "requestPlan") {
|
|
66960
67304
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
66961
67305
|
postPlanProgress();
|
|
66962
67306
|
} else if (message3.type === "requestPlanProgress") {
|
|
66963
67307
|
postPlanProgress();
|
|
66964
67308
|
} else if (message3.type === "requestAgents") {
|
|
66965
|
-
|
|
67309
|
+
reportFailure("postAgents", postAgents());
|
|
66966
67310
|
} else if (message3.type === "setAgentRole") {
|
|
66967
67311
|
const assignment = message3.assignment;
|
|
66968
67312
|
const role = message3.role;
|
|
@@ -66970,7 +67314,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66970
67314
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66971
67315
|
return;
|
|
66972
67316
|
}
|
|
66973
|
-
|
|
67317
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66974
67318
|
const roles = { ...current.roles ?? {} };
|
|
66975
67319
|
if (assignment === void 0)
|
|
66976
67320
|
delete roles[role];
|
|
@@ -66982,7 +67326,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66982
67326
|
};
|
|
66983
67327
|
}
|
|
66984
67328
|
return { ...current, roles };
|
|
66985
|
-
});
|
|
67329
|
+
}));
|
|
66986
67330
|
} else if (message3.type === "setAgentPrompt") {
|
|
66987
67331
|
const role = message3.role;
|
|
66988
67332
|
const prompt = message3.prompt;
|
|
@@ -66990,7 +67334,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66990
67334
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66991
67335
|
return;
|
|
66992
67336
|
}
|
|
66993
|
-
|
|
67337
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66994
67338
|
const roles = { ...current.roles ?? {} };
|
|
66995
67339
|
const existing = roles[role];
|
|
66996
67340
|
if (prompt === void 0 || prompt === defaultPromptFor(role)) {
|
|
@@ -67003,31 +67347,31 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67003
67347
|
roles[role] = { ...existing ?? { kind: "profile" }, prompt };
|
|
67004
67348
|
}
|
|
67005
67349
|
return { ...current, roles };
|
|
67006
|
-
});
|
|
67350
|
+
}));
|
|
67007
67351
|
} else if (message3.type === "setAgentBudget") {
|
|
67008
67352
|
const matters = message3.matters;
|
|
67009
|
-
|
|
67353
|
+
reportFailure("saveAgents", saveAgents((current) => ({ ...current, budgetMatters: matters })));
|
|
67010
67354
|
} else if (message3.type === "setTeamGuidance") {
|
|
67011
67355
|
const guidance = message3.guidance;
|
|
67012
|
-
|
|
67356
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67013
67357
|
if (guidance === void 0 || guidance.trim().length === 0 || guidance === DEFAULT_TEAM_GUIDANCE) {
|
|
67014
67358
|
const rest = { ...current };
|
|
67015
67359
|
delete rest.teamGuidance;
|
|
67016
67360
|
return rest;
|
|
67017
67361
|
}
|
|
67018
67362
|
return { ...current, teamGuidance: guidance };
|
|
67019
|
-
});
|
|
67363
|
+
}));
|
|
67020
67364
|
} else if (message3.type === "saveCustomRole") {
|
|
67021
|
-
|
|
67365
|
+
reportFailure("handleSaveCustomRole", handleSaveCustomRole(message3));
|
|
67022
67366
|
} else if (message3.type === "deleteCustomRole") {
|
|
67023
|
-
|
|
67367
|
+
reportFailure("handleDeleteCustomRole", handleDeleteCustomRole(message3.id));
|
|
67024
67368
|
} else if (message3.type === "setRoleThinking") {
|
|
67025
67369
|
const role = message3.role;
|
|
67026
67370
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67027
67371
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67028
67372
|
return;
|
|
67029
67373
|
}
|
|
67030
|
-
|
|
67374
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67031
67375
|
const roles = { ...current.roles ?? {} };
|
|
67032
67376
|
const existing = roles[role] ?? { kind: "profile" };
|
|
67033
67377
|
if (message3.level === void 0) {
|
|
@@ -67038,79 +67382,79 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67038
67382
|
roles[role] = { ...existing, thinking: message3.level };
|
|
67039
67383
|
}
|
|
67040
67384
|
return { ...current, roles };
|
|
67041
|
-
});
|
|
67385
|
+
}));
|
|
67042
67386
|
} else if (message3.type === "setRoleEnabled") {
|
|
67043
67387
|
const role = message3.role;
|
|
67044
67388
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67045
67389
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67046
67390
|
return;
|
|
67047
67391
|
}
|
|
67048
|
-
|
|
67392
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67049
67393
|
const roles = { ...current.roles ?? {} };
|
|
67050
67394
|
roles[role] = {
|
|
67051
67395
|
...roles[role] ?? { kind: "profile" },
|
|
67052
67396
|
enabled: message3.enabled
|
|
67053
67397
|
};
|
|
67054
67398
|
return { ...current, roles };
|
|
67055
|
-
});
|
|
67399
|
+
}));
|
|
67056
67400
|
} else if (message3.type === "setRoleWrite") {
|
|
67057
67401
|
const role = message3.role;
|
|
67058
67402
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67059
67403
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67060
67404
|
return;
|
|
67061
67405
|
}
|
|
67062
|
-
|
|
67406
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67063
67407
|
const roles = { ...current.roles ?? {} };
|
|
67064
67408
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, write: message3.canWrite };
|
|
67065
67409
|
return { ...current, roles };
|
|
67066
|
-
});
|
|
67410
|
+
}));
|
|
67067
67411
|
} else if (message3.type === "setRoleTools") {
|
|
67068
67412
|
const role = message3.role;
|
|
67069
67413
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67070
67414
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67071
67415
|
return;
|
|
67072
67416
|
}
|
|
67073
|
-
|
|
67417
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67074
67418
|
const roles = { ...current.roles ?? {} };
|
|
67075
67419
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, tools: message3.usesTools };
|
|
67076
67420
|
return { ...current, roles };
|
|
67077
|
-
});
|
|
67421
|
+
}));
|
|
67078
67422
|
} else if (message3.type === "setAgentColor") {
|
|
67079
67423
|
const role = message3.role;
|
|
67080
67424
|
const color = message3.color;
|
|
67081
|
-
if (!
|
|
67425
|
+
if (!isColourableAgent(role, cachedAgentDefinitions)) {
|
|
67082
67426
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67083
67427
|
return;
|
|
67084
67428
|
}
|
|
67085
|
-
|
|
67429
|
+
reportFailure("saveAgents", saveAgents((current) => ({
|
|
67086
67430
|
...current,
|
|
67087
67431
|
colors: { ...current.colors ?? {}, [role]: color }
|
|
67088
|
-
}));
|
|
67432
|
+
})));
|
|
67089
67433
|
} else if (message3.type === "setExpert") {
|
|
67090
|
-
|
|
67434
|
+
reportFailure("handleSetExpert", handleSetExpert(message3.enabled, message3.path, message3.model, {
|
|
67091
67435
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
67092
67436
|
...message3.maxConsultations !== void 0 ? { maxConsultations: message3.maxConsultations } : {},
|
|
67093
67437
|
...message3.profileId !== void 0 ? { profileId: message3.profileId } : {}
|
|
67094
|
-
});
|
|
67438
|
+
}));
|
|
67095
67439
|
} else if (message3.type === "requestProfiles") {
|
|
67096
|
-
|
|
67097
|
-
|
|
67440
|
+
reportFailure("postProfiles", postProfiles());
|
|
67441
|
+
reportFailure("postCapabilities", postCapabilities());
|
|
67098
67442
|
} else if (message3.type === "saveProfile") {
|
|
67099
|
-
|
|
67443
|
+
reportFailure("handleSaveProfile", handleSaveProfile(message3.profile));
|
|
67100
67444
|
} else if (message3.type === "requestModels") {
|
|
67101
|
-
|
|
67445
|
+
reportFailure("handleRequestModels", handleRequestModels(message3.profile));
|
|
67102
67446
|
} else if (message3.type === "testConnection") {
|
|
67103
|
-
|
|
67447
|
+
reportFailure("handleTestConnection", handleTestConnection(message3.profile));
|
|
67104
67448
|
} else if (message3.type === "duplicateProfile") {
|
|
67105
|
-
|
|
67449
|
+
reportFailure("handleDuplicateProfile", handleDuplicateProfile(message3.id));
|
|
67106
67450
|
} else if (message3.type === "deleteProfile") {
|
|
67107
|
-
|
|
67451
|
+
reportFailure("handleDeleteProfile", handleDeleteProfile(message3.id));
|
|
67108
67452
|
} else if (message3.type === "setActiveProfile") {
|
|
67109
|
-
|
|
67453
|
+
reportFailure("handleSetActiveProfile", handleSetActiveProfile(message3.id, message3.forProject));
|
|
67110
67454
|
} else if (message3.type === "exportConfig") {
|
|
67111
|
-
|
|
67455
|
+
reportFailure("handleExportConfig", handleExportConfig());
|
|
67112
67456
|
} else if (message3.type === "importConfig") {
|
|
67113
|
-
|
|
67457
|
+
reportFailure("handleImportConfig", handleImportConfig());
|
|
67114
67458
|
}
|
|
67115
67459
|
});
|
|
67116
67460
|
void (async () => {
|
|
@@ -67625,6 +67969,8 @@ ${contents}
|
|
|
67625
67969
|
}
|
|
67626
67970
|
await postTasks();
|
|
67627
67971
|
await postSettings();
|
|
67972
|
+
await postProfiles();
|
|
67973
|
+
await postS3();
|
|
67628
67974
|
await postSchedules();
|
|
67629
67975
|
} catch (error51) {
|
|
67630
67976
|
logger.warn(`Could not resync the view: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -67687,6 +68033,10 @@ function deriveTitle(messages) {
|
|
|
67687
68033
|
return `${cut.trimEnd()}\u2026`;
|
|
67688
68034
|
}
|
|
67689
68035
|
|
|
68036
|
+
// ../../packages/core/dist/display/size.js
|
|
68037
|
+
var DISPLAY_SIZES = ["small", "medium", "large", "full"];
|
|
68038
|
+
var DISPLAY_SIZE_DESCRIPTION = "How wide to draw it: small (an aside), medium (the ordinary case), large (worth studying), or full (the whole width available). Use a smaller one when the user says it is too big, and small or medium for something beside a paragraph of text rather than the point of the answer.";
|
|
68039
|
+
|
|
67690
68040
|
// ../../packages/core/dist/charts/types.js
|
|
67691
68041
|
var CHART_TYPES = ["bar", "stackedBar", "groupedBar", "line", "multiLine", "pie"];
|
|
67692
68042
|
var MAX_CATEGORIES = 200;
|
|
@@ -67709,6 +68059,8 @@ var chartSpecSchema = external_exports.object({
|
|
|
67709
68059
|
title: external_exports.string().max(200).optional(),
|
|
67710
68060
|
categories: external_exports.array(external_exports.string()).min(1).max(MAX_CATEGORIES).describe("The x axis, or the pie slice labels. One per value in every series."),
|
|
67711
68061
|
series: external_exports.array(chartSeriesSchema).min(1).max(MAX_SERIES),
|
|
68062
|
+
/** See `display/size.ts` — the same field and the same words as a diagram's. */
|
|
68063
|
+
size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
|
|
67712
68064
|
xLabel: external_exports.string().max(80).optional(),
|
|
67713
68065
|
yLabel: external_exports.string().max(80).optional(),
|
|
67714
68066
|
note: external_exports.string().max(500).optional().describe("A line under the chart. Say where the numbers came from, and what they exclude.")
|
|
@@ -67829,6 +68181,8 @@ var diagramSpecSchema = external_exports.object({
|
|
|
67829
68181
|
title: external_exports.string().max(120).optional(),
|
|
67830
68182
|
textSize: external_exports.enum(TEXT_SIZES).optional().describe("The size for every box that does not set its own. Use it when the user says the diagram is too small or too large to read comfortably."),
|
|
67831
68183
|
legend: external_exports.array(diagramLegendSchema).max(DIAGRAM_MAX_LEGEND).optional().describe("A key under the diagram. Give an entry only where the meaning is not obvious from the label \u2014 a colour that stands for something, a shape used in a particular way. Explain the diagram, not the palette."),
|
|
68184
|
+
/** See `display/size.ts` — the same field and the same words as a chart's. */
|
|
68185
|
+
size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
|
|
67832
68186
|
direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
|
|
67833
68187
|
nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
|
|
67834
68188
|
edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
|
|
@@ -67970,7 +68324,7 @@ function toolCallSummary(call, outcome) {
|
|
|
67970
68324
|
function consultationFromToolCall(name, rawArguments) {
|
|
67971
68325
|
const call = throughDispatch(name, rawArguments);
|
|
67972
68326
|
if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
|
|
67973
|
-
return "
|
|
68327
|
+
return "claude";
|
|
67974
68328
|
if (call.name !== "ask_agent")
|
|
67975
68329
|
return void 0;
|
|
67976
68330
|
const decoded = call.args;
|
|
@@ -69538,6 +69892,570 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
69538
69892
|
};
|
|
69539
69893
|
}
|
|
69540
69894
|
|
|
69895
|
+
// ../../packages/core/dist/s3/sigv4.js
|
|
69896
|
+
import { createHash as createHash4, createHmac } from "node:crypto";
|
|
69897
|
+
var EMPTY_PAYLOAD_SHA256 = createHash4("sha256").update("").digest("hex");
|
|
69898
|
+
function encodeSegment(segment) {
|
|
69899
|
+
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
69900
|
+
}
|
|
69901
|
+
function canonicalPath(pathname) {
|
|
69902
|
+
if (pathname === "" || pathname === "/")
|
|
69903
|
+
return "/";
|
|
69904
|
+
return pathname.split("/").map((segment) => {
|
|
69905
|
+
let raw = segment;
|
|
69906
|
+
try {
|
|
69907
|
+
raw = decodeURIComponent(segment);
|
|
69908
|
+
} catch {
|
|
69909
|
+
}
|
|
69910
|
+
return encodeSegment(raw);
|
|
69911
|
+
}).join("/");
|
|
69912
|
+
}
|
|
69913
|
+
function canonicalQuery(search) {
|
|
69914
|
+
const parameters = [...new URLSearchParams(search).entries()].map(([name, value]) => [encodeSegment(name), encodeSegment(value)]).sort((a, b) => a[0] === b[0] ? a[1].localeCompare(b[1]) : a[0].localeCompare(b[0]));
|
|
69915
|
+
return parameters.map(([name, value]) => `${name}=${value}`).join("&");
|
|
69916
|
+
}
|
|
69917
|
+
function amzDate(now) {
|
|
69918
|
+
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
69919
|
+
}
|
|
69920
|
+
function signingKey(secretAccessKey, date5, region, service) {
|
|
69921
|
+
const dateKey = createHmac("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
69922
|
+
const regionKey = createHmac("sha256", dateKey).update(region).digest();
|
|
69923
|
+
const serviceKey = createHmac("sha256", regionKey).update(service).digest();
|
|
69924
|
+
return createHmac("sha256", serviceKey).update("aws4_request").digest();
|
|
69925
|
+
}
|
|
69926
|
+
function signRequest(input) {
|
|
69927
|
+
const service = input.service ?? "s3";
|
|
69928
|
+
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
69929
|
+
const timestamp = amzDate(now);
|
|
69930
|
+
const date5 = timestamp.slice(0, 8);
|
|
69931
|
+
const url2 = new URL(input.url);
|
|
69932
|
+
const body = input.body ?? Buffer.alloc(0);
|
|
69933
|
+
const payloadHash = createHash4("sha256").update(body).digest("hex");
|
|
69934
|
+
const headers = {
|
|
69935
|
+
...input.headers,
|
|
69936
|
+
host: url2.host,
|
|
69937
|
+
"x-amz-content-sha256": payloadHash,
|
|
69938
|
+
"x-amz-date": timestamp,
|
|
69939
|
+
...input.sessionToken !== void 0 ? { "x-amz-security-token": input.sessionToken } : {}
|
|
69940
|
+
};
|
|
69941
|
+
const canonicalHeaderEntries = Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value.trim().replace(/\s+/g, " ")]).sort((a, b) => a[0].localeCompare(b[0]));
|
|
69942
|
+
const signedHeaders = canonicalHeaderEntries.map(([name]) => name).join(";");
|
|
69943
|
+
const canonicalRequest = [
|
|
69944
|
+
input.method.toUpperCase(),
|
|
69945
|
+
canonicalPath(url2.pathname),
|
|
69946
|
+
canonicalQuery(url2.search),
|
|
69947
|
+
`${canonicalHeaderEntries.map(([name, value]) => `${name}:${value}`).join("\n")}
|
|
69948
|
+
`,
|
|
69949
|
+
signedHeaders,
|
|
69950
|
+
payloadHash
|
|
69951
|
+
].join("\n");
|
|
69952
|
+
const scope = `${date5}/${input.region}/${service}/aws4_request`;
|
|
69953
|
+
const stringToSign = [
|
|
69954
|
+
"AWS4-HMAC-SHA256",
|
|
69955
|
+
timestamp,
|
|
69956
|
+
scope,
|
|
69957
|
+
createHash4("sha256").update(canonicalRequest).digest("hex")
|
|
69958
|
+
].join("\n");
|
|
69959
|
+
const signature = createHmac("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
69960
|
+
return {
|
|
69961
|
+
headers: {
|
|
69962
|
+
...headers,
|
|
69963
|
+
Authorization: `AWS4-HMAC-SHA256 Credential=${input.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
69964
|
+
},
|
|
69965
|
+
canonicalRequest,
|
|
69966
|
+
stringToSign,
|
|
69967
|
+
signature
|
|
69968
|
+
};
|
|
69969
|
+
}
|
|
69970
|
+
|
|
69971
|
+
// ../../packages/core/dist/s3/client.js
|
|
69972
|
+
var S3Client = class {
|
|
69973
|
+
http;
|
|
69974
|
+
connection;
|
|
69975
|
+
tls;
|
|
69976
|
+
constructor(http, connection, tls2) {
|
|
69977
|
+
this.http = http;
|
|
69978
|
+
this.connection = connection;
|
|
69979
|
+
this.tls = tls2;
|
|
69980
|
+
}
|
|
69981
|
+
url(call) {
|
|
69982
|
+
const { bucket, region, endpoint, pathStyle } = this.connection;
|
|
69983
|
+
const origin = new URL(endpoint ?? `https://s3.${region}.amazonaws.com`);
|
|
69984
|
+
const key = call.key ?? "";
|
|
69985
|
+
const inPath = usesPathStyle(pathStyle, origin.host);
|
|
69986
|
+
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
69987
|
+
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
69988
|
+
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
69989
|
+
const path32 = key === "" ? "" : `/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
69990
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path32}`);
|
|
69991
|
+
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
69992
|
+
url2.searchParams.set(name, value);
|
|
69993
|
+
return url2.toString();
|
|
69994
|
+
}
|
|
69995
|
+
async send(call) {
|
|
69996
|
+
const url2 = this.url(call);
|
|
69997
|
+
const signed = signRequest({
|
|
69998
|
+
method: call.method,
|
|
69999
|
+
url: url2,
|
|
70000
|
+
headers: call.headers ?? {},
|
|
70001
|
+
...call.bodyBytes !== void 0 ? { body: Buffer.from(call.bodyBytes) } : {},
|
|
70002
|
+
region: this.connection.region,
|
|
70003
|
+
accessKeyId: this.connection.accessKeyId,
|
|
70004
|
+
secretAccessKey: this.connection.secretAccessKey,
|
|
70005
|
+
...this.connection.sessionToken !== void 0 ? { sessionToken: this.connection.sessionToken } : {}
|
|
70006
|
+
});
|
|
70007
|
+
let response;
|
|
70008
|
+
try {
|
|
70009
|
+
response = await this.http.request(url2, {
|
|
70010
|
+
method: call.method,
|
|
70011
|
+
headers: signed.headers,
|
|
70012
|
+
...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
|
|
70013
|
+
...call.signal !== void 0 ? { signal: call.signal } : {},
|
|
70014
|
+
...this.tls !== void 0 ? { tls: this.tls } : {}
|
|
70015
|
+
});
|
|
70016
|
+
} catch (error51) {
|
|
70017
|
+
throw new Error(`Could not reach ${new URL(url2).host}: ${describeTlsError(error51)}`, { cause: error51 });
|
|
70018
|
+
}
|
|
70019
|
+
const bytes = await readAll(response);
|
|
70020
|
+
return { status: response.status, text: bytes.toString("utf8"), bytes };
|
|
70021
|
+
}
|
|
70022
|
+
/**
|
|
70023
|
+
* Objects under a prefix.
|
|
70024
|
+
*
|
|
70025
|
+
* Follows the continuation token rather than stopping at the first page: a folder of 1,200 files
|
|
70026
|
+
* silently reported as 1,000 is the kind of wrong answer nobody thinks to check.
|
|
70027
|
+
*/
|
|
70028
|
+
async list(prefix, limit = 1e3, signal) {
|
|
70029
|
+
const found = [];
|
|
70030
|
+
let token;
|
|
70031
|
+
while (found.length < limit) {
|
|
70032
|
+
const query = {
|
|
70033
|
+
"list-type": "2",
|
|
70034
|
+
"max-keys": String(Math.min(1e3, limit - found.length))
|
|
70035
|
+
};
|
|
70036
|
+
if (prefix !== "")
|
|
70037
|
+
query["prefix"] = prefix;
|
|
70038
|
+
if (token !== void 0)
|
|
70039
|
+
query["continuation-token"] = token;
|
|
70040
|
+
const result = await this.send({
|
|
70041
|
+
method: "GET",
|
|
70042
|
+
query,
|
|
70043
|
+
...signal !== void 0 ? { signal } : {}
|
|
70044
|
+
});
|
|
70045
|
+
if (result.status !== 200)
|
|
70046
|
+
throw new Error(describeFailure(result.status, result.text));
|
|
70047
|
+
found.push(...parseListing(result.text));
|
|
70048
|
+
token = matchTag(result.text, "NextContinuationToken");
|
|
70049
|
+
if (token === void 0)
|
|
70050
|
+
break;
|
|
70051
|
+
}
|
|
70052
|
+
return found.slice(0, limit);
|
|
70053
|
+
}
|
|
70054
|
+
async get(key, signal) {
|
|
70055
|
+
const result = await this.send({
|
|
70056
|
+
method: "GET",
|
|
70057
|
+
key,
|
|
70058
|
+
...signal !== void 0 ? { signal } : {}
|
|
70059
|
+
});
|
|
70060
|
+
if (result.status !== 200)
|
|
70061
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
70062
|
+
return result.bytes;
|
|
70063
|
+
}
|
|
70064
|
+
async put(key, bytes, contentType2, signal) {
|
|
70065
|
+
const result = await this.send({
|
|
70066
|
+
method: "PUT",
|
|
70067
|
+
key,
|
|
70068
|
+
bodyBytes: bytes,
|
|
70069
|
+
...contentType2 !== void 0 ? { headers: { "content-type": contentType2 } } : {},
|
|
70070
|
+
...signal !== void 0 ? { signal } : {}
|
|
70071
|
+
});
|
|
70072
|
+
if (result.status !== 200 && result.status !== 204) {
|
|
70073
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
70074
|
+
}
|
|
70075
|
+
}
|
|
70076
|
+
};
|
|
70077
|
+
async function readAll(response) {
|
|
70078
|
+
if (response.body === null)
|
|
70079
|
+
return Buffer.from(await response.text(), "utf8");
|
|
70080
|
+
const reader = response.body.getReader();
|
|
70081
|
+
const chunks = [];
|
|
70082
|
+
for (; ; ) {
|
|
70083
|
+
const { done, value } = await reader.read();
|
|
70084
|
+
if (done)
|
|
70085
|
+
break;
|
|
70086
|
+
if (value !== void 0)
|
|
70087
|
+
chunks.push(value);
|
|
70088
|
+
}
|
|
70089
|
+
return Buffer.concat(chunks);
|
|
70090
|
+
}
|
|
70091
|
+
function describeFailure(status, body, key) {
|
|
70092
|
+
const code = matchTag(body, "Code");
|
|
70093
|
+
const message3 = matchTag(body, "Message");
|
|
70094
|
+
const what = key === void 0 ? "" : ` for "${key}"`;
|
|
70095
|
+
if (code === void 0)
|
|
70096
|
+
return `S3 request failed${what} with status ${String(status)}.`;
|
|
70097
|
+
return `S3 ${code}${what}: ${message3 ?? `status ${String(status)}`}`;
|
|
70098
|
+
}
|
|
70099
|
+
function matchTag(xml, tag) {
|
|
70100
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(xml);
|
|
70101
|
+
return match?.[1];
|
|
70102
|
+
}
|
|
70103
|
+
function parseListing(xml) {
|
|
70104
|
+
const objects = [];
|
|
70105
|
+
for (const block of xml.split("<Contents>").slice(1)) {
|
|
70106
|
+
const key = matchTag(block, "Key");
|
|
70107
|
+
if (key === void 0)
|
|
70108
|
+
continue;
|
|
70109
|
+
objects.push({
|
|
70110
|
+
key: decodeEntities3(key),
|
|
70111
|
+
size: Number(matchTag(block, "Size") ?? "0"),
|
|
70112
|
+
lastModified: matchTag(block, "LastModified") ?? ""
|
|
70113
|
+
});
|
|
70114
|
+
}
|
|
70115
|
+
return objects;
|
|
70116
|
+
}
|
|
70117
|
+
function decodeEntities3(value) {
|
|
70118
|
+
return value.replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", '"').replaceAll("'", String.fromCharCode(39)).replaceAll("&", "&");
|
|
70119
|
+
}
|
|
70120
|
+
function usesPathStyle(configured, host) {
|
|
70121
|
+
if (configured !== void 0)
|
|
70122
|
+
return configured;
|
|
70123
|
+
return !/(^|\.)amazonaws\.com$/i.test(host);
|
|
70124
|
+
}
|
|
70125
|
+
|
|
70126
|
+
// ../../packages/core/dist/s3/keys.js
|
|
70127
|
+
function normalisePrefix(prefix) {
|
|
70128
|
+
const trimmed = (prefix ?? "").trim().replace(/^\/+/, "");
|
|
70129
|
+
if (trimmed === "")
|
|
70130
|
+
return "";
|
|
70131
|
+
return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
|
|
70132
|
+
}
|
|
70133
|
+
function confineKey(requested, prefix) {
|
|
70134
|
+
const clean = requested.trim().replace(/^\/+/, "");
|
|
70135
|
+
if (clean === "")
|
|
70136
|
+
return { ok: false, message: "No key was given." };
|
|
70137
|
+
if (clean.split("/").includes("..")) {
|
|
70138
|
+
return {
|
|
70139
|
+
ok: false,
|
|
70140
|
+
message: `"${requested}" contains "..", which S3 does not interpret as a parent folder \u2014 it would be part of the key. Give the key as it appears in the bucket.`
|
|
70141
|
+
};
|
|
70142
|
+
}
|
|
70143
|
+
const base = normalisePrefix(prefix);
|
|
70144
|
+
if (base === "")
|
|
70145
|
+
return { ok: true, key: clean };
|
|
70146
|
+
const key = clean.startsWith(base) ? clean : `${base}${clean}`;
|
|
70147
|
+
if (!key.startsWith(base)) {
|
|
70148
|
+
return { ok: false, message: `"${requested}" is outside "${base}", which this connection is limited to.` };
|
|
70149
|
+
}
|
|
70150
|
+
return { ok: true, key };
|
|
70151
|
+
}
|
|
70152
|
+
function displayKey(key, prefix) {
|
|
70153
|
+
const base = normalisePrefix(prefix);
|
|
70154
|
+
return base !== "" && key.startsWith(base) ? key.slice(base.length) : key;
|
|
70155
|
+
}
|
|
70156
|
+
|
|
70157
|
+
// ../../packages/core/dist/s3/resolve.js
|
|
70158
|
+
async function resolveS3(options) {
|
|
70159
|
+
const targets = [];
|
|
70160
|
+
const problems = [];
|
|
70161
|
+
for (const connection of options.config?.connections ?? []) {
|
|
70162
|
+
const secret = await options.secrets.get(connection.secretAccessKeyRef);
|
|
70163
|
+
if (secret === void 0 || secret.trim().length === 0) {
|
|
70164
|
+
problems.push({
|
|
70165
|
+
label: connection.label,
|
|
70166
|
+
problem: "Its secret access key is not in storage. Open Settings \u2192 Skills and enter it again \u2014 a key is never written to the config file, so one can go missing while the connection stays."
|
|
70167
|
+
});
|
|
70168
|
+
continue;
|
|
70169
|
+
}
|
|
70170
|
+
const sessionToken = connection.sessionTokenRef === void 0 ? void 0 : await options.secrets.get(connection.sessionTokenRef);
|
|
70171
|
+
const client = new S3Client(options.http, {
|
|
70172
|
+
bucket: connection.bucket,
|
|
70173
|
+
region: connection.region,
|
|
70174
|
+
accessKeyId: connection.accessKeyId,
|
|
70175
|
+
secretAccessKey: secret,
|
|
70176
|
+
...sessionToken !== void 0 ? { sessionToken } : {},
|
|
70177
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
70178
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {}
|
|
70179
|
+
}, options.tls);
|
|
70180
|
+
targets.push({
|
|
70181
|
+
id: connection.id,
|
|
70182
|
+
label: connection.label,
|
|
70183
|
+
bucket: connection.bucket,
|
|
70184
|
+
client,
|
|
70185
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
70186
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
70187
|
+
});
|
|
70188
|
+
}
|
|
70189
|
+
return { targets, problems };
|
|
70190
|
+
}
|
|
70191
|
+
function targetById(resolved, id) {
|
|
70192
|
+
if (id === void 0)
|
|
70193
|
+
return void 0;
|
|
70194
|
+
return resolved.targets.find((target) => target.id === id);
|
|
70195
|
+
}
|
|
70196
|
+
|
|
70197
|
+
// ../../packages/core/dist/s3/sync.js
|
|
70198
|
+
var DEFAULT_LIMIT2 = 500;
|
|
70199
|
+
async function syncFromS3(options) {
|
|
70200
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70201
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70202
|
+
const result = { written: [], unchanged: 0, failed: [] };
|
|
70203
|
+
const objects = await options.target.client.list(where, options.limit ?? DEFAULT_LIMIT2, options.signal);
|
|
70204
|
+
for (const object3 of objects) {
|
|
70205
|
+
const relative = object3.key.slice(where.length);
|
|
70206
|
+
if (relative === "" || relative.endsWith("/"))
|
|
70207
|
+
continue;
|
|
70208
|
+
if (!options.extensions.some((extension) => relative.toLowerCase().endsWith(extension)))
|
|
70209
|
+
continue;
|
|
70210
|
+
if (relative.split("/").includes("..")) {
|
|
70211
|
+
result.failed.push({ key: object3.key, problem: "The key would write outside the folder." });
|
|
70212
|
+
continue;
|
|
70213
|
+
}
|
|
70214
|
+
try {
|
|
70215
|
+
const bytes = await options.target.client.get(object3.key, options.signal);
|
|
70216
|
+
const localPath = join(options.localDir, relative);
|
|
70217
|
+
let existing;
|
|
70218
|
+
try {
|
|
70219
|
+
existing = await options.fs.readBytes(localPath);
|
|
70220
|
+
} catch {
|
|
70221
|
+
}
|
|
70222
|
+
if (existing !== void 0 && existing.equals(bytes)) {
|
|
70223
|
+
result.unchanged += 1;
|
|
70224
|
+
continue;
|
|
70225
|
+
}
|
|
70226
|
+
await options.fs.mkdir(dirname(localPath));
|
|
70227
|
+
await options.fs.writeBytes(localPath, bytes);
|
|
70228
|
+
result.written.push(relative);
|
|
70229
|
+
} catch (error51) {
|
|
70230
|
+
result.failed.push({
|
|
70231
|
+
key: object3.key,
|
|
70232
|
+
problem: error51 instanceof Error ? error51.message : String(error51)
|
|
70233
|
+
});
|
|
70234
|
+
}
|
|
70235
|
+
}
|
|
70236
|
+
return result;
|
|
70237
|
+
}
|
|
70238
|
+
async function uploadToS3(options) {
|
|
70239
|
+
if (options.target.readOnly === true) {
|
|
70240
|
+
throw new Error(`The connection "${options.target.label}" is read-only.`);
|
|
70241
|
+
}
|
|
70242
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70243
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70244
|
+
await options.target.client.put(`${where}${options.relative}`, options.contents, void 0, options.signal);
|
|
70245
|
+
}
|
|
70246
|
+
function join(dir, relative) {
|
|
70247
|
+
const left = dir.replace(/[\\/]+$/, "");
|
|
70248
|
+
return `${left}/${relative}`;
|
|
70249
|
+
}
|
|
70250
|
+
function dirname(filePath) {
|
|
70251
|
+
const cut = filePath.lastIndexOf("/");
|
|
70252
|
+
return cut === -1 ? filePath : filePath.slice(0, cut);
|
|
70253
|
+
}
|
|
70254
|
+
|
|
70255
|
+
// ../../packages/core/dist/s3/tools.js
|
|
70256
|
+
function pick2(targets, wanted) {
|
|
70257
|
+
if (wanted === void 0) {
|
|
70258
|
+
if (targets.length === 1)
|
|
70259
|
+
return targets[0];
|
|
70260
|
+
return `Several buckets are configured. Name one with "connection": ${targets.map((target) => target.label).join(", ")}.`;
|
|
70261
|
+
}
|
|
70262
|
+
const found = targets.find((target) => target.label.toLowerCase() === wanted.toLowerCase() || target.id === wanted);
|
|
70263
|
+
if (found !== void 0)
|
|
70264
|
+
return found;
|
|
70265
|
+
return `There is no S3 connection called "${wanted}". Configured: ${targets.map((target) => target.label).join(", ")}.`;
|
|
70266
|
+
}
|
|
70267
|
+
function looksBinary(bytes) {
|
|
70268
|
+
return bytes.subarray(0, 8e3).includes(0);
|
|
70269
|
+
}
|
|
70270
|
+
function describeSize(bytes) {
|
|
70271
|
+
if (bytes < 1024)
|
|
70272
|
+
return `${String(bytes)} B`;
|
|
70273
|
+
if (bytes < 1024 * 1024)
|
|
70274
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
70275
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
70276
|
+
}
|
|
70277
|
+
var failed = (error51) => ({
|
|
70278
|
+
content: error51 instanceof Error ? error51.message : String(error51),
|
|
70279
|
+
isError: true
|
|
70280
|
+
});
|
|
70281
|
+
function whichBuckets(targets) {
|
|
70282
|
+
return targets.length === 1 ? `the S3 bucket "${targets[0]?.label ?? ""}"` : `an S3 bucket (${targets.map((target) => target.label).join(", ")})`;
|
|
70283
|
+
}
|
|
70284
|
+
var connectionField = external_exports.string().optional().describe("Which configured bucket to use. May be omitted when only one is set up.");
|
|
70285
|
+
var listSchema = external_exports.object({
|
|
70286
|
+
connection: connectionField,
|
|
70287
|
+
prefix: external_exports.string().optional().describe("Folder to list, relative to the connection\u2019s own prefix. Omit for everything."),
|
|
70288
|
+
limit: external_exports.number().int().min(1).max(1e3).optional().describe("How many to return. Default 100.")
|
|
70289
|
+
});
|
|
70290
|
+
function createS3ListTool(targets) {
|
|
70291
|
+
return {
|
|
70292
|
+
name: "s3_list_files",
|
|
70293
|
+
group: "read",
|
|
70294
|
+
description: `List files in ${whichBuckets(targets)}. Use it to find what is there before reading or downloading. Returns keys, sizes and dates, never contents.`,
|
|
70295
|
+
parametersSchema: listSchema,
|
|
70296
|
+
async execute(params, context) {
|
|
70297
|
+
const target = pick2(targets, params.connection);
|
|
70298
|
+
if (typeof target === "string")
|
|
70299
|
+
return { content: target, isError: true };
|
|
70300
|
+
const base = normalisePrefix(target.prefix);
|
|
70301
|
+
const where = params.prefix === void 0 ? base : normalisePrefix(`${base}${params.prefix}`);
|
|
70302
|
+
try {
|
|
70303
|
+
const found = await target.client.list(where, params.limit ?? 100, context.signal);
|
|
70304
|
+
if (found.length === 0)
|
|
70305
|
+
return { content: `No files under "${where === "" ? "/" : where}".` };
|
|
70306
|
+
const lines = found.map((object3) => `${displayKey(object3.key, target.prefix)} ${describeSize(object3.size)} ${object3.lastModified}`);
|
|
70307
|
+
return { content: [`${String(found.length)} file(s) in ${target.bucket}:`, ...lines].join("\n") };
|
|
70308
|
+
} catch (error51) {
|
|
70309
|
+
return failed(error51);
|
|
70310
|
+
}
|
|
70311
|
+
}
|
|
70312
|
+
};
|
|
70313
|
+
}
|
|
70314
|
+
var readSchema = external_exports.object({
|
|
70315
|
+
connection: connectionField,
|
|
70316
|
+
key: external_exports.string().min(1).describe("The file to read, as s3_list_files reports it.")
|
|
70317
|
+
});
|
|
70318
|
+
function createS3ReadTool(targets) {
|
|
70319
|
+
return {
|
|
70320
|
+
name: "s3_read_file",
|
|
70321
|
+
group: "read",
|
|
70322
|
+
description: `Read a file from ${whichBuckets(targets)} as text. For anything that is not text, use s3_download_file and open it locally.`,
|
|
70323
|
+
parametersSchema: readSchema,
|
|
70324
|
+
async execute(params, context) {
|
|
70325
|
+
const target = pick2(targets, params.connection);
|
|
70326
|
+
if (typeof target === "string")
|
|
70327
|
+
return { content: target, isError: true };
|
|
70328
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70329
|
+
if (!resolved.ok)
|
|
70330
|
+
return { content: resolved.message, isError: true };
|
|
70331
|
+
try {
|
|
70332
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70333
|
+
if (looksBinary(bytes)) {
|
|
70334
|
+
return {
|
|
70335
|
+
content: `"${params.key}" is ${describeSize(bytes.length)} of binary data, not text. Use s3_download_file to copy it here and open it with something that understands it.`
|
|
70336
|
+
};
|
|
70337
|
+
}
|
|
70338
|
+
return { content: bytes.toString("utf8") };
|
|
70339
|
+
} catch (error51) {
|
|
70340
|
+
return failed(error51);
|
|
70341
|
+
}
|
|
70342
|
+
}
|
|
70343
|
+
};
|
|
70344
|
+
}
|
|
70345
|
+
var downloadSchema = external_exports.object({
|
|
70346
|
+
connection: connectionField,
|
|
70347
|
+
key: external_exports.string().min(1).describe("The file in the bucket."),
|
|
70348
|
+
to: external_exports.string().min(1).describe("Where to write it, relative to the workspace root.")
|
|
70349
|
+
});
|
|
70350
|
+
function createS3DownloadTool(targets) {
|
|
70351
|
+
return {
|
|
70352
|
+
name: "s3_download_file",
|
|
70353
|
+
group: "edit",
|
|
70354
|
+
description: `Copy a file out of ${whichBuckets(targets)} onto this machine.`,
|
|
70355
|
+
parametersSchema: downloadSchema,
|
|
70356
|
+
preview: async (params) => {
|
|
70357
|
+
const target = pick2(targets, params.connection);
|
|
70358
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${params.key}`;
|
|
70359
|
+
return { kind: "text", text: `Copy ${where}
|
|
70360
|
+
to ${params.to}` };
|
|
70361
|
+
},
|
|
70362
|
+
async execute(params, context) {
|
|
70363
|
+
const target = pick2(targets, params.connection);
|
|
70364
|
+
if (typeof target === "string")
|
|
70365
|
+
return { content: target, isError: true };
|
|
70366
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70367
|
+
if (!resolved.ok)
|
|
70368
|
+
return { content: resolved.message, isError: true };
|
|
70369
|
+
const to = await resolveToolPath(context, params.to);
|
|
70370
|
+
if (!to.ok)
|
|
70371
|
+
return { content: to.message, isError: true };
|
|
70372
|
+
try {
|
|
70373
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70374
|
+
await context.fs.writeBytes(to.realPath, bytes);
|
|
70375
|
+
return {
|
|
70376
|
+
content: `Wrote ${describeSize(bytes.length)} to ${params.to} from s3://${target.bucket}/${resolved.key}.`,
|
|
70377
|
+
path: to.realPath
|
|
70378
|
+
};
|
|
70379
|
+
} catch (error51) {
|
|
70380
|
+
return failed(error51);
|
|
70381
|
+
}
|
|
70382
|
+
}
|
|
70383
|
+
};
|
|
70384
|
+
}
|
|
70385
|
+
var uploadSchema = external_exports.object({
|
|
70386
|
+
connection: connectionField,
|
|
70387
|
+
from: external_exports.string().min(1).describe("The local file to upload, relative to the workspace root."),
|
|
70388
|
+
key: external_exports.string().min(1).describe("Where to put it in the bucket.")
|
|
70389
|
+
});
|
|
70390
|
+
function createS3UploadTool(targets) {
|
|
70391
|
+
return {
|
|
70392
|
+
name: "s3_upload_file",
|
|
70393
|
+
group: "edit",
|
|
70394
|
+
description: `Copy a file from this machine into ${whichBuckets(targets)}.`,
|
|
70395
|
+
parametersSchema: uploadSchema,
|
|
70396
|
+
/*
|
|
70397
|
+
* The preview names the destination in full, bucket included.
|
|
70398
|
+
*
|
|
70399
|
+
* Invariant 8: this is the one thing the person approving needs and cannot otherwise check.
|
|
70400
|
+
* A file sent to the wrong bucket is not recoverable by undoing anything here — it is on
|
|
70401
|
+
* somebody else's storage, possibly visible to people the user never intended.
|
|
70402
|
+
*/
|
|
70403
|
+
preview: async (params) => {
|
|
70404
|
+
const target = pick2(targets, params.connection);
|
|
70405
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${normalisePrefix(target.prefix)}${params.key}`;
|
|
70406
|
+
return { kind: "text", text: `Upload ${params.from}
|
|
70407
|
+
to ${where}` };
|
|
70408
|
+
},
|
|
70409
|
+
async execute(params, context) {
|
|
70410
|
+
const target = pick2(targets, params.connection);
|
|
70411
|
+
if (typeof target === "string")
|
|
70412
|
+
return { content: target, isError: true };
|
|
70413
|
+
if (target.readOnly === true) {
|
|
70414
|
+
return { content: `The connection "${target.label}" is read-only.`, isError: true };
|
|
70415
|
+
}
|
|
70416
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70417
|
+
if (!resolved.ok)
|
|
70418
|
+
return { content: resolved.message, isError: true };
|
|
70419
|
+
const from = await resolveToolPath(context, params.from);
|
|
70420
|
+
if (!from.ok)
|
|
70421
|
+
return { content: from.message, isError: true };
|
|
70422
|
+
try {
|
|
70423
|
+
const bytes = await context.fs.readBytes(from.realPath);
|
|
70424
|
+
await target.client.put(resolved.key, bytes, void 0, context.signal);
|
|
70425
|
+
return { content: `Uploaded ${describeSize(bytes.length)} to s3://${target.bucket}/${resolved.key}.` };
|
|
70426
|
+
} catch (error51) {
|
|
70427
|
+
return failed(error51);
|
|
70428
|
+
}
|
|
70429
|
+
}
|
|
70430
|
+
};
|
|
70431
|
+
}
|
|
70432
|
+
function createS3Tools(targets) {
|
|
70433
|
+
if (targets.length === 0)
|
|
70434
|
+
return [];
|
|
70435
|
+
return [
|
|
70436
|
+
createS3ListTool(targets),
|
|
70437
|
+
createS3ReadTool(targets),
|
|
70438
|
+
createS3DownloadTool(targets),
|
|
70439
|
+
createS3UploadTool(targets)
|
|
70440
|
+
];
|
|
70441
|
+
}
|
|
70442
|
+
|
|
70443
|
+
// ../../packages/core/dist/s3/localFolder.js
|
|
70444
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
70445
|
+
function mirrorFolder(options) {
|
|
70446
|
+
const connection = safeSegment(options.connectionId);
|
|
70447
|
+
const digest = createHash5("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
70448
|
+
return join2(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
70449
|
+
}
|
|
70450
|
+
function safeSegment(id) {
|
|
70451
|
+
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
70452
|
+
const suffix = createHash5("sha256").update(id).digest("hex").slice(0, 6);
|
|
70453
|
+
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
70454
|
+
}
|
|
70455
|
+
function join2(...parts) {
|
|
70456
|
+
return parts.map((part, index) => index === 0 ? part.replace(/[\\/]+$/, "") : part).join("/");
|
|
70457
|
+
}
|
|
70458
|
+
|
|
69541
70459
|
// src/reachableHosts.ts
|
|
69542
70460
|
import os3 from "node:os";
|
|
69543
70461
|
function reachableHosts(bindAddress, port, extra = []) {
|
|
@@ -69581,8 +70499,9 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
69581
70499
|
// src/identity.ts
|
|
69582
70500
|
import crypto5 from "node:crypto";
|
|
69583
70501
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
69584
|
-
describe
|
|
70502
|
+
describe;
|
|
69585
70503
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
70504
|
+
principal;
|
|
69586
70505
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
69587
70506
|
sessionToken = crypto5.randomBytes(32).toString("base64url");
|
|
69588
70507
|
/**
|
|
@@ -69597,9 +70516,19 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
69597
70516
|
handoffToken = crypto5.randomBytes(32).toString("base64url");
|
|
69598
70517
|
handoffExpiresAt;
|
|
69599
70518
|
handoffSeconds;
|
|
69600
|
-
|
|
70519
|
+
/**
|
|
70520
|
+
* @param principal Who this server's storage is filed under. Defaults to the local user.
|
|
70521
|
+
*
|
|
70522
|
+
* Supplied when the platform named the account — `JUPYTERHUB_USER` and friends, see
|
|
70523
|
+
* `hostedUser.ts`. **It changes the name, not the gate.** The bearer token below still decides
|
|
70524
|
+
* who gets in, which is §14's rule that identity resolution must never become a way past the
|
|
70525
|
+
* door: knowing that a server was spawned for Ana says nothing about who is making this request.
|
|
70526
|
+
*/
|
|
70527
|
+
constructor(handoffSeconds = 10, principal) {
|
|
69601
70528
|
this.handoffSeconds = handoffSeconds;
|
|
69602
70529
|
this.handoffExpiresAt = Date.now() + handoffSeconds * 1e3;
|
|
70530
|
+
this.principal = principal ?? _SingleUserIdentity.PRINCIPAL;
|
|
70531
|
+
this.describe = principal === void 0 ? "single user (local)" : `single user \u2014 ${principal.id}`;
|
|
69603
70532
|
}
|
|
69604
70533
|
get launchToken() {
|
|
69605
70534
|
if (this.handoffToken === void 0) throw new Error("handoff token already consumed");
|
|
@@ -69646,7 +70575,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
69646
70575
|
async authenticate(request) {
|
|
69647
70576
|
const header = request.headers.authorization;
|
|
69648
70577
|
if (header === void 0 || !header.startsWith("Bearer ")) return void 0;
|
|
69649
|
-
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ?
|
|
70578
|
+
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ? this.principal : void 0;
|
|
69650
70579
|
}
|
|
69651
70580
|
};
|
|
69652
70581
|
function timingSafeEquals(a, b) {
|
|
@@ -70234,6 +71163,21 @@ function readVariablesFile(filePath) {
|
|
|
70234
71163
|
}
|
|
70235
71164
|
}
|
|
70236
71165
|
|
|
71166
|
+
// src/hostedUser.ts
|
|
71167
|
+
var SOURCES = [
|
|
71168
|
+
/** JupyterHub's own, set in every single-user server it spawns. */
|
|
71169
|
+
"JUPYTERHUB_USER",
|
|
71170
|
+
/** Set by some deployments that front an app without the hub's spawner. */
|
|
71171
|
+
"JUPYTER_USER"
|
|
71172
|
+
];
|
|
71173
|
+
function hostedUser(env2 = process.env) {
|
|
71174
|
+
for (const source of SOURCES) {
|
|
71175
|
+
const value = env2[source]?.trim();
|
|
71176
|
+
if (value !== void 0 && value.length > 0) return { id: value, source };
|
|
71177
|
+
}
|
|
71178
|
+
return void 0;
|
|
71179
|
+
}
|
|
71180
|
+
|
|
70237
71181
|
// src/session.ts
|
|
70238
71182
|
import { watch as fsWatch } from "node:fs";
|
|
70239
71183
|
import fs23 from "node:fs/promises";
|
|
@@ -70766,11 +71710,26 @@ var STREAM_PADDING = `: ${(() => {
|
|
|
70766
71710
|
})()}
|
|
70767
71711
|
|
|
70768
71712
|
`;
|
|
71713
|
+
function principalFromPlatform() {
|
|
71714
|
+
const found = hostedUser();
|
|
71715
|
+
return found === void 0 ? void 0 : { id: found.id, displayName: found.id };
|
|
71716
|
+
}
|
|
70769
71717
|
async function startServer(options) {
|
|
70770
71718
|
const log = options.logSink ?? ((line) => process.stderr.write(`${line}
|
|
70771
71719
|
`));
|
|
70772
71720
|
setFrameAncestors(options.allowFrameAncestors ?? []);
|
|
70773
|
-
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() :
|
|
71721
|
+
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() : (
|
|
71722
|
+
/*
|
|
71723
|
+
* Named by the platform when it says so, and still gated by the token either way.
|
|
71724
|
+
*
|
|
71725
|
+
* JupyterHub spawns a server per person and sets `JUPYTERHUB_USER` in it, so settings,
|
|
71726
|
+
* secrets and history are filed under that person rather than under "local" — which is
|
|
71727
|
+
* what somebody had otherwise to write a Python function to achieve. Read from this
|
|
71728
|
+
* process's environment, never from a request: see `hostedUser.ts` for why the URL
|
|
71729
|
+
* suffix carrying the same name is not the same fact.
|
|
71730
|
+
*/
|
|
71731
|
+
new SingleUserIdentity(options.handoffSeconds, principalFromPlatform())
|
|
71732
|
+
));
|
|
70774
71733
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
70775
71734
|
const sharedStore = options.sharedConfig;
|
|
70776
71735
|
const sharedSecretStore = new FileSecretStore(path31.join(options.dataDir, "shared-secrets.json"));
|
|
@@ -70825,6 +71784,12 @@ async function startServer(options) {
|
|
|
70825
71784
|
};
|
|
70826
71785
|
const connection = {
|
|
70827
71786
|
transport,
|
|
71787
|
+
/*
|
|
71788
|
+
* Replaced below, once the bridge that owns the state exists. A no-op rather than a missing
|
|
71789
|
+
* field so the object is a complete `Connection` from the moment it is built — a half-built
|
|
71790
|
+
* one handed to anything in between is how a route ends up calling something undefined.
|
|
71791
|
+
*/
|
|
71792
|
+
resync: () => void 0,
|
|
70828
71793
|
deliver: (message3) => {
|
|
70829
71794
|
for (const listener of listeners) listener(message3);
|
|
70830
71795
|
},
|
|
@@ -70932,6 +71897,9 @@ async function startServer(options) {
|
|
|
70932
71897
|
originalDispose();
|
|
70933
71898
|
session.dispose();
|
|
70934
71899
|
};
|
|
71900
|
+
connection.resync = () => {
|
|
71901
|
+
session.resync();
|
|
71902
|
+
};
|
|
70935
71903
|
return connection;
|
|
70936
71904
|
}
|
|
70937
71905
|
const server = createServer((request, response) => {
|
|
@@ -71024,6 +71992,7 @@ async function startServer(options) {
|
|
|
71024
71992
|
if (viaAdminUrl) adminConnections.add(principal.id);
|
|
71025
71993
|
else adminConnections.delete(principal.id);
|
|
71026
71994
|
connection.attach(response);
|
|
71995
|
+
connection.resync();
|
|
71027
71996
|
connection.transport.post({
|
|
71028
71997
|
type: "hostRole",
|
|
71029
71998
|
role: isAdminSession(principal) ? "admin" : "user",
|
|
@@ -71051,6 +72020,7 @@ async function startServer(options) {
|
|
|
71051
72020
|
if (connection === void 0) {
|
|
71052
72021
|
connection = await openConnection(principal);
|
|
71053
72022
|
connections.set(principal.id, connection);
|
|
72023
|
+
connection.resync();
|
|
71054
72024
|
}
|
|
71055
72025
|
respondJson(response, 200, { messages: connection.drain() });
|
|
71056
72026
|
return;
|