@chosengeneration/light-code 0.60.0 → 0.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +559 -19
- package/dist/client/client.js +67 -67
- package/dist/client/index.html +19 -19
- package/dist/server.js +465 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3382,7 +3382,7 @@ var require_util2 = __commonJS({
|
|
|
3382
3382
|
return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin;
|
|
3383
3383
|
}
|
|
3384
3384
|
}
|
|
3385
|
-
function stripURLForReferrer(url2,
|
|
3385
|
+
function stripURLForReferrer(url2, originOnly2) {
|
|
3386
3386
|
assert2(url2 instanceof URL);
|
|
3387
3387
|
if (url2.protocol === "file:" || url2.protocol === "about:" || url2.protocol === "blank:") {
|
|
3388
3388
|
return "no-referrer";
|
|
@@ -3390,7 +3390,7 @@ var require_util2 = __commonJS({
|
|
|
3390
3390
|
url2.username = "";
|
|
3391
3391
|
url2.password = "";
|
|
3392
3392
|
url2.hash = "";
|
|
3393
|
-
if (
|
|
3393
|
+
if (originOnly2) {
|
|
3394
3394
|
url2.pathname = "";
|
|
3395
3395
|
url2.search = "";
|
|
3396
3396
|
}
|
|
@@ -24303,6 +24303,49 @@ function installNodeCompat() {
|
|
|
24303
24303
|
return { installed, nodeVersion: process.version };
|
|
24304
24304
|
}
|
|
24305
24305
|
|
|
24306
|
+
// src/publicUrl.ts
|
|
24307
|
+
function publicAddressFor(port, options) {
|
|
24308
|
+
const env2 = options.env ?? {};
|
|
24309
|
+
const prefix = env2.JUPYTERHUB_SERVICE_PREFIX?.trim();
|
|
24310
|
+
const proxyPath = prefix === void 0 || prefix.length === 0 ? void 0 : `${withSlash(prefix)}proxy/${String(port)}/`;
|
|
24311
|
+
const stated = options.publicUrl?.trim();
|
|
24312
|
+
if (stated !== void 0 && stated.length > 0) {
|
|
24313
|
+
const origin = originOnly(stated);
|
|
24314
|
+
if (origin !== void 0 && proxyPath !== void 0) {
|
|
24315
|
+
return { base: `${origin}${proxyPath}`, source: "--public-url and JupyterHub" };
|
|
24316
|
+
}
|
|
24317
|
+
return { base: withSlash(stated), source: "--public-url" };
|
|
24318
|
+
}
|
|
24319
|
+
if (proxyPath === void 0) return void 0;
|
|
24320
|
+
const hubOrigin = (env2.JUPYTERHUB_PUBLIC_URL ?? env2.JUPYTERHUB_HOST ?? "").trim();
|
|
24321
|
+
if (hubOrigin.length === 0) {
|
|
24322
|
+
return {
|
|
24323
|
+
base: proxyPath,
|
|
24324
|
+
source: "JupyterHub \u2014 append this to the host in your browser, or give --public-url"
|
|
24325
|
+
};
|
|
24326
|
+
}
|
|
24327
|
+
return { base: `${trimSlash(hubOrigin)}${proxyPath}`, source: "JupyterHub" };
|
|
24328
|
+
}
|
|
24329
|
+
function originOnly(value) {
|
|
24330
|
+
if (!/^https?:\/\//i.test(value)) return void 0;
|
|
24331
|
+
try {
|
|
24332
|
+
const url2 = new URL(value);
|
|
24333
|
+
return url2.pathname === "/" || url2.pathname === "" ? url2.origin : void 0;
|
|
24334
|
+
} catch {
|
|
24335
|
+
return void 0;
|
|
24336
|
+
}
|
|
24337
|
+
}
|
|
24338
|
+
function publicLaunchUrl(address, adminMode, token) {
|
|
24339
|
+
const page = `${address.base}${adminMode ? "admin" : ""}`;
|
|
24340
|
+
return token.length > 0 ? `${page}#t=${token}` : page;
|
|
24341
|
+
}
|
|
24342
|
+
function withSlash(value) {
|
|
24343
|
+
return value.endsWith("/") ? value : `${value}/`;
|
|
24344
|
+
}
|
|
24345
|
+
function trimSlash(value) {
|
|
24346
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
24347
|
+
}
|
|
24348
|
+
|
|
24306
24349
|
// src/cli.ts
|
|
24307
24350
|
import { spawn as spawn9 } from "node:child_process";
|
|
24308
24351
|
import fs26 from "node:fs/promises";
|
|
@@ -48306,15 +48349,15 @@ ${record2.preview}`.toLowerCase();
|
|
|
48306
48349
|
const hits = await options.semantic.searcher.searchByVector(options.semantic.collection, vector, {
|
|
48307
48350
|
size: Math.min(100, Math.max(limit * 4, 40))
|
|
48308
48351
|
});
|
|
48309
|
-
const
|
|
48352
|
+
const rank3 = /* @__PURE__ */ new Map();
|
|
48310
48353
|
hits.forEach((hit, position) => {
|
|
48311
48354
|
const id = hit.path.startsWith("mail:") ? hit.path.slice("mail:".length) : hit.path;
|
|
48312
|
-
if (!
|
|
48313
|
-
|
|
48355
|
+
if (!rank3.has(id))
|
|
48356
|
+
rank3.set(id, position);
|
|
48314
48357
|
});
|
|
48315
48358
|
ordered = [...candidates].sort((a, b) => {
|
|
48316
|
-
const left =
|
|
48317
|
-
const right =
|
|
48359
|
+
const left = rank3.get(a.id);
|
|
48360
|
+
const right = rank3.get(b.id);
|
|
48318
48361
|
if (left !== void 0 && right !== void 0)
|
|
48319
48362
|
return left - right;
|
|
48320
48363
|
if (left !== void 0)
|
|
@@ -60961,8 +61004,8 @@ function coerceFormValue(field, raw) {
|
|
|
60961
61004
|
if (field.required !== false && chosen.length === 0) {
|
|
60962
61005
|
return { error: `"${field.label}" needs at least one selection.` };
|
|
60963
61006
|
}
|
|
60964
|
-
const
|
|
60965
|
-
return { value:
|
|
61007
|
+
const order2 = (field.options ?? []).map((option) => option.value);
|
|
61008
|
+
return { value: order2.filter((value) => chosen.includes(value)) };
|
|
60966
61009
|
}
|
|
60967
61010
|
if (field.type === "number") {
|
|
60968
61011
|
const parsed = typeof raw === "number" ? raw : Number(String(raw ?? "").trim());
|
|
@@ -62884,6 +62927,8 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
62884
62927
|
return;
|
|
62885
62928
|
if (chartFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
|
|
62886
62929
|
return;
|
|
62930
|
+
if (diagramFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
|
|
62931
|
+
return;
|
|
62887
62932
|
const summary = toolCallSummary(toolCall);
|
|
62888
62933
|
post({
|
|
62889
62934
|
type: "toolCall",
|
|
@@ -62896,6 +62941,15 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
62896
62941
|
post({ type: "textChunk", text: result.content });
|
|
62897
62942
|
return;
|
|
62898
62943
|
}
|
|
62944
|
+
const diagram = diagramFromToolCall(toolCall.name, toolCall.arguments);
|
|
62945
|
+
if (diagram !== void 0) {
|
|
62946
|
+
post(diagram.kind === "diagram" ? {
|
|
62947
|
+
type: "diagram",
|
|
62948
|
+
diagram: diagram.diagram,
|
|
62949
|
+
...informedBy !== void 0 ? { expertInformed: true, informedBy } : {}
|
|
62950
|
+
} : { type: "diagramError", message: diagram.message });
|
|
62951
|
+
return;
|
|
62952
|
+
}
|
|
62899
62953
|
const chart = chartFromToolCall(toolCall.name, toolCall.arguments);
|
|
62900
62954
|
if (chart !== void 0) {
|
|
62901
62955
|
post(chart.kind === "chart" ? {
|
|
@@ -66549,6 +66603,22 @@ ${entry.content}`);
|
|
|
66549
66603
|
lines.push(`## Chart
|
|
66550
66604
|
|
|
66551
66605
|
Could not be drawn: ${entry.message}`);
|
|
66606
|
+
} else if (entry.kind === "diagramError") {
|
|
66607
|
+
lines.push(`## Diagram
|
|
66608
|
+
|
|
66609
|
+
Could not be drawn: ${entry.message}`);
|
|
66610
|
+
} else if (entry.kind === "diagram") {
|
|
66611
|
+
const diagram = entry.diagram;
|
|
66612
|
+
const labels = new Map(diagram.nodes.map((node) => [node.id, node.label]));
|
|
66613
|
+
lines.push([
|
|
66614
|
+
`## ${diagram.title ?? "Diagram"}`,
|
|
66615
|
+
"",
|
|
66616
|
+
...diagram.edges.map((edge) => {
|
|
66617
|
+
const via = edge.label === void 0 ? "" : ` \u2014 ${edge.label}`;
|
|
66618
|
+
return `- ${labels.get(edge.from) ?? edge.from} \u2192 ${labels.get(edge.to) ?? edge.to}${via}`;
|
|
66619
|
+
}),
|
|
66620
|
+
...diagram.note === void 0 ? [] : ["", diagram.note]
|
|
66621
|
+
].join("\n"));
|
|
66552
66622
|
} else {
|
|
66553
66623
|
const call = entry.toolCall;
|
|
66554
66624
|
lines.push([
|
|
@@ -67132,6 +67202,104 @@ function chartTotals(spec) {
|
|
|
67132
67202
|
return { series, grand: series.reduce((sum, entry) => sum + entry.total, 0) };
|
|
67133
67203
|
}
|
|
67134
67204
|
|
|
67205
|
+
// ../../packages/core/dist/diagrams/types.js
|
|
67206
|
+
var DIAGRAM_MAX_NODES = 40;
|
|
67207
|
+
var DIAGRAM_MAX_EDGES = 80;
|
|
67208
|
+
var NODE_TONES = [
|
|
67209
|
+
"neutral",
|
|
67210
|
+
"accent",
|
|
67211
|
+
"info",
|
|
67212
|
+
"success",
|
|
67213
|
+
"warning",
|
|
67214
|
+
"danger",
|
|
67215
|
+
"muted"
|
|
67216
|
+
];
|
|
67217
|
+
var NODE_ICONS = [
|
|
67218
|
+
"service",
|
|
67219
|
+
"database",
|
|
67220
|
+
"user",
|
|
67221
|
+
"file",
|
|
67222
|
+
"cloud",
|
|
67223
|
+
"lock",
|
|
67224
|
+
"clock",
|
|
67225
|
+
"queue",
|
|
67226
|
+
"code",
|
|
67227
|
+
"mail",
|
|
67228
|
+
"check",
|
|
67229
|
+
"cross",
|
|
67230
|
+
"warning",
|
|
67231
|
+
"gear"
|
|
67232
|
+
];
|
|
67233
|
+
var TEXT_SIZES = ["small", "normal", "large", "xlarge"];
|
|
67234
|
+
var NODE_SHAPES = ["box", "round", "diamond", "cylinder"];
|
|
67235
|
+
var diagramNodeSchema = external_exports.object({
|
|
67236
|
+
id: external_exports.string().min(1).max(64).describe("A short identifier, referenced by edges. Not shown."),
|
|
67237
|
+
label: external_exports.string().min(1).max(120).describe("The text in the box. Keep it to a few words."),
|
|
67238
|
+
shape: external_exports.enum(NODE_SHAPES).optional().describe("box (a step, the default), round (a start or end), diamond (a decision), cylinder (a store or database)."),
|
|
67239
|
+
/** Shown under the label, smaller. For the qualifier that would otherwise bloat the label. */
|
|
67240
|
+
note: external_exports.string().max(120).optional().describe("A second, smaller line under the label."),
|
|
67241
|
+
tone: external_exports.enum(NODE_TONES).optional().describe("What the box means, as a colour: success for a good outcome, danger for a failure, warning for a risk, info for an external system, accent for the thing being explained, muted for context. Resolved against the theme, so it stays legible in light and dark."),
|
|
67242
|
+
icon: external_exports.enum(NODE_ICONS).optional().describe("A small glyph in the corner of the box: service, database, user, file, cloud, lock, clock, queue, code, mail, check, cross, warning, gear."),
|
|
67243
|
+
emphasis: external_exports.enum(["bold"]).optional().describe("Bold the label, for the one or two boxes the diagram is really about."),
|
|
67244
|
+
font: external_exports.enum(["mono"]).optional().describe("Set the label in a monospaced face. For a label that *is* an identifier \u2014 a path, a function, a table, an endpoint \u2014 where proportional text reads as prose."),
|
|
67245
|
+
textSize: external_exports.enum(TEXT_SIZES).optional().describe("How large this box's text is: small, normal, large or xlarge. Use it when the user asks for a particular box to be bigger, or to make the one thing the diagram is about stand out. The box grows with the text, so nothing is cut off.")
|
|
67246
|
+
});
|
|
67247
|
+
var diagramEdgeSchema = external_exports.object({
|
|
67248
|
+
from: external_exports.string().min(1).describe("The id of the node the arrow leaves."),
|
|
67249
|
+
to: external_exports.string().min(1).describe("The id of the node the arrow enters."),
|
|
67250
|
+
label: external_exports.string().max(60).optional().describe('Text on the arrow \u2014 the condition, or what flows along it. "yes", "on failure".'),
|
|
67251
|
+
style: external_exports.enum(["solid", "dashed"]).optional().describe("dashed for something conditional, asynchronous or secondary.")
|
|
67252
|
+
});
|
|
67253
|
+
var diagramLegendSchema = external_exports.object({
|
|
67254
|
+
label: external_exports.string().min(1).max(80).describe("What this appearance means in this diagram."),
|
|
67255
|
+
tone: external_exports.enum(NODE_TONES).optional(),
|
|
67256
|
+
shape: external_exports.enum(NODE_SHAPES).optional(),
|
|
67257
|
+
icon: external_exports.enum(NODE_ICONS).optional()
|
|
67258
|
+
});
|
|
67259
|
+
var DIAGRAM_MAX_LEGEND = 8;
|
|
67260
|
+
var diagramSpecSchema = external_exports.object({
|
|
67261
|
+
title: external_exports.string().max(120).optional(),
|
|
67262
|
+
textSize: external_exports.enum(TEXT_SIZES).optional().describe("The size for every box that does not set its own. Use it when the user says the diagram is too small or too large to read comfortably."),
|
|
67263
|
+
legend: external_exports.array(diagramLegendSchema).max(DIAGRAM_MAX_LEGEND).optional().describe("A key under the diagram. Give an entry only where the meaning is not obvious from the label \u2014 a colour that stands for something, a shape used in a particular way. Explain the diagram, not the palette."),
|
|
67264
|
+
direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
|
|
67265
|
+
nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
|
|
67266
|
+
edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
|
|
67267
|
+
note: external_exports.string().max(400).optional().describe("A line under the diagram. Say what it leaves out, or where it came from.")
|
|
67268
|
+
}).superRefine((spec, context) => {
|
|
67269
|
+
const ids = /* @__PURE__ */ new Set();
|
|
67270
|
+
for (const [index, node] of spec.nodes.entries()) {
|
|
67271
|
+
if (ids.has(node.id)) {
|
|
67272
|
+
context.addIssue({
|
|
67273
|
+
code: "custom",
|
|
67274
|
+
path: ["nodes", index, "id"],
|
|
67275
|
+
/*
|
|
67276
|
+
* Named rather than de-duplicated. Two nodes sharing an id means the edges meant for one
|
|
67277
|
+
* of them are pointing at the other, and silently keeping the first would draw a diagram
|
|
67278
|
+
* that is wrong in a way nobody can see.
|
|
67279
|
+
*/
|
|
67280
|
+
message: `Two nodes share the id "${node.id}". Ids must be unique \u2014 edges are resolved by them.`
|
|
67281
|
+
});
|
|
67282
|
+
}
|
|
67283
|
+
ids.add(node.id);
|
|
67284
|
+
}
|
|
67285
|
+
for (const [index, edge] of spec.edges.entries()) {
|
|
67286
|
+
for (const [end, id] of [
|
|
67287
|
+
["from", edge.from],
|
|
67288
|
+
["to", edge.to]
|
|
67289
|
+
]) {
|
|
67290
|
+
if (!ids.has(id)) {
|
|
67291
|
+
context.addIssue({
|
|
67292
|
+
code: "custom",
|
|
67293
|
+
path: ["edges", index, end],
|
|
67294
|
+
// The available ids are listed: the usual cause is a typo, and a message that names
|
|
67295
|
+
// the candidates is one the model can act on without another round trip.
|
|
67296
|
+
message: `No node has the id "${id}". Known ids: ${[...ids].join(", ")}.`
|
|
67297
|
+
});
|
|
67298
|
+
}
|
|
67299
|
+
}
|
|
67300
|
+
}
|
|
67301
|
+
});
|
|
67302
|
+
|
|
67135
67303
|
// ../../packages/core/dist/history/transcript.js
|
|
67136
67304
|
var CONTROL_TOOLS = /* @__PURE__ */ new Set([
|
|
67137
67305
|
"attempt_completion",
|
|
@@ -67241,6 +67409,16 @@ function consultationFromToolCall(name, rawArguments) {
|
|
|
67241
67409
|
const role = typeof decoded === "object" && decoded !== null ? decoded.role : void 0;
|
|
67242
67410
|
return typeof role === "string" && role.trim().length > 0 ? role.trim().toLowerCase() : "unknown";
|
|
67243
67411
|
}
|
|
67412
|
+
function diagramFromToolCall(name, rawArguments) {
|
|
67413
|
+
const call = throughDispatch(name, rawArguments);
|
|
67414
|
+
if (call.name !== "show_diagram")
|
|
67415
|
+
return void 0;
|
|
67416
|
+
const parsed = diagramSpecSchema.safeParse(call.args);
|
|
67417
|
+
return parsed.success ? { kind: "diagram", diagram: parsed.data } : {
|
|
67418
|
+
kind: "diagramError",
|
|
67419
|
+
message: parsed.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")
|
|
67420
|
+
};
|
|
67421
|
+
}
|
|
67244
67422
|
function chartFromToolCall(name, rawArguments) {
|
|
67245
67423
|
const call = throughDispatch(name, rawArguments);
|
|
67246
67424
|
if (call.name !== "show_chart")
|
|
@@ -67315,6 +67493,323 @@ function createShowChartTool() {
|
|
|
67315
67493
|
};
|
|
67316
67494
|
}
|
|
67317
67495
|
|
|
67496
|
+
// ../../packages/core/dist/diagrams/layout.js
|
|
67497
|
+
var NODE_HEIGHT = 52;
|
|
67498
|
+
var MIN_WIDTH = 96;
|
|
67499
|
+
var MAX_WIDTH = 280;
|
|
67500
|
+
var FACE_WIDTH = { regular: 7.6, bold: 8.2, mono: 8, monoBold: 8 };
|
|
67501
|
+
var SIZE_SCALE = {
|
|
67502
|
+
small: 0.85,
|
|
67503
|
+
normal: 1,
|
|
67504
|
+
large: 1.25,
|
|
67505
|
+
xlarge: 1.55
|
|
67506
|
+
};
|
|
67507
|
+
var NOTE_CHAR_WIDTH = 6.4;
|
|
67508
|
+
var LINE_HEIGHT = 17;
|
|
67509
|
+
var NOTE_LINE_HEIGHT = 14;
|
|
67510
|
+
var LABEL_FONT_SIZE = 13;
|
|
67511
|
+
var NOTE_FONT_SIZE = 11;
|
|
67512
|
+
var PADDING_Y = 15;
|
|
67513
|
+
var PADDING_X = 28;
|
|
67514
|
+
var GAP_WITHIN_RANK = 28;
|
|
67515
|
+
var GAP_BETWEEN_RANKS = 64;
|
|
67516
|
+
var MARGIN = 28;
|
|
67517
|
+
var TITLE_HEIGHT = 40;
|
|
67518
|
+
var SWATCH_WIDTH = 26;
|
|
67519
|
+
var SWATCH_HEIGHT = 16;
|
|
67520
|
+
var SWATCH_GAP = 7;
|
|
67521
|
+
var LEGEND_ITEM_GAP = 22;
|
|
67522
|
+
var LEGEND_ROW_HEIGHT = 24;
|
|
67523
|
+
var LEGEND_TOP_GAP = 18;
|
|
67524
|
+
function wrapText(text, perLine) {
|
|
67525
|
+
const limit = Math.max(4, perLine);
|
|
67526
|
+
const lines = [];
|
|
67527
|
+
let current = "";
|
|
67528
|
+
for (const word of text.split(/\s+/).filter((part) => part.length > 0)) {
|
|
67529
|
+
if (current.length === 0) {
|
|
67530
|
+
current = word;
|
|
67531
|
+
} else if (current.length + 1 + word.length <= limit) {
|
|
67532
|
+
current = `${current} ${word}`;
|
|
67533
|
+
} else {
|
|
67534
|
+
lines.push(current);
|
|
67535
|
+
current = word;
|
|
67536
|
+
}
|
|
67537
|
+
while (current.length > limit) {
|
|
67538
|
+
lines.push(current.slice(0, limit));
|
|
67539
|
+
current = current.slice(limit);
|
|
67540
|
+
}
|
|
67541
|
+
}
|
|
67542
|
+
if (current.length > 0)
|
|
67543
|
+
lines.push(current);
|
|
67544
|
+
return lines.length > 0 ? lines : [""];
|
|
67545
|
+
}
|
|
67546
|
+
function boxFor(label, note, face = "regular", size = "normal") {
|
|
67547
|
+
const scale = SIZE_SCALE[size];
|
|
67548
|
+
const charWidth = FACE_WIDTH[face] * scale;
|
|
67549
|
+
const noteCharWidth = NOTE_CHAR_WIDTH * scale;
|
|
67550
|
+
const lineHeight = LINE_HEIGHT * scale;
|
|
67551
|
+
const noteLineHeight = NOTE_LINE_HEIGHT * scale;
|
|
67552
|
+
const ideal = Math.max(Math.round(label.length * charWidth), note === void 0 ? 0 : Math.round(note.length * noteCharWidth));
|
|
67553
|
+
const maxWidth = MAX_WIDTH * scale;
|
|
67554
|
+
const width = Math.min(maxWidth, Math.max(MIN_WIDTH, ideal + PADDING_X * 2));
|
|
67555
|
+
const usable = width - PADDING_X * 2;
|
|
67556
|
+
const lines = wrapText(label, Math.floor(usable / charWidth));
|
|
67557
|
+
const noteLines = note === void 0 ? [] : wrapText(note, Math.floor(usable / noteCharWidth));
|
|
67558
|
+
const textHeight = lines.length * lineHeight + noteLines.length * noteLineHeight;
|
|
67559
|
+
return {
|
|
67560
|
+
width,
|
|
67561
|
+
height: Math.max(NODE_HEIGHT * scale, textHeight + PADDING_Y * 2),
|
|
67562
|
+
lines,
|
|
67563
|
+
noteLines,
|
|
67564
|
+
fontSize: LABEL_FONT_SIZE * scale,
|
|
67565
|
+
noteFontSize: NOTE_FONT_SIZE * scale,
|
|
67566
|
+
lineHeight,
|
|
67567
|
+
noteLineHeight
|
|
67568
|
+
};
|
|
67569
|
+
}
|
|
67570
|
+
function backEdges(spec) {
|
|
67571
|
+
const outgoing = /* @__PURE__ */ new Map();
|
|
67572
|
+
for (const [index, edge] of spec.edges.entries()) {
|
|
67573
|
+
const list = outgoing.get(edge.from) ?? [];
|
|
67574
|
+
list.push({ to: edge.to, index });
|
|
67575
|
+
outgoing.set(edge.from, list);
|
|
67576
|
+
}
|
|
67577
|
+
const back = /* @__PURE__ */ new Set();
|
|
67578
|
+
const state = /* @__PURE__ */ new Map();
|
|
67579
|
+
const visit = (id) => {
|
|
67580
|
+
state.set(id, "open");
|
|
67581
|
+
for (const edge of outgoing.get(id) ?? []) {
|
|
67582
|
+
const seen = state.get(edge.to);
|
|
67583
|
+
if (seen === "open")
|
|
67584
|
+
back.add(edge.index);
|
|
67585
|
+
else if (seen === void 0)
|
|
67586
|
+
visit(edge.to);
|
|
67587
|
+
}
|
|
67588
|
+
state.set(id, "done");
|
|
67589
|
+
};
|
|
67590
|
+
for (const node of spec.nodes)
|
|
67591
|
+
if (!state.has(node.id))
|
|
67592
|
+
visit(node.id);
|
|
67593
|
+
return back;
|
|
67594
|
+
}
|
|
67595
|
+
function rank2(spec, back) {
|
|
67596
|
+
const incoming = /* @__PURE__ */ new Map();
|
|
67597
|
+
for (const node of spec.nodes)
|
|
67598
|
+
incoming.set(node.id, []);
|
|
67599
|
+
for (const [index, edge] of spec.edges.entries()) {
|
|
67600
|
+
if (back.has(index))
|
|
67601
|
+
continue;
|
|
67602
|
+
incoming.get(edge.to)?.push(edge.from);
|
|
67603
|
+
}
|
|
67604
|
+
const ranks = /* @__PURE__ */ new Map();
|
|
67605
|
+
const resolving = /* @__PURE__ */ new Set();
|
|
67606
|
+
const rankOf = (id) => {
|
|
67607
|
+
const known = ranks.get(id);
|
|
67608
|
+
if (known !== void 0)
|
|
67609
|
+
return known;
|
|
67610
|
+
if (resolving.has(id))
|
|
67611
|
+
return 0;
|
|
67612
|
+
resolving.add(id);
|
|
67613
|
+
const parents = incoming.get(id) ?? [];
|
|
67614
|
+
const depth = parents.length === 0 ? 0 : Math.max(...parents.map((parent) => rankOf(parent) + 1));
|
|
67615
|
+
resolving.delete(id);
|
|
67616
|
+
ranks.set(id, depth);
|
|
67617
|
+
return depth;
|
|
67618
|
+
};
|
|
67619
|
+
for (const node of spec.nodes)
|
|
67620
|
+
rankOf(node.id);
|
|
67621
|
+
return ranks;
|
|
67622
|
+
}
|
|
67623
|
+
function order(spec, ranks, back) {
|
|
67624
|
+
const byRank = [];
|
|
67625
|
+
for (const node of spec.nodes) {
|
|
67626
|
+
const depth = ranks.get(node.id) ?? 0;
|
|
67627
|
+
while (byRank.length <= depth)
|
|
67628
|
+
byRank.push([]);
|
|
67629
|
+
byRank[depth]?.push(node.id);
|
|
67630
|
+
}
|
|
67631
|
+
const parents = /* @__PURE__ */ new Map();
|
|
67632
|
+
for (const [index, edge] of spec.edges.entries()) {
|
|
67633
|
+
if (back.has(index))
|
|
67634
|
+
continue;
|
|
67635
|
+
const list = parents.get(edge.to) ?? [];
|
|
67636
|
+
list.push(edge.from);
|
|
67637
|
+
parents.set(edge.to, list);
|
|
67638
|
+
}
|
|
67639
|
+
for (let depth = 1; depth < byRank.length; depth += 1) {
|
|
67640
|
+
const above = byRank[depth - 1] ?? [];
|
|
67641
|
+
const positions = new Map(above.map((id, index) => [id, index]));
|
|
67642
|
+
const row = byRank[depth] ?? [];
|
|
67643
|
+
const keyed = row.map((id, index) => {
|
|
67644
|
+
const known = (parents.get(id) ?? []).map((parent) => positions.get(parent)).filter((value) => value !== void 0);
|
|
67645
|
+
const barycentre = known.length === 0 ? index : known.reduce((a, b) => a + b, 0) / known.length;
|
|
67646
|
+
return { id, barycentre, index };
|
|
67647
|
+
});
|
|
67648
|
+
keyed.sort((a, b) => a.barycentre - b.barycentre || a.index - b.index);
|
|
67649
|
+
byRank[depth] = keyed.map((entry) => entry.id);
|
|
67650
|
+
}
|
|
67651
|
+
return byRank;
|
|
67652
|
+
}
|
|
67653
|
+
function layoutDiagram(spec) {
|
|
67654
|
+
const sideways = spec.direction === "right";
|
|
67655
|
+
const back = backEdges(spec);
|
|
67656
|
+
const ranks = rank2(spec, back);
|
|
67657
|
+
const rows = order(spec, ranks, back);
|
|
67658
|
+
const byId = new Map(spec.nodes.map((node) => [node.id, node]));
|
|
67659
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
67660
|
+
for (const node of spec.nodes) {
|
|
67661
|
+
const bold = node.emphasis === "bold";
|
|
67662
|
+
const mono = node.font === "mono";
|
|
67663
|
+
const face = mono ? bold ? "monoBold" : "mono" : bold ? "bold" : "regular";
|
|
67664
|
+
sizes.set(node.id, boxFor(node.label, node.note, face, node.textSize ?? spec.textSize ?? "normal"));
|
|
67665
|
+
}
|
|
67666
|
+
const rankExtent = rows.map((row) => Math.max(...row.map((id) => sizes.get(id)?.height ?? NODE_HEIGHT)));
|
|
67667
|
+
const rowWidths = rows.map((row) => row.reduce((total, id) => total + (sizes.get(id)?.width ?? MIN_WIDTH), 0) + GAP_WITHIN_RANK * Math.max(0, row.length - 1));
|
|
67668
|
+
const widest = Math.max(...rowWidths, 1);
|
|
67669
|
+
const placed = [];
|
|
67670
|
+
let cursor = MARGIN + (spec.title === void 0 ? 0 : TITLE_HEIGHT);
|
|
67671
|
+
for (const [depth, row] of rows.entries()) {
|
|
67672
|
+
const extent = rankExtent[depth] ?? NODE_HEIGHT;
|
|
67673
|
+
let x = MARGIN + (widest - (rowWidths[depth] ?? 0)) / 2;
|
|
67674
|
+
for (const id of row) {
|
|
67675
|
+
const node = byId.get(id);
|
|
67676
|
+
const size2 = sizes.get(id);
|
|
67677
|
+
if (node === void 0 || size2 === void 0)
|
|
67678
|
+
continue;
|
|
67679
|
+
placed.push({
|
|
67680
|
+
id,
|
|
67681
|
+
lines: size2.lines,
|
|
67682
|
+
noteLines: size2.noteLines,
|
|
67683
|
+
bold: node.emphasis === "bold",
|
|
67684
|
+
mono: node.font === "mono",
|
|
67685
|
+
fontSize: size2.fontSize,
|
|
67686
|
+
noteFontSize: size2.noteFontSize,
|
|
67687
|
+
lineHeight: size2.lineHeight,
|
|
67688
|
+
noteLineHeight: size2.noteLineHeight,
|
|
67689
|
+
shape: node.shape ?? "box",
|
|
67690
|
+
// A start or an end is accented unless the model said otherwise: the entry and exit of a
|
|
67691
|
+
// flow are what a reader looks for first.
|
|
67692
|
+
tone: node.tone ?? (node.shape === "round" ? "accent" : "neutral"),
|
|
67693
|
+
icon: node.icon,
|
|
67694
|
+
x,
|
|
67695
|
+
// Centred in its rank, so a tall box beside a short one does not look misaligned.
|
|
67696
|
+
y: cursor + (extent - size2.height) / 2,
|
|
67697
|
+
width: size2.width,
|
|
67698
|
+
height: size2.height
|
|
67699
|
+
});
|
|
67700
|
+
x += size2.width + GAP_WITHIN_RANK;
|
|
67701
|
+
}
|
|
67702
|
+
cursor += extent + GAP_BETWEEN_RANKS;
|
|
67703
|
+
}
|
|
67704
|
+
const upright = {
|
|
67705
|
+
width: widest + MARGIN * 2,
|
|
67706
|
+
height: cursor - GAP_BETWEEN_RANKS + MARGIN
|
|
67707
|
+
};
|
|
67708
|
+
const nodes = sideways ? placed.map((node) => ({
|
|
67709
|
+
...node,
|
|
67710
|
+
x: node.y,
|
|
67711
|
+
y: node.x
|
|
67712
|
+
// Size is not transposed: a box swapping its width for its height would wrap its text.
|
|
67713
|
+
})) : placed;
|
|
67714
|
+
const size = sideways ? { width: upright.height, height: upright.width } : { width: upright.width, height: upright.height };
|
|
67715
|
+
const positions = new Map(nodes.map((node) => [node.id, node]));
|
|
67716
|
+
const edges = spec.edges.flatMap((edge, index) => {
|
|
67717
|
+
const from = positions.get(edge.from);
|
|
67718
|
+
const to = positions.get(edge.to);
|
|
67719
|
+
if (from === void 0 || to === void 0)
|
|
67720
|
+
return [];
|
|
67721
|
+
const start = sideways ? { x: from.x + from.width, y: from.y + from.height / 2 } : { x: from.x + from.width / 2, y: from.y + from.height };
|
|
67722
|
+
const end = sideways ? { x: to.x, y: to.y + to.height / 2 } : { x: to.x + to.width / 2, y: to.y };
|
|
67723
|
+
const isBack = back.has(index);
|
|
67724
|
+
const points = isBack ? sideways ? [
|
|
67725
|
+
{ x: from.x + from.width / 2, y: from.y + from.height },
|
|
67726
|
+
{ x: from.x + from.width / 2, y: size.height - MARGIN / 2 },
|
|
67727
|
+
{ x: to.x + to.width / 2, y: size.height - MARGIN / 2 },
|
|
67728
|
+
{ x: to.x + to.width / 2, y: to.y + to.height }
|
|
67729
|
+
] : [
|
|
67730
|
+
{ x: from.x + from.width, y: from.y + from.height / 2 },
|
|
67731
|
+
{ x: size.width - MARGIN / 2, y: from.y + from.height / 2 },
|
|
67732
|
+
{ x: size.width - MARGIN / 2, y: to.y + to.height / 2 },
|
|
67733
|
+
{ x: to.x + to.width, y: to.y + to.height / 2 }
|
|
67734
|
+
] : [start, end];
|
|
67735
|
+
const midpoint = points.length === 2 ? 0 : 1;
|
|
67736
|
+
const a = points[midpoint] ?? start;
|
|
67737
|
+
const b = points[midpoint + 1] ?? end;
|
|
67738
|
+
return [
|
|
67739
|
+
{
|
|
67740
|
+
from: edge.from,
|
|
67741
|
+
to: edge.to,
|
|
67742
|
+
label: edge.label,
|
|
67743
|
+
dashed: edge.style === "dashed",
|
|
67744
|
+
points,
|
|
67745
|
+
labelAt: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }
|
|
67746
|
+
}
|
|
67747
|
+
];
|
|
67748
|
+
});
|
|
67749
|
+
const legend = [];
|
|
67750
|
+
let legendHeight = 0;
|
|
67751
|
+
let canvasWidth = size.width;
|
|
67752
|
+
if (spec.legend !== void 0 && spec.legend.length > 0) {
|
|
67753
|
+
const entryWidths = spec.legend.map((entry) => SWATCH_WIDTH + SWATCH_GAP + Math.round(entry.label.length * 6.6));
|
|
67754
|
+
const available = Math.max(size.width - MARGIN * 2, Math.max(...entryWidths));
|
|
67755
|
+
let x = MARGIN;
|
|
67756
|
+
let y = size.height + LEGEND_TOP_GAP;
|
|
67757
|
+
let rows2 = 1;
|
|
67758
|
+
for (const [index, entry] of spec.legend.entries()) {
|
|
67759
|
+
const entryWidth = entryWidths[index] ?? 0;
|
|
67760
|
+
if (x > MARGIN && x + entryWidth - MARGIN > available) {
|
|
67761
|
+
x = MARGIN;
|
|
67762
|
+
y += LEGEND_ROW_HEIGHT;
|
|
67763
|
+
rows2 += 1;
|
|
67764
|
+
}
|
|
67765
|
+
legend.push({
|
|
67766
|
+
label: entry.label,
|
|
67767
|
+
shape: entry.shape ?? "box",
|
|
67768
|
+
tone: entry.tone ?? "neutral",
|
|
67769
|
+
icon: entry.icon,
|
|
67770
|
+
x,
|
|
67771
|
+
y,
|
|
67772
|
+
swatchWidth: SWATCH_WIDTH,
|
|
67773
|
+
swatchHeight: SWATCH_HEIGHT
|
|
67774
|
+
});
|
|
67775
|
+
x += entryWidth + LEGEND_ITEM_GAP;
|
|
67776
|
+
canvasWidth = Math.max(canvasWidth, x - LEGEND_ITEM_GAP + MARGIN);
|
|
67777
|
+
}
|
|
67778
|
+
legendHeight = LEGEND_TOP_GAP + rows2 * LEGEND_ROW_HEIGHT;
|
|
67779
|
+
}
|
|
67780
|
+
return {
|
|
67781
|
+
width: canvasWidth,
|
|
67782
|
+
height: size.height + legendHeight,
|
|
67783
|
+
title: spec.title,
|
|
67784
|
+
note: spec.note,
|
|
67785
|
+
nodes,
|
|
67786
|
+
edges,
|
|
67787
|
+
legend
|
|
67788
|
+
};
|
|
67789
|
+
}
|
|
67790
|
+
|
|
67791
|
+
// ../../packages/core/dist/tools/showDiagram.js
|
|
67792
|
+
function createShowDiagramTool() {
|
|
67793
|
+
return {
|
|
67794
|
+
name: "show_diagram",
|
|
67795
|
+
group: "always",
|
|
67796
|
+
description: 'Draw a technical diagram for the user: a flow chart, an architecture sketch, a sequence of steps, a state machine. Give `nodes` (each with an `id` and a `label`) and `edges` between those ids \u2014 the layout is worked out for you, so do not attempt coordinates. Use it when a structure is easier seen than described: how a request travels, what calls what, where a decision branches, what happens on failure. Shapes carry the usual meanings \u2014 `round` for a start or end, `diamond` for a decision, `cylinder` for a store, and the default box for a step. Put the condition on the edge (`label: "yes"`, `label: "on timeout"`) rather than inventing a node for it, and use `style: "dashed"` for anything conditional, asynchronous or secondary. Tone colours a box by meaning \u2014 success, danger, warning, info, accent, muted \u2014 and `icon` puts a glyph in its corner. `emphasis: "bold"` for the box the diagram is really about, `font: "mono"` where the label *is* an identifier (a path, a function, a table). `textSize` is small, normal, large or xlarge, on a node for one box or on the diagram for all of them \u2014 use it when the user asks for bigger or smaller text, which they may well do; the box grows with the text so nothing is cut off. A `legend` explains what a colour or a shape stands for *in this diagram*, which is worth giving whenever the meaning is not obvious from the labels. `direction: "right"` suits a pipeline; the default runs downwards and suits most flows. Loops are fine \u2014 an edge pointing back is drawn round the outside. Keep it to the boxes that earn their place: a diagram of forty is a wall, not an explanation, and the limit is a refusal rather than a truncation.',
|
|
67797
|
+
parametersSchema: diagramSpecSchema,
|
|
67798
|
+
async execute(params) {
|
|
67799
|
+
const layout = layoutDiagram(params);
|
|
67800
|
+
const ranks = new Set(layout.nodes.map((node) => node.y)).size;
|
|
67801
|
+
const unreachable = params.nodes.filter((node) => node.id !== params.nodes[0]?.id && !params.edges.some((edge) => edge.to === node.id || edge.from === node.id));
|
|
67802
|
+
return {
|
|
67803
|
+
content: [
|
|
67804
|
+
`Drew a diagram${params.title === void 0 ? "" : ` titled "${params.title}"`} with ${String(params.nodes.length)} node(s) and ${String(params.edges.length)} edge(s), across ${String(ranks)} level(s), running ${params.direction ?? "down"}.`,
|
|
67805
|
+
unreachable.length === 0 ? "" : `${String(unreachable.length)} node(s) have no edges at all and float unconnected: ${unreachable.map((node) => node.id).join(", ")}. Connect them or drop them.`,
|
|
67806
|
+
"The diagram is now in the conversation. Describe what it shows rather than listing the boxes again \u2014 they are on screen."
|
|
67807
|
+
].filter((line) => line !== "").join("\n")
|
|
67808
|
+
};
|
|
67809
|
+
}
|
|
67810
|
+
};
|
|
67811
|
+
}
|
|
67812
|
+
|
|
67318
67813
|
// ../../packages/core/dist/tools/applyDiff/eol.js
|
|
67319
67814
|
function detectEol(text) {
|
|
67320
67815
|
const crlfCount = (text.match(/\r\n/g) ?? []).length;
|
|
@@ -68024,6 +68519,7 @@ function createDefaultToolRegistry() {
|
|
|
68024
68519
|
registry2.register(askFollowupQuestionTool);
|
|
68025
68520
|
registry2.register(createAskUserFormTool());
|
|
68026
68521
|
registry2.register(createShowChartTool());
|
|
68522
|
+
registry2.register(createShowDiagramTool());
|
|
68027
68523
|
registry2.register(attemptCompletionTool);
|
|
68028
68524
|
return registry2;
|
|
68029
68525
|
}
|
|
@@ -68321,14 +68817,14 @@ ${entry.record.text}`.toLowerCase();
|
|
|
68321
68817
|
const hits = await options.semantic.searcher.searchByVector(options.semantic.collection, vector, {
|
|
68322
68818
|
size: Math.min(100, Math.max(limit * 4, 40))
|
|
68323
68819
|
});
|
|
68324
|
-
const
|
|
68820
|
+
const rank3 = /* @__PURE__ */ new Map();
|
|
68325
68821
|
hits.forEach((hit, position) => {
|
|
68326
|
-
if (!
|
|
68327
|
-
|
|
68822
|
+
if (!rank3.has(hit.path))
|
|
68823
|
+
rank3.set(hit.path, position);
|
|
68328
68824
|
});
|
|
68329
68825
|
ordered = [...candidates].sort((a, b) => {
|
|
68330
|
-
const left =
|
|
68331
|
-
const right =
|
|
68826
|
+
const left = rank3.get(`data:${a.datasetId}:${a.record.id}`);
|
|
68827
|
+
const right = rank3.get(`data:${b.datasetId}:${b.record.id}`);
|
|
68332
68828
|
if (left !== void 0 && right !== void 0)
|
|
68333
68829
|
return left - right;
|
|
68334
68830
|
if (left !== void 0)
|
|
@@ -70600,7 +71096,7 @@ function respondJson(response, status, body) {
|
|
|
70600
71096
|
}
|
|
70601
71097
|
|
|
70602
71098
|
// src/cli.ts
|
|
70603
|
-
var VERSION = true ? "0.
|
|
71099
|
+
var VERSION = true ? "0.64.1" : "unknown (not a packaged build)";
|
|
70604
71100
|
var compat = installNodeCompat();
|
|
70605
71101
|
function lastMeaningfulLine(problem) {
|
|
70606
71102
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|
|
@@ -70665,6 +71161,7 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
70665
71161
|
const dataDir = valueOf(args, "--data-dir") ?? envPaths("light-code", { suffix: "" }).data;
|
|
70666
71162
|
const port = Number.parseInt(valueOf(args, "--port") ?? "0", 10);
|
|
70667
71163
|
const noToken = args.includes("--no-token");
|
|
71164
|
+
const publicUrl = valueOf(args, "--public-url");
|
|
70668
71165
|
const allowHosts = valuesOf(args, "--allow-host");
|
|
70669
71166
|
const allowOrigins = valuesOf(args, "--allow-origin");
|
|
70670
71167
|
const handoffSeconds = Math.min(
|
|
@@ -70716,8 +71213,16 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
70716
71213
|
...credentialTool !== void 0 ? { credentialTool: { interpreter: credentialPython, file: credentialTool } } : {},
|
|
70717
71214
|
handoffSeconds,
|
|
70718
71215
|
noToken,
|
|
70719
|
-
|
|
70720
|
-
|
|
71216
|
+
/*
|
|
71217
|
+
* A stated public address is trusted as a name and an origin.
|
|
71218
|
+
*
|
|
71219
|
+
* Otherwise `--public-url` would print a link that the server then refuses: the Host check
|
|
71220
|
+
* exists to catch DNS rebinding, and a proxy legitimately forwards the name the browser used.
|
|
71221
|
+
* Somebody who typed the address is telling us it is theirs, which is the same statement
|
|
71222
|
+
* `--allow-host` makes and this saves them making it twice.
|
|
71223
|
+
*/
|
|
71224
|
+
allowHosts: [...allowHosts, ...trustedFromPublicUrl(publicUrl).hosts],
|
|
71225
|
+
allowOrigins: [...allowOrigins, ...trustedFromPublicUrl(publicUrl).origins],
|
|
70721
71226
|
/*
|
|
70722
71227
|
* A lapsed link is replaced rather than ending the session.
|
|
70723
71228
|
*
|
|
@@ -70746,6 +71251,10 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
70746
71251
|
...bindAddress !== void 0 ? { bindAddress } : {}
|
|
70747
71252
|
});
|
|
70748
71253
|
const launchUrl = `${server.url}${adminMode ? "/admin" : ""}/#t=${server.launchToken ?? ""}`;
|
|
71254
|
+
const publicAddress = publicAddressFor(new URL(server.url).port === "" ? 80 : Number(new URL(server.url).port), {
|
|
71255
|
+
...publicUrl !== void 0 ? { publicUrl } : {},
|
|
71256
|
+
env: process.env
|
|
71257
|
+
});
|
|
70749
71258
|
process.stdout.write(
|
|
70750
71259
|
`
|
|
70751
71260
|
Light Code ${VERSION}
|
|
@@ -70754,6 +71263,14 @@ Light Code ${VERSION}
|
|
|
70754
71263
|
listening ${server.url}
|
|
70755
71264
|
`
|
|
70756
71265
|
);
|
|
71266
|
+
const reachableUrl = publicAddress === void 0 ? noToken ? server.url : launchUrl : publicLaunchUrl(publicAddress, adminMode, noToken ? "" : server.launchToken ?? "");
|
|
71267
|
+
if (publicAddress !== void 0) {
|
|
71268
|
+
process.stdout.write(
|
|
71269
|
+
` open ${reachableUrl}
|
|
71270
|
+
via ${publicAddress.source}
|
|
71271
|
+
`
|
|
71272
|
+
);
|
|
71273
|
+
}
|
|
70757
71274
|
if (noToken) {
|
|
70758
71275
|
process.stdout.write(
|
|
70759
71276
|
` auth none \u2014 --no-token. Any program on this machine can drive this
|
|
@@ -70822,13 +71339,20 @@ Both go through your proxy. Anyone reaching /admin directly is an administrator.
|
|
|
70822
71339
|
* seconds sends them looking for a token that was never minted. Instructions for a
|
|
70823
71340
|
* mechanism that is not running are worse than none.
|
|
70824
71341
|
*/
|
|
71342
|
+
/*
|
|
71343
|
+
* The *reachable* address, which on a server is not the one it binds to.
|
|
71344
|
+
*
|
|
71345
|
+
* This line is the one people copy, so printing loopback here undid the whole point of
|
|
71346
|
+
* working the public address out: the useful URL scrolled past above it, and the useless
|
|
71347
|
+
* one had the last word.
|
|
71348
|
+
*/
|
|
70825
71349
|
noToken ? `Opening ${server.url}
|
|
70826
71350
|
(If the browser does not open, open this \u2014 there is no time limit:)
|
|
70827
|
-
${
|
|
71351
|
+
${reachableUrl}
|
|
70828
71352
|
|
|
70829
71353
|
` : `Opening ${server.url}
|
|
70830
71354
|
(If the browser does not open, paste this within ${String(handoffSeconds)} seconds:)
|
|
70831
|
-
${
|
|
71355
|
+
${reachableUrl}
|
|
70832
71356
|
|
|
70833
71357
|
` + (handoffSeconds === 10 ? " Not long enough? Start with --handoff-seconds 120.\n If it does lapse, a fresh link is printed here \u2014 no need to restart.\n\n" : " If it does lapse, a fresh link is printed here \u2014 no need to restart.\n\n")
|
|
70834
71358
|
);
|
|
@@ -70852,6 +71376,7 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
70852
71376
|
"--data-dir",
|
|
70853
71377
|
"--no-open",
|
|
70854
71378
|
"--no-token",
|
|
71379
|
+
"--public-url",
|
|
70855
71380
|
"--allow-host",
|
|
70856
71381
|
"--allow-origin",
|
|
70857
71382
|
"--server",
|
|
@@ -70866,6 +71391,15 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
70866
71391
|
"--bind",
|
|
70867
71392
|
"--guide"
|
|
70868
71393
|
]);
|
|
71394
|
+
function trustedFromPublicUrl(value) {
|
|
71395
|
+
if (value === void 0 || !/^https?:\/\//i.test(value.trim())) return { hosts: [], origins: [] };
|
|
71396
|
+
try {
|
|
71397
|
+
const url2 = new URL(value.trim());
|
|
71398
|
+
return { hosts: [url2.host], origins: [url2.origin] };
|
|
71399
|
+
} catch {
|
|
71400
|
+
return { hosts: [], origins: [] };
|
|
71401
|
+
}
|
|
71402
|
+
}
|
|
70869
71403
|
function valuesOf(args, flag) {
|
|
70870
71404
|
const values = [];
|
|
70871
71405
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -70931,6 +71465,12 @@ Usage: light-code [options]
|
|
|
70931
71465
|
--bind <address> Interface to listen on (default: 127.0.0.1). Use 0.0.0.0 to
|
|
70932
71466
|
reach it from another machine; it then answers to this
|
|
70933
71467
|
machine's own hostname and addresses as well as localhost
|
|
71468
|
+
--public-url <u> The address this is reachable at from a browser, when that is not
|
|
71469
|
+
the one it binds. Printed as the link to open, and trusted as a
|
|
71470
|
+
host and origin.
|
|
71471
|
+
Under JupyterHub give only the hub's base URL \u2014 the
|
|
71472
|
+
/user/<you>/proxy/<port>/ part is worked out, including the
|
|
71473
|
+
port, which you cannot know before it starts.
|
|
70934
71474
|
--allow-host <h> An extra name to answer to, e.g. a reverse proxy or a
|
|
70935
71475
|
container alias (repeatable)
|
|
70936
71476
|
--allow-origin <o> An extra origin allowed to call it, e.g. an app embedding
|