@cotal-ai/workspace 0.90.1 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Release/win32-arm64/build.json +1 -1
- package/build/Release/win32-x64/build.json +1 -1
- package/dist/agent-secrets.d.ts +2 -2
- package/dist/agent-secrets.d.ts.map +1 -1
- package/dist/agent-secrets.js +2 -2
- package/dist/agent-secrets.js.map +1 -1
- package/dist/auth-paths.d.ts +8 -2
- package/dist/auth-paths.d.ts.map +1 -1
- package/dist/auth-paths.js +12 -5
- package/dist/auth-paths.js.map +1 -1
- package/dist/broker-display.d.ts +4 -0
- package/dist/broker-display.d.ts.map +1 -0
- package/dist/broker-display.js +29 -0
- package/dist/broker-display.js.map +1 -0
- package/dist/colors.d.ts +11 -4
- package/dist/colors.d.ts.map +1 -1
- package/dist/colors.js +36 -9
- package/dist/colors.js.map +1 -1
- package/dist/connect.d.ts +64 -6
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +170 -74
- package/dist/connect.js.map +1 -1
- package/dist/control-target.d.ts +2 -2
- package/dist/control-target.js +2 -2
- package/dist/credential-actions.d.ts +91 -0
- package/dist/credential-actions.d.ts.map +1 -0
- package/dist/credential-actions.js +74 -0
- package/dist/credential-actions.js.map +1 -0
- package/dist/deprecated-daemon-entries.d.ts +30 -0
- package/dist/deprecated-daemon-entries.d.ts.map +1 -0
- package/dist/deprecated-daemon-entries.js +37 -0
- package/dist/deprecated-daemon-entries.js.map +1 -0
- package/dist/endpoint-actions.d.ts +31 -0
- package/dist/endpoint-actions.d.ts.map +1 -0
- package/dist/endpoint-actions.js +2 -0
- package/dist/endpoint-actions.js.map +1 -0
- package/dist/endpoint-caller.d.ts +74 -0
- package/dist/endpoint-caller.d.ts.map +1 -0
- package/dist/endpoint-caller.js +118 -0
- package/dist/endpoint-caller.js.map +1 -0
- package/dist/endpoint-contract.d.ts +32 -0
- package/dist/endpoint-contract.d.ts.map +1 -0
- package/dist/endpoint-contract.js +92 -0
- package/dist/endpoint-contract.js.map +1 -0
- package/dist/extension-mutation.d.ts.map +1 -1
- package/dist/extension-mutation.js +4 -1
- package/dist/extension-mutation.js.map +1 -1
- package/dist/extensions.d.ts +28 -8
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +20 -8
- package/dist/extensions.js.map +1 -1
- package/dist/flags.d.ts +8 -1
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +9 -7
- package/dist/flags.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/launch-persona.d.ts +10 -0
- package/dist/launch-persona.d.ts.map +1 -0
- package/dist/launch-persona.js +34 -0
- package/dist/launch-persona.js.map +1 -0
- package/dist/local-process.d.ts +16 -12
- package/dist/local-process.d.ts.map +1 -1
- package/dist/local-process.js +7 -2
- package/dist/local-process.js.map +1 -1
- package/dist/maintenance.d.ts +267 -4
- package/dist/maintenance.d.ts.map +1 -1
- package/dist/maintenance.js +666 -12
- package/dist/maintenance.js.map +1 -1
- package/dist/mesh-manifest-schema.d.ts +118 -0
- package/dist/mesh-manifest-schema.d.ts.map +1 -0
- package/dist/mesh-manifest-schema.js +96 -0
- package/dist/mesh-manifest-schema.js.map +1 -0
- package/dist/mesh-registry.d.ts +27 -0
- package/dist/mesh-registry.d.ts.map +1 -1
- package/dist/mesh-registry.js +69 -13
- package/dist/mesh-registry.js.map +1 -1
- package/dist/mesh-target.d.ts +15 -7
- package/dist/mesh-target.d.ts.map +1 -1
- package/dist/mesh-target.js +77 -26
- package/dist/mesh-target.js.map +1 -1
- package/dist/official-connectors.d.ts +13 -0
- package/dist/official-connectors.d.ts.map +1 -1
- package/dist/official-connectors.js +18 -2
- package/dist/official-connectors.js.map +1 -1
- package/dist/output.d.ts +147 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +186 -0
- package/dist/output.js.map +1 -0
- package/dist/pid.d.ts +5 -3
- package/dist/pid.d.ts.map +1 -1
- package/dist/pid.js +25 -13
- package/dist/pid.js.map +1 -1
- package/dist/preferences.d.ts +93 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +272 -0
- package/dist/preferences.js.map +1 -0
- package/dist/preflight.d.ts +3 -0
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +6 -3
- package/dist/preflight.js.map +1 -1
- package/dist/prepared-spaces.d.ts +27 -0
- package/dist/prepared-spaces.d.ts.map +1 -0
- package/dist/prepared-spaces.js +57 -0
- package/dist/prepared-spaces.js.map +1 -0
- package/dist/present.d.ts +108 -0
- package/dist/present.d.ts.map +1 -0
- package/dist/present.js +249 -0
- package/dist/present.js.map +1 -0
- package/dist/prompt-input.d.ts +12 -0
- package/dist/prompt-input.d.ts.map +1 -0
- package/dist/prompt-input.js +35 -0
- package/dist/prompt-input.js.map +1 -0
- package/dist/protected-records.d.ts +102 -0
- package/dist/protected-records.d.ts.map +1 -0
- package/dist/protected-records.js +465 -0
- package/dist/protected-records.js.map +1 -0
- package/dist/registration-policy.d.ts +4 -1
- package/dist/registration-policy.d.ts.map +1 -1
- package/dist/registration-policy.js +4 -3
- package/dist/registration-policy.js.map +1 -1
- package/dist/render.d.ts +8 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +49 -32
- package/dist/render.js.map +1 -1
- package/dist/service-adapter.d.ts +198 -0
- package/dist/service-adapter.d.ts.map +1 -0
- package/dist/service-adapter.js +294 -0
- package/dist/service-adapter.js.map +1 -0
- package/dist/service-custody.d.ts +5 -0
- package/dist/service-custody.d.ts.map +1 -0
- package/dist/service-custody.js +41 -0
- package/dist/service-custody.js.map +1 -0
- package/dist/service-definition.d.ts +52 -0
- package/dist/service-definition.d.ts.map +1 -0
- package/dist/service-definition.js +85 -0
- package/dist/service-definition.js.map +1 -0
- package/dist/service-definition.schema.json +79 -0
- package/dist/service-extension-metadata.d.ts +11 -0
- package/dist/service-extension-metadata.d.ts.map +1 -0
- package/dist/service-extension-metadata.js +66 -0
- package/dist/service-extension-metadata.js.map +1 -0
- package/dist/service-identity.d.ts +51 -0
- package/dist/service-identity.d.ts.map +1 -0
- package/dist/service-identity.js +103 -0
- package/dist/service-identity.js.map +1 -0
- package/dist/service-observation.d.ts +32 -0
- package/dist/service-observation.d.ts.map +1 -0
- package/dist/service-observation.js +134 -0
- package/dist/service-observation.js.map +1 -0
- package/dist/service-preset.d.ts +12 -0
- package/dist/service-preset.d.ts.map +1 -0
- package/dist/service-preset.js +10 -0
- package/dist/service-preset.js.map +1 -0
- package/dist/service-startup.d.ts +23 -0
- package/dist/service-startup.d.ts.map +1 -0
- package/dist/service-startup.js +39 -0
- package/dist/service-startup.js.map +1 -0
- package/dist/service-stop.d.ts +47 -0
- package/dist/service-stop.d.ts.map +1 -0
- package/dist/service-stop.js +152 -0
- package/dist/service-stop.js.map +1 -0
- package/dist/service-target.d.ts +5 -0
- package/dist/service-target.d.ts.map +1 -0
- package/dist/service-target.js +19 -0
- package/dist/service-target.js.map +1 -0
- package/dist/signer-export.d.ts +31 -0
- package/dist/signer-export.d.ts.map +1 -0
- package/dist/signer-export.js +114 -0
- package/dist/signer-export.js.map +1 -0
- package/dist/space-segmentation.d.ts +13 -2
- package/dist/space-segmentation.d.ts.map +1 -1
- package/dist/space-segmentation.js +7 -3
- package/dist/space-segmentation.js.map +1 -1
- package/dist/space.d.ts +5 -5
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +8 -6
- package/dist/space.js.map +1 -1
- package/dist/system-rotation.d.ts +4 -3
- package/dist/system-rotation.d.ts.map +1 -1
- package/dist/system-rotation.js +16 -6
- package/dist/system-rotation.js.map +1 -1
- package/dist/web-session.d.ts +7 -0
- package/dist/web-session.d.ts.map +1 -1
- package/dist/web-session.js +9 -0
- package/dist/web-session.js.map +1 -1
- package/package.json +6 -2
package/dist/present.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import stringWidth from "string-width";
|
|
2
|
+
import { c } from "./colors.js";
|
|
3
|
+
import { oneLine } from "@cotal-ai/core";
|
|
4
|
+
import { CommandFailure, exitCode, writeEnvelope } from "./output.js";
|
|
5
|
+
const tones = {
|
|
6
|
+
command: c.blue,
|
|
7
|
+
selected: c.blue,
|
|
8
|
+
ok: c.green,
|
|
9
|
+
waiting: c.yellow,
|
|
10
|
+
failed: c.red,
|
|
11
|
+
label: c.dim,
|
|
12
|
+
hint: c.dim,
|
|
13
|
+
title: c.bold,
|
|
14
|
+
};
|
|
15
|
+
/** The columns `text` occupies on a terminal: grapheme clusters, wide East Asian and emoji
|
|
16
|
+
* characters as two, combining marks and zero-width characters as none, ANSI sequences as none. */
|
|
17
|
+
export function displayWidth(text) {
|
|
18
|
+
return stringWidth(text);
|
|
19
|
+
}
|
|
20
|
+
/** Punctuation as plain writes it, wherever it appears, so a plain report is ASCII apart from
|
|
21
|
+
* other characters of the content itself, such as the letters of a name. */
|
|
22
|
+
const PLAIN_PUNCTUATION = { "·": "-", "…": "...", "→": "->", "↳": "->", "—": "-", "–": "-" };
|
|
23
|
+
const textOf = (cell, style) => {
|
|
24
|
+
const text = oneLine(typeof cell === "string" ? cell : cell.text);
|
|
25
|
+
return style === "plain" ? text.replace(/[·…→↳—–]/g, (glyph) => PLAIN_PUNCTUATION[glyph]).replace(/§ ?/g, "section ") : text;
|
|
26
|
+
};
|
|
27
|
+
/** One cell as `style` draws it. The width it occupies is that of its escaped text, plus the mark
|
|
28
|
+
* and a space in rich style. */
|
|
29
|
+
function draw(cell, style) {
|
|
30
|
+
const text = textOf(cell, style);
|
|
31
|
+
if (typeof cell !== "string" && cell.mark && !cell.text.trim())
|
|
32
|
+
throw new Error(`internal error: the mark ${cell.mark} names no state in words`);
|
|
33
|
+
if (typeof cell === "string" || style === "plain")
|
|
34
|
+
return { shown: text, width: displayWidth(text) };
|
|
35
|
+
const marked = cell.mark ? `${oneLine(cell.mark)} ${text}` : text;
|
|
36
|
+
return { shown: cell.tone ? tones[cell.tone](marked) : marked, width: displayWidth(marked) };
|
|
37
|
+
}
|
|
38
|
+
/** `text` in lines of at most `width` display columns, broken at spaces, or only between the given
|
|
39
|
+
* words. A word wider than `width` keeps a line of its own, so an identity, path or command is never
|
|
40
|
+
* split. Below 20 columns, and when the output is not a terminal, nothing is wrapped. */
|
|
41
|
+
export function wrapWords(text, width) {
|
|
42
|
+
const words = typeof text === "string" ? text.split(" ") : text;
|
|
43
|
+
if (!(width >= 20) || displayWidth(words.join(" ")) <= width)
|
|
44
|
+
return [words.join(" ")];
|
|
45
|
+
const lines = [];
|
|
46
|
+
let line = "";
|
|
47
|
+
for (const word of words) {
|
|
48
|
+
const next = line ? `${line} ${word}` : word;
|
|
49
|
+
if (line && displayWidth(next) > width) {
|
|
50
|
+
lines.push(line);
|
|
51
|
+
line = word;
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
line = next;
|
|
55
|
+
}
|
|
56
|
+
lines.push(line);
|
|
57
|
+
return lines;
|
|
58
|
+
}
|
|
59
|
+
/** A cell drawn in lines that fit `width` columns, each line toned on its own. A continuation line
|
|
60
|
+
* starts under the first line's text, past its leading spaces and the mark, plus `hang` columns. */
|
|
61
|
+
function drawWrapped(cell, style, width, hang = 0) {
|
|
62
|
+
const text = textOf(cell, style);
|
|
63
|
+
const lead = /^ */.exec(text)[0];
|
|
64
|
+
const markWidth = typeof cell !== "string" && cell.mark && style === "rich" ? displayWidth(oneLine(cell.mark)) + 1 : 0;
|
|
65
|
+
const [first = "", ...rest] = wrapWords(text.slice(lead.length), width - lead.length - markWidth - hang);
|
|
66
|
+
const piece = (words) => (typeof cell === "string" ? words : { text: words, ...(cell.tone ? { tone: cell.tone } : {}) });
|
|
67
|
+
return [
|
|
68
|
+
draw(typeof cell === "string" ? lead + first : { ...cell, text: lead + first }, style).shown,
|
|
69
|
+
...rest.map((words) => " ".repeat(lead.length + markWidth + hang) + draw(piece(words), style).shown),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function drawPadded(cell, style, width) {
|
|
73
|
+
const { shown, width: used } = draw(cell, style);
|
|
74
|
+
return shown + " ".repeat(Math.max(0, width - used));
|
|
75
|
+
}
|
|
76
|
+
function renderTable(table, style, width, indent) {
|
|
77
|
+
const label = (column) => ({ text: column.label, tone: "label" });
|
|
78
|
+
const cellOf = (row, column) => row[column.key] ?? "";
|
|
79
|
+
const widths = table.columns.map((column) => Math.max(table.header === false ? 0 : draw(label(column), style).width, ...table.rows.map((row) => draw(cellOf(row, column), style).width)));
|
|
80
|
+
const total = indent.length + widths.reduce((sum, w) => sum + w, 0) + 2 * (widths.length - 1);
|
|
81
|
+
if (total <= width) {
|
|
82
|
+
// An empty last cell would leave the padding before it trailing the line.
|
|
83
|
+
const line = (cells) => (indent + cells.map((cell, i) => (i === cells.length - 1 ? draw(cell, style).shown : drawPadded(cell, style, widths[i]))).join(" ")).replace(/ +$/, "");
|
|
84
|
+
return [...(table.header === false ? [] : [line(table.columns.map(label))]), ...table.rows.map((row) => line(table.columns.map((column) => cellOf(row, column))))];
|
|
85
|
+
}
|
|
86
|
+
// Too narrow for the columns: one labeled record per row, so nothing is clipped. Its labels read
|
|
87
|
+
// as the other reports' fields do, and a field the row leaves empty is left out.
|
|
88
|
+
const records = table.rows.map((row) => renderFields({ kind: "fields", rows: table.columns.filter((column) => textOf(cellOf(row, column), "plain") !== "").map((column) => [column.label.toLowerCase(), cellOf(row, column)]) }, style, indent, width));
|
|
89
|
+
return records.flatMap((record, i) => (i === 0 ? record : ["", ...record]));
|
|
90
|
+
}
|
|
91
|
+
/** Each value starts after its padded label; a value too long for the line continues under itself.
|
|
92
|
+
* Below 48 columns each label takes a line of its own, with its value on the lines under it. */
|
|
93
|
+
function renderFields(fields, style, indent, width) {
|
|
94
|
+
if (width < 48) {
|
|
95
|
+
return fields.rows.flatMap(([name, value]) => [
|
|
96
|
+
indent + draw({ text: name, tone: "label" }, style).shown,
|
|
97
|
+
...drawWrapped(value, style, width - indent.length - 2).map((line) => indent + " " + line),
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
const pad = Math.max(0, ...fields.rows.map(([name]) => displayWidth(textOf(name, style)) + 1));
|
|
101
|
+
const start = indent.length + pad + 1;
|
|
102
|
+
return fields.rows.flatMap(([name, value]) => {
|
|
103
|
+
const [first, ...rest] = drawWrapped(value, style, width - start);
|
|
104
|
+
return [`${indent}${drawPadded({ text: `${name}:`, tone: "label" }, style, pad)} ${first}`, ...rest.map((line) => " ".repeat(start) + line)];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function renderCommands(block, style, width, indent) {
|
|
108
|
+
const commands = block.items.map((item) => ({ text: item.command, tone: "command" }));
|
|
109
|
+
const pad = Math.max(0, ...commands.map((command) => draw(command, style).width));
|
|
110
|
+
// A description that would have fewer than 30 columns beside its command goes on the lines under it.
|
|
111
|
+
const stacked = width - indent.length - pad - 2 < 30;
|
|
112
|
+
return block.items.flatMap((item, index) => {
|
|
113
|
+
const description = { text: item.description, tone: "hint" };
|
|
114
|
+
if (stacked)
|
|
115
|
+
return [
|
|
116
|
+
...drawWrapped(commands[index], style, width - indent.length).map((line) => indent + line),
|
|
117
|
+
...drawWrapped(description, style, width - indent.length - 2).map((line) => indent + " " + line),
|
|
118
|
+
];
|
|
119
|
+
const [first = "", ...rest] = drawWrapped(description, style, width - indent.length - pad - 2);
|
|
120
|
+
return [
|
|
121
|
+
indent + drawPadded(commands[index], style, pad) + " " + first,
|
|
122
|
+
...rest.map((line) => " ".repeat(indent.length + pad + 2) + line),
|
|
123
|
+
];
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** A report as lines of text, fitted to `width` columns (unbounded when output is not a terminal):
|
|
127
|
+
* tables fit or become records, and long values and lines wrap at spaces. */
|
|
128
|
+
export function renderReport(report, style, width = Number.POSITIVE_INFINITY) {
|
|
129
|
+
const out = report.space ? drawWrapped({ text: `Mesh: ${report.space}`, tone: "selected" }, style, width) : [];
|
|
130
|
+
for (const section of report.sections) {
|
|
131
|
+
if (out.length)
|
|
132
|
+
out.push("");
|
|
133
|
+
const indent = section.title === undefined ? "" : " ";
|
|
134
|
+
if (section.title !== undefined)
|
|
135
|
+
out.push(draw({ text: section.title, tone: "title" }, style).shown);
|
|
136
|
+
for (const block of section.blocks) {
|
|
137
|
+
if (block.kind === "table")
|
|
138
|
+
out.push(...renderTable(block, style, width, indent));
|
|
139
|
+
else if (block.kind === "fields")
|
|
140
|
+
out.push(...renderFields(block, style, indent, width));
|
|
141
|
+
else if (block.kind === "commands")
|
|
142
|
+
out.push(...renderCommands(block, style, width, indent));
|
|
143
|
+
else
|
|
144
|
+
out.push(...block.lines.flatMap((line) => drawWrapped(line, style, width - indent.length).map((shown) => indent + shown)));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return out.join("\n");
|
|
148
|
+
}
|
|
149
|
+
/** The columns a stream can show: its terminal's width, or unbounded when it is not a terminal. */
|
|
150
|
+
export function terminalWidth(stream) {
|
|
151
|
+
return stream.isTTY && stream.columns ? stream.columns : Number.POSITIVE_INFINITY;
|
|
152
|
+
}
|
|
153
|
+
/** The presentation `--json` and `--plain` ask for. Both at once is a usage error. */
|
|
154
|
+
export function presentationOf(values) {
|
|
155
|
+
if (values.json === true && values.plain === true)
|
|
156
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--json and --plain choose different outputs - pass one", { remedy: "pass --json for a document or --plain for text" });
|
|
157
|
+
return values.json === true ? "json" : values.plain === true ? "plain" : "rich";
|
|
158
|
+
}
|
|
159
|
+
/** One finished result in the presentation the run asked for: the envelope for `json`, otherwise the
|
|
160
|
+
* report `view` builds from the same result, fitted to the terminal stdout is, with each warning on
|
|
161
|
+
* stderr. `partial` marks a read that answered for only part of what was asked: the result keeps
|
|
162
|
+
* what was read, the outcome is `partial`, and the run exits 4. `noOp` marks a change that was
|
|
163
|
+
* already in place: the outcome is `no-op` and the run exits 0. `failure` retains an attributed
|
|
164
|
+
* multi-member result alongside its classified error. A failure without useful result data is
|
|
165
|
+
* thrown as a {@link CommandFailure} for the kernel to write. */
|
|
166
|
+
export function writeResult(presentation, out, view) {
|
|
167
|
+
if (Number(Boolean(out.partial)) + Number(Boolean(out.noOp)) + Number(Boolean(out.failure)) > 1)
|
|
168
|
+
throw new Error("internal error: a result has one outcome classification");
|
|
169
|
+
const outcome = out.failure?.outcome ?? (out.partial ? "partial" : out.noOp ? "no-op" : "ok");
|
|
170
|
+
const code = out.failure?.code ?? (out.partial ? "OPERATION_PARTIAL" : undefined);
|
|
171
|
+
const error = out.failure?.detail() ?? (out.partial ? { code: "OPERATION_PARTIAL", message: out.partial.message, ...(out.partial.remedy === undefined ? {} : { remedy: out.partial.remedy }) } : undefined);
|
|
172
|
+
if (presentation === "json") {
|
|
173
|
+
writeEnvelope({
|
|
174
|
+
schemaVersion: 1,
|
|
175
|
+
command: out.command,
|
|
176
|
+
target: out.target,
|
|
177
|
+
outcome,
|
|
178
|
+
completeness: out.completeness ?? "complete",
|
|
179
|
+
result: out.result,
|
|
180
|
+
warnings: out.warnings ?? [],
|
|
181
|
+
...(error ? { error } : {}),
|
|
182
|
+
...(out.failure?.changed === undefined ? {} : { changed: out.failure.changed }),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const target = out.target !== null && typeof out.target === "object" && !Array.isArray(out.target) ? out.target : undefined;
|
|
187
|
+
const report = view(out.result);
|
|
188
|
+
console.log(renderReport({ ...report, ...(typeof target?.space === "string" && target.space ? { space: target.space } : {}) }, presentation, terminalWidth(process.stdout)));
|
|
189
|
+
const errWidth = terminalWidth(process.stderr);
|
|
190
|
+
const say = (cell, hang) => { for (const line of drawWrapped(cell, presentation, errWidth, hang))
|
|
191
|
+
console.error(line); };
|
|
192
|
+
for (const warning of out.warnings ?? [])
|
|
193
|
+
say({ text: `! ${warning.message}`, tone: "waiting" }, 2);
|
|
194
|
+
if (error) {
|
|
195
|
+
say({ text: `${presentation === "plain" ? "!" : "✗"} ${error.message}`, tone: outcome === "partial" || outcome === "unknown" ? "waiting" : "failed" }, 2);
|
|
196
|
+
if (error.remedy)
|
|
197
|
+
say({ text: ` ↳ ${error.remedy}`, tone: "hint" }, 2);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
process.exitCode = exitCode(outcome, code);
|
|
201
|
+
}
|
|
202
|
+
/** A failure report exposes only attributed target/receipt fields, never arbitrary input objects. */
|
|
203
|
+
export function commandFailureReport(failure) {
|
|
204
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
205
|
+
const fields = [["Outcome", { text: failure.outcome, tone: failure.outcome === "unknown" || failure.outcome === "partial" ? "waiting" : "failed" }], ["Code", failure.code]];
|
|
206
|
+
const target = object(failure.target);
|
|
207
|
+
const labels = [["space", "Space"], ["endpoint", "Endpoint"], ["command", "Native command"], ["name", "Name"], ["deploymentId", "Deployment"], ["instanceId", "Instance"], ["requestedInstanceId", "Requested instance"], ["managerInstanceId", "Manager"], ["requestId", "Original request"], ["requestedGoalId", "Requested goal"], ["acceptedGoalId", "Accepted goal"]];
|
|
208
|
+
for (const [key, label] of labels)
|
|
209
|
+
if (typeof target?.[key] === "string" && target[key])
|
|
210
|
+
fields.push([label, target[key]]);
|
|
211
|
+
const accepted = object(target?.accepted);
|
|
212
|
+
if (typeof accepted?.goalId === "string")
|
|
213
|
+
fields.push(["Accepted goal", accepted.goalId]);
|
|
214
|
+
if (typeof accepted?.fingerprint === "string")
|
|
215
|
+
fields.push(["Goal fingerprint", accepted.fingerprint]);
|
|
216
|
+
const responder = object(accepted?.responder) ?? object(object(failure.native?.detail)?.responder);
|
|
217
|
+
if (typeof responder?.instanceId === "string")
|
|
218
|
+
fields.push(["Answering instance", responder.instanceId]);
|
|
219
|
+
if (typeof responder?.epoch === "number")
|
|
220
|
+
fields.push(["Answering epoch", String(responder.epoch)]);
|
|
221
|
+
if (failure.native?.code)
|
|
222
|
+
fields.push(["Native code", failure.native.code]);
|
|
223
|
+
if (failure.native?.outcome)
|
|
224
|
+
fields.push(["Native outcome", failure.native.outcome]);
|
|
225
|
+
// A wrapped cause's own sentence, such as which path a check refused and why. Cells render on one line.
|
|
226
|
+
if (typeof failure.native?.detail === "string" && failure.native.detail)
|
|
227
|
+
fields.push(["Native detail", failure.native.detail]);
|
|
228
|
+
const purges = (failure.changed ?? []).flatMap((item) => {
|
|
229
|
+
const row = object(item);
|
|
230
|
+
return typeof row?.stream === "string" && typeof row.purged === "number" ? [{ stream: row.stream, purged: String(row.purged) }] : [];
|
|
231
|
+
});
|
|
232
|
+
const native = object(failure.native?.detail);
|
|
233
|
+
const names = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : [];
|
|
234
|
+
const nativeRows = [
|
|
235
|
+
...names(native?.acknowledged).map((name) => ({ state: "acknowledged", name })),
|
|
236
|
+
...names(native?.alreadyAbsent).map((name) => ({ state: "already absent", name })),
|
|
237
|
+
...(typeof native?.refused === "string" ? [{ state: "refused", name: native.refused }] : []),
|
|
238
|
+
...(typeof native?.unconfirmed === "string" ? [{ state: "unconfirmed", name: native.unconfirmed }] : []),
|
|
239
|
+
...names(native?.remaining).filter((name) => name !== native?.refused && name !== native?.unconfirmed).map((name) => ({ state: "remaining or unresolved", name })),
|
|
240
|
+
];
|
|
241
|
+
return { ...(typeof target?.space === "string" && target.space ? { space: target.space } : {}), sections: [
|
|
242
|
+
{ title: failure.outcome === "unknown" ? "Outcome unconfirmed" : failure.outcome === "partial" ? "Partly completed" : failure.outcome === "refused" ? "Request refused" : "Request failed", blocks: [{ kind: "lines", lines: [{ text: failure.message, tone: failure.outcome === "unknown" || failure.outcome === "partial" ? "waiting" : "failed" }] }, { kind: "fields", rows: fields }] },
|
|
243
|
+
...(purges.length ? [{ title: "Acknowledged history changes", blocks: [{ kind: "table", columns: [{ key: "stream", label: "Native stream" }, { key: "purged", label: "Messages purged" }], rows: purges }] }] : []),
|
|
244
|
+
...(nativeRows.length ? [{ title: "Native target details", blocks: [{ kind: "table", columns: [{ key: "state", label: "State" }, { key: "name", label: "Target" }], rows: nativeRows.slice(0, 100) }, ...(nativeRows.length > 100 ? [{ kind: "lines", lines: [`Showing 100 of ${nativeRows.length} targets; --json retains every row.`] }] : [])] }] : []),
|
|
245
|
+
...(failure.changed?.length && !purges.length && !nativeRows.length ? [{ title: "Confirmed changes", blocks: [{ kind: "lines", lines: [`${failure.changed.length} change receipt(s) retained. Choose structured output before the operation to retain their data; do not repeat a mutation merely to view its receipt.`] }] }] : []),
|
|
246
|
+
...(failure.remedy ? [{ title: "Next", blocks: [{ kind: "lines", lines: [failure.remedy] }] }] : []),
|
|
247
|
+
] };
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=present.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present.js","sourceRoot":"","sources":["../src/present.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAyC,MAAM,aAAa,CAAC;AA6E7G,MAAM,KAAK,GAAwC;IACjD,OAAO,EAAE,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,CAAC,CAAC,IAAI;IAChB,EAAE,EAAE,CAAC,CAAC,KAAK;IACX,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB,MAAM,EAAE,CAAC,CAAC,GAAG;IACb,KAAK,EAAE,CAAC,CAAC,GAAG;IACZ,IAAI,EAAE,CAAC,CAAC,GAAG;IACX,KAAK,EAAE,CAAC,CAAC,IAAI;CACd,CAAC;AAEF;oGACoG;AACpG,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;6EAC6E;AAC7E,MAAM,iBAAiB,GAAqC,EAAE,GAAG,EAAE,GAAG,EAAE,GA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,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,CAAC,kBAAkB,UAAU,CAAC,MAAM,qCAAqC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5W,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,uJAAuJ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7U,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9G,EAAE,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
/**
|
|
3
|
+
* Ask one clack prompt that ends when its input does. Ctrl-D on an empty line closes clack's own
|
|
4
|
+
* readline without settling the prompt, and so does a closed stdin; the process then drains and
|
|
5
|
+
* exits 13 with Node's unsettled top-level await warning. Both are answered here as the cancel
|
|
6
|
+
* Ctrl-C gives, so the caller's own cancelled branch reports and exits.
|
|
7
|
+
*
|
|
8
|
+
* A Ctrl-D is acted on only after every keypress listener ran and only when it left the input
|
|
9
|
+
* paused, which is what a closed readline does. Mid-line it deletes, as readline has it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function untilInputEnds<T>(ask: (signal: AbortSignal) => Promise<T | symbol>, input?: Readable): Promise<T | symbol>;
|
|
12
|
+
//# sourceMappingURL=prompt-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-input.d.ts","sourceRoot":"","sources":["../src/prompt-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,KAAK,GAAE,QAAwB,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAmB/I"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ask one clack prompt that ends when its input does. Ctrl-D on an empty line closes clack's own
|
|
3
|
+
* readline without settling the prompt, and so does a closed stdin; the process then drains and
|
|
4
|
+
* exits 13 with Node's unsettled top-level await warning. Both are answered here as the cancel
|
|
5
|
+
* Ctrl-C gives, so the caller's own cancelled branch reports and exits.
|
|
6
|
+
*
|
|
7
|
+
* A Ctrl-D is acted on only after every keypress listener ran and only when it left the input
|
|
8
|
+
* paused, which is what a closed readline does. Mid-line it deletes, as readline has it.
|
|
9
|
+
*/
|
|
10
|
+
export async function untilInputEnds(ask, input = process.stdin) {
|
|
11
|
+
const ended = new AbortController();
|
|
12
|
+
let settled = false;
|
|
13
|
+
const end = () => { if (!settled)
|
|
14
|
+
ended.abort(); };
|
|
15
|
+
const key = (_text, pressed) => {
|
|
16
|
+
if (pressed?.ctrl && pressed.name === "d")
|
|
17
|
+
setImmediate(() => { if (input.isPaused())
|
|
18
|
+
end(); });
|
|
19
|
+
};
|
|
20
|
+
if (input.readableEnded || input.destroyed)
|
|
21
|
+
end();
|
|
22
|
+
input.once("end", end);
|
|
23
|
+
input.once("close", end);
|
|
24
|
+
input.on("keypress", key);
|
|
25
|
+
try {
|
|
26
|
+
return await ask(ended.signal);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
settled = true;
|
|
30
|
+
input.off("end", end);
|
|
31
|
+
input.off("close", end);
|
|
32
|
+
input.off("keypress", key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=prompt-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-input.js","sourceRoot":"","sources":["../src/prompt-input.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,GAAiD,EAAE,QAAkB,OAAO,CAAC,KAAK;IACxH,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;IACpC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO;QAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,CAAC,KAAc,EAAE,OAA2C,EAAE,EAAE;QAC1E,IAAI,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG;YAAE,YAAY,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,CAAC,CAAC;IACF,IAAI,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,SAAS;QAAE,GAAG,EAAE,CAAC;IAClD,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;YAAS,CAAC;QACT,OAAO,GAAG,IAAI,CAAC;QACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtB,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACxB,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type Stats } from "node:fs";
|
|
2
|
+
export declare const LOCAL_INPUT_LIMIT: number;
|
|
3
|
+
export interface SavedLocalRecord<T> {
|
|
4
|
+
recordVersion: 1;
|
|
5
|
+
revision: string;
|
|
6
|
+
value: T;
|
|
7
|
+
}
|
|
8
|
+
export interface LocalRecordSnapshot<T> {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
record: SavedLocalRecord<T>;
|
|
12
|
+
hash: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function localRecordName(name: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* How local records are protected. `posix` checks the owner and the mode and refuses links, and
|
|
17
|
+
* opens without following a link or blocking. `windows-acl` is the model Cotal already uses for
|
|
18
|
+
* private files on Windows: a private file or directory gets an access list for this user, SYSTEM
|
|
19
|
+
* and Administrators when Cotal creates it (core `hardenPrivate`). Windows has no POSIX owner or
|
|
20
|
+
* mode, so that model checks neither and does not refuse a link.
|
|
21
|
+
*/
|
|
22
|
+
export type LocalRecordAccess = "posix" | "windows-acl";
|
|
23
|
+
/** The model for `platform`, or undefined when a POSIX host lacks the owner id or the no-follow
|
|
24
|
+
* and nonblocking opens the POSIX checks need. It is the one place the platform is decided;
|
|
25
|
+
* `platform` is a parameter so a suite can select the Windows model off Windows. */
|
|
26
|
+
export declare function localRecordAccess(platform?: NodeJS.Platform): LocalRecordAccess | undefined;
|
|
27
|
+
/** Whether this platform has a protection model for local records. */
|
|
28
|
+
export declare function protectedFileAccessAvailable(): boolean;
|
|
29
|
+
export declare function assertProtectedFileAccess(): void;
|
|
30
|
+
/** Establish a regular descriptor, then read only bounded bytes. POSIX opens nonblocking and
|
|
31
|
+
* without following a link, and checks a private file's owner and mode; Windows does neither. */
|
|
32
|
+
export declare function readLocalRecordSource(path: string, limit?: number, privateFile?: boolean): Buffer | undefined;
|
|
33
|
+
export declare function localRecordObject(value: unknown, fields: readonly string[]): Record<string, unknown>;
|
|
34
|
+
export declare function localRecordText(value: unknown, limit: number): string;
|
|
35
|
+
/** The account-database reads behind the private-group proof, as raw text. Each one throws with
|
|
36
|
+
* its reason when the read is unavailable. */
|
|
37
|
+
export interface AccountDatabase {
|
|
38
|
+
/** `/etc/nsswitch.conf`, which names the sources behind the lookups below */
|
|
39
|
+
readonly nameServices: () => string;
|
|
40
|
+
/** `getent passwd <uid>` */
|
|
41
|
+
readonly user: (uid: number) => string;
|
|
42
|
+
/** `getent group <gid>` */
|
|
43
|
+
readonly group: (gid: number) => string;
|
|
44
|
+
/** `getent passwd`: every account the name service enumerates */
|
|
45
|
+
readonly users: () => string;
|
|
46
|
+
}
|
|
47
|
+
/** Who may write a protected path besides its owner: only a group proven to be the caller's
|
|
48
|
+
* user private group, on an entry with no extended ACL. */
|
|
49
|
+
export interface ProtectedPathPolicy {
|
|
50
|
+
readonly uid: number;
|
|
51
|
+
/** Why `gid` is not proven to be the caller's user private group, or undefined when it is. */
|
|
52
|
+
readonly privateGroupGap: (gid: number) => string | undefined;
|
|
53
|
+
/** `getfacl --skip-base --absolute-names -- <path>` output, empty when the path has only base
|
|
54
|
+
* ACL entries. Throws with its reason when the read is unavailable. */
|
|
55
|
+
readonly extendedAcl: (path: string) => string;
|
|
56
|
+
}
|
|
57
|
+
/** Debian OpenSSH's user-private-group rule (user-group-modes.patch): the group is the caller's
|
|
58
|
+
* primary group, it lists no other member, and no other account has it as its primary group.
|
|
59
|
+
* The account list counts only when /etc/nsswitch.conf names local sources alone.
|
|
60
|
+
* Returns why that is not proven, or undefined when it is. */
|
|
61
|
+
export declare function privateGroupGap(accounts: AccountDatabase, uid: number, gid: number): string | undefined;
|
|
62
|
+
/** A proven private group holds for the life of the policy, which for the system policy is the
|
|
63
|
+
* process. Every other verdict is read again on the next check, so a transient lookup failure
|
|
64
|
+
* does not stick in a long-lived service. */
|
|
65
|
+
export declare function protectedPathPolicy(accounts: AccountDatabase, extendedAcl: (path: string) => string, uid: number): ProtectedPathPolicy;
|
|
66
|
+
type EntryStat = Pick<Stats, "uid" | "gid" | "mode" | "isDirectory" | "isSymbolicLink">;
|
|
67
|
+
/** Refuse an existing entry that another local account could replace or write. Root or the caller
|
|
68
|
+
* must own it. Group write needs the caller's proven user private group and no extended ACL, whose
|
|
69
|
+
* named entries the group bits only mask. World write is never accepted. An `ancestor` walk also
|
|
70
|
+
* accepts a root-owned sticky directory such as /tmp. `what` names the path the caller checks,
|
|
71
|
+
* for the refusal. These are POSIX owner, mode and link checks, so the Windows model skips them. */
|
|
72
|
+
export declare function assertProtectedEntry(what: string, path: string, stat: EntryStat, options?: {
|
|
73
|
+
ancestor?: boolean;
|
|
74
|
+
policy?: ProtectedPathPolicy;
|
|
75
|
+
}): void;
|
|
76
|
+
/** Verify an existing physical directory chain before using a protected private output path.
|
|
77
|
+
* `what` names the path for the refusal, such as "the project root". */
|
|
78
|
+
export declare function protectedLocalDirectory(path: string, what?: string, policy?: ProtectedPathPolicy): void;
|
|
79
|
+
export declare function protectedCredentialReference(path: string): void;
|
|
80
|
+
/** Explicit exports stay outside managed state; canonical credentials use their declared store kind. */
|
|
81
|
+
export declare function assertExternalCredentialExport(path: string, roots: readonly string[]): void;
|
|
82
|
+
export declare function decodeLocalJson(bytes: Buffer): unknown;
|
|
83
|
+
/** Workstation records only. Providers are never imported and revisions confer no native authority. */
|
|
84
|
+
export declare class ProtectedRecordStore<T> {
|
|
85
|
+
readonly namespace: "endpoints" | "services";
|
|
86
|
+
readonly space: string;
|
|
87
|
+
readonly validate: (value: unknown, checkReferences: boolean) => T;
|
|
88
|
+
readonly family?: "definitions" | "instances" | "supervisors" | "install-intents" | "uninstall-intents" | "unit-actions" | undefined;
|
|
89
|
+
constructor(namespace: "endpoints" | "services", space: string, validate: (value: unknown, checkReferences: boolean) => T, family?: "definitions" | "instances" | "supervisors" | "install-intents" | "uninstall-intents" | "unit-actions" | undefined);
|
|
90
|
+
directory(create?: boolean): string | undefined;
|
|
91
|
+
read(name: string): LocalRecordSnapshot<T> | undefined;
|
|
92
|
+
list(): LocalRecordSnapshot<T>[];
|
|
93
|
+
/** Hold the cooperative writer lock while a native action uses this exact local revision. */
|
|
94
|
+
pin(expected: LocalRecordSnapshot<T>): {
|
|
95
|
+
check(): void;
|
|
96
|
+
release(): void;
|
|
97
|
+
};
|
|
98
|
+
/** Cooperative CLI writers compare revision and exact bytes under the private per-name lock. */
|
|
99
|
+
commit(name: string, expected: LocalRecordSnapshot<T> | undefined, value: T | undefined, beforeCommit?: () => void): SavedLocalRecord<T> | undefined;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=protected-records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected-records.d.ts","sourceRoot":"","sources":["../src/protected-records.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiH,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAOpJ,eAAO,MAAM,iBAAiB,QAAa,CAAC;AAI5C,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAAI,aAAa,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE;AACrF,MAAM,WAAW,mBAAmB,CAAC,CAAC;IAAI,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,C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