@chosengeneration/light-code 0.62.0 → 0.67.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 +279 -46
- package/dist/client/client.js +36 -36
- package/dist/client/index.html +19 -19
- package/dist/server.js +175 -36
- package/package.json +65 -65
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";
|
|
@@ -40153,6 +40196,7 @@ function dispatcherEnabled(retrieval) {
|
|
|
40153
40196
|
function skillRetrievalEnabled(retrieval) {
|
|
40154
40197
|
return dispatcherEnabled(retrieval) && retrieval?.skills !== false;
|
|
40155
40198
|
}
|
|
40199
|
+
var aliasNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore");
|
|
40156
40200
|
var embedderConfigSchema = external_exports.object({
|
|
40157
40201
|
profileId: external_exports.string().min(1),
|
|
40158
40202
|
model: external_exports.string().min(1),
|
|
@@ -40204,7 +40248,28 @@ var embedderConfigSchema = external_exports.object({
|
|
|
40204
40248
|
* keeping their code indexes to themselves — skills are prose somebody wrote on purpose,
|
|
40205
40249
|
* source is not.
|
|
40206
40250
|
*/
|
|
40207
|
-
skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore")
|
|
40251
|
+
skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore"),
|
|
40252
|
+
/**
|
|
40253
|
+
* Further names the codebase index answers to, beyond `indexAlias`.
|
|
40254
|
+
*
|
|
40255
|
+
* An index may carry several, and that is what makes *levels* of sharing possible rather than
|
|
40256
|
+
* a single pool: the same index can be reachable as `my-squad`, as `platform-team` and as
|
|
40257
|
+
* `everyone`, and searching one of those reaches exactly the people who attached it. With one
|
|
40258
|
+
* name there is one circle, and you are either in it or out of it.
|
|
40259
|
+
*
|
|
40260
|
+
* Order is meaningful — the first is the default, and is what `scope: "team"` resolves to.
|
|
40261
|
+
* Read through `rag/aliases.ts` together with the singular key, never directly, so the two
|
|
40262
|
+
* spellings cannot drift.
|
|
40263
|
+
*/
|
|
40264
|
+
indexAliases: external_exports.array(aliasNameSchema).max(8).optional(),
|
|
40265
|
+
/**
|
|
40266
|
+
* The same for skills.
|
|
40267
|
+
*
|
|
40268
|
+
* Kept separate from the codebase list rather than derived from it, for the reason
|
|
40269
|
+
* `skillsAlias` already records: pooling your source and pooling what you have *taught* the
|
|
40270
|
+
* assistant are different decisions, and a team routinely wants one without the other.
|
|
40271
|
+
*/
|
|
40272
|
+
skillsAliases: external_exports.array(aliasNameSchema).max(8).optional()
|
|
40208
40273
|
}).partial();
|
|
40209
40274
|
var globalTlsSchema = tlsSettingsSchema;
|
|
40210
40275
|
var identityConfigSchema = external_exports.object({
|
|
@@ -46918,11 +46983,48 @@ Filters: ${JSON.stringify(params.filters)}` : ""}`
|
|
|
46918
46983
|
|
|
46919
46984
|
// ../../packages/core/dist/tools/searchCodebase.js
|
|
46920
46985
|
import path10 from "node:path";
|
|
46986
|
+
|
|
46987
|
+
// ../../packages/core/dist/rag/aliases.js
|
|
46988
|
+
function codebaseAliases(config2) {
|
|
46989
|
+
return merge2(config2?.embedder?.indexAlias, config2?.embedder?.indexAliases);
|
|
46990
|
+
}
|
|
46991
|
+
function skillAliases(config2) {
|
|
46992
|
+
return merge2(config2?.embedder?.skillsAlias, config2?.embedder?.skillsAliases);
|
|
46993
|
+
}
|
|
46994
|
+
function aliasForScope(scope, aliases) {
|
|
46995
|
+
const wanted = scope.trim().toLowerCase();
|
|
46996
|
+
if (wanted.length === 0 || wanted === "mine")
|
|
46997
|
+
return void 0;
|
|
46998
|
+
if (wanted === "team")
|
|
46999
|
+
return aliases[0];
|
|
47000
|
+
return aliases.find((alias) => alias.toLowerCase() === wanted);
|
|
47001
|
+
}
|
|
47002
|
+
function merge2(single, many) {
|
|
47003
|
+
const out = [];
|
|
47004
|
+
for (const value of [single, ...many ?? []]) {
|
|
47005
|
+
const trimmed = value?.trim();
|
|
47006
|
+
if (trimmed === void 0 || trimmed.length === 0)
|
|
47007
|
+
continue;
|
|
47008
|
+
if (!out.some((existing) => existing.toLowerCase() === trimmed.toLowerCase()))
|
|
47009
|
+
out.push(trimmed);
|
|
47010
|
+
}
|
|
47011
|
+
return out;
|
|
47012
|
+
}
|
|
47013
|
+
|
|
47014
|
+
// ../../packages/core/dist/tools/searchCodebase.js
|
|
46921
47015
|
var paramsSchema6 = external_exports.object({
|
|
46922
47016
|
query: external_exports.string().min(1).describe('What you are looking for, described in plain words \u2014 e.g. "where the retry backoff is calculated".'),
|
|
46923
47017
|
size: external_exports.number().int().min(1).max(25).optional().describe("How many results to return. Default 8."),
|
|
46924
47018
|
pathPrefix: external_exports.string().optional().describe('Restrict to a subtree, e.g. "packages/core/src". Omit to search everything indexed.'),
|
|
46925
|
-
|
|
47019
|
+
/*
|
|
47020
|
+
* A free string rather than an enum, because the scopes are whatever the user configured.
|
|
47021
|
+
*
|
|
47022
|
+
* An index may carry several aliases — a squad, a department, everyone — and each is a level of
|
|
47023
|
+
* sharing. The *description* names the ones that exist here, which is §12's carve-out: it varies
|
|
47024
|
+
* with a setting rather than with the turn, so the tool block stays byte-stable for a session
|
|
47025
|
+
* exactly as `ask_expert`'s does.
|
|
47026
|
+
*/
|
|
47027
|
+
scope: external_exports.string().optional().describe('Whose code to search. "mine" (default) is this workspace only. Anything else names a shared scope \u2014 use it for "how did anyone solve X", never for questions about the code in front of you. Shared results are NOT on this machine and cannot be opened or edited.')
|
|
46926
47028
|
});
|
|
46927
47029
|
var DEFAULT_SIZE = 8;
|
|
46928
47030
|
var REMOTE_GUIDANCE = [
|
|
@@ -46966,10 +47068,12 @@ function createSearchCodebaseTool(options) {
|
|
|
46966
47068
|
const startedAt = Date.now();
|
|
46967
47069
|
try {
|
|
46968
47070
|
const size = params.size ?? DEFAULT_SIZE;
|
|
46969
|
-
const
|
|
46970
|
-
const
|
|
46971
|
-
const
|
|
46972
|
-
const
|
|
47071
|
+
const requested = params.scope?.trim() ?? "mine";
|
|
47072
|
+
const wantsTeam = requested.length > 0 && requested.toLowerCase() !== "mine";
|
|
47073
|
+
const alias = aliasForScope(requested, options.teamAliases ?? []);
|
|
47074
|
+
const teamUnavailable = wantsTeam && alias === void 0;
|
|
47075
|
+
const searchingTeam = wantsTeam && alias !== void 0;
|
|
47076
|
+
const collection = searchingTeam ? alias : options.index;
|
|
46973
47077
|
const vector = await options.embedder.embed(params.query);
|
|
46974
47078
|
const hits = await options.searcher.searchByVector(collection, vector, {
|
|
46975
47079
|
size,
|
|
@@ -47015,7 +47119,12 @@ ${hit.text}`;
|
|
|
47015
47119
|
"These are approximate. Read the files before relying on them, and use search_files if you know the exact term.",
|
|
47016
47120
|
...teamUnavailable ? [
|
|
47017
47121
|
"",
|
|
47018
|
-
|
|
47122
|
+
/*
|
|
47123
|
+
* Which it was matters: nothing configured is a different thing to fix from a
|
|
47124
|
+
* scope that was misspelled, and naming the ones that exist turns a dead end
|
|
47125
|
+
* into a retry the model can get right.
|
|
47126
|
+
*/
|
|
47127
|
+
(options.teamAliases ?? []).length === 0 ? "A shared scope was asked for but none is configured, so only this workspace was searched. Do not conclude from this that no colleague has solved it \u2014 their work was not looked at." : `There is no shared scope called "${requested}". The ones configured here are: ${(options.teamAliases ?? []).join(", ")}. Only this workspace was searched, so do not conclude that no colleague has solved it.`
|
|
47019
47128
|
] : [],
|
|
47020
47129
|
...anyRemote ? ["", ...REMOTE_GUIDANCE] : [],
|
|
47021
47130
|
"",
|
|
@@ -47123,8 +47232,10 @@ ${hit.text}`;
|
|
|
47123
47232
|
}
|
|
47124
47233
|
async function indexTeamSkills(options) {
|
|
47125
47234
|
await options.writer.ensureCollection(options.collection, options.embedder.dimensions, options.signal);
|
|
47126
|
-
if (options.
|
|
47127
|
-
|
|
47235
|
+
if (options.writer.ensureAlias !== void 0) {
|
|
47236
|
+
for (const alias of options.aliases ?? []) {
|
|
47237
|
+
await options.writer.ensureAlias(options.collection, alias, options.signal);
|
|
47238
|
+
}
|
|
47128
47239
|
}
|
|
47129
47240
|
if (options.skills.length === 0)
|
|
47130
47241
|
return 0;
|
|
@@ -50275,7 +50386,8 @@ async function indexWorkspace(options) {
|
|
|
50275
50386
|
};
|
|
50276
50387
|
await writer.ensureCollection(index, embedder.dimensions, signal);
|
|
50277
50388
|
if (options.alias !== void 0 && writer.ensureAlias !== void 0) {
|
|
50278
|
-
|
|
50389
|
+
for (const alias of options.alias)
|
|
50390
|
+
await writer.ensureAlias(index, alias, signal);
|
|
50279
50391
|
}
|
|
50280
50392
|
const signature = chunkSignatureFor(options.chunkOptions);
|
|
50281
50393
|
const stale = options.manifest.model !== embedder.model || options.manifest.dimensions !== embedder.dimensions || options.manifest.chunkSignature !== signature;
|
|
@@ -62661,7 +62773,7 @@ ${preview.text}` } : {}
|
|
|
62661
62773
|
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
|
|
62662
62774
|
// Only when a pool actually exists: telling the model about a tool it has not been given
|
|
62663
62775
|
// is how it comes to report that it looked somewhere it could not reach.
|
|
62664
|
-
teamSkillsAvailable: config2.
|
|
62776
|
+
teamSkillsAvailable: skillAliases(config2).length > 0,
|
|
62665
62777
|
/*
|
|
62666
62778
|
* Read from config rather than from the registry, because the prompt is built before the
|
|
62667
62779
|
* registry is. Only the *off* case is claimed: "on but uv is missing" leaves the model
|
|
@@ -62798,7 +62910,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
62798
62910
|
* to look and every hit can say whose it is. Both absent on a solo install,
|
|
62799
62911
|
* where team scope is simply unavailable and says so.
|
|
62800
62912
|
*/
|
|
62801
|
-
...config2.
|
|
62913
|
+
...codebaseAliases(config2).length > 0 ? { teamAliases: codebaseAliases(config2) } : {},
|
|
62802
62914
|
...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
|
|
62803
62915
|
} : void 0,
|
|
62804
62916
|
/*
|
|
@@ -62814,10 +62926,11 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
62814
62926
|
* The team's shared skills. Needs an alias, a connection and an embedder — without
|
|
62815
62927
|
* all three there is nothing to search, and the tool is simply not offered.
|
|
62816
62928
|
*/
|
|
62817
|
-
config2.
|
|
62929
|
+
skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
|
|
62818
62930
|
searcher: search.searcher,
|
|
62819
62931
|
embedder,
|
|
62820
|
-
|
|
62932
|
+
// The first is the default circle, exactly as it is for the codebase index.
|
|
62933
|
+
collection: skillAliases(config2)[0],
|
|
62821
62934
|
...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
|
|
62822
62935
|
} : void 0,
|
|
62823
62936
|
/*
|
|
@@ -63791,8 +63904,8 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63791
63904
|
}
|
|
63792
63905
|
async function handleAttachTeamAlias() {
|
|
63793
63906
|
const config2 = await loadSettings();
|
|
63794
|
-
const
|
|
63795
|
-
if (
|
|
63907
|
+
const aliases = codebaseAliases(config2);
|
|
63908
|
+
if (aliases.length === 0) {
|
|
63796
63909
|
post({
|
|
63797
63910
|
type: "teamAliasAttached",
|
|
63798
63911
|
error: "Set a team index alias in Settings \u2192 Search first \u2014 there is nothing to attach to."
|
|
@@ -63817,7 +63930,8 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63817
63930
|
});
|
|
63818
63931
|
return;
|
|
63819
63932
|
}
|
|
63820
|
-
|
|
63933
|
+
for (const alias of aliases)
|
|
63934
|
+
await writer.ensureAlias(index, alias);
|
|
63821
63935
|
let attributed = 0;
|
|
63822
63936
|
const owner = indexOwner(config2);
|
|
63823
63937
|
if (owner !== void 0 && writer.attributeUnowned !== void 0) {
|
|
@@ -63827,7 +63941,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63827
63941
|
...project !== void 0 ? { project } : {}
|
|
63828
63942
|
});
|
|
63829
63943
|
}
|
|
63830
|
-
post({ type: "teamAliasAttached", alias, index, attributed });
|
|
63944
|
+
post({ type: "teamAliasAttached", alias: aliases.join(", "), index, attributed });
|
|
63831
63945
|
} catch (error51) {
|
|
63832
63946
|
post({
|
|
63833
63947
|
type: "teamAliasAttached",
|
|
@@ -64502,7 +64616,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
64502
64616
|
writer: createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id)),
|
|
64503
64617
|
embedder,
|
|
64504
64618
|
collection,
|
|
64505
|
-
|
|
64619
|
+
aliases: skillAliases(config2),
|
|
64506
64620
|
skills: withBodies,
|
|
64507
64621
|
signal,
|
|
64508
64622
|
onProgress: (done, total) => reportIndexing("teamSkills", "Embedding and sending", { done, total }),
|
|
@@ -65009,7 +65123,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65009
65123
|
const manifestFile = manifestPath(index, search.id);
|
|
65010
65124
|
const owner = indexOwner(config2);
|
|
65011
65125
|
const project = indexProject();
|
|
65012
|
-
const
|
|
65126
|
+
const aliases = codebaseAliases(config2);
|
|
65013
65127
|
try {
|
|
65014
65128
|
const manifest = await loadIndexManifest(manifestFile, embedder);
|
|
65015
65129
|
const isIgnored = await ignoredFilesPredicate();
|
|
@@ -65036,7 +65150,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
65036
65150
|
*/
|
|
65037
65151
|
...owner !== void 0 ? { owner } : {},
|
|
65038
65152
|
...project !== void 0 ? { project } : {},
|
|
65039
|
-
|
|
65153
|
+
alias: aliases,
|
|
65040
65154
|
onProgress: (progress) => post({ type: "indexProgress", progress }),
|
|
65041
65155
|
signal: indexingAbort.signal
|
|
65042
65156
|
});
|
|
@@ -67187,6 +67301,7 @@ var NODE_ICONS = [
|
|
|
67187
67301
|
"warning",
|
|
67188
67302
|
"gear"
|
|
67189
67303
|
];
|
|
67304
|
+
var TEXT_SIZES = ["small", "normal", "large", "xlarge"];
|
|
67190
67305
|
var NODE_SHAPES = ["box", "round", "diamond", "cylinder"];
|
|
67191
67306
|
var diagramNodeSchema = external_exports.object({
|
|
67192
67307
|
id: external_exports.string().min(1).max(64).describe("A short identifier, referenced by edges. Not shown."),
|
|
@@ -67195,7 +67310,10 @@ var diagramNodeSchema = external_exports.object({
|
|
|
67195
67310
|
/** Shown under the label, smaller. For the qualifier that would otherwise bloat the label. */
|
|
67196
67311
|
note: external_exports.string().max(120).optional().describe("A second, smaller line under the label."),
|
|
67197
67312
|
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."),
|
|
67198
|
-
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.")
|
|
67313
|
+
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."),
|
|
67314
|
+
emphasis: external_exports.enum(["bold"]).optional().describe("Bold the label, for the one or two boxes the diagram is really about."),
|
|
67315
|
+
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."),
|
|
67316
|
+
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.")
|
|
67199
67317
|
});
|
|
67200
67318
|
var diagramEdgeSchema = external_exports.object({
|
|
67201
67319
|
from: external_exports.string().min(1).describe("The id of the node the arrow leaves."),
|
|
@@ -67212,6 +67330,7 @@ var diagramLegendSchema = external_exports.object({
|
|
|
67212
67330
|
var DIAGRAM_MAX_LEGEND = 8;
|
|
67213
67331
|
var diagramSpecSchema = external_exports.object({
|
|
67214
67332
|
title: external_exports.string().max(120).optional(),
|
|
67333
|
+
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."),
|
|
67215
67334
|
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."),
|
|
67216
67335
|
direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
|
|
67217
67336
|
nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
|
|
@@ -67447,10 +67566,21 @@ function createShowChartTool() {
|
|
|
67447
67566
|
|
|
67448
67567
|
// ../../packages/core/dist/diagrams/layout.js
|
|
67449
67568
|
var NODE_HEIGHT = 52;
|
|
67450
|
-
var NOTE_EXTRA = 14;
|
|
67451
67569
|
var MIN_WIDTH = 96;
|
|
67452
|
-
var MAX_WIDTH =
|
|
67453
|
-
var
|
|
67570
|
+
var MAX_WIDTH = 280;
|
|
67571
|
+
var FACE_WIDTH = { regular: 7.6, bold: 8.2, mono: 8, monoBold: 8 };
|
|
67572
|
+
var SIZE_SCALE = {
|
|
67573
|
+
small: 0.85,
|
|
67574
|
+
normal: 1,
|
|
67575
|
+
large: 1.25,
|
|
67576
|
+
xlarge: 1.55
|
|
67577
|
+
};
|
|
67578
|
+
var NOTE_CHAR_WIDTH = 6.4;
|
|
67579
|
+
var LINE_HEIGHT = 17;
|
|
67580
|
+
var NOTE_LINE_HEIGHT = 14;
|
|
67581
|
+
var LABEL_FONT_SIZE = 13;
|
|
67582
|
+
var NOTE_FONT_SIZE = 11;
|
|
67583
|
+
var PADDING_Y = 15;
|
|
67454
67584
|
var PADDING_X = 28;
|
|
67455
67585
|
var GAP_WITHIN_RANK = 28;
|
|
67456
67586
|
var GAP_BETWEEN_RANKS = 64;
|
|
@@ -67462,9 +67592,51 @@ var SWATCH_GAP = 7;
|
|
|
67462
67592
|
var LEGEND_ITEM_GAP = 22;
|
|
67463
67593
|
var LEGEND_ROW_HEIGHT = 24;
|
|
67464
67594
|
var LEGEND_TOP_GAP = 18;
|
|
67465
|
-
function
|
|
67466
|
-
const
|
|
67467
|
-
|
|
67595
|
+
function wrapText(text, perLine) {
|
|
67596
|
+
const limit = Math.max(4, perLine);
|
|
67597
|
+
const lines = [];
|
|
67598
|
+
let current = "";
|
|
67599
|
+
for (const word of text.split(/\s+/).filter((part) => part.length > 0)) {
|
|
67600
|
+
if (current.length === 0) {
|
|
67601
|
+
current = word;
|
|
67602
|
+
} else if (current.length + 1 + word.length <= limit) {
|
|
67603
|
+
current = `${current} ${word}`;
|
|
67604
|
+
} else {
|
|
67605
|
+
lines.push(current);
|
|
67606
|
+
current = word;
|
|
67607
|
+
}
|
|
67608
|
+
while (current.length > limit) {
|
|
67609
|
+
lines.push(current.slice(0, limit));
|
|
67610
|
+
current = current.slice(limit);
|
|
67611
|
+
}
|
|
67612
|
+
}
|
|
67613
|
+
if (current.length > 0)
|
|
67614
|
+
lines.push(current);
|
|
67615
|
+
return lines.length > 0 ? lines : [""];
|
|
67616
|
+
}
|
|
67617
|
+
function boxFor(label, note, face = "regular", size = "normal") {
|
|
67618
|
+
const scale = SIZE_SCALE[size];
|
|
67619
|
+
const charWidth = FACE_WIDTH[face] * scale;
|
|
67620
|
+
const noteCharWidth = NOTE_CHAR_WIDTH * scale;
|
|
67621
|
+
const lineHeight = LINE_HEIGHT * scale;
|
|
67622
|
+
const noteLineHeight = NOTE_LINE_HEIGHT * scale;
|
|
67623
|
+
const ideal = Math.max(Math.round(label.length * charWidth), note === void 0 ? 0 : Math.round(note.length * noteCharWidth));
|
|
67624
|
+
const maxWidth = MAX_WIDTH * scale;
|
|
67625
|
+
const width = Math.min(maxWidth, Math.max(MIN_WIDTH, ideal + PADDING_X * 2));
|
|
67626
|
+
const usable = width - PADDING_X * 2;
|
|
67627
|
+
const lines = wrapText(label, Math.floor(usable / charWidth));
|
|
67628
|
+
const noteLines = note === void 0 ? [] : wrapText(note, Math.floor(usable / noteCharWidth));
|
|
67629
|
+
const textHeight = lines.length * lineHeight + noteLines.length * noteLineHeight;
|
|
67630
|
+
return {
|
|
67631
|
+
width,
|
|
67632
|
+
height: Math.max(NODE_HEIGHT * scale, textHeight + PADDING_Y * 2),
|
|
67633
|
+
lines,
|
|
67634
|
+
noteLines,
|
|
67635
|
+
fontSize: LABEL_FONT_SIZE * scale,
|
|
67636
|
+
noteFontSize: NOTE_FONT_SIZE * scale,
|
|
67637
|
+
lineHeight,
|
|
67638
|
+
noteLineHeight
|
|
67639
|
+
};
|
|
67468
67640
|
}
|
|
67469
67641
|
function backEdges(spec) {
|
|
67470
67642
|
const outgoing = /* @__PURE__ */ new Map();
|
|
@@ -67557,10 +67729,10 @@ function layoutDiagram(spec) {
|
|
|
67557
67729
|
const byId = new Map(spec.nodes.map((node) => [node.id, node]));
|
|
67558
67730
|
const sizes = /* @__PURE__ */ new Map();
|
|
67559
67731
|
for (const node of spec.nodes) {
|
|
67560
|
-
|
|
67561
|
-
|
|
67562
|
-
|
|
67563
|
-
|
|
67732
|
+
const bold = node.emphasis === "bold";
|
|
67733
|
+
const mono = node.font === "mono";
|
|
67734
|
+
const face = mono ? bold ? "monoBold" : "mono" : bold ? "bold" : "regular";
|
|
67735
|
+
sizes.set(node.id, boxFor(node.label, node.note, face, node.textSize ?? spec.textSize ?? "normal"));
|
|
67564
67736
|
}
|
|
67565
67737
|
const rankExtent = rows.map((row) => Math.max(...row.map((id) => sizes.get(id)?.height ?? NODE_HEIGHT)));
|
|
67566
67738
|
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));
|
|
@@ -67577,8 +67749,14 @@ function layoutDiagram(spec) {
|
|
|
67577
67749
|
continue;
|
|
67578
67750
|
placed.push({
|
|
67579
67751
|
id,
|
|
67580
|
-
|
|
67581
|
-
|
|
67752
|
+
lines: size2.lines,
|
|
67753
|
+
noteLines: size2.noteLines,
|
|
67754
|
+
bold: node.emphasis === "bold",
|
|
67755
|
+
mono: node.font === "mono",
|
|
67756
|
+
fontSize: size2.fontSize,
|
|
67757
|
+
noteFontSize: size2.noteFontSize,
|
|
67758
|
+
lineHeight: size2.lineHeight,
|
|
67759
|
+
noteLineHeight: size2.noteLineHeight,
|
|
67582
67760
|
shape: node.shape ?? "box",
|
|
67583
67761
|
// A start or an end is accented unless the model said otherwise: the entry and exit of a
|
|
67584
67762
|
// flow are what a reader looks for first.
|
|
@@ -67686,7 +67864,7 @@ function createShowDiagramTool() {
|
|
|
67686
67864
|
return {
|
|
67687
67865
|
name: "show_diagram",
|
|
67688
67866
|
group: "always",
|
|
67689
|
-
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. `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.',
|
|
67867
|
+
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.',
|
|
67690
67868
|
parametersSchema: diagramSpecSchema,
|
|
67691
67869
|
async execute(params) {
|
|
67692
67870
|
const layout = layoutDiagram(params);
|
|
@@ -69422,7 +69600,11 @@ function reachableHosts(bindAddress, port, extra = []) {
|
|
|
69422
69600
|
}
|
|
69423
69601
|
}
|
|
69424
69602
|
}
|
|
69425
|
-
for (const name of extra)
|
|
69603
|
+
for (const name of extra) {
|
|
69604
|
+
add(name);
|
|
69605
|
+
const trimmed = name.trim().toLowerCase();
|
|
69606
|
+
if (trimmed.length > 0) names.add(trimmed);
|
|
69607
|
+
}
|
|
69426
69608
|
return [...names];
|
|
69427
69609
|
}
|
|
69428
69610
|
function reachableOrigins(hosts, extra = []) {
|
|
@@ -70989,7 +71171,7 @@ function respondJson(response, status, body) {
|
|
|
70989
71171
|
}
|
|
70990
71172
|
|
|
70991
71173
|
// src/cli.ts
|
|
70992
|
-
var VERSION = true ? "0.
|
|
71174
|
+
var VERSION = true ? "0.67.0" : "unknown (not a packaged build)";
|
|
70993
71175
|
var compat = installNodeCompat();
|
|
70994
71176
|
function lastMeaningfulLine(problem) {
|
|
70995
71177
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|
|
@@ -71054,6 +71236,8 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
71054
71236
|
const dataDir = valueOf(args, "--data-dir") ?? envPaths("light-code", { suffix: "" }).data;
|
|
71055
71237
|
const port = Number.parseInt(valueOf(args, "--port") ?? "0", 10);
|
|
71056
71238
|
const noToken = args.includes("--no-token");
|
|
71239
|
+
const printUrl = args.includes("--print-url");
|
|
71240
|
+
const publicUrl = valueOf(args, "--public-url");
|
|
71057
71241
|
const allowHosts = valuesOf(args, "--allow-host");
|
|
71058
71242
|
const allowOrigins = valuesOf(args, "--allow-origin");
|
|
71059
71243
|
const handoffSeconds = Math.min(
|
|
@@ -71061,7 +71245,7 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
71061
71245
|
Math.max(1, Number.parseInt(valueOf(args, "--handoff-seconds") ?? "10", 10) || 10)
|
|
71062
71246
|
);
|
|
71063
71247
|
const bindAddress = valueOf(args, "--bind");
|
|
71064
|
-
const noOpen = args.includes("--no-open") || serverMode;
|
|
71248
|
+
const noOpen = args.includes("--no-open") || serverMode || printUrl;
|
|
71065
71249
|
let identity;
|
|
71066
71250
|
let identityProblem;
|
|
71067
71251
|
if (identityTool !== void 0) {
|
|
@@ -71105,8 +71289,16 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
71105
71289
|
...credentialTool !== void 0 ? { credentialTool: { interpreter: credentialPython, file: credentialTool } } : {},
|
|
71106
71290
|
handoffSeconds,
|
|
71107
71291
|
noToken,
|
|
71108
|
-
|
|
71109
|
-
|
|
71292
|
+
/*
|
|
71293
|
+
* A stated public address is trusted as a name and an origin.
|
|
71294
|
+
*
|
|
71295
|
+
* Otherwise `--public-url` would print a link that the server then refuses: the Host check
|
|
71296
|
+
* exists to catch DNS rebinding, and a proxy legitimately forwards the name the browser used.
|
|
71297
|
+
* Somebody who typed the address is telling us it is theirs, which is the same statement
|
|
71298
|
+
* `--allow-host` makes and this saves them making it twice.
|
|
71299
|
+
*/
|
|
71300
|
+
allowHosts: [...allowHosts, ...trustedFromPublicUrl(publicUrl).hosts],
|
|
71301
|
+
allowOrigins: [...allowOrigins, ...trustedFromPublicUrl(publicUrl).origins],
|
|
71110
71302
|
/*
|
|
71111
71303
|
* A lapsed link is replaced rather than ending the session.
|
|
71112
71304
|
*
|
|
@@ -71135,6 +71327,10 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
71135
71327
|
...bindAddress !== void 0 ? { bindAddress } : {}
|
|
71136
71328
|
});
|
|
71137
71329
|
const launchUrl = `${server.url}${adminMode ? "/admin" : ""}/#t=${server.launchToken ?? ""}`;
|
|
71330
|
+
const publicAddress = publicAddressFor(new URL(server.url).port === "" ? 80 : Number(new URL(server.url).port), {
|
|
71331
|
+
...publicUrl !== void 0 ? { publicUrl } : {},
|
|
71332
|
+
env: process.env
|
|
71333
|
+
});
|
|
71138
71334
|
process.stdout.write(
|
|
71139
71335
|
`
|
|
71140
71336
|
Light Code ${VERSION}
|
|
@@ -71143,6 +71339,16 @@ Light Code ${VERSION}
|
|
|
71143
71339
|
listening ${server.url}
|
|
71144
71340
|
`
|
|
71145
71341
|
);
|
|
71342
|
+
const reachableUrl = publicAddress === void 0 ? noToken ? server.url : launchUrl : publicLaunchUrl(publicAddress, adminMode, noToken ? "" : server.launchToken ?? "");
|
|
71343
|
+
if (printUrl) process.stdout.write(`light-code-url: ${reachableUrl}
|
|
71344
|
+
`);
|
|
71345
|
+
if (publicAddress !== void 0) {
|
|
71346
|
+
process.stdout.write(
|
|
71347
|
+
` open ${reachableUrl}
|
|
71348
|
+
via ${publicAddress.source}
|
|
71349
|
+
`
|
|
71350
|
+
);
|
|
71351
|
+
}
|
|
71146
71352
|
if (noToken) {
|
|
71147
71353
|
process.stdout.write(
|
|
71148
71354
|
` auth none \u2014 --no-token. Any program on this machine can drive this
|
|
@@ -71211,13 +71417,20 @@ Both go through your proxy. Anyone reaching /admin directly is an administrator.
|
|
|
71211
71417
|
* seconds sends them looking for a token that was never minted. Instructions for a
|
|
71212
71418
|
* mechanism that is not running are worse than none.
|
|
71213
71419
|
*/
|
|
71214
|
-
|
|
71420
|
+
/*
|
|
71421
|
+
* The *reachable* address, which on a server is not the one it binds to.
|
|
71422
|
+
*
|
|
71423
|
+
* This line is the one people copy, so printing loopback here undid the whole point of
|
|
71424
|
+
* working the public address out: the useful URL scrolled past above it, and the useless
|
|
71425
|
+
* one had the last word.
|
|
71426
|
+
*/
|
|
71427
|
+
noToken ? `${noOpen ? "Serving on" : "Opening"} ${server.url}
|
|
71215
71428
|
(If the browser does not open, open this \u2014 there is no time limit:)
|
|
71216
|
-
${
|
|
71429
|
+
${reachableUrl}
|
|
71217
71430
|
|
|
71218
|
-
` :
|
|
71431
|
+
` : `${noOpen ? "Serving on" : "Opening"} ${server.url}
|
|
71219
71432
|
(If the browser does not open, paste this within ${String(handoffSeconds)} seconds:)
|
|
71220
|
-
${
|
|
71433
|
+
${reachableUrl}
|
|
71221
71434
|
|
|
71222
71435
|
` + (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")
|
|
71223
71436
|
);
|
|
@@ -71241,6 +71454,8 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
71241
71454
|
"--data-dir",
|
|
71242
71455
|
"--no-open",
|
|
71243
71456
|
"--no-token",
|
|
71457
|
+
"--public-url",
|
|
71458
|
+
"--print-url",
|
|
71244
71459
|
"--allow-host",
|
|
71245
71460
|
"--allow-origin",
|
|
71246
71461
|
"--server",
|
|
@@ -71255,6 +71470,15 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
71255
71470
|
"--bind",
|
|
71256
71471
|
"--guide"
|
|
71257
71472
|
]);
|
|
71473
|
+
function trustedFromPublicUrl(value) {
|
|
71474
|
+
if (value === void 0 || !/^https?:\/\//i.test(value.trim())) return { hosts: [], origins: [] };
|
|
71475
|
+
try {
|
|
71476
|
+
const url2 = new URL(value.trim());
|
|
71477
|
+
return { hosts: [url2.host], origins: [url2.origin] };
|
|
71478
|
+
} catch {
|
|
71479
|
+
return { hosts: [], origins: [] };
|
|
71480
|
+
}
|
|
71481
|
+
}
|
|
71258
71482
|
function valuesOf(args, flag) {
|
|
71259
71483
|
const values = [];
|
|
71260
71484
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -71320,6 +71544,15 @@ Usage: light-code [options]
|
|
|
71320
71544
|
--bind <address> Interface to listen on (default: 127.0.0.1). Use 0.0.0.0 to
|
|
71321
71545
|
reach it from another machine; it then answers to this
|
|
71322
71546
|
machine's own hostname and addresses as well as localhost
|
|
71547
|
+
--print-url Print the launch URL on its own line, prefixed light-code-url:,
|
|
71548
|
+
then serve. For a program starting this and needing to know
|
|
71549
|
+
where it went \u2014 an IDE plugin, a script. Implies --no-open.
|
|
71550
|
+
--public-url <u> The address this is reachable at from a browser, when that is not
|
|
71551
|
+
the one it binds. Printed as the link to open, and trusted as a
|
|
71552
|
+
host and origin.
|
|
71553
|
+
Under JupyterHub give only the hub's base URL \u2014 the
|
|
71554
|
+
/user/<you>/proxy/<port>/ part is worked out, including the
|
|
71555
|
+
port, which you cannot know before it starts.
|
|
71323
71556
|
--allow-host <h> An extra name to answer to, e.g. a reverse proxy or a
|
|
71324
71557
|
container alias (repeatable)
|
|
71325
71558
|
--allow-origin <o> An extra origin allowed to call it, e.g. an app embedding
|