@chosengeneration/light-code 0.70.0 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1173 -173
- package/dist/client/client.css +88 -0
- package/dist/client/client.js +57 -57
- package/dist/client/index.html +17 -0
- package/dist/server.js +1172 -172
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -24482,6 +24482,8 @@ var FetchHttpClient = class {
|
|
|
24482
24482
|
init.headers = options.headers;
|
|
24483
24483
|
if (options.body !== void 0)
|
|
24484
24484
|
init.body = options.body;
|
|
24485
|
+
if (options.bodyBytes !== void 0)
|
|
24486
|
+
init.body = options.bodyBytes;
|
|
24485
24487
|
if (options.signal !== void 0)
|
|
24486
24488
|
init.signal = options.signal;
|
|
24487
24489
|
let target;
|
|
@@ -40171,6 +40173,55 @@ var mailIndexConfigSchema = external_exports.object({
|
|
|
40171
40173
|
/** Characters of body kept per message, for showing a hit without reopening Outlook. */
|
|
40172
40174
|
previewChars: external_exports.number().int().min(0).max(2e3)
|
|
40173
40175
|
}).partial();
|
|
40176
|
+
var s3ConnectionSchema = external_exports.object({
|
|
40177
|
+
id: external_exports.string().min(1),
|
|
40178
|
+
label: external_exports.string().min(1),
|
|
40179
|
+
bucket: external_exports.string().min(1),
|
|
40180
|
+
region: external_exports.string().min(1),
|
|
40181
|
+
accessKeyId: external_exports.string().min(1),
|
|
40182
|
+
secretAccessKeyRef: external_exports.string().min(1),
|
|
40183
|
+
/** Only for temporary credentials. */
|
|
40184
|
+
sessionTokenRef: external_exports.string().optional(),
|
|
40185
|
+
/** Absent means the ordinary AWS endpoint for the region. */
|
|
40186
|
+
endpoint: external_exports.string().url().optional(),
|
|
40187
|
+
/** `host/bucket/key` instead of `bucket.host/key`, which internal deployments usually need. */
|
|
40188
|
+
pathStyle: external_exports.boolean().optional(),
|
|
40189
|
+
/**
|
|
40190
|
+
* Everything is confined to this prefix, when one is set.
|
|
40191
|
+
*
|
|
40192
|
+
* Not a convenience. It is the only thing bounding what the tools can reach in a bucket that may
|
|
40193
|
+
* hold far more than this project, and it is enforced on every key rather than trusted to the
|
|
40194
|
+
* model — `confine()`'s argument applied to a bucket instead of a disk.
|
|
40195
|
+
*/
|
|
40196
|
+
prefix: external_exports.string().optional(),
|
|
40197
|
+
/** Refuses every write, so a bucket can be attached for reading with nothing to go wrong. */
|
|
40198
|
+
readOnly: external_exports.boolean().optional()
|
|
40199
|
+
});
|
|
40200
|
+
var s3MirrorSchema = external_exports.object({
|
|
40201
|
+
connectionId: external_exports.string().min(1),
|
|
40202
|
+
prefix: external_exports.string().optional(),
|
|
40203
|
+
/** Off by default: reading a bucket on every panel open is somebody's money and latency. */
|
|
40204
|
+
enabled: external_exports.boolean().optional()
|
|
40205
|
+
});
|
|
40206
|
+
var s3ConfigSchema = external_exports.object({
|
|
40207
|
+
connections: external_exports.array(s3ConnectionSchema).max(20).optional(),
|
|
40208
|
+
/**
|
|
40209
|
+
* Where skills are kept, when they live in a bucket rather than on this disk.
|
|
40210
|
+
*
|
|
40211
|
+
* Only the *files* move. They are still loaded, watched and indexed exactly as local ones are —
|
|
40212
|
+
* indexing stays as configured — so this names a sync, not a second kind of skill.
|
|
40213
|
+
*/
|
|
40214
|
+
skills: s3MirrorSchema.optional(),
|
|
40215
|
+
/**
|
|
40216
|
+
* The same for Python tools, with one difference that is not a detail.
|
|
40217
|
+
*
|
|
40218
|
+
* A mirrored `.py` is **not** loaded on arrival. The hash-pinned registry (§13) refuses any tool
|
|
40219
|
+
* that was not approved with its source shown, so a bucket is how a tool *reaches* a machine,
|
|
40220
|
+
* and approval still happens on each one. Anybody with write access to the bucket would
|
|
40221
|
+
* otherwise be running code as this user on every machine that syncs.
|
|
40222
|
+
*/
|
|
40223
|
+
tools: s3MirrorSchema.optional()
|
|
40224
|
+
});
|
|
40174
40225
|
var configSchema = external_exports.object({
|
|
40175
40226
|
profiles: external_exports.array(providerProfileSchema),
|
|
40176
40227
|
/**
|
|
@@ -40192,6 +40243,8 @@ var configSchema = external_exports.object({
|
|
|
40192
40243
|
* embedder would exfiltrate whatever gets indexed — sharper than the existing entries,
|
|
40193
40244
|
* because the payload is source code.
|
|
40194
40245
|
*/
|
|
40246
|
+
/** User-scope only (invariant 5): it holds a bucket and a key that can write to it. */
|
|
40247
|
+
s3: s3ConfigSchema,
|
|
40195
40248
|
vectorStores: external_exports.record(external_exports.string(), vectorStoreSchema),
|
|
40196
40249
|
activeVectorStoreId: external_exports.string(),
|
|
40197
40250
|
embedder: embedderConfigSchema,
|
|
@@ -40839,6 +40892,15 @@ var USER_SCOPE_ONLY_KEYS = [
|
|
|
40839
40892
|
// Per-project settings live here, keyed by path. Same reasoning as `approvals` exactly: a repo
|
|
40840
40893
|
// that could write its own entry would choose its own vector store and model for itself.
|
|
40841
40894
|
"workspaces",
|
|
40895
|
+
/*
|
|
40896
|
+
* Holds a bucket, an endpoint and the reference to a key that can read and write it.
|
|
40897
|
+
*
|
|
40898
|
+
* The sharpest kind of entry on this list: a repository able to set it would point the upload
|
|
40899
|
+
* tool at a bucket of its choosing, and everything copied "into S3" would go to somebody else —
|
|
40900
|
+
* with the user watching a tool succeed. Same shape as `embedder`, with whatever the user
|
|
40901
|
+
* uploads as the payload.
|
|
40902
|
+
*/
|
|
40903
|
+
"s3",
|
|
40842
40904
|
// `expert.path` names an executable. A workspace able to set it would run a program of
|
|
40843
40905
|
// its choosing as soon as the panel opened — the same threat as `python.uvPath`.
|
|
40844
40906
|
// `expert.enabled` is here too, so a repo cannot switch on paid API calls by itself.
|
|
@@ -46881,6 +46943,14 @@ function merge2(single, many) {
|
|
|
46881
46943
|
}
|
|
46882
46944
|
return out;
|
|
46883
46945
|
}
|
|
46946
|
+
function aliasFields(names) {
|
|
46947
|
+
const cleaned = merge2(void 0, names);
|
|
46948
|
+
const [primary, ...rest] = cleaned;
|
|
46949
|
+
return {
|
|
46950
|
+
primary,
|
|
46951
|
+
rest: rest.length > 0 ? rest : void 0
|
|
46952
|
+
};
|
|
46953
|
+
}
|
|
46884
46954
|
|
|
46885
46955
|
// ../../packages/core/dist/tools/searchCodebase.js
|
|
46886
46956
|
var paramsSchema6 = external_exports.object({
|
|
@@ -47056,16 +47126,44 @@ function toHit(match, self) {
|
|
|
47056
47126
|
}
|
|
47057
47127
|
async function searchTeamSkills(options, query, size = 5, signal) {
|
|
47058
47128
|
const vector = await options.embedder.embed(query);
|
|
47059
|
-
const
|
|
47060
|
-
|
|
47061
|
-
|
|
47062
|
-
|
|
47063
|
-
|
|
47129
|
+
const tried = [];
|
|
47130
|
+
let firstError;
|
|
47131
|
+
for (const collection of options.collections) {
|
|
47132
|
+
tried.push(collection);
|
|
47133
|
+
let matches;
|
|
47134
|
+
try {
|
|
47135
|
+
matches = await options.searcher.searchByVector(collection, vector, {
|
|
47136
|
+
size,
|
|
47137
|
+
...signal !== void 0 ? { signal } : {}
|
|
47138
|
+
});
|
|
47139
|
+
} catch (error51) {
|
|
47140
|
+
firstError ??= error51 instanceof Error ? error51 : new Error(String(error51));
|
|
47141
|
+
continue;
|
|
47142
|
+
}
|
|
47143
|
+
if (matches.length > 0) {
|
|
47144
|
+
return { hits: matches.map((match) => toHit(match, options.owner)), collection, tried };
|
|
47145
|
+
}
|
|
47146
|
+
}
|
|
47147
|
+
if (firstError !== void 0)
|
|
47148
|
+
throw firstError;
|
|
47149
|
+
return { hits: [], collection: void 0, tried };
|
|
47064
47150
|
}
|
|
47065
47151
|
async function findTeamSkillsNamed(options, name, signal) {
|
|
47066
|
-
const candidates = await searchTeamSkills(options, name, 25, signal);
|
|
47067
47152
|
const wanted = name.trim().toLowerCase();
|
|
47068
|
-
|
|
47153
|
+
const found = /* @__PURE__ */ new Map();
|
|
47154
|
+
for (const collection of options.collections) {
|
|
47155
|
+
let result;
|
|
47156
|
+
try {
|
|
47157
|
+
result = await searchTeamSkills({ ...options, collections: [collection] }, name, 25, signal);
|
|
47158
|
+
} catch {
|
|
47159
|
+
continue;
|
|
47160
|
+
}
|
|
47161
|
+
for (const hit of result.hits) {
|
|
47162
|
+
if (hit.name.trim().toLowerCase() === wanted)
|
|
47163
|
+
found.set(`${hit.owner ?? "?"}/${hit.name}`, hit);
|
|
47164
|
+
}
|
|
47165
|
+
}
|
|
47166
|
+
return [...found.values()];
|
|
47069
47167
|
}
|
|
47070
47168
|
function describeTeamSkillCollision(name, hits) {
|
|
47071
47169
|
const others = hits.filter((hit) => !hit.isMine);
|
|
@@ -47081,11 +47179,13 @@ function describeTeamSkillCollision(name, hits) {
|
|
|
47081
47179
|
" name and does not overwrite theirs."
|
|
47082
47180
|
].join("\n");
|
|
47083
47181
|
}
|
|
47084
|
-
function renderTeamSkillHits(
|
|
47182
|
+
function renderTeamSkillHits(found, query) {
|
|
47183
|
+
const { hits, collection, tried } = found;
|
|
47085
47184
|
if (hits.length === 0) {
|
|
47086
47185
|
return `No team skills match: ${query}
|
|
47087
|
-
Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented
|
|
47186
|
+
` + (tried.length > 0 ? "Looked in " + tried.join(", ") + ". " : "") + "Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented.";
|
|
47088
47187
|
}
|
|
47188
|
+
const widened = collection !== void 0 && tried.length > 1 && tried[0] !== collection ? "Nothing in " + tried.slice(0, tried.indexOf(collection)).join(", ") + "; these are from " + collection + "." : void 0;
|
|
47089
47189
|
const rendered = hits.map((hit, position) => {
|
|
47090
47190
|
const who = hit.isMine ? "yours" : hit.owner ?? "unknown owner";
|
|
47091
47191
|
const where = hit.project === void 0 ? who : `${who} / ${hit.project}`;
|
|
@@ -47094,6 +47194,7 @@ ${hit.text}`;
|
|
|
47094
47194
|
}).join("\n\n---\n\n");
|
|
47095
47195
|
return [
|
|
47096
47196
|
`${hits.length} team skill(s) matching: ${query}`,
|
|
47197
|
+
...widened !== void 0 ? [widened] : [],
|
|
47097
47198
|
'Anything not marked "yours" is a colleague\u2019s and has no file on this machine \u2014 the text',
|
|
47098
47199
|
"above is the whole of it, so do not try to read_file it. To keep one, write your own copy",
|
|
47099
47200
|
"with write_skill; that stores it under your name and leaves theirs alone.",
|
|
@@ -47136,24 +47237,27 @@ function createSearchTeamSkillsTool(options) {
|
|
|
47136
47237
|
async execute(params) {
|
|
47137
47238
|
const startedAt = Date.now();
|
|
47138
47239
|
try {
|
|
47139
|
-
const
|
|
47240
|
+
const found = await searchTeamSkills(options, params.query, params.size ?? 5);
|
|
47140
47241
|
options.observer?.record({
|
|
47141
47242
|
at: startedAt,
|
|
47142
47243
|
source: "search_team_skills",
|
|
47244
|
+
// The one that answered, not the one that was asked first — the log is evidence about
|
|
47245
|
+
// what happened, and a widened search is exactly what somebody would want to see.
|
|
47246
|
+
collection: found.collection ?? found.tried.join(" \u2192 "),
|
|
47143
47247
|
query: params.query,
|
|
47144
|
-
|
|
47145
|
-
hits: hits.length,
|
|
47248
|
+
hits: found.hits.length,
|
|
47146
47249
|
elapsedMs: Date.now() - startedAt,
|
|
47147
47250
|
via: "index"
|
|
47148
47251
|
});
|
|
47149
|
-
return { content: renderTeamSkillHits(
|
|
47252
|
+
return { content: renderTeamSkillHits(found, params.query) };
|
|
47150
47253
|
} catch (error51) {
|
|
47151
47254
|
const message3 = error51 instanceof Error ? error51.message : String(error51);
|
|
47152
47255
|
options.observer?.record({
|
|
47153
47256
|
at: startedAt,
|
|
47154
47257
|
source: "search_team_skills",
|
|
47155
47258
|
query: params.query,
|
|
47156
|
-
|
|
47259
|
+
// Every name that would have been tried: the search failed before one could answer.
|
|
47260
|
+
collection: options.collections.join(" \u2192 "),
|
|
47157
47261
|
hits: 0,
|
|
47158
47262
|
elapsedMs: Date.now() - startedAt,
|
|
47159
47263
|
error: message3
|
|
@@ -48444,26 +48548,26 @@ Each appears in its own window. Nothing is changed or sent.`
|
|
|
48444
48548
|
async execute(params) {
|
|
48445
48549
|
const ids = idsOf(params);
|
|
48446
48550
|
const opened = [];
|
|
48447
|
-
const
|
|
48551
|
+
const failed2 = [];
|
|
48448
48552
|
for (const id of ids) {
|
|
48449
48553
|
try {
|
|
48450
48554
|
opened.push((await options.display(id)).subject);
|
|
48451
48555
|
} catch (error51) {
|
|
48452
|
-
|
|
48556
|
+
failed2.push(`${id}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48453
48557
|
}
|
|
48454
48558
|
}
|
|
48455
48559
|
if (opened.length === 0) {
|
|
48456
48560
|
return { content: `Could not open any of them.
|
|
48457
|
-
${
|
|
48561
|
+
${failed2.join("\n")}`, isError: true };
|
|
48458
48562
|
}
|
|
48459
48563
|
return {
|
|
48460
48564
|
content: [
|
|
48461
48565
|
`Opened ${String(opened.length)} message(s) in Outlook:`,
|
|
48462
48566
|
...opened.map((subject) => ` "${subject}"`),
|
|
48463
|
-
...
|
|
48567
|
+
...failed2.length === 0 ? [] : [
|
|
48464
48568
|
"",
|
|
48465
|
-
`${String(
|
|
48466
|
-
...
|
|
48569
|
+
`${String(failed2.length)} could not be opened - moved or deleted since indexing:`,
|
|
48570
|
+
...failed2.map((line) => ` ${line}`)
|
|
48467
48571
|
]
|
|
48468
48572
|
].join("\n")
|
|
48469
48573
|
};
|
|
@@ -56133,6 +56237,7 @@ var McpConnection = class {
|
|
|
56133
56237
|
if (transport instanceof StdioClientTransport) {
|
|
56134
56238
|
this.attachStderr(transport);
|
|
56135
56239
|
}
|
|
56240
|
+
this.onLog(await describeMcpRequest(this.config, this.secrets));
|
|
56136
56241
|
try {
|
|
56137
56242
|
await client.connect(transport);
|
|
56138
56243
|
} catch (error51) {
|
|
@@ -56216,6 +56321,20 @@ function renderToolResult(result) {
|
|
|
56216
56321
|
function describeError(error51) {
|
|
56217
56322
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
56218
56323
|
}
|
|
56324
|
+
async function describeMcpRequest(config2, secrets) {
|
|
56325
|
+
if (isStdioServer(config2))
|
|
56326
|
+
return `Starting ${config2.command}`;
|
|
56327
|
+
const kind = config2.type ?? "streamable-http (no type set; SSE is the fallback)";
|
|
56328
|
+
let names;
|
|
56329
|
+
try {
|
|
56330
|
+
const resolved = await interpolateSecrets(config2.headers, secrets);
|
|
56331
|
+
names = Object.entries(resolved).map(([name, value]) => value.trim().length === 0 ? `${name} (EMPTY)` : name);
|
|
56332
|
+
} catch (error51) {
|
|
56333
|
+
return `Connecting to ${config2.url} as ${kind}; headers unresolved: ${describeError(error51)}`;
|
|
56334
|
+
}
|
|
56335
|
+
const headers = names.length === 0 ? "no headers configured" : `headers: ${names.join(", ")}`;
|
|
56336
|
+
return `Connecting to ${config2.url} as ${kind}; ${headers}`;
|
|
56337
|
+
}
|
|
56219
56338
|
|
|
56220
56339
|
// ../../packages/core/dist/mcp/registry.js
|
|
56221
56340
|
function adaptTool(serverName, toolName, description, inputSchema, call) {
|
|
@@ -57017,10 +57136,20 @@ function createWriteSkillTool(context) {
|
|
|
57017
57136
|
}
|
|
57018
57137
|
await fs10.writeFile(filePath, rendered, "utf8");
|
|
57019
57138
|
await context.onChanged();
|
|
57139
|
+
let publishProblem;
|
|
57140
|
+
if (context.onSaved !== void 0) {
|
|
57141
|
+
try {
|
|
57142
|
+
await context.onSaved(params.name, rendered);
|
|
57143
|
+
} catch (error51) {
|
|
57144
|
+
publishProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
57145
|
+
}
|
|
57146
|
+
}
|
|
57020
57147
|
const collision = existed ? void 0 : await collisionWarning(params.name);
|
|
57021
57148
|
return {
|
|
57022
57149
|
content: `${existed ? "Updated" : "Recorded"} the skill "${params.name}" at ${filePath}.
|
|
57023
|
-
Its summary will appear in your context from the next message onward.` + (
|
|
57150
|
+
Its summary will appear in your context from the next message onward.` + (publishProblem === void 0 ? "" : `
|
|
57151
|
+
|
|
57152
|
+
Saved here, but NOT copied to the bucket: ${publishProblem}`) + (collision === void 0 ? "" : `
|
|
57024
57153
|
|
|
57025
57154
|
${collision}`),
|
|
57026
57155
|
path: filePath
|
|
@@ -58327,6 +58456,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
|
|
|
58327
58456
|
var DEFAULT_MAX_ITERATIONS = 25;
|
|
58328
58457
|
var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
|
|
58329
58458
|
var MAX_REFUNDED_STEPS = 20;
|
|
58459
|
+
var FORM_DISMISSED = "The user dismissed the form without answering.";
|
|
58460
|
+
var MAX_FORM_RESETS = 5;
|
|
58330
58461
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
58331
58462
|
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
58332
58463
|
const contextWindow = options.contextWindow ?? 0;
|
|
@@ -58509,6 +58640,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58509
58640
|
conversation.addUserMessage(userMessage, options.images);
|
|
58510
58641
|
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
58511
58642
|
let refunded = 0;
|
|
58643
|
+
let formResets = 0;
|
|
58512
58644
|
const mistakeCounts = /* @__PURE__ */ new Map();
|
|
58513
58645
|
let continueNudges = 0;
|
|
58514
58646
|
const mode = options.mode ?? CODE_MODE;
|
|
@@ -58582,6 +58714,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58582
58714
|
conversation.addUserMessage(message3);
|
|
58583
58715
|
events.onQueuedMessageConsumed?.(message3);
|
|
58584
58716
|
}
|
|
58717
|
+
if (queued.length > 0) {
|
|
58718
|
+
iteration = -1;
|
|
58719
|
+
refunded = 0;
|
|
58720
|
+
}
|
|
58585
58721
|
if (toolCall.name === "attempt_completion" || toolCall.name === "ask_followup_question") {
|
|
58586
58722
|
events.onDone();
|
|
58587
58723
|
return;
|
|
@@ -58590,6 +58726,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58590
58726
|
refunded += 1;
|
|
58591
58727
|
iteration -= 1;
|
|
58592
58728
|
}
|
|
58729
|
+
if (toolCall.name === "ask_user_form" && result.isError !== true && !result.content.startsWith(FORM_DISMISSED) && formResets < MAX_FORM_RESETS) {
|
|
58730
|
+
formResets += 1;
|
|
58731
|
+
iteration = -1;
|
|
58732
|
+
refunded = 0;
|
|
58733
|
+
}
|
|
58593
58734
|
if (result.path !== void 0) {
|
|
58594
58735
|
if (result.isError === true) {
|
|
58595
58736
|
const count = (mistakeCounts.get(result.path) ?? 0) + 1;
|
|
@@ -58603,7 +58744,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
58603
58744
|
}
|
|
58604
58745
|
}
|
|
58605
58746
|
}
|
|
58606
|
-
events.onError(`Stopped after ${maxIterations} steps
|
|
58747
|
+
events.onError(`Stopped after ${maxIterations} steps since your last message. Nothing is lost \u2014 send another message (for example "continue") to carry on from here. Raise the limit in Settings \u2192 Approvals if this task legitimately needs more.`);
|
|
58607
58748
|
}
|
|
58608
58749
|
|
|
58609
58750
|
// ../../packages/core/dist/host/bridge.js
|
|
@@ -61573,6 +61714,10 @@ var NodeFileSystem = class {
|
|
|
61573
61714
|
async writeFile(path32, contents) {
|
|
61574
61715
|
await fs16.writeFile(path32, contents, "utf8");
|
|
61575
61716
|
}
|
|
61717
|
+
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
61718
|
+
async writeBytes(path32, contents) {
|
|
61719
|
+
await fs16.writeFile(path32, contents);
|
|
61720
|
+
}
|
|
61576
61721
|
async stat(path32) {
|
|
61577
61722
|
const stat = await fs16.lstat(path32);
|
|
61578
61723
|
return {
|
|
@@ -61991,6 +62136,10 @@ ${preview.text}` } : {}
|
|
|
61991
62136
|
const defaultSkillsDir = workspaceRoot !== void 0 ? path23.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
61992
62137
|
let skillsDir = defaultSkillsDir;
|
|
61993
62138
|
let extraSkillDirs = [];
|
|
62139
|
+
let mirroredSkillsDir;
|
|
62140
|
+
let mirroredToolsDir;
|
|
62141
|
+
let cachedSkillMirror;
|
|
62142
|
+
let lastSync = {};
|
|
61994
62143
|
function resolveSkillDir(entry) {
|
|
61995
62144
|
const trimmed = entry.trim();
|
|
61996
62145
|
if (trimmed.length === 0)
|
|
@@ -62545,6 +62694,7 @@ ${preview.text}` } : {}
|
|
|
62545
62694
|
let cachedOffice = {};
|
|
62546
62695
|
let cachedMail = {};
|
|
62547
62696
|
let cachedDatasets = [];
|
|
62697
|
+
let cachedS3 = { targets: [], problems: [] };
|
|
62548
62698
|
let datasetSummaryForPrompt = [];
|
|
62549
62699
|
let cachedPythonEnabled = false;
|
|
62550
62700
|
const mailStore = new MailStore(storageDir);
|
|
@@ -62593,6 +62743,22 @@ ${preview.text}` } : {}
|
|
|
62593
62743
|
cachedOffice = config2.office ?? {};
|
|
62594
62744
|
cachedMail = config2.mail ?? {};
|
|
62595
62745
|
cachedDatasets = config2.datasets ?? [];
|
|
62746
|
+
cachedS3 = await resolveS3({
|
|
62747
|
+
config: config2.s3,
|
|
62748
|
+
http: httpClient,
|
|
62749
|
+
secrets,
|
|
62750
|
+
/*
|
|
62751
|
+
* Through the one global resolver, so a corporate root certificate reaches S3 exactly as it
|
|
62752
|
+
* reaches the gateway and the vector store. §10: do not add another place to configure a CA.
|
|
62753
|
+
*/
|
|
62754
|
+
tls: await resolveConnectionTls({
|
|
62755
|
+
...config2.tls !== void 0 ? { global: config2.tls } : {},
|
|
62756
|
+
...config2.certDir !== void 0 ? { certDir: config2.certDir } : {},
|
|
62757
|
+
onPaths: (paths) => {
|
|
62758
|
+
void Promise.all(paths.map((certPath) => denylist.add(certPath))).catch(() => void 0);
|
|
62759
|
+
}
|
|
62760
|
+
})
|
|
62761
|
+
});
|
|
62596
62762
|
cachedPythonEnabled = config2.python?.dynamicTools === "on";
|
|
62597
62763
|
datasetSummaryForPrompt = await Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
62598
62764
|
name: dataset.name,
|
|
@@ -62626,6 +62792,20 @@ ${preview.text}` } : {}
|
|
|
62626
62792
|
cachedReadRoots = (config2.filesystem?.readRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
62627
62793
|
skillsDir = (config2.skills?.dir !== void 0 ? resolveSkillDir(config2.skills.dir) : void 0) ?? defaultSkillsDir;
|
|
62628
62794
|
extraSkillDirs = (config2.skills?.paths ?? []).map(resolveSkillDir).filter((dir) => dir !== void 0);
|
|
62795
|
+
const skillMirror = config2.s3?.skills;
|
|
62796
|
+
cachedSkillMirror = skillMirror;
|
|
62797
|
+
if (skillMirror?.enabled === true) {
|
|
62798
|
+
mirroredSkillsDir = mirrorFolder({
|
|
62799
|
+
storageDir,
|
|
62800
|
+
connectionId: skillMirror.connectionId,
|
|
62801
|
+
kind: "skills",
|
|
62802
|
+
...skillMirror.prefix !== void 0 ? { prefix: skillMirror.prefix } : {}
|
|
62803
|
+
});
|
|
62804
|
+
if (mirroredSkillsDir !== void 0)
|
|
62805
|
+
extraSkillDirs.push(mirroredSkillsDir);
|
|
62806
|
+
} else {
|
|
62807
|
+
mirroredSkillsDir = void 0;
|
|
62808
|
+
}
|
|
62629
62809
|
return config2;
|
|
62630
62810
|
}
|
|
62631
62811
|
function announceConfigRecovery() {
|
|
@@ -62795,7 +62975,21 @@ ${preview.text}` } : {}
|
|
|
62795
62975
|
submitForReview: (request) => services.submitForReview?.({ kind: "skill", ...request }) ?? Promise.resolve("")
|
|
62796
62976
|
} : {}
|
|
62797
62977
|
};
|
|
62798
|
-
|
|
62978
|
+
const skillTarget = cachedSkillMirror?.enabled === true ? targetById(cachedS3, cachedSkillMirror.connectionId) : void 0;
|
|
62979
|
+
const mirrorPrefix = cachedSkillMirror?.prefix;
|
|
62980
|
+
combined.register(createWriteSkillTool({
|
|
62981
|
+
...context,
|
|
62982
|
+
...skillTarget !== void 0 && skillTarget.readOnly !== true ? {
|
|
62983
|
+
onSaved: async (name, content) => {
|
|
62984
|
+
await uploadToS3({
|
|
62985
|
+
target: skillTarget,
|
|
62986
|
+
...mirrorPrefix !== void 0 ? { prefix: mirrorPrefix } : {},
|
|
62987
|
+
relative: `${name}.md`,
|
|
62988
|
+
contents: Buffer.from(content, "utf8")
|
|
62989
|
+
});
|
|
62990
|
+
}
|
|
62991
|
+
} : {}
|
|
62992
|
+
}));
|
|
62799
62993
|
combined.register(createDeleteSkillTool(context));
|
|
62800
62994
|
}
|
|
62801
62995
|
if (workspaceRoot !== void 0) {
|
|
@@ -62830,6 +63024,8 @@ ${preview.text}` } : {}
|
|
|
62830
63024
|
if (codebase !== void 0) {
|
|
62831
63025
|
combined.register(createSearchCodebaseTool({ ...codebase, observer: searchLog }));
|
|
62832
63026
|
}
|
|
63027
|
+
for (const tool of createS3Tools(cachedS3.targets))
|
|
63028
|
+
combined.register(tool);
|
|
62833
63029
|
if (cachedDatasets.length > 0) {
|
|
62834
63030
|
combined.register(createSearchDataTool({
|
|
62835
63031
|
load: async () => Promise.all(cachedDatasets.map(async (dataset) => ({
|
|
@@ -63324,8 +63520,12 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63324
63520
|
skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
|
|
63325
63521
|
searcher: search.searcher,
|
|
63326
63522
|
embedder,
|
|
63327
|
-
|
|
63328
|
-
|
|
63523
|
+
/*
|
|
63524
|
+
* All of them, in order — the first is the ordinary circle and the rest are what a
|
|
63525
|
+
* search widens into when it holds nothing. Handing over only the first is what
|
|
63526
|
+
* made the extra names typed in the panel do nothing at all for skills.
|
|
63527
|
+
*/
|
|
63528
|
+
collections: skillAliases(config2),
|
|
63329
63529
|
...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
|
|
63330
63530
|
} : void 0,
|
|
63331
63531
|
/*
|
|
@@ -64955,15 +65155,168 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
64955
65155
|
const digest = createHash3("sha256").update(path23.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
|
|
64956
65156
|
return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
|
|
64957
65157
|
}
|
|
64958
|
-
async function
|
|
65158
|
+
async function postS3() {
|
|
65159
|
+
const { config: config2 } = await configManager.load();
|
|
65160
|
+
const connections = await Promise.all((config2.s3?.connections ?? []).map(async (connection) => ({
|
|
65161
|
+
id: connection.id,
|
|
65162
|
+
label: connection.label,
|
|
65163
|
+
bucket: connection.bucket,
|
|
65164
|
+
region: connection.region,
|
|
65165
|
+
accessKeyId: connection.accessKeyId,
|
|
65166
|
+
/*
|
|
65167
|
+
* Asked of the secret store rather than inferred from config holding a reference.
|
|
65168
|
+
*
|
|
65169
|
+
* Config and the store are two stores that can diverge, and letting one assert what only
|
|
65170
|
+
* the other knows is what made a vanished API key keep reading as "Set" for three
|
|
65171
|
+
* releases (section 19).
|
|
65172
|
+
*/
|
|
65173
|
+
hasSecret: await secrets.get(connection.secretAccessKeyRef) !== void 0,
|
|
65174
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
65175
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {},
|
|
65176
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
65177
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
65178
|
+
})));
|
|
65179
|
+
post({
|
|
65180
|
+
type: "s3",
|
|
65181
|
+
connections,
|
|
65182
|
+
problems: cachedS3.problems,
|
|
65183
|
+
...config2.s3?.skills !== void 0 ? { skills: config2.s3.skills } : {},
|
|
65184
|
+
...config2.s3?.tools !== void 0 ? { tools: config2.s3.tools } : {},
|
|
65185
|
+
...mirroredSkillsDir !== void 0 ? { skillsFolder: mirroredSkillsDir } : {},
|
|
65186
|
+
...mirroredToolsDir !== void 0 ? { toolsFolder: mirroredToolsDir } : {},
|
|
65187
|
+
...lastSync.skills !== void 0 ? { lastSkillsSync: lastSync.skills } : {},
|
|
65188
|
+
...lastSync.tools !== void 0 ? { lastToolsSync: lastSync.tools } : {}
|
|
65189
|
+
});
|
|
65190
|
+
}
|
|
65191
|
+
const s3SecretRef = (id) => `s3:${id}:secret`;
|
|
65192
|
+
const s3TokenRef = (id) => `s3:${id}:sessionToken`;
|
|
65193
|
+
async function handleSaveS3Connection(input, secret, sessionToken) {
|
|
65194
|
+
const { config: config2 } = await configManager.load();
|
|
65195
|
+
const id = input.id ?? `s3-${Date.now().toString(36)}`;
|
|
65196
|
+
const existing = (config2.s3?.connections ?? []).find((connection) => connection.id === id);
|
|
65197
|
+
if (secret !== void 0 && secret.trim().length > 0) {
|
|
65198
|
+
await secrets.set(s3SecretRef(id), secret.trim());
|
|
65199
|
+
}
|
|
65200
|
+
if (sessionToken !== void 0 && sessionToken.trim().length > 0) {
|
|
65201
|
+
await secrets.set(s3TokenRef(id), sessionToken.trim());
|
|
65202
|
+
}
|
|
65203
|
+
const saved = {
|
|
65204
|
+
id,
|
|
65205
|
+
label: input.label.trim(),
|
|
65206
|
+
bucket: input.bucket.trim(),
|
|
65207
|
+
region: input.region.trim(),
|
|
65208
|
+
accessKeyId: input.accessKeyId.trim(),
|
|
65209
|
+
secretAccessKeyRef: s3SecretRef(id),
|
|
65210
|
+
...existing?.sessionTokenRef !== void 0 || (sessionToken ?? "").trim().length > 0 ? { sessionTokenRef: s3TokenRef(id) } : {},
|
|
65211
|
+
...input.endpoint !== void 0 && input.endpoint.trim().length > 0 ? { endpoint: input.endpoint.trim() } : {},
|
|
65212
|
+
...input.pathStyle === true ? { pathStyle: true } : {},
|
|
65213
|
+
...input.prefix !== void 0 && input.prefix.trim().length > 0 ? { prefix: input.prefix.trim() } : {},
|
|
65214
|
+
...input.readOnly === true ? { readOnly: true } : {}
|
|
65215
|
+
};
|
|
65216
|
+
const others = (config2.s3?.connections ?? []).filter((connection) => connection.id !== id);
|
|
65217
|
+
await configManager.save("user", {
|
|
65218
|
+
s3: { ...config2.s3 ?? {}, connections: [...others, saved] }
|
|
65219
|
+
});
|
|
65220
|
+
await loadSettings();
|
|
65221
|
+
await postS3();
|
|
65222
|
+
}
|
|
65223
|
+
async function handleDeleteS3Connection(id) {
|
|
65224
|
+
const { config: config2 } = await configManager.load();
|
|
65225
|
+
await secrets.delete(s3SecretRef(id)).catch(() => void 0);
|
|
65226
|
+
await secrets.delete(s3TokenRef(id)).catch(() => void 0);
|
|
65227
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65228
|
+
s3.connections = (s3.connections ?? []).filter((connection) => connection.id !== id);
|
|
65229
|
+
if (s3.skills?.connectionId === id)
|
|
65230
|
+
delete s3.skills;
|
|
65231
|
+
if (s3.tools?.connectionId === id)
|
|
65232
|
+
delete s3.tools;
|
|
65233
|
+
await configManager.save("user", { s3 });
|
|
65234
|
+
await loadSettings();
|
|
65235
|
+
await postS3();
|
|
65236
|
+
}
|
|
65237
|
+
async function handleSaveS3Mirror(kind, connectionId, prefix, enabled) {
|
|
65238
|
+
const { config: config2 } = await configManager.load();
|
|
65239
|
+
const s3 = { ...config2.s3 ?? {} };
|
|
65240
|
+
if (connectionId.trim().length === 0)
|
|
65241
|
+
delete s3[kind];
|
|
65242
|
+
else {
|
|
65243
|
+
s3[kind] = {
|
|
65244
|
+
connectionId: connectionId.trim(),
|
|
65245
|
+
...prefix !== void 0 && prefix.trim().length > 0 ? { prefix: prefix.trim() } : {},
|
|
65246
|
+
enabled
|
|
65247
|
+
};
|
|
65248
|
+
}
|
|
65249
|
+
await configManager.save("user", { s3 });
|
|
65250
|
+
await loadSettings();
|
|
65251
|
+
if (enabled && connectionId.trim().length > 0)
|
|
65252
|
+
await handleSyncS3(kind);
|
|
65253
|
+
else
|
|
65254
|
+
await postS3();
|
|
65255
|
+
}
|
|
65256
|
+
async function handleSyncS3(kind) {
|
|
65257
|
+
const { config: config2 } = await configManager.load();
|
|
65258
|
+
const mirror = config2.s3?.[kind];
|
|
65259
|
+
if (mirror === void 0) {
|
|
65260
|
+
lastSync = { ...lastSync, [kind]: "No bucket folder is configured." };
|
|
65261
|
+
await postS3();
|
|
65262
|
+
return;
|
|
65263
|
+
}
|
|
65264
|
+
const target = targetById(cachedS3, mirror.connectionId);
|
|
65265
|
+
if (target === void 0) {
|
|
65266
|
+
lastSync = {
|
|
65267
|
+
...lastSync,
|
|
65268
|
+
[kind]: "That connection is not usable - check its key in the list above."
|
|
65269
|
+
};
|
|
65270
|
+
await postS3();
|
|
65271
|
+
return;
|
|
65272
|
+
}
|
|
65273
|
+
const localDir = mirrorFolder({
|
|
65274
|
+
storageDir,
|
|
65275
|
+
connectionId: mirror.connectionId,
|
|
65276
|
+
kind,
|
|
65277
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
65278
|
+
});
|
|
65279
|
+
if (kind === "tools")
|
|
65280
|
+
mirroredToolsDir = localDir;
|
|
65281
|
+
try {
|
|
65282
|
+
const result = await syncFromS3({
|
|
65283
|
+
target,
|
|
65284
|
+
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
65285
|
+
localDir,
|
|
65286
|
+
fs: new NodeFileSystem(),
|
|
65287
|
+
extensions: kind === "skills" ? [".md"] : [".py"]
|
|
65288
|
+
});
|
|
65289
|
+
const parts = [
|
|
65290
|
+
`${String(result.written.length)} updated`,
|
|
65291
|
+
`${String(result.unchanged)} unchanged`
|
|
65292
|
+
];
|
|
65293
|
+
if (result.failed.length > 0)
|
|
65294
|
+
parts.push(`${String(result.failed.length)} failed`);
|
|
65295
|
+
lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${parts.join(", ")}` };
|
|
65296
|
+
for (const failure of result.failed)
|
|
65297
|
+
logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
|
|
65298
|
+
if (kind === "skills") {
|
|
65299
|
+
await refreshSkills();
|
|
65300
|
+
postSkills();
|
|
65301
|
+
}
|
|
65302
|
+
} catch (error51) {
|
|
65303
|
+
lastSync = { ...lastSync, [kind]: error51 instanceof Error ? error51.message : String(error51) };
|
|
65304
|
+
}
|
|
65305
|
+
await postS3();
|
|
65306
|
+
}
|
|
65307
|
+
async function handleSaveSkillsAlias(aliases) {
|
|
64959
65308
|
try {
|
|
64960
65309
|
const { config: config2 } = await configManager.load();
|
|
64961
|
-
const trimmed = alias.trim();
|
|
64962
65310
|
const embedder = { ...config2.embedder ?? {} };
|
|
64963
|
-
|
|
64964
|
-
|
|
65311
|
+
const { primary, rest } = aliasFields(aliases);
|
|
65312
|
+
if (primary !== void 0)
|
|
65313
|
+
embedder.skillsAlias = primary;
|
|
64965
65314
|
else
|
|
64966
65315
|
delete embedder.skillsAlias;
|
|
65316
|
+
if (rest !== void 0)
|
|
65317
|
+
embedder.skillsAliases = rest;
|
|
65318
|
+
else
|
|
65319
|
+
delete embedder.skillsAliases;
|
|
64967
65320
|
await configManager.save("user", { embedder });
|
|
64968
65321
|
const { config: next } = await configManager.load();
|
|
64969
65322
|
await postEmbedder(next);
|
|
@@ -65685,26 +66038,50 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65685
66038
|
// rather than replacing a blank with the default and looking like it was set.
|
|
65686
66039
|
...config2.embedder?.indexPrefix !== void 0 ? { indexPrefix: config2.embedder.indexPrefix } : {},
|
|
65687
66040
|
...config2.embedder?.indexAlias !== void 0 ? { indexAlias: config2.embedder.indexAlias } : {},
|
|
66041
|
+
/*
|
|
66042
|
+
* Both spellings of both, because the panel shows the merged list and cannot merge what it
|
|
66043
|
+
* was never sent. The singular halves stay for older configs and older builds; the panel
|
|
66044
|
+
* runs them through `codebaseAliases`/`skillAliases`, which is the one place that knows how
|
|
66045
|
+
* the two fit together.
|
|
66046
|
+
*/
|
|
66047
|
+
...config2.embedder?.indexAliases !== void 0 ? { indexAliases: config2.embedder.indexAliases } : {},
|
|
66048
|
+
...config2.embedder?.skillsAliases !== void 0 ? { skillsAliases: config2.embedder.skillsAliases } : {},
|
|
65688
66049
|
...config2.embedder?.skillsAlias !== void 0 ? { skillsAlias: config2.embedder.skillsAlias } : {},
|
|
65689
66050
|
defaultIndexPrefix: DEFAULT_INDEX_PREFIX,
|
|
65690
66051
|
indexedFiles
|
|
65691
66052
|
});
|
|
65692
66053
|
}
|
|
65693
|
-
async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix,
|
|
66054
|
+
async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAliases) {
|
|
65694
66055
|
try {
|
|
65695
|
-
await configManager.
|
|
65696
|
-
|
|
65697
|
-
|
|
65698
|
-
|
|
65699
|
-
|
|
65700
|
-
|
|
65701
|
-
|
|
65702
|
-
|
|
65703
|
-
|
|
65704
|
-
|
|
65705
|
-
|
|
65706
|
-
|
|
65707
|
-
|
|
66056
|
+
const { config: current } = await configManager.load();
|
|
66057
|
+
const embedder = {
|
|
66058
|
+
...current.embedder ?? {},
|
|
66059
|
+
profileId,
|
|
66060
|
+
model,
|
|
66061
|
+
dimensions
|
|
66062
|
+
};
|
|
66063
|
+
const put = (key, value) => {
|
|
66064
|
+
if (value === void 0)
|
|
66065
|
+
return;
|
|
66066
|
+
if (value.trim().length > 0)
|
|
66067
|
+
embedder[key] = value.trim();
|
|
66068
|
+
else
|
|
66069
|
+
delete embedder[key];
|
|
66070
|
+
};
|
|
66071
|
+
put("indexName", indexName);
|
|
66072
|
+
put("indexPrefix", indexPrefix);
|
|
66073
|
+
if (indexAliases !== void 0) {
|
|
66074
|
+
const { primary, rest } = aliasFields(indexAliases);
|
|
66075
|
+
if (primary !== void 0)
|
|
66076
|
+
embedder["indexAlias"] = primary;
|
|
66077
|
+
else
|
|
66078
|
+
delete embedder["indexAlias"];
|
|
66079
|
+
if (rest !== void 0)
|
|
66080
|
+
embedder["indexAliases"] = rest;
|
|
66081
|
+
else
|
|
66082
|
+
delete embedder["indexAliases"];
|
|
66083
|
+
}
|
|
66084
|
+
await configManager.save("user", { embedder });
|
|
65708
66085
|
const { config: config2 } = await configManager.load();
|
|
65709
66086
|
await postEmbedder(config2);
|
|
65710
66087
|
scheduleDocsReindex("index prefix changed");
|
|
@@ -66493,6 +66870,13 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66493
66870
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
66494
66871
|
}
|
|
66495
66872
|
}
|
|
66873
|
+
function reportFailure(operation, work) {
|
|
66874
|
+
work.catch((error51) => {
|
|
66875
|
+
const reason = error51 instanceof Error ? error51.message : String(error51);
|
|
66876
|
+
logger.warn(`${operation} failed`, reason);
|
|
66877
|
+
post({ type: "error", message: `${operation} failed: ${reason}` });
|
|
66878
|
+
});
|
|
66879
|
+
}
|
|
66496
66880
|
const unsubscribe = transport.onMessage((raw) => {
|
|
66497
66881
|
const message3 = raw;
|
|
66498
66882
|
if (message3.type === "sendMessage") {
|
|
@@ -66513,7 +66897,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66513
66897
|
}
|
|
66514
66898
|
})();
|
|
66515
66899
|
} else if (message3.type === "requestMentionCandidates") {
|
|
66516
|
-
|
|
66900
|
+
reportFailure("handleMentionCandidates", handleMentionCandidates(message3.query));
|
|
66517
66901
|
} else if (message3.type === "queueMessage") {
|
|
66518
66902
|
queuedMessages.push(message3.text);
|
|
66519
66903
|
postQueued();
|
|
@@ -66536,21 +66920,21 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66536
66920
|
pendingFormFields.delete(message3.id);
|
|
66537
66921
|
}
|
|
66538
66922
|
} else if (message3.type === "approvalResponseAlways") {
|
|
66539
|
-
|
|
66923
|
+
reportFailure("handleAlwaysAllow", handleAlwaysAllow(message3.id, message3.scope));
|
|
66540
66924
|
} else if (message3.type === "rollback") {
|
|
66541
|
-
|
|
66925
|
+
reportFailure("handleRollback", handleRollback());
|
|
66542
66926
|
} else if (message3.type === "requestSettings") {
|
|
66543
|
-
|
|
66927
|
+
reportFailure("postSettings", postSettings());
|
|
66544
66928
|
} else if (message3.type === "requestTasks") {
|
|
66545
|
-
|
|
66929
|
+
reportFailure("postTasks", postTasks());
|
|
66546
66930
|
} else if (message3.type === "openTask") {
|
|
66547
|
-
|
|
66931
|
+
reportFailure("openTask", openTask(message3.id));
|
|
66548
66932
|
} else if (message3.type === "deleteTask") {
|
|
66549
|
-
|
|
66933
|
+
reportFailure("deleteTask", deleteTask(message3.id));
|
|
66550
66934
|
} else if (message3.type === "newTask") {
|
|
66551
|
-
|
|
66935
|
+
reportFailure("startNewTask", startNewTask());
|
|
66552
66936
|
} else if (message3.type === "setMode") {
|
|
66553
|
-
|
|
66937
|
+
reportFailure("handleSetMode", handleSetMode(message3.modeId));
|
|
66554
66938
|
} else if (message3.type === "setMaxIterations") {
|
|
66555
66939
|
void configManager.save("user", { maxIterations: message3.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66556
66940
|
} else if (message3.type === "setProgrammingProfile") {
|
|
@@ -66578,7 +66962,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66578
66962
|
}
|
|
66579
66963
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66580
66964
|
} else if (message3.type === "setToolTimeoutFor") {
|
|
66581
|
-
|
|
66965
|
+
reportFailure("handleSetToolTimeoutFor", handleSetToolTimeoutFor(message3.name, message3.seconds));
|
|
66582
66966
|
} else if (message3.type === "setToolTimeout") {
|
|
66583
66967
|
void configManager.save("user", {
|
|
66584
66968
|
tools: message3.seconds === void 0 ? {} : { timeoutSeconds: message3.seconds }
|
|
@@ -66600,73 +66984,73 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66600
66984
|
}
|
|
66601
66985
|
}).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66602
66986
|
} else if (message3.type === "setAutoApprove") {
|
|
66603
|
-
|
|
66987
|
+
reportFailure("handleSetAutoApprove", handleSetAutoApprove(message3.group, message3.enabled));
|
|
66604
66988
|
} else if (message3.type === "revokeAllowedTool") {
|
|
66605
|
-
|
|
66989
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66606
66990
|
...cachedApprovals,
|
|
66607
66991
|
allowedTools: removeFromAllowlist(message3.toolName, cachedApprovals.allowedTools ?? [])
|
|
66608
|
-
});
|
|
66992
|
+
}));
|
|
66609
66993
|
} else if (message3.type === "revokeAllowedCommand") {
|
|
66610
|
-
|
|
66994
|
+
reportFailure("saveApprovals", saveApprovals({
|
|
66611
66995
|
...cachedApprovals,
|
|
66612
66996
|
allowedCommands: removeFromAllowlist(message3.command, cachedApprovals.allowedCommands ?? [])
|
|
66613
|
-
});
|
|
66997
|
+
}));
|
|
66614
66998
|
} else if (message3.type === "requestMcp") {
|
|
66615
|
-
|
|
66999
|
+
reportFailure("handleRequestMcp", handleRequestMcp());
|
|
66616
67000
|
} else if (message3.type === "saveMcpServers") {
|
|
66617
|
-
|
|
67001
|
+
reportFailure("handleSaveMcpServers", handleSaveMcpServers(message3.json));
|
|
66618
67002
|
} else if (message3.type === "saveMcpServer") {
|
|
66619
|
-
|
|
67003
|
+
reportFailure("handleSaveMcpServer", handleSaveMcpServer(message3.name, message3.previousName, message3.config));
|
|
66620
67004
|
} else if (message3.type === "duplicateMcpServer") {
|
|
66621
|
-
|
|
67005
|
+
reportFailure("handleDuplicateMcpServer", handleDuplicateMcpServer(message3.name));
|
|
66622
67006
|
} else if (message3.type === "deleteMcpServer") {
|
|
66623
|
-
|
|
67007
|
+
reportFailure("handleDeleteMcpServer", handleDeleteMcpServer(message3.name));
|
|
66624
67008
|
} else if (message3.type === "browseForPath") {
|
|
66625
|
-
|
|
67009
|
+
reportFailure("handleBrowseForPath", handleBrowseForPath(message3.purpose, message3.kind, message3.extensions));
|
|
66626
67010
|
} else if (message3.type === "probePythonEnv") {
|
|
66627
|
-
|
|
67011
|
+
reportFailure("handleProbePythonEnv", handleProbePythonEnv(message3.venvDir, message3.script));
|
|
66628
67012
|
} else if (message3.type === "connectMcpServer") {
|
|
66629
67013
|
void mcp.connectServer(message3.name);
|
|
66630
67014
|
} else if (message3.type === "restartMcpServer") {
|
|
66631
67015
|
void mcp.restart(message3.name);
|
|
66632
67016
|
} else if (message3.type === "setMcpServerEnabled") {
|
|
66633
|
-
|
|
67017
|
+
reportFailure("updateMcpServer", updateMcpServer(message3.name, (entry) => ({
|
|
66634
67018
|
...entry,
|
|
66635
67019
|
disabled: !message3.enabled
|
|
66636
|
-
})).then(() => postMcp());
|
|
67020
|
+
})).then(() => postMcp()));
|
|
66637
67021
|
} else if (message3.type === "setMcpToolTimeout") {
|
|
66638
|
-
|
|
67022
|
+
reportFailure("handleSetToolTimeout", handleSetToolTimeout(message3.server, message3.tool, message3.seconds));
|
|
66639
67023
|
} else if (message3.type === "setMcpToolPermission") {
|
|
66640
|
-
|
|
67024
|
+
reportFailure("handleSetToolPermission", handleSetToolPermission(message3.server, message3.tool, message3.permission));
|
|
66641
67025
|
} else if (message3.type === "requestSearch") {
|
|
66642
|
-
|
|
66643
|
-
|
|
67026
|
+
reportFailure("postSearch", postSearch());
|
|
67027
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66644
67028
|
post({ type: "searchLog", entries: [...searchLog.list()] });
|
|
66645
67029
|
} else if (message3.type === "saveSearchConnection") {
|
|
66646
|
-
|
|
67030
|
+
reportFailure("handleSaveSearchConnection", handleSaveSearchConnection(message3.connection));
|
|
66647
67031
|
} else if (message3.type === "deleteSearchConnection") {
|
|
66648
|
-
|
|
67032
|
+
reportFailure("handleDeleteSearchConnection", handleDeleteSearchConnection(message3.id));
|
|
66649
67033
|
} else if (message3.type === "setActiveSearchConnection") {
|
|
66650
67034
|
void (message3.forProject === true ? configManager.saveForWorkspace({ activeVectorStoreId: message3.id }) : configManager.save("user", { activeVectorStoreId: message3.id })).then(async () => {
|
|
66651
67035
|
await postSearch();
|
|
66652
67036
|
await postProjectSettings();
|
|
66653
67037
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66654
67038
|
} else if (message3.type === "requestProjectSettings") {
|
|
66655
|
-
|
|
67039
|
+
reportFailure("postProjectSettings", postProjectSettings());
|
|
66656
67040
|
} else if (message3.type === "clearProjectSettings") {
|
|
66657
|
-
|
|
67041
|
+
reportFailure("handleClearProjectSettings", handleClearProjectSettings());
|
|
66658
67042
|
} else if (message3.type === "requestSearchIndexes") {
|
|
66659
|
-
|
|
67043
|
+
reportFailure("handleRequestSearchIndexes", handleRequestSearchIndexes(message3.connection));
|
|
66660
67044
|
} else if (message3.type === "testSearchConnection") {
|
|
66661
|
-
|
|
67045
|
+
reportFailure("handleTestSearchConnection", handleTestSearchConnection(message3.connection));
|
|
66662
67046
|
} else if (message3.type === "syncVectorStore") {
|
|
66663
|
-
|
|
67047
|
+
reportFailure("handleSyncVectorStore", handleSyncVectorStore(message3.fromId));
|
|
66664
67048
|
} else if (message3.type === "clearDocsIndex") {
|
|
66665
|
-
|
|
67049
|
+
reportFailure("handleClearDocsIndex", handleClearDocsIndex(message3.kind));
|
|
66666
67050
|
} else if (message3.type === "clearCodebaseIndex") {
|
|
66667
|
-
|
|
67051
|
+
reportFailure("handleClearCodebaseIndex", handleClearCodebaseIndex());
|
|
66668
67052
|
} else if (message3.type === "openStandingSkill") {
|
|
66669
|
-
|
|
67053
|
+
reportFailure("handleOpenStandingSkill", handleOpenStandingSkill());
|
|
66670
67054
|
} else if (message3.type === "setOffice") {
|
|
66671
67055
|
void configManager.load().then(async () => {
|
|
66672
67056
|
await configManager.save("user", {
|
|
@@ -66680,70 +67064,80 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66680
67064
|
}
|
|
66681
67065
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66682
67066
|
} else if (message3.type === "indexDocs") {
|
|
66683
|
-
|
|
67067
|
+
reportFailure("handleIndexDocs", handleIndexDocs(message3.kind));
|
|
66684
67068
|
} else if (message3.type === "runSearchProbe") {
|
|
66685
|
-
|
|
67069
|
+
reportFailure("handleSearchProbe", handleSearchProbe(message3.query, message3.target));
|
|
66686
67070
|
} else if (message3.type === "clearSearchLog") {
|
|
66687
67071
|
searchLog.clear();
|
|
66688
67072
|
} else if (message3.type === "setDispatcher") {
|
|
66689
|
-
|
|
66690
|
-
|
|
67073
|
+
reportFailure("saveRetrieval", saveRetrieval({ dispatcher: message3.enabled }).then(() => {
|
|
67074
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66691
67075
|
if (message3.enabled)
|
|
66692
67076
|
scheduleDocsReindex("dispatcher enabled");
|
|
66693
|
-
})
|
|
67077
|
+
}));
|
|
66694
67078
|
} else if (message3.type === "setSkillRetrieval") {
|
|
66695
|
-
|
|
66696
|
-
|
|
67079
|
+
reportFailure("saveRetrieval", saveRetrieval({ skills: message3.enabled }).then(() => {
|
|
67080
|
+
reportFailure("postDispatcher", postDispatcher());
|
|
66697
67081
|
if (message3.enabled)
|
|
66698
67082
|
scheduleDocsReindex("skill retrieval enabled");
|
|
66699
|
-
})
|
|
67083
|
+
}));
|
|
66700
67084
|
} else if (message3.type === "startIndexing") {
|
|
66701
|
-
|
|
67085
|
+
reportFailure("handleStartIndexing", handleStartIndexing());
|
|
66702
67086
|
} else if (message3.type === "attachTeamAlias") {
|
|
66703
|
-
|
|
67087
|
+
reportFailure("handleAttachTeamAlias", handleAttachTeamAlias());
|
|
66704
67088
|
} else if (message3.type === "publishTeamSkills") {
|
|
66705
|
-
|
|
67089
|
+
reportFailure("handlePublishTeamSkills", handlePublishTeamSkills());
|
|
66706
67090
|
} else if (message3.type === "syncMail") {
|
|
66707
|
-
|
|
67091
|
+
reportFailure("runMailSync", runMailSync("requested"));
|
|
66708
67092
|
} else if (message3.type === "pruneMail") {
|
|
66709
|
-
|
|
67093
|
+
reportFailure("handlePruneMail", handlePruneMail());
|
|
66710
67094
|
} else if (message3.type === "requestOutlookFolders") {
|
|
66711
|
-
|
|
67095
|
+
reportFailure("handleRequestOutlookFolders", handleRequestOutlookFolders(message3.depth, message3.force === true));
|
|
66712
67096
|
} else if (message3.type === "validateMailFolder") {
|
|
66713
|
-
|
|
67097
|
+
reportFailure("handleValidateMailFolder", handleValidateMailFolder(message3.path));
|
|
66714
67098
|
} else if (message3.type === "requestMailStatus") {
|
|
66715
|
-
|
|
67099
|
+
reportFailure("loadSettings", loadSettings().then((config2) => {
|
|
66716
67100
|
reconcileMailTimer(config2);
|
|
66717
67101
|
reconcileDatasetTimers(config2);
|
|
66718
67102
|
return postMailStatus();
|
|
66719
|
-
});
|
|
67103
|
+
}));
|
|
66720
67104
|
} else if (message3.type === "saveMailSettings") {
|
|
66721
|
-
|
|
67105
|
+
reportFailure("handleSaveMailSettings", handleSaveMailSettings({
|
|
66722
67106
|
enabled: message3.enabled,
|
|
66723
67107
|
folders: message3.folders,
|
|
66724
67108
|
includeSubfolders: message3.includeSubfolders,
|
|
66725
67109
|
syncMinutes: message3.syncMinutes,
|
|
66726
67110
|
retentionMonths: message3.retentionMonths,
|
|
66727
67111
|
...message3.storeId !== void 0 ? { storeId: message3.storeId } : {}
|
|
66728
|
-
});
|
|
67112
|
+
}));
|
|
66729
67113
|
} else if (message3.type === "clearTeamSkills") {
|
|
66730
|
-
|
|
67114
|
+
reportFailure("handleClearTeamSkills", handleClearTeamSkills());
|
|
66731
67115
|
} else if (message3.type === "refreshMail") {
|
|
66732
|
-
|
|
67116
|
+
reportFailure("handleRefreshMail", handleRefreshMail(message3.days));
|
|
66733
67117
|
} else if (message3.type === "requestDatasetStatus") {
|
|
66734
|
-
|
|
67118
|
+
reportFailure("postDatasetStatus", postDatasetStatus());
|
|
66735
67119
|
} else if (message3.type === "saveDataset") {
|
|
66736
|
-
|
|
67120
|
+
reportFailure("handleSaveDataset", handleSaveDataset(message3.dataset));
|
|
66737
67121
|
} else if (message3.type === "deleteDataset") {
|
|
66738
|
-
|
|
67122
|
+
reportFailure("handleDeleteDataset", handleDeleteDataset(message3.id));
|
|
66739
67123
|
} else if (message3.type === "syncDataset") {
|
|
66740
|
-
|
|
67124
|
+
reportFailure("runDatasetSync", runDatasetSync(message3.id, "manual"));
|
|
66741
67125
|
} else if (message3.type === "clearDataset") {
|
|
66742
|
-
|
|
67126
|
+
reportFailure("handleClearDataset", handleClearDataset(message3.id, message3.resync === true));
|
|
66743
67127
|
} else if (message3.type === "clearMailIndex") {
|
|
66744
|
-
|
|
67128
|
+
reportFailure("handleClearMailIndex", handleClearMailIndex(message3.resync === true));
|
|
67129
|
+
} else if (message3.type === "requestS3") {
|
|
67130
|
+
reportFailure("postS3", postS3());
|
|
67131
|
+
} else if (message3.type === "saveS3Connection") {
|
|
67132
|
+
reportFailure("handleSaveS3Connection", handleSaveS3Connection(message3.connection, message3.secret, message3.sessionToken));
|
|
67133
|
+
} else if (message3.type === "deleteS3Connection") {
|
|
67134
|
+
reportFailure("handleDeleteS3Connection", handleDeleteS3Connection(message3.id));
|
|
67135
|
+
} else if (message3.type === "saveS3Mirror") {
|
|
67136
|
+
reportFailure("handleSaveS3Mirror", handleSaveS3Mirror(message3.kind, message3.connectionId, message3.prefix, message3.enabled));
|
|
67137
|
+
} else if (message3.type === "syncS3") {
|
|
67138
|
+
reportFailure("handleSyncS3", handleSyncS3(message3.kind));
|
|
66745
67139
|
} else if (message3.type === "saveSkillsAlias") {
|
|
66746
|
-
|
|
67140
|
+
reportFailure("handleSaveSkillsAlias", handleSaveSkillsAlias(message3.aliases));
|
|
66747
67141
|
} else if (message3.type === "cancelIndexing") {
|
|
66748
67142
|
if (message3.kind === void 0) {
|
|
66749
67143
|
indexingAbort?.abort();
|
|
@@ -66755,23 +67149,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66755
67149
|
indexingAborts.get(message3.kind)?.abort();
|
|
66756
67150
|
}
|
|
66757
67151
|
} else if (message3.type === "saveEmbedder") {
|
|
66758
|
-
|
|
67152
|
+
reportFailure("handleSaveEmbedder", handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases));
|
|
66759
67153
|
} else if (message3.type === "requestEmbedderModels") {
|
|
66760
|
-
|
|
67154
|
+
reportFailure("handleRequestEmbedderModels", handleRequestEmbedderModels(message3.profileId));
|
|
66761
67155
|
} else if (message3.type === "openWalkthrough") {
|
|
66762
67156
|
void ui.openWalkthrough?.();
|
|
66763
67157
|
} else if (message3.type === "requestTools") {
|
|
66764
|
-
|
|
67158
|
+
reportFailure("postTools", postTools());
|
|
66765
67159
|
} else if (message3.type === "requestSchedules") {
|
|
66766
|
-
|
|
67160
|
+
reportFailure("postSchedules", postSchedules());
|
|
66767
67161
|
} else if (message3.type === "saveSchedule") {
|
|
66768
|
-
|
|
67162
|
+
reportFailure("handleSaveSchedule", handleSaveSchedule(message3.schedule));
|
|
66769
67163
|
} else if (message3.type === "duplicateSchedule") {
|
|
66770
|
-
|
|
67164
|
+
reportFailure("handleDuplicateSchedule", handleDuplicateSchedule(message3.id));
|
|
66771
67165
|
} else if (message3.type === "deleteSchedule") {
|
|
66772
|
-
|
|
67166
|
+
reportFailure("handleDeleteSchedule", handleDeleteSchedule(message3.id));
|
|
66773
67167
|
} else if (message3.type === "setScheduleEnabled") {
|
|
66774
|
-
|
|
67168
|
+
reportFailure("handleSetScheduleEnabled", handleSetScheduleEnabled(message3.id, message3.enabled));
|
|
66775
67169
|
} else if (message3.type === "setTaskExpertLimits") {
|
|
66776
67170
|
const next = message3.maxSpendUsd === void 0 && message3.maxConsultations === void 0 ? void 0 : {
|
|
66777
67171
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
@@ -66801,7 +67195,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66801
67195
|
await postExpert({ redetect: false });
|
|
66802
67196
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66803
67197
|
} else if (message3.type === "measureExpertCost") {
|
|
66804
|
-
|
|
67198
|
+
reportFailure("handleMeasureExpertCost", handleMeasureExpertCost());
|
|
66805
67199
|
} else if (message3.type === "clearExpertPricing") {
|
|
66806
67200
|
void configManager.load().then(async ({ config: config2 }) => {
|
|
66807
67201
|
const expert = { ...config2.expert };
|
|
@@ -66811,23 +67205,23 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66811
67205
|
await postExpert({ redetect: false });
|
|
66812
67206
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66813
67207
|
} else if (message3.type === "assessJunior") {
|
|
66814
|
-
|
|
67208
|
+
reportFailure("handleAssessJunior", handleAssessJunior(message3.profileId));
|
|
66815
67209
|
} else if (message3.type === "clearAssessment") {
|
|
66816
|
-
|
|
67210
|
+
reportFailure("handleClearAssessment", handleClearAssessment(message3.model, message3.profileLabel));
|
|
66817
67211
|
} else if (message3.type === "restartScheduler") {
|
|
66818
67212
|
restartScheduleTimer();
|
|
66819
67213
|
logger.info("schedule timer restarted by the user");
|
|
66820
|
-
|
|
67214
|
+
reportFailure("postSchedules", postSchedules());
|
|
66821
67215
|
} else if (message3.type === "deleteScheduleRun") {
|
|
66822
|
-
|
|
67216
|
+
reportFailure("handleDeleteScheduleRun", handleDeleteScheduleRun(message3.id, message3.at));
|
|
66823
67217
|
} else if (message3.type === "clearScheduleRuns") {
|
|
66824
|
-
|
|
67218
|
+
reportFailure("handleClearScheduleRuns", handleClearScheduleRuns(message3.id));
|
|
66825
67219
|
} else if (message3.type === "openScheduleRun") {
|
|
66826
|
-
|
|
67220
|
+
reportFailure("openRunTranscript", openRunTranscript(message3.taskId, message3.title));
|
|
66827
67221
|
} else if (message3.type === "runScheduleNow") {
|
|
66828
|
-
|
|
67222
|
+
reportFailure("runSchedule", runSchedule(message3.id, "manual"));
|
|
66829
67223
|
} else if (message3.type === "requestSkills") {
|
|
66830
|
-
|
|
67224
|
+
reportFailure("postSkills", postSkills());
|
|
66831
67225
|
} else if (message3.type === "saveSkillDirs") {
|
|
66832
67226
|
void configManager.save("user", {
|
|
66833
67227
|
skills: {
|
|
@@ -66836,32 +67230,32 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66836
67230
|
}
|
|
66837
67231
|
}).then(() => postSkills()).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
66838
67232
|
} else if (message3.type === "openManagedFile") {
|
|
66839
|
-
|
|
67233
|
+
reportFailure("handleOpenManagedFile", handleOpenManagedFile(message3.path));
|
|
66840
67234
|
} else if (message3.type === "deletePythonTool") {
|
|
66841
|
-
|
|
67235
|
+
reportFailure("handleDeletePythonTool", handleDeletePythonTool(message3.name));
|
|
66842
67236
|
} else if (message3.type === "approvePythonTool") {
|
|
66843
|
-
|
|
67237
|
+
reportFailure("handleApprovePythonTool", handleApprovePythonTool(message3.name));
|
|
66844
67238
|
} else if (message3.type === "deleteSkillFile") {
|
|
66845
|
-
|
|
67239
|
+
reportFailure("handleDeleteSkillFile", handleDeleteSkillFile(message3.name));
|
|
66846
67240
|
} else if (message3.type === "requestPython") {
|
|
66847
|
-
|
|
67241
|
+
reportFailure("postPython", postPython());
|
|
66848
67242
|
} else if (message3.type === "setPython") {
|
|
66849
|
-
|
|
67243
|
+
reportFailure("handleSetPython", handleSetPython(message3));
|
|
66850
67244
|
} else if (message3.type === "requestNetwork") {
|
|
66851
|
-
|
|
67245
|
+
reportFailure("postNetwork", postNetwork());
|
|
66852
67246
|
} else if (message3.type === "saveNetwork") {
|
|
66853
|
-
|
|
67247
|
+
reportFailure("handleSaveNetwork", handleSaveNetwork(message3.settings));
|
|
66854
67248
|
} else if (message3.type === "requestExpert") {
|
|
66855
|
-
|
|
67249
|
+
reportFailure("postExpert", postExpert());
|
|
66856
67250
|
} else if (message3.type === "setPlan") {
|
|
66857
|
-
|
|
67251
|
+
reportFailure("applyPlan", applyPlan(message3.plan));
|
|
66858
67252
|
} else if (message3.type === "requestPlan") {
|
|
66859
67253
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
66860
67254
|
postPlanProgress();
|
|
66861
67255
|
} else if (message3.type === "requestPlanProgress") {
|
|
66862
67256
|
postPlanProgress();
|
|
66863
67257
|
} else if (message3.type === "requestAgents") {
|
|
66864
|
-
|
|
67258
|
+
reportFailure("postAgents", postAgents());
|
|
66865
67259
|
} else if (message3.type === "setAgentRole") {
|
|
66866
67260
|
const assignment = message3.assignment;
|
|
66867
67261
|
const role = message3.role;
|
|
@@ -66869,7 +67263,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66869
67263
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66870
67264
|
return;
|
|
66871
67265
|
}
|
|
66872
|
-
|
|
67266
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66873
67267
|
const roles = { ...current.roles ?? {} };
|
|
66874
67268
|
if (assignment === void 0)
|
|
66875
67269
|
delete roles[role];
|
|
@@ -66881,7 +67275,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66881
67275
|
};
|
|
66882
67276
|
}
|
|
66883
67277
|
return { ...current, roles };
|
|
66884
|
-
});
|
|
67278
|
+
}));
|
|
66885
67279
|
} else if (message3.type === "setAgentPrompt") {
|
|
66886
67280
|
const role = message3.role;
|
|
66887
67281
|
const prompt = message3.prompt;
|
|
@@ -66889,7 +67283,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66889
67283
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66890
67284
|
return;
|
|
66891
67285
|
}
|
|
66892
|
-
|
|
67286
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66893
67287
|
const roles = { ...current.roles ?? {} };
|
|
66894
67288
|
const existing = roles[role];
|
|
66895
67289
|
if (prompt === void 0 || prompt === defaultPromptFor(role)) {
|
|
@@ -66902,31 +67296,31 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66902
67296
|
roles[role] = { ...existing ?? { kind: "profile" }, prompt };
|
|
66903
67297
|
}
|
|
66904
67298
|
return { ...current, roles };
|
|
66905
|
-
});
|
|
67299
|
+
}));
|
|
66906
67300
|
} else if (message3.type === "setAgentBudget") {
|
|
66907
67301
|
const matters = message3.matters;
|
|
66908
|
-
|
|
67302
|
+
reportFailure("saveAgents", saveAgents((current) => ({ ...current, budgetMatters: matters })));
|
|
66909
67303
|
} else if (message3.type === "setTeamGuidance") {
|
|
66910
67304
|
const guidance = message3.guidance;
|
|
66911
|
-
|
|
67305
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66912
67306
|
if (guidance === void 0 || guidance.trim().length === 0 || guidance === DEFAULT_TEAM_GUIDANCE) {
|
|
66913
67307
|
const rest = { ...current };
|
|
66914
67308
|
delete rest.teamGuidance;
|
|
66915
67309
|
return rest;
|
|
66916
67310
|
}
|
|
66917
67311
|
return { ...current, teamGuidance: guidance };
|
|
66918
|
-
});
|
|
67312
|
+
}));
|
|
66919
67313
|
} else if (message3.type === "saveCustomRole") {
|
|
66920
|
-
|
|
67314
|
+
reportFailure("handleSaveCustomRole", handleSaveCustomRole(message3));
|
|
66921
67315
|
} else if (message3.type === "deleteCustomRole") {
|
|
66922
|
-
|
|
67316
|
+
reportFailure("handleDeleteCustomRole", handleDeleteCustomRole(message3.id));
|
|
66923
67317
|
} else if (message3.type === "setRoleThinking") {
|
|
66924
67318
|
const role = message3.role;
|
|
66925
67319
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
66926
67320
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66927
67321
|
return;
|
|
66928
67322
|
}
|
|
66929
|
-
|
|
67323
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66930
67324
|
const roles = { ...current.roles ?? {} };
|
|
66931
67325
|
const existing = roles[role] ?? { kind: "profile" };
|
|
66932
67326
|
if (message3.level === void 0) {
|
|
@@ -66937,43 +67331,43 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66937
67331
|
roles[role] = { ...existing, thinking: message3.level };
|
|
66938
67332
|
}
|
|
66939
67333
|
return { ...current, roles };
|
|
66940
|
-
});
|
|
67334
|
+
}));
|
|
66941
67335
|
} else if (message3.type === "setRoleEnabled") {
|
|
66942
67336
|
const role = message3.role;
|
|
66943
67337
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
66944
67338
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66945
67339
|
return;
|
|
66946
67340
|
}
|
|
66947
|
-
|
|
67341
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66948
67342
|
const roles = { ...current.roles ?? {} };
|
|
66949
67343
|
roles[role] = {
|
|
66950
67344
|
...roles[role] ?? { kind: "profile" },
|
|
66951
67345
|
enabled: message3.enabled
|
|
66952
67346
|
};
|
|
66953
67347
|
return { ...current, roles };
|
|
66954
|
-
});
|
|
67348
|
+
}));
|
|
66955
67349
|
} else if (message3.type === "setRoleWrite") {
|
|
66956
67350
|
const role = message3.role;
|
|
66957
67351
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
66958
67352
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66959
67353
|
return;
|
|
66960
67354
|
}
|
|
66961
|
-
|
|
67355
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66962
67356
|
const roles = { ...current.roles ?? {} };
|
|
66963
67357
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, write: message3.canWrite };
|
|
66964
67358
|
return { ...current, roles };
|
|
66965
|
-
});
|
|
67359
|
+
}));
|
|
66966
67360
|
} else if (message3.type === "setRoleTools") {
|
|
66967
67361
|
const role = message3.role;
|
|
66968
67362
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
66969
67363
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66970
67364
|
return;
|
|
66971
67365
|
}
|
|
66972
|
-
|
|
67366
|
+
reportFailure("saveAgents", saveAgents((current) => {
|
|
66973
67367
|
const roles = { ...current.roles ?? {} };
|
|
66974
67368
|
roles[role] = { ...roles[role] ?? { kind: "profile" }, tools: message3.usesTools };
|
|
66975
67369
|
return { ...current, roles };
|
|
66976
|
-
});
|
|
67370
|
+
}));
|
|
66977
67371
|
} else if (message3.type === "setAgentColor") {
|
|
66978
67372
|
const role = message3.role;
|
|
66979
67373
|
const color = message3.color;
|
|
@@ -66981,35 +67375,35 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
66981
67375
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66982
67376
|
return;
|
|
66983
67377
|
}
|
|
66984
|
-
|
|
67378
|
+
reportFailure("saveAgents", saveAgents((current) => ({
|
|
66985
67379
|
...current,
|
|
66986
67380
|
colors: { ...current.colors ?? {}, [role]: color }
|
|
66987
|
-
}));
|
|
67381
|
+
})));
|
|
66988
67382
|
} else if (message3.type === "setExpert") {
|
|
66989
|
-
|
|
67383
|
+
reportFailure("handleSetExpert", handleSetExpert(message3.enabled, message3.path, message3.model, {
|
|
66990
67384
|
...message3.maxSpendUsd !== void 0 ? { maxSpendUsd: message3.maxSpendUsd } : {},
|
|
66991
67385
|
...message3.maxConsultations !== void 0 ? { maxConsultations: message3.maxConsultations } : {},
|
|
66992
67386
|
...message3.profileId !== void 0 ? { profileId: message3.profileId } : {}
|
|
66993
|
-
});
|
|
67387
|
+
}));
|
|
66994
67388
|
} else if (message3.type === "requestProfiles") {
|
|
66995
|
-
|
|
66996
|
-
|
|
67389
|
+
reportFailure("postProfiles", postProfiles());
|
|
67390
|
+
reportFailure("postCapabilities", postCapabilities());
|
|
66997
67391
|
} else if (message3.type === "saveProfile") {
|
|
66998
|
-
|
|
67392
|
+
reportFailure("handleSaveProfile", handleSaveProfile(message3.profile));
|
|
66999
67393
|
} else if (message3.type === "requestModels") {
|
|
67000
|
-
|
|
67394
|
+
reportFailure("handleRequestModels", handleRequestModels(message3.profile));
|
|
67001
67395
|
} else if (message3.type === "testConnection") {
|
|
67002
|
-
|
|
67396
|
+
reportFailure("handleTestConnection", handleTestConnection(message3.profile));
|
|
67003
67397
|
} else if (message3.type === "duplicateProfile") {
|
|
67004
|
-
|
|
67398
|
+
reportFailure("handleDuplicateProfile", handleDuplicateProfile(message3.id));
|
|
67005
67399
|
} else if (message3.type === "deleteProfile") {
|
|
67006
|
-
|
|
67400
|
+
reportFailure("handleDeleteProfile", handleDeleteProfile(message3.id));
|
|
67007
67401
|
} else if (message3.type === "setActiveProfile") {
|
|
67008
|
-
|
|
67402
|
+
reportFailure("handleSetActiveProfile", handleSetActiveProfile(message3.id, message3.forProject));
|
|
67009
67403
|
} else if (message3.type === "exportConfig") {
|
|
67010
|
-
|
|
67404
|
+
reportFailure("handleExportConfig", handleExportConfig());
|
|
67011
67405
|
} else if (message3.type === "importConfig") {
|
|
67012
|
-
|
|
67406
|
+
reportFailure("handleImportConfig", handleImportConfig());
|
|
67013
67407
|
}
|
|
67014
67408
|
});
|
|
67015
67409
|
void (async () => {
|
|
@@ -67524,6 +67918,8 @@ ${contents}
|
|
|
67524
67918
|
}
|
|
67525
67919
|
await postTasks();
|
|
67526
67920
|
await postSettings();
|
|
67921
|
+
await postProfiles();
|
|
67922
|
+
await postS3();
|
|
67527
67923
|
await postSchedules();
|
|
67528
67924
|
} catch (error51) {
|
|
67529
67925
|
logger.warn(`Could not resync the view: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -69437,6 +69833,558 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
69437
69833
|
};
|
|
69438
69834
|
}
|
|
69439
69835
|
|
|
69836
|
+
// ../../packages/core/dist/s3/sigv4.js
|
|
69837
|
+
import { createHash as createHash4, createHmac } from "node:crypto";
|
|
69838
|
+
var EMPTY_PAYLOAD_SHA256 = createHash4("sha256").update("").digest("hex");
|
|
69839
|
+
function encodeSegment(segment) {
|
|
69840
|
+
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
69841
|
+
}
|
|
69842
|
+
function canonicalPath(pathname) {
|
|
69843
|
+
if (pathname === "" || pathname === "/")
|
|
69844
|
+
return "/";
|
|
69845
|
+
return pathname.split("/").map((segment) => {
|
|
69846
|
+
let raw = segment;
|
|
69847
|
+
try {
|
|
69848
|
+
raw = decodeURIComponent(segment);
|
|
69849
|
+
} catch {
|
|
69850
|
+
}
|
|
69851
|
+
return encodeSegment(raw);
|
|
69852
|
+
}).join("/");
|
|
69853
|
+
}
|
|
69854
|
+
function canonicalQuery(search) {
|
|
69855
|
+
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]));
|
|
69856
|
+
return parameters.map(([name, value]) => `${name}=${value}`).join("&");
|
|
69857
|
+
}
|
|
69858
|
+
function amzDate(now) {
|
|
69859
|
+
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
69860
|
+
}
|
|
69861
|
+
function signingKey(secretAccessKey, date5, region, service) {
|
|
69862
|
+
const dateKey = createHmac("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
69863
|
+
const regionKey = createHmac("sha256", dateKey).update(region).digest();
|
|
69864
|
+
const serviceKey = createHmac("sha256", regionKey).update(service).digest();
|
|
69865
|
+
return createHmac("sha256", serviceKey).update("aws4_request").digest();
|
|
69866
|
+
}
|
|
69867
|
+
function signRequest(input) {
|
|
69868
|
+
const service = input.service ?? "s3";
|
|
69869
|
+
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
69870
|
+
const timestamp = amzDate(now);
|
|
69871
|
+
const date5 = timestamp.slice(0, 8);
|
|
69872
|
+
const url2 = new URL(input.url);
|
|
69873
|
+
const body = input.body ?? Buffer.alloc(0);
|
|
69874
|
+
const payloadHash = createHash4("sha256").update(body).digest("hex");
|
|
69875
|
+
const headers = {
|
|
69876
|
+
...input.headers,
|
|
69877
|
+
host: url2.host,
|
|
69878
|
+
"x-amz-content-sha256": payloadHash,
|
|
69879
|
+
"x-amz-date": timestamp,
|
|
69880
|
+
...input.sessionToken !== void 0 ? { "x-amz-security-token": input.sessionToken } : {}
|
|
69881
|
+
};
|
|
69882
|
+
const canonicalHeaderEntries = Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value.trim().replace(/\s+/g, " ")]).sort((a, b) => a[0].localeCompare(b[0]));
|
|
69883
|
+
const signedHeaders = canonicalHeaderEntries.map(([name]) => name).join(";");
|
|
69884
|
+
const canonicalRequest = [
|
|
69885
|
+
input.method.toUpperCase(),
|
|
69886
|
+
canonicalPath(url2.pathname),
|
|
69887
|
+
canonicalQuery(url2.search),
|
|
69888
|
+
`${canonicalHeaderEntries.map(([name, value]) => `${name}:${value}`).join("\n")}
|
|
69889
|
+
`,
|
|
69890
|
+
signedHeaders,
|
|
69891
|
+
payloadHash
|
|
69892
|
+
].join("\n");
|
|
69893
|
+
const scope = `${date5}/${input.region}/${service}/aws4_request`;
|
|
69894
|
+
const stringToSign = [
|
|
69895
|
+
"AWS4-HMAC-SHA256",
|
|
69896
|
+
timestamp,
|
|
69897
|
+
scope,
|
|
69898
|
+
createHash4("sha256").update(canonicalRequest).digest("hex")
|
|
69899
|
+
].join("\n");
|
|
69900
|
+
const signature = createHmac("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
69901
|
+
return {
|
|
69902
|
+
headers: {
|
|
69903
|
+
...headers,
|
|
69904
|
+
Authorization: `AWS4-HMAC-SHA256 Credential=${input.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
69905
|
+
},
|
|
69906
|
+
canonicalRequest,
|
|
69907
|
+
stringToSign,
|
|
69908
|
+
signature
|
|
69909
|
+
};
|
|
69910
|
+
}
|
|
69911
|
+
|
|
69912
|
+
// ../../packages/core/dist/s3/client.js
|
|
69913
|
+
var S3Client = class {
|
|
69914
|
+
http;
|
|
69915
|
+
connection;
|
|
69916
|
+
tls;
|
|
69917
|
+
constructor(http, connection, tls2) {
|
|
69918
|
+
this.http = http;
|
|
69919
|
+
this.connection = connection;
|
|
69920
|
+
this.tls = tls2;
|
|
69921
|
+
}
|
|
69922
|
+
url(call) {
|
|
69923
|
+
const { bucket, region, endpoint, pathStyle } = this.connection;
|
|
69924
|
+
const origin = new URL(endpoint ?? `https://s3.${region}.amazonaws.com`);
|
|
69925
|
+
const key = call.key ?? "";
|
|
69926
|
+
const host = pathStyle === true ? origin.host : `${bucket}.${origin.host}`;
|
|
69927
|
+
const prefix = pathStyle === true ? `/${bucket}` : "";
|
|
69928
|
+
const path32 = key === "" ? "" : `/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
69929
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path32}`);
|
|
69930
|
+
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
69931
|
+
url2.searchParams.set(name, value);
|
|
69932
|
+
return url2.toString();
|
|
69933
|
+
}
|
|
69934
|
+
async send(call) {
|
|
69935
|
+
const url2 = this.url(call);
|
|
69936
|
+
const signed = signRequest({
|
|
69937
|
+
method: call.method,
|
|
69938
|
+
url: url2,
|
|
69939
|
+
headers: call.headers ?? {},
|
|
69940
|
+
...call.bodyBytes !== void 0 ? { body: Buffer.from(call.bodyBytes) } : {},
|
|
69941
|
+
region: this.connection.region,
|
|
69942
|
+
accessKeyId: this.connection.accessKeyId,
|
|
69943
|
+
secretAccessKey: this.connection.secretAccessKey,
|
|
69944
|
+
...this.connection.sessionToken !== void 0 ? { sessionToken: this.connection.sessionToken } : {}
|
|
69945
|
+
});
|
|
69946
|
+
const response = await this.http.request(url2, {
|
|
69947
|
+
method: call.method,
|
|
69948
|
+
headers: signed.headers,
|
|
69949
|
+
...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
|
|
69950
|
+
...call.signal !== void 0 ? { signal: call.signal } : {},
|
|
69951
|
+
...this.tls !== void 0 ? { tls: this.tls } : {}
|
|
69952
|
+
});
|
|
69953
|
+
const bytes = await readAll(response);
|
|
69954
|
+
return { status: response.status, text: bytes.toString("utf8"), bytes };
|
|
69955
|
+
}
|
|
69956
|
+
/**
|
|
69957
|
+
* Objects under a prefix.
|
|
69958
|
+
*
|
|
69959
|
+
* Follows the continuation token rather than stopping at the first page: a folder of 1,200 files
|
|
69960
|
+
* silently reported as 1,000 is the kind of wrong answer nobody thinks to check.
|
|
69961
|
+
*/
|
|
69962
|
+
async list(prefix, limit = 1e3, signal) {
|
|
69963
|
+
const found = [];
|
|
69964
|
+
let token;
|
|
69965
|
+
while (found.length < limit) {
|
|
69966
|
+
const query = {
|
|
69967
|
+
"list-type": "2",
|
|
69968
|
+
"max-keys": String(Math.min(1e3, limit - found.length))
|
|
69969
|
+
};
|
|
69970
|
+
if (prefix !== "")
|
|
69971
|
+
query["prefix"] = prefix;
|
|
69972
|
+
if (token !== void 0)
|
|
69973
|
+
query["continuation-token"] = token;
|
|
69974
|
+
const result = await this.send({
|
|
69975
|
+
method: "GET",
|
|
69976
|
+
query,
|
|
69977
|
+
...signal !== void 0 ? { signal } : {}
|
|
69978
|
+
});
|
|
69979
|
+
if (result.status !== 200)
|
|
69980
|
+
throw new Error(describeFailure(result.status, result.text));
|
|
69981
|
+
found.push(...parseListing(result.text));
|
|
69982
|
+
token = matchTag(result.text, "NextContinuationToken");
|
|
69983
|
+
if (token === void 0)
|
|
69984
|
+
break;
|
|
69985
|
+
}
|
|
69986
|
+
return found.slice(0, limit);
|
|
69987
|
+
}
|
|
69988
|
+
async get(key, signal) {
|
|
69989
|
+
const result = await this.send({
|
|
69990
|
+
method: "GET",
|
|
69991
|
+
key,
|
|
69992
|
+
...signal !== void 0 ? { signal } : {}
|
|
69993
|
+
});
|
|
69994
|
+
if (result.status !== 200)
|
|
69995
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
69996
|
+
return result.bytes;
|
|
69997
|
+
}
|
|
69998
|
+
async put(key, bytes, contentType2, signal) {
|
|
69999
|
+
const result = await this.send({
|
|
70000
|
+
method: "PUT",
|
|
70001
|
+
key,
|
|
70002
|
+
bodyBytes: bytes,
|
|
70003
|
+
...contentType2 !== void 0 ? { headers: { "content-type": contentType2 } } : {},
|
|
70004
|
+
...signal !== void 0 ? { signal } : {}
|
|
70005
|
+
});
|
|
70006
|
+
if (result.status !== 200 && result.status !== 204) {
|
|
70007
|
+
throw new Error(describeFailure(result.status, result.text, key));
|
|
70008
|
+
}
|
|
70009
|
+
}
|
|
70010
|
+
};
|
|
70011
|
+
async function readAll(response) {
|
|
70012
|
+
if (response.body === null)
|
|
70013
|
+
return Buffer.from(await response.text(), "utf8");
|
|
70014
|
+
const reader = response.body.getReader();
|
|
70015
|
+
const chunks = [];
|
|
70016
|
+
for (; ; ) {
|
|
70017
|
+
const { done, value } = await reader.read();
|
|
70018
|
+
if (done)
|
|
70019
|
+
break;
|
|
70020
|
+
if (value !== void 0)
|
|
70021
|
+
chunks.push(value);
|
|
70022
|
+
}
|
|
70023
|
+
return Buffer.concat(chunks);
|
|
70024
|
+
}
|
|
70025
|
+
function describeFailure(status, body, key) {
|
|
70026
|
+
const code = matchTag(body, "Code");
|
|
70027
|
+
const message3 = matchTag(body, "Message");
|
|
70028
|
+
const what = key === void 0 ? "" : ` for "${key}"`;
|
|
70029
|
+
if (code === void 0)
|
|
70030
|
+
return `S3 request failed${what} with status ${String(status)}.`;
|
|
70031
|
+
return `S3 ${code}${what}: ${message3 ?? `status ${String(status)}`}`;
|
|
70032
|
+
}
|
|
70033
|
+
function matchTag(xml, tag) {
|
|
70034
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(xml);
|
|
70035
|
+
return match?.[1];
|
|
70036
|
+
}
|
|
70037
|
+
function parseListing(xml) {
|
|
70038
|
+
const objects = [];
|
|
70039
|
+
for (const block of xml.split("<Contents>").slice(1)) {
|
|
70040
|
+
const key = matchTag(block, "Key");
|
|
70041
|
+
if (key === void 0)
|
|
70042
|
+
continue;
|
|
70043
|
+
objects.push({
|
|
70044
|
+
key: decodeEntities3(key),
|
|
70045
|
+
size: Number(matchTag(block, "Size") ?? "0"),
|
|
70046
|
+
lastModified: matchTag(block, "LastModified") ?? ""
|
|
70047
|
+
});
|
|
70048
|
+
}
|
|
70049
|
+
return objects;
|
|
70050
|
+
}
|
|
70051
|
+
function decodeEntities3(value) {
|
|
70052
|
+
return value.replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", '"').replaceAll("'", String.fromCharCode(39)).replaceAll("&", "&");
|
|
70053
|
+
}
|
|
70054
|
+
|
|
70055
|
+
// ../../packages/core/dist/s3/keys.js
|
|
70056
|
+
function normalisePrefix(prefix) {
|
|
70057
|
+
const trimmed = (prefix ?? "").trim().replace(/^\/+/, "");
|
|
70058
|
+
if (trimmed === "")
|
|
70059
|
+
return "";
|
|
70060
|
+
return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
|
|
70061
|
+
}
|
|
70062
|
+
function confineKey(requested, prefix) {
|
|
70063
|
+
const clean = requested.trim().replace(/^\/+/, "");
|
|
70064
|
+
if (clean === "")
|
|
70065
|
+
return { ok: false, message: "No key was given." };
|
|
70066
|
+
if (clean.split("/").includes("..")) {
|
|
70067
|
+
return {
|
|
70068
|
+
ok: false,
|
|
70069
|
+
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.`
|
|
70070
|
+
};
|
|
70071
|
+
}
|
|
70072
|
+
const base = normalisePrefix(prefix);
|
|
70073
|
+
if (base === "")
|
|
70074
|
+
return { ok: true, key: clean };
|
|
70075
|
+
const key = clean.startsWith(base) ? clean : `${base}${clean}`;
|
|
70076
|
+
if (!key.startsWith(base)) {
|
|
70077
|
+
return { ok: false, message: `"${requested}" is outside "${base}", which this connection is limited to.` };
|
|
70078
|
+
}
|
|
70079
|
+
return { ok: true, key };
|
|
70080
|
+
}
|
|
70081
|
+
function displayKey(key, prefix) {
|
|
70082
|
+
const base = normalisePrefix(prefix);
|
|
70083
|
+
return base !== "" && key.startsWith(base) ? key.slice(base.length) : key;
|
|
70084
|
+
}
|
|
70085
|
+
|
|
70086
|
+
// ../../packages/core/dist/s3/resolve.js
|
|
70087
|
+
async function resolveS3(options) {
|
|
70088
|
+
const targets = [];
|
|
70089
|
+
const problems = [];
|
|
70090
|
+
for (const connection of options.config?.connections ?? []) {
|
|
70091
|
+
const secret = await options.secrets.get(connection.secretAccessKeyRef);
|
|
70092
|
+
if (secret === void 0 || secret.trim().length === 0) {
|
|
70093
|
+
problems.push({
|
|
70094
|
+
label: connection.label,
|
|
70095
|
+
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."
|
|
70096
|
+
});
|
|
70097
|
+
continue;
|
|
70098
|
+
}
|
|
70099
|
+
const sessionToken = connection.sessionTokenRef === void 0 ? void 0 : await options.secrets.get(connection.sessionTokenRef);
|
|
70100
|
+
const client = new S3Client(options.http, {
|
|
70101
|
+
bucket: connection.bucket,
|
|
70102
|
+
region: connection.region,
|
|
70103
|
+
accessKeyId: connection.accessKeyId,
|
|
70104
|
+
secretAccessKey: secret,
|
|
70105
|
+
...sessionToken !== void 0 ? { sessionToken } : {},
|
|
70106
|
+
...connection.endpoint !== void 0 ? { endpoint: connection.endpoint } : {},
|
|
70107
|
+
...connection.pathStyle !== void 0 ? { pathStyle: connection.pathStyle } : {}
|
|
70108
|
+
}, options.tls);
|
|
70109
|
+
targets.push({
|
|
70110
|
+
id: connection.id,
|
|
70111
|
+
label: connection.label,
|
|
70112
|
+
bucket: connection.bucket,
|
|
70113
|
+
client,
|
|
70114
|
+
...connection.prefix !== void 0 ? { prefix: connection.prefix } : {},
|
|
70115
|
+
...connection.readOnly !== void 0 ? { readOnly: connection.readOnly } : {}
|
|
70116
|
+
});
|
|
70117
|
+
}
|
|
70118
|
+
return { targets, problems };
|
|
70119
|
+
}
|
|
70120
|
+
function targetById(resolved, id) {
|
|
70121
|
+
if (id === void 0)
|
|
70122
|
+
return void 0;
|
|
70123
|
+
return resolved.targets.find((target) => target.id === id);
|
|
70124
|
+
}
|
|
70125
|
+
|
|
70126
|
+
// ../../packages/core/dist/s3/sync.js
|
|
70127
|
+
var DEFAULT_LIMIT2 = 500;
|
|
70128
|
+
async function syncFromS3(options) {
|
|
70129
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70130
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70131
|
+
const result = { written: [], unchanged: 0, failed: [] };
|
|
70132
|
+
const objects = await options.target.client.list(where, options.limit ?? DEFAULT_LIMIT2, options.signal);
|
|
70133
|
+
for (const object3 of objects) {
|
|
70134
|
+
const relative = object3.key.slice(where.length);
|
|
70135
|
+
if (relative === "" || relative.endsWith("/"))
|
|
70136
|
+
continue;
|
|
70137
|
+
if (!options.extensions.some((extension) => relative.toLowerCase().endsWith(extension)))
|
|
70138
|
+
continue;
|
|
70139
|
+
if (relative.split("/").includes("..")) {
|
|
70140
|
+
result.failed.push({ key: object3.key, problem: "The key would write outside the folder." });
|
|
70141
|
+
continue;
|
|
70142
|
+
}
|
|
70143
|
+
try {
|
|
70144
|
+
const bytes = await options.target.client.get(object3.key, options.signal);
|
|
70145
|
+
const localPath = join(options.localDir, relative);
|
|
70146
|
+
let existing;
|
|
70147
|
+
try {
|
|
70148
|
+
existing = await options.fs.readBytes(localPath);
|
|
70149
|
+
} catch {
|
|
70150
|
+
}
|
|
70151
|
+
if (existing !== void 0 && existing.equals(bytes)) {
|
|
70152
|
+
result.unchanged += 1;
|
|
70153
|
+
continue;
|
|
70154
|
+
}
|
|
70155
|
+
await options.fs.mkdir(dirname(localPath));
|
|
70156
|
+
await options.fs.writeBytes(localPath, bytes);
|
|
70157
|
+
result.written.push(relative);
|
|
70158
|
+
} catch (error51) {
|
|
70159
|
+
result.failed.push({
|
|
70160
|
+
key: object3.key,
|
|
70161
|
+
problem: error51 instanceof Error ? error51.message : String(error51)
|
|
70162
|
+
});
|
|
70163
|
+
}
|
|
70164
|
+
}
|
|
70165
|
+
return result;
|
|
70166
|
+
}
|
|
70167
|
+
async function uploadToS3(options) {
|
|
70168
|
+
if (options.target.readOnly === true) {
|
|
70169
|
+
throw new Error(`The connection "${options.target.label}" is read-only.`);
|
|
70170
|
+
}
|
|
70171
|
+
const base = normalisePrefix(options.target.prefix);
|
|
70172
|
+
const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
|
|
70173
|
+
await options.target.client.put(`${where}${options.relative}`, options.contents, void 0, options.signal);
|
|
70174
|
+
}
|
|
70175
|
+
function join(dir, relative) {
|
|
70176
|
+
const left = dir.replace(/[\\/]+$/, "");
|
|
70177
|
+
return `${left}/${relative}`;
|
|
70178
|
+
}
|
|
70179
|
+
function dirname(filePath) {
|
|
70180
|
+
const cut = filePath.lastIndexOf("/");
|
|
70181
|
+
return cut === -1 ? filePath : filePath.slice(0, cut);
|
|
70182
|
+
}
|
|
70183
|
+
|
|
70184
|
+
// ../../packages/core/dist/s3/tools.js
|
|
70185
|
+
function pick2(targets, wanted) {
|
|
70186
|
+
if (wanted === void 0) {
|
|
70187
|
+
if (targets.length === 1)
|
|
70188
|
+
return targets[0];
|
|
70189
|
+
return `Several buckets are configured. Name one with "connection": ${targets.map((target) => target.label).join(", ")}.`;
|
|
70190
|
+
}
|
|
70191
|
+
const found = targets.find((target) => target.label.toLowerCase() === wanted.toLowerCase() || target.id === wanted);
|
|
70192
|
+
if (found !== void 0)
|
|
70193
|
+
return found;
|
|
70194
|
+
return `There is no S3 connection called "${wanted}". Configured: ${targets.map((target) => target.label).join(", ")}.`;
|
|
70195
|
+
}
|
|
70196
|
+
function looksBinary(bytes) {
|
|
70197
|
+
return bytes.subarray(0, 8e3).includes(0);
|
|
70198
|
+
}
|
|
70199
|
+
function describeSize(bytes) {
|
|
70200
|
+
if (bytes < 1024)
|
|
70201
|
+
return `${String(bytes)} B`;
|
|
70202
|
+
if (bytes < 1024 * 1024)
|
|
70203
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
70204
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
70205
|
+
}
|
|
70206
|
+
var failed = (error51) => ({
|
|
70207
|
+
content: error51 instanceof Error ? error51.message : String(error51),
|
|
70208
|
+
isError: true
|
|
70209
|
+
});
|
|
70210
|
+
function whichBuckets(targets) {
|
|
70211
|
+
return targets.length === 1 ? `the S3 bucket "${targets[0]?.label ?? ""}"` : `an S3 bucket (${targets.map((target) => target.label).join(", ")})`;
|
|
70212
|
+
}
|
|
70213
|
+
var connectionField = external_exports.string().optional().describe("Which configured bucket to use. May be omitted when only one is set up.");
|
|
70214
|
+
var listSchema = external_exports.object({
|
|
70215
|
+
connection: connectionField,
|
|
70216
|
+
prefix: external_exports.string().optional().describe("Folder to list, relative to the connection\u2019s own prefix. Omit for everything."),
|
|
70217
|
+
limit: external_exports.number().int().min(1).max(1e3).optional().describe("How many to return. Default 100.")
|
|
70218
|
+
});
|
|
70219
|
+
function createS3ListTool(targets) {
|
|
70220
|
+
return {
|
|
70221
|
+
name: "s3_list_files",
|
|
70222
|
+
group: "read",
|
|
70223
|
+
description: `List files in ${whichBuckets(targets)}. Use it to find what is there before reading or downloading. Returns keys, sizes and dates, never contents.`,
|
|
70224
|
+
parametersSchema: listSchema,
|
|
70225
|
+
async execute(params, context) {
|
|
70226
|
+
const target = pick2(targets, params.connection);
|
|
70227
|
+
if (typeof target === "string")
|
|
70228
|
+
return { content: target, isError: true };
|
|
70229
|
+
const base = normalisePrefix(target.prefix);
|
|
70230
|
+
const where = params.prefix === void 0 ? base : normalisePrefix(`${base}${params.prefix}`);
|
|
70231
|
+
try {
|
|
70232
|
+
const found = await target.client.list(where, params.limit ?? 100, context.signal);
|
|
70233
|
+
if (found.length === 0)
|
|
70234
|
+
return { content: `No files under "${where === "" ? "/" : where}".` };
|
|
70235
|
+
const lines = found.map((object3) => `${displayKey(object3.key, target.prefix)} ${describeSize(object3.size)} ${object3.lastModified}`);
|
|
70236
|
+
return { content: [`${String(found.length)} file(s) in ${target.bucket}:`, ...lines].join("\n") };
|
|
70237
|
+
} catch (error51) {
|
|
70238
|
+
return failed(error51);
|
|
70239
|
+
}
|
|
70240
|
+
}
|
|
70241
|
+
};
|
|
70242
|
+
}
|
|
70243
|
+
var readSchema = external_exports.object({
|
|
70244
|
+
connection: connectionField,
|
|
70245
|
+
key: external_exports.string().min(1).describe("The file to read, as s3_list_files reports it.")
|
|
70246
|
+
});
|
|
70247
|
+
function createS3ReadTool(targets) {
|
|
70248
|
+
return {
|
|
70249
|
+
name: "s3_read_file",
|
|
70250
|
+
group: "read",
|
|
70251
|
+
description: `Read a file from ${whichBuckets(targets)} as text. For anything that is not text, use s3_download_file and open it locally.`,
|
|
70252
|
+
parametersSchema: readSchema,
|
|
70253
|
+
async execute(params, context) {
|
|
70254
|
+
const target = pick2(targets, params.connection);
|
|
70255
|
+
if (typeof target === "string")
|
|
70256
|
+
return { content: target, isError: true };
|
|
70257
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70258
|
+
if (!resolved.ok)
|
|
70259
|
+
return { content: resolved.message, isError: true };
|
|
70260
|
+
try {
|
|
70261
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70262
|
+
if (looksBinary(bytes)) {
|
|
70263
|
+
return {
|
|
70264
|
+
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.`
|
|
70265
|
+
};
|
|
70266
|
+
}
|
|
70267
|
+
return { content: bytes.toString("utf8") };
|
|
70268
|
+
} catch (error51) {
|
|
70269
|
+
return failed(error51);
|
|
70270
|
+
}
|
|
70271
|
+
}
|
|
70272
|
+
};
|
|
70273
|
+
}
|
|
70274
|
+
var downloadSchema = external_exports.object({
|
|
70275
|
+
connection: connectionField,
|
|
70276
|
+
key: external_exports.string().min(1).describe("The file in the bucket."),
|
|
70277
|
+
to: external_exports.string().min(1).describe("Where to write it, relative to the workspace root.")
|
|
70278
|
+
});
|
|
70279
|
+
function createS3DownloadTool(targets) {
|
|
70280
|
+
return {
|
|
70281
|
+
name: "s3_download_file",
|
|
70282
|
+
group: "edit",
|
|
70283
|
+
description: `Copy a file out of ${whichBuckets(targets)} onto this machine.`,
|
|
70284
|
+
parametersSchema: downloadSchema,
|
|
70285
|
+
preview: async (params) => {
|
|
70286
|
+
const target = pick2(targets, params.connection);
|
|
70287
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${params.key}`;
|
|
70288
|
+
return { kind: "text", text: `Copy ${where}
|
|
70289
|
+
to ${params.to}` };
|
|
70290
|
+
},
|
|
70291
|
+
async execute(params, context) {
|
|
70292
|
+
const target = pick2(targets, params.connection);
|
|
70293
|
+
if (typeof target === "string")
|
|
70294
|
+
return { content: target, isError: true };
|
|
70295
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70296
|
+
if (!resolved.ok)
|
|
70297
|
+
return { content: resolved.message, isError: true };
|
|
70298
|
+
const to = await resolveToolPath(context, params.to);
|
|
70299
|
+
if (!to.ok)
|
|
70300
|
+
return { content: to.message, isError: true };
|
|
70301
|
+
try {
|
|
70302
|
+
const bytes = await target.client.get(resolved.key, context.signal);
|
|
70303
|
+
await context.fs.writeBytes(to.realPath, bytes);
|
|
70304
|
+
return {
|
|
70305
|
+
content: `Wrote ${describeSize(bytes.length)} to ${params.to} from s3://${target.bucket}/${resolved.key}.`,
|
|
70306
|
+
path: to.realPath
|
|
70307
|
+
};
|
|
70308
|
+
} catch (error51) {
|
|
70309
|
+
return failed(error51);
|
|
70310
|
+
}
|
|
70311
|
+
}
|
|
70312
|
+
};
|
|
70313
|
+
}
|
|
70314
|
+
var uploadSchema = external_exports.object({
|
|
70315
|
+
connection: connectionField,
|
|
70316
|
+
from: external_exports.string().min(1).describe("The local file to upload, relative to the workspace root."),
|
|
70317
|
+
key: external_exports.string().min(1).describe("Where to put it in the bucket.")
|
|
70318
|
+
});
|
|
70319
|
+
function createS3UploadTool(targets) {
|
|
70320
|
+
return {
|
|
70321
|
+
name: "s3_upload_file",
|
|
70322
|
+
group: "edit",
|
|
70323
|
+
description: `Copy a file from this machine into ${whichBuckets(targets)}.`,
|
|
70324
|
+
parametersSchema: uploadSchema,
|
|
70325
|
+
/*
|
|
70326
|
+
* The preview names the destination in full, bucket included.
|
|
70327
|
+
*
|
|
70328
|
+
* Invariant 8: this is the one thing the person approving needs and cannot otherwise check.
|
|
70329
|
+
* A file sent to the wrong bucket is not recoverable by undoing anything here — it is on
|
|
70330
|
+
* somebody else's storage, possibly visible to people the user never intended.
|
|
70331
|
+
*/
|
|
70332
|
+
preview: async (params) => {
|
|
70333
|
+
const target = pick2(targets, params.connection);
|
|
70334
|
+
const where = typeof target === "string" ? "(unknown bucket)" : `s3://${target.bucket}/${normalisePrefix(target.prefix)}${params.key}`;
|
|
70335
|
+
return { kind: "text", text: `Upload ${params.from}
|
|
70336
|
+
to ${where}` };
|
|
70337
|
+
},
|
|
70338
|
+
async execute(params, context) {
|
|
70339
|
+
const target = pick2(targets, params.connection);
|
|
70340
|
+
if (typeof target === "string")
|
|
70341
|
+
return { content: target, isError: true };
|
|
70342
|
+
if (target.readOnly === true) {
|
|
70343
|
+
return { content: `The connection "${target.label}" is read-only.`, isError: true };
|
|
70344
|
+
}
|
|
70345
|
+
const resolved = confineKey(params.key, target.prefix);
|
|
70346
|
+
if (!resolved.ok)
|
|
70347
|
+
return { content: resolved.message, isError: true };
|
|
70348
|
+
const from = await resolveToolPath(context, params.from);
|
|
70349
|
+
if (!from.ok)
|
|
70350
|
+
return { content: from.message, isError: true };
|
|
70351
|
+
try {
|
|
70352
|
+
const bytes = await context.fs.readBytes(from.realPath);
|
|
70353
|
+
await target.client.put(resolved.key, bytes, void 0, context.signal);
|
|
70354
|
+
return { content: `Uploaded ${describeSize(bytes.length)} to s3://${target.bucket}/${resolved.key}.` };
|
|
70355
|
+
} catch (error51) {
|
|
70356
|
+
return failed(error51);
|
|
70357
|
+
}
|
|
70358
|
+
}
|
|
70359
|
+
};
|
|
70360
|
+
}
|
|
70361
|
+
function createS3Tools(targets) {
|
|
70362
|
+
if (targets.length === 0)
|
|
70363
|
+
return [];
|
|
70364
|
+
return [
|
|
70365
|
+
createS3ListTool(targets),
|
|
70366
|
+
createS3ReadTool(targets),
|
|
70367
|
+
createS3DownloadTool(targets),
|
|
70368
|
+
createS3UploadTool(targets)
|
|
70369
|
+
];
|
|
70370
|
+
}
|
|
70371
|
+
|
|
70372
|
+
// ../../packages/core/dist/s3/localFolder.js
|
|
70373
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
70374
|
+
function mirrorFolder(options) {
|
|
70375
|
+
const connection = safeSegment(options.connectionId);
|
|
70376
|
+
const digest = createHash5("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
70377
|
+
return join2(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
70378
|
+
}
|
|
70379
|
+
function safeSegment(id) {
|
|
70380
|
+
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
70381
|
+
const suffix = createHash5("sha256").update(id).digest("hex").slice(0, 6);
|
|
70382
|
+
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
70383
|
+
}
|
|
70384
|
+
function join2(...parts) {
|
|
70385
|
+
return parts.map((part, index) => index === 0 ? part.replace(/[\\/]+$/, "") : part).join("/");
|
|
70386
|
+
}
|
|
70387
|
+
|
|
69440
70388
|
// src/reachableHosts.ts
|
|
69441
70389
|
import os3 from "node:os";
|
|
69442
70390
|
function reachableHosts(bindAddress, port, extra = []) {
|
|
@@ -69480,8 +70428,9 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
69480
70428
|
// src/identity.ts
|
|
69481
70429
|
import crypto5 from "node:crypto";
|
|
69482
70430
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
69483
|
-
describe
|
|
70431
|
+
describe;
|
|
69484
70432
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
70433
|
+
principal;
|
|
69485
70434
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
69486
70435
|
sessionToken = crypto5.randomBytes(32).toString("base64url");
|
|
69487
70436
|
/**
|
|
@@ -69496,9 +70445,19 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
69496
70445
|
handoffToken = crypto5.randomBytes(32).toString("base64url");
|
|
69497
70446
|
handoffExpiresAt;
|
|
69498
70447
|
handoffSeconds;
|
|
69499
|
-
|
|
70448
|
+
/**
|
|
70449
|
+
* @param principal Who this server's storage is filed under. Defaults to the local user.
|
|
70450
|
+
*
|
|
70451
|
+
* Supplied when the platform named the account — `JUPYTERHUB_USER` and friends, see
|
|
70452
|
+
* `hostedUser.ts`. **It changes the name, not the gate.** The bearer token below still decides
|
|
70453
|
+
* who gets in, which is §14's rule that identity resolution must never become a way past the
|
|
70454
|
+
* door: knowing that a server was spawned for Ana says nothing about who is making this request.
|
|
70455
|
+
*/
|
|
70456
|
+
constructor(handoffSeconds = 10, principal) {
|
|
69500
70457
|
this.handoffSeconds = handoffSeconds;
|
|
69501
70458
|
this.handoffExpiresAt = Date.now() + handoffSeconds * 1e3;
|
|
70459
|
+
this.principal = principal ?? _SingleUserIdentity.PRINCIPAL;
|
|
70460
|
+
this.describe = principal === void 0 ? "single user (local)" : `single user \u2014 ${principal.id}`;
|
|
69502
70461
|
}
|
|
69503
70462
|
get launchToken() {
|
|
69504
70463
|
if (this.handoffToken === void 0) throw new Error("handoff token already consumed");
|
|
@@ -69545,7 +70504,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
69545
70504
|
async authenticate(request) {
|
|
69546
70505
|
const header = request.headers.authorization;
|
|
69547
70506
|
if (header === void 0 || !header.startsWith("Bearer ")) return void 0;
|
|
69548
|
-
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ?
|
|
70507
|
+
return timingSafeEquals(header.slice("Bearer ".length), this.sessionToken) ? this.principal : void 0;
|
|
69549
70508
|
}
|
|
69550
70509
|
};
|
|
69551
70510
|
function timingSafeEquals(a, b) {
|
|
@@ -70133,6 +71092,21 @@ function readVariablesFile(filePath) {
|
|
|
70133
71092
|
}
|
|
70134
71093
|
}
|
|
70135
71094
|
|
|
71095
|
+
// src/hostedUser.ts
|
|
71096
|
+
var SOURCES = [
|
|
71097
|
+
/** JupyterHub's own, set in every single-user server it spawns. */
|
|
71098
|
+
"JUPYTERHUB_USER",
|
|
71099
|
+
/** Set by some deployments that front an app without the hub's spawner. */
|
|
71100
|
+
"JUPYTER_USER"
|
|
71101
|
+
];
|
|
71102
|
+
function hostedUser(env2 = process.env) {
|
|
71103
|
+
for (const source of SOURCES) {
|
|
71104
|
+
const value = env2[source]?.trim();
|
|
71105
|
+
if (value !== void 0 && value.length > 0) return { id: value, source };
|
|
71106
|
+
}
|
|
71107
|
+
return void 0;
|
|
71108
|
+
}
|
|
71109
|
+
|
|
70136
71110
|
// src/session.ts
|
|
70137
71111
|
import { watch as fsWatch } from "node:fs";
|
|
70138
71112
|
import fs23 from "node:fs/promises";
|
|
@@ -70665,11 +71639,26 @@ var STREAM_PADDING = `: ${(() => {
|
|
|
70665
71639
|
})()}
|
|
70666
71640
|
|
|
70667
71641
|
`;
|
|
71642
|
+
function principalFromPlatform() {
|
|
71643
|
+
const found = hostedUser();
|
|
71644
|
+
return found === void 0 ? void 0 : { id: found.id, displayName: found.id };
|
|
71645
|
+
}
|
|
70668
71646
|
async function startServer(options) {
|
|
70669
71647
|
const log = options.logSink ?? ((line) => process.stderr.write(`${line}
|
|
70670
71648
|
`));
|
|
70671
71649
|
setFrameAncestors(options.allowFrameAncestors ?? []);
|
|
70672
|
-
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() :
|
|
71650
|
+
const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() : (
|
|
71651
|
+
/*
|
|
71652
|
+
* Named by the platform when it says so, and still gated by the token either way.
|
|
71653
|
+
*
|
|
71654
|
+
* JupyterHub spawns a server per person and sets `JUPYTERHUB_USER` in it, so settings,
|
|
71655
|
+
* secrets and history are filed under that person rather than under "local" — which is
|
|
71656
|
+
* what somebody had otherwise to write a Python function to achieve. Read from this
|
|
71657
|
+
* process's environment, never from a request: see `hostedUser.ts` for why the URL
|
|
71658
|
+
* suffix carrying the same name is not the same fact.
|
|
71659
|
+
*/
|
|
71660
|
+
new SingleUserIdentity(options.handoffSeconds, principalFromPlatform())
|
|
71661
|
+
));
|
|
70673
71662
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
70674
71663
|
const sharedStore = options.sharedConfig;
|
|
70675
71664
|
const sharedSecretStore = new FileSecretStore(path31.join(options.dataDir, "shared-secrets.json"));
|
|
@@ -70724,6 +71713,12 @@ async function startServer(options) {
|
|
|
70724
71713
|
};
|
|
70725
71714
|
const connection = {
|
|
70726
71715
|
transport,
|
|
71716
|
+
/*
|
|
71717
|
+
* Replaced below, once the bridge that owns the state exists. A no-op rather than a missing
|
|
71718
|
+
* field so the object is a complete `Connection` from the moment it is built — a half-built
|
|
71719
|
+
* one handed to anything in between is how a route ends up calling something undefined.
|
|
71720
|
+
*/
|
|
71721
|
+
resync: () => void 0,
|
|
70727
71722
|
deliver: (message3) => {
|
|
70728
71723
|
for (const listener of listeners) listener(message3);
|
|
70729
71724
|
},
|
|
@@ -70831,6 +71826,9 @@ async function startServer(options) {
|
|
|
70831
71826
|
originalDispose();
|
|
70832
71827
|
session.dispose();
|
|
70833
71828
|
};
|
|
71829
|
+
connection.resync = () => {
|
|
71830
|
+
session.resync();
|
|
71831
|
+
};
|
|
70834
71832
|
return connection;
|
|
70835
71833
|
}
|
|
70836
71834
|
const server = createServer((request, response) => {
|
|
@@ -70923,6 +71921,7 @@ async function startServer(options) {
|
|
|
70923
71921
|
if (viaAdminUrl) adminConnections.add(principal.id);
|
|
70924
71922
|
else adminConnections.delete(principal.id);
|
|
70925
71923
|
connection.attach(response);
|
|
71924
|
+
connection.resync();
|
|
70926
71925
|
connection.transport.post({
|
|
70927
71926
|
type: "hostRole",
|
|
70928
71927
|
role: isAdminSession(principal) ? "admin" : "user",
|
|
@@ -70950,6 +71949,7 @@ async function startServer(options) {
|
|
|
70950
71949
|
if (connection === void 0) {
|
|
70951
71950
|
connection = await openConnection(principal);
|
|
70952
71951
|
connections.set(principal.id, connection);
|
|
71952
|
+
connection.resync();
|
|
70953
71953
|
}
|
|
70954
71954
|
respondJson(response, 200, { messages: connection.drain() });
|
|
70955
71955
|
return;
|