@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/cli.js
CHANGED
|
@@ -24631,6 +24631,8 @@ var FetchHttpClient = class {
|
|
|
24631
24631
|
init.headers = options.headers;
|
|
24632
24632
|
if (options.body !== void 0)
|
|
24633
24633
|
init.body = options.body;
|
|
24634
|
+
if (options.bodyBytes !== void 0)
|
|
24635
|
+
init.body = options.bodyBytes;
|
|
24634
24636
|
if (options.signal !== void 0)
|
|
24635
24637
|
init.signal = options.signal;
|
|
24636
24638
|
let target;
|
|
@@ -40320,6 +40322,68 @@ var mailIndexConfigSchema = external_exports.object({
|
|
|
40320
40322
|
/** Characters of body kept per message, for showing a hit without reopening Outlook. */
|
|
40321
40323
|
previewChars: external_exports.number().int().min(0).max(2e3)
|
|
40322
40324
|
}).partial();
|
|
40325
|
+
var s3ConnectionSchema = external_exports.object({
|
|
40326
|
+
id: external_exports.string().min(1),
|
|
40327
|
+
label: external_exports.string().min(1),
|
|
40328
|
+
bucket: external_exports.string().min(1),
|
|
40329
|
+
region: external_exports.string().min(1),
|
|
40330
|
+
accessKeyId: external_exports.string().min(1),
|
|
40331
|
+
secretAccessKeyRef: external_exports.string().min(1),
|
|
40332
|
+
/** Only for temporary credentials. */
|
|
40333
|
+
sessionTokenRef: external_exports.string().optional(),
|
|
40334
|
+
/** Absent means the ordinary AWS endpoint for the region. */
|
|
40335
|
+
endpoint: external_exports.string().url().optional(),
|
|
40336
|
+
/** `host/bucket/key` instead of `bucket.host/key`, which internal deployments usually need. */
|
|
40337
|
+
pathStyle: external_exports.boolean().optional(),
|
|
40338
|
+
/**
|
|
40339
|
+
* Everything is confined to this prefix, when one is set.
|
|
40340
|
+
*
|
|
40341
|
+
* Not a convenience. It is the only thing bounding what the tools can reach in a bucket that may
|
|
40342
|
+
* hold far more than this project, and it is enforced on every key rather than trusted to the
|
|
40343
|
+
* model — `confine()`'s argument applied to a bucket instead of a disk.
|
|
40344
|
+
*/
|
|
40345
|
+
prefix: external_exports.string().optional(),
|
|
40346
|
+
/** Refuses every write, so a bucket can be attached for reading with nothing to go wrong. */
|
|
40347
|
+
readOnly: external_exports.boolean().optional()
|
|
40348
|
+
});
|
|
40349
|
+
var s3MirrorSchema = external_exports.object({
|
|
40350
|
+
connectionId: external_exports.string().min(1),
|
|
40351
|
+
prefix: external_exports.string().optional(),
|
|
40352
|
+
/** Off by default: reading a bucket on every panel open is somebody's money and latency. */
|
|
40353
|
+
enabled: external_exports.boolean().optional(),
|
|
40354
|
+
/**
|
|
40355
|
+
* New skills written here are also copied up to this folder.
|
|
40356
|
+
*
|
|
40357
|
+
* At most one folder should carry it, and the bridge takes the first that does. The rest are
|
|
40358
|
+
* read-only sources, which is the same split the local folders already have: one place new
|
|
40359
|
+
* skills are saved, and any number of folders they are *also* read from. A list where every
|
|
40360
|
+
* entry was writable would make "where did that skill go" unanswerable.
|
|
40361
|
+
*/
|
|
40362
|
+
publish: external_exports.boolean().optional()
|
|
40363
|
+
});
|
|
40364
|
+
var s3ConfigSchema = external_exports.object({
|
|
40365
|
+
connections: external_exports.array(s3ConnectionSchema).max(20).optional(),
|
|
40366
|
+
/**
|
|
40367
|
+
* Where skills are kept, when they live in a bucket rather than on this disk.
|
|
40368
|
+
*
|
|
40369
|
+
* Only the *files* move. They are still loaded, watched and indexed exactly as local ones are —
|
|
40370
|
+
* indexing stays as configured — so this names a sync, not a second kind of skill.
|
|
40371
|
+
*
|
|
40372
|
+
* A **list**, because it maps onto the split the local folders already have: any number of
|
|
40373
|
+
* folders skills are read from, and one place new ones are saved. A bucket folder is one more
|
|
40374
|
+
* source, so several of them is the ordinary case rather than a special one.
|
|
40375
|
+
*/
|
|
40376
|
+
skills: external_exports.array(s3MirrorSchema).max(8).optional(),
|
|
40377
|
+
/**
|
|
40378
|
+
* The same for Python tools, with one difference that is not a detail.
|
|
40379
|
+
*
|
|
40380
|
+
* A mirrored `.py` is **not** loaded on arrival. The hash-pinned registry (§13) refuses any tool
|
|
40381
|
+
* that was not approved with its source shown, so a bucket is how a tool *reaches* a machine,
|
|
40382
|
+
* and approval still happens on each one. Anybody with write access to the bucket would
|
|
40383
|
+
* otherwise be running code as this user on every machine that syncs.
|
|
40384
|
+
*/
|
|
40385
|
+
tools: external_exports.array(s3MirrorSchema).max(8).optional()
|
|
40386
|
+
});
|
|
40323
40387
|
var configSchema = external_exports.object({
|
|
40324
40388
|
profiles: external_exports.array(providerProfileSchema),
|
|
40325
40389
|
/**
|
|
@@ -40341,6 +40405,8 @@ var configSchema = external_exports.object({
|
|
|
40341
40405
|
* embedder would exfiltrate whatever gets indexed — sharper than the existing entries,
|
|
40342
40406
|
* because the payload is source code.
|
|
40343
40407
|
*/
|
|
40408
|
+
/** User-scope only (invariant 5): it holds a bucket and a key that can write to it. */
|
|
40409
|
+
s3: s3ConfigSchema,
|
|
40344
40410
|
vectorStores: external_exports.record(external_exports.string(), vectorStoreSchema),
|
|
40345
40411
|
activeVectorStoreId: external_exports.string(),
|
|
40346
40412
|
embedder: embedderConfigSchema,
|
|
@@ -40988,6 +41054,15 @@ var USER_SCOPE_ONLY_KEYS = [
|
|
|
40988
41054
|
// Per-project settings live here, keyed by path. Same reasoning as `approvals` exactly: a repo
|
|
40989
41055
|
// that could write its own entry would choose its own vector store and model for itself.
|
|
40990
41056
|
"workspaces",
|
|
41057
|
+
/*
|
|
41058
|
+
* Holds a bucket, an endpoint and the reference to a key that can read and write it.
|
|
41059
|
+
*
|
|
41060
|
+
* The sharpest kind of entry on this list: a repository able to set it would point the upload
|
|
41061
|
+
* tool at a bucket of its choosing, and everything copied "into S3" would go to somebody else —
|
|
41062
|
+
* with the user watching a tool succeed. Same shape as `embedder`, with whatever the user
|
|
41063
|
+
* uploads as the payload.
|
|
41064
|
+
*/
|
|
41065
|
+
"s3",
|
|
40991
41066
|
// `expert.path` names an executable. A workspace able to set it would run a program of
|
|
40992
41067
|
// its choosing as soon as the panel opened — the same threat as `python.uvPath`.
|
|
40993
41068
|
// `expert.enabled` is here too, so a repo cannot switch on paid API calls by itself.
|
|
@@ -43650,6 +43725,10 @@ function isValidRoleId(id) {
|
|
|
43650
43725
|
function isAgentRole(value, custom2 = []) {
|
|
43651
43726
|
return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
|
|
43652
43727
|
}
|
|
43728
|
+
var COLOURED_NON_ROLES = ["claude"];
|
|
43729
|
+
function isColourableAgent(value, custom2 = []) {
|
|
43730
|
+
return isAgentRole(value, custom2) || COLOURED_NON_ROLES.includes(value);
|
|
43731
|
+
}
|
|
43653
43732
|
function knownRoles(custom2 = []) {
|
|
43654
43733
|
return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
|
|
43655
43734
|
}
|
|
@@ -48628,26 +48707,26 @@ Each appears in its own window. Nothing is changed or sent.`
|
|
|
48628
48707
|
async execute(params) {
|
|
48629
48708
|
const ids = idsOf(params);
|
|
48630
48709
|
const opened = [];
|
|
48631
|
-
const
|
|
48710
|
+
const failed2 = [];
|
|
48632
48711
|
for (const id of ids) {
|
|
48633
48712
|
try {
|
|
48634
48713
|
opened.push((await options.display(id)).subject);
|
|
48635
48714
|
} catch (error51) {
|
|
48636
|
-
|
|
48715
|
+
failed2.push(`${id}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48637
48716
|
}
|
|
48638
48717
|
}
|
|
48639
48718
|
if (opened.length === 0) {
|
|
48640
48719
|
return { content: `Could not open any of them.
|
|
48641
|
-
${
|
|
48720
|
+
${failed2.join("\n")}`, isError: true };
|
|
48642
48721
|
}
|
|
48643
48722
|
return {
|
|
48644
48723
|
content: [
|
|
48645
48724
|
`Opened ${String(opened.length)} message(s) in Outlook:`,
|
|
48646
48725
|
...opened.map((subject) => ` "${subject}"`),
|
|
48647
|
-
...
|
|
48726
|
+
...failed2.length === 0 ? [] : [
|
|
48648
48727
|
"",
|
|
48649
|
-
`${String(
|
|
48650
|
-
...
|
|
48728
|
+
`${String(failed2.length)} could not be opened - moved or deleted since indexing:`,
|
|
48729
|
+
...failed2.map((line) => ` ${line}`)
|
|
48651
48730
|
]
|
|
48652
48731
|
].join("\n")
|
|
48653
48732
|
};
|
|
@@ -57216,10 +57295,20 @@ function createWriteSkillTool(context) {
|
|
|
57216
57295
|
}
|
|
57217
57296
|
await fs10.writeFile(filePath, rendered, "utf8");
|
|
57218
57297
|
await context.onChanged();
|
|
57298
|
+
let publishProblem;
|
|
57299
|
+
if (context.onSaved !== void 0) {
|
|
57300
|
+
try {
|
|
57301
|
+
await context.onSaved(params.name, rendered);
|
|
57302
|
+
} catch (error51) {
|
|
57303
|
+
publishProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
57304
|
+
}
|
|
57305
|
+
}
|
|
57219
57306
|
const collision = existed ? void 0 : await collisionWarning(params.name);
|
|
57220
57307
|
return {
|
|
57221
57308
|
content: `${existed ? "Updated" : "Recorded"} the skill "${params.name}" at ${filePath}.
|
|
57222
|
-
Its summary will appear in your context from the next message onward.` + (
|
|
57309
|
+
Its summary will appear in your context from the next message onward.` + (publishProblem === void 0 ? "" : `
|
|
57310
|
+
|
|
57311
|
+
Saved here, but NOT copied to the bucket: ${publishProblem}`) + (collision === void 0 ? "" : `
|
|
57223
57312
|
|
|
57224
57313
|
${collision}`),
|
|
57225
57314
|
path: filePath
|
|
@@ -58781,8 +58870,8 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58781
58870
|
events.onToolResult(toolCall, result);
|
|
58782
58871
|
const queued = options.drainQueuedMessages?.() ?? [];
|
|
58783
58872
|
for (const message3 of queued) {
|
|
58784
|
-
conversation.addUserMessage(message3);
|
|
58785
|
-
events.onQueuedMessageConsumed?.(message3);
|
|
58873
|
+
conversation.addUserMessage(message3.text, message3.images);
|
|
58874
|
+
events.onQueuedMessageConsumed?.(message3.text);
|
|
58786
58875
|
}
|
|
58787
58876
|
if (queued.length > 0) {
|
|
58788
58877
|
iteration = -1;
|
|
@@ -61784,6 +61873,10 @@ var NodeFileSystem = class {
|
|
|
61784
61873
|
async writeFile(path36, contents) {
|
|
61785
61874
|
await fs16.writeFile(path36, contents, "utf8");
|
|
61786
61875
|
}
|
|
61876
|
+
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
61877
|
+
async writeBytes(path36, contents) {
|
|
61878
|
+
await fs16.writeFile(path36, contents);
|
|
61879
|
+
}
|
|
61787
61880
|
async stat(path36) {
|
|
61788
61881
|
const stat = await fs16.lstat(path36);
|
|
61789
61882
|
return {
|
|
@@ -62109,7 +62202,7 @@ function wireChatBridge(services) {
|
|
|
62109
62202
|
const { transport, secrets, ui, workspaceRoot, storageDir } = services;
|
|
62110
62203
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
62111
62204
|
const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
|
|
62112
|
-
const httpClient = services.httpClient ?? new FetchHttpClient();
|
|
62205
|
+
const httpClient = services.httpClient ?? new FetchHttpClient({ useEnvProxy: true });
|
|
62113
62206
|
const conversation = new Conversation(workspaceRoot !== void 0 ? buildSystemPrompt(workspaceRoot) : void 0);
|
|
62114
62207
|
let cachedSecretValues = [];
|
|
62115
62208
|
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(path24.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
@@ -62202,6 +62295,10 @@ ${preview.text}` } : {}
|
|
|
62202
62295
|
const defaultSkillsDir = workspaceRoot !== void 0 ? path24.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
62203
62296
|
let skillsDir = defaultSkillsDir;
|
|
62204
62297
|
let extraSkillDirs = [];
|
|
62298
|
+
let mirroredSkillsDirs = [];
|
|
62299
|
+
let mirroredToolsDirs = [];
|
|
62300
|
+
let cachedSkillMirrors = [];
|
|
62301
|
+
let lastSync = {};
|
|
62205
62302
|
function resolveSkillDir(entry) {
|
|
62206
62303
|
const trimmed = entry.trim();
|
|
62207
62304
|
if (trimmed.length === 0)
|
|
@@ -62403,7 +62500,15 @@ ${preview.text}` } : {}
|
|
|
62403
62500
|
}
|
|
62404
62501
|
let queuedMessages = [];
|
|
62405
62502
|
function postQueued() {
|
|
62406
|
-
post({
|
|
62503
|
+
post({
|
|
62504
|
+
type: "queued",
|
|
62505
|
+
// A count, not the attachments: the composer only needs to say one is there, and sending
|
|
62506
|
+
// the bytes back for something already on screen would be waste.
|
|
62507
|
+
messages: queuedMessages.map((entry) => ({
|
|
62508
|
+
text: entry.text,
|
|
62509
|
+
...entry.images !== void 0 && entry.images.length > 0 ? { images: entry.images.length } : {}
|
|
62510
|
+
}))
|
|
62511
|
+
});
|
|
62407
62512
|
}
|
|
62408
62513
|
let activeAbortController;
|
|
62409
62514
|
let taskCheckpoint;
|
|
@@ -62756,6 +62861,7 @@ ${preview.text}` } : {}
|
|
|
62756
62861
|
let cachedOffice = {};
|
|
62757
62862
|
let cachedMail = {};
|
|
62758
62863
|
let cachedDatasets = [];
|
|
62864
|
+
let cachedS3 = { targets: [], problems: [] };
|
|
62759
62865
|
let datasetSummaryForPrompt = [];
|
|
62760
62866
|
let cachedPythonEnabled = false;
|
|
62761
62867
|
const mailStore = new MailStore(storageDir);
|
|
@@ -62804,6 +62910,22 @@ ${preview.text}` } : {}
|
|
|
62804
62910
|
cachedOffice = config2.office ?? {};
|
|
62805
62911
|
cachedMail = config2.mail ?? {};
|
|
62806
62912
|
cachedDatasets = config2.datasets ?? [];
|
|
62913
|
+
cachedS3 = await resolveS3({
|
|
62914
|
+
config: config2.s3,
|
|
62915
|
+
http: httpClient,
|
|
62916
|
+
secrets,
|
|
62917
|
+
/*
|
|
62918
|
+
* Through the one global resolver, so a corporate root certificate reaches S3 exactly as it
|
|
62919
|
+
* reaches the gateway and the vector store. §10: do not add another place to configure a CA.
|
|
62920
|
+
*/
|
|
62921
|
+
tls: await resolveConnectionTls({
|
|
62922
|
+
...config2.tls !== void 0 ? { global: config2.tls } : {},
|
|
62923
|
+
...config2.certDir !== void 0 ? { certDir: config2.certDir } : {},
|
|
62924
|
+
onPaths: (paths) => {
|
|
62925
|
+
void Promise.all(paths.map((certPath) => denylist.add(certPath))).catch(() => void 0);
|
|
62926
|
+
}
|
|
62927
|
+
})
|
|
62928
|
+
});
|
|
62807
62929
|
cachedPythonEnabled = config2.python?.dynamicTools === "on";
|
|
62808
62930
|
datasetSummaryForPrompt = await Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
62809
62931
|
name: dataset.name,
|
|
@@ -62837,6 +62959,20 @@ ${preview.text}` } : {}
|
|
|
62837
62959
|
cachedReadRoots = (config2.filesystem?.readRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
62838
62960
|
skillsDir = (config2.skills?.dir !== void 0 ? resolveSkillDir(config2.skills.dir) : void 0) ?? defaultSkillsDir;
|
|
62839
62961
|
extraSkillDirs = (config2.skills?.paths ?? []).map(resolveSkillDir).filter((dir) => dir !== void 0);
|
|
62962
|
+
cachedSkillMirrors = config2.s3?.skills ?? [];
|
|
62963
|
+
mirroredSkillsDirs = cachedSkillMirrors.filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
|
|
62964
|
+
storageDir,
|
|
62965
|
+
connectionId: mirror.connectionId,
|
|
62966
|
+
kind: "skills",
|
|
62967
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
62968
|
+
}));
|
|
62969
|
+
extraSkillDirs.push(...mirroredSkillsDirs);
|
|
62970
|
+
mirroredToolsDirs = (config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
|
|
62971
|
+
storageDir,
|
|
62972
|
+
connectionId: mirror.connectionId,
|
|
62973
|
+
kind: "tools",
|
|
62974
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
62975
|
+
}));
|
|
62840
62976
|
return config2;
|
|
62841
62977
|
}
|
|
62842
62978
|
function announceConfigRecovery() {
|
|
@@ -63006,7 +63142,22 @@ ${preview.text}` } : {}
|
|
|
63006
63142
|
submitForReview: (request) => services.submitForReview?.({ kind: "skill", ...request }) ?? Promise.resolve("")
|
|
63007
63143
|
} : {}
|
|
63008
63144
|
};
|
|
63009
|
-
|
|
63145
|
+
const publishTo = cachedSkillMirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
|
|
63146
|
+
const skillTarget = publishTo === void 0 ? void 0 : targetById(cachedS3, publishTo.connectionId);
|
|
63147
|
+
const mirrorPrefix = publishTo?.prefix;
|
|
63148
|
+
combined.register(createWriteSkillTool({
|
|
63149
|
+
...context,
|
|
63150
|
+
...skillTarget !== void 0 && skillTarget.readOnly !== true ? {
|
|
63151
|
+
onSaved: async (name, content) => {
|
|
63152
|
+
await uploadToS3({
|
|
63153
|
+
target: skillTarget,
|
|
63154
|
+
...mirrorPrefix !== void 0 ? { prefix: mirrorPrefix } : {},
|
|
63155
|
+
relative: `${name}.md`,
|
|
63156
|
+
contents: Buffer.from(content, "utf8")
|
|
63157
|
+
});
|
|
63158
|
+
}
|
|
63159
|
+
} : {}
|
|
63160
|
+
}));
|
|
63010
63161
|
combined.register(createDeleteSkillTool(context));
|
|
63011
63162
|
}
|
|
63012
63163
|
if (workspaceRoot !== void 0) {
|
|
@@ -63041,6 +63192,8 @@ ${preview.text}` } : {}
|
|
|
63041
63192
|
if (codebase !== void 0) {
|
|
63042
63193
|
combined.register(createSearchCodebaseTool({ ...codebase, observer: searchLog }));
|
|
63043
63194
|
}
|
|
63195
|
+
for (const tool of createS3Tools(cachedS3.targets))
|
|
63196
|
+
combined.register(tool);
|
|
63044
63197
|
if (cachedDatasets.length > 0) {
|
|
63045
63198
|
combined.register(createSearchDataTool({
|
|
63046
63199
|
load: async () => Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
@@ -63474,7 +63627,25 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63474
63627
|
const drained = queuedMessages;
|
|
63475
63628
|
queuedMessages = [];
|
|
63476
63629
|
postQueued();
|
|
63477
|
-
return drained
|
|
63630
|
+
return drained.map((entry) => {
|
|
63631
|
+
const attachments = entry.images ?? [];
|
|
63632
|
+
if (attachments.length === 0)
|
|
63633
|
+
return { text: entry.text };
|
|
63634
|
+
if (!capabilities.supportsVision) {
|
|
63635
|
+
post({
|
|
63636
|
+
type: "error",
|
|
63637
|
+
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.`
|
|
63638
|
+
});
|
|
63639
|
+
return { text: entry.text };
|
|
63640
|
+
}
|
|
63641
|
+
return {
|
|
63642
|
+
text: entry.text,
|
|
63643
|
+
images: attachments.map((image) => ({
|
|
63644
|
+
mediaType: image.mediaType,
|
|
63645
|
+
data: image.data
|
|
63646
|
+
}))
|
|
63647
|
+
};
|
|
63648
|
+
});
|
|
63478
63649
|
}
|
|
63479
63650
|
};
|
|
63480
63651
|
if (images !== void 0 && images.length > 0 && capabilities.supportsVision) {
|
|
@@ -63670,10 +63841,11 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63670
63841
|
await persistActiveTask();
|
|
63671
63842
|
await postTasks();
|
|
63672
63843
|
if (queuedMessages.length > 0 && activeAbortController === void 0) {
|
|
63673
|
-
const next = queuedMessages.join("\n\n");
|
|
63844
|
+
const next = queuedMessages.map((entry) => entry.text).join("\n\n");
|
|
63845
|
+
const images2 = queuedMessages.flatMap((entry) => entry.images ?? []);
|
|
63674
63846
|
queuedMessages = [];
|
|
63675
63847
|
postQueued();
|
|
63676
|
-
void handleSendMessage(next);
|
|
63848
|
+
void handleSendMessage(next, images2.length > 0 ? images2 : void 0);
|
|
63677
63849
|
}
|
|
63678
63850
|
}
|
|
63679
63851
|
}
|
|
@@ -65170,6 +65342,158 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65170
65342
|
const digest = createHash3("sha256").update(path24.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
|
|
65171
65343
|
return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
|
|
65172
65344
|
}
|
|
65345
|
+
async function postS3() {
|
|
65346
|
+
const { config: config2 } = await configManager.load();
|
|
65347
|
+
const connections = await Promise.all((config2.s3?.connections ?? []).map(async (connection) => ({
|
|
65348
|
+
id: connection.id,
|
|
65349
|
+
label: connection.label,
|
|
65350
|
+
bucket: connection.bucket,
|
|
65351
|
+
region: connection.region,
|
|
65352
|
+
accessKeyId: connection.accessKeyId,
|
|
65353
|
+
/*
|
|
65354
|
+
* Asked of the secret store rather than inferred from config holding a reference.
|
|
65355
|
+
*
|
|
65356
|
+
* Config and the store are two stores that can diverge, and letting one assert what only
|
|
65357
|
+
* the other knows is what made a vanished API key keep reading as "Set" for three
|
|
65358
|
+
* releases (section 19).
|
|
65359
|
+
*/
|
|
65360
|
+
hasSecret: await secrets.get(connection.secretAccessKeyRef) !== void 0,
|
|
65361
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
65362
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {},
|
|
65363
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
65364
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
65365
|
+
})));
|
|
65366
|
+
post({
|
|
65367
|
+
type: "s3",
|
|
65368
|
+
connections,
|
|
65369
|
+
problems: cachedS3.problems,
|
|
65370
|
+
skills: config2.s3?.skills ?? [],
|
|
65371
|
+
tools: config2.s3?.tools ?? [],
|
|
65372
|
+
skillsFolders: mirroredSkillsDirs,
|
|
65373
|
+
toolsFolders: mirroredToolsDirs,
|
|
65374
|
+
...lastSync.skills !== void 0 ? { lastSkillsSync: lastSync.skills } : {},
|
|
65375
|
+
...lastSync.tools !== void 0 ? { lastToolsSync: lastSync.tools } : {}
|
|
65376
|
+
});
|
|
65377
|
+
}
|
|
65378
|
+
const s3SecretRef = (id) => `s3:${id}:secret`;
|
|
65379
|
+
const s3TokenRef = (id) => `s3:${id}:sessionToken`;
|
|
65380
|
+
async function handleSaveS3Connection(input, secret, sessionToken) {
|
|
65381
|
+
const { config: config2 } = await configManager.load();
|
|
65382
|
+
const id = input.id ?? `s3-${Date.now().toString(36)}`;
|
|
65383
|
+
const existing = (config2.s3?.connections ?? []).find((connection) => connection.id === id);
|
|
65384
|
+
if (secret !== void 0 && secret.trim().length > 0) {
|
|
65385
|
+
await secrets.set(s3SecretRef(id), secret.trim());
|
|
65386
|
+
}
|
|
65387
|
+
if (sessionToken !== void 0 && sessionToken.trim().length > 0) {
|
|
65388
|
+
await secrets.set(s3TokenRef(id), sessionToken.trim());
|
|
65389
|
+
}
|
|
65390
|
+
const saved = {
|
|
65391
|
+
id,
|
|
65392
|
+
label: input.label.trim(),
|
|
65393
|
+
bucket: input.bucket.trim(),
|
|
65394
|
+
region: input.region.trim(),
|
|
65395
|
+
accessKeyId: input.accessKeyId.trim(),
|
|
65396
|
+
secretAccessKeyRef: s3SecretRef(id),
|
|
65397
|
+
...existing?.sessionTokenRef !== void 0 || (sessionToken ?? "").trim().length > 0 ? { sessionTokenRef: s3TokenRef(id) } : {},
|
|
65398
|
+
...input.endpoint !== void 0 && input.endpoint.trim().length > 0 ? { endpoint: input.endpoint.trim() } : {},
|
|
65399
|
+
...input.pathStyle === true ? { pathStyle: true } : {},
|
|
65400
|
+
...input.prefix !== void 0 && input.prefix.trim().length > 0 ? { prefix: input.prefix.trim() } : {},
|
|
65401
|
+
...input.readOnly === true ? { readOnly: true } : {}
|
|
65402
|
+
};
|
|
65403
|
+
const others = (config2.s3?.connections ?? []).filter((connection) => connection.id !== id);
|
|
65404
|
+
await configManager.save("user", {
|
|
65405
|
+
s3: { ...config2.s3 ?? {}, connections: [...others, saved] }
|
|
65406
|
+
});
|
|
65407
|
+
await loadSettings();
|
|
65408
|
+
await postS3();
|
|
65409
|
+
}
|
|
65410
|
+
async function handleDeleteS3Connection(id) {
|
|
65411
|
+
const { config: config2 } = await configManager.load();
|
|
65412
|
+
await secrets.delete(s3SecretRef(id)).catch(() => void 0);
|
|
65413
|
+
await secrets.delete(s3TokenRef(id)).catch(() => void 0);
|
|
65414
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65415
|
+
s3.connections = (s3.connections ?? []).filter((connection) => connection.id !== id);
|
|
65416
|
+
s3.skills = (s3.skills ?? []).filter((mirror) => mirror.connectionId !== id);
|
|
65417
|
+
s3.tools = (s3.tools ?? []).filter((mirror) => mirror.connectionId !== id);
|
|
65418
|
+
if (s3.skills.length === 0)
|
|
65419
|
+
delete s3.skills;
|
|
65420
|
+
if (s3.tools.length === 0)
|
|
65421
|
+
delete s3.tools;
|
|
65422
|
+
await configManager.save("user", { s3 });
|
|
65423
|
+
await loadSettings();
|
|
65424
|
+
await postS3();
|
|
65425
|
+
}
|
|
65426
|
+
async function handleSaveS3Mirrors(kind, mirrors) {
|
|
65427
|
+
const { config: config2 } = await configManager.load();
|
|
65428
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65429
|
+
const cleaned = mirrors.filter((mirror) => mirror.connectionId.trim().length > 0).map((mirror) => ({
|
|
65430
|
+
connectionId: mirror.connectionId.trim(),
|
|
65431
|
+
...mirror.prefix !== void 0 && mirror.prefix.trim().length > 0 ? { prefix: mirror.prefix.trim() } : {},
|
|
65432
|
+
...mirror.enabled === true ? { enabled: true } : {},
|
|
65433
|
+
...mirror.publish === true ? { publish: true } : {}
|
|
65434
|
+
}));
|
|
65435
|
+
if (cleaned.length === 0)
|
|
65436
|
+
delete s3[kind];
|
|
65437
|
+
else
|
|
65438
|
+
s3[kind] = cleaned;
|
|
65439
|
+
await configManager.save("user", { s3 });
|
|
65440
|
+
await loadSettings();
|
|
65441
|
+
if (cleaned.some((mirror) => mirror.enabled === true))
|
|
65442
|
+
await handleSyncS3(kind);
|
|
65443
|
+
else
|
|
65444
|
+
await postS3();
|
|
65445
|
+
}
|
|
65446
|
+
async function handleSyncS3(kind) {
|
|
65447
|
+
const { config: config2 } = await configManager.load();
|
|
65448
|
+
const mirrors = (config2.s3?.[kind] ?? []).filter((mirror) => mirror.enabled === true);
|
|
65449
|
+
if (mirrors.length === 0) {
|
|
65450
|
+
lastSync = { ...lastSync, [kind]: "No bucket folder is configured." };
|
|
65451
|
+
await postS3();
|
|
65452
|
+
return;
|
|
65453
|
+
}
|
|
65454
|
+
const lines = [];
|
|
65455
|
+
for (const mirror of mirrors) {
|
|
65456
|
+
const target = targetById(cachedS3, mirror.connectionId);
|
|
65457
|
+
const where = `${mirror.connectionId}/${mirror.prefix ?? ""}`;
|
|
65458
|
+
if (target === void 0) {
|
|
65459
|
+
lines.push(`${where}: connection unusable - check its key above`);
|
|
65460
|
+
continue;
|
|
65461
|
+
}
|
|
65462
|
+
const localDir = mirrorFolder({
|
|
65463
|
+
storageDir,
|
|
65464
|
+
connectionId: mirror.connectionId,
|
|
65465
|
+
kind,
|
|
65466
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
65467
|
+
});
|
|
65468
|
+
try {
|
|
65469
|
+
const result = await syncFromS3({
|
|
65470
|
+
target,
|
|
65471
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
65472
|
+
localDir,
|
|
65473
|
+
fs: new NodeFileSystem(),
|
|
65474
|
+
extensions: kind === "skills" ? [".md"] : [".py"]
|
|
65475
|
+
});
|
|
65476
|
+
const parts = [
|
|
65477
|
+
`${String(result.written.length)} updated`,
|
|
65478
|
+
`${String(result.unchanged)} unchanged`
|
|
65479
|
+
];
|
|
65480
|
+
if (result.failed.length > 0)
|
|
65481
|
+
parts.push(`${String(result.failed.length)} failed`);
|
|
65482
|
+
lines.push(`${target.label}${mirror.prefix === void 0 ? "" : `/${mirror.prefix}`}: ${parts.join(", ")}`);
|
|
65483
|
+
for (const failure of result.failed) {
|
|
65484
|
+
logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
|
|
65485
|
+
}
|
|
65486
|
+
} catch (error51) {
|
|
65487
|
+
lines.push(`${target.label}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
65488
|
+
}
|
|
65489
|
+
}
|
|
65490
|
+
lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${lines.join("; ")}` };
|
|
65491
|
+
if (kind === "skills") {
|
|
65492
|
+
await refreshSkills();
|
|
65493
|
+
postSkills();
|
|
65494
|
+
}
|
|
65495
|
+
await postS3();
|
|
65496
|
+
}
|
|
65173
65497
|
async function handleSaveSkillsAlias(aliases) {
|
|
65174
65498
|
try {
|
|
65175
65499
|
const { config: config2 } = await configManager.load();
|
|
@@ -66736,6 +67060,13 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66736
67060
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
66737
67061
|
}
|
|
66738
67062
|
}
|
|
67063
|
+
function reportFailure(operation, work) {
|
|
67064
|
+
work.catch((error51) => {
|
|
67065
|
+
const reason = error51 instanceof Error ? error51.message : String(error51);
|
|
67066
|
+
logger.warn(`${operation} failed`, reason);
|
|
67067
|
+
post({ type: "error", message: `${operation} failed: ${reason}` });
|
|
67068
|
+
});
|
|
67069
|
+
}
|
|
66739
67070
|
const unsubscribe = transport.onMessage((raw) => {
|
|
66740
67071
|
const message3 = raw;
|
|
66741
67072
|
if (message3.type === "sendMessage") {
|
|
@@ -66756,9 +67087,12 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66756
67087
|
}
|
|
66757
67088
|
})();
|
|
66758
67089
|
} else if (message3.type === "requestMentionCandidates") {
|
|
66759
|
-
|
|
67090
|
+
reportFailure("handleMentionCandidates", handleMentionCandidates(message3.query));
|
|
66760
67091
|
} else if (message3.type === "queueMessage") {
|
|
66761
|
-
queuedMessages.push(
|
|
67092
|
+
queuedMessages.push({
|
|
67093
|
+
text: message3.text,
|
|
67094
|
+
...message3.images !== void 0 && message3.images.length > 0 ? { images: message3.images } : {}
|
|
67095
|
+
});
|
|
66762
67096
|
postQueued();
|
|
66763
67097
|
} else if (message3.type === "unqueueMessage") {
|
|
66764
67098
|
queuedMessages.splice(message3.index, 1);
|
|
@@ -66779,21 +67113,21 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66779
67113
|
pendingFormFields.delete(message3.id);
|
|
66780
67114
|
}
|
|
66781
67115
|
} else if (message3.type === "approvalResponseAlways") {
|
|
66782
|
-
|
|
67116
|
+
reportFailure("handleAlwaysAllow", handleAlwaysAllow(message3.id, message3.scope));
|
|
66783
67117
|
} else if (message3.type === "rollback") {
|
|
66784
|
-
|
|
67118
|
+
reportFailure("handleRollback", handleRollback());
|
|
66785
67119
|
} else if (message3.type === "requestSettings") {
|
|
66786
|
-
|
|
67120
|
+
reportFailure("postSettings", postSettings());
|
|
66787
67121
|
} else if (message3.type === "requestTasks") {
|
|
66788
|
-
|
|
67122
|
+
reportFailure("postTasks", postTasks());
|
|
66789
67123
|
} else if (message3.type === "openTask") {
|
|
66790
|
-
|
|
67124
|
+
reportFailure("openTask", openTask(message3.id));
|
|
66791
67125
|
} else if (message3.type === "deleteTask") {
|
|
66792
|
-
|
|
67126
|
+
reportFailure("deleteTask", deleteTask(message3.id));
|
|
66793
67127
|
} else if (message3.type === "newTask") {
|
|
66794
|
-
|
|
67128
|
+
reportFailure("startNewTask", startNewTask());
|
|
66795
67129
|
} else if (message3.type === "setMode") {
|
|
66796
|
-
|
|
67130
|
+
reportFailure("handleSetMode", handleSetMode(message3.modeId));
|
|
66797
67131
|
} else if (message3.type === "setMaxIterations") {
|
|
66798
67132
|
void configManager.save("user", { maxIterations: message3.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66799
67133
|
} else if (message3.type === "setProgrammingProfile") {
|
|
@@ -66821,7 +67155,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66821
67155
|
}
|
|
66822
67156
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66823
67157
|
} else if (message3.type === "setToolTimeoutFor") {
|
|
66824
|
-
|
|
67158
|
+
reportFailure("handleSetToolTimeoutFor", handleSetToolTimeoutFor(message3.name, message3.seconds));
|
|
66825
67159
|
} else if (message3.type === "setToolTimeout") {
|
|
66826
67160
|
void configManager.save("user", {
|
|
66827
67161
|
tools: message3.seconds === void 0 ? {} : { timeoutSeconds: message3.seconds }
|
|
@@ -66843,73 +67177,73 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66843
67177
|
}
|
|
66844
67178
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66845
67179
|
} else if (message3.type === "setAutoApprove") {
|
|
66846
|
-
|
|
67180
|
+
reportFailure("handleSetAutoApprove", handleSetAutoApprove(message3.group, message3.enabled));
|
|
66847
67181
|
} else if (message3.type === "revokeAllowedTool") {
|
|
66848
|
-
|
|
67182
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66849
67183
|
...cachedApprovals,
|
|
66850
67184
|
allowedTools: removeFromAllowlist(message3.toolName, cachedApprovals.allowedTools ?? [])
|
|
66851
|
-
});
|
|
67185
|
+
}));
|
|
66852
67186
|
} else if (message3.type === "revokeAllowedCommand") {
|
|
66853
|
-
|
|
67187
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66854
67188
|
...cachedApprovals,
|
|
66855
67189
|
allowedCommands: removeFromAllowlist(message3.command, cachedApprovals.allowedCommands ?? [])
|
|
66856
|
-
});
|
|
67190
|
+
}));
|
|
66857
67191
|
} else if (message3.type === "requestMcp") {
|
|
66858
|
-
|
|
67192
|
+
reportFailure("handleRequestMcp", handleRequestMcp());
|
|
66859
67193
|
} else if (message3.type === "saveMcpServers") {
|
|
66860
|
-
|
|
67194
|
+
reportFailure("handleSaveMcpServers", handleSaveMcpServers(message3.json));
|
|
66861
67195
|
} else if (message3.type === "saveMcpServer") {
|
|
66862
|
-
|
|
67196
|
+
reportFailure("handleSaveMcpServer", handleSaveMcpServer(message3.name, message3.previousName, message3.config));
|
|
66863
67197
|
} else if (message3.type === "duplicateMcpServer") {
|
|
66864
|
-
|
|
67198
|
+
reportFailure("handleDuplicateMcpServer", handleDuplicateMcpServer(message3.name));
|
|
66865
67199
|
} else if (message3.type === "deleteMcpServer") {
|
|
66866
|
-
|
|
67200
|
+
reportFailure("handleDeleteMcpServer", handleDeleteMcpServer(message3.name));
|
|
66867
67201
|
} else if (message3.type === "browseForPath") {
|
|
66868
|
-
|
|
67202
|
+
reportFailure("handleBrowseForPath", handleBrowseForPath(message3.purpose, message3.kind, message3.extensions));
|
|
66869
67203
|
} else if (message3.type === "probePythonEnv") {
|
|
66870
|
-
|
|
67204
|
+
reportFailure("handleProbePythonEnv", handleProbePythonEnv(message3.venvDir, message3.script));
|
|
66871
67205
|
} else if (message3.type === "connectMcpServer") {
|
|
66872
67206
|
void mcp.connectServer(message3.name);
|
|
66873
67207
|
} else if (message3.type === "restartMcpServer") {
|
|
66874
67208
|
void mcp.restart(message3.name);
|
|
66875
67209
|
} else if (message3.type === "setMcpServerEnabled") {
|
|
66876
|
-
|
|
67210
|
+
reportFailure("updateMcpServer", updateMcpServer(message3.name, (entry) => ({
|
|
66877
67211
|
...entry,
|
|
66878
67212
|
disabled: !message3.enabled
|
|
66879
|
-
})).then(() => postMcp());
|
|
67213
|
+
})).then(() => postMcp()));
|
|
66880
67214
|
} else if (message3.type === "setMcpToolTimeout") {
|
|
66881
|
-
|
|
67215
|
+
reportFailure("handleSetToolTimeout", handleSetToolTimeout(message3.server, message3.tool, message3.seconds));
|
|
66882
67216
|
} else if (message3.type === "setMcpToolPermission") {
|
|
66883
|
-
|
|
67217
|
+
reportFailure("handleSetToolPermission", handleSetToolPermission(message3.server, message3.tool, message3.permission));
|
|
66884
67218
|
} else if (message3.type === "requestSearch") {
|
|
66885
|
-
|
|
66886
|
-
|
|
67219
|
+
reportFailure("postSearch", postSearch());
|
|
67220
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66887
67221
|
post({ type: "searchLog", entries: [...searchLog.list()] });
|
|
66888
67222
|
} else if (message3.type === "saveSearchConnection") {
|
|
66889
|
-
|
|
67223
|
+
reportFailure("handleSaveSearchConnection", handleSaveSearchConnection(message3.connection));
|
|
66890
67224
|
} else if (message3.type === "deleteSearchConnection") {
|
|
66891
|
-
|
|
67225
|
+
reportFailure("handleDeleteSearchConnection", handleDeleteSearchConnection(message3.id));
|
|
66892
67226
|
} else if (message3.type === "setActiveSearchConnection") {
|
|
66893
67227
|
void (message3.forProject === true ? configManager.saveForWorkspace({ activeVectorStoreId: message3.id }) : configManager.save("user", { activeVectorStoreId: message3.id })).then(async () => {
|
|
66894
67228
|
await postSearch();
|
|
66895
67229
|
await postProjectSettings();
|
|
66896
67230
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66897
67231
|
} else if (message3.type === "requestProjectSettings") {
|
|
66898
|
-
|
|
67232
|
+
reportFailure("postProjectSettings", postProjectSettings());
|
|
66899
67233
|
} else if (message3.type === "clearProjectSettings") {
|
|
66900
|
-
|
|
67234
|
+
reportFailure("handleClearProjectSettings", handleClearProjectSettings());
|
|
66901
67235
|
} else if (message3.type === "requestSearchIndexes") {
|
|
66902
|
-
|
|
67236
|
+
reportFailure("handleRequestSearchIndexes", handleRequestSearchIndexes(message3.connection));
|
|
66903
67237
|
} else if (message3.type === "testSearchConnection") {
|
|
66904
|
-
|
|
67238
|
+
reportFailure("handleTestSearchConnection", handleTestSearchConnection(message3.connection));
|
|
66905
67239
|
} else if (message3.type === "syncVectorStore") {
|
|
66906
|
-
|
|
67240
|
+
reportFailure("handleSyncVectorStore", handleSyncVectorStore(message3.fromId));
|
|
66907
67241
|
} else if (message3.type === "clearDocsIndex") {
|
|
66908
|
-
|
|
67242
|
+
reportFailure("handleClearDocsIndex", handleClearDocsIndex(message3.kind));
|
|
66909
67243
|
} else if (message3.type === "clearCodebaseIndex") {
|
|
66910
|
-
|
|
67244
|
+
reportFailure("handleClearCodebaseIndex", handleClearCodebaseIndex());
|
|
66911
67245
|
} else if (message3.type === "openStandingSkill") {
|
|
66912
|
-
|
|
67246
|
+
reportFailure("handleOpenStandingSkill", handleOpenStandingSkill());
|
|
66913
67247
|
} else if (message3.type === "setOffice") {
|
|
66914
67248
|
void configManager.load().then(async () => {
|
|
66915
67249
|
await configManager.save("user", {
|
|
@@ -66923,70 +67257,80 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66923
67257
|
}
|
|
66924
67258
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66925
67259
|
} else if (message3.type === "indexDocs") {
|
|
66926
|
-
|
|
67260
|
+
reportFailure("handleIndexDocs", handleIndexDocs(message3.kind));
|
|
66927
67261
|
} else if (message3.type === "runSearchProbe") {
|
|
66928
|
-
|
|
67262
|
+
reportFailure("handleSearchProbe", handleSearchProbe(message3.query, message3.target));
|
|
66929
67263
|
} else if (message3.type === "clearSearchLog") {
|
|
66930
67264
|
searchLog.clear();
|
|
66931
67265
|
} else if (message3.type === "setDispatcher") {
|
|
66932
|
-
|
|
66933
|
-
|
|
67266
|
+
reportFailure("saveRetrieval", saveRetrieval({ dispatcher: message3.enabled }).then(() => {
|
|
67267
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66934
67268
|
if (message3.enabled)
|
|
66935
67269
|
scheduleDocsReindex("dispatcher enabled");
|
|
66936
|
-
})
|
|
67270
|
+
}));
|
|
66937
67271
|
} else if (message3.type === "setSkillRetrieval") {
|
|
66938
|
-
|
|
66939
|
-
|
|
67272
|
+
reportFailure("saveRetrieval", saveRetrieval({ skills: message3.enabled }).then(() => {
|
|
67273
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66940
67274
|
if (message3.enabled)
|
|
66941
67275
|
scheduleDocsReindex("skill retrieval enabled");
|
|
66942
|
-
})
|
|
67276
|
+
}));
|
|
66943
67277
|
} else if (message3.type === "startIndexing") {
|
|
66944
|
-
|
|
67278
|
+
reportFailure("handleStartIndexing", handleStartIndexing());
|
|
66945
67279
|
} else if (message3.type === "attachTeamAlias") {
|
|
66946
|
-
|
|
67280
|
+
reportFailure("handleAttachTeamAlias", handleAttachTeamAlias());
|
|
66947
67281
|
} else if (message3.type === "publishTeamSkills") {
|
|
66948
|
-
|
|
67282
|
+
reportFailure("handlePublishTeamSkills", handlePublishTeamSkills());
|
|
66949
67283
|
} else if (message3.type === "syncMail") {
|
|
66950
|
-
|
|
67284
|
+
reportFailure("runMailSync", runMailSync("requested"));
|
|
66951
67285
|
} else if (message3.type === "pruneMail") {
|
|
66952
|
-
|
|
67286
|
+
reportFailure("handlePruneMail", handlePruneMail());
|
|
66953
67287
|
} else if (message3.type === "requestOutlookFolders") {
|
|
66954
|
-
|
|
67288
|
+
reportFailure("handleRequestOutlookFolders", handleRequestOutlookFolders(message3.depth, message3.force === true));
|
|
66955
67289
|
} else if (message3.type === "validateMailFolder") {
|
|
66956
|
-
|
|
67290
|
+
reportFailure("handleValidateMailFolder", handleValidateMailFolder(message3.path));
|
|
66957
67291
|
} else if (message3.type === "requestMailStatus") {
|
|
66958
|
-
|
|
67292
|
+
reportFailure("loadSettings", loadSettings().then((config2) => {
|
|
66959
67293
|
reconcileMailTimer(config2);
|
|
66960
67294
|
reconcileDatasetTimers(config2);
|
|
66961
67295
|
return postMailStatus();
|
|
66962
|
-
});
|
|
67296
|
+
}));
|
|
66963
67297
|
} else if (message3.type === "saveMailSettings") {
|
|
66964
|
-
|
|
67298
|
+
reportFailure("handleSaveMailSettings", handleSaveMailSettings({
|
|
66965
67299
|
enabled: message3.enabled,
|
|
66966
67300
|
folders: message3.folders,
|
|
66967
67301
|
includeSubfolders: message3.includeSubfolders,
|
|
66968
67302
|
syncMinutes: message3.syncMinutes,
|
|
66969
67303
|
retentionMonths: message3.retentionMonths,
|
|
66970
67304
|
...message3.storeId !== void 0 ? { storeId: message3.storeId } : {}
|
|
66971
|
-
});
|
|
67305
|
+
}));
|
|
66972
67306
|
} else if (message3.type === "clearTeamSkills") {
|
|
66973
|
-
|
|
67307
|
+
reportFailure("handleClearTeamSkills", handleClearTeamSkills());
|
|
66974
67308
|
} else if (message3.type === "refreshMail") {
|
|
66975
|
-
|
|
67309
|
+
reportFailure("handleRefreshMail", handleRefreshMail(message3.days));
|
|
66976
67310
|
} else if (message3.type === "requestDatasetStatus") {
|
|
66977
|
-
|
|
67311
|
+
reportFailure("postDatasetStatus", postDatasetStatus());
|
|
66978
67312
|
} else if (message3.type === "saveDataset") {
|
|
66979
|
-
|
|
67313
|
+
reportFailure("handleSaveDataset", handleSaveDataset(message3.dataset));
|
|
66980
67314
|
} else if (message3.type === "deleteDataset") {
|
|
66981
|
-
|
|
67315
|
+
reportFailure("handleDeleteDataset", handleDeleteDataset(message3.id));
|
|
66982
67316
|
} else if (message3.type === "syncDataset") {
|
|
66983
|
-
|
|
67317
|
+
reportFailure("runDatasetSync", runDatasetSync(message3.id, "manual"));
|
|
66984
67318
|
} else if (message3.type === "clearDataset") {
|
|
66985
|
-
|
|
67319
|
+
reportFailure("handleClearDataset", handleClearDataset(message3.id, message3.resync === true));
|
|
66986
67320
|
} else if (message3.type === "clearMailIndex") {
|
|
66987
|
-
|
|
67321
|
+
reportFailure("handleClearMailIndex", handleClearMailIndex(message3.resync === true));
|
|
67322
|
+
} else if (message3.type === "requestS3") {
|
|
67323
|
+
reportFailure("postS3", postS3());
|
|
67324
|
+
} else if (message3.type === "saveS3Connection") {
|
|
67325
|
+
reportFailure("handleSaveS3Connection", handleSaveS3Connection(message3.connection, message3.secret, message3.sessionToken));
|
|
67326
|
+
} else if (message3.type === "deleteS3Connection") {
|
|
67327
|
+
reportFailure("handleDeleteS3Connection", handleDeleteS3Connection(message3.id));
|
|
67328
|
+
} else if (message3.type === "saveS3Mirrors") {
|
|
67329
|
+
reportFailure("handleSaveS3Mirrors", handleSaveS3Mirrors(message3.kind, message3.mirrors));
|
|
67330
|
+
} else if (message3.type === "syncS3") {
|
|
67331
|
+
reportFailure("handleSyncS3", handleSyncS3(message3.kind));
|
|
66988
67332
|
} else if (message3.type === "saveSkillsAlias") {
|
|
66989
|
-
|
|
67333
|
+
reportFailure("handleSaveSkillsAlias", handleSaveSkillsAlias(message3.aliases));
|
|
66990
67334
|
} else if (message3.type === "cancelIndexing") {
|
|
66991
67335
|
if (message3.kind === void 0) {
|
|
66992
67336
|
indexingAbort?.abort();
|
|
@@ -66998,23 +67342,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66998
67342
|
indexingAborts.get(message3.kind)?.abort();
|
|
66999
67343
|
}
|
|
67000
67344
|
} else if (message3.type === "saveEmbedder") {
|
|
67001
|
-
|
|
67345
|
+
reportFailure("handleSaveEmbedder", handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases));
|
|
67002
67346
|
} else if (message3.type === "requestEmbedderModels") {
|
|
67003
|
-
|
|
67347
|
+
reportFailure("handleRequestEmbedderModels", handleRequestEmbedderModels(message3.profileId));
|
|
67004
67348
|
} else if (message3.type === "openWalkthrough") {
|
|
67005
67349
|
void ui.openWalkthrough?.();
|
|
67006
67350
|
} else if (message3.type === "requestTools") {
|
|
67007
|
-
|
|
67351
|
+
reportFailure("postTools", postTools());
|
|
67008
67352
|
} else if (message3.type === "requestSchedules") {
|
|
67009
|
-
|
|
67353
|
+
reportFailure("postSchedules", postSchedules());
|
|
67010
67354
|
} else if (message3.type === "saveSchedule") {
|
|
67011
|
-
|
|
67355
|
+
reportFailure("handleSaveSchedule", handleSaveSchedule(message3.schedule));
|
|
67012
67356
|
} else if (message3.type === "duplicateSchedule") {
|
|
67013
|
-
|
|
67357
|
+
reportFailure("handleDuplicateSchedule", handleDuplicateSchedule(message3.id));
|
|
67014
67358
|
} else if (message3.type === "deleteSchedule") {
|
|
67015
|
-
|
|
67359
|
+
reportFailure("handleDeleteSchedule", handleDeleteSchedule(message3.id));
|
|
67016
67360
|
} else if (message3.type === "setScheduleEnabled") {
|
|
67017
|
-
|
|
67361
|
+
reportFailure("handleSetScheduleEnabled", handleSetScheduleEnabled(message3.id, message3.enabled));
|
|
67018
67362
|
} else if (message3.type === "setTaskExpertLimits") {
|
|
67019
67363
|
const next = message3.maxSpendUsd === void 0 && message3.maxConsultations === void 0 ? void 0 : {
|
|
67020
67364
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
@@ -67044,7 +67388,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67044
67388
|
await postExpert({ redetect: false });
|
|
67045
67389
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
67046
67390
|
} else if (message3.type === "measureExpertCost") {
|
|
67047
|
-
|
|
67391
|
+
reportFailure("handleMeasureExpertCost", handleMeasureExpertCost());
|
|
67048
67392
|
} else if (message3.type === "clearExpertPricing") {
|
|
67049
67393
|
void configManager.load().then(async ({ config: config2 }) => {
|
|
67050
67394
|
const expert = { ...config2.expert };
|
|
@@ -67054,23 +67398,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67054
67398
|
await postExpert({ redetect: false });
|
|
67055
67399
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
67056
67400
|
} else if (message3.type === "assessJunior") {
|
|
67057
|
-
|
|
67401
|
+
reportFailure("handleAssessJunior", handleAssessJunior(message3.profileId));
|
|
67058
67402
|
} else if (message3.type === "clearAssessment") {
|
|
67059
|
-
|
|
67403
|
+
reportFailure("handleClearAssessment", handleClearAssessment(message3.model, message3.profileLabel));
|
|
67060
67404
|
} else if (message3.type === "restartScheduler") {
|
|
67061
67405
|
restartScheduleTimer();
|
|
67062
67406
|
logger.info("schedule timer restarted by the user");
|
|
67063
|
-
|
|
67407
|
+
reportFailure("postSchedules", postSchedules());
|
|
67064
67408
|
} else if (message3.type === "deleteScheduleRun") {
|
|
67065
|
-
|
|
67409
|
+
reportFailure("handleDeleteScheduleRun", handleDeleteScheduleRun(message3.id, message3.at));
|
|
67066
67410
|
} else if (message3.type === "clearScheduleRuns") {
|
|
67067
|
-
|
|
67411
|
+
reportFailure("handleClearScheduleRuns", handleClearScheduleRuns(message3.id));
|
|
67068
67412
|
} else if (message3.type === "openScheduleRun") {
|
|
67069
|
-
|
|
67413
|
+
reportFailure("openRunTranscript", openRunTranscript(message3.taskId, message3.title));
|
|
67070
67414
|
} else if (message3.type === "runScheduleNow") {
|
|
67071
|
-
|
|
67415
|
+
reportFailure("runSchedule", runSchedule(message3.id, "manual"));
|
|
67072
67416
|
} else if (message3.type === "requestSkills") {
|
|
67073
|
-
|
|
67417
|
+
reportFailure("postSkills", postSkills());
|
|
67074
67418
|
} else if (message3.type === "saveSkillDirs") {
|
|
67075
67419
|
void configManager.save("user", {
|
|
67076
67420
|
skills: {
|
|
@@ -67079,32 +67423,32 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67079
67423
|
}
|
|
67080
67424
|
}).then(() => postSkills()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
67081
67425
|
} else if (message3.type === "openManagedFile") {
|
|
67082
|
-
|
|
67426
|
+
reportFailure("handleOpenManagedFile", handleOpenManagedFile(message3.path));
|
|
67083
67427
|
} else if (message3.type === "deletePythonTool") {
|
|
67084
|
-
|
|
67428
|
+
reportFailure("handleDeletePythonTool", handleDeletePythonTool(message3.name));
|
|
67085
67429
|
} else if (message3.type === "approvePythonTool") {
|
|
67086
|
-
|
|
67430
|
+
reportFailure("handleApprovePythonTool", handleApprovePythonTool(message3.name));
|
|
67087
67431
|
} else if (message3.type === "deleteSkillFile") {
|
|
67088
|
-
|
|
67432
|
+
reportFailure("handleDeleteSkillFile", handleDeleteSkillFile(message3.name));
|
|
67089
67433
|
} else if (message3.type === "requestPython") {
|
|
67090
|
-
|
|
67434
|
+
reportFailure("postPython", postPython());
|
|
67091
67435
|
} else if (message3.type === "setPython") {
|
|
67092
|
-
|
|
67436
|
+
reportFailure("handleSetPython", handleSetPython(message3));
|
|
67093
67437
|
} else if (message3.type === "requestNetwork") {
|
|
67094
|
-
|
|
67438
|
+
reportFailure("postNetwork", postNetwork());
|
|
67095
67439
|
} else if (message3.type === "saveNetwork") {
|
|
67096
|
-
|
|
67440
|
+
reportFailure("handleSaveNetwork", handleSaveNetwork(message3.settings));
|
|
67097
67441
|
} else if (message3.type === "requestExpert") {
|
|
67098
|
-
|
|
67442
|
+
reportFailure("postExpert", postExpert());
|
|
67099
67443
|
} else if (message3.type === "setPlan") {
|
|
67100
|
-
|
|
67444
|
+
reportFailure("applyPlan", applyPlan(message3.plan));
|
|
67101
67445
|
} else if (message3.type === "requestPlan") {
|
|
67102
67446
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
67103
67447
|
postPlanProgress();
|
|
67104
67448
|
} else if (message3.type === "requestPlanProgress") {
|
|
67105
67449
|
postPlanProgress();
|
|
67106
67450
|
} else if (message3.type === "requestAgents") {
|
|
67107
|
-
|
|
67451
|
+
reportFailure("postAgents", postAgents());
|
|
67108
67452
|
} else if (message3.type === "setAgentRole") {
|
|
67109
67453
|
const assignment = message3.assignment;
|
|
67110
67454
|
const role = message3.role;
|
|
@@ -67112,7 +67456,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67112
67456
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67113
67457
|
return;
|
|
67114
67458
|
}
|
|
67115
|
-
|
|
67459
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67116
67460
|
const roles = { ...current.roles ?? {} };
|
|
67117
67461
|
if (assignment === void 0)
|
|
67118
67462
|
delete roles[role];
|
|
@@ -67124,7 +67468,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67124
67468
|
};
|
|
67125
67469
|
}
|
|
67126
67470
|
return { ...current, roles };
|
|
67127
|
-
});
|
|
67471
|
+
}));
|
|
67128
67472
|
} else if (message3.type === "setAgentPrompt") {
|
|
67129
67473
|
const role = message3.role;
|
|
67130
67474
|
const prompt = message3.prompt;
|
|
@@ -67132,7 +67476,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67132
67476
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67133
67477
|
return;
|
|
67134
67478
|
}
|
|
67135
|
-
|
|
67479
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67136
67480
|
const roles = { ...current.roles ?? {} };
|
|
67137
67481
|
const existing = roles[role];
|
|
67138
67482
|
if (prompt === void 0 || prompt === defaultPromptFor(role)) {
|
|
@@ -67145,31 +67489,31 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67145
67489
|
roles[role] = { ...existing ?? { kind: "profile" }, prompt };
|
|
67146
67490
|
}
|
|
67147
67491
|
return { ...current, roles };
|
|
67148
|
-
});
|
|
67492
|
+
}));
|
|
67149
67493
|
} else if (message3.type === "setAgentBudget") {
|
|
67150
67494
|
const matters = message3.matters;
|
|
67151
|
-
|
|
67495
|
+
reportFailure("saveAgents", saveAgents((current) => ({ ...current, budgetMatters: matters })));
|
|
67152
67496
|
} else if (message3.type === "setTeamGuidance") {
|
|
67153
67497
|
const guidance = message3.guidance;
|
|
67154
|
-
|
|
67498
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67155
67499
|
if (guidance === void 0 || guidance.trim().length === 0 || guidance === DEFAULT_TEAM_GUIDANCE) {
|
|
67156
67500
|
const rest = { ...current };
|
|
67157
67501
|
delete rest.teamGuidance;
|
|
67158
67502
|
return rest;
|
|
67159
67503
|
}
|
|
67160
67504
|
return { ...current, teamGuidance: guidance };
|
|
67161
|
-
});
|
|
67505
|
+
}));
|
|
67162
67506
|
} else if (message3.type === "saveCustomRole") {
|
|
67163
|
-
|
|
67507
|
+
reportFailure("handleSaveCustomRole", handleSaveCustomRole(message3));
|
|
67164
67508
|
} else if (message3.type === "deleteCustomRole") {
|
|
67165
|
-
|
|
67509
|
+
reportFailure("handleDeleteCustomRole", handleDeleteCustomRole(message3.id));
|
|
67166
67510
|
} else if (message3.type === "setRoleThinking") {
|
|
67167
67511
|
const role = message3.role;
|
|
67168
67512
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67169
67513
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67170
67514
|
return;
|
|
67171
67515
|
}
|
|
67172
|
-
|
|
67516
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67173
67517
|
const roles = { ...current.roles ?? {} };
|
|
67174
67518
|
const existing = roles[role] ?? { kind: "profile" };
|
|
67175
67519
|
if (message3.level === void 0) {
|
|
@@ -67180,79 +67524,79 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
67180
67524
|
roles[role] = { ...existing, thinking: message3.level };
|
|
67181
67525
|
}
|
|
67182
67526
|
return { ...current, roles };
|
|
67183
|
-
});
|
|
67527
|
+
}));
|
|
67184
67528
|
} else if (message3.type === "setRoleEnabled") {
|
|
67185
67529
|
const role = message3.role;
|
|
67186
67530
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67187
67531
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67188
67532
|
return;
|
|
67189
67533
|
}
|
|
67190
|
-
|
|
67534
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67191
67535
|
const roles = { ...current.roles ?? {} };
|
|
67192
67536
|
roles[role] = {
|
|
67193
67537
|
...roles[role] ?? { kind: "profile" },
|
|
67194
67538
|
enabled: message3.enabled
|
|
67195
67539
|
};
|
|
67196
67540
|
return { ...current, roles };
|
|
67197
|
-
});
|
|
67541
|
+
}));
|
|
67198
67542
|
} else if (message3.type === "setRoleWrite") {
|
|
67199
67543
|
const role = message3.role;
|
|
67200
67544
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67201
67545
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67202
67546
|
return;
|
|
67203
67547
|
}
|
|
67204
|
-
|
|
67548
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67205
67549
|
const roles = { ...current.roles ?? {} };
|
|
67206
67550
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, write: message3.canWrite };
|
|
67207
67551
|
return { ...current, roles };
|
|
67208
|
-
});
|
|
67552
|
+
}));
|
|
67209
67553
|
} else if (message3.type === "setRoleTools") {
|
|
67210
67554
|
const role = message3.role;
|
|
67211
67555
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
67212
67556
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67213
67557
|
return;
|
|
67214
67558
|
}
|
|
67215
|
-
|
|
67559
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
67216
67560
|
const roles = { ...current.roles ?? {} };
|
|
67217
67561
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, tools: message3.usesTools };
|
|
67218
67562
|
return { ...current, roles };
|
|
67219
|
-
});
|
|
67563
|
+
}));
|
|
67220
67564
|
} else if (message3.type === "setAgentColor") {
|
|
67221
67565
|
const role = message3.role;
|
|
67222
67566
|
const color = message3.color;
|
|
67223
|
-
if (!
|
|
67567
|
+
if (!isColourableAgent(role, cachedAgentDefinitions)) {
|
|
67224
67568
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
67225
67569
|
return;
|
|
67226
67570
|
}
|
|
67227
|
-
|
|
67571
|
+
reportFailure("saveAgents", saveAgents((current) => ({
|
|
67228
67572
|
...current,
|
|
67229
67573
|
colors: { ...current.colors ?? {}, [role]: color }
|
|
67230
|
-
}));
|
|
67574
|
+
})));
|
|
67231
67575
|
} else if (message3.type === "setExpert") {
|
|
67232
|
-
|
|
67576
|
+
reportFailure("handleSetExpert", handleSetExpert(message3.enabled, message3.path, message3.model, {
|
|
67233
67577
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
67234
67578
|
...message3.maxConsultations !== void 0 ? { maxConsultations: message3.maxConsultations } : {},
|
|
67235
67579
|
...message3.profileId !== void 0 ? { profileId: message3.profileId } : {}
|
|
67236
|
-
});
|
|
67580
|
+
}));
|
|
67237
67581
|
} else if (message3.type === "requestProfiles") {
|
|
67238
|
-
|
|
67239
|
-
|
|
67582
|
+
reportFailure("postProfiles", postProfiles());
|
|
67583
|
+
reportFailure("postCapabilities", postCapabilities());
|
|
67240
67584
|
} else if (message3.type === "saveProfile") {
|
|
67241
|
-
|
|
67585
|
+
reportFailure("handleSaveProfile", handleSaveProfile(message3.profile));
|
|
67242
67586
|
} else if (message3.type === "requestModels") {
|
|
67243
|
-
|
|
67587
|
+
reportFailure("handleRequestModels", handleRequestModels(message3.profile));
|
|
67244
67588
|
} else if (message3.type === "testConnection") {
|
|
67245
|
-
|
|
67589
|
+
reportFailure("handleTestConnection", handleTestConnection(message3.profile));
|
|
67246
67590
|
} else if (message3.type === "duplicateProfile") {
|
|
67247
|
-
|
|
67591
|
+
reportFailure("handleDuplicateProfile", handleDuplicateProfile(message3.id));
|
|
67248
67592
|
} else if (message3.type === "deleteProfile") {
|
|
67249
|
-
|
|
67593
|
+
reportFailure("handleDeleteProfile", handleDeleteProfile(message3.id));
|
|
67250
67594
|
} else if (message3.type === "setActiveProfile") {
|
|
67251
|
-
|
|
67595
|
+
reportFailure("handleSetActiveProfile", handleSetActiveProfile(message3.id, message3.forProject));
|
|
67252
67596
|
} else if (message3.type === "exportConfig") {
|
|
67253
|
-
|
|
67597
|
+
reportFailure("handleExportConfig", handleExportConfig());
|
|
67254
67598
|
} else if (message3.type === "importConfig") {
|
|
67255
|
-
|
|
67599
|
+
reportFailure("handleImportConfig", handleImportConfig());
|
|
67256
67600
|
}
|
|
67257
67601
|
});
|
|
67258
67602
|
void (async () => {
|
|
@@ -67767,6 +68111,8 @@ ${contents}
|
|
|
67767
68111
|
}
|
|
67768
68112
|
await postTasks();
|
|
67769
68113
|
await postSettings();
|
|
68114
|
+
await postProfiles();
|
|
68115
|
+
await postS3();
|
|
67770
68116
|
await postSchedules();
|
|
67771
68117
|
} catch (error51) {
|
|
67772
68118
|
logger.warn(`Could not resync the view: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -67829,6 +68175,10 @@ function deriveTitle(messages) {
|
|
|
67829
68175
|
return `${cut.trimEnd()}\u2026`;
|
|
67830
68176
|
}
|
|
67831
68177
|
|
|
68178
|
+
// ../../packages/core/dist/display/size.js
|
|
68179
|
+
var DISPLAY_SIZES = ["small", "medium", "large", "full"];
|
|
68180
|
+
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.";
|
|
68181
|
+
|
|
67832
68182
|
// ../../packages/core/dist/charts/types.js
|
|
67833
68183
|
var CHART_TYPES = ["bar", "stackedBar", "groupedBar", "line", "multiLine", "pie"];
|
|
67834
68184
|
var MAX_CATEGORIES = 200;
|
|
@@ -67851,6 +68201,8 @@ var chartSpecSchema = external_exports.object({
|
|
|
67851
68201
|
title: external_exports.string().max(200).optional(),
|
|
67852
68202
|
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."),
|
|
67853
68203
|
series: external_exports.array(chartSeriesSchema).min(1).max(MAX_SERIES),
|
|
68204
|
+
/** See `display/size.ts` — the same field and the same words as a diagram's. */
|
|
68205
|
+
size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
|
|
67854
68206
|
xLabel: external_exports.string().max(80).optional(),
|
|
67855
68207
|
yLabel: external_exports.string().max(80).optional(),
|
|
67856
68208
|
note: external_exports.string().max(500).optional().describe("A line under the chart. Say where the numbers came from, and what they exclude.")
|
|
@@ -67971,6 +68323,8 @@ var diagramSpecSchema = external_exports.object({
|
|
|
67971
68323
|
title: external_exports.string().max(120).optional(),
|
|
67972
68324
|
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."),
|
|
67973
68325
|
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."),
|
|
68326
|
+
/** See `display/size.ts` — the same field and the same words as a chart's. */
|
|
68327
|
+
size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
|
|
67974
68328
|
direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
|
|
67975
68329
|
nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
|
|
67976
68330
|
edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
|
|
@@ -68112,7 +68466,7 @@ function toolCallSummary(call, outcome) {
|
|
|
68112
68466
|
function consultationFromToolCall(name, rawArguments) {
|
|
68113
68467
|
const call = throughDispatch(name, rawArguments);
|
|
68114
68468
|
if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
|
|
68115
|
-
return "
|
|
68469
|
+
return "claude";
|
|
68116
68470
|
if (call.name !== "ask_agent")
|
|
68117
68471
|
return void 0;
|
|
68118
68472
|
const decoded = call.args;
|
|
@@ -69680,6 +70034,570 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
69680
70034
|
};
|
|
69681
70035
|
}
|
|
69682
70036
|
|
|
70037
|
+
// ../../packages/core/dist/s3/sigv4.js
|
|
70038
|
+
import { createHash as createHash4, createHmac } from "node:crypto";
|
|
70039
|
+
var EMPTY_PAYLOAD_SHA256 = createHash4("sha256").update("").digest("hex");
|
|
70040
|
+
function encodeSegment(segment) {
|
|
70041
|
+
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
70042
|
+
}
|
|
70043
|
+
function canonicalPath(pathname) {
|
|
70044
|
+
if (pathname === "" || pathname === "/")
|
|
70045
|
+
return "/";
|
|
70046
|
+
return pathname.split("/").map((segment) => {
|
|
70047
|
+
let raw = segment;
|
|
70048
|
+
try {
|
|
70049
|
+
raw = decodeURIComponent(segment);
|
|
70050
|
+
} catch {
|
|
70051
|
+
}
|
|
70052
|
+
return encodeSegment(raw);
|
|
70053
|
+
}).join("/");
|
|
70054
|
+
}
|
|
70055
|
+
function canonicalQuery(search) {
|
|
70056
|
+
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]));
|
|
70057
|
+
return parameters.map(([name, value]) => `${name}=${value}`).join("&");
|
|
70058
|
+
}
|
|
70059
|
+
function amzDate(now) {
|
|
70060
|
+
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
70061
|
+
}
|
|
70062
|
+
function signingKey(secretAccessKey, date5, region, service) {
|
|
70063
|
+
const dateKey = createHmac("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
70064
|
+
const regionKey = createHmac("sha256", dateKey).update(region).digest();
|
|
70065
|
+
const serviceKey = createHmac("sha256", regionKey).update(service).digest();
|
|
70066
|
+
return createHmac("sha256", serviceKey).update("aws4_request").digest();
|
|
70067
|
+
}
|
|
70068
|
+
function signRequest(input) {
|
|
70069
|
+
const service = input.service ?? "s3";
|
|
70070
|
+
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
70071
|
+
const timestamp = amzDate(now);
|
|
70072
|
+
const date5 = timestamp.slice(0, 8);
|
|
70073
|
+
const url2 = new URL(input.url);
|
|
70074
|
+
const body = input.body ?? Buffer.alloc(0);
|
|
70075
|
+
const payloadHash = createHash4("sha256").update(body).digest("hex");
|
|
70076
|
+
const headers = {
|
|
70077
|
+
...input.headers,
|
|
70078
|
+
host: url2.host,
|
|
70079
|
+
"x-amz-content-sha256": payloadHash,
|
|
70080
|
+
"x-amz-date": timestamp,
|
|
70081
|
+
...input.sessionToken !== void 0 ? { "x-amz-security-token": input.sessionToken } : {}
|
|
70082
|
+
};
|
|
70083
|
+
const canonicalHeaderEntries = Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value.trim().replace(/\s+/g, " ")]).sort((a, b) => a[0].localeCompare(b[0]));
|
|
70084
|
+
const signedHeaders = canonicalHeaderEntries.map(([name]) => name).join(";");
|
|
70085
|
+
const canonicalRequest = [
|
|
70086
|
+
input.method.toUpperCase(),
|
|
70087
|
+
canonicalPath(url2.pathname),
|
|
70088
|
+
canonicalQuery(url2.search),
|
|
70089
|
+
`${canonicalHeaderEntries.map(([name, value]) => `${name}:${value}`).join("\n")}
|
|
70090
|
+
`,
|
|
70091
|
+
signedHeaders,
|
|
70092
|
+
payloadHash
|
|
70093
|
+
].join("\n");
|
|
70094
|
+
const scope = `${date5}/${input.region}/${service}/aws4_request`;
|
|
70095
|
+
const stringToSign = [
|
|
70096
|
+
"AWS4-HMAC-SHA256",
|
|
70097
|
+
timestamp,
|
|
70098
|
+
scope,
|
|
70099
|
+
createHash4("sha256").update(canonicalRequest).digest("hex")
|
|
70100
|
+
].join("\n");
|
|
70101
|
+
const signature = createHmac("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
70102
|
+
return {
|
|
70103
|
+
headers: {
|
|
70104
|
+
...headers,
|
|
70105
|
+
Authorization: `AWS4-HMAC-SHA256 Credential=${input.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
70106
|
+
},
|
|
70107
|
+
canonicalRequest,
|
|
70108
|
+
stringToSign,
|
|
70109
|
+
signature
|
|
70110
|
+
};
|
|
70111
|
+
}
|
|
70112
|
+
|
|
70113
|
+
// ../../packages/core/dist/s3/client.js
|
|
70114
|
+
var S3Client = class {
|
|
70115
|
+
http;
|
|
70116
|
+
connection;
|
|
70117
|
+
tls;
|
|
70118
|
+
constructor(http, connection, tls2) {
|
|
70119
|
+
this.http = http;
|
|
70120
|
+
this.connection = connection;
|
|
70121
|
+
this.tls = tls2;
|
|
70122
|
+
}
|
|
70123
|
+
url(call) {
|
|
70124
|
+
const { bucket, region, endpoint, pathStyle } = this.connection;
|
|
70125
|
+
const origin = new URL(endpoint ?? `https://s3.${region}.amazonaws.com`);
|
|
70126
|
+
const key = call.key ?? "";
|
|
70127
|
+
const inPath = usesPathStyle(pathStyle, origin.host);
|
|
70128
|
+
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
70129
|
+
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
70130
|
+
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
70131
|
+
const path36 = key === "" ? "" : `/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
70132
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path36}`);
|
|
70133
|
+
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
70134
|
+
url2.searchParams.set(name, value);
|
|
70135
|
+
return url2.toString();
|
|
70136
|
+
}
|
|
70137
|
+
async send(call) {
|
|
70138
|
+
const url2 = this.url(call);
|
|
70139
|
+
const signed = signRequest({
|
|
70140
|
+
method: call.method,
|
|
70141
|
+
url: url2,
|
|
70142
|
+
headers: call.headers ?? {},
|
|
70143
|
+
...call.bodyBytes !== void 0 ? { body: Buffer.from(call.bodyBytes) } : {},
|
|
70144
|
+
region: this.connection.region,
|
|
70145
|
+
accessKeyId: this.connection.accessKeyId,
|
|
70146
|
+
secretAccessKey: this.connection.secretAccessKey,
|
|
70147
|
+
...this.connection.sessionToken !== void 0 ? { sessionToken: this.connection.sessionToken } : {}
|
|
70148
|
+
});
|
|
70149
|
+
let response;
|
|
70150
|
+
try {
|
|
70151
|
+
response = await this.http.request(url2, {
|
|
70152
|
+
method: call.method,
|
|
70153
|
+
headers: signed.headers,
|
|
70154
|
+
...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
|
|
70155
|
+
...call.signal !== void 0 ? { signal: call.signal } : {},
|
|
70156
|
+
...this.tls !== void 0 ? { tls: this.tls } : {}
|
|
70157
|
+
});
|
|
70158
|
+
} catch (error51) {
|
|
70159
|
+
throw new Error(`Could not reach ${new URL(url2).host}: ${describeTlsError(error51)}`, { cause: error51 });
|
|
70160
|
+
}
|
|
70161
|
+
const bytes = await readAll(response);
|
|
70162
|
+
return { status: response.status, text: bytes.toString("utf8"), bytes };
|
|
70163
|
+
}
|
|
70164
|
+
/**
|
|
70165
|
+
* Objects under a prefix.
|
|
70166
|
+
*
|
|
70167
|
+
* Follows the continuation token rather than stopping at the first page: a folder of 1,200 files
|
|
70168
|
+
* silently reported as 1,000 is the kind of wrong answer nobody thinks to check.
|
|
70169
|
+
*/
|
|
70170
|
+
async list(prefix, limit = 1e3, signal) {
|
|
70171
|
+
const found = [];
|
|
70172
|
+
let token;
|
|
70173
|
+
while (found.length < limit) {
|
|
70174
|
+
const query = {
|
|
70175
|
+
"list-type": "2",
|
|
70176
|
+
"max-keys": String(Math.min(1e3, limit - found.length))
|
|
70177
|
+
};
|
|
70178
|
+
if (prefix !== "")
|
|
70179
|
+
query["prefix"] = prefix;
|
|
70180
|
+
if (token !== void 0)
|
|
70181
|
+
query["continuation-token"] = token;
|
|
70182
|
+
const result = await this.send({
|
|
70183
|
+
method: "GET",
|
|
70184
|
+
query,
|
|
70185
|
+
...signal !== void 0 ? { signal } : {}
|
|
70186
|
+
});
|
|
70187
|
+
if (result.status !== 200)
|
|
70188
|
+
throw new Error(describeFailure(result.status, result.text));
|
|
70189
|
+
found.push(...parseListing(result.text));
|
|
70190
|
+
token = matchTag(result.text, "NextContinuationToken");
|
|
70191
|
+
if (token === void 0)
|
|
70192
|
+
break;
|
|
70193
|
+
}
|
|
70194
|
+
return found.slice(0, limit);
|
|
70195
|
+
}
|
|
70196
|
+
async get(key, signal) {
|
|
70197
|
+
const result = await this.send({
|
|
70198
|
+
method: "GET",
|
|
70199
|
+
key,
|
|
70200
|
+
...signal !== void 0 ? { signal } : {}
|
|
70201
|
+
});
|
|
70202
|
+
if (result.status !== 200)
|
|
70203
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
70204
|
+
return result.bytes;
|
|
70205
|
+
}
|
|
70206
|
+
async put(key, bytes, contentType2, signal) {
|
|
70207
|
+
const result = await this.send({
|
|
70208
|
+
method: "PUT",
|
|
70209
|
+
key,
|
|
70210
|
+
bodyBytes: bytes,
|
|
70211
|
+
...contentType2 !== void 0 ? { headers: { "content-type": contentType2 } } : {},
|
|
70212
|
+
...signal !== void 0 ? { signal } : {}
|
|
70213
|
+
});
|
|
70214
|
+
if (result.status !== 200 && result.status !== 204) {
|
|
70215
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
70216
|
+
}
|
|
70217
|
+
}
|
|
70218
|
+
};
|
|
70219
|
+
async function readAll(response) {
|
|
70220
|
+
if (response.body === null)
|
|
70221
|
+
return Buffer.from(await response.text(), "utf8");
|
|
70222
|
+
const reader = response.body.getReader();
|
|
70223
|
+
const chunks = [];
|
|
70224
|
+
for (; ; ) {
|
|
70225
|
+
const { done, value } = await reader.read();
|
|
70226
|
+
if (done)
|
|
70227
|
+
break;
|
|
70228
|
+
if (value !== void 0)
|
|
70229
|
+
chunks.push(value);
|
|
70230
|
+
}
|
|
70231
|
+
return Buffer.concat(chunks);
|
|
70232
|
+
}
|
|
70233
|
+
function describeFailure(status, body, key) {
|
|
70234
|
+
const code = matchTag(body, "Code");
|
|
70235
|
+
const message3 = matchTag(body, "Message");
|
|
70236
|
+
const what = key === void 0 ? "" : ` for "${key}"`;
|
|
70237
|
+
if (code === void 0)
|
|
70238
|
+
return `S3 request failed${what} with status ${String(status)}.`;
|
|
70239
|
+
return `S3 ${code}${what}: ${message3 ?? `status ${String(status)}`}`;
|
|
70240
|
+
}
|
|
70241
|
+
function matchTag(xml, tag) {
|
|
70242
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(xml);
|
|
70243
|
+
return match?.[1];
|
|
70244
|
+
}
|
|
70245
|
+
function parseListing(xml) {
|
|
70246
|
+
const objects = [];
|
|
70247
|
+
for (const block of xml.split("<Contents>").slice(1)) {
|
|
70248
|
+
const key = matchTag(block, "Key");
|
|
70249
|
+
if (key === void 0)
|
|
70250
|
+
continue;
|
|
70251
|
+
objects.push({
|
|
70252
|
+
key: decodeEntities3(key),
|
|
70253
|
+
size: Number(matchTag(block, "Size") ?? "0"),
|
|
70254
|
+
lastModified: matchTag(block, "LastModified") ?? ""
|
|
70255
|
+
});
|
|
70256
|
+
}
|
|
70257
|
+
return objects;
|
|
70258
|
+
}
|
|
70259
|
+
function decodeEntities3(value) {
|
|
70260
|
+
return value.replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", '"').replaceAll("'", String.fromCharCode(39)).replaceAll("&", "&");
|
|
70261
|
+
}
|
|
70262
|
+
function usesPathStyle(configured, host) {
|
|
70263
|
+
if (configured !== void 0)
|
|
70264
|
+
return configured;
|
|
70265
|
+
return !/(^|\.)amazonaws\.com$/i.test(host);
|
|
70266
|
+
}
|
|
70267
|
+
|
|
70268
|
+
// ../../packages/core/dist/s3/keys.js
|
|
70269
|
+
function normalisePrefix(prefix) {
|
|
70270
|
+
const trimmed = (prefix ?? "").trim().replace(/^\/+/, "");
|
|
70271
|
+
if (trimmed === "")
|
|
70272
|
+
return "";
|
|
70273
|
+
return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
|
|
70274
|
+
}
|
|
70275
|
+
function confineKey(requested, prefix) {
|
|
70276
|
+
const clean = requested.trim().replace(/^\/+/, "");
|
|
70277
|
+
if (clean === "")
|
|
70278
|
+
return { ok: false, message: "No key was given." };
|
|
70279
|
+
if (clean.split("/").includes("..")) {
|
|
70280
|
+
return {
|
|
70281
|
+
ok: false,
|
|
70282
|
+
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.`
|
|
70283
|
+
};
|
|
70284
|
+
}
|
|
70285
|
+
const base = normalisePrefix(prefix);
|
|
70286
|
+
if (base === "")
|
|
70287
|
+
return { ok: true, key: clean };
|
|
70288
|
+
const key = clean.startsWith(base) ? clean : `${base}${clean}`;
|
|
70289
|
+
if (!key.startsWith(base)) {
|
|
70290
|
+
return { ok: false, message: `"${requested}" is outside "${base}", which this connection is limited to.` };
|
|
70291
|
+
}
|
|
70292
|
+
return { ok: true, key };
|
|
70293
|
+
}
|
|
70294
|
+
function displayKey(key, prefix) {
|
|
70295
|
+
const base = normalisePrefix(prefix);
|
|
70296
|
+
return base !== "" && key.startsWith(base) ? key.slice(base.length) : key;
|
|
70297
|
+
}
|
|
70298
|
+
|
|
70299
|
+
// ../../packages/core/dist/s3/resolve.js
|
|
70300
|
+
async function resolveS3(options) {
|
|
70301
|
+
const targets = [];
|
|
70302
|
+
const problems = [];
|
|
70303
|
+
for (const connection of options.config?.connections ?? []) {
|
|
70304
|
+
const secret = await options.secrets.get(connection.secretAccessKeyRef);
|
|
70305
|
+
if (secret === void 0 || secret.trim().length === 0) {
|
|
70306
|
+
problems.push({
|
|
70307
|
+
label: connection.label,
|
|
70308
|
+
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."
|
|
70309
|
+
});
|
|
70310
|
+
continue;
|
|
70311
|
+
}
|
|
70312
|
+
const sessionToken = connection.sessionTokenRef === void 0 ? void 0 : await options.secrets.get(connection.sessionTokenRef);
|
|
70313
|
+
const client = new S3Client(options.http, {
|
|
70314
|
+
bucket: connection.bucket,
|
|
70315
|
+
region: connection.region,
|
|
70316
|
+
accessKeyId: connection.accessKeyId,
|
|
70317
|
+
secretAccessKey: secret,
|
|
70318
|
+
...sessionToken !== void 0 ? { sessionToken } : {},
|
|
70319
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
70320
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {}
|
|
70321
|
+
}, options.tls);
|
|
70322
|
+
targets.push({
|
|
70323
|
+
id: connection.id,
|
|
70324
|
+
label: connection.label,
|
|
70325
|
+
bucket: connection.bucket,
|
|
70326
|
+
client,
|
|
70327
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
70328
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
70329
|
+
});
|
|
70330
|
+
}
|
|
70331
|
+
return { targets, problems };
|
|
70332
|
+
}
|
|
70333
|
+
function targetById(resolved, id) {
|
|
70334
|
+
if (id === void 0)
|
|
70335
|
+
return void 0;
|
|
70336
|
+
return resolved.targets.find((target) => target.id === id);
|
|
70337
|
+
}
|
|
70338
|
+
|
|
70339
|
+
// ../../packages/core/dist/s3/sync.js
|
|
70340
|
+
var DEFAULT_LIMIT2 = 500;
|
|
70341
|
+
async function syncFromS3(options) {
|
|
70342
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70343
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70344
|
+
const result = { written: [], unchanged: 0, failed: [] };
|
|
70345
|
+
const objects = await options.target.client.list(where, options.limit ?? DEFAULT_LIMIT2, options.signal);
|
|
70346
|
+
for (const object3 of objects) {
|
|
70347
|
+
const relative = object3.key.slice(where.length);
|
|
70348
|
+
if (relative === "" || relative.endsWith("/"))
|
|
70349
|
+
continue;
|
|
70350
|
+
if (!options.extensions.some((extension) => relative.toLowerCase().endsWith(extension)))
|
|
70351
|
+
continue;
|
|
70352
|
+
if (relative.split("/").includes("..")) {
|
|
70353
|
+
result.failed.push({ key: object3.key, problem: "The key would write outside the folder." });
|
|
70354
|
+
continue;
|
|
70355
|
+
}
|
|
70356
|
+
try {
|
|
70357
|
+
const bytes = await options.target.client.get(object3.key, options.signal);
|
|
70358
|
+
const localPath = join(options.localDir, relative);
|
|
70359
|
+
let existing;
|
|
70360
|
+
try {
|
|
70361
|
+
existing = await options.fs.readBytes(localPath);
|
|
70362
|
+
} catch {
|
|
70363
|
+
}
|
|
70364
|
+
if (existing !== void 0 && existing.equals(bytes)) {
|
|
70365
|
+
result.unchanged += 1;
|
|
70366
|
+
continue;
|
|
70367
|
+
}
|
|
70368
|
+
await options.fs.mkdir(dirname(localPath));
|
|
70369
|
+
await options.fs.writeBytes(localPath, bytes);
|
|
70370
|
+
result.written.push(relative);
|
|
70371
|
+
} catch (error51) {
|
|
70372
|
+
result.failed.push({
|
|
70373
|
+
key: object3.key,
|
|
70374
|
+
problem: error51 instanceof Error ? error51.message : String(error51)
|
|
70375
|
+
});
|
|
70376
|
+
}
|
|
70377
|
+
}
|
|
70378
|
+
return result;
|
|
70379
|
+
}
|
|
70380
|
+
async function uploadToS3(options) {
|
|
70381
|
+
if (options.target.readOnly === true) {
|
|
70382
|
+
throw new Error(`The connection "${options.target.label}" is read-only.`);
|
|
70383
|
+
}
|
|
70384
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70385
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70386
|
+
await options.target.client.put(`${where}${options.relative}`, options.contents, void 0, options.signal);
|
|
70387
|
+
}
|
|
70388
|
+
function join(dir, relative) {
|
|
70389
|
+
const left = dir.replace(/[\\/]+$/, "");
|
|
70390
|
+
return `${left}/${relative}`;
|
|
70391
|
+
}
|
|
70392
|
+
function dirname(filePath) {
|
|
70393
|
+
const cut = filePath.lastIndexOf("/");
|
|
70394
|
+
return cut === -1 ? filePath : filePath.slice(0, cut);
|
|
70395
|
+
}
|
|
70396
|
+
|
|
70397
|
+
// ../../packages/core/dist/s3/tools.js
|
|
70398
|
+
function pick2(targets, wanted) {
|
|
70399
|
+
if (wanted === void 0) {
|
|
70400
|
+
if (targets.length === 1)
|
|
70401
|
+
return targets[0];
|
|
70402
|
+
return `Several buckets are configured. Name one with "connection": ${targets.map((target) => target.label).join(", ")}.`;
|
|
70403
|
+
}
|
|
70404
|
+
const found = targets.find((target) => target.label.toLowerCase() === wanted.toLowerCase() || target.id === wanted);
|
|
70405
|
+
if (found !== void 0)
|
|
70406
|
+
return found;
|
|
70407
|
+
return `There is no S3 connection called "${wanted}". Configured: ${targets.map((target) => target.label).join(", ")}.`;
|
|
70408
|
+
}
|
|
70409
|
+
function looksBinary(bytes) {
|
|
70410
|
+
return bytes.subarray(0, 8e3).includes(0);
|
|
70411
|
+
}
|
|
70412
|
+
function describeSize(bytes) {
|
|
70413
|
+
if (bytes < 1024)
|
|
70414
|
+
return `${String(bytes)} B`;
|
|
70415
|
+
if (bytes < 1024 * 1024)
|
|
70416
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
70417
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
70418
|
+
}
|
|
70419
|
+
var failed = (error51) => ({
|
|
70420
|
+
content: error51 instanceof Error ? error51.message : String(error51),
|
|
70421
|
+
isError: true
|
|
70422
|
+
});
|
|
70423
|
+
function whichBuckets(targets) {
|
|
70424
|
+
return targets.length === 1 ? `the S3 bucket "${targets[0]?.label ?? ""}"` : `an S3 bucket (${targets.map((target) => target.label).join(", ")})`;
|
|
70425
|
+
}
|
|
70426
|
+
var connectionField = external_exports.string().optional().describe("Which configured bucket to use. May be omitted when only one is set up.");
|
|
70427
|
+
var listSchema = external_exports.object({
|
|
70428
|
+
connection: connectionField,
|
|
70429
|
+
prefix: external_exports.string().optional().describe("Folder to list, relative to the connection\u2019s own prefix. Omit for everything."),
|
|
70430
|
+
limit: external_exports.number().int().min(1).max(1e3).optional().describe("How many to return. Default 100.")
|
|
70431
|
+
});
|
|
70432
|
+
function createS3ListTool(targets) {
|
|
70433
|
+
return {
|
|
70434
|
+
name: "s3_list_files",
|
|
70435
|
+
group: "read",
|
|
70436
|
+
description: `List files in ${whichBuckets(targets)}. Use it to find what is there before reading or downloading. Returns keys, sizes and dates, never contents.`,
|
|
70437
|
+
parametersSchema: listSchema,
|
|
70438
|
+
async execute(params, context) {
|
|
70439
|
+
const target = pick2(targets, params.connection);
|
|
70440
|
+
if (typeof target === "string")
|
|
70441
|
+
return { content: target, isError: true };
|
|
70442
|
+
const base = normalisePrefix(target.prefix);
|
|
70443
|
+
const where = params.prefix === void 0 ? base : normalisePrefix(`${base}${params.prefix}`);
|
|
70444
|
+
try {
|
|
70445
|
+
const found = await target.client.list(where, params.limit ?? 100, context.signal);
|
|
70446
|
+
if (found.length === 0)
|
|
70447
|
+
return { content: `No files under "${where === "" ? "/" : where}".` };
|
|
70448
|
+
const lines = found.map((object3) => `${displayKey(object3.key, target.prefix)} ${describeSize(object3.size)} ${object3.lastModified}`);
|
|
70449
|
+
return { content: [`${String(found.length)} file(s) in ${target.bucket}:`, ...lines].join("\n") };
|
|
70450
|
+
} catch (error51) {
|
|
70451
|
+
return failed(error51);
|
|
70452
|
+
}
|
|
70453
|
+
}
|
|
70454
|
+
};
|
|
70455
|
+
}
|
|
70456
|
+
var readSchema = external_exports.object({
|
|
70457
|
+
connection: connectionField,
|
|
70458
|
+
key: external_exports.string().min(1).describe("The file to read, as s3_list_files reports it.")
|
|
70459
|
+
});
|
|
70460
|
+
function createS3ReadTool(targets) {
|
|
70461
|
+
return {
|
|
70462
|
+
name: "s3_read_file",
|
|
70463
|
+
group: "read",
|
|
70464
|
+
description: `Read a file from ${whichBuckets(targets)} as text. For anything that is not text, use s3_download_file and open it locally.`,
|
|
70465
|
+
parametersSchema: readSchema,
|
|
70466
|
+
async execute(params, context) {
|
|
70467
|
+
const target = pick2(targets, params.connection);
|
|
70468
|
+
if (typeof target === "string")
|
|
70469
|
+
return { content: target, isError: true };
|
|
70470
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70471
|
+
if (!resolved.ok)
|
|
70472
|
+
return { content: resolved.message, isError: true };
|
|
70473
|
+
try {
|
|
70474
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70475
|
+
if (looksBinary(bytes)) {
|
|
70476
|
+
return {
|
|
70477
|
+
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.`
|
|
70478
|
+
};
|
|
70479
|
+
}
|
|
70480
|
+
return { content: bytes.toString("utf8") };
|
|
70481
|
+
} catch (error51) {
|
|
70482
|
+
return failed(error51);
|
|
70483
|
+
}
|
|
70484
|
+
}
|
|
70485
|
+
};
|
|
70486
|
+
}
|
|
70487
|
+
var downloadSchema = external_exports.object({
|
|
70488
|
+
connection: connectionField,
|
|
70489
|
+
key: external_exports.string().min(1).describe("The file in the bucket."),
|
|
70490
|
+
to: external_exports.string().min(1).describe("Where to write it, relative to the workspace root.")
|
|
70491
|
+
});
|
|
70492
|
+
function createS3DownloadTool(targets) {
|
|
70493
|
+
return {
|
|
70494
|
+
name: "s3_download_file",
|
|
70495
|
+
group: "edit",
|
|
70496
|
+
description: `Copy a file out of ${whichBuckets(targets)} onto this machine.`,
|
|
70497
|
+
parametersSchema: downloadSchema,
|
|
70498
|
+
preview: async (params) => {
|
|
70499
|
+
const target = pick2(targets, params.connection);
|
|
70500
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${params.key}`;
|
|
70501
|
+
return { kind: "text", text: `Copy ${where}
|
|
70502
|
+
to ${params.to}` };
|
|
70503
|
+
},
|
|
70504
|
+
async execute(params, context) {
|
|
70505
|
+
const target = pick2(targets, params.connection);
|
|
70506
|
+
if (typeof target === "string")
|
|
70507
|
+
return { content: target, isError: true };
|
|
70508
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70509
|
+
if (!resolved.ok)
|
|
70510
|
+
return { content: resolved.message, isError: true };
|
|
70511
|
+
const to = await resolveToolPath(context, params.to);
|
|
70512
|
+
if (!to.ok)
|
|
70513
|
+
return { content: to.message, isError: true };
|
|
70514
|
+
try {
|
|
70515
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70516
|
+
await context.fs.writeBytes(to.realPath, bytes);
|
|
70517
|
+
return {
|
|
70518
|
+
content: `Wrote ${describeSize(bytes.length)} to ${params.to} from s3://${target.bucket}/${resolved.key}.`,
|
|
70519
|
+
path: to.realPath
|
|
70520
|
+
};
|
|
70521
|
+
} catch (error51) {
|
|
70522
|
+
return failed(error51);
|
|
70523
|
+
}
|
|
70524
|
+
}
|
|
70525
|
+
};
|
|
70526
|
+
}
|
|
70527
|
+
var uploadSchema = external_exports.object({
|
|
70528
|
+
connection: connectionField,
|
|
70529
|
+
from: external_exports.string().min(1).describe("The local file to upload, relative to the workspace root."),
|
|
70530
|
+
key: external_exports.string().min(1).describe("Where to put it in the bucket.")
|
|
70531
|
+
});
|
|
70532
|
+
function createS3UploadTool(targets) {
|
|
70533
|
+
return {
|
|
70534
|
+
name: "s3_upload_file",
|
|
70535
|
+
group: "edit",
|
|
70536
|
+
description: `Copy a file from this machine into ${whichBuckets(targets)}.`,
|
|
70537
|
+
parametersSchema: uploadSchema,
|
|
70538
|
+
/*
|
|
70539
|
+
* The preview names the destination in full, bucket included.
|
|
70540
|
+
*
|
|
70541
|
+
* Invariant 8: this is the one thing the person approving needs and cannot otherwise check.
|
|
70542
|
+
* A file sent to the wrong bucket is not recoverable by undoing anything here — it is on
|
|
70543
|
+
* somebody else's storage, possibly visible to people the user never intended.
|
|
70544
|
+
*/
|
|
70545
|
+
preview: async (params) => {
|
|
70546
|
+
const target = pick2(targets, params.connection);
|
|
70547
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${normalisePrefix(target.prefix)}${params.key}`;
|
|
70548
|
+
return { kind: "text", text: `Upload ${params.from}
|
|
70549
|
+
to ${where}` };
|
|
70550
|
+
},
|
|
70551
|
+
async execute(params, context) {
|
|
70552
|
+
const target = pick2(targets, params.connection);
|
|
70553
|
+
if (typeof target === "string")
|
|
70554
|
+
return { content: target, isError: true };
|
|
70555
|
+
if (target.readOnly === true) {
|
|
70556
|
+
return { content: `The connection "${target.label}" is read-only.`, isError: true };
|
|
70557
|
+
}
|
|
70558
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70559
|
+
if (!resolved.ok)
|
|
70560
|
+
return { content: resolved.message, isError: true };
|
|
70561
|
+
const from = await resolveToolPath(context, params.from);
|
|
70562
|
+
if (!from.ok)
|
|
70563
|
+
return { content: from.message, isError: true };
|
|
70564
|
+
try {
|
|
70565
|
+
const bytes = await context.fs.readBytes(from.realPath);
|
|
70566
|
+
await target.client.put(resolved.key, bytes, void 0, context.signal);
|
|
70567
|
+
return { content: `Uploaded ${describeSize(bytes.length)} to s3://${target.bucket}/${resolved.key}.` };
|
|
70568
|
+
} catch (error51) {
|
|
70569
|
+
return failed(error51);
|
|
70570
|
+
}
|
|
70571
|
+
}
|
|
70572
|
+
};
|
|
70573
|
+
}
|
|
70574
|
+
function createS3Tools(targets) {
|
|
70575
|
+
if (targets.length === 0)
|
|
70576
|
+
return [];
|
|
70577
|
+
return [
|
|
70578
|
+
createS3ListTool(targets),
|
|
70579
|
+
createS3ReadTool(targets),
|
|
70580
|
+
createS3DownloadTool(targets),
|
|
70581
|
+
createS3UploadTool(targets)
|
|
70582
|
+
];
|
|
70583
|
+
}
|
|
70584
|
+
|
|
70585
|
+
// ../../packages/core/dist/s3/localFolder.js
|
|
70586
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
70587
|
+
function mirrorFolder(options) {
|
|
70588
|
+
const connection = safeSegment(options.connectionId);
|
|
70589
|
+
const digest = createHash5("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
70590
|
+
return join2(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
70591
|
+
}
|
|
70592
|
+
function safeSegment(id) {
|
|
70593
|
+
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
70594
|
+
const suffix = createHash5("sha256").update(id).digest("hex").slice(0, 6);
|
|
70595
|
+
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
70596
|
+
}
|
|
70597
|
+
function join2(...parts) {
|
|
70598
|
+
return parts.map((part, index) => index === 0 ? part.replace(/[\\/]+$/, "") : part).join("/");
|
|
70599
|
+
}
|
|
70600
|
+
|
|
69683
70601
|
// src/identityTool.ts
|
|
69684
70602
|
import { spawn as spawn7 } from "node:child_process";
|
|
69685
70603
|
import path27 from "node:path";
|
|
@@ -70270,8 +71188,9 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
70270
71188
|
// src/identity.ts
|
|
70271
71189
|
import crypto5 from "node:crypto";
|
|
70272
71190
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
70273
|
-
describe
|
|
71191
|
+
describe;
|
|
70274
71192
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
71193
|
+
principal;
|
|
70275
71194
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
70276
71195
|
sessionToken = crypto5.randomBytes(32).toString("base64url");
|
|
70277
71196
|
/**
|
|
@@ -70286,9 +71205,19 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
70286
71205
|
handoffToken = crypto5.randomBytes(32).toString("base64url");
|
|
70287
71206
|
handoffExpiresAt;
|
|
70288
71207
|
handoffSeconds;
|
|
70289
|
-
|
|
71208
|
+
/**
|
|
71209
|
+
* @param principal Who this server's storage is filed under. Defaults to the local user.
|
|
71210
|
+
*
|
|
71211
|
+
* Supplied when the platform named the account — `JUPYTERHUB_USER` and friends, see
|
|
71212
|
+
* `hostedUser.ts`. **It changes the name, not the gate.** The bearer token below still decides
|
|
71213
|
+
* who gets in, which is §14's rule that identity resolution must never become a way past the
|
|
71214
|
+
* door: knowing that a server was spawned for Ana says nothing about who is making this request.
|
|
71215
|
+
*/
|
|
71216
|
+
constructor(handoffSeconds = 10, principal) {
|
|
70290
71217
|
this.handoffSeconds = handoffSeconds;
|
|
70291
71218
|
this.handoffExpiresAt = Date.now() + handoffSeconds * 1e3;
|
|
71219
|
+
this.principal = principal ?? _SingleUserIdentity.PRINCIPAL;
|
|
71220
|
+
this.describe = principal === void 0 ? "single user (local)" : `single user \u2014 ${principal.id}`;
|
|
70292
71221
|
}
|
|
70293
71222
|
get launchToken() {
|
|
70294
71223
|
if (this.handoffToken === void 0) throw new Error("handoff token already consumed");
|
|
@@ -70335,7 +71264,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
70335
71264
|
async authenticate(request) {
|
|
70336
71265
|
const header = request.headers.authorization;
|
|
70337
71266
|
if (header === void 0 || !header.startsWith("Bearer ")) return void 0;
|
|
70338
|
-
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ?
|
|
71267
|
+
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ? this.principal : void 0;
|
|
70339
71268
|
}
|
|
70340
71269
|
};
|
|
70341
71270
|
function timingSafeEquals(a, b) {
|
|
@@ -70794,6 +71723,21 @@ function readVariablesFile(filePath) {
|
|
|
70794
71723
|
}
|
|
70795
71724
|
}
|
|
70796
71725
|
|
|
71726
|
+
// src/hostedUser.ts
|
|
71727
|
+
var SOURCES = [
|
|
71728
|
+
/** JupyterHub's own, set in every single-user server it spawns. */
|
|
71729
|
+
"JUPYTERHUB_USER",
|
|
71730
|
+
/** Set by some deployments that front an app without the hub's spawner. */
|
|
71731
|
+
"JUPYTER_USER"
|
|
71732
|
+
];
|
|
71733
|
+
function hostedUser(env2 = process.env) {
|
|
71734
|
+
for (const source of SOURCES) {
|
|
71735
|
+
const value = env2[source]?.trim();
|
|
71736
|
+
if (value !== void 0 && value.length > 0) return { id: value, source };
|
|
71737
|
+
}
|
|
71738
|
+
return void 0;
|
|
71739
|
+
}
|
|
71740
|
+
|
|
70797
71741
|
// src/session.ts
|
|
70798
71742
|
import { watch as fsWatch } from "node:fs";
|
|
70799
71743
|
import fs24 from "node:fs/promises";
|
|
@@ -71326,11 +72270,26 @@ var STREAM_PADDING = `: ${(() => {
|
|
|
71326
72270
|
})()}
|
|
71327
72271
|
|
|
71328
72272
|
`;
|
|
72273
|
+
function principalFromPlatform() {
|
|
72274
|
+
const found = hostedUser();
|
|
72275
|
+
return found === void 0 ? void 0 : { id: found.id, displayName: found.id };
|
|
72276
|
+
}
|
|
71329
72277
|
async function startServer(options) {
|
|
71330
72278
|
const log = options.logSink ?? ((line) => process.stderr.write(`${line}
|
|
71331
72279
|
`));
|
|
71332
72280
|
setFrameAncestors(options.allowFrameAncestors ?? []);
|
|
71333
|
-
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() :
|
|
72281
|
+
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() : (
|
|
72282
|
+
/*
|
|
72283
|
+
* Named by the platform when it says so, and still gated by the token either way.
|
|
72284
|
+
*
|
|
72285
|
+
* JupyterHub spawns a server per person and sets `JUPYTERHUB_USER` in it, so settings,
|
|
72286
|
+
* secrets and history are filed under that person rather than under "local" — which is
|
|
72287
|
+
* what somebody had otherwise to write a Python function to achieve. Read from this
|
|
72288
|
+
* process's environment, never from a request: see `hostedUser.ts` for why the URL
|
|
72289
|
+
* suffix carrying the same name is not the same fact.
|
|
72290
|
+
*/
|
|
72291
|
+
new SingleUserIdentity(options.handoffSeconds, principalFromPlatform())
|
|
72292
|
+
));
|
|
71334
72293
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
71335
72294
|
const sharedStore = options.sharedConfig;
|
|
71336
72295
|
const sharedSecretStore = new FileSecretStore(path34.join(options.dataDir, "shared-secrets.json"));
|
|
@@ -71385,6 +72344,12 @@ async function startServer(options) {
|
|
|
71385
72344
|
};
|
|
71386
72345
|
const connection = {
|
|
71387
72346
|
transport,
|
|
72347
|
+
/*
|
|
72348
|
+
* Replaced below, once the bridge that owns the state exists. A no-op rather than a missing
|
|
72349
|
+
* field so the object is a complete `Connection` from the moment it is built — a half-built
|
|
72350
|
+
* one handed to anything in between is how a route ends up calling something undefined.
|
|
72351
|
+
*/
|
|
72352
|
+
resync: () => void 0,
|
|
71388
72353
|
deliver: (message3) => {
|
|
71389
72354
|
for (const listener of listeners) listener(message3);
|
|
71390
72355
|
},
|
|
@@ -71492,6 +72457,9 @@ async function startServer(options) {
|
|
|
71492
72457
|
originalDispose();
|
|
71493
72458
|
session.dispose();
|
|
71494
72459
|
};
|
|
72460
|
+
connection.resync = () => {
|
|
72461
|
+
session.resync();
|
|
72462
|
+
};
|
|
71495
72463
|
return connection;
|
|
71496
72464
|
}
|
|
71497
72465
|
const server = createServer((request, response) => {
|
|
@@ -71584,6 +72552,7 @@ async function startServer(options) {
|
|
|
71584
72552
|
if (viaAdminUrl) adminConnections.add(principal.id);
|
|
71585
72553
|
else adminConnections.delete(principal.id);
|
|
71586
72554
|
connection.attach(response);
|
|
72555
|
+
connection.resync();
|
|
71587
72556
|
connection.transport.post({
|
|
71588
72557
|
type: "hostRole",
|
|
71589
72558
|
role: isAdminSession(principal) ? "admin" : "user",
|
|
@@ -71611,6 +72580,7 @@ async function startServer(options) {
|
|
|
71611
72580
|
if (connection === void 0) {
|
|
71612
72581
|
connection = await openConnection(principal);
|
|
71613
72582
|
connections.set(principal.id, connection);
|
|
72583
|
+
connection.resync();
|
|
71614
72584
|
}
|
|
71615
72585
|
respondJson(response, 200, { messages: connection.drain() });
|
|
71616
72586
|
return;
|
|
@@ -71834,7 +72804,7 @@ function respondJson(response, status, body) {
|
|
|
71834
72804
|
}
|
|
71835
72805
|
|
|
71836
72806
|
// src/cli.ts
|
|
71837
|
-
var VERSION = true ? "0.
|
|
72807
|
+
var VERSION = true ? "0.80.1" : "unknown (not a packaged build)";
|
|
71838
72808
|
var compat = installNodeCompat();
|
|
71839
72809
|
function lastMeaningfulLine(problem) {
|
|
71840
72810
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|