@enhance-eng/enhance 0.1.161 → 0.1.166
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-output-identity.lib-BfvrkZX5.mjs → cli-output-identity.lib-DTdmAFNC.mjs} +4199 -2567
- package/dist/enhance-mcp.cjs +4 -0
- package/dist/enhance.cjs +4 -0
- package/dist/file-credential.adapter-CShGZcd5.mjs +63 -0
- package/dist/launch.cjs +36 -0
- package/dist/main.mjs +1623 -271
- package/dist/{mcp-invocation.adapter-DtgErzi9.mjs → mcp-invocation.adapter-C8vXAND1.mjs} +25 -5
- package/dist/mcp-main.mjs +10 -9
- package/dist/{mcp-server.adapter-DJeyBKo7.mjs → mcp-server.adapter-BgNggWKN.mjs} +14 -8
- package/dist/mcp.mjs +2 -2
- package/dist/older-node.mjs +7320 -0
- package/dist/remote-mcp-main.mjs +117 -28
- package/dist/rolldown-runtime-b6G8-vqI.mjs +6 -0
- package/dist/{mutation-key.adapter-TMLqYILu.mjs → zod-messages.lib-CH-SDeX_.mjs} +1655 -465
- package/package.json +6 -4
- package/dist/file-credential.adapter-C78gc9OK.mjs +0 -51
package/dist/main.mjs
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { C as
|
|
2
|
+
import { An as emptyFixtureDocument, Ar as wholeCanvasDocumentOutputSchema, C as PROCEDURE_DESCRIPTIONS, Ct as ROOT_FIELD, Dt as objectFieldNames, Et as isInputRecord, Ft as canvasReadInputSchema, Gr as emptyCanvasSceneDocument$1, Gt as hasCanvasReferenceScope, Jr as canvasAuthoredLayoutValueOf, Kt as parseCanvasReference, Lt as canvasUpdateHtmlCapabilityInputSchema, On as createOrganisationOutputSchema, Ot as quotedValue, Qr as canvasLayoutMainAxisOf, Rr as canvasWorldBoundsSchema$1, St as canvasEditsSchema, Tt as inputProblemSummary, Ut as canvasReferenceRenderTarget, V as operationStatusInputSchema, Vt as assertCanvasReferenceNodes, Wt as fromCanvasReference, Xr as canvasAxisStyleProperties, Yr as canvasAuthoredStyleDeclarations, Zt as currentNodeIdStep, _ as CANVAS_UPDATE_HTML_INPUT_EXAMPLE, _i as canvasSchema$1, a as createRouterShapeAdapter, an as CliError, b as ProcessExitError, c as toKebabCase, cn as appErrorSchema$1, ct as canvasRemoveCapabilityInputSchema, d as createMcpCapabilityDiscoveryAdapter, dn as appendRecordingChunkOutputSchema, dr as canvasAgentActivityPhaseSchema$1, ei as canvasLayoutPriorityDeclarations, er as canvasTextRunsOf, f as toExitCode, fn as completeRecordingOutputSchema, h as toPublishedExitTable, i as createLazyCapabilityCatalogAdapter, in as PartialBatchError, it as canvasRenderScopedInputSchema, jn as withFixtureScreen, jr as canvasOperationSchema$1, kr as saveCanvasDocumentOutputSchema, ln as completeScreenOutputSchema, mn as startRecordingOutputSchema, n as withCommandName, p as toFailurePayload, pt as canvasFindInputSchema, qt as readStoredCanvasScene, r as toCanvasAuthoringResult, t as withCommandInFailure, u as toSharedCapabilities, un as createScreenOutputSchema, ur as beginCanvasActivityOutputSchema, v as CAPABILITY_UUID_EXAMPLE, wt as inputProblemFields, x as OPTION_DESCRIPTIONS, y as createCapabilityPolicyAdapter } from "./cli-output-identity.lib-DTdmAFNC.mjs";
|
|
3
|
+
import { A as canvasAngularGradientSvg, C as assertCanvasReferenceOperations, D as canvasLinearGradientSvg, E as canvasRadialGradientSvg, M as compareCanvasSortKeys, O as canvasFilterListCss, S as createCanvasActivityComposite, T as createAuthUseCase, _ as readCanvasReferenceScene, b as createEditCanvasComposite, c as createOauthLoopbackAdapter, d as isJsonValued, f as createCapabilityInvocationAdapter, g as createRenderFileAdapter, i as readCliEnvironment, j as canvasColorCss, k as canvasDiamondGradientSvg, l as toInputHelp, n as createMutationKeyAdapter, r as createHttpRemoteAdapter, s as readToolMachine, t as installZodMessages, u as withCapabilityNames, v as createWriteHtmlCanvasComposite, w as createRenderCanvasComposite, x as sceneAtVersion } from "./zod-messages.lib-CH-SDeX_.mjs";
|
|
4
4
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
5
|
-
import { t as createFileCredentialAdapter } from "./file-credential.adapter-
|
|
5
|
+
import { t as createFileCredentialAdapter } from "./file-credential.adapter-CShGZcd5.mjs";
|
|
6
6
|
import process from "node:process";
|
|
7
|
-
import { Command } from "commander";
|
|
7
|
+
import { Command, Help, Option } from "commander";
|
|
8
8
|
import { createCli, parseRouter } from "trpc-cli";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { z as z$1 } from "zod/mini";
|
|
11
|
+
import { link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
12
|
+
import path from "node:path";
|
|
11
13
|
import { hostname, tmpdir } from "node:os";
|
|
12
14
|
import { createInterface } from "node:readline";
|
|
13
|
-
import { chmodSync, createReadStream, existsSync, lstatSync, mkdirSync, openAsBlob, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
14
|
-
import path from "node:path";
|
|
15
15
|
import { createHash, randomUUID } from "node:crypto";
|
|
16
|
-
import {
|
|
16
|
+
import { chmodSync, createReadStream, existsSync, lstatSync, mkdirSync, openAsBlob, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { pipeline } from "node:stream/promises";
|
|
18
18
|
import { channel } from "node:diagnostics_channel";
|
|
19
19
|
import { proxify } from "trpc-cli/dist/proxify.js";
|
|
20
20
|
|
|
21
21
|
//#region ../../packages/contract/src/canvas/canvas-font-family.lib.ts
|
|
22
22
|
const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
23
|
+
"-apple-system",
|
|
24
|
+
"blinkmacsystemfont",
|
|
23
25
|
"cursive",
|
|
24
26
|
"emoji",
|
|
25
27
|
"fantasy",
|
|
@@ -271,6 +273,65 @@ const createScreenFixtureComposite = (remote) => async (input) => {
|
|
|
271
273
|
}
|
|
272
274
|
};
|
|
273
275
|
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/application/setup.use-case.ts
|
|
278
|
+
const nextOf = (input) => [
|
|
279
|
+
...input.isSignedIn ? [] : ["The sign-in is not done. Run enhance auth login, then enhance setup again."],
|
|
280
|
+
...input.notWritten.map(({ agent, file }) => `The skill for ${agent} could not be written to ${file}.`),
|
|
281
|
+
...input.shared === null ? [] : [`No coding agent was found on this machine, so the skill is in ${input.shared.file}, which several agents read.`],
|
|
282
|
+
`Open your coding agent in your project and run the ${input.skill} skill.`
|
|
283
|
+
];
|
|
284
|
+
const createSetupUseCase = (dependencies) => ({ run: async (input) => {
|
|
285
|
+
const { auth, skills } = dependencies;
|
|
286
|
+
const signIn = async () => {
|
|
287
|
+
if (input.token !== null) return auth.loginWithToken(input.token);
|
|
288
|
+
try {
|
|
289
|
+
return await auth.status();
|
|
290
|
+
} catch (error) {
|
|
291
|
+
if (!(error instanceof CliError) || error.code !== "UNAUTHORIZED") throw error;
|
|
292
|
+
}
|
|
293
|
+
return auth.loginWithBrowser({
|
|
294
|
+
label: input.label,
|
|
295
|
+
openBrowser: input.openBrowser,
|
|
296
|
+
onReady: input.onReady
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
const signed = await (async () => {
|
|
300
|
+
try {
|
|
301
|
+
return {
|
|
302
|
+
person: await signIn(),
|
|
303
|
+
problem: null
|
|
304
|
+
};
|
|
305
|
+
} catch (error) {
|
|
306
|
+
return {
|
|
307
|
+
person: null,
|
|
308
|
+
problem: error instanceof Error ? error.message : String(error)
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
})();
|
|
312
|
+
const skill = dependencies.skill();
|
|
313
|
+
const copied = await skills.write(skill);
|
|
314
|
+
return {
|
|
315
|
+
status: signed.person !== null && copied.notWritten.length === 0 ? "ready" : "incomplete",
|
|
316
|
+
signedIn: signed.person === null ? null : {
|
|
317
|
+
personId: signed.person.personId,
|
|
318
|
+
displayName: signed.person.displayName
|
|
319
|
+
},
|
|
320
|
+
signInProblem: signed.problem,
|
|
321
|
+
skill: {
|
|
322
|
+
name: skill.name,
|
|
323
|
+
written: copied.written,
|
|
324
|
+
notWritten: copied.notWritten
|
|
325
|
+
},
|
|
326
|
+
next: nextOf({
|
|
327
|
+
skill: skill.name,
|
|
328
|
+
isSignedIn: signed.person !== null,
|
|
329
|
+
shared: copied.isShared ? copied.written[0] ?? null : null,
|
|
330
|
+
notWritten: copied.notWritten
|
|
331
|
+
})
|
|
332
|
+
};
|
|
333
|
+
} });
|
|
334
|
+
|
|
274
335
|
//#endregion
|
|
275
336
|
//#region src/application/world-fixture.composite.ts
|
|
276
337
|
const WORLD_FIXTURE_PROCEDURES = [
|
|
@@ -326,6 +387,83 @@ const createWorldFixtureComposite = (remote, createScreen) => async (input) => {
|
|
|
326
387
|
}
|
|
327
388
|
};
|
|
328
389
|
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/infrastructure/agent-skill-folders.adapter.ts
|
|
392
|
+
/** Each coding agent's own folder in the home folder, and where it reads personal skills from. */
|
|
393
|
+
const AGENTS = [
|
|
394
|
+
{
|
|
395
|
+
agent: "Claude Code",
|
|
396
|
+
home: ".claude",
|
|
397
|
+
skills: ".claude/skills"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
agent: "Codex",
|
|
401
|
+
home: ".codex",
|
|
402
|
+
skills: ".codex/skills"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
agent: "Cursor",
|
|
406
|
+
home: ".cursor",
|
|
407
|
+
skills: ".cursor/skills"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
agent: "OpenCode",
|
|
411
|
+
home: ".config/opencode",
|
|
412
|
+
skills: ".config/opencode/skills"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
agent: "Gemini",
|
|
416
|
+
home: ".gemini",
|
|
417
|
+
skills: ".gemini/skills"
|
|
418
|
+
}
|
|
419
|
+
];
|
|
420
|
+
/** The folder several agents read, used when none of the agents above is installed. */
|
|
421
|
+
const SHARED = {
|
|
422
|
+
agent: "the shared skills folder",
|
|
423
|
+
skills: ".agents/skills"
|
|
424
|
+
};
|
|
425
|
+
const isFolder = async (folder) => {
|
|
426
|
+
try {
|
|
427
|
+
return (await stat(folder)).isDirectory();
|
|
428
|
+
} catch {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const createAgentSkillFoldersAdapter = (homeDirectory) => ({ write: async (skill) => {
|
|
433
|
+
const found = (await Promise.all(AGENTS.map(async (entry) => await isFolder(path.join(homeDirectory, entry.home)) ? entry : null))).filter((entry) => entry !== null);
|
|
434
|
+
const targets = found.length === 0 ? [SHARED] : found;
|
|
435
|
+
const outcomes = await Promise.all(targets.map(async ({ agent, skills }) => {
|
|
436
|
+
const file = path.join(homeDirectory, skills, skill.name, "SKILL.md");
|
|
437
|
+
try {
|
|
438
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
439
|
+
await writeFile(file, skill.text);
|
|
440
|
+
return {
|
|
441
|
+
agent,
|
|
442
|
+
file,
|
|
443
|
+
reason: null
|
|
444
|
+
};
|
|
445
|
+
} catch (error) {
|
|
446
|
+
return {
|
|
447
|
+
agent,
|
|
448
|
+
file,
|
|
449
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}));
|
|
453
|
+
return {
|
|
454
|
+
written: outcomes.flatMap(({ agent, file, reason }) => reason === null ? [{
|
|
455
|
+
agent,
|
|
456
|
+
file
|
|
457
|
+
}] : []),
|
|
458
|
+
notWritten: outcomes.flatMap(({ agent, file, reason }) => reason === null ? [] : [{
|
|
459
|
+
agent,
|
|
460
|
+
file,
|
|
461
|
+
reason
|
|
462
|
+
}]),
|
|
463
|
+
isShared: found.length === 0
|
|
464
|
+
};
|
|
465
|
+
} });
|
|
466
|
+
|
|
329
467
|
//#endregion
|
|
330
468
|
//#region src/infrastructure/stdin-token.lib.ts
|
|
331
469
|
const readToken = async (offered, command) => {
|
|
@@ -360,7 +498,9 @@ const readOptionalToken = async (offered) => {
|
|
|
360
498
|
|
|
361
499
|
//#endregion
|
|
362
500
|
//#region src/infrastructure/auth.program.ts
|
|
363
|
-
const MAX_TOKEN_LABEL_CHARACTERS = 120;
|
|
501
|
+
const MAX_TOKEN_LABEL_CHARACTERS$1 = 120;
|
|
502
|
+
/** What a person, or an agent relaying to one, is told while the browser sign-in is open. */
|
|
503
|
+
const WAITING_FOR_BROWSER = "Sign in or sign up in the browser. This command carries on when you finish, however long that takes; Ctrl-C stops it.";
|
|
364
504
|
const registerAuthProgram = (program, auth, output) => {
|
|
365
505
|
const command = program.command("auth").description("Store and inspect the agent credential.");
|
|
366
506
|
command.command("login").description("Authenticate in a browser, then store a revocable agent credential.").option("--token <token>", "Use an existing agent token instead of browser authentication.").option("--no-open", "Print the authorization URL without opening the browser.").action(async (options) => {
|
|
@@ -370,12 +510,13 @@ const registerAuthProgram = (program, auth, output) => {
|
|
|
370
510
|
return;
|
|
371
511
|
}
|
|
372
512
|
output.result(await auth.loginWithBrowser({
|
|
373
|
-
label: `CLI on ${hostname()}`.slice(0, MAX_TOKEN_LABEL_CHARACTERS),
|
|
513
|
+
label: `CLI on ${hostname()}`.slice(0, MAX_TOKEN_LABEL_CHARACTERS$1),
|
|
374
514
|
openBrowser: options.open,
|
|
375
515
|
onReady: (url) => {
|
|
376
516
|
output.result({
|
|
377
517
|
status: "waiting_for_browser",
|
|
378
|
-
url
|
|
518
|
+
url,
|
|
519
|
+
waiting: WAITING_FOR_BROWSER
|
|
379
520
|
});
|
|
380
521
|
}
|
|
381
522
|
}));
|
|
@@ -451,14 +592,11 @@ const selectAuthoringToken = (input, value, isComposite) => {
|
|
|
451
592
|
const authoringMutationId = (input, purpose) => input.mutationKey.current("canvas.applyOperations", { purpose });
|
|
452
593
|
const applyAuthoringOperations = async (input, options, purpose, operations) => {
|
|
453
594
|
selectAuthoringToken(input, options.clientToken, false);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return createApplyCanvasComposite(input.remote).execute({
|
|
458
|
-
canvasId: reference.canvasId,
|
|
595
|
+
return createEditCanvasComposite(input.remote).apply({
|
|
596
|
+
...parseCanvasReference(options.canvas),
|
|
597
|
+
baseVersion: authoringBaseVersion(options.baseVersion),
|
|
459
598
|
mutationId: authoringMutationId(input, purpose),
|
|
460
|
-
|
|
461
|
-
operations: [...operations]
|
|
599
|
+
operations
|
|
462
600
|
});
|
|
463
601
|
};
|
|
464
602
|
const applyAuthoringEdits = async (input, options, edits, idPrefix) => {
|
|
@@ -473,6 +611,54 @@ const applyAuthoringEdits = async (input, options, edits, idPrefix) => {
|
|
|
473
611
|
});
|
|
474
612
|
};
|
|
475
613
|
|
|
614
|
+
//#endregion
|
|
615
|
+
//#region src/application/input-refusal.use-case.ts
|
|
616
|
+
const MAX_NAMED_PATHS = 3;
|
|
617
|
+
const namedPaths = (fields) => {
|
|
618
|
+
const paths = Object.keys(fields).filter((field) => field !== ROOT_FIELD);
|
|
619
|
+
const roots = paths.filter((path) => paths.every((other) => !path.startsWith(`${other}.`)));
|
|
620
|
+
if (roots.length === 0) return "";
|
|
621
|
+
const shown = roots.slice(0, MAX_NAMED_PATHS).join(", ");
|
|
622
|
+
return roots.length <= MAX_NAMED_PATHS ? ` at ${shown}` : ` at ${shown} and ${String(roots.length - MAX_NAMED_PATHS)} more`;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* The refusal of an input that failed its check: every problem with its field, what was expected
|
|
626
|
+
* and what was given.
|
|
627
|
+
*/
|
|
628
|
+
const inputRefusal = (input) => {
|
|
629
|
+
const fields = inputProblemFields(input.error, input.checked);
|
|
630
|
+
return new CliError("BAD_REQUEST", `${input.subject} is invalid${namedPaths(fields)}.`, `${inputProblemSummary(fields)} ${input.help}`, fields);
|
|
631
|
+
};
|
|
632
|
+
const SPELLINGS = [
|
|
633
|
+
["canvasRef", "canvasId"],
|
|
634
|
+
["canvasId", "canvasRef"],
|
|
635
|
+
["baseVersion", "expectedVersion"],
|
|
636
|
+
["expectedVersion", "baseVersion"]
|
|
637
|
+
];
|
|
638
|
+
const readAs = (given, name, other, subject) => {
|
|
639
|
+
const hasName = Object.hasOwn(given, name);
|
|
640
|
+
if (hasName && JSON.stringify(given[name]) !== JSON.stringify(given[other])) throw new CliError("BAD_REQUEST", `${subject} gives ${name} and ${other} different values.`, `Give ${name} alone; ${other} is another name for it.`, {
|
|
641
|
+
[name]: quotedValue(given[name]),
|
|
642
|
+
[other]: quotedValue(given[other])
|
|
643
|
+
});
|
|
644
|
+
return Object.fromEntries(Object.entries(given).flatMap(([key, held]) => {
|
|
645
|
+
if (key !== other) return [[key, held]];
|
|
646
|
+
return hasName ? [] : [[name, held]];
|
|
647
|
+
}));
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* Reads the other spelling of a canvas and of the version a write expects, where the command has
|
|
651
|
+
* one name and not the other. The schemas are strict and shared with hosted assistants, so the
|
|
652
|
+
* key is renamed here and the schema stays as it is.
|
|
653
|
+
*/
|
|
654
|
+
const withAcceptedSpellings = (schema, value, subject) => {
|
|
655
|
+
const shapes = objectFieldNames(schema);
|
|
656
|
+
if (shapes === null || shapes.length === 0 || !isInputRecord(value) || Array.isArray(value)) return value;
|
|
657
|
+
let read = { ...value };
|
|
658
|
+
for (const [name, other] of SPELLINGS) if (shapes.every((names) => names.includes(name) && !names.includes(other)) && Object.hasOwn(read, other)) read = readAs(read, name, other, subject);
|
|
659
|
+
return read;
|
|
660
|
+
};
|
|
661
|
+
|
|
476
662
|
//#endregion
|
|
477
663
|
//#region src/infrastructure/canvas-authoring-input.lib.ts
|
|
478
664
|
const canvasAuthoringInput = (value, option) => {
|
|
@@ -502,10 +688,15 @@ const decodedFrom = (value) => {
|
|
|
502
688
|
const createCanvasOperationInputAdapter = (value) => {
|
|
503
689
|
const decoded = decodedFrom(value);
|
|
504
690
|
const parsed = operationBatchSchema.safeParse(decoded);
|
|
505
|
-
if (!parsed.success) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
691
|
+
if (!parsed.success) throw inputRefusal({
|
|
692
|
+
subject: "The canvas operation batch",
|
|
693
|
+
error: parsed.error,
|
|
694
|
+
checked: {
|
|
695
|
+
schema: operationBatchSchema,
|
|
696
|
+
value: decoded
|
|
697
|
+
},
|
|
698
|
+
help: "Run 'enhance canvas apply --help' for the supported vocabulary."
|
|
699
|
+
});
|
|
509
700
|
return parsed.data;
|
|
510
701
|
};
|
|
511
702
|
|
|
@@ -527,17 +718,15 @@ const configureCanvasApply = (canvas, input) => {
|
|
|
527
718
|
canvas.command("apply").description("Apply an atomic canvas edit batch and return its affected bounds.").summary("Apply edits and return affected bounds.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID to edit.").requiredOption("--base-version <integer>", "Exact version returned by canvas inspect or tree.").requiredOption("--operations <json-or-@path>", "JSON operation array inline, or @path to a JSON file.").option("--client-token <uuid>", "Stable UUID to reuse only when retrying this exact batch.").addHelpText("after", [
|
|
528
719
|
"",
|
|
529
720
|
"Supported operations: insertNode, insertText, insertPrototype, setText, editText, setBox, setLabel, setVisibility, setLocked, setConstraints, setStyles, setAppearance, setLayout, patchTypography, setTypography, patchAdditionalStyles, setAdditionalStyles, setProps, setParentage, move, remove.",
|
|
530
|
-
"Use editText for revision-aware character or range changes. setText replaces the whole text and is rejected if it conflicts with a newer text edit."
|
|
531
|
-
"Example:",
|
|
532
|
-
` enhance canvas apply --canvas <url-or-id> --base-version 3 --operations '[{"op":"insertText","nodeId":"txt_summary","parentId":"root","text":"Checkout needs an address.","box":{"x":120,"y":594,"width":720,"height":80},"styles":{"font-size":24}}]'`
|
|
721
|
+
"Use editText for revision-aware character or range changes. setText replaces the whole text and is rejected if it conflicts with a newer text edit."
|
|
533
722
|
].join("\n")).action(async (options) => {
|
|
534
723
|
selectMutationToken(input, options.clientToken);
|
|
535
724
|
const reference = parseCanvasReference(options.canvas);
|
|
536
725
|
const baseVersion = baseVersionFrom(options.baseVersion);
|
|
537
726
|
const operations = createCanvasOperationInputAdapter(options.operations);
|
|
538
|
-
if (hasCanvasReferenceScope(reference)) assertCanvasReferenceOperations(reference, await sceneAtVersion(input, reference.canvasId, baseVersion), operations);
|
|
727
|
+
if (hasCanvasReferenceScope(reference)) assertCanvasReferenceOperations(reference, await sceneAtVersion(input, reference.canvasId, baseVersion, "flag"), operations);
|
|
539
728
|
const result = await input.invocation.invoke({
|
|
540
|
-
capability:
|
|
729
|
+
capability: input.catalog.one("canvas.apply"),
|
|
541
730
|
arguments: {
|
|
542
731
|
canvasId: reference.canvasId,
|
|
543
732
|
baseVersion,
|
|
@@ -613,18 +802,25 @@ const configureCanvasAuthoringActivity = (canvas, input) => {
|
|
|
613
802
|
//#endregion
|
|
614
803
|
//#region src/infrastructure/canvas-json-input.adapter.ts
|
|
615
804
|
const createCanvasJsonInputAdapter = (value, schema, option) => {
|
|
616
|
-
const
|
|
805
|
+
const read = withAcceptedSpellings(schema, (() => {
|
|
617
806
|
try {
|
|
618
807
|
return JSON.parse(canvasAuthoringInput(value, option));
|
|
619
808
|
} catch (error) {
|
|
620
809
|
if (error instanceof CliError) throw error;
|
|
621
810
|
throw new CliError("BAD_REQUEST", `${option} must be valid JSON.`, `Pass inline JSON or @/absolute/path/to/input.json; run the command with --help.`);
|
|
622
811
|
}
|
|
623
|
-
})();
|
|
624
|
-
const parsed = schema.safeParse(
|
|
812
|
+
})(), option);
|
|
813
|
+
const parsed = schema.safeParse(read);
|
|
625
814
|
if (parsed.success) return parsed.data;
|
|
626
|
-
|
|
627
|
-
|
|
815
|
+
throw inputRefusal({
|
|
816
|
+
subject: option,
|
|
817
|
+
error: parsed.error,
|
|
818
|
+
checked: {
|
|
819
|
+
schema,
|
|
820
|
+
value: read
|
|
821
|
+
},
|
|
822
|
+
help: "Run the command with --help for the whole input."
|
|
823
|
+
});
|
|
628
824
|
};
|
|
629
825
|
|
|
630
826
|
//#endregion
|
|
@@ -1022,7 +1218,7 @@ const computedCanvasNodeCss = (node, document) => ({
|
|
|
1022
1218
|
const childrenOf = (document, parentId) => Object.entries(document.relationships).filter(([, relationship]) => relationship.parentId === parentId).toSorted(([leftId, left], [rightId, right]) => left.sortKey === right.sortKey ? leftId.localeCompare(rightId) : compareCanvasSortKeys(left.sortKey, right.sortKey)).map(([nodeId]) => nodeId);
|
|
1023
1219
|
const requireNode = (document, nodeId) => {
|
|
1024
1220
|
const node = document.nodes[nodeId];
|
|
1025
|
-
if (node === void 0) throw new CliError("NOT_FOUND", `Canvas node ${nodeId} does not exist.`,
|
|
1221
|
+
if (node === void 0) throw new CliError("NOT_FOUND", `Canvas node ${nodeId} does not exist.`, currentNodeIdStep());
|
|
1026
1222
|
return node;
|
|
1027
1223
|
};
|
|
1028
1224
|
const stringProperty = (node, property) => {
|
|
@@ -1143,7 +1339,7 @@ const canvasScene = async (input, canvasId) => {
|
|
|
1143
1339
|
const held = wholeCanvasDocumentOutputSchema.parse(await input.remote.query("canvas.document.get", { canvasId }));
|
|
1144
1340
|
return {
|
|
1145
1341
|
held,
|
|
1146
|
-
document:
|
|
1342
|
+
document: readStoredCanvasScene(held.document)
|
|
1147
1343
|
};
|
|
1148
1344
|
};
|
|
1149
1345
|
const configureCanvasAuthoringSource = (canvas, input) => {
|
|
@@ -1178,12 +1374,62 @@ const configureCanvasAuthoringSource = (canvas, input) => {
|
|
|
1178
1374
|
});
|
|
1179
1375
|
};
|
|
1180
1376
|
|
|
1377
|
+
//#endregion
|
|
1378
|
+
//#region src/application/client-token.use-case.ts
|
|
1379
|
+
const REPEATABLE_CODES = /* @__PURE__ */ new Set(["INTERNAL", "RATE_LIMITED"]);
|
|
1380
|
+
const SAYS_SAME_TOKEN = /same (?:--client-token|clientToken)/u;
|
|
1381
|
+
const isRecord$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1382
|
+
/**
|
|
1383
|
+
* Whether the same call may be made again after this refusal. A wrong input, a missing canvas and
|
|
1384
|
+
* a canvas that moved on would only be refused again, and the changed call needs a new token.
|
|
1385
|
+
*/
|
|
1386
|
+
const isRepeatable = (error) => REPEATABLE_CODES.has(error.code) || error.fields?.["outcome"] === "not_confirmed" || SAYS_SAME_TOKEN.test(error.remediation);
|
|
1387
|
+
const repeatWith = (clientToken) => `To repeat this call, give it --client-token ${clientToken}: a write that landed is found, not made twice.`;
|
|
1388
|
+
const refusalWith = (error, clientToken) => {
|
|
1389
|
+
if (!(error instanceof CliError)) return new CliError("INTERNAL", "The command failed before its answer arrived, so a write may or may not have landed.", repeatWith(clientToken), { clientToken });
|
|
1390
|
+
if (!isRepeatable(error)) return error;
|
|
1391
|
+
const remediation = `${error.remediation} ${repeatWith(clientToken)}`;
|
|
1392
|
+
const fields = {
|
|
1393
|
+
...error.fields,
|
|
1394
|
+
clientToken
|
|
1395
|
+
};
|
|
1396
|
+
return error instanceof PartialBatchError ? new PartialBatchError(error.message, remediation, {
|
|
1397
|
+
code: error.code,
|
|
1398
|
+
fields
|
|
1399
|
+
}) : new CliError(error.code, error.message, remediation, fields);
|
|
1400
|
+
};
|
|
1401
|
+
/**
|
|
1402
|
+
* Runs a write with the caller's client token, or with one made here when the caller gave none.
|
|
1403
|
+
* A token made here is the only way to repeat the call as the same call, so it is put in the
|
|
1404
|
+
* answer and in every refusal after which the call may be repeated.
|
|
1405
|
+
*/
|
|
1406
|
+
const runWithClientToken = async (given, run) => {
|
|
1407
|
+
if (given !== null) return run(given);
|
|
1408
|
+
const clientToken = randomUUID();
|
|
1409
|
+
try {
|
|
1410
|
+
const answer = await run(clientToken);
|
|
1411
|
+
return isRecord$3(answer) ? {
|
|
1412
|
+
...answer,
|
|
1413
|
+
clientToken
|
|
1414
|
+
} : answer;
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
throw refusalWith(error, clientToken);
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1181
1420
|
//#endregion
|
|
1182
1421
|
//#region src/infrastructure/client-token-input.lib.ts
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1422
|
+
/** The client token a flag gave, or null when the flag was left out for the tool to make one. */
|
|
1423
|
+
const clientTokenFrom = (offered) => {
|
|
1424
|
+
if (offered === void 0) return null;
|
|
1425
|
+
const parsed = z.uuid().safeParse(offered);
|
|
1426
|
+
if (parsed.success) return parsed.data;
|
|
1427
|
+
throw new CliError("BAD_REQUEST", "--client-token must be a UUID.", "Give a UUID, or leave --client-token out: the command makes one and prints it as clientToken.");
|
|
1186
1428
|
};
|
|
1429
|
+
const invokeWithClientToken = async (invocation, request, offered) => runWithClientToken(clientTokenFrom(offered), async (clientToken) => invocation.invoke({
|
|
1430
|
+
...request,
|
|
1431
|
+
clientToken
|
|
1432
|
+
}));
|
|
1187
1433
|
|
|
1188
1434
|
//#endregion
|
|
1189
1435
|
//#region src/infrastructure/canvas-authoring-structure.program.ts
|
|
@@ -1194,13 +1440,12 @@ const executeDuplicate = async (input, options) => {
|
|
|
1194
1440
|
options.baseVersion,
|
|
1195
1441
|
options.nodes,
|
|
1196
1442
|
options.idPrefix
|
|
1197
|
-
].some((value) => value !== void 0)) throw new CliError("BAD_REQUEST", "Choose --input or the individual duplicate options.", "Use --input
|
|
1198
|
-
const capability =
|
|
1199
|
-
input.output.result(await input.invocation
|
|
1443
|
+
].some((value) => value !== void 0)) throw new CliError("BAD_REQUEST", "Choose --input or the individual duplicate options.", "Use --input alone for native measured duplication.");
|
|
1444
|
+
const capability = input.catalog.one("canvas.duplicateNodes");
|
|
1445
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1200
1446
|
capability,
|
|
1201
|
-
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1202
|
-
|
|
1203
|
-
}));
|
|
1447
|
+
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1448
|
+
}, options.clientToken));
|
|
1204
1449
|
return;
|
|
1205
1450
|
}
|
|
1206
1451
|
if (options.canvas === void 0 || options.baseVersion === void 0 || options.nodes === void 0) throw new TypeError("The required-option check let duplicate-nodes run without --canvas, --base-version or --nodes.");
|
|
@@ -1222,7 +1467,7 @@ const executeDuplicate = async (input, options) => {
|
|
|
1222
1467
|
});
|
|
1223
1468
|
};
|
|
1224
1469
|
const configureDuplicate = (canvas, input) => {
|
|
1225
|
-
canvas.command("duplicate-nodes").description("Deep-clone node subtrees; --input uses native measured layout and durable copy receipts.").option("--input <json-or-@path>", "Scoped native duplication request
|
|
1470
|
+
canvas.command("duplicate-nodes").description("Deep-clone node subtrees; --input uses native measured layout and durable copy receipts.").option("--input <json-or-@path>", "Scoped native duplication request.").option("--canvas <url-or-id>", "Canvas URL or UUID to edit.").option("--base-version <integer>", "Exact current canvas version.").option("--nodes <json-or-@path>", "Array of {id,parentId?} requests.").option("--id-prefix <prefix>", "Stable namespace for cloned ids.").option("--client-token <uuid>", "Stable UUID for retrying this exact batch.").action(async (options) => executeDuplicate(input, options));
|
|
1226
1471
|
};
|
|
1227
1472
|
const configureMove = (canvas, input) => {
|
|
1228
1473
|
canvas.command("move-nodes").description("Reorder or reparent nodes.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID to edit.").requiredOption("--base-version <integer>", "Exact current canvas version.").requiredOption("--moves <json-or-@path>", "Sequential before, after, or parent/index moves.").option("--client-token <uuid>", "Stable UUID for retrying this exact batch.").action(async (options) => {
|
|
@@ -1279,7 +1524,7 @@ const writeHtml = async (input, options) => {
|
|
|
1279
1524
|
const reference = parseCanvasReference(options.canvas);
|
|
1280
1525
|
const baseVersion = authoringBaseVersion(options.baseVersion);
|
|
1281
1526
|
input.output.result(await input.invocation.invoke({
|
|
1282
|
-
capability:
|
|
1527
|
+
capability: input.catalog.one("canvas.writeHtml"),
|
|
1283
1528
|
arguments: {
|
|
1284
1529
|
canvasId: reference.canvasId,
|
|
1285
1530
|
...reference.pageId !== void 0 && { pageId: reference.pageId },
|
|
@@ -1315,7 +1560,7 @@ const configureCreateArtboard = (canvas, input) => {
|
|
|
1315
1560
|
selectAuthoringToken(input, options.clientToken, true);
|
|
1316
1561
|
const canvasId = fromCanvasReference(options.canvas);
|
|
1317
1562
|
const baseVersion = authoringBaseVersion(options.baseVersion);
|
|
1318
|
-
const scene = await sceneAtVersion(input, canvasId, baseVersion);
|
|
1563
|
+
const scene = await sceneAtVersion(input, canvasId, baseVersion, "flag");
|
|
1319
1564
|
const rootBoxes = Object.entries(scene.relationships).flatMap(([nodeId, relationship]) => {
|
|
1320
1565
|
const box = scene.nodes[nodeId]?.box;
|
|
1321
1566
|
return box !== void 0 && relationship.parentId === "root" ? [box] : [];
|
|
@@ -1356,16 +1601,16 @@ const configureCanvasConversions = (canvas, input) => {
|
|
|
1356
1601
|
"canvas.insertHtml",
|
|
1357
1602
|
"canvas.makeEditable",
|
|
1358
1603
|
"canvas.capture",
|
|
1604
|
+
"canvas.capturePage",
|
|
1359
1605
|
"canvas.arrange"
|
|
1360
1606
|
]) {
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
input.output.result(await input.invocation
|
|
1607
|
+
const name = id === "canvas.insertHtml" ? "insert-html" : id === "canvas.makeEditable" ? "make-editable" : id === "canvas.capturePage" ? "capture-page" : id.slice(7);
|
|
1608
|
+
canvas.command(name).description(input.catalog.summary(id)).requiredOption("--input <json-or-@path>", "Canvas reference, base version and explicit native authoring request.").option("--client-token <uuid>", "Stable intent ID; reuse unchanged after an uncertain outcome. Made and printed as clientToken when left out.").action(async (options) => {
|
|
1609
|
+
const capability = input.catalog.one(id);
|
|
1610
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1365
1611
|
capability,
|
|
1366
|
-
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1367
|
-
|
|
1368
|
-
}));
|
|
1612
|
+
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1613
|
+
}, options.clientToken));
|
|
1369
1614
|
});
|
|
1370
1615
|
}
|
|
1371
1616
|
};
|
|
@@ -1373,12 +1618,11 @@ const configureCanvasConversions = (canvas, input) => {
|
|
|
1373
1618
|
//#endregion
|
|
1374
1619
|
//#region src/infrastructure/canvas-exchange.program.ts
|
|
1375
1620
|
const configureRemove = (canvas, input) => {
|
|
1376
|
-
canvas.command("remove").description("Remove explicitly named canvas subtrees with scope, lock and revision checks.").requiredOption("--input <json-or-@path>", "Request containing canvasRef, baseVersion and rootNodeIds.").
|
|
1377
|
-
input.output.result(await input.invocation
|
|
1378
|
-
capability:
|
|
1379
|
-
arguments: createCanvasJsonInputAdapter(options.input, canvasRemoveCapabilityInputSchema, "--input")
|
|
1380
|
-
|
|
1381
|
-
}));
|
|
1621
|
+
canvas.command("remove").description("Remove explicitly named canvas subtrees with scope, lock and revision checks.").requiredOption("--input <json-or-@path>", "Request containing canvasRef, baseVersion and rootNodeIds.").option("--client-token <uuid>", "Stable intent ID; reuse unchanged after an uncertain outcome. Made and printed as clientToken when left out.").action(async (options) => {
|
|
1622
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1623
|
+
capability: input.catalog.one("canvas.remove"),
|
|
1624
|
+
arguments: createCanvasJsonInputAdapter(options.input, canvasRemoveCapabilityInputSchema, "--input")
|
|
1625
|
+
}, options.clientToken));
|
|
1382
1626
|
});
|
|
1383
1627
|
};
|
|
1384
1628
|
const configureRead = (canvas, input) => {
|
|
@@ -1389,7 +1633,7 @@ const configureRead = (canvas, input) => {
|
|
|
1389
1633
|
...options.nodeId !== void 0 && { nodeId: options.nodeId }
|
|
1390
1634
|
} : createCanvasJsonInputAdapter(options.input, canvasReadInputSchema, "--input");
|
|
1391
1635
|
input.output.result(await input.invocation.invoke({
|
|
1392
|
-
capability:
|
|
1636
|
+
capability: input.catalog.one("canvas.read"),
|
|
1393
1637
|
arguments: request,
|
|
1394
1638
|
clientToken: null
|
|
1395
1639
|
}));
|
|
@@ -1398,46 +1642,43 @@ const configureRead = (canvas, input) => {
|
|
|
1398
1642
|
const configureCanvasExchange = (canvas, input) => {
|
|
1399
1643
|
canvas.command("find").description("Find accessible canvases and existing creation destinations with bounded results.").option("--input <json-or-@path>", "Search title, collection, limit and continuation cursor.", "{}").action(async (options) => {
|
|
1400
1644
|
input.output.result(await input.invocation.invoke({
|
|
1401
|
-
capability:
|
|
1645
|
+
capability: input.catalog.one("canvas.find"),
|
|
1402
1646
|
arguments: createCanvasJsonInputAdapter(options.input, canvasFindInputSchema, "--input"),
|
|
1403
1647
|
clientToken: null
|
|
1404
1648
|
}));
|
|
1405
1649
|
});
|
|
1406
1650
|
configureRemove(canvas, input);
|
|
1407
1651
|
configureRead(canvas, input);
|
|
1408
|
-
canvas.command("update-html").description("Apply an identity-preserving edit from a complete HTML snapshot.").requiredOption("--input <json-or-@path>", "Request containing canvasRef, snapshotToken, html and removeNodeIds.").
|
|
1652
|
+
canvas.command("update-html").description("Apply an identity-preserving edit from a complete HTML snapshot.").requiredOption("--input <json-or-@path>", "Request containing canvasRef, snapshotToken, html and removeNodeIds.").option("--client-token <uuid>", "Stable intent ID; reuse unchanged after an uncertain outcome. Made and printed as clientToken when left out.").action(async (options) => {
|
|
1409
1653
|
const request = createCanvasJsonInputAdapter(options.input, canvasUpdateHtmlCapabilityInputSchema, "--input");
|
|
1410
|
-
input.output.result(await input.invocation
|
|
1411
|
-
capability:
|
|
1412
|
-
arguments: request
|
|
1413
|
-
|
|
1414
|
-
}));
|
|
1654
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1655
|
+
capability: input.catalog.one("canvas.updateHtml"),
|
|
1656
|
+
arguments: request
|
|
1657
|
+
}, options.clientToken));
|
|
1415
1658
|
});
|
|
1416
1659
|
};
|
|
1417
1660
|
|
|
1418
1661
|
//#endregion
|
|
1419
1662
|
//#region src/infrastructure/canvas-prototype.program.ts
|
|
1420
1663
|
const configureCanvasPrototype = (canvas, input) => {
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
input.output.result(await input.invocation
|
|
1664
|
+
canvas.command("publish-prototype").description(input.catalog.summary("prototype.publishCanvas")).requiredOption("--input <json-or-@path>", "Complete canvas reference, baseVersion, unpacked build directory or existing deployment, and bounded waitMs.").option("--client-token <uuid>", "Stable attachment intent; reuse the same arguments after uncertainty, use a new token after replanning. Made and printed as clientToken when left out.").action(async (options) => {
|
|
1665
|
+
const capability = input.catalog.one("prototype.publishCanvas");
|
|
1666
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1424
1667
|
capability,
|
|
1425
|
-
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1426
|
-
|
|
1427
|
-
}));
|
|
1668
|
+
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1669
|
+
}, options.clientToken));
|
|
1428
1670
|
});
|
|
1429
1671
|
};
|
|
1430
1672
|
|
|
1431
1673
|
//#endregion
|
|
1432
1674
|
//#region src/infrastructure/canvas-asset.program.ts
|
|
1433
1675
|
const configureCanvasAsset = (canvas, input) => {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
input.output.result(await input.invocation
|
|
1676
|
+
canvas.command("import-asset").description(input.catalog.summary("canvas.importAsset")).requiredOption("--input <json-or-@path>", "Canvas reference and selected local file source.").option("--client-token <uuid>", "Stable import intent; reuse after uncertainty. Made and printed as clientToken when left out.").action(async (options) => {
|
|
1677
|
+
const capability = input.catalog.one("canvas.importAsset");
|
|
1678
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1437
1679
|
capability,
|
|
1438
|
-
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1439
|
-
|
|
1440
|
-
}));
|
|
1680
|
+
arguments: createCanvasJsonInputAdapter(options.input, capability.inputSchema, "--input")
|
|
1681
|
+
}, options.clientToken));
|
|
1441
1682
|
});
|
|
1442
1683
|
};
|
|
1443
1684
|
|
|
@@ -1458,11 +1699,8 @@ const configureCanvasAuthoring = (canvas, input) => {
|
|
|
1458
1699
|
//#endregion
|
|
1459
1700
|
//#region src/infrastructure/canvas-inspection.program.ts
|
|
1460
1701
|
const referenceFor = (command) => {
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1463
|
-
if (reference !== void 0 && legacy !== void 0) throw new CliError("BAD_REQUEST", "--canvas and --canvas-id cannot be combined.", "Pass the pasted URL or UUID through --canvas.");
|
|
1464
|
-
const selected = reference ?? legacy;
|
|
1465
|
-
if (typeof selected !== "string") throw new TypeError(`The required-option check let canvas ${command.name()} run without --canvas.`);
|
|
1702
|
+
const selected = command.getOptionValue("canvas");
|
|
1703
|
+
if (typeof selected !== "string") throw new TypeError(`The spelling check let canvas ${command.name()} run without --canvas.`);
|
|
1466
1704
|
return {
|
|
1467
1705
|
reference: parseCanvasReference(selected),
|
|
1468
1706
|
url: selected
|
|
@@ -1486,6 +1724,10 @@ const readLinkedSelection = async (command, input, reference, url) => {
|
|
|
1486
1724
|
node: nodes.find((node) => node.id === nodeId)
|
|
1487
1725
|
};
|
|
1488
1726
|
};
|
|
1727
|
+
/**
|
|
1728
|
+
* Lets the four read commands follow a link to a page or a selection. They take `--canvas` as
|
|
1729
|
+
* their own, so the link reaches them whole and `--canvas-id` is read into it.
|
|
1730
|
+
*/
|
|
1489
1731
|
const configureCanvasInspection = (canvas, input) => {
|
|
1490
1732
|
for (const name of [
|
|
1491
1733
|
"inspect",
|
|
@@ -1496,7 +1738,6 @@ const configureCanvasInspection = (canvas, input) => {
|
|
|
1496
1738
|
const command = canvas.commands.find((candidate) => candidate.name() === name);
|
|
1497
1739
|
const canvasId = command?.options.find((option) => option.long === "--canvas-id");
|
|
1498
1740
|
if (command === void 0 || canvasId === void 0) continue;
|
|
1499
|
-
canvasId.makeOptionMandatory(false);
|
|
1500
1741
|
command.options.find((option) => option.long === "--node-id")?.makeOptionMandatory(false);
|
|
1501
1742
|
command.option("--canvas <url-or-id>", "Pasted canvas URL or UUID. Selection links limit reads and edits to the linked subtree.");
|
|
1502
1743
|
command.action(async () => {
|
|
@@ -1515,18 +1756,9 @@ const configureCanvasInspection = (canvas, input) => {
|
|
|
1515
1756
|
const createCanvasRenderInputAdapter = (options) => {
|
|
1516
1757
|
if (options.input === void 0) return null;
|
|
1517
1758
|
if (options.canvas !== void 0 || options.nodeId !== void 0 || options.bounds !== void 0 || options.expectedVersion !== void 0 || options.atMs !== void 0 || options.output !== void 0 || options.force === true || options.scale !== "1" || options.timeoutMs !== "120000") throw new CliError("BAD_REQUEST", "The bounded --input request cannot be combined with individual render options.", "Put the entire scoped render request in --input.");
|
|
1518
|
-
return {
|
|
1519
|
-
arguments: createCanvasJsonInputAdapter(options.input, canvasRenderScopedInputSchema, "--input"),
|
|
1520
|
-
clientToken: clientTokenForInput(options.clientToken)
|
|
1521
|
-
};
|
|
1759
|
+
return { arguments: createCanvasJsonInputAdapter(options.input, canvasRenderScopedInputSchema, "--input") };
|
|
1522
1760
|
};
|
|
1523
1761
|
|
|
1524
|
-
//#endregion
|
|
1525
|
-
//#region src/infrastructure/command-examples.consts.ts
|
|
1526
|
-
const CANVAS_RENDER_EXAMPLE = "canvas render --canvas 0b9f4c1e-5d2a-4e8b-9c3f-7a6d1e2b4c50";
|
|
1527
|
-
/** A command line, after the binary name, that each listed command accepts exactly as written. */
|
|
1528
|
-
const COMMAND_EXAMPLES = { "canvas render": CANVAS_RENDER_EXAMPLE };
|
|
1529
|
-
|
|
1530
1762
|
//#endregion
|
|
1531
1763
|
//#region src/infrastructure/canvas.program.ts
|
|
1532
1764
|
const positiveInteger$2 = z.coerce.number().int().positive();
|
|
@@ -1578,7 +1810,7 @@ const selectedRenderTarget = async (options, input) => {
|
|
|
1578
1810
|
const held = wholeCanvasDocumentOutputSchema.parse(await input.remote.query("canvas.document.get", { canvasId: reference.canvasId }));
|
|
1579
1811
|
if (expectedVersion !== null && expectedVersion !== held.version) throw new CliError("CONFLICT", "The canvas changed before rendering.", "Read the linked page or selection and render its current version.");
|
|
1580
1812
|
return {
|
|
1581
|
-
target: canvasReferenceRenderTarget(reference,
|
|
1813
|
+
target: canvasReferenceRenderTarget(reference, readStoredCanvasScene(held.document), target),
|
|
1582
1814
|
expectedVersion: held.version
|
|
1583
1815
|
};
|
|
1584
1816
|
};
|
|
@@ -1592,7 +1824,7 @@ const executeRender = async (options, input) => {
|
|
|
1592
1824
|
if (recordingId === void 0 && options.atMs !== void 0) throw new CliError("BAD_REQUEST", "--at-ms requires a stable recording node id such as rec_<recording-uuid>.", "Run `enhance canvas tree --canvas <url-or-id>` and choose a recording node.");
|
|
1593
1825
|
selectClientToken(input, options.clientToken);
|
|
1594
1826
|
const result = await input.invocation.invoke({
|
|
1595
|
-
capability:
|
|
1827
|
+
capability: input.catalog.one("canvas.render"),
|
|
1596
1828
|
arguments: {
|
|
1597
1829
|
canvasId: parseCanvasReference(options.canvas).canvasId,
|
|
1598
1830
|
...resolved,
|
|
@@ -1610,15 +1842,14 @@ const executeRender = async (options, input) => {
|
|
|
1610
1842
|
});
|
|
1611
1843
|
input.output.result(result);
|
|
1612
1844
|
};
|
|
1613
|
-
const rootOf = (command) => command.parent === null ? command : rootOf(command.parent);
|
|
1614
1845
|
const configureRender = (render, input) => {
|
|
1615
|
-
render.option("--input <json-or-@path>", "Bounded scoped render request
|
|
1846
|
+
render.option("--input <json-or-@path>", "Bounded scoped render request.").option("--canvas <url-or-id>", "Canvas URL or UUID to render.").option("--node-id <id>", "Render one stable canvas node instead of all authored content.").option("--bounds <json>", "Render an explicit rectangle in canvas world coordinates.").option("--expected-version <integer>", "Refuse pixels from any other document version.").option("--at-ms <integer>", "Pause a recording node at this millisecond; inspect the PNG before snapshotting it.").option("--scale <number>", "Output pixels per canvas unit, from 0.1 to 4.", "1").option("--output <path>", "Write the PNG to this path instead of a protected temporary file.").option("--force", "Replace an existing --output file deliberately.", false).option("--timeout-ms <integer>", "Local polling deadline in milliseconds.", "120000").option("--client-token <uuid>", "Stable UUID to reuse only when retrying this render request.").addHelpText("after", "\nFor transcript-led selection, inspect nearby --at-ms renders and reject transitions or duplicate states before running recording snapshot.").action(async (options) => {
|
|
1616
1847
|
const bounded = createCanvasRenderInputAdapter(options);
|
|
1617
1848
|
if (bounded === null) return executeRender(options, input);
|
|
1618
|
-
input.output.result(await input.invocation
|
|
1619
|
-
capability:
|
|
1849
|
+
input.output.result(await invokeWithClientToken(input.invocation, {
|
|
1850
|
+
capability: input.catalog.one("canvas.render"),
|
|
1620
1851
|
...bounded
|
|
1621
|
-
}));
|
|
1852
|
+
}, options.clientToken));
|
|
1622
1853
|
});
|
|
1623
1854
|
};
|
|
1624
1855
|
const registerCanvasProgram = (program, input) => {
|
|
@@ -1638,7 +1869,42 @@ const registerCanvasProgram = (program, input) => {
|
|
|
1638
1869
|
};
|
|
1639
1870
|
|
|
1640
1871
|
//#endregion
|
|
1641
|
-
//#region
|
|
1872
|
+
//#region src/infrastructure/capture-skill.lib.ts
|
|
1873
|
+
/**
|
|
1874
|
+
* The skill `setup` copies to each coding agent. Its description says when it applies, and its body
|
|
1875
|
+
* names the commands; the tool's own help teaches the rest. A line is added only when measured
|
|
1876
|
+
* runs are worse without it; `skill-evaluation` holds the cases and what the last runs found.
|
|
1877
|
+
*/
|
|
1878
|
+
const skillText = (skill, command) => `---
|
|
1879
|
+
name: ${skill}
|
|
1880
|
+
description: Put the screens a thread is changing onto an Enhance canvas as editable frames and return the link. Use when asked to capture, share or review screens, or to put work on a canvas. Also applies whenever a thread has changed how a screen looks: when that work is done, offer once, in one line, to put the changed screens on an Enhance canvas for review, and capture only on a yes.
|
|
1881
|
+
---
|
|
1882
|
+
|
|
1883
|
+
# Capture screens to Enhance
|
|
1884
|
+
|
|
1885
|
+
Put each screen this thread is changing onto one Enhance canvas as an editable frame, and return the canvas link.
|
|
1886
|
+
|
|
1887
|
+
## Commands
|
|
1888
|
+
|
|
1889
|
+
- \`${command} canvas create --title "<what this thread is changing>"\` makes the canvas and answers with its id and its link.
|
|
1890
|
+
- \`${command} canvas capture-page --help\` shows the two calls one capture takes, with an example. Read it before the first capture.
|
|
1891
|
+
- \`${command} auth status\` says who is signed in. If nobody is, ask the person to run \`${command} setup\`.
|
|
1892
|
+
`;
|
|
1893
|
+
/**
|
|
1894
|
+
* The skill's name and file. `command` is how an agent's shell reaches the tool: its command name
|
|
1895
|
+
* when that is on the PATH, or its full path. Each release names its skill after its own command,
|
|
1896
|
+
* so the production and development tools never overwrite one another's.
|
|
1897
|
+
*/
|
|
1898
|
+
const captureSkillOf = (input) => {
|
|
1899
|
+
const name = `${input.commandName}-capture`;
|
|
1900
|
+
return {
|
|
1901
|
+
name,
|
|
1902
|
+
text: skillText(name, input.command)
|
|
1903
|
+
};
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
//#endregion
|
|
1907
|
+
//#region ../../packages/sdk/dist/stall-watch.lib-DL_Gnxep.mjs
|
|
1642
1908
|
const CAPTURE_METADATA_LENGTH = 200;
|
|
1643
1909
|
const CAPTURE_FAILURE_LENGTH = 1e3;
|
|
1644
1910
|
const CAPTURE_UPLOAD_BATCH_SIZE = 400;
|
|
@@ -2383,9 +2649,24 @@ const writeCaptureJson = async (path, value) => {
|
|
|
2383
2649
|
await writeFile(temporary, JSON.stringify(value), { mode: 384 });
|
|
2384
2650
|
await rename(temporary, path);
|
|
2385
2651
|
};
|
|
2652
|
+
const manifestJson = (path, content) => {
|
|
2653
|
+
try {
|
|
2654
|
+
return JSON.parse(content);
|
|
2655
|
+
} catch (error) {
|
|
2656
|
+
throw captureError("artifact", `The capture manifest ${path} is not JSON: ${error instanceof Error ? error.message : "it could not be parsed"}.`);
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
/**
|
|
2660
|
+
* The manifest at `path`. One that is not JSON, or not a capture manifest, throws an artifact
|
|
2661
|
+
* error naming the file and the first problem in it, which a caller can report as bad input.
|
|
2662
|
+
*/
|
|
2386
2663
|
const readCaptureManifest = async (path) => {
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2664
|
+
const content = await readFile(path, "utf8");
|
|
2665
|
+
const parsed = lenientCaptureManifestSchema.safeParse(manifestJson(path, content));
|
|
2666
|
+
if (parsed.success) return parsed.data;
|
|
2667
|
+
const [problem] = parsed.error.issues;
|
|
2668
|
+
const field = problem?.path.join(".") ?? "";
|
|
2669
|
+
throw captureError("artifact", `The capture manifest ${path} is not valid: ${field === "" ? "" : `${field}: `}${problem?.message ?? "it is not a capture manifest"}`);
|
|
2389
2670
|
};
|
|
2390
2671
|
/** Historical formats stay pinned; an ordinary writer always uses CANVAS_SCENE_VERSION. */
|
|
2391
2672
|
const LEGACY_CANVAS_FORMATS = {
|
|
@@ -2421,8 +2702,10 @@ const LEGACY_CANVAS_ADAPTATIONS = {
|
|
|
2421
2702
|
[LEGACY_CANVAS_FORMATS.v13]: "format-number",
|
|
2422
2703
|
[LEGACY_CANVAS_FORMATS.v14]: "format-number"
|
|
2423
2704
|
};
|
|
2424
|
-
/** Why the API refused
|
|
2705
|
+
/** Why the API refused a request or one of its operations, as a fixed value. Never its words. */
|
|
2425
2706
|
const CANVAS_REFUSAL_CODES = [
|
|
2707
|
+
"input-invalid",
|
|
2708
|
+
"request-too-large",
|
|
2426
2709
|
"appearance-unsupported-component",
|
|
2427
2710
|
"styles-unsupported-component",
|
|
2428
2711
|
"text-shadow-blend-unsupported",
|
|
@@ -2725,6 +3008,96 @@ const adaptCanvasDocumentFormat = (document) => {
|
|
|
2725
3008
|
if (document["version"] === LEGACY_CANVAS_FORMATS.v13 || document["version"] === LEGACY_CANVAS_FORMATS.v14) return adapted;
|
|
2726
3009
|
return withoutTextShadowBlends(document["version"] === LEGACY_CANVAS_FORMATS.v12 ? adapted : adaptCanvasCss(adapted));
|
|
2727
3010
|
};
|
|
3011
|
+
const isSafeInteger = (value) => Number.isSafeInteger(value);
|
|
3012
|
+
/** A format below 1 names no adaptation, so the walk below refuses it. */
|
|
3013
|
+
const canvasWriterFormat = (version) => {
|
|
3014
|
+
if (!isSafeInteger(version)) return "refused";
|
|
3015
|
+
if (version > 15) return "ahead";
|
|
3016
|
+
if (version === 15) return "current";
|
|
3017
|
+
const adaptations = new Map(Object.entries(LEGACY_CANVAS_ADAPTATIONS).map(([format, kind]) => [Number(format), kind]));
|
|
3018
|
+
for (let format = version; format < 15; format += 1) if (adaptations.get(format) !== "format-number") return "refused";
|
|
3019
|
+
return "number-only";
|
|
3020
|
+
};
|
|
3021
|
+
const objectPictureSizeSchema = z.enum(["quarter", "sixteenth"]);
|
|
3022
|
+
/** One stored picture of one top layer. */
|
|
3023
|
+
const canvasObjectPictureSchema = z.strictObject({
|
|
3024
|
+
objectId: z.string().min(1),
|
|
3025
|
+
size: objectPictureSizeSchema,
|
|
3026
|
+
/** Where the picture's bytes are; what it answers with never changes. */
|
|
3027
|
+
url: z.string().min(1),
|
|
3028
|
+
width: z.number().int().positive(),
|
|
3029
|
+
height: z.number().int().positive(),
|
|
3030
|
+
/** The canvas version the picture was drawn at. */
|
|
3031
|
+
drawnVersion: z.number().int().nonnegative(),
|
|
3032
|
+
/** Whether the top layer is unchanged since the picture was drawn. */
|
|
3033
|
+
isCurrent: z.boolean(),
|
|
3034
|
+
/**
|
|
3035
|
+
* The font size, in pixels, that set the most characters of the top layer's texts when it was
|
|
3036
|
+
* drawn; left out where it held no text, or for a picture drawn before sizes were kept.
|
|
3037
|
+
*/
|
|
3038
|
+
textSize: z.number().positive().optional()
|
|
3039
|
+
});
|
|
3040
|
+
z.strictObject({
|
|
3041
|
+
canvasId: z.uuid(),
|
|
3042
|
+
/** Only pictures drawn after this version; every picture when left out. */
|
|
3043
|
+
sinceVersion: z.number().int().nonnegative().optional()
|
|
3044
|
+
});
|
|
3045
|
+
z.object({ pictures: z.array(canvasObjectPictureSchema) });
|
|
3046
|
+
z.strictObject({
|
|
3047
|
+
canvasId: z.uuid(),
|
|
3048
|
+
objectIds: z.array(z.string().min(1)).min(1).max(200)
|
|
3049
|
+
});
|
|
3050
|
+
z.object({ scheduled: z.number().int().nonnegative() });
|
|
3051
|
+
const MAX_PICTURE_STORAGE_KEY_LENGTH = 500;
|
|
3052
|
+
const MAX_PICTURE_FAILURE_LENGTH = 500;
|
|
3053
|
+
/** One top layer a picture job is to draw, with when it was last put on the list. */
|
|
3054
|
+
const objectPictureWorkObjectSchema = z.object({
|
|
3055
|
+
objectId: z.string().min(1),
|
|
3056
|
+
wantedAt: z.iso.datetime()
|
|
3057
|
+
});
|
|
3058
|
+
/** One picture a job drew and uploaded, in pixels of the stored picture. */
|
|
3059
|
+
const drawnObjectPictureSchema = z.object({
|
|
3060
|
+
size: objectPictureSizeSchema,
|
|
3061
|
+
width: z.number().int().positive(),
|
|
3062
|
+
height: z.number().int().positive(),
|
|
3063
|
+
bytes: z.number().int().positive(),
|
|
3064
|
+
storageKey: z.string().min(1).max(MAX_PICTURE_STORAGE_KEY_LENGTH),
|
|
3065
|
+
/** The text size of the top layer the page drew, as the list of pictures gives it. */
|
|
3066
|
+
textSize: z.number().positive().optional()
|
|
3067
|
+
});
|
|
3068
|
+
z.object({
|
|
3069
|
+
jobId: z.uuid(),
|
|
3070
|
+
loadedVersion: z.number().int().positive(),
|
|
3071
|
+
drawn: z.array(objectPictureWorkObjectSchema.extend({ pictures: z.array(drawnObjectPictureSchema).length(2) })).max(20),
|
|
3072
|
+
failed: z.array(z.object({
|
|
3073
|
+
objectId: z.string().min(1),
|
|
3074
|
+
message: z.string().min(1).max(MAX_PICTURE_FAILURE_LENGTH)
|
|
3075
|
+
})).max(20)
|
|
3076
|
+
});
|
|
3077
|
+
const coordinate$1 = z.number();
|
|
3078
|
+
const extent = z.number().nonnegative();
|
|
3079
|
+
/** A box in page coordinates. */
|
|
3080
|
+
const canvasOutlineBoxSchema = z.strictObject({
|
|
3081
|
+
x: coordinate$1,
|
|
3082
|
+
y: coordinate$1,
|
|
3083
|
+
width: extent,
|
|
3084
|
+
height: extent
|
|
3085
|
+
});
|
|
3086
|
+
/** What a browser measured of one top layer: its own box, and how far its descendants paint. */
|
|
3087
|
+
const canvasOutlineMeasurementSchema = z.strictObject({
|
|
3088
|
+
objectId: z.string().min(1),
|
|
3089
|
+
box: canvasOutlineBoxSchema,
|
|
3090
|
+
reach: canvasOutlineBoxSchema
|
|
3091
|
+
});
|
|
3092
|
+
z.strictObject({
|
|
3093
|
+
canvasId: z.uuid(),
|
|
3094
|
+
/** The revision of the document the browser had laid out when it measured. */
|
|
3095
|
+
version: z.number().int().positive(),
|
|
3096
|
+
measurements: z.array(canvasOutlineMeasurementSchema).min(1).max(200)
|
|
3097
|
+
});
|
|
3098
|
+
z.object({ stored: z.number().int().nonnegative() });
|
|
3099
|
+
z.strictObject({ canvasId: z.uuid() });
|
|
3100
|
+
z.object({ measurements: z.array(canvasOutlineMeasurementSchema.extend({ measuredVersion: z.number().int().nonnegative() })) });
|
|
2728
3101
|
z.strictObject({});
|
|
2729
3102
|
z.object({ firstAgentWorkAt: z.iso.datetime().nullable() });
|
|
2730
3103
|
/** Cursor pagination, defined once so no endpoint invents its own page shape. */
|
|
@@ -2831,13 +3204,18 @@ const canvasSchema = z.object({
|
|
|
2831
3204
|
createdAt: z.iso.datetime(),
|
|
2832
3205
|
lastActivityAt: z.iso.datetime()
|
|
2833
3206
|
});
|
|
3207
|
+
/**
|
|
3208
|
+
* A canvas with its full web address, which only the API can write: it is built from the web
|
|
3209
|
+
* address of the API's own environment, so a reader never joins an id to a host.
|
|
3210
|
+
*/
|
|
3211
|
+
const linkedCanvasSchema = canvasSchema.extend({ url: z.url() });
|
|
2834
3212
|
z.object({
|
|
2835
3213
|
title: z.string().trim().min(1),
|
|
2836
3214
|
/** The team to file it under, or null for the maker's own. Refused for one you are not on. */
|
|
2837
3215
|
organisationId: z.uuid().nullable().default(null),
|
|
2838
3216
|
sourceUrl: z.string().nullable().default(null)
|
|
2839
3217
|
});
|
|
2840
|
-
|
|
3218
|
+
linkedCanvasSchema.extend({ version: z.number().int().positive() });
|
|
2841
3219
|
z.object({ canvasId: z.uuid() });
|
|
2842
3220
|
/**
|
|
2843
3221
|
* Which collection to draw: your own, a team's by id, or everything you can reach. One field
|
|
@@ -2861,7 +3239,7 @@ z.object({
|
|
|
2861
3239
|
]).default("all"),
|
|
2862
3240
|
hasUnresolved: z.boolean().default(false)
|
|
2863
3241
|
});
|
|
2864
|
-
const canvasCardBaseSchema =
|
|
3242
|
+
const canvasCardBaseSchema = linkedCanvasSchema.extend({
|
|
2865
3243
|
screenCount: z.number().int().min(0),
|
|
2866
3244
|
hasRecording: z.boolean(),
|
|
2867
3245
|
/** When the person listing last opened it in the web app; `null` if they never have. */
|
|
@@ -3293,6 +3671,11 @@ const canvasNodeLayoutSchema = z.object({
|
|
|
3293
3671
|
clipContent: z.boolean().optional(),
|
|
3294
3672
|
baselineSource: canvasBaselineSourceSchema.optional(),
|
|
3295
3673
|
scrollbarGutter: canvasScrollbarGutterSchema.optional(),
|
|
3674
|
+
/**
|
|
3675
|
+
* The frame holds an embedded document. Chromium sizes that document's viewport in whole
|
|
3676
|
+
* pixels, rounding the frame's content box up, so what the frame holds resolves against that.
|
|
3677
|
+
*/
|
|
3678
|
+
embeddedDocument: z.literal(true).optional(),
|
|
3296
3679
|
container: canvasFlexLayoutSchema.partial().extend({ padding: canvasFlexPaddingSchema.partial().optional() }).optional()
|
|
3297
3680
|
}).strict();
|
|
3298
3681
|
const boundedNumber = canvasNumberSchema;
|
|
@@ -3361,7 +3744,9 @@ const canvasOutlineSchema = z.object({
|
|
|
3361
3744
|
]),
|
|
3362
3745
|
paints: z.array(canvasPaintSchema),
|
|
3363
3746
|
dashPattern: canvasDashPatternSchema.optional(),
|
|
3364
|
-
dashCap: canvasDashCapSchema.optional()
|
|
3747
|
+
dashCap: canvasDashCapSchema.optional(),
|
|
3748
|
+
/** Captured CSS dashes, which the browser draws, as for a border. */
|
|
3749
|
+
dashOrigin: z.literal("css").optional()
|
|
3365
3750
|
});
|
|
3366
3751
|
const canvasShadowSchema = z.object({
|
|
3367
3752
|
id: itemId,
|
|
@@ -3820,13 +4205,13 @@ z.strictObject({
|
|
|
3820
4205
|
state: z.enum(["awaiting_upload", "ready"]),
|
|
3821
4206
|
metadata: canvasAssetMetadataSchema.nullable()
|
|
3822
4207
|
}).refine((asset) => asset.state === "ready" === (asset.metadata !== null), "Readiness must match verified metadata.").refine((asset) => asset.metadata === null || asset.metadata.kind === asset.kind, "Metadata must describe the reserved asset kind.").refine((asset) => isStoredContentType(asset.kind, asset.contentType), "Content type must match the asset kind.").refine((asset) => asset.path === (asset.kind === "image" ? canvasImageAssetPath(asset.canvasId, asset.assetId) : canvasFontAssetPath(asset.canvasId, asset.sha256)), "The resource path must match its native identity.").safeExtend({ upload: signedUploadSchema.nullable() }).refine((asset) => asset.state === "awaiting_upload" === (asset.upload !== null), "Only pending uploads receive upload access.");
|
|
3823
|
-
const SIDES = [
|
|
4208
|
+
const SIDES$1 = [
|
|
3824
4209
|
"top",
|
|
3825
4210
|
"right",
|
|
3826
4211
|
"bottom",
|
|
3827
4212
|
"left"
|
|
3828
4213
|
];
|
|
3829
|
-
SIDES.map((side) => `padding-${side}`), SIDES.map((side) => `margin-${side}`);
|
|
4214
|
+
SIDES$1.map((side) => `padding-${side}`), SIDES$1.map((side) => `margin-${side}`);
|
|
3830
4215
|
const format = z.enum(["png", "jpeg"]);
|
|
3831
4216
|
const scale = z.number().positive();
|
|
3832
4217
|
const canvasExportSettingsSchema = z.strictObject({
|
|
@@ -3899,7 +4284,34 @@ const canvasGeometrySchema = z.discriminatedUnion("kind", [
|
|
|
3899
4284
|
canvasBooleanGeometrySchema
|
|
3900
4285
|
]);
|
|
3901
4286
|
const CANVAS_COMPOSITING_RETIRED = "Update Enhance: compositing is no longer supported. Use the isolation style or a mask group.";
|
|
3902
|
-
const
|
|
4287
|
+
const CANVAS_FORMAT_UPDATE_REQUIRED = "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.";
|
|
4288
|
+
const CANVAS_FORMAT_SERVER_UPDATING = "Enhance is being updated. Try again in a minute.";
|
|
4289
|
+
/** Marks an issue whose message was written for whoever sent the request, so the API keeps it. */
|
|
4290
|
+
const FOR_CALLER = { forCaller: true };
|
|
4291
|
+
/**
|
|
4292
|
+
* The format a writer was built for, as a plain whole number so tool schemas can describe it. Which
|
|
4293
|
+
* writes that format may make is `refuseUnsafeWriterFormat`'s call.
|
|
4294
|
+
*/
|
|
4295
|
+
const canvasDocumentFormatSchema = z.number({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).int({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).positive({ error: CANVAS_FORMAT_UPDATE_REQUIRED }).meta({
|
|
4296
|
+
description: `The document format this client writes. The current format is ${String(15)}.`,
|
|
4297
|
+
examples: [15]
|
|
4298
|
+
});
|
|
4299
|
+
/**
|
|
4300
|
+
* Refuses a write its client's format could get wrong. A client whose format differs from the
|
|
4301
|
+
* current one only in its number may still name changes, but a whole value it sends may lack
|
|
4302
|
+
* fields added since, so that needs the current format.
|
|
4303
|
+
*/
|
|
4304
|
+
const refuseUnsafeWriterFormat = (documentFormatVersion, writes, context) => {
|
|
4305
|
+
const writer = canvasWriterFormat(documentFormatVersion);
|
|
4306
|
+
if (writer === "current" || writer === "number-only" && writes === "names") return;
|
|
4307
|
+
context.addIssue({
|
|
4308
|
+
code: "custom",
|
|
4309
|
+
path: ["documentFormatVersion"],
|
|
4310
|
+
message: writer === "ahead" ? CANVAS_FORMAT_SERVER_UPDATING : CANVAS_FORMAT_UPDATE_REQUIRED,
|
|
4311
|
+
params: FOR_CALLER,
|
|
4312
|
+
input: documentFormatVersion
|
|
4313
|
+
});
|
|
4314
|
+
};
|
|
3903
4315
|
z.object({
|
|
3904
4316
|
signature: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
3905
4317
|
/** The captured picture of the page's text, inline as written or as its canvas image store path. */
|
|
@@ -3949,13 +4361,14 @@ const canvasSceneNodeSchema = z.looseObject({
|
|
|
3949
4361
|
props: z.record(z.string(), z.unknown()).optional(),
|
|
3950
4362
|
box: canvasSceneBoxSchema.optional()
|
|
3951
4363
|
});
|
|
4364
|
+
const canvasSceneRelationshipSchema = z.object({
|
|
4365
|
+
parentId: z.string().min(1),
|
|
4366
|
+
sortKey: z.string().min(1)
|
|
4367
|
+
});
|
|
3952
4368
|
const canvasSceneDocumentSchema = z.object({
|
|
3953
4369
|
version: z.literal(15),
|
|
3954
4370
|
nodes: z.record(z.string(), canvasSceneNodeSchema),
|
|
3955
|
-
relationships: z.record(z.string(),
|
|
3956
|
-
parentId: z.string().min(1),
|
|
3957
|
-
sortKey: z.string().min(1)
|
|
3958
|
-
})),
|
|
4371
|
+
relationships: z.record(z.string(), canvasSceneRelationshipSchema),
|
|
3959
4372
|
tombstones: z.record(z.string(), z.literal(true)).default({})
|
|
3960
4373
|
});
|
|
3961
4374
|
const legacyRecordSchema = z.record(z.string(), z.unknown());
|
|
@@ -3979,6 +4392,10 @@ const emptyCanvasSceneDocument = () => ({
|
|
|
3979
4392
|
relationships: {},
|
|
3980
4393
|
tombstones: {}
|
|
3981
4394
|
});
|
|
4395
|
+
canvasSceneDocumentSchema.extend({
|
|
4396
|
+
nodes: z.record(z.string(), z.unknown()),
|
|
4397
|
+
relationships: z.record(z.string(), z.unknown())
|
|
4398
|
+
});
|
|
3982
4399
|
const temporaryIdSchema = z.string().min(1);
|
|
3983
4400
|
const canvasConversionIssueSchema = z.object({
|
|
3984
4401
|
code: z.enum([
|
|
@@ -4014,7 +4431,8 @@ const canvasUnsupportedFeatureSchema = z.enum([
|
|
|
4014
4431
|
"image-shadows",
|
|
4015
4432
|
"effect-noise",
|
|
4016
4433
|
"effect-texture",
|
|
4017
|
-
"effect-glass"
|
|
4434
|
+
"effect-glass",
|
|
4435
|
+
"mask-source"
|
|
4018
4436
|
]);
|
|
4019
4437
|
const canvasConversionReportSchema = z.object({
|
|
4020
4438
|
nodeCount: z.number().int().positive(),
|
|
@@ -4059,7 +4477,8 @@ const canvasSubtreeDraftSchema = z.object({
|
|
|
4059
4477
|
/** A capture that lands as a new editable frame on a page, with no screen layer. */
|
|
4060
4478
|
const editableFrameCaptureSchema = z.object({
|
|
4061
4479
|
screenId: z.string().min(1),
|
|
4062
|
-
pageId: z.string().min(1)
|
|
4480
|
+
pageId: z.string().min(1),
|
|
4481
|
+
pictureNodeId: z.string().min(1).optional().describe("The capture's picture, which the frame replaces in place and whose id it keeps. Refused as capture-already-landed once the picture is a frame.")
|
|
4063
4482
|
});
|
|
4064
4483
|
const editableFrameInputBase = {
|
|
4065
4484
|
canvasId: z.uuid(),
|
|
@@ -4074,7 +4493,9 @@ z.union([z.strictObject({
|
|
|
4074
4493
|
}), z.strictObject({
|
|
4075
4494
|
...editableFrameInputBase,
|
|
4076
4495
|
capture: editableFrameCaptureSchema.describe("The stored page a new capture lands from, and the page its frame goes on.")
|
|
4077
|
-
})])
|
|
4496
|
+
})]).superRefine((input, context) => {
|
|
4497
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "whole", context);
|
|
4498
|
+
});
|
|
4078
4499
|
const createEditableFrameResultSchema = z.object({
|
|
4079
4500
|
canvasId: z.uuid(),
|
|
4080
4501
|
mutationId: z.uuid(),
|
|
@@ -4135,7 +4556,8 @@ const RENDER_WARNING_CODES = [
|
|
|
4135
4556
|
"LOCAL_FONT_FALLBACK",
|
|
4136
4557
|
"SOURCE_FALLBACK",
|
|
4137
4558
|
"SCALE_REDUCED",
|
|
4138
|
-
"LAYOUT_FALLBACK"
|
|
4559
|
+
"LAYOUT_FALLBACK",
|
|
4560
|
+
"DRAWN_APPROXIMATELY"
|
|
4139
4561
|
];
|
|
4140
4562
|
const MAX_RENDER_MESSAGE_LENGTH$1 = 500;
|
|
4141
4563
|
const canvasRenderPixelLimitSchema = z.number().int().positive();
|
|
@@ -4372,7 +4794,12 @@ const canvasConversionDestinationSchema = z.discriminatedUnion("kind", [
|
|
|
4372
4794
|
}),
|
|
4373
4795
|
z.object({
|
|
4374
4796
|
kind: z.literal("replace"),
|
|
4375
|
-
targetNodeId: z.string().min(1)
|
|
4797
|
+
targetNodeId: z.string().min(1),
|
|
4798
|
+
/**
|
|
4799
|
+
* A capture's swap: the target must still be the capture's picture. When another browser has
|
|
4800
|
+
* already made it editable, the swap is refused as `capture-already-landed`.
|
|
4801
|
+
*/
|
|
4802
|
+
onlyPicture: z.literal(true).optional()
|
|
4376
4803
|
})
|
|
4377
4804
|
]);
|
|
4378
4805
|
const canvasConversionSourceSchema = z.discriminatedUnion("kind", [z.object({
|
|
@@ -5095,7 +5522,7 @@ const currentCanvasOperationSchema = z.discriminatedUnion("op", [
|
|
|
5095
5522
|
removedText: z.record(nodeIdSchema$3, canvasSceneNodeSchema.pick({ props: true })).optional()
|
|
5096
5523
|
})
|
|
5097
5524
|
]);
|
|
5098
|
-
|
|
5525
|
+
currentCanvasOperationSchema.options;
|
|
5099
5526
|
/** Each operation's name, for records that may state which kind failed and nothing else. */
|
|
5100
5527
|
const CANVAS_OPERATION_NAMES = currentCanvasOperationSchema.options.map((option) => option.shape.op.value);
|
|
5101
5528
|
const canvasOperationSchema = z.preprocess((value, context) => {
|
|
@@ -5154,6 +5581,8 @@ const canvasMutationRevisionSchema = z.object({
|
|
|
5154
5581
|
operations: z.array(canvasOperationSchema)
|
|
5155
5582
|
});
|
|
5156
5583
|
z.object({
|
|
5584
|
+
/** The canvas's web address. An API older than the field answers without it. */
|
|
5585
|
+
url: z.url().optional(),
|
|
5157
5586
|
mutations: z.array(canvasMutationRevisionSchema).optional(),
|
|
5158
5587
|
version: z.number().int().min(1),
|
|
5159
5588
|
/**
|
|
@@ -5185,6 +5614,119 @@ z.discriminatedUnion("outcome", [z.object({
|
|
|
5185
5614
|
version: z.number().int().min(1),
|
|
5186
5615
|
document: canvasDocumentBlobSchema
|
|
5187
5616
|
})]);
|
|
5617
|
+
/** One answer stops taking top layers once it holds this many layers, unless it is asked for more. */
|
|
5618
|
+
const CANVAS_PART_LAYER_LIMIT = 5e3;
|
|
5619
|
+
/** The most layers a read of parts may ask one answer to hold before it stops. */
|
|
5620
|
+
const CANVAS_PART_LAYER_LIMIT_MAX = 1e5;
|
|
5621
|
+
/** The most identifiers one read of parts may name in each list. */
|
|
5622
|
+
const CANVAS_PART_NAMED_LIMIT = 2e3;
|
|
5623
|
+
z.strictObject({ canvasId: z.uuid() });
|
|
5624
|
+
/** The font files a layer inside a top layer declares, without the rest of the layer. */
|
|
5625
|
+
const canvasFontDeclarationSchema = z.object({
|
|
5626
|
+
layerId: z.string(),
|
|
5627
|
+
/** The child of the root that holds the layer. */
|
|
5628
|
+
topLayerId: z.string(),
|
|
5629
|
+
fontFaces: z.array(z.unknown())
|
|
5630
|
+
});
|
|
5631
|
+
z.object({
|
|
5632
|
+
version: z.number().int().min(1),
|
|
5633
|
+
restoreFenceVersion: z.number().int().positive().optional(),
|
|
5634
|
+
/** The root and each child of the root, pages among them, and every removed-layer id. */
|
|
5635
|
+
document: canvasDocumentBlobSchema,
|
|
5636
|
+
screens: z.array(documentScreenSchema),
|
|
5637
|
+
/** Whether the canvas holds more than `LARGE_PAGE_LAYERS` layers, every page counted. */
|
|
5638
|
+
isLarge: z.boolean(),
|
|
5639
|
+
fontDeclarations: z.array(canvasFontDeclarationSchema)
|
|
5640
|
+
});
|
|
5641
|
+
const namedIds = z.array(z.string().min(1)).max(CANVAS_PART_NAMED_LIMIT);
|
|
5642
|
+
z.strictObject({
|
|
5643
|
+
canvasId: z.uuid(),
|
|
5644
|
+
/** Children of the root, answered in this order. */
|
|
5645
|
+
topLayerIds: namedIds.optional(),
|
|
5646
|
+
/** Layers anywhere; each is answered with the whole top layer that holds it. */
|
|
5647
|
+
layerIds: namedIds.optional(),
|
|
5648
|
+
/**
|
|
5649
|
+
* The layers after which the answer takes no further top layer. An editor raises it on a very
|
|
5650
|
+
* large canvas, so the whole canvas arrives in a bounded number of answers.
|
|
5651
|
+
*/
|
|
5652
|
+
maxLayers: z.number().int().min(CANVAS_PART_LAYER_LIMIT).max(CANVAS_PART_LAYER_LIMIT_MAX).default(CANVAS_PART_LAYER_LIMIT)
|
|
5653
|
+
}).refine(({ topLayerIds = [], layerIds = [] }) => topLayerIds.length + layerIds.length > 0, "A read of parts names at least one layer.");
|
|
5654
|
+
z.object({
|
|
5655
|
+
/** The revision every layer of the answer was read at. */
|
|
5656
|
+
version: z.number().int().min(1),
|
|
5657
|
+
/** Each answered top layer's own record and every layer inside it: no root, no removed ids. */
|
|
5658
|
+
document: canvasDocumentBlobSchema,
|
|
5659
|
+
/** The top layers answered, in the order asked. */
|
|
5660
|
+
read: z.array(z.string()),
|
|
5661
|
+
/** The top layers left out because the answer was full, in the order asked. */
|
|
5662
|
+
notReached: z.array(z.string()),
|
|
5663
|
+
/** The named identifiers that are no top layer of the canvas, or are inside none. */
|
|
5664
|
+
absent: z.array(z.string())
|
|
5665
|
+
});
|
|
5666
|
+
/** Custom CSS on a text layer that styles its first letter, one declaration per property. */
|
|
5667
|
+
const CANVAS_FIRST_LETTER_PREFIX = "--canvas-first-letter-";
|
|
5668
|
+
const SIDES = [
|
|
5669
|
+
"top",
|
|
5670
|
+
"right",
|
|
5671
|
+
"bottom",
|
|
5672
|
+
"left"
|
|
5673
|
+
];
|
|
5674
|
+
/**
|
|
5675
|
+
* The properties a first letter takes (CSS Pseudo-Elements 4, `::first-letter`), each with the
|
|
5676
|
+
* value it has when a layer does not declare it: its block's for a property that inherits, the
|
|
5677
|
+
* initial value for one that does not.
|
|
5678
|
+
*/
|
|
5679
|
+
const CANVAS_FIRST_LETTER_PROPERTIES = {
|
|
5680
|
+
...Object.fromEntries([
|
|
5681
|
+
"color",
|
|
5682
|
+
"font-family",
|
|
5683
|
+
"font-size",
|
|
5684
|
+
"font-stretch",
|
|
5685
|
+
"font-style",
|
|
5686
|
+
"font-weight",
|
|
5687
|
+
"font-variant-caps",
|
|
5688
|
+
"font-variant-ligatures",
|
|
5689
|
+
"font-variant-numeric",
|
|
5690
|
+
"font-feature-settings",
|
|
5691
|
+
"font-variation-settings",
|
|
5692
|
+
"font-kerning",
|
|
5693
|
+
"letter-spacing",
|
|
5694
|
+
"line-height",
|
|
5695
|
+
"text-shadow",
|
|
5696
|
+
"text-transform",
|
|
5697
|
+
"word-spacing",
|
|
5698
|
+
"-webkit-text-fill-color",
|
|
5699
|
+
"-webkit-text-stroke-color",
|
|
5700
|
+
"-webkit-text-stroke-width"
|
|
5701
|
+
].map((property) => [property, "inherit"])),
|
|
5702
|
+
...Object.fromEntries([
|
|
5703
|
+
"float",
|
|
5704
|
+
"vertical-align",
|
|
5705
|
+
"initial-letter",
|
|
5706
|
+
"opacity",
|
|
5707
|
+
"background-color",
|
|
5708
|
+
"background-image",
|
|
5709
|
+
"box-shadow",
|
|
5710
|
+
"text-decoration-line",
|
|
5711
|
+
"text-decoration-style",
|
|
5712
|
+
"text-decoration-color",
|
|
5713
|
+
"text-decoration-thickness",
|
|
5714
|
+
...SIDES.flatMap((side) => [
|
|
5715
|
+
`margin-${side}`,
|
|
5716
|
+
`padding-${side}`,
|
|
5717
|
+
`border-${side}-style`,
|
|
5718
|
+
`border-${side}-width`,
|
|
5719
|
+
`border-${side}-color`
|
|
5720
|
+
]),
|
|
5721
|
+
...[
|
|
5722
|
+
"top-left",
|
|
5723
|
+
"top-right",
|
|
5724
|
+
"bottom-right",
|
|
5725
|
+
"bottom-left"
|
|
5726
|
+
].map((corner) => `border-${corner}-radius`)
|
|
5727
|
+
].map((property) => [property, "initial"]))
|
|
5728
|
+
};
|
|
5729
|
+
`${Object.entries(CANVAS_FIRST_LETTER_PROPERTIES).map(([property, fallback]) => `${property}:var(${CANVAS_FIRST_LETTER_PREFIX}${property},${fallback})`).join(";")}`;
|
|
5188
5730
|
const textLinkSchema = z.object({
|
|
5189
5731
|
start: z.number().int().nonnegative(),
|
|
5190
5732
|
end: z.number().int().positive(),
|
|
@@ -5215,13 +5757,28 @@ const canvasPropertySectionSchema = z.enum([
|
|
|
5215
5757
|
"export",
|
|
5216
5758
|
"source"
|
|
5217
5759
|
]);
|
|
5760
|
+
const MAX_RENDER_MESSAGE_LENGTH = 500;
|
|
5761
|
+
const MAX_RENDER_KIND_LENGTH = 100;
|
|
5762
|
+
/**
|
|
5763
|
+
* What a layer's box is: `placed` where the canvas draws the layer, `placed-before-transform` where
|
|
5764
|
+
* it draws the layer before the layer's own transform, `recorded` a size kept from when the layer
|
|
5765
|
+
* was made, for a layer the browser lays out.
|
|
5766
|
+
*/
|
|
5767
|
+
const canvasBoxSourceSchema = z.enum([
|
|
5768
|
+
"placed",
|
|
5769
|
+
"placed-before-transform",
|
|
5770
|
+
"recorded"
|
|
5771
|
+
]);
|
|
5772
|
+
/** Present only on a read that holds a `recorded` box. */
|
|
5773
|
+
const boxNoteSchema = z.string().min(1).optional();
|
|
5218
5774
|
const canvasInspectNodeSummarySchema = z.object({
|
|
5219
5775
|
id: z.string().min(1),
|
|
5220
|
-
label: z.string().max(
|
|
5221
|
-
kind: z.string().min(1).max(
|
|
5776
|
+
label: z.string().max(MAX_RENDER_MESSAGE_LENGTH),
|
|
5777
|
+
kind: z.string().min(1).max(MAX_RENDER_KIND_LENGTH),
|
|
5222
5778
|
parentId: z.string().min(1).nullable(),
|
|
5223
5779
|
childCount: z.number().int().min(0),
|
|
5224
5780
|
box: canvasSceneBoxSchema.nullable(),
|
|
5781
|
+
boxSource: canvasBoxSourceSchema.optional(),
|
|
5225
5782
|
propertySections: z.array(canvasPropertySectionSchema)
|
|
5226
5783
|
});
|
|
5227
5784
|
z.object({ canvasId: z.uuid() });
|
|
@@ -5234,13 +5791,15 @@ z.object({
|
|
|
5234
5791
|
rootChildCount: z.number().int().min(0),
|
|
5235
5792
|
bounds: canvasSceneBoxSchema.nullable(),
|
|
5236
5793
|
kinds: z.record(z.string(), z.number().int().min(0)),
|
|
5794
|
+
boxNote: boxNoteSchema,
|
|
5237
5795
|
next: z.array(z.string().min(1))
|
|
5238
5796
|
});
|
|
5239
5797
|
z.object({ canvasId: z.uuid() });
|
|
5240
5798
|
z.object({
|
|
5241
5799
|
canvasId: z.uuid(),
|
|
5242
5800
|
version: z.number().int().positive(),
|
|
5243
|
-
nodes: z.array(canvasInspectNodeSummarySchema)
|
|
5801
|
+
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
5802
|
+
boxNote: boxNoteSchema
|
|
5244
5803
|
});
|
|
5245
5804
|
z.object({
|
|
5246
5805
|
canvasId: z.uuid(),
|
|
@@ -5259,14 +5818,54 @@ z.object({
|
|
|
5259
5818
|
props: z.record(z.string(), z.unknown()),
|
|
5260
5819
|
children: z.array(z.string().min(1))
|
|
5261
5820
|
}),
|
|
5821
|
+
boxNote: boxNoteSchema,
|
|
5262
5822
|
next: z.array(z.string().min(1))
|
|
5263
5823
|
});
|
|
5824
|
+
/**
|
|
5825
|
+
* What each operation writes. `names` sets one plain value, places, removes, or merges a patch, so
|
|
5826
|
+
* values its client never knew stay as stored. `whole` brings a whole layer or replaces a whole
|
|
5827
|
+
* group of values, which a client that read the canvas in an older format may have stripped.
|
|
5828
|
+
*/
|
|
5829
|
+
const CANVAS_OPERATION_WRITES = {
|
|
5830
|
+
insertConvertedSubtree: "whole",
|
|
5831
|
+
insertNode: "whole",
|
|
5832
|
+
insertText: "names",
|
|
5833
|
+
insertPrototype: "names",
|
|
5834
|
+
setPrototypeDeployment: "names",
|
|
5835
|
+
editText: "names",
|
|
5836
|
+
setText: "names",
|
|
5837
|
+
setBox: "names",
|
|
5838
|
+
setLabel: "names",
|
|
5839
|
+
setContainerKind: "names",
|
|
5840
|
+
setVisibility: "names",
|
|
5841
|
+
setLocked: "names",
|
|
5842
|
+
setConstraints: "names",
|
|
5843
|
+
setStyles: "names",
|
|
5844
|
+
patchExportSettings: "names",
|
|
5845
|
+
setAppearance: "names",
|
|
5846
|
+
setLayout: "whole",
|
|
5847
|
+
patchTypography: "names",
|
|
5848
|
+
setTypography: "whole",
|
|
5849
|
+
patchAdditionalStyles: "names",
|
|
5850
|
+
setAdditionalStyles: "whole",
|
|
5851
|
+
setArtworkColor: "whole",
|
|
5852
|
+
setTextStyleLibrary: "whole",
|
|
5853
|
+
patchFontLibrary: "names",
|
|
5854
|
+
setTextStyle: "whole",
|
|
5855
|
+
setGeometry: "whole",
|
|
5856
|
+
setProps: "whole",
|
|
5857
|
+
setParentage: "names",
|
|
5858
|
+
move: "names",
|
|
5859
|
+
remove: "names"
|
|
5860
|
+
};
|
|
5264
5861
|
const nodeIdSchema$2 = canvasSceneNodeSchema.shape.id;
|
|
5265
5862
|
const writableBoxSchema = canvasSceneBoxSchema.extend({
|
|
5266
5863
|
width: z.number().positive(),
|
|
5267
5864
|
height: z.number().positive()
|
|
5268
5865
|
});
|
|
5269
5866
|
const copiedNodeIdsSchema = z.record(nodeIdSchema$2, nodeIdSchema$2);
|
|
5867
|
+
/** A receipt stored before boxes said what they are holds none, so the source stays optional. */
|
|
5868
|
+
const canvasReceiptBoxSchema = canvasSceneBoxSchema.extend({ boxSource: canvasBoxSourceSchema.optional() });
|
|
5270
5869
|
const canvasMutationRequestContextSchema = z.strictObject({
|
|
5271
5870
|
fingerprint: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
5272
5871
|
revisionPolicy: z.enum(["strict", "rebase"]),
|
|
@@ -5280,6 +5879,8 @@ z.object({
|
|
|
5280
5879
|
operations: z.array(canvasOperationSchema).min(1),
|
|
5281
5880
|
requestContext: canvasMutationRequestContextSchema.optional(),
|
|
5282
5881
|
writeScope: canvasWriteScopeSchema.optional()
|
|
5882
|
+
}).superRefine((input, context) => {
|
|
5883
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, input.operations.every((operation) => CANVAS_OPERATION_WRITES[operation.op] === "names") ? "names" : "whole", context);
|
|
5283
5884
|
});
|
|
5284
5885
|
const applyCanvasOperationsOutputSchema = z.object({
|
|
5285
5886
|
canvasId: z.uuid(),
|
|
@@ -5290,7 +5891,7 @@ const applyCanvasOperationsOutputSchema = z.object({
|
|
|
5290
5891
|
insertedNodeIds: z.array(nodeIdSchema$2),
|
|
5291
5892
|
changedNodeIds: z.array(nodeIdSchema$2),
|
|
5292
5893
|
removedNodeIds: z.array(nodeIdSchema$2),
|
|
5293
|
-
boxes: z.record(nodeIdSchema$2,
|
|
5894
|
+
boxes: z.record(nodeIdSchema$2, canvasReceiptBoxSchema),
|
|
5294
5895
|
affectedBounds: writableBoxSchema.nullable(),
|
|
5295
5896
|
copiedNodeIds: copiedNodeIdsSchema.optional(),
|
|
5296
5897
|
next: z.array(z.string().min(1))
|
|
@@ -5302,7 +5903,8 @@ z.strictObject({
|
|
|
5302
5903
|
});
|
|
5303
5904
|
z.discriminatedUnion("state", [z.strictObject({ state: z.literal("not-found") }), z.strictObject({
|
|
5304
5905
|
state: z.literal("committed"),
|
|
5305
|
-
|
|
5906
|
+
/** `url` is the canvas's web address. An API older than the field answers without it. */
|
|
5907
|
+
result: applyCanvasOperationsOutputSchema.extend({ url: z.url().optional() })
|
|
5306
5908
|
})]);
|
|
5307
5909
|
const LIMITS = {
|
|
5308
5910
|
nodes: 1e3,
|
|
@@ -5699,8 +6301,10 @@ const canvasPreparationRequestSchema = z.discriminatedUnion("kind", [
|
|
|
5699
6301
|
sources: z.array(z.strictObject({
|
|
5700
6302
|
screenId: z.uuid(),
|
|
5701
6303
|
captureId: z.uuid(),
|
|
5702
|
-
|
|
5703
|
-
|
|
6304
|
+
/** What the frame is called. Absent, the frame takes the stored page's own title. */
|
|
6305
|
+
label: z.string().min(1).optional()
|
|
6306
|
+
})).min(1),
|
|
6307
|
+
landing: z.literal("editable-frame").optional().describe("Lands the page as an ordinary editable frame. Without it, the layers belong to a capture run.")
|
|
5704
6308
|
}),
|
|
5705
6309
|
canvasArrangePreparationSchema,
|
|
5706
6310
|
canvasDuplicatePreparationSchema,
|
|
@@ -5781,7 +6385,11 @@ const canvasPreparationJobSchema = z.discriminatedUnion("state", [
|
|
|
5781
6385
|
job.extend({
|
|
5782
6386
|
state: z.literal("succeeded"),
|
|
5783
6387
|
phase: z.literal("complete"),
|
|
5784
|
-
result: canvasPreparationPlanSchema.extend({
|
|
6388
|
+
result: canvasPreparationPlanSchema.extend({
|
|
6389
|
+
loadedVersion: z.number().int().positive(),
|
|
6390
|
+
/** Where a screen compile fell back, such as a font it replaced; absent when it had none. */
|
|
6391
|
+
warnings: z.array(canvasRenderWarningSchema).optional()
|
|
6392
|
+
}),
|
|
5785
6393
|
failure: z.null()
|
|
5786
6394
|
}),
|
|
5787
6395
|
job.extend({
|
|
@@ -6166,7 +6774,8 @@ z.discriminatedUnion("purpose", [
|
|
|
6166
6774
|
"inspection",
|
|
6167
6775
|
"snapshot",
|
|
6168
6776
|
"thumbnail",
|
|
6169
|
-
"export"
|
|
6777
|
+
"export",
|
|
6778
|
+
"object-pictures"
|
|
6170
6779
|
]),
|
|
6171
6780
|
scale: z.number().positive(),
|
|
6172
6781
|
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
@@ -6235,6 +6844,16 @@ z.discriminatedUnion("purpose", [
|
|
|
6235
6844
|
sourceState: z.undefined().optional(),
|
|
6236
6845
|
conversion: canvasConversionRequestSchema,
|
|
6237
6846
|
scale: z.literal(1)
|
|
6847
|
+
}),
|
|
6848
|
+
claimRenderWorkBaseSchema.extend({
|
|
6849
|
+
purpose: z.literal("object-pictures"),
|
|
6850
|
+
target: canvasRenderTargetSchema,
|
|
6851
|
+
sourceState: z.undefined().optional(),
|
|
6852
|
+
scale: z.number().positive(),
|
|
6853
|
+
maxOutputPixels: canvasRenderPixelLimitSchema.optional(),
|
|
6854
|
+
/** The top layers to draw, in order; each picture is stored under the prefix. */
|
|
6855
|
+
objects: z.array(objectPictureWorkObjectSchema).max(20),
|
|
6856
|
+
outputPrefix: z.string().min(1).max(MAX_STORAGE_KEY_LENGTH)
|
|
6238
6857
|
})
|
|
6239
6858
|
]);
|
|
6240
6859
|
z.object({
|
|
@@ -6379,12 +6998,24 @@ z.object({
|
|
|
6379
6998
|
nodes: z.array(canvasInspectNodeSummarySchema),
|
|
6380
6999
|
contextRootId: nodeIdSchema.nullable(),
|
|
6381
7000
|
visibleWorldBox: canvasWorldBoundsSchema.nullable(),
|
|
7001
|
+
boxNote: z.string().min(1).optional(),
|
|
6382
7002
|
next: z.array(z.string().min(1)).max(MAX_SELECTION_COMMANDS)
|
|
6383
7003
|
});
|
|
6384
7004
|
const canvasCaptureProvenanceSchema = z.discriminatedUnion("kind", [z.object({
|
|
6385
7005
|
kind: z.literal("recording"),
|
|
6386
7006
|
recordingId: z.string()
|
|
6387
7007
|
})]);
|
|
7008
|
+
/**
|
|
7009
|
+
* The mark on a captured page's picture while it becomes editable. Every capture lands as this
|
|
7010
|
+
* picture first; whoever converts it replaces the same layer with the editable frame, through the
|
|
7011
|
+
* one swap (`insertConvertedSubtree` with destination `replace` and `onlyPicture`). A conversion
|
|
7012
|
+
* that fails writes `failed` with a short reason, so every viewer sees the failure rather than a
|
|
7013
|
+
* spinner that never ends; Try again writes `converting` again.
|
|
7014
|
+
*/
|
|
7015
|
+
const captureLandingSchema = z.discriminatedUnion("state", [z.object({ state: z.literal("converting") }), z.object({
|
|
7016
|
+
state: z.literal("failed"),
|
|
7017
|
+
reason: z.string().min(1).max(200)
|
|
7018
|
+
})]);
|
|
6388
7019
|
z.object({
|
|
6389
7020
|
html: z.string().optional(),
|
|
6390
7021
|
viewport: z.object({
|
|
@@ -6394,7 +7025,8 @@ z.object({
|
|
|
6394
7025
|
atMs: z.number(),
|
|
6395
7026
|
screenId: z.string().nullable().default(null),
|
|
6396
7027
|
sourceNodeId: z.string().optional(),
|
|
6397
|
-
provenance: canvasCaptureProvenanceSchema.optional()
|
|
7028
|
+
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
7029
|
+
landing: captureLandingSchema.optional()
|
|
6398
7030
|
});
|
|
6399
7031
|
z.object({
|
|
6400
7032
|
provenance: canvasCaptureProvenanceSchema.optional(),
|
|
@@ -6518,12 +7150,16 @@ z.object({
|
|
|
6518
7150
|
versionId: z.uuid()
|
|
6519
7151
|
});
|
|
6520
7152
|
z.object({ entry: canvasVersionEntrySchema });
|
|
7153
|
+
/** A restore or a duplicate copies a version the API holds, so it only names what to change. */
|
|
7154
|
+
const refuseUnsafeVersionCopy = (input, context) => {
|
|
7155
|
+
refuseUnsafeWriterFormat(input.documentFormatVersion, "names", context);
|
|
7156
|
+
};
|
|
6521
7157
|
z.object({
|
|
6522
7158
|
canvasId: z.uuid(),
|
|
6523
7159
|
documentFormatVersion: canvasDocumentFormatSchema,
|
|
6524
7160
|
versionId: z.uuid(),
|
|
6525
7161
|
expectedVersion: z.number().int().positive()
|
|
6526
|
-
});
|
|
7162
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
6527
7163
|
z.object({
|
|
6528
7164
|
canvasId: z.uuid(),
|
|
6529
7165
|
version: z.number().int().positive(),
|
|
@@ -6537,7 +7173,7 @@ z.object({
|
|
|
6537
7173
|
versionId: z.uuid(),
|
|
6538
7174
|
organisationId: z.union([z.uuid(), z.literal("personal")]),
|
|
6539
7175
|
title: z.string().trim().min(1).optional()
|
|
6540
|
-
});
|
|
7176
|
+
}).superRefine(refuseUnsafeVersionCopy);
|
|
6541
7177
|
z.object({
|
|
6542
7178
|
canvasId: z.uuid(),
|
|
6543
7179
|
title: z.string().min(1),
|
|
@@ -6720,6 +7356,16 @@ const setReviewStateInputSchema = z.object({
|
|
|
6720
7356
|
])
|
|
6721
7357
|
});
|
|
6722
7358
|
z.object({ reviewState: setReviewStateInputSchema.shape.reviewState.nullable() });
|
|
7359
|
+
z.object({ canvasId: z.uuid() });
|
|
7360
|
+
z.object({
|
|
7361
|
+
/** The only credential a page receives: it stores captures and does nothing else. */
|
|
7362
|
+
pass: z.string().min(1),
|
|
7363
|
+
expiresAt: z.iso.datetime(),
|
|
7364
|
+
/** Where the capture script is published, for the snippet to load. */
|
|
7365
|
+
scriptUrl: z.url(),
|
|
7366
|
+
/** Where the page stores its capture: the API as the page reaches it. */
|
|
7367
|
+
apiUrl: z.url()
|
|
7368
|
+
});
|
|
6723
7369
|
/** How many replies a thread hands back in one go before `hasMoreMessages` takes over. */
|
|
6724
7370
|
const MAX_MESSAGES_PER_THREAD = 50;
|
|
6725
7371
|
const MAX_MESSAGES_PER_PAGE = 100;
|
|
@@ -8001,6 +8647,12 @@ z.object({
|
|
|
8001
8647
|
version: z.number().int().positive()
|
|
8002
8648
|
})]).optional()
|
|
8003
8649
|
});
|
|
8650
|
+
z.object({ bytes: z.number().int().positive().max(Number.MAX_SAFE_INTEGER) });
|
|
8651
|
+
z.object({
|
|
8652
|
+
id: z.uuid(),
|
|
8653
|
+
upload: signedUploadSchema
|
|
8654
|
+
});
|
|
8655
|
+
z.object({ id: z.uuid() });
|
|
8004
8656
|
const MAX_PROTOTYPE_CONTENT_TYPE_LENGTH = 200;
|
|
8005
8657
|
const prototypePathSchema = z.string().min(1).refine((value) => !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && !value.includes("\0") && value.split("/").every((part) => part !== "" && part !== "." && part !== ".."), { message: "prototype paths must be portable relative file paths" });
|
|
8006
8658
|
const prototypeFileSchema = z.object({
|
|
@@ -8391,6 +9043,22 @@ const HASH_SEEDS = [
|
|
|
8391
9043
|
FNV_OFFSET_BASIS ^ MURMUR_HASH_2,
|
|
8392
9044
|
FNV_OFFSET_BASIS ^ MURMUR_HASH_3
|
|
8393
9045
|
];
|
|
9046
|
+
const CROSS_LINE = "transparent calc(50% - 2px), rgba(255, 255, 255, 0.85) calc(50% - 1px), #a8a8b0 50%, rgba(255, 255, 255, 0.85) calc(50% + 1px), transparent calc(50% + 2px)";
|
|
9047
|
+
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
9048
|
+
align-items: center !important;
|
|
9049
|
+
background-color: transparent !important;
|
|
9050
|
+
background-image: ${`linear-gradient(to top right, ${CROSS_LINE}), linear-gradient(to bottom right, ${CROSS_LINE})`} !important;
|
|
9051
|
+
border: 1px solid #c7c7cc !important;
|
|
9052
|
+
box-sizing: border-box !important;
|
|
9053
|
+
color: #4f4f55 !important;
|
|
9054
|
+
display: flex !important;
|
|
9055
|
+
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
9056
|
+
justify-content: center !important;
|
|
9057
|
+
overflow: hidden !important;
|
|
9058
|
+
text-align: center !important;
|
|
9059
|
+
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
9060
|
+
display: none !important;
|
|
9061
|
+
}`].join("\n");
|
|
8394
9062
|
const viewportSchema = z.object({
|
|
8395
9063
|
width: z.number().int().positive(),
|
|
8396
9064
|
height: z.number().int().positive()
|
|
@@ -8655,21 +9323,6 @@ z.object({
|
|
|
8655
9323
|
/** Screens survive with their provenance nulled. That is what makes iteration safe. */
|
|
8656
9324
|
detachedScreenCount: z.number().int().min(0)
|
|
8657
9325
|
});
|
|
8658
|
-
[`[data-enhance-unsupported]:not([data-enhance-unsupported-hidden]):not([style*="display: none"]) {
|
|
8659
|
-
align-items: center !important;
|
|
8660
|
-
background-color: #f7f7f8 !important;
|
|
8661
|
-
background-image: linear-gradient(to top right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)), linear-gradient(to bottom right, transparent calc(50% - 1px), #a8a8b0 50%, transparent calc(50% + 1px)) !important;
|
|
8662
|
-
border: 1px solid #c7c7cc !important;
|
|
8663
|
-
box-sizing: border-box !important;
|
|
8664
|
-
color: #4f4f55 !important;
|
|
8665
|
-
display: flex !important;
|
|
8666
|
-
font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif !important;
|
|
8667
|
-
justify-content: center !important;
|
|
8668
|
-
overflow: hidden !important;
|
|
8669
|
-
text-align: center !important;
|
|
8670
|
-
}`, `[data-enhance-unsupported-hidden], [data-enhance-unsupported][style*="display: none"] {
|
|
8671
|
-
display: none !important;
|
|
8672
|
-
}`].join("\n");
|
|
8673
9326
|
z.object({
|
|
8674
9327
|
/**
|
|
8675
9328
|
* Client-minted, once per capture attempt. A retry is the same screen; a re-capture at the
|
|
@@ -8766,6 +9419,21 @@ const MAX_DURATION_MS$1 = 18e5;
|
|
|
8766
9419
|
const MAX_COUNT$1 = 1e6;
|
|
8767
9420
|
const MAX_BYTES = 1073741824;
|
|
8768
9421
|
const MAX_PROTOTYPE_OPEN_ATTEMPTS = 16;
|
|
9422
|
+
const MAX_SCRIPT_POSITION = 1e8;
|
|
9423
|
+
/** What the person was doing when a long frame ended; `idle` is nothing at all. */
|
|
9424
|
+
const longFrameActionSchema = z.enum([
|
|
9425
|
+
"pan",
|
|
9426
|
+
"zoom",
|
|
9427
|
+
"drag",
|
|
9428
|
+
"typing",
|
|
9429
|
+
"paste",
|
|
9430
|
+
"undo",
|
|
9431
|
+
"redo",
|
|
9432
|
+
"edit",
|
|
9433
|
+
"opening",
|
|
9434
|
+
"loading",
|
|
9435
|
+
"idle"
|
|
9436
|
+
]);
|
|
8769
9437
|
/** How the read of a canvas's unsaved browser copy ended when the canvas opened. */
|
|
8770
9438
|
const browserCopyCheckSchema = z.enum([
|
|
8771
9439
|
"answered",
|
|
@@ -8780,6 +9448,12 @@ const base$1 = {
|
|
|
8780
9448
|
releaseIdentity: z.string().min(1).max(100),
|
|
8781
9449
|
capabilityVersion: z.number().int().min(1).max(MAX_CAPABILITY_VERSION$1)
|
|
8782
9450
|
};
|
|
9451
|
+
const scriptSourceSchema = z.enum([
|
|
9452
|
+
"app",
|
|
9453
|
+
"extension",
|
|
9454
|
+
"third-party",
|
|
9455
|
+
"unknown"
|
|
9456
|
+
]);
|
|
8783
9457
|
const mainThreadWork = {
|
|
8784
9458
|
longTaskCount: countSchema,
|
|
8785
9459
|
longTaskTotalMs: durationSchema$1,
|
|
@@ -8789,12 +9463,7 @@ const mainThreadWork = {
|
|
|
8789
9463
|
loafLongestBlockingMs: durationSchema$1,
|
|
8790
9464
|
loafStyleAndLayoutMs: durationSchema$1,
|
|
8791
9465
|
loafTopScriptMs: durationSchema$1,
|
|
8792
|
-
loafTopScriptSource:
|
|
8793
|
-
"app",
|
|
8794
|
-
"extension",
|
|
8795
|
-
"third-party",
|
|
8796
|
-
"unknown"
|
|
8797
|
-
])
|
|
9466
|
+
loafTopScriptSource: scriptSourceSchema
|
|
8798
9467
|
};
|
|
8799
9468
|
z.discriminatedUnion("name", [
|
|
8800
9469
|
z.object({
|
|
@@ -8855,10 +9524,42 @@ z.discriminatedUnion("name", [
|
|
|
8855
9524
|
durationMs: durationSchema$1,
|
|
8856
9525
|
frameCount: countSchema,
|
|
8857
9526
|
slowFrameCount: countSchema,
|
|
9527
|
+
over16FrameCount: countSchema.optional(),
|
|
9528
|
+
over33FrameCount: countSchema.optional(),
|
|
8858
9529
|
worstFrameMs: durationSchema$1,
|
|
8859
9530
|
nodeCount: countSchema,
|
|
8860
9531
|
replayCount: countSchema
|
|
8861
9532
|
}),
|
|
9533
|
+
z.object({
|
|
9534
|
+
...base$1,
|
|
9535
|
+
name: z.literal("canvas_long_frame"),
|
|
9536
|
+
source: z.enum(["long-animation-frame", "longtask"]),
|
|
9537
|
+
action: longFrameActionSchema,
|
|
9538
|
+
durationMs: durationSchema$1,
|
|
9539
|
+
blockingMs: durationSchema$1,
|
|
9540
|
+
styleAndLayoutMs: durationSchema$1,
|
|
9541
|
+
topScriptMs: durationSchema$1,
|
|
9542
|
+
topScriptSource: scriptSourceSchema,
|
|
9543
|
+
topScriptInvoker: z.enum([
|
|
9544
|
+
"event-listener",
|
|
9545
|
+
"user-callback",
|
|
9546
|
+
"resolve-promise",
|
|
9547
|
+
"reject-promise",
|
|
9548
|
+
"classic-script",
|
|
9549
|
+
"module-script",
|
|
9550
|
+
"none"
|
|
9551
|
+
]),
|
|
9552
|
+
topScriptEvent: z.string().regex(/^[a-z]{1,32}$/u).optional(),
|
|
9553
|
+
topScriptFile: z.string().regex(/^[\w-][\w.-]{0,124}\.js$/u).optional(),
|
|
9554
|
+
topScriptFunction: z.string().regex(/^[\w$.]{1,80}$/u).optional(),
|
|
9555
|
+
topScriptPosition: z.number().int().min(0).max(MAX_SCRIPT_POSITION).optional(),
|
|
9556
|
+
layerCount: countSchema,
|
|
9557
|
+
topLayerCount: countSchema,
|
|
9558
|
+
builtLayerCount: countSchema,
|
|
9559
|
+
zoomPercent: countSchema,
|
|
9560
|
+
frameNumber: countSchema,
|
|
9561
|
+
skippedCount: countSchema
|
|
9562
|
+
}),
|
|
8862
9563
|
z.object({
|
|
8863
9564
|
...base$1,
|
|
8864
9565
|
name: z.literal("canvas_measurement"),
|
|
@@ -8976,6 +9677,7 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
8976
9677
|
"clipboard-unavailable",
|
|
8977
9678
|
"clipboard-image-pending",
|
|
8978
9679
|
"clipboard-image-unavailable",
|
|
9680
|
+
"paste-content-refused",
|
|
8979
9681
|
"edit-target-unsupported",
|
|
8980
9682
|
"edit-result-invalid",
|
|
8981
9683
|
"react-hook-order",
|
|
@@ -9013,6 +9715,7 @@ const clientRenderFailureDetailsSchema = z.strictObject({
|
|
|
9013
9715
|
subsystem: z.enum([
|
|
9014
9716
|
"menu",
|
|
9015
9717
|
"menu-picture",
|
|
9718
|
+
"arrival-cue",
|
|
9016
9719
|
"unknown"
|
|
9017
9720
|
]).optional(),
|
|
9018
9721
|
repeats: count$1.optional(),
|
|
@@ -9083,7 +9786,18 @@ const CANVAS_SYNC_REPORTS = [
|
|
|
9083
9786
|
"whole-value-text",
|
|
9084
9787
|
"retrying",
|
|
9085
9788
|
"recovery",
|
|
9086
|
-
"trace"
|
|
9789
|
+
"trace",
|
|
9790
|
+
"update-required"
|
|
9791
|
+
];
|
|
9792
|
+
/** How a failed document read was answered, on the report of one worth a look. */
|
|
9793
|
+
const CANVAS_SYNC_READ_OUTCOMES = [
|
|
9794
|
+
"transient",
|
|
9795
|
+
"no-edit-access",
|
|
9796
|
+
"restored",
|
|
9797
|
+
"replan",
|
|
9798
|
+
"refused",
|
|
9799
|
+
"update-required",
|
|
9800
|
+
"fault"
|
|
9087
9801
|
];
|
|
9088
9802
|
const CANVAS_SYNC_DETAILS = [
|
|
9089
9803
|
...CLIENT_SAVE_ISSUES,
|
|
@@ -9120,7 +9834,8 @@ const CANVAS_SYNC_REPORT_STATUSES = [
|
|
|
9120
9834
|
"view-only",
|
|
9121
9835
|
"sign-in",
|
|
9122
9836
|
"gone",
|
|
9123
|
-
"restored"
|
|
9837
|
+
"restored",
|
|
9838
|
+
"update-required"
|
|
9124
9839
|
];
|
|
9125
9840
|
/** Whether a recovery state began in this visit or was reopened from the browser copy. */
|
|
9126
9841
|
const CANVAS_SYNC_EPISODES = ["new", "reopened"];
|
|
@@ -9162,6 +9877,7 @@ const CANVAS_SAVE_NOTICE_CAUSES = [
|
|
|
9162
9877
|
"refused",
|
|
9163
9878
|
"copy-refused",
|
|
9164
9879
|
"copy-preview",
|
|
9880
|
+
"update-required",
|
|
9165
9881
|
"unknown"
|
|
9166
9882
|
];
|
|
9167
9883
|
const CANVAS_SAVE_SEVERITIES = [
|
|
@@ -9185,7 +9901,8 @@ const CANVAS_SAVE_ACTIONS = [
|
|
|
9185
9901
|
"retry-upload",
|
|
9186
9902
|
"choose-file",
|
|
9187
9903
|
"remove-screen",
|
|
9188
|
-
"go-to-canvases"
|
|
9904
|
+
"go-to-canvases",
|
|
9905
|
+
"reload"
|
|
9189
9906
|
];
|
|
9190
9907
|
const CANVAS_SAVE_OUTCOMES = [
|
|
9191
9908
|
"saved",
|
|
@@ -9279,6 +9996,7 @@ z.strictObject({
|
|
|
9279
9996
|
durationMs: z.number().int().nonnegative(),
|
|
9280
9997
|
pendingChanges: z.number().int().nonnegative(),
|
|
9281
9998
|
reason: z.enum(CANVAS_SYNC_DETAILS).optional(),
|
|
9999
|
+
readOutcome: z.enum(CANVAS_SYNC_READ_OUTCOMES).optional(),
|
|
9282
10000
|
status: z.enum(CANVAS_SYNC_REPORT_STATUSES).optional(),
|
|
9283
10001
|
episode: z.enum(CANVAS_SYNC_EPISODES).optional(),
|
|
9284
10002
|
trace: canvasSaveTraceSchema.optional()
|
|
@@ -9495,8 +10213,8 @@ z.discriminatedUnion("name", [
|
|
|
9495
10213
|
z.object({ accepted: z.literal(true) });
|
|
9496
10214
|
const listed = (allowed, value) => typeof value === "string" && allowed.includes(value) ? value : null;
|
|
9497
10215
|
const refusalOf = (error) => {
|
|
9498
|
-
const { refusalCode, operation, component } = error.fields ?? {};
|
|
9499
|
-
if (refusalCode === void 0 && operation === void 0 && component === void 0) return void 0;
|
|
10216
|
+
const { refusalCode, operation, component, operationIndex } = error.fields ?? {};
|
|
10217
|
+
if (refusalCode === void 0 && operation === void 0 && component === void 0 && operationIndex === void 0) return void 0;
|
|
9500
10218
|
const code = CANVAS_SAVE_REFUSAL_CODES.find((value) => value === refusalCode);
|
|
9501
10219
|
return {
|
|
9502
10220
|
refusalCode: refusalCode === void 0 ? "unclassified" : code ?? "unknown",
|
|
@@ -9508,6 +10226,15 @@ const refusalOf = (error) => {
|
|
|
9508
10226
|
const MUTATION_ID_REUSED = "mutation-id-reused";
|
|
9509
10227
|
/** `fields.reason` on a 413, whether the server's envelope or a proxy's bare status says so. */
|
|
9510
10228
|
const REQUEST_TOO_LARGE = "request-too-large";
|
|
10229
|
+
const tooLarge = {
|
|
10230
|
+
kind: "refused",
|
|
10231
|
+
reason: REQUEST_TOO_LARGE,
|
|
10232
|
+
refusal: {
|
|
10233
|
+
refusalCode: REQUEST_TOO_LARGE,
|
|
10234
|
+
operation: "unknown",
|
|
10235
|
+
component: "unknown"
|
|
10236
|
+
}
|
|
10237
|
+
};
|
|
9511
10238
|
const HTTP_UNAUTHORIZED = 401;
|
|
9512
10239
|
const HTTP_FORBIDDEN$1 = 403;
|
|
9513
10240
|
const HTTP_NOT_FOUND = 404;
|
|
@@ -9542,17 +10269,15 @@ const conflictOutcome = (error) => {
|
|
|
9542
10269
|
reason: error.message
|
|
9543
10270
|
};
|
|
9544
10271
|
};
|
|
9545
|
-
/** The server names the
|
|
10272
|
+
/** The server names the refusals a client must tell apart; any other is the message. */
|
|
9546
10273
|
const badRequestOutcome = (error) => {
|
|
9547
10274
|
const reason = error.fields?.["reason"];
|
|
9548
10275
|
if (reason === "mutation-id-reused") return {
|
|
9549
10276
|
kind: "fault",
|
|
9550
10277
|
detail: MUTATION_ID_REUSED
|
|
9551
10278
|
};
|
|
9552
|
-
if (reason === "request-too-large") return
|
|
9553
|
-
|
|
9554
|
-
reason: REQUEST_TOO_LARGE
|
|
9555
|
-
};
|
|
10279
|
+
if (reason === "request-too-large") return tooLarge;
|
|
10280
|
+
if (error.fields?.["documentFormatVersion"] === "This change needs a newer version of Enhance. Refresh the editor, or update the Enhance plugin or command-line tool, then try again.") return { kind: "update-required" };
|
|
9556
10281
|
const refusal = refusalOf(error);
|
|
9557
10282
|
return {
|
|
9558
10283
|
kind: "refused",
|
|
@@ -9584,10 +10309,7 @@ const statusOutcome = (status, retryAfterMs) => {
|
|
|
9584
10309
|
};
|
|
9585
10310
|
if (status === HTTP_FORBIDDEN$1) return { kind: "no-edit-access" };
|
|
9586
10311
|
if (status === HTTP_NOT_FOUND) return { kind: "gone" };
|
|
9587
|
-
if (status === HTTP_TOO_LARGE) return
|
|
9588
|
-
kind: "refused",
|
|
9589
|
-
reason: REQUEST_TOO_LARGE
|
|
9590
|
-
};
|
|
10312
|
+
if (status === HTTP_TOO_LARGE) return tooLarge;
|
|
9591
10313
|
if (status === HTTP_TIMEOUT || status === HTTP_TOO_MANY_REQUESTS || status === HTTP_CLIENT_CLOSED || status >= HTTP_SERVER_ERROR) return {
|
|
9592
10314
|
kind: "transient",
|
|
9593
10315
|
retryAfterMs
|
|
@@ -9794,7 +10516,7 @@ const startStallWatch = (caller, idleMs = STALL_MS) => {
|
|
|
9794
10516
|
};
|
|
9795
10517
|
|
|
9796
10518
|
//#endregion
|
|
9797
|
-
//#region ../../packages/sdk/dist/capture-client.client-
|
|
10519
|
+
//#region ../../packages/sdk/dist/capture-client.client-GeV8SAsY.mjs
|
|
9798
10520
|
const line = (text) => `Enhance: ${text}\n`;
|
|
9799
10521
|
/** A left-out capture by its journey and step, or by its test when it could not be read at all. */
|
|
9800
10522
|
const leftOutName = (leftOut, attempts) => {
|
|
@@ -10306,7 +11028,7 @@ const createEnhance = (options) => {
|
|
|
10306
11028
|
//#region src/infrastructure/captures.program.ts
|
|
10307
11029
|
const publicationError = (error, manifest) => {
|
|
10308
11030
|
const code = error instanceof Error ? Reflect.get(error, "code") : void 0;
|
|
10309
|
-
return new CliError(code === "authorization" ? "UNAUTHORIZED" : code === "conflict" ? "CONFLICT" : ["configuration", "artifact"].includes(String(code)) ? "BAD_REQUEST" : "INTERNAL", error instanceof Error ? error.message : "Capture publication was not confirmed.", `Retry enhance captures publish with the same manifest: ${manifest}`);
|
|
11031
|
+
return new CliError(code === "authorization" ? "UNAUTHORIZED" : code === "conflict" ? "CONFLICT" : ["configuration", "artifact"].includes(String(code)) ? "BAD_REQUEST" : "INTERNAL", error instanceof Error ? error.message : "Capture publication was not confirmed.", code === "artifact" ? "The manifest or a capture file beside it cannot be published as it is. Correct what the message names, or capture again and publish the new manifest." : `Retry enhance captures publish with the same manifest: ${manifest}`);
|
|
10310
11032
|
};
|
|
10311
11033
|
const registerCapturesProgram = (program, dependencies) => {
|
|
10312
11034
|
program.command("captures").description("Publish SDK captures as editable canvas journeys.").command("publish <manifest>").description("Publish or resume a reserved capture manifest and print its durable receipt.").action(async (manifest) => {
|
|
@@ -10328,8 +11050,6 @@ const registerCapturesProgram = (program, dependencies) => {
|
|
|
10328
11050
|
//#region src/infrastructure/command-summaries.consts.ts
|
|
10329
11051
|
const COMMAND_SUMMARIES = {
|
|
10330
11052
|
"captureRun.review": "Read product review for a run canvas.",
|
|
10331
|
-
"canvas chats": "Chat history.",
|
|
10332
|
-
"canvas.createEditableFrame": "Make a screen editable.",
|
|
10333
11053
|
"canvas.create": "Create a canvas.",
|
|
10334
11054
|
"canvas.get": "Read a canvas and access.",
|
|
10335
11055
|
"canvas.setAccess": "Change canvas link access.",
|
|
@@ -10346,8 +11066,6 @@ const COMMAND_SUMMARIES = {
|
|
|
10346
11066
|
"canvas.tree": "Read the node hierarchy.",
|
|
10347
11067
|
"canvas.node": "Read a node and children.",
|
|
10348
11068
|
"canvas.selection": "Read the live selection.",
|
|
10349
|
-
"canvas asset": "Manage uploaded assets.",
|
|
10350
|
-
"canvas mutation": "Read mutation receipts.",
|
|
10351
11069
|
"canvas apply": "Apply canvas operations.",
|
|
10352
11070
|
"canvas find": "Find accessible canvases.",
|
|
10353
11071
|
"canvas remove": "Remove scoped subtrees.",
|
|
@@ -10358,6 +11076,7 @@ const COMMAND_SUMMARIES = {
|
|
|
10358
11076
|
"canvas insert-html": "Insert compiled HTML.",
|
|
10359
11077
|
"canvas make-editable": "Convert a captured screen.",
|
|
10360
11078
|
"canvas capture": "Capture a recording moment.",
|
|
11079
|
+
"canvas capture-page": "Capture a page you opened.",
|
|
10361
11080
|
"canvas arrange": "Arrange canvas objects.",
|
|
10362
11081
|
"canvas duplicate-nodes": "Duplicate node subtrees.",
|
|
10363
11082
|
"canvas text-style-library": "Manage text styles.",
|
|
@@ -10369,6 +11088,104 @@ const COMMAND_SUMMARIES = {
|
|
|
10369
11088
|
"canvas invites": "Invite people to a canvas."
|
|
10370
11089
|
};
|
|
10371
11090
|
|
|
11091
|
+
//#endregion
|
|
11092
|
+
//#region src/infrastructure/input-spellings.lib.ts
|
|
11093
|
+
const CANVAS = "--canvas";
|
|
11094
|
+
const CANVAS_ID = "--canvas-id";
|
|
11095
|
+
const VERSION_SPELLINGS = ["--base-version", "--expected-version"];
|
|
11096
|
+
/** Options a command cannot run without, which the tool checks once either spelling is read. */
|
|
11097
|
+
const REQUIRED_SPELLINGS = /* @__PURE__ */ new WeakSet();
|
|
11098
|
+
/** Whether the command needs this option or the other spelling of it. */
|
|
11099
|
+
const isRequiredSpelling = (option) => REQUIRED_SPELLINGS.has(option);
|
|
11100
|
+
const optionOf = (command, long) => command.options.find((option) => option.long === long);
|
|
11101
|
+
const isGiven = (command, option) => command.getOptionValueSource(option.attributeName()) === "cli";
|
|
11102
|
+
/** Hands one spelling's value to the option the command's action reads, and forgets the first. */
|
|
11103
|
+
const moveValue = (command, from, to, value) => {
|
|
11104
|
+
command.setOptionValueWithSource(to.attributeName(), value, "cli");
|
|
11105
|
+
Reflect.deleteProperty(command.opts(), from.attributeName());
|
|
11106
|
+
};
|
|
11107
|
+
/** Puts `second` straight after `first` in help, wherever each was added. */
|
|
11108
|
+
const placeTogether = (command, first, second) => {
|
|
11109
|
+
const others = command.options.filter((option) => option !== first && option !== second);
|
|
11110
|
+
const at = Math.min(...[first, second].map((option) => command.options.indexOf(option)).filter((i) => i >= 0));
|
|
11111
|
+
Reflect.set(command, "options", [
|
|
11112
|
+
...others.slice(0, at),
|
|
11113
|
+
first,
|
|
11114
|
+
second,
|
|
11115
|
+
...others.slice(at)
|
|
11116
|
+
]);
|
|
11117
|
+
};
|
|
11118
|
+
/**
|
|
11119
|
+
* Commander refuses a missing mandatory option before any hook runs, so an option with a second
|
|
11120
|
+
* spelling is checked here instead, after either spelling has had its chance.
|
|
11121
|
+
*/
|
|
11122
|
+
const requireEither = (shown, other) => {
|
|
11123
|
+
const wasMandatory = shown.mandatory || other.mandatory;
|
|
11124
|
+
shown.makeOptionMandatory(false);
|
|
11125
|
+
other.makeOptionMandatory(false);
|
|
11126
|
+
if (wasMandatory) REQUIRED_SPELLINGS.add(shown);
|
|
11127
|
+
};
|
|
11128
|
+
const refuseMissing = (command, shown, other) => {
|
|
11129
|
+
if (!isRequiredSpelling(shown) || isGiven(command, shown) || isGiven(command, other)) return;
|
|
11130
|
+
if (command.getOptionValueSource("json") === "cli") return;
|
|
11131
|
+
throw new CliError("BAD_REQUEST", `${String(shown.long)} is required.`, `Pass ${String(shown.long)}, or ${String(other.long)} in its place.`);
|
|
11132
|
+
};
|
|
11133
|
+
/** Runs `read` before the command's own action, and never for a subcommand of it. */
|
|
11134
|
+
const beforeAction = (command, read) => {
|
|
11135
|
+
command.hook("preAction", (_hooked, actionCommand) => {
|
|
11136
|
+
if (actionCommand === command) read();
|
|
11137
|
+
});
|
|
11138
|
+
};
|
|
11139
|
+
const acceptCanvasSpellings = (command) => {
|
|
11140
|
+
const ownCanvas = optionOf(command, CANVAS);
|
|
11141
|
+
const ownCanvasId = optionOf(command, CANVAS_ID);
|
|
11142
|
+
if (ownCanvas === void 0 && ownCanvasId === void 0) return;
|
|
11143
|
+
const canvas = ownCanvas ?? new Option(`${CANVAS} <url-or-id>`, "Canvas URL, the `/c/<id>` path `enhance canvas find` returns, or canvas id.");
|
|
11144
|
+
const canvasId = ownCanvasId ?? new Option(`${CANVAS_ID} <id>`, `Canvas id alone. Accepted in place of ${CANVAS}.`);
|
|
11145
|
+
if (ownCanvas === void 0) command.addOption(canvas);
|
|
11146
|
+
if (ownCanvasId === void 0) command.addOption(canvasId);
|
|
11147
|
+
else canvasId.description = `${canvasId.description} Accepted in place of ${CANVAS}.`.trim();
|
|
11148
|
+
placeTogether(command, canvas, canvasId);
|
|
11149
|
+
requireEither(canvas, canvasId);
|
|
11150
|
+
beforeAction(command, () => {
|
|
11151
|
+
if (isGiven(command, canvas) && isGiven(command, canvasId)) throw new CliError("BAD_REQUEST", `${CANVAS} and ${CANVAS_ID} cannot be combined.`, `Pass the canvas once, through ${CANVAS}.`);
|
|
11152
|
+
refuseMissing(command, canvas, canvasId);
|
|
11153
|
+
if (ownCanvas !== void 0) {
|
|
11154
|
+
if (isGiven(command, canvasId)) moveValue(command, canvasId, canvas, command.getOptionValue(canvasId.attributeName()));
|
|
11155
|
+
return;
|
|
11156
|
+
}
|
|
11157
|
+
const reference = command.getOptionValue(canvas.attributeName());
|
|
11158
|
+
if (typeof reference === "string") moveValue(command, canvas, canvasId, fromCanvasReference(reference));
|
|
11159
|
+
});
|
|
11160
|
+
};
|
|
11161
|
+
const acceptVersionSpellings = (command) => {
|
|
11162
|
+
const [base, expected] = VERSION_SPELLINGS.map((long) => optionOf(command, long));
|
|
11163
|
+
const own = base ?? expected;
|
|
11164
|
+
if (own?.long === void 0 || base !== void 0 && expected !== void 0) return;
|
|
11165
|
+
const otherLong = VERSION_SPELLINGS.find((long) => long !== own.long) ?? own.long;
|
|
11166
|
+
const other = new Option(`${otherLong} ${own.flags.split(" ").slice(1).join(" ")}`, `Accepted in place of ${own.long}.`);
|
|
11167
|
+
if (own.parseArg !== void 0) other.argParser(own.parseArg);
|
|
11168
|
+
command.addOption(other);
|
|
11169
|
+
placeTogether(command, own, other);
|
|
11170
|
+
requireEither(own, other);
|
|
11171
|
+
beforeAction(command, () => {
|
|
11172
|
+
refuseMissing(command, own, other);
|
|
11173
|
+
if (!isGiven(command, other)) return;
|
|
11174
|
+
const given = command.getOptionValue(other.attributeName());
|
|
11175
|
+
if (isGiven(command, own) && String(command.getOptionValue(own.attributeName())) !== String(given)) throw new CliError("BAD_REQUEST", `${own.long ?? ""} and ${otherLong} name the same version and were given different values.`, "Pass the version once.");
|
|
11176
|
+
moveValue(command, other, own, given);
|
|
11177
|
+
});
|
|
11178
|
+
};
|
|
11179
|
+
/**
|
|
11180
|
+
* Gives a command the second spelling of each input it takes under one: a canvas as `--canvas`
|
|
11181
|
+
* and `--canvas-id`, and the version it expects as `--base-version` and `--expected-version`. The
|
|
11182
|
+
* command's action still reads the option it was written with.
|
|
11183
|
+
*/
|
|
11184
|
+
const acceptInputSpellings = (command) => {
|
|
11185
|
+
acceptCanvasSpellings(command);
|
|
11186
|
+
acceptVersionSpellings(command);
|
|
11187
|
+
};
|
|
11188
|
+
|
|
10372
11189
|
//#endregion
|
|
10373
11190
|
//#region src/infrastructure/option-string.mapper.ts
|
|
10374
11191
|
const toBareStringOption = (option, canAcceptNull = false) => {
|
|
@@ -10407,11 +11224,14 @@ const REQUIRED_OPTIONS = /* @__PURE__ */ new Map([
|
|
|
10407
11224
|
["screen.create --provenance", null],
|
|
10408
11225
|
["screen.create --route", null],
|
|
10409
11226
|
["screen.create --viewport", null],
|
|
11227
|
+
["canvas.duplicate --organisation-id", null],
|
|
11228
|
+
["canvas.move --organisation-id", null],
|
|
11229
|
+
["canvas.version.name --target", null],
|
|
11230
|
+
["canvas.document.save --document", null],
|
|
11231
|
+
["canvas.copyWalkthroughs --recording-ids", null],
|
|
11232
|
+
["comment.start --anchor", null],
|
|
11233
|
+
["comment.move --anchor", null],
|
|
10410
11234
|
["canvas render --canvas", "--input"],
|
|
10411
|
-
["canvas.inspect --canvas", "--canvas-id"],
|
|
10412
|
-
["canvas.tree --canvas", "--canvas-id"],
|
|
10413
|
-
["canvas.node --canvas", "--canvas-id"],
|
|
10414
|
-
["canvas.selection --canvas", "--canvas-id"],
|
|
10415
11235
|
["canvas read --canvas", "--input"],
|
|
10416
11236
|
["canvas duplicate-nodes --canvas", "--input"],
|
|
10417
11237
|
["canvas duplicate-nodes --base-version", "--input"],
|
|
@@ -10441,13 +11261,20 @@ const refusalFor = ({ option, replacement }) => {
|
|
|
10441
11261
|
return replacement === null ? new CliError("BAD_REQUEST", `${flag} is required unless --json supplies the complete input.`, `Pass ${flag} explicitly, including false or null when that is the intended value.`) : new CliError("BAD_REQUEST", `${flag} is required unless ${replacement.long ?? replacement.flags} is given.`, `Pass ${flag}, or use ${replacement.long ?? replacement.flags} instead.`);
|
|
10442
11262
|
};
|
|
10443
11263
|
/**
|
|
10444
|
-
*
|
|
10445
|
-
*
|
|
11264
|
+
* The API's commands print a value that is one of several kinds, or an object, as optional:
|
|
11265
|
+
* `[value]`, `[json]`, `[values...]`. Help shows a required one as every other required flag.
|
|
11266
|
+
*/
|
|
11267
|
+
const shownAsRequired = (flags) => flags.replace(/\[([^\]]+)\]$/u, (_whole, name) => `<${name}>`);
|
|
11268
|
+
/**
|
|
11269
|
+
* Shows each requirement in the option's help: a replaceable one in its description, and one that
|
|
11270
|
+
* nothing replaces in its flags. Refuses a command that has neither the option nor its replacement
|
|
11271
|
+
* on the command line.
|
|
10446
11272
|
*/
|
|
10447
11273
|
const requireOptions = (command, scope) => {
|
|
10448
11274
|
const required = requiredOptionsOf(command, scope);
|
|
10449
11275
|
if (required.length === 0) return;
|
|
10450
|
-
for (const { option, replacement } of required) if (replacement
|
|
11276
|
+
for (const { option, replacement } of required) if (replacement === null) option.flags = shownAsRequired(option.flags);
|
|
11277
|
+
else option.description = `${option.description} Required unless ${replacement.long ?? replacement.flags} is given.`;
|
|
10451
11278
|
command.hook("preAction", (_hookedCommand, actionCommand) => {
|
|
10452
11279
|
if (actionCommand !== command) return;
|
|
10453
11280
|
if (actionCommand.getOptionValueSource("json") === "cli") return;
|
|
@@ -10461,13 +11288,15 @@ const requireOptions = (command, scope) => {
|
|
|
10461
11288
|
//#region src/infrastructure/cli-polish.lib.ts
|
|
10462
11289
|
const NAMESPACES = {
|
|
10463
11290
|
"canvas text-style-library": "Find, read, and publish reusable text styles across canvases.",
|
|
10464
|
-
"canvas chats": "Inspect and manage authorized canvas chat history.",
|
|
10465
11291
|
canvas: "Create, find, share and manage canvases.",
|
|
10466
11292
|
"canvas render": "Render production-faithful canvas pixels after inspecting exact structure and geometry.",
|
|
10467
11293
|
"canvas version": "Inspect and name retained canvas history.",
|
|
10468
11294
|
"canvas document": "Read or replace the opaque document stored on a canvas.",
|
|
10469
11295
|
"canvas invites": "Invite people to a canvas and manage pending invitations.",
|
|
10470
11296
|
"canvas participants": "List and change the people who can reach a canvas.",
|
|
11297
|
+
"canvas realtime": "Tell the people on a canvas that an agent is at work on it.",
|
|
11298
|
+
"canvas realtime activity": "Begin, renew and end the indicator that an agent is working on a canvas.",
|
|
11299
|
+
"capture-run": "Review what a capture run changed against its baseline.",
|
|
10471
11300
|
comment: "Comment threads and replies anchored to canvas content.",
|
|
10472
11301
|
organisation: "Teams the authenticated person belongs to or creates.",
|
|
10473
11302
|
"organisation invites": "Invite people to a team and manage pending invitations.",
|
|
@@ -10476,8 +11305,24 @@ const NAMESPACES = {
|
|
|
10476
11305
|
"person recipients": "People available when choosing sharing recipients.",
|
|
10477
11306
|
recording: "Recorded walkthroughs, chunks, recovery, and completion.",
|
|
10478
11307
|
"recording-asset": "External page assets mirrored for durable replay.",
|
|
10479
|
-
screen: "Captured pages uploaded for placement on a canvas."
|
|
10480
|
-
|
|
11308
|
+
screen: "Captured pages uploaded for placement on a canvas.",
|
|
11309
|
+
transcript: "Read what was said in a recorded walkthrough, and retry a failed transcription."
|
|
11310
|
+
};
|
|
11311
|
+
/** Commands that do one job from different inputs, each with the sentence that names the other. */
|
|
11312
|
+
const TWINS = {
|
|
11313
|
+
"canvas delete-nodes": "`enhance canvas remove` does the same with a JSON input.",
|
|
11314
|
+
"canvas remove": "`enhance canvas delete-nodes` does the same with flags.",
|
|
11315
|
+
"prototype publish": "`enhance canvas publish-prototype` does the same with a JSON input.",
|
|
11316
|
+
"canvas publish-prototype": "`enhance prototype publish` does the same with flags.",
|
|
11317
|
+
"canvas work begin": "`enhance canvas realtime activity begin` does the same.",
|
|
11318
|
+
"canvas work update": "`enhance canvas realtime activity renew` does the same.",
|
|
11319
|
+
"canvas finish-working-on-nodes": "`enhance canvas realtime activity end` does the same.",
|
|
11320
|
+
"canvas realtime activity begin": "`enhance canvas work begin` does the same.",
|
|
11321
|
+
"canvas realtime activity renew": "`enhance canvas work update` does the same.",
|
|
11322
|
+
"canvas realtime activity end": "`enhance canvas finish-working-on-nodes` does the same."
|
|
11323
|
+
};
|
|
11324
|
+
const DEFAULT_HELP_WIDTH = 80;
|
|
11325
|
+
const LONG_ANSWER_NOTE = "An answer with a line over 2,000 characters, or over 25,000 in all, is written to a file. The tool prints the path of that file with its characters and records in its place: read the file.";
|
|
10481
11326
|
const STDIN_TOKEN_PROCEDURES = /* @__PURE__ */ new Set([
|
|
10482
11327
|
"canvas.invites.accept",
|
|
10483
11328
|
"canvas.invites.preview",
|
|
@@ -10494,16 +11339,18 @@ const NULL_LITERAL_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
10494
11339
|
"screen.create --route"
|
|
10495
11340
|
]);
|
|
10496
11341
|
const asRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : null;
|
|
10497
|
-
const procedurePathOf$
|
|
11342
|
+
const procedurePathOf$3 = (command) => {
|
|
10498
11343
|
const details = asRecord$1(Reflect.get(command, "__trpcCli"));
|
|
10499
11344
|
const path = details === null ? void 0 : details["path"];
|
|
10500
11345
|
return typeof path === "string" ? path : null;
|
|
10501
11346
|
};
|
|
10502
11347
|
const optionDescription = (command, option, generated, commandPath) => {
|
|
10503
11348
|
const longName = option.long;
|
|
10504
|
-
const
|
|
11349
|
+
const procedurePath = procedurePathOf$3(command);
|
|
11350
|
+
const scope = procedurePath ?? commandPath.join(" ");
|
|
10505
11351
|
const specific = scope === "" || longName === void 0 ? void 0 : OPTION_DESCRIPTIONS[`${scope} ${longName}`];
|
|
10506
11352
|
if (specific !== void 0) return specific;
|
|
11353
|
+
if (procedurePath === null && generated.trim() !== "") return generated;
|
|
10507
11354
|
if (longName !== void 0 && OPTION_DESCRIPTIONS[longName] !== void 0) return OPTION_DESCRIPTIONS[longName];
|
|
10508
11355
|
const useful = (generated.split(/Any of:|One of:/u, 1)[0]?.trim() ?? "").split(";").map((part) => part.trim()).filter((part) => part !== "" && [
|
|
10509
11356
|
"Format:",
|
|
@@ -10522,7 +11369,7 @@ const configureCommand = (command, input, commandPath) => {
|
|
|
10522
11369
|
});
|
|
10523
11370
|
command.showHelpAfterError(false).showSuggestionAfterError(false);
|
|
10524
11371
|
const explicitNulls = [];
|
|
10525
|
-
const scope = procedurePathOf$
|
|
11372
|
+
const scope = procedurePathOf$3(command) ?? commandPath.join(" ");
|
|
10526
11373
|
for (const option of command.options) {
|
|
10527
11374
|
option.description = optionDescription(command, option, option.description, commandPath);
|
|
10528
11375
|
const canAcceptNull = NULL_LITERAL_OPTIONS.has(`${scope} ${option.long ?? ""}`);
|
|
@@ -10535,6 +11382,7 @@ const configureCommand = (command, input, commandPath) => {
|
|
|
10535
11382
|
if (explicitNulls.length > 0) command.hook("preAction", (actionCommand) => {
|
|
10536
11383
|
for (const explicitNull of explicitNulls) if (explicitNull.matches(actionCommand.getOptionValue(explicitNull.name))) actionCommand.setOptionValueWithSource(explicitNull.name, null, "cli");
|
|
10537
11384
|
});
|
|
11385
|
+
acceptInputSpellings(command);
|
|
10538
11386
|
requireOptions(command, scope);
|
|
10539
11387
|
};
|
|
10540
11388
|
const prepareMutation = (command, commandPath, procedurePath, input) => {
|
|
@@ -10563,12 +11411,21 @@ const describe = (command, commandPath, procedurePath, descriptions) => {
|
|
|
10563
11411
|
else if (procedurePath !== null) command.description(PROCEDURE_DESCRIPTIONS[procedurePath] ?? descriptions.get(procedurePath) ?? `Run the ${procedurePath} API operation.`);
|
|
10564
11412
|
const summary = COMMAND_SUMMARIES[commandPath.join(" ")] ?? (procedurePath === null ? void 0 : COMMAND_SUMMARIES[procedurePath]);
|
|
10565
11413
|
if (summary !== void 0) command.summary(summary);
|
|
11414
|
+
const twin = TWINS[commandPath.join(" ")];
|
|
11415
|
+
if (twin === void 0) return;
|
|
11416
|
+
if (command.summary() === "") command.summary(command.description());
|
|
11417
|
+
command.description(`${command.description()} ${twin}`);
|
|
11418
|
+
};
|
|
11419
|
+
/** Says once, in the tool's own help, where a long answer goes. */
|
|
11420
|
+
const noteLongAnswers = (program) => {
|
|
11421
|
+
program.configureHelp({ formatHelp: (command, helper) => `${Help.prototype.formatHelp.call(helper, command, helper)}\n${helper.boxWrap(LONG_ANSWER_NOTE, helper.helpWidth ?? DEFAULT_HELP_WIDTH)}\n` });
|
|
10566
11422
|
};
|
|
10567
11423
|
const polishCli = (command, input, path = []) => {
|
|
10568
11424
|
configureCommand(command, input, path);
|
|
11425
|
+
if (path.length === 0) noteLongAnswers(command);
|
|
10569
11426
|
for (const child of command.commands) {
|
|
10570
11427
|
const commandPath = [...path, child.name()];
|
|
10571
|
-
const procedurePath = procedurePathOf$
|
|
11428
|
+
const procedurePath = procedurePathOf$3(child);
|
|
10572
11429
|
prepareMutation(child, commandPath, procedurePath, input);
|
|
10573
11430
|
describe(child, commandPath, procedurePath, input.descriptions);
|
|
10574
11431
|
prepareStdinToken(child, commandPath, procedurePath);
|
|
@@ -10579,30 +11436,128 @@ const polishCli = (command, input, path = []) => {
|
|
|
10579
11436
|
//#endregion
|
|
10580
11437
|
//#region src/infrastructure/cli-surface.lib.ts
|
|
10581
11438
|
const CLI_EXCLUDED_PROCEDURES = createCapabilityPolicyAdapter().excludedProcedures;
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
"telemetry"
|
|
10586
|
-
]);
|
|
10587
|
-
const procedurePathOf$1 = (command) => {
|
|
11439
|
+
/** The list trpc-cli writes into a group's description when it builds the group. */
|
|
11440
|
+
const SUBCOMMAND_LIST = /Available subcommands: .*$/u;
|
|
11441
|
+
const procedurePathOf$2 = (command) => {
|
|
10588
11442
|
const details = Reflect.get(command, "__trpcCli");
|
|
10589
11443
|
if (typeof details !== "object" || details === null) return null;
|
|
10590
11444
|
const path = Reflect.get(details, "path");
|
|
10591
11445
|
return typeof path === "string" ? path : null;
|
|
10592
11446
|
};
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
11447
|
+
/**
|
|
11448
|
+
* Leaves only what an agent can run: removes each command whose procedure is not offered, then
|
|
11449
|
+
* each group that is left with no command, so a group is never a command that does nothing.
|
|
11450
|
+
*/
|
|
11451
|
+
const removeExcludedProcedures = (command) => {
|
|
11452
|
+
const offered = command.commands.filter((child) => {
|
|
11453
|
+
const procedure = procedurePathOf$2(child);
|
|
11454
|
+
if (procedure !== null) return !CLI_EXCLUDED_PROCEDURES.has(procedure);
|
|
11455
|
+
const isGroup = child.commands.length > 0;
|
|
11456
|
+
removeExcludedProcedures(child);
|
|
11457
|
+
return !isGroup || child.commands.length > 0;
|
|
10598
11458
|
});
|
|
10599
|
-
Reflect.set(command, "commands",
|
|
10600
|
-
|
|
11459
|
+
Reflect.set(command, "commands", offered);
|
|
11460
|
+
const names = offered.map((child) => child.name()).join(", ");
|
|
11461
|
+
command.description(command.description().replace(SUBCOMMAND_LIST, () => `Available subcommands: ${names}`));
|
|
11462
|
+
};
|
|
11463
|
+
|
|
11464
|
+
//#endregion
|
|
11465
|
+
//#region src/infrastructure/command-examples.consts.ts
|
|
11466
|
+
const CANVAS_RENDER_EXAMPLE = "canvas render --canvas 0b9f4c1e-5d2a-4e8b-9c3f-7a6d1e2b4c50";
|
|
11467
|
+
/**
|
|
11468
|
+
* A command line, after the binary name, that each listed command accepts exactly as written. Help,
|
|
11469
|
+
* the command listing and the docs page of a command all show this one line.
|
|
11470
|
+
*/
|
|
11471
|
+
const COMMAND_EXAMPLES = {
|
|
11472
|
+
"canvas apply": `canvas apply --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --operations '[{"op":"setText","nodeId":"text_title","text":"Ready"}]'`,
|
|
11473
|
+
"canvas edit": `canvas edit --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --edits '[{"kind":"set_text","nodeId":"text_title","text":"Today"}]'`,
|
|
11474
|
+
"canvas set-text-content": `canvas set-text-content --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --updates '[{"nodeId":"text_title","textContent":"Today"}]'`,
|
|
11475
|
+
"canvas rename-nodes": `canvas rename-nodes --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --updates '[{"nodeId":"card","name":"Task"}]'`,
|
|
11476
|
+
"canvas update-styles": `canvas update-styles --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --updates '[{"nodeIds":["button"],"styles":{"background":"#0f766e"}}]'`,
|
|
11477
|
+
"canvas delete-nodes": `canvas delete-nodes --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --node-ids '["obsolete"]'`,
|
|
11478
|
+
"canvas get-computed-styles": `canvas get-computed-styles --canvas 00000000-0000-4000-8000-000000000010 --node-ids '["button"]'`,
|
|
11479
|
+
"canvas duplicate-nodes": `canvas duplicate-nodes --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"nodeIds":["screen"],"destination":{"kind":"native"}}'`,
|
|
11480
|
+
"canvas move-nodes": `canvas move-nodes --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --moves '[{"nodeId":"card","before":"other"}]'`,
|
|
11481
|
+
"canvas create-artboard": `canvas create-artboard --canvas 00000000-0000-4000-8000-000000000010 --base-version 1 --name Home --styles '{"width":"1440px","height":"900px"}'`,
|
|
11482
|
+
"canvas render": CANVAS_RENDER_EXAMPLE,
|
|
11483
|
+
"canvas work begin": `canvas work begin --canvas 00000000-0000-4000-8000-000000000010 --phase creating --bounds '{"x":0,"y":0,"width":1440,"height":900}'`,
|
|
11484
|
+
"canvas work update": `canvas work update --canvas 00000000-0000-4000-8000-000000000010 --activity-id 00000000-0000-4000-8000-000000000010 --phase writing --bounds '{"x":0,"y":0,"width":1440,"height":900}'`,
|
|
11485
|
+
"canvas find": `canvas find --input '{"collection":"everything","includeDestinations":true,"limit":25}'`,
|
|
11486
|
+
"canvas read": `canvas read --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","view":"outline","depth":2,"limit":50}'`,
|
|
11487
|
+
"canvas remove": `canvas remove --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"rootNodeIds":["obsolete"]}'`,
|
|
11488
|
+
"canvas update-html": `canvas update-html --input '${JSON.stringify(CANVAS_UPDATE_HTML_INPUT_EXAMPLE)}'`,
|
|
11489
|
+
"canvas publish-prototype": `canvas publish-prototype --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"source":{"kind":"deployment","deploymentId":"00000000-0000-4000-8000-000000000010"},"waitMs":1500}'`,
|
|
11490
|
+
"canvas import-asset": `canvas import-asset --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","source":{"kind":"file","path":"/project/logo.png"}}'`,
|
|
11491
|
+
"canvas insert-html": String.raw`canvas insert-html --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"destination":{"parentNodeId":"root"},"html":"<div style=\"width:400px;height:200px\">Hello</div>","waitMs":1500}'`,
|
|
11492
|
+
"canvas make-editable": `canvas make-editable --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"sourceNodeId":"screen","placement":{"kind":"adjacent"},"waitMs":1500}'`,
|
|
11493
|
+
"canvas capture": `canvas capture --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"source":{"kind":"recording","recordingId":"00000000-0000-4000-8000-000000000010","atMs":500},"previewJobId":"00000000-0000-4000-8000-000000000010","placement":{"kind":"editable-below-source"},"waitMs":1500}'`,
|
|
11494
|
+
"canvas capture-page": `canvas capture-page --input '{"canvasRef":"00000000-0000-4000-8000-000000000010"}'`,
|
|
11495
|
+
"canvas arrange": `canvas arrange --input '{"canvasRef":"00000000-0000-4000-8000-000000000010","baseVersion":1,"changes":[{"kind":"position","nodeId":"screen","parentPosition":{"x":40,"y":40}}]}'`,
|
|
11496
|
+
"operation status": `operation status --input '{"operation":{"kind":"canvas-mutation","canvasId":"00000000-0000-4000-8000-000000000010","mutationId":"00000000-0000-4000-8000-000000000010","fingerprint":"5bf58a8bb75a9cf7b4718822d018a70aa3a06113c5eea973eb908ada9000766f"}}'`,
|
|
11497
|
+
"canvas document save": `canvas document save --json '${JSON.stringify({
|
|
11498
|
+
canvasId: CAPABILITY_UUID_EXAMPLE,
|
|
11499
|
+
baseVersion: 1,
|
|
11500
|
+
document: emptyCanvasSceneDocument$1(),
|
|
11501
|
+
screenIds: []
|
|
11502
|
+
})}'`,
|
|
11503
|
+
"canvas text-style-library list": `canvas text-style-library list --json '{"search":"Brand","limit":20}'`,
|
|
11504
|
+
"canvas realtime activity begin": `canvas realtime activity begin --json '{"canvasId":"00000000-0000-4000-8000-000000000010","phase":"creating","bounds":{"x":0,"y":0,"width":1440,"height":900}}'`,
|
|
11505
|
+
"canvas realtime activity renew": `canvas realtime activity renew --json '{"canvasId":"00000000-0000-4000-8000-000000000010","activityId":"00000000-0000-4000-8000-000000000010","phase":"writing","bounds":{"x":0,"y":0,"width":1440,"height":900}}'`,
|
|
11506
|
+
"canvas version name": `canvas version name --json '{"canvasId":"00000000-0000-4000-8000-000000000010","target":{"kind":"current","expectedVersion":1},"title":"Checkout review"}'`,
|
|
11507
|
+
"comment list": `comment list --json '{"canvasId":"00000000-0000-4000-8000-000000000010","page":{"limit":20}}'`,
|
|
11508
|
+
"comment get": `comment get --json '{"canvasId":"00000000-0000-4000-8000-000000000010","threadId":"00000000-0000-4000-8000-000000000010"}'`,
|
|
11509
|
+
"comment start": `comment start --json '{"canvasId":"00000000-0000-4000-8000-000000000010","clientThreadId":"00000000-0000-4000-8000-000000000010","anchor":{"on":"canvas","point":{"x":120,"y":160}},"body":"Check this spacing."}'`,
|
|
11510
|
+
"comment resolve": `comment resolve --json '{"canvasId":"00000000-0000-4000-8000-000000000010","threadId":"00000000-0000-4000-8000-000000000010","resolved":true}'`,
|
|
11511
|
+
"comment reply": `comment reply --json '{"canvasId":"00000000-0000-4000-8000-000000000010","threadId":"00000000-0000-4000-8000-000000000010","clientMessageId":"00000000-0000-4000-8000-000000000010","body":"Fixed."}'`,
|
|
11512
|
+
"comment move": `comment move --json '{"canvasId":"00000000-0000-4000-8000-000000000010","threadId":"00000000-0000-4000-8000-000000000010","anchor":{"on":"canvas","point":{"x":120,"y":160}}}'`,
|
|
11513
|
+
"recording start": `recording start --json '{"sourceUrl":"https://example.test/checkout","viewport":{"width":1280,"height":800},"pageTitle":"Checkout"}'`,
|
|
11514
|
+
"recording complete": `recording complete --json '{"recordingId":"00000000-0000-4000-8000-000000000010","durationMs":1000,"viewport":{"width":1280,"height":800},"sourceUrl":"https://example.test/checkout"}'`,
|
|
11515
|
+
"screen create": `screen create --json '{"clientToken":"00000000-0000-4000-8000-000000000010","provenance":null,"route":"/checkout","pageTitle":"Checkout","viewport":{"width":1280,"height":800},"bytes":1024}'`
|
|
11516
|
+
};
|
|
11517
|
+
/** The line under a command's example that says which of its values stand for the caller's own. */
|
|
11518
|
+
const COMMAND_EXAMPLE_PLACEHOLDERS = {
|
|
11519
|
+
"canvas apply": "Replace with your own: the canvas id, the version, the layer id \"text_title\".",
|
|
11520
|
+
"canvas edit": "Replace with your own: the canvas id, the version, the layer id \"text_title\".",
|
|
11521
|
+
"canvas set-text-content": "Replace with your own: the canvas id, the version, the layer id \"text_title\".",
|
|
11522
|
+
"canvas rename-nodes": "Replace with your own: the canvas id, the version, the layer id \"card\".",
|
|
11523
|
+
"canvas update-styles": "Replace with your own: the canvas id, the version, the layer id \"button\".",
|
|
11524
|
+
"canvas delete-nodes": "Replace with your own: the canvas id, the version, the layer id \"obsolete\".",
|
|
11525
|
+
"canvas get-computed-styles": "Replace with your own: the canvas id, the layer id \"button\".",
|
|
11526
|
+
"canvas duplicate-nodes": "Replace with your own: the canvas id, the version, the layer id \"screen\".",
|
|
11527
|
+
"canvas move-nodes": "Replace with your own: the canvas id, the version, the layer ids \"card\" and \"other\".",
|
|
11528
|
+
"canvas create-artboard": "Replace with your own: the canvas id, the version.",
|
|
11529
|
+
"canvas render": "Replace with your own: the canvas id.",
|
|
11530
|
+
"canvas work begin": "Replace with your own: the canvas id.",
|
|
11531
|
+
"canvas work update": "Replace with your own: the canvas id, the activity id.",
|
|
11532
|
+
"canvas read": "Replace with your own: the canvas id.",
|
|
11533
|
+
"canvas remove": "Replace with your own: the canvas id, the version, the layer id \"obsolete\".",
|
|
11534
|
+
"canvas update-html": "Replace with your own: the canvas id, the snapshot token, the HTML.",
|
|
11535
|
+
"canvas publish-prototype": "Replace with your own: the canvas id, the version, the deployment id.",
|
|
11536
|
+
"canvas import-asset": "Replace with your own: the canvas id, the file path.",
|
|
11537
|
+
"canvas insert-html": "Replace with your own: the canvas id, the version.",
|
|
11538
|
+
"canvas make-editable": "Replace with your own: the canvas id, the version, the layer id \"screen\".",
|
|
11539
|
+
"canvas capture": "Replace with your own: the canvas id, the version, the recording id, the time, the preview job id.",
|
|
11540
|
+
"canvas capture-page": "Replace with your own: the canvas id.",
|
|
11541
|
+
"canvas arrange": "Replace with your own: the canvas id, the version, the layer id \"screen\".",
|
|
11542
|
+
"operation status": "Replace with your own: the whole operation, copied from the answer of a write.",
|
|
11543
|
+
"canvas document save": "Replace with your own: the canvas id, the version, the document.",
|
|
11544
|
+
"canvas realtime activity begin": "Replace with your own: the canvas id.",
|
|
11545
|
+
"canvas realtime activity renew": "Replace with your own: the canvas id, the activity id.",
|
|
11546
|
+
"canvas version name": "Replace with your own: the canvas id, the version.",
|
|
11547
|
+
"comment list": "Replace with your own: the canvas id.",
|
|
11548
|
+
"comment get": "Replace with your own: the canvas id, the thread id.",
|
|
11549
|
+
"comment start": "Replace with your own: the canvas id, the thread id, a UUID you make.",
|
|
11550
|
+
"comment resolve": "Replace with your own: the canvas id, the thread id.",
|
|
11551
|
+
"comment reply": "Replace with your own: the canvas id, the thread id, the message id, a UUID you make.",
|
|
11552
|
+
"comment move": "Replace with your own: the canvas id, the thread id.",
|
|
11553
|
+
"recording start": "Replace with your own: the address, the page title.",
|
|
11554
|
+
"recording complete": "Replace with your own: the recording id, the address.",
|
|
11555
|
+
"screen create": "Replace with your own: the client token, a UUID you make, the route, the page title, the size in bytes."
|
|
10601
11556
|
};
|
|
10602
11557
|
|
|
10603
11558
|
//#endregion
|
|
10604
11559
|
//#region src/infrastructure/commands.program.ts
|
|
10605
|
-
const procedurePathOf = (command) => {
|
|
11560
|
+
const procedurePathOf$1 = (command) => {
|
|
10606
11561
|
const details = Reflect.get(command, "__trpcCli");
|
|
10607
11562
|
if (typeof details !== "object" || details === null) return null;
|
|
10608
11563
|
const path = Reflect.get(details, "path");
|
|
@@ -10617,7 +11572,7 @@ const listedCommands = (command, path = []) => command.commands.filter((child) =
|
|
|
10617
11572
|
});
|
|
10618
11573
|
const recordsFrom = (command, path = []) => command.commands.filter((child) => child.name() !== "help").flatMap((child) => {
|
|
10619
11574
|
const childPath = [...path, child.name()];
|
|
10620
|
-
const procedure = procedurePathOf(child);
|
|
11575
|
+
const procedure = procedurePathOf$1(child);
|
|
10621
11576
|
return [{
|
|
10622
11577
|
path: childPath.join(" "),
|
|
10623
11578
|
procedure,
|
|
@@ -10634,12 +11589,19 @@ const toReferenceRecord = (capability, discovery) => ({
|
|
|
10634
11589
|
}),
|
|
10635
11590
|
exampleOutput: capability.guide.examples[0]?.output ?? null
|
|
10636
11591
|
});
|
|
10637
|
-
|
|
10638
|
-
|
|
11592
|
+
/** Whether a command path is the namespace or below it; every path is, when none is asked for. */
|
|
11593
|
+
const withinNamespace = (namespace) => (path) => {
|
|
11594
|
+
const prefix = namespace?.trim();
|
|
11595
|
+
if (prefix === void 0) return true;
|
|
11596
|
+
return path === prefix || path?.startsWith(`${prefix} `) === true;
|
|
11597
|
+
};
|
|
11598
|
+
const commandRecords = (program, catalog, isListed) => {
|
|
11599
|
+
const capabilities = catalog.all();
|
|
10639
11600
|
const discovery = createMcpCapabilityDiscoveryAdapter(capabilities);
|
|
10640
11601
|
const exitCodes = toPublishedExitTable();
|
|
10641
11602
|
return listedCommands(program).flatMap(({ command, path }) => {
|
|
10642
|
-
|
|
11603
|
+
if (!isListed(path)) return [];
|
|
11604
|
+
const procedure = procedurePathOf$1(command);
|
|
10643
11605
|
const capability = capabilities.find(({ cli }) => cli?.path === path);
|
|
10644
11606
|
if (capability === void 0 && procedure === null && command.commands.length > 0) return [];
|
|
10645
11607
|
return [{
|
|
@@ -10657,7 +11619,7 @@ const commandRecords = (program, catalog) => {
|
|
|
10657
11619
|
return {
|
|
10658
11620
|
flags: option.flags,
|
|
10659
11621
|
description: option.description,
|
|
10660
|
-
required: requirement !== void 0 || option.mandatory,
|
|
11622
|
+
required: requirement !== void 0 || option.mandatory || isRequiredSpelling(option),
|
|
10661
11623
|
...typeof requirement === "string" && { requiredUnless: requirement },
|
|
10662
11624
|
...option.defaultValue !== void 0 && { defaultValue: option.defaultValue }
|
|
10663
11625
|
};
|
|
@@ -10669,9 +11631,10 @@ const commandRecords = (program, catalog) => {
|
|
|
10669
11631
|
});
|
|
10670
11632
|
};
|
|
10671
11633
|
const registerCommandsProgram = (program, output, catalog) => {
|
|
10672
|
-
program.command("commands").description("Emit the command inventory as NDJSON without walking the help tree.").option("--namespace <path>", "Keep commands at or below this space-separated path.").option("--capabilities", "Emit the transport-neutral capability inventory.", false).option("--reference", "Emit complete shared capability contracts for documentation.", false).option("--records", "Emit the complete contract of each listed command for documentation.", false).action((options) => {
|
|
11634
|
+
program.command("commands").description("Emit the command inventory as NDJSON without walking the help tree.").option("--namespace <path>", "Keep commands at or below this space-separated path, in every mode.").option("--capabilities", "Emit the transport-neutral capability inventory.", false).option("--reference", "Emit complete shared capability contracts for documentation.", false).option("--records", "Emit the complete contract of each listed command for documentation.", false).action((options) => {
|
|
11635
|
+
const isListed = withinNamespace(options.namespace);
|
|
10673
11636
|
if (options.reference) {
|
|
10674
|
-
const shared = toSharedCapabilities(catalog());
|
|
11637
|
+
const shared = toSharedCapabilities(catalog.all()).filter(({ cli }) => isListed(cli?.path));
|
|
10675
11638
|
const discovery = createMcpCapabilityDiscoveryAdapter(shared);
|
|
10676
11639
|
output.result({
|
|
10677
11640
|
items: shared.map((capability) => toReferenceRecord(capability, discovery)),
|
|
@@ -10681,20 +11644,20 @@ const registerCommandsProgram = (program, output, catalog) => {
|
|
|
10681
11644
|
}
|
|
10682
11645
|
if (options.records) {
|
|
10683
11646
|
output.result({
|
|
10684
|
-
items: commandRecords(program, catalog),
|
|
11647
|
+
items: commandRecords(program, catalog, isListed),
|
|
10685
11648
|
truncated: false
|
|
10686
11649
|
});
|
|
10687
11650
|
return;
|
|
10688
11651
|
}
|
|
10689
11652
|
if (options.capabilities) {
|
|
11653
|
+
const listed = catalog.all().filter(({ cli }) => isListed(cli?.path));
|
|
10690
11654
|
output.result({
|
|
10691
|
-
items: toCapabilityInventory(
|
|
11655
|
+
items: toCapabilityInventory(listed),
|
|
10692
11656
|
truncated: false
|
|
10693
11657
|
});
|
|
10694
11658
|
return;
|
|
10695
11659
|
}
|
|
10696
|
-
const
|
|
10697
|
-
const records = recordsFrom(program).filter((record) => prefix === void 0 || record.path === prefix || record.path.startsWith(`${prefix} `));
|
|
11660
|
+
const records = recordsFrom(program).filter((record) => isListed(record.path));
|
|
10698
11661
|
output.result({
|
|
10699
11662
|
items: records,
|
|
10700
11663
|
truncated: false
|
|
@@ -10704,12 +11667,19 @@ const registerCommandsProgram = (program, output, catalog) => {
|
|
|
10704
11667
|
|
|
10705
11668
|
//#endregion
|
|
10706
11669
|
//#region src/infrastructure/comment.program.ts
|
|
11670
|
+
const canvasGiven = (argument, option) => {
|
|
11671
|
+
if (argument !== void 0 && option !== void 0) throw new CliError("BAD_REQUEST", "The canvas was given twice: as the argument and as --canvas.", "Pass the canvas once.");
|
|
11672
|
+
const reference = argument ?? option;
|
|
11673
|
+
if (reference === void 0) throw new CliError("BAD_REQUEST", "--canvas is required.", "Pass --canvas with a canvas URL or id, or --canvas-id with the id alone.");
|
|
11674
|
+
return reference;
|
|
11675
|
+
};
|
|
10707
11676
|
const registerCommentProgram = (program, invocation, catalog, output) => {
|
|
10708
11677
|
const comment = program.commands.find((command) => command.name() === "comment");
|
|
10709
11678
|
if (comment === void 0) throw new TypeError("derived comment namespace is missing");
|
|
10710
|
-
comment.command("attention").description("List every open comment needing attention; source metadata is included when a capture has it.").argument("
|
|
11679
|
+
comment.command("attention").description("List every open comment needing attention; source metadata is included when a capture has it.").argument("[canvas-url-or-id]", "A pasted Enhance canvas URL shaped /c/<UUID>, or a bare canvas UUID. --canvas is also accepted.").option("--canvas <url-or-id>", "Canvas URL or UUID, in place of the argument.").action(async (argument, options) => {
|
|
11680
|
+
const reference = canvasGiven(argument, options.canvas);
|
|
10711
11681
|
output.result(await invocation.invoke({
|
|
10712
|
-
capability:
|
|
11682
|
+
capability: catalog.one("comment.attention"),
|
|
10713
11683
|
arguments: { canvasId: fromCanvasReference(reference) },
|
|
10714
11684
|
clientToken: null
|
|
10715
11685
|
}));
|
|
@@ -10720,12 +11690,13 @@ const registerCommentProgram = (program, invocation, catalog, output) => {
|
|
|
10720
11690
|
//#region src/infrastructure/doctor.program.ts
|
|
10721
11691
|
const registerDoctorProgram = (program, dependencies) => {
|
|
10722
11692
|
const { version, credentials, remote, output } = dependencies;
|
|
10723
|
-
program.command("doctor").description("Check the installed binary, API reachability, and credential file without changes.").action(async () => {
|
|
11693
|
+
program.command("doctor").description("Check the installed binary, its Node, API reachability, and credential file without changes.").action(async () => {
|
|
10724
11694
|
const [health, token] = await Promise.all([remote.health(), credentials.read()]);
|
|
10725
11695
|
output.result({
|
|
10726
11696
|
status: token !== null && health.reachable ? "ok" : "degraded",
|
|
10727
11697
|
binary: process.argv[1] ?? "enhance",
|
|
10728
11698
|
version,
|
|
11699
|
+
node: process.versions.node,
|
|
10729
11700
|
api: health,
|
|
10730
11701
|
credential: {
|
|
10731
11702
|
path: credentials.path,
|
|
@@ -10811,12 +11782,264 @@ const registerFixtureProgram = (program, composites, output) => {
|
|
|
10811
11782
|
registerWorldFixture(fixture, composites.world, output);
|
|
10812
11783
|
};
|
|
10813
11784
|
|
|
11785
|
+
//#endregion
|
|
11786
|
+
//#region src/infrastructure/input-help.program.ts
|
|
11787
|
+
/** The longest help a command made from an API procedure may print, and any other command. */
|
|
11788
|
+
const PROCEDURE_HELP_LIMIT = 2500;
|
|
11789
|
+
const UTILITY_HELP_LIMIT = 3200;
|
|
11790
|
+
const BOUNDS = {
|
|
11791
|
+
flag: "--bounds",
|
|
11792
|
+
schema: canvasWorldBoundsSchema$1
|
|
11793
|
+
};
|
|
11794
|
+
/** The JSON flags of each hand-written command. A command made from a procedure needs no row. */
|
|
11795
|
+
const JSON_FLAGS = {
|
|
11796
|
+
"canvas apply": [{
|
|
11797
|
+
flag: "--operations",
|
|
11798
|
+
capability: "canvas.apply",
|
|
11799
|
+
field: "operations"
|
|
11800
|
+
}],
|
|
11801
|
+
"canvas edit": [{
|
|
11802
|
+
flag: "--edits",
|
|
11803
|
+
capability: "canvas.edit",
|
|
11804
|
+
field: "edits"
|
|
11805
|
+
}],
|
|
11806
|
+
"canvas set-text-content": [{
|
|
11807
|
+
flag: "--updates",
|
|
11808
|
+
schema: textUpdatesSchema
|
|
11809
|
+
}],
|
|
11810
|
+
"canvas rename-nodes": [{
|
|
11811
|
+
flag: "--updates",
|
|
11812
|
+
schema: renameUpdatesSchema
|
|
11813
|
+
}],
|
|
11814
|
+
"canvas update-styles": [{
|
|
11815
|
+
flag: "--updates",
|
|
11816
|
+
schema: styleUpdatesSchema
|
|
11817
|
+
}],
|
|
11818
|
+
"canvas delete-nodes": [{
|
|
11819
|
+
flag: "--node-ids",
|
|
11820
|
+
schema: nodeIdsSchema
|
|
11821
|
+
}],
|
|
11822
|
+
"canvas get-computed-styles": [{
|
|
11823
|
+
flag: "--node-ids",
|
|
11824
|
+
schema: nodeIdsSchema
|
|
11825
|
+
}],
|
|
11826
|
+
"canvas duplicate-nodes": [{
|
|
11827
|
+
flag: "--input",
|
|
11828
|
+
capability: "canvas.duplicateNodes"
|
|
11829
|
+
}, {
|
|
11830
|
+
flag: "--nodes",
|
|
11831
|
+
schema: duplicateInputsSchema
|
|
11832
|
+
}],
|
|
11833
|
+
"canvas move-nodes": [{
|
|
11834
|
+
flag: "--moves",
|
|
11835
|
+
schema: moveInputsSchema
|
|
11836
|
+
}],
|
|
11837
|
+
"canvas create-artboard": [{
|
|
11838
|
+
flag: "--styles",
|
|
11839
|
+
schema: styleObjectSchema
|
|
11840
|
+
}],
|
|
11841
|
+
"canvas render": [{
|
|
11842
|
+
flag: "--input",
|
|
11843
|
+
schema: canvasRenderScopedInputSchema,
|
|
11844
|
+
capability: "canvas.render"
|
|
11845
|
+
}, BOUNDS],
|
|
11846
|
+
"canvas work begin": [BOUNDS],
|
|
11847
|
+
"canvas work update": [BOUNDS],
|
|
11848
|
+
"canvas find": [{
|
|
11849
|
+
flag: "--input",
|
|
11850
|
+
capability: "canvas.find"
|
|
11851
|
+
}],
|
|
11852
|
+
"canvas read": [{
|
|
11853
|
+
flag: "--input",
|
|
11854
|
+
schema: canvasReadInputSchema,
|
|
11855
|
+
capability: "canvas.read"
|
|
11856
|
+
}],
|
|
11857
|
+
"canvas remove": [{
|
|
11858
|
+
flag: "--input",
|
|
11859
|
+
capability: "canvas.remove"
|
|
11860
|
+
}],
|
|
11861
|
+
"canvas update-html": [{
|
|
11862
|
+
flag: "--input",
|
|
11863
|
+
capability: "canvas.updateHtml"
|
|
11864
|
+
}],
|
|
11865
|
+
"canvas publish-prototype": [{
|
|
11866
|
+
flag: "--input",
|
|
11867
|
+
capability: "prototype.publishCanvas"
|
|
11868
|
+
}],
|
|
11869
|
+
"canvas import-asset": [{
|
|
11870
|
+
flag: "--input",
|
|
11871
|
+
capability: "canvas.importAsset"
|
|
11872
|
+
}],
|
|
11873
|
+
"canvas insert-html": [{
|
|
11874
|
+
flag: "--input",
|
|
11875
|
+
capability: "canvas.insertHtml"
|
|
11876
|
+
}],
|
|
11877
|
+
"canvas make-editable": [{
|
|
11878
|
+
flag: "--input",
|
|
11879
|
+
capability: "canvas.makeEditable"
|
|
11880
|
+
}],
|
|
11881
|
+
"canvas capture": [{
|
|
11882
|
+
flag: "--input",
|
|
11883
|
+
capability: "canvas.capture"
|
|
11884
|
+
}],
|
|
11885
|
+
"canvas capture-page": [{
|
|
11886
|
+
flag: "--input",
|
|
11887
|
+
capability: "canvas.capturePage"
|
|
11888
|
+
}],
|
|
11889
|
+
"canvas arrange": [{
|
|
11890
|
+
flag: "--input",
|
|
11891
|
+
capability: "canvas.arrange"
|
|
11892
|
+
}],
|
|
11893
|
+
"operation status": [{
|
|
11894
|
+
flag: "--input",
|
|
11895
|
+
capability: "operation.status"
|
|
11896
|
+
}]
|
|
11897
|
+
};
|
|
11898
|
+
const capabilityOf = (find, id) => {
|
|
11899
|
+
const capability = find(id);
|
|
11900
|
+
if (capability === void 0) throw new TypeError(`${id} is missing from the capability catalogue`);
|
|
11901
|
+
return capability;
|
|
11902
|
+
};
|
|
11903
|
+
const jsonSchemaOf = (schema) => z.toJSONSchema(schema, {
|
|
11904
|
+
unrepresentable: "any",
|
|
11905
|
+
io: "input"
|
|
11906
|
+
});
|
|
11907
|
+
/** The schema a hand-written command checks the value of one JSON flag against. */
|
|
11908
|
+
const jsonFlagSchemaOf = (source, find) => {
|
|
11909
|
+
if ("schema" in source) return source.schema;
|
|
11910
|
+
const input = capabilityOf(find, source.capability).inputSchema;
|
|
11911
|
+
if (source.field === void 0) return input;
|
|
11912
|
+
const field = input instanceof z.ZodObject ? input.shape[source.field] : void 0;
|
|
11913
|
+
if (!(field instanceof z.ZodType)) throw new TypeError(`${source.capability} has no input field ${source.field}`);
|
|
11914
|
+
return field;
|
|
11915
|
+
};
|
|
11916
|
+
/** One field's schema, still able to follow a reference into the input it was taken from. */
|
|
11917
|
+
const fieldSchemaOf = (input, field) => {
|
|
11918
|
+
const properties = input["properties"];
|
|
11919
|
+
const held = typeof properties === "object" && properties !== null ? Reflect.get(properties, field) : void 0;
|
|
11920
|
+
return typeof held === "object" && held !== null ? {
|
|
11921
|
+
...held,
|
|
11922
|
+
$defs: input["$defs"]
|
|
11923
|
+
} : held;
|
|
11924
|
+
};
|
|
11925
|
+
const describedFlag = (source, find) => ({
|
|
11926
|
+
flag: source.flag,
|
|
11927
|
+
schema: jsonSchemaOf(jsonFlagSchemaOf(source, find)),
|
|
11928
|
+
fields: "schema" in source || source.field !== void 0 ? [] : capabilityOf(find, source.capability).guide.input
|
|
11929
|
+
});
|
|
11930
|
+
const procedurePathOf = (command) => {
|
|
11931
|
+
const details = Reflect.get(command, "__trpcCli");
|
|
11932
|
+
const path = typeof details === "object" && details !== null ? Reflect.get(details, "path") : void 0;
|
|
11933
|
+
return typeof path === "string" ? path : null;
|
|
11934
|
+
};
|
|
11935
|
+
/** The flags of a command made from a procedure whose value is a JSON object or a list of them. */
|
|
11936
|
+
const procedureFlags = (command, capability) => {
|
|
11937
|
+
const input = jsonSchemaOf(capability.inputSchema);
|
|
11938
|
+
const properties = input["properties"];
|
|
11939
|
+
if (typeof properties !== "object" || properties === null) return [];
|
|
11940
|
+
return Object.keys(properties).flatMap((name) => {
|
|
11941
|
+
const flag = `--${toKebabCase(name)}`;
|
|
11942
|
+
const schema = fieldSchemaOf(input, name);
|
|
11943
|
+
return command.options.some((option) => option.long === flag) && isJsonValued(schema) ? [{
|
|
11944
|
+
flag,
|
|
11945
|
+
schema,
|
|
11946
|
+
fields: []
|
|
11947
|
+
}] : [];
|
|
11948
|
+
});
|
|
11949
|
+
};
|
|
11950
|
+
const inputOf = (command, path, find) => {
|
|
11951
|
+
const sources = JSON_FLAGS[path];
|
|
11952
|
+
if (sources !== void 0) {
|
|
11953
|
+
const owner = sources.find((source) => source.capability !== void 0)?.capability;
|
|
11954
|
+
return {
|
|
11955
|
+
flags: sources.map((source) => describedFlag(source, find)),
|
|
11956
|
+
capability: owner === void 0 ? null : capabilityOf(find, owner)
|
|
11957
|
+
};
|
|
11958
|
+
}
|
|
11959
|
+
const procedure = procedurePathOf(command);
|
|
11960
|
+
const capability = procedure === null ? void 0 : find(procedure);
|
|
11961
|
+
if (capability === void 0) return null;
|
|
11962
|
+
const flags = procedureFlags(command, capability);
|
|
11963
|
+
return flags.length === 0 ? null : {
|
|
11964
|
+
flags,
|
|
11965
|
+
capability
|
|
11966
|
+
};
|
|
11967
|
+
};
|
|
11968
|
+
const rootOf = (command) => command.parent === null ? command : rootOf(command.parent);
|
|
11969
|
+
/**
|
|
11970
|
+
* The writers of the help texts already added after a command's options. Commander keeps each as
|
|
11971
|
+
* a listener on the command, which is an event emitter its types do not show.
|
|
11972
|
+
*/
|
|
11973
|
+
const helpWritersOf = (command) => {
|
|
11974
|
+
const listeners = Reflect.get(command, "listeners");
|
|
11975
|
+
if (typeof listeners !== "function") return [];
|
|
11976
|
+
const held = Reflect.apply(listeners, command, ["afterHelp"]);
|
|
11977
|
+
return Array.isArray(held) ? held.filter((writer) => typeof writer === "function") : [];
|
|
11978
|
+
};
|
|
11979
|
+
/** What those writers print, to count its length against the help limit. */
|
|
11980
|
+
const textAfterOptions = (command, writers) => {
|
|
11981
|
+
const parts = [];
|
|
11982
|
+
const context = {
|
|
11983
|
+
error: false,
|
|
11984
|
+
command,
|
|
11985
|
+
write: (part) => {
|
|
11986
|
+
parts.push(part);
|
|
11987
|
+
}
|
|
11988
|
+
};
|
|
11989
|
+
for (const write of writers) write(context);
|
|
11990
|
+
return parts.join("");
|
|
11991
|
+
};
|
|
11992
|
+
/** Every command of a program with its path, groups included. */
|
|
11993
|
+
const commandsOf = (command, path = []) => command.commands.flatMap((child) => {
|
|
11994
|
+
const childPath = [...path, child.name()];
|
|
11995
|
+
return [{
|
|
11996
|
+
command: child,
|
|
11997
|
+
path: childPath.join(" ")
|
|
11998
|
+
}, ...commandsOf(child, childPath)];
|
|
11999
|
+
});
|
|
12000
|
+
const inputHelpOf = (target, find) => {
|
|
12001
|
+
const { command, path, others } = target;
|
|
12002
|
+
const input = inputOf(command, path, find);
|
|
12003
|
+
if (input === null) return "";
|
|
12004
|
+
const binary = rootOf(command).name();
|
|
12005
|
+
const example = COMMAND_EXAMPLES[path];
|
|
12006
|
+
const cap = procedurePathOf(command) === null ? UTILITY_HELP_LIMIT : PROCEDURE_HELP_LIMIT;
|
|
12007
|
+
const commandOf = (id) => {
|
|
12008
|
+
const cliPath = find(id)?.cli?.path;
|
|
12009
|
+
return cliPath === void 0 ? id : `${binary} ${cliPath}`;
|
|
12010
|
+
};
|
|
12011
|
+
return toInputHelp({
|
|
12012
|
+
flags: input.flags,
|
|
12013
|
+
earlier: (input.capability?.earlierAnswers ?? []).map((sentence) => withCapabilityNames(sentence, commandOf)),
|
|
12014
|
+
example: example === void 0 ? null : `${binary} ${example}`,
|
|
12015
|
+
placeholders: COMMAND_EXAMPLE_PLACEHOLDERS[path] ?? null,
|
|
12016
|
+
limit: cap - command.helpInformation().length - textAfterOptions(command, others).length - 1,
|
|
12017
|
+
rest: `${binary} commands --records --namespace "${path}"`
|
|
12018
|
+
});
|
|
12019
|
+
};
|
|
12020
|
+
/**
|
|
12021
|
+
* Adds, after the options of each command that takes JSON in a flag, the fields of that JSON, the
|
|
12022
|
+
* call that gives an input an earlier answer supplies, and one example. The text is made when
|
|
12023
|
+
* help is asked for, from the command's capability record.
|
|
12024
|
+
*/
|
|
12025
|
+
const attachInputHelp = (program, catalog) => {
|
|
12026
|
+
for (const { command, path } of commandsOf(program)) {
|
|
12027
|
+
if (!(JSON_FLAGS[path] !== void 0 || procedurePathOf(command) !== null)) continue;
|
|
12028
|
+
const others = helpWritersOf(command);
|
|
12029
|
+
command.addHelpText("after", () => inputHelpOf({
|
|
12030
|
+
command,
|
|
12031
|
+
path,
|
|
12032
|
+
others
|
|
12033
|
+
}, catalog.find));
|
|
12034
|
+
}
|
|
12035
|
+
};
|
|
12036
|
+
|
|
10814
12037
|
//#endregion
|
|
10815
12038
|
//#region src/infrastructure/operation.program.ts
|
|
10816
12039
|
const registerOperationProgram = (program, input) => {
|
|
10817
12040
|
program.command("operation").description("Read existing domain-owned operation outcomes.").command("status").description("Recover an existing outcome without creating or resuming work.").requiredOption("--input <json-or-@path>", "Operation reference and optional detail offset/limit.").action(async (options) => {
|
|
10818
12041
|
input.output.result(await input.invocation.invoke({
|
|
10819
|
-
capability:
|
|
12042
|
+
capability: input.catalog.one("operation.status"),
|
|
10820
12043
|
arguments: createCanvasJsonInputAdapter(options.input, operationStatusInputSchema, "--input"),
|
|
10821
12044
|
clientToken: null
|
|
10822
12045
|
}));
|
|
@@ -10835,7 +12058,7 @@ const registerPrototypeProgram = (program, invocation, catalog, output) => {
|
|
|
10835
12058
|
(program.commands.find((command) => command.name() === "prototype") ?? program.command("prototype").description("Publish static frontend prototypes.")).command("publish").description("Package and publish an unpacked static build directory. The CLI creates the upload artifact. To update a prototype, publish to its owner node: pass --prototype-id and that node as --node-id. Any other node that shows it forks into its own prototype. An update keeps the title the node shows; --title only names a new node.").requiredOption("--canvas-id <uuid>", "Canvas that receives the prototype.").requiredOption("--directory <path>", "Unpacked static build directory; do not pass a ZIP file.").requiredOption("--title <title>", "Label above the prototype frame.").requiredOption("--base-version <number>", "Current canvas document version.", positiveInteger).option("--prototype-id <uuid>", "Existing prototype identity to publish a new deployment.").option("--client-token <uuid>", "Stable retry token for this exact build.").option("--node-id <id>", "Exact canvas node to create, update, or fork when it is a copy.").option("--entry <path>", "HTML entry relative to the uploaded directory.", "index.html").option("--x <pixels>", "Canvas x coordinate.", finiteNumber, DEFAULT_POSITION).option("--y <pixels>", "Canvas y coordinate.", finiteNumber, DEFAULT_POSITION).option("--width <pixels>", "Prototype viewport width.", positiveNumber, DEFAULT_WIDTH).option("--height <pixels>", "Prototype viewport height.", positiveNumber, DEFAULT_HEIGHT).action(async (options) => {
|
|
10836
12059
|
const clientToken = options.clientToken ?? randomUUID();
|
|
10837
12060
|
output.result(await invocation.invoke({
|
|
10838
|
-
capability:
|
|
12061
|
+
capability: catalog.one("prototype.publish"),
|
|
10839
12062
|
arguments: {
|
|
10840
12063
|
canvasId: options.canvasId,
|
|
10841
12064
|
prototypeId: options.prototypeId ?? null,
|
|
@@ -10872,7 +12095,7 @@ const registerRecordingProgram = (program, input) => {
|
|
|
10872
12095
|
const recordingId = z.uuid().safeParse(options.recordingId);
|
|
10873
12096
|
if (!token.success || !recordingId.success) throw new CliError("BAD_REQUEST", "The recording id or client token is not a UUID.", "Use the recording id from `recording list`; mint one client token per accepted moment.");
|
|
10874
12097
|
input.output.result(await input.invocation.invoke({
|
|
10875
|
-
capability:
|
|
12098
|
+
capability: input.catalog.one("recording.snapshot"),
|
|
10876
12099
|
arguments: {
|
|
10877
12100
|
canvasId: fromCanvasReference(options.canvas),
|
|
10878
12101
|
recordingId: recordingId.data,
|
|
@@ -10890,10 +12113,87 @@ const refuseDocumentConflict = (path, input, result) => {
|
|
|
10890
12113
|
if (path !== "canvas.document.save" || typeof result !== "object" || result === null || !("outcome" in result) || result.outcome !== "conflict") return result;
|
|
10891
12114
|
throw new CliError("CONFLICT", "The canvas document changed before this save landed.", `Run 'enhance canvas document get --canvas-id ${typeof input === "object" && input !== null && "canvasId" in input && typeof input.canvasId === "string" ? input.canvasId : "<canvas-id>"}', merge your change into that document, then retry with its version.`);
|
|
10892
12115
|
};
|
|
10893
|
-
const
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
12116
|
+
const INPUT_SUBJECT = "The input";
|
|
12117
|
+
/**
|
|
12118
|
+
* Checks a generated command's input with the schema the API checks it with, so every problem is
|
|
12119
|
+
* named before anything is sent. The input goes on as it was given: the API applies its own
|
|
12120
|
+
* defaults. A schema that cannot be checked here is left to the API.
|
|
12121
|
+
*/
|
|
12122
|
+
const checkedInput = (schema, input) => {
|
|
12123
|
+
if (!(schema instanceof z.ZodType)) return input;
|
|
12124
|
+
const read = withAcceptedSpellings(schema, input, INPUT_SUBJECT);
|
|
12125
|
+
const parsed = (() => {
|
|
12126
|
+
try {
|
|
12127
|
+
return schema.safeParse(read);
|
|
12128
|
+
} catch {
|
|
12129
|
+
return null;
|
|
12130
|
+
}
|
|
12131
|
+
})();
|
|
12132
|
+
if (parsed === null || parsed.success) return read;
|
|
12133
|
+
const refusal = inputRefusal({
|
|
12134
|
+
subject: INPUT_SUBJECT,
|
|
12135
|
+
error: parsed.error,
|
|
12136
|
+
checked: {
|
|
12137
|
+
schema,
|
|
12138
|
+
value: read
|
|
12139
|
+
},
|
|
12140
|
+
help: "Run the command with --help for every flag."
|
|
12141
|
+
});
|
|
12142
|
+
const flags = Object.keys(refusal.fields ?? {}).map((field) => field.split(".", 1)[0] ?? "").filter((field, index, all) => field !== "input" && all.indexOf(field) === index).map((field) => `--${toKebabCase(field)}`);
|
|
12143
|
+
throw new CliError(refusal.code, refusal.message, flags.length === 0 ? refusal.remediation : `${refusal.remediation} These are the flags ${flags.join(", ")}.`, refusal.fields);
|
|
12144
|
+
};
|
|
12145
|
+
const createRemoteRouterAdapter = (source, remote) => {
|
|
12146
|
+
const schemas = new Map(source.map(([path, info]) => [path, info.originalInputSchema]));
|
|
12147
|
+
return proxify(source, (path) => ({ [path]: {
|
|
12148
|
+
query: async (input) => remote.query(path, checkedInput(schemas.get(path), input)),
|
|
12149
|
+
mutate: async (input) => {
|
|
12150
|
+
const checked = checkedInput(schemas.get(path), input);
|
|
12151
|
+
return refuseDocumentConflict(path, checked, await remote.mutate(path, checked));
|
|
12152
|
+
}
|
|
12153
|
+
} }));
|
|
12154
|
+
};
|
|
12155
|
+
|
|
12156
|
+
//#endregion
|
|
12157
|
+
//#region src/infrastructure/setup.program.ts
|
|
12158
|
+
const MAX_TOKEN_LABEL_CHARACTERS = 120;
|
|
12159
|
+
const registerSetupProgram = (program, setup, output) => {
|
|
12160
|
+
program.command("setup").description("Sign in if nobody is, give each coding agent on this machine the Enhance skill, and say what to do next.").option("--token <token>", "Sign in with an existing agent token instead of the browser.").option("--no-open", "Print the sign-in address without opening the browser.").action(async (options) => {
|
|
12161
|
+
const answer = await setup.run({
|
|
12162
|
+
token: await readOptionalToken(options.token),
|
|
12163
|
+
label: `CLI on ${hostname()}`.slice(0, MAX_TOKEN_LABEL_CHARACTERS),
|
|
12164
|
+
openBrowser: options.open,
|
|
12165
|
+
onReady: (url) => {
|
|
12166
|
+
output.result({
|
|
12167
|
+
status: "waiting_for_browser",
|
|
12168
|
+
url,
|
|
12169
|
+
waiting: WAITING_FOR_BROWSER
|
|
12170
|
+
});
|
|
12171
|
+
}
|
|
12172
|
+
});
|
|
12173
|
+
output.result(answer);
|
|
12174
|
+
if (answer.status === "ready") return;
|
|
12175
|
+
throw answer.signedIn === null ? new CliError("UNAUTHORIZED", `Setup is not finished: ${answer.signInProblem ?? "nobody is signed in."}`, "Run 'enhance auth login', then 'enhance setup' again.") : new CliError("INTERNAL", `Setup is not finished: the skill could not be written to ${answer.skill.notWritten.map(({ file }) => file).join(", ")}.`, "Make that folder writable, then run 'enhance setup' again.");
|
|
12176
|
+
});
|
|
12177
|
+
};
|
|
12178
|
+
|
|
12179
|
+
//#endregion
|
|
12180
|
+
//#region src/infrastructure/skill-command.lib.ts
|
|
12181
|
+
const realFileOf = (file) => {
|
|
12182
|
+
try {
|
|
12183
|
+
return realpathSync(file);
|
|
12184
|
+
} catch {
|
|
12185
|
+
return null;
|
|
12186
|
+
}
|
|
12187
|
+
};
|
|
12188
|
+
/**
|
|
12189
|
+
* How a skill should name the tool so an agent's shell can run it: the bare command when the PATH
|
|
12190
|
+
* leads to this tool, and this tool's full path when it leads nowhere or to another install.
|
|
12191
|
+
*/
|
|
12192
|
+
const skillCommandOf = (commandName, machine) => {
|
|
12193
|
+
if (machine.entry === void 0) return commandName;
|
|
12194
|
+
const found = machine.searchPath.split(path.delimiter).filter((folder) => folder !== "").map((folder) => realFileOf(path.join(folder, commandName))).find((file) => file !== null);
|
|
12195
|
+
return found !== void 0 && found === realFileOf(machine.entry) ? commandName : machine.entry;
|
|
12196
|
+
};
|
|
10897
12197
|
|
|
10898
12198
|
//#endregion
|
|
10899
12199
|
//#region src/infrastructure/transcript.program.ts
|
|
@@ -10904,7 +12204,7 @@ const registerTranscriptProgram = (program, input) => {
|
|
|
10904
12204
|
const recordingId = z.uuid().safeParse(options.recordingId);
|
|
10905
12205
|
if (!recordingId.success) throw new CliError("BAD_REQUEST", "--recording-id must be a UUID.", "Use the recording id returned by `enhance recording list`.");
|
|
10906
12206
|
input.output.result(await input.invocation.invoke({
|
|
10907
|
-
capability:
|
|
12207
|
+
capability: input.catalog.one("transcript.read"),
|
|
10908
12208
|
arguments: {
|
|
10909
12209
|
canvasId: fromCanvasReference(options.canvas),
|
|
10910
12210
|
recordingId: recordingId.data
|
|
@@ -10951,12 +12251,18 @@ const cliMetadataFrom = (procedures) => {
|
|
|
10951
12251
|
mutationPaths: new Set(procedures.flatMap(([path, info]) => info.type === "mutation" ? [path] : []))
|
|
10952
12252
|
};
|
|
10953
12253
|
};
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
12254
|
+
/** Signing in, and the setup that signs in and gives each coding agent the skill. */
|
|
12255
|
+
const registerSignInPrograms = (program, input) => {
|
|
12256
|
+
const auth = createAuthUseCase(input.credentials, input.remote, createOauthLoopbackAdapter(input.remote));
|
|
12257
|
+
registerAuthProgram(program, auth, input.output);
|
|
12258
|
+
registerSetupProgram(program, createSetupUseCase({
|
|
12259
|
+
auth,
|
|
12260
|
+
skills: createAgentSkillFoldersAdapter(input.machine.homeDirectory),
|
|
12261
|
+
skill: () => captureSkillOf({
|
|
12262
|
+
commandName: input.commandName,
|
|
12263
|
+
command: skillCommandOf(input.commandName, input.machine)
|
|
12264
|
+
})
|
|
12265
|
+
}), input.output);
|
|
10960
12266
|
};
|
|
10961
12267
|
const registerUtilityPrograms = (program, input, catalog) => {
|
|
10962
12268
|
const screen = createScreenFixtureComposite(input.remote);
|
|
@@ -10967,7 +12273,7 @@ const registerUtilityPrograms = (program, input, catalog) => {
|
|
|
10967
12273
|
now: () => /* @__PURE__ */ new Date(),
|
|
10968
12274
|
progress: input.output.result
|
|
10969
12275
|
});
|
|
10970
|
-
|
|
12276
|
+
registerSignInPrograms(program, input);
|
|
10971
12277
|
registerCommentProgram(program, invocation, catalog, input.output);
|
|
10972
12278
|
registerCapturesProgram(program, input);
|
|
10973
12279
|
registerOperationProgram(program, {
|
|
@@ -11008,9 +12314,20 @@ const registerUtilityPrograms = (program, input, catalog) => {
|
|
|
11008
12314
|
output: input.output
|
|
11009
12315
|
});
|
|
11010
12316
|
};
|
|
12317
|
+
/**
|
|
12318
|
+
* Whether the command that ran answered with nothing. trpc-cli prints no line for such an answer
|
|
12319
|
+
* and keeps it on the command, so the tool prints the `null` itself.
|
|
12320
|
+
*/
|
|
12321
|
+
const ranWithNoAnswer = (program) => {
|
|
12322
|
+
const ran = Reflect.get(program, "__ran");
|
|
12323
|
+
const last = Array.isArray(ran) ? ran.at(-1) : void 0;
|
|
12324
|
+
if (typeof last !== "object" || last === null) return false;
|
|
12325
|
+
const answer = Reflect.get(last, "__result");
|
|
12326
|
+
return answer === null || answer === void 0;
|
|
12327
|
+
};
|
|
11011
12328
|
const createCliProgram = (input) => {
|
|
11012
12329
|
const procedures = parseRouter({ router: createRouterShapeAdapter() });
|
|
11013
|
-
const catalog =
|
|
12330
|
+
const catalog = createLazyCapabilityCatalogAdapter();
|
|
11014
12331
|
const { descriptions, mutationPaths } = cliMetadataFrom(procedures);
|
|
11015
12332
|
const cli = createCli({
|
|
11016
12333
|
router: createRemoteRouterAdapter(procedures, input.remote),
|
|
@@ -11031,6 +12348,7 @@ const createCliProgram = (input) => {
|
|
|
11031
12348
|
output: input.output
|
|
11032
12349
|
});
|
|
11033
12350
|
built.description("Operate Enhance as the authenticated person.");
|
|
12351
|
+
attachInputHelp(built, catalog);
|
|
11034
12352
|
const failureState = input.state;
|
|
11035
12353
|
return {
|
|
11036
12354
|
program: built,
|
|
@@ -11039,6 +12357,7 @@ const createCliProgram = (input) => {
|
|
|
11039
12357
|
await cli.run(runParams, built);
|
|
11040
12358
|
} catch (error) {
|
|
11041
12359
|
if (!(error instanceof ProcessExitError)) throw error;
|
|
12360
|
+
if (error.requestedCode === 0 && ranWithNoAnswer(built)) input.output.result(null);
|
|
11042
12361
|
if (error.requestedCode !== 0 && failureState.pendingParserMessage !== null) {
|
|
11043
12362
|
const failure = toFailurePayload(error, failureState.pendingParserMessage);
|
|
11044
12363
|
failureState.exitCode = toExitCode(failure, true);
|
|
@@ -11055,17 +12374,48 @@ const createCliProgram = (input) => {
|
|
|
11055
12374
|
//#region src/infrastructure/exit-process.lib.ts
|
|
11056
12375
|
const exitProcess = (code) => process.exit(code);
|
|
11057
12376
|
|
|
12377
|
+
//#endregion
|
|
12378
|
+
//#region src/infrastructure/sensitive-file.lib.ts
|
|
12379
|
+
const SENSITIVE_FILE_TTL_MS = 36e5;
|
|
12380
|
+
const DIRECTORY_MODE = 448;
|
|
12381
|
+
const FILE_MODE = 384;
|
|
12382
|
+
const prepareSensitiveDirectory = (directory) => {
|
|
12383
|
+
mkdirSync(directory, {
|
|
12384
|
+
recursive: true,
|
|
12385
|
+
mode: DIRECTORY_MODE
|
|
12386
|
+
});
|
|
12387
|
+
chmodSync(directory, DIRECTORY_MODE);
|
|
12388
|
+
};
|
|
12389
|
+
const sensitiveReference = (fields) => ({
|
|
12390
|
+
...fields,
|
|
12391
|
+
sensitive: true,
|
|
12392
|
+
cleanup: "unlink-after-use",
|
|
12393
|
+
deleteAfter: new Date(Date.now() + SENSITIVE_FILE_TTL_MS).toISOString()
|
|
12394
|
+
});
|
|
12395
|
+
/** Writes one record to a protected file of its own, and answers with what names that file. */
|
|
12396
|
+
const sensitiveRecordFile = (directory, record) => {
|
|
12397
|
+
prepareSensitiveDirectory(directory);
|
|
12398
|
+
const outputPath = path.join(directory, `result-${randomUUID()}.ndjson`);
|
|
12399
|
+
const body = `${JSON.stringify(record)}\n`;
|
|
12400
|
+
writeFileSync(outputPath, body, {
|
|
12401
|
+
mode: 384,
|
|
12402
|
+
flag: "wx"
|
|
12403
|
+
});
|
|
12404
|
+
return sensitiveReference({
|
|
12405
|
+
path: outputPath,
|
|
12406
|
+
characters: body.length,
|
|
12407
|
+
records: 1
|
|
12408
|
+
});
|
|
12409
|
+
};
|
|
12410
|
+
|
|
11058
12411
|
//#endregion
|
|
11059
12412
|
//#region src/infrastructure/ndjson.logger.ts
|
|
11060
12413
|
const MAX_INLINE_CHARACTERS = 25e3;
|
|
11061
12414
|
const MAX_LINE_CHARACTERS = 2e3;
|
|
11062
12415
|
const DIGEST_CHARACTERS = 16;
|
|
11063
|
-
const SENSITIVE_FILE_TTL_MS = 36e5;
|
|
11064
|
-
const DIRECTORY_MODE = 448;
|
|
11065
|
-
const FILE_MODE = 384;
|
|
11066
12416
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11067
12417
|
const linesFor = (value) => {
|
|
11068
|
-
if (Array.isArray(value)) return value.map((entry) => JSON.stringify(entry));
|
|
12418
|
+
if (Array.isArray(value)) return value.length === 0 ? ["[]"] : value.map((entry) => JSON.stringify(entry));
|
|
11069
12419
|
if (!isObject(value) || !Array.isArray(value["items"])) return [JSON.stringify(value)];
|
|
11070
12420
|
if ("nextCursor" in value) return [JSON.stringify(value)];
|
|
11071
12421
|
const items = value["items"];
|
|
@@ -11087,7 +12437,7 @@ const writeLines = (lines) => {
|
|
|
11087
12437
|
}
|
|
11088
12438
|
const reference = createHash("sha256").update(body).digest("hex").slice(0, DIGEST_CHARACTERS);
|
|
11089
12439
|
const outputPath = path.join(tmpdir(), `enhance-${reference}.ndjson`);
|
|
11090
|
-
writeFileSync(outputPath, body, { mode:
|
|
12440
|
+
writeFileSync(outputPath, body, { mode: 384 });
|
|
11091
12441
|
process.stdout.write(`${JSON.stringify({
|
|
11092
12442
|
path: outputPath,
|
|
11093
12443
|
characters: body.length,
|
|
@@ -11110,13 +12460,6 @@ const hasSignedUrl = (value) => {
|
|
|
11110
12460
|
if (!isObject(value)) return false;
|
|
11111
12461
|
return Object.values(value).some((entry) => hasSignedUrl(entry));
|
|
11112
12462
|
};
|
|
11113
|
-
const prepareSensitiveDirectory = (directory) => {
|
|
11114
|
-
mkdirSync(directory, {
|
|
11115
|
-
recursive: true,
|
|
11116
|
-
mode: DIRECTORY_MODE
|
|
11117
|
-
});
|
|
11118
|
-
chmodSync(directory, DIRECTORY_MODE);
|
|
11119
|
-
};
|
|
11120
12463
|
const sweepExpiredSensitiveFiles = (directory) => {
|
|
11121
12464
|
if (!existsSync(directory)) return;
|
|
11122
12465
|
const staleBefore = Date.now() - SENSITIVE_FILE_TTL_MS;
|
|
@@ -11127,19 +12470,13 @@ const sweepExpiredSensitiveFiles = (directory) => {
|
|
|
11127
12470
|
if (lstatSync(candidate).mtimeMs < staleBefore) unlinkSync(candidate);
|
|
11128
12471
|
}
|
|
11129
12472
|
};
|
|
11130
|
-
const sensitiveReference = (fields) => ({
|
|
11131
|
-
...fields,
|
|
11132
|
-
sensitive: true,
|
|
11133
|
-
cleanup: "unlink-after-use",
|
|
11134
|
-
deleteAfter: new Date(Date.now() + SENSITIVE_FILE_TTL_MS).toISOString()
|
|
11135
|
-
});
|
|
11136
12473
|
const writeSignedUrlResult = (value, sensitiveDirectory) => {
|
|
11137
12474
|
const lines = linesFor(value);
|
|
11138
12475
|
const body = `${lines.join("\n")}\n`;
|
|
11139
12476
|
prepareSensitiveDirectory(sensitiveDirectory);
|
|
11140
12477
|
const outputPath = path.join(sensitiveDirectory, `result-${randomUUID()}.ndjson`);
|
|
11141
12478
|
writeFileSync(outputPath, body, {
|
|
11142
|
-
mode:
|
|
12479
|
+
mode: 384,
|
|
11143
12480
|
flag: "wx"
|
|
11144
12481
|
});
|
|
11145
12482
|
process.stdout.write(`${JSON.stringify(sensitiveReference({
|
|
@@ -11166,7 +12503,7 @@ const writeSensitiveResult = (value, secret, sensitiveDirectory) => {
|
|
|
11166
12503
|
prepareSensitiveDirectory(sensitiveDirectory);
|
|
11167
12504
|
const outputPath = path.join(sensitiveDirectory, `result-${randomUUID()}.token`);
|
|
11168
12505
|
writeFileSync(outputPath, body, {
|
|
11169
|
-
mode:
|
|
12506
|
+
mode: 384,
|
|
11170
12507
|
flag: "wx"
|
|
11171
12508
|
});
|
|
11172
12509
|
const safe = Object.fromEntries(Object.entries(value).filter(([field]) => field !== secret.field));
|
|
@@ -11179,6 +12516,24 @@ const writeSensitiveResult = (value, secret, sensitiveDirectory) => {
|
|
|
11179
12516
|
})
|
|
11180
12517
|
})}\n`);
|
|
11181
12518
|
};
|
|
12519
|
+
/** The source a render answered with, when the answer is a rendered picture that carries one. */
|
|
12520
|
+
const renderSourceOf = (value) => {
|
|
12521
|
+
if (!isObject(value) || value["contentType"] !== "image/png") return null;
|
|
12522
|
+
if (typeof value["picture"] !== "string") return null;
|
|
12523
|
+
const source = value["source"];
|
|
12524
|
+
return isObject(source) && source["status"] === "available" ? source : null;
|
|
12525
|
+
};
|
|
12526
|
+
/**
|
|
12527
|
+
* A render's answer names its picture; the layer's source, which is long, goes to a file of its own
|
|
12528
|
+
* that the answer names as `source`. Printed whole, the source pushed the answer into a file and
|
|
12529
|
+
* the picture's path out of sight.
|
|
12530
|
+
*/
|
|
12531
|
+
const writeRenderResult = (value, source, sensitiveDirectory) => {
|
|
12532
|
+
writeLines([JSON.stringify({
|
|
12533
|
+
...value,
|
|
12534
|
+
source: sensitiveRecordFile(sensitiveDirectory, source)
|
|
12535
|
+
})]);
|
|
12536
|
+
};
|
|
11182
12537
|
const isHelpText = (value) => value.includes("Usage:") || value.includes("Options:") || value.includes("Commands:");
|
|
11183
12538
|
const failureSchema = appErrorSchema$1.omit({ fields: true }).extend({
|
|
11184
12539
|
remediation: z.string(),
|
|
@@ -11218,27 +12573,18 @@ const writeResult = (value, sensitiveDirectory) => {
|
|
|
11218
12573
|
}
|
|
11219
12574
|
const authoring = toCanvasAuthoringResult(value);
|
|
11220
12575
|
if (authoring !== null) {
|
|
11221
|
-
|
|
11222
|
-
if (authoring.detail !== null) {
|
|
11223
|
-
prepareSensitiveDirectory(sensitiveDirectory);
|
|
11224
|
-
const outputPath = path.join(sensitiveDirectory, `result-${randomUUID()}.ndjson`);
|
|
11225
|
-
const body = `${JSON.stringify(authoring.detail)}\n`;
|
|
11226
|
-
writeFileSync(outputPath, body, {
|
|
11227
|
-
mode: FILE_MODE,
|
|
11228
|
-
flag: "wx"
|
|
11229
|
-
});
|
|
11230
|
-
detail = sensitiveReference({
|
|
11231
|
-
path: outputPath,
|
|
11232
|
-
characters: body.length,
|
|
11233
|
-
records: 1
|
|
11234
|
-
});
|
|
11235
|
-
}
|
|
12576
|
+
const detail = authoring.detail === null ? null : sensitiveRecordFile(sensitiveDirectory, authoring.detail);
|
|
11236
12577
|
process.stdout.write(`${JSON.stringify({
|
|
11237
12578
|
...authoring.value,
|
|
11238
12579
|
...detail !== null && { detail }
|
|
11239
12580
|
})}\n`);
|
|
11240
12581
|
return;
|
|
11241
12582
|
}
|
|
12583
|
+
const renderSource = renderSourceOf(value);
|
|
12584
|
+
if (renderSource !== null && isObject(value)) {
|
|
12585
|
+
writeRenderResult(value, renderSource, sensitiveDirectory);
|
|
12586
|
+
return;
|
|
12587
|
+
}
|
|
11242
12588
|
writeLines(linesFor(value));
|
|
11243
12589
|
};
|
|
11244
12590
|
const writeFailure = (value) => {
|
|
@@ -11248,6 +12594,7 @@ const createNdjsonLoggerAdapter = (state, configDirectory, commandName = "enhanc
|
|
|
11248
12594
|
const failureState = state;
|
|
11249
12595
|
const sensitiveDirectory = path.join(configDirectory, "sensitive");
|
|
11250
12596
|
sweepExpiredSensitiveFiles(sensitiveDirectory);
|
|
12597
|
+
let hasPrintedHelp = false;
|
|
11251
12598
|
return {
|
|
11252
12599
|
result: (value) => {
|
|
11253
12600
|
writeResult(withCommandName(value, commandName), sensitiveDirectory);
|
|
@@ -11257,7 +12604,10 @@ const createNdjsonLoggerAdapter = (state, configDirectory, commandName = "enhanc
|
|
|
11257
12604
|
},
|
|
11258
12605
|
logger: {
|
|
11259
12606
|
info: (...args) => {
|
|
11260
|
-
|
|
12607
|
+
const value = withCommandName(args.length === 1 ? args[0] : args, commandName);
|
|
12608
|
+
hasPrintedHelp ||= typeof value === "string" && isHelpText(value);
|
|
12609
|
+
if (hasPrintedHelp && typeof value === "string") process.stdout.write(value);
|
|
12610
|
+
else writeResult(value, sensitiveDirectory);
|
|
11261
12611
|
},
|
|
11262
12612
|
error: (...args) => {
|
|
11263
12613
|
const message = String(withCommandName(args.map(String).join(""), commandName));
|
|
@@ -11271,6 +12621,7 @@ const createNdjsonLoggerAdapter = (state, configDirectory, commandName = "enhanc
|
|
|
11271
12621
|
|
|
11272
12622
|
//#endregion
|
|
11273
12623
|
//#region src/main.ts
|
|
12624
|
+
installZodMessages();
|
|
11274
12625
|
const main = async () => {
|
|
11275
12626
|
const config = readCliEnvironment();
|
|
11276
12627
|
const state = {
|
|
@@ -11278,19 +12629,20 @@ const main = async () => {
|
|
|
11278
12629
|
pendingParserMessage: null
|
|
11279
12630
|
};
|
|
11280
12631
|
const output = createNdjsonLoggerAdapter(state, config.configDirectory, config.commandName);
|
|
11281
|
-
const credentials = createFileCredentialAdapter(config.configDirectory);
|
|
12632
|
+
const credentials = createFileCredentialAdapter(config.configDirectory, config.earlierConfigDirectory);
|
|
11282
12633
|
const mutationKey = createMutationKeyAdapter();
|
|
11283
12634
|
const remote = createHttpRemoteAdapter(config.apiUrl, credentials, mutationKey);
|
|
11284
12635
|
const cli = createCliProgram({
|
|
11285
12636
|
apiUrl: config.apiUrl,
|
|
11286
|
-
version: "0.1.
|
|
12637
|
+
version: "0.1.166",
|
|
11287
12638
|
credentials,
|
|
11288
12639
|
remote,
|
|
11289
12640
|
mutationKey,
|
|
11290
12641
|
output,
|
|
11291
12642
|
state,
|
|
11292
12643
|
configDirectory: config.configDirectory,
|
|
11293
|
-
commandName: config.commandName
|
|
12644
|
+
commandName: config.commandName,
|
|
12645
|
+
machine: readToolMachine()
|
|
11294
12646
|
});
|
|
11295
12647
|
try {
|
|
11296
12648
|
await cli.run();
|