@insmind/cli 1.5.1 → 1.5.3
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/contracts/operations/auth.status/output.schema.json +3 -4
- package/dist/bin/insmind-cli.js +12 -7
- package/dist/bin/postinstall.js +7 -5
- package/dist/bin/{agent-worker.js → task-worker.js} +5 -4
- package/dist/src/analytics/device.js +23 -0
- package/dist/src/analytics/wind.js +54 -0
- package/dist/src/bootstrap/create-cli.js +33 -19
- package/dist/src/bootstrap/create-runtime.js +45 -16
- package/dist/src/bootstrap/{run-agent-worker.js → run-task-worker.js} +20 -10
- package/dist/src/bootstrap/validators.js +10 -5
- package/dist/src/cli/action-binding.js +14 -0
- package/dist/src/cli/agent-commands.js +9 -4
- package/dist/src/cli/auth-commands.js +5 -3
- package/dist/src/cli/credits-command.js +2 -2
- package/dist/src/cli/dam-commands.js +51 -52
- package/dist/src/cli/editor-commands.js +13 -15
- package/dist/src/cli/errors.js +97 -44
- package/dist/src/cli/model-commands.js +6 -4
- package/dist/src/cli/presenter.js +13 -10
- package/dist/src/cli/task-commands.js +13 -5
- package/dist/src/cli/tool-commands.js +11 -5
- package/dist/src/features/agent/use-cases.js +11 -5
- package/dist/src/features/auth/access-policy.js +2 -0
- package/dist/src/features/auth/credential-store.js +2 -2
- package/dist/src/features/auth/sso-service.js +5 -4
- package/dist/src/features/auth/state.js +11 -1
- package/dist/src/features/auth/use-cases.js +43 -40
- package/dist/src/features/credits/use-cases.js +2 -0
- package/dist/src/features/dam/file-downloader.js +38 -16
- package/dist/src/features/dam/object-storage.js +23 -11
- package/dist/src/features/dam/operation-executor.js +46 -37
- package/dist/src/features/dam/registered-uploader.js +39 -29
- package/dist/src/features/dam/storage-upload.js +5 -4
- package/dist/src/features/dam/use-cases.js +81 -60
- package/dist/src/features/editor/bridge-client.js +6 -6
- package/dist/src/features/editor/bridge-process.js +2 -1
- package/dist/src/features/editor/session-state.js +6 -4
- package/dist/src/features/editor/session.js +26 -8
- package/dist/src/features/editor/use-cases.js +10 -3
- package/dist/src/features/org/use-cases.js +2 -1
- package/dist/src/features/task/store.js +4 -0
- package/dist/src/features/task/{agent-background.js → task-background.js} +5 -4
- package/dist/src/features/task/use-cases.js +123 -28
- package/dist/src/features/tool/catalog.js +11 -5
- package/dist/src/features/tool/dynamic-schema.js +9 -7
- package/dist/src/features/tool/mns-catalog-adapter.js +1 -0
- package/dist/src/features/tool/tool-api-adapter.js +8 -7
- package/dist/src/features/tool/use-cases.js +8 -4
- package/dist/src/features/update/update-notification.js +75 -70
- package/dist/src/features/update/update-service.js +24 -20
- package/dist/src/platform/file-lock.js +36 -9
- package/dist/src/platform/interruption.js +13 -0
- package/dist/src/platform/json-input.js +12 -9
- package/dist/src/platform/local-json-file.js +8 -4
- package/dist/src/platform/redact.js +7 -1
- package/dist/src/platform/remote-protocol.js +2 -2
- package/dist/src/platform/safe-upload-file.js +2 -1
- package/dist/src/platform/schema-issues.js +8 -0
- package/dist/src/platform/signed-http-transport.js +8 -7
- package/dist/src/platform/text-output.js +33 -0
- package/dist/src/telemetry/invocation.js +19 -4
- package/dist/src/telemetry/process-errors.js +14 -4
- package/dist/src/telemetry/sanitize.js +4 -2
- package/dist/src/telemetry/sls-sink.js +36 -20
- package/dist/vendor/README.md +10 -0
- package/dist/vendor/gd-tracker-node.mjs +1175 -0
- package/package.json +4 -4
|
@@ -21,8 +21,8 @@ export function wireEvent(event) {
|
|
|
21
21
|
wire[key] = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
22
22
|
}
|
|
23
23
|
for (const key of ["error_stack", "remote_error_body", "error_message"]) {
|
|
24
|
-
if (wire[key] && wire[key]
|
|
25
|
-
wire[key] = wire[key]
|
|
24
|
+
if (wire[key] && Buffer.byteLength(wire[key]) > 8192) {
|
|
25
|
+
wire[key] = utf8Prefix(wire[key], 8192);
|
|
26
26
|
wire.truncated = "true";
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -59,15 +59,21 @@ export function createSlsTelemetrySink(options) {
|
|
|
59
59
|
const entries = new Map();
|
|
60
60
|
let writes = Promise.resolve();
|
|
61
61
|
const file = (id) => createLocalJsonFile({ directory: options.directory, filename: `${id}.json` });
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
let exitDeadline = Infinity;
|
|
63
|
+
const locked = (run, deadline) => options.directory
|
|
64
|
+
? withFileLock(join(options.directory, ".lock"), run, { deadline: Math.min(deadline ?? Infinity, exitDeadline) }) : run();
|
|
65
|
+
function checkBudget(deadline) {
|
|
66
|
+
if (Date.now() >= deadline)
|
|
67
|
+
throw new Error("Telemetry delivery budget exhausted.");
|
|
68
|
+
}
|
|
69
|
+
async function load(deadline = exitDeadline) {
|
|
65
70
|
if (!options.directory)
|
|
66
71
|
return;
|
|
67
72
|
entries.clear();
|
|
68
73
|
await mkdir(options.directory, { recursive: true, mode: 0o700 });
|
|
69
74
|
await chmod(options.directory, 0o700);
|
|
70
75
|
for (const name of await readdir(options.directory)) {
|
|
76
|
+
checkBudget(deadline);
|
|
71
77
|
// All writers hold the same lock, so remaining atomic-write temporaries are orphaned.
|
|
72
78
|
if (/^(?:[a-f0-9]{64}|delivery-status)\.json\.tmp-[a-f0-9-]+$/u.test(name)) {
|
|
73
79
|
await unlink(join(options.directory, name)).catch(() => undefined);
|
|
@@ -76,8 +82,10 @@ export function createSlsTelemetrySink(options) {
|
|
|
76
82
|
}
|
|
77
83
|
if (!/^[a-f0-9]{64}\.json$/u.test(name))
|
|
78
84
|
continue;
|
|
85
|
+
// An unreadable valid record is not corrupt and must survive for replay.
|
|
86
|
+
const raw = await readFile(join(options.directory, name), "utf8");
|
|
79
87
|
try {
|
|
80
|
-
const entry = JSON.parse(
|
|
88
|
+
const entry = JSON.parse(raw);
|
|
81
89
|
if (!Number.isFinite(entry.queuedAt) || !entry.event || eventKey(entry.event) !== name.slice(0, -5))
|
|
82
90
|
throw new Error();
|
|
83
91
|
entries.set(name.slice(0, -5), entry);
|
|
@@ -110,8 +118,9 @@ export function createSlsTelemetrySink(options) {
|
|
|
110
118
|
if (options.directory)
|
|
111
119
|
await file(id).writeTextAtomically(JSON.stringify(entry));
|
|
112
120
|
}
|
|
113
|
-
async function trim() {
|
|
121
|
+
async function trim(deadline = exitDeadline) {
|
|
114
122
|
for (const [id, entry] of entries) {
|
|
123
|
+
checkBudget(deadline);
|
|
115
124
|
if (now() - entry.queuedAt > (options.retentionMs ?? TTL)) {
|
|
116
125
|
await remove(id);
|
|
117
126
|
await dropped("expired", 1);
|
|
@@ -121,6 +130,7 @@ export function createSlsTelemetrySink(options) {
|
|
|
121
130
|
const priority = (e) => e.event.event_name === "request_sent" || e.event.event_name === "result_ready" ? 2
|
|
122
131
|
: "outcome" in e.event && e.event.outcome !== "success" ? 1 : 0;
|
|
123
132
|
for (const [id, entry] of [...entries].sort((a, b) => priority(a[1]) - priority(b[1]) || a[1].queuedAt - b[1].queuedAt)) {
|
|
133
|
+
checkBudget(deadline);
|
|
124
134
|
if (size <= (options.maxBytes ?? CAPACITY))
|
|
125
135
|
break;
|
|
126
136
|
size -= Buffer.byteLength(JSON.stringify(entry));
|
|
@@ -128,21 +138,24 @@ export function createSlsTelemetrySink(options) {
|
|
|
128
138
|
await dropped("capacity", 1);
|
|
129
139
|
}
|
|
130
140
|
}
|
|
131
|
-
function enqueue(events) {
|
|
141
|
+
function enqueue(events, deadline) {
|
|
142
|
+
if (events.length === 0)
|
|
143
|
+
return writes;
|
|
132
144
|
writes = writes.catch(() => undefined).then(() => locked(async () => {
|
|
133
|
-
await load();
|
|
145
|
+
await load(deadline);
|
|
134
146
|
for (const event of events) {
|
|
147
|
+
checkBudget(deadline ?? exitDeadline);
|
|
135
148
|
const id = eventKey(event);
|
|
136
149
|
if (entries.has(id))
|
|
137
150
|
continue;
|
|
138
151
|
// Persist the sanitized, bounded wire payload and replay it unchanged.
|
|
139
152
|
await persist(id, { event: wireEvent(event), queuedAt: now(), nextAttempt: 0, attempts: 0 });
|
|
140
153
|
}
|
|
141
|
-
await trim();
|
|
142
|
-
})).catch(() => undefined);
|
|
143
|
-
if (options.background)
|
|
154
|
+
await trim(deadline);
|
|
155
|
+
}, deadline)).catch(() => undefined);
|
|
156
|
+
if (options.background && deadline === undefined)
|
|
144
157
|
void writes.then(() => { if (!sending)
|
|
145
|
-
void start(Date.now() + BUDGET); });
|
|
158
|
+
void start(Math.min(Date.now() + BUDGET, exitDeadline)); });
|
|
146
159
|
return writes;
|
|
147
160
|
}
|
|
148
161
|
let sending;
|
|
@@ -150,14 +163,14 @@ export function createSlsTelemetrySink(options) {
|
|
|
150
163
|
for (let attempt = 0; attempt < 2 && Date.now() < deadline; attempt++) {
|
|
151
164
|
let batch = [];
|
|
152
165
|
await locked(async () => {
|
|
153
|
-
await load();
|
|
154
|
-
await trim();
|
|
166
|
+
await load(deadline);
|
|
167
|
+
await trim(deadline);
|
|
155
168
|
let bytes = 0;
|
|
156
169
|
batch = [...entries].filter(([, e]) => e.nextAttempt <= now()).filter(([, e]) => {
|
|
157
170
|
bytes += Buffer.byteLength(JSON.stringify(e.event));
|
|
158
171
|
return bytes <= 512 * 1024;
|
|
159
172
|
}).slice(0, 100);
|
|
160
|
-
});
|
|
173
|
+
}, deadline);
|
|
161
174
|
if (!batch.length || Date.now() >= deadline)
|
|
162
175
|
return;
|
|
163
176
|
let response;
|
|
@@ -181,9 +194,12 @@ export function createSlsTelemetrySink(options) {
|
|
|
181
194
|
catch { /* Retain the original records for the next invocation. */ }
|
|
182
195
|
const accepted = response?.ok === true;
|
|
183
196
|
const rejected = response !== undefined && response.status >= 400 && response.status < 500 && response.status !== 429;
|
|
197
|
+
if (Date.now() >= deadline)
|
|
198
|
+
return; // Original records remain safe for at-least-once replay.
|
|
184
199
|
await locked(async () => {
|
|
185
|
-
await load();
|
|
200
|
+
await load(deadline);
|
|
186
201
|
for (const [id, original] of batch) {
|
|
202
|
+
checkBudget(deadline);
|
|
187
203
|
const entry = entries.get(id);
|
|
188
204
|
if (!entry)
|
|
189
205
|
continue;
|
|
@@ -195,7 +211,7 @@ export function createSlsTelemetrySink(options) {
|
|
|
195
211
|
}
|
|
196
212
|
if (rejected)
|
|
197
213
|
await dropped(`http_${response.status}`, batch.length);
|
|
198
|
-
});
|
|
214
|
+
}, deadline);
|
|
199
215
|
if (!accepted && (retryAfter > 0 || rejected))
|
|
200
216
|
return;
|
|
201
217
|
}
|
|
@@ -206,8 +222,8 @@ export function createSlsTelemetrySink(options) {
|
|
|
206
222
|
}
|
|
207
223
|
return { enqueue,
|
|
208
224
|
async send(events) {
|
|
209
|
-
const deadline = Date.now() + BUDGET;
|
|
210
|
-
await enqueue(events);
|
|
225
|
+
const deadline = exitDeadline = Date.now() + BUDGET;
|
|
226
|
+
await enqueue(events, deadline);
|
|
211
227
|
if (sending)
|
|
212
228
|
await sending;
|
|
213
229
|
if (Date.now() < deadline)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# GD-Tracker Node artifact
|
|
2
|
+
|
|
3
|
+
Official GD-Tracker `2.21.0-beta.5`, master source `5bdbdce78f6de06a74aac566cc962aa57a4eb78e`.
|
|
4
|
+
|
|
5
|
+
- Artifact: https://cdn.dancf.com/packages/gaoding/gd-tracker/2.21.0-beta.5/node.mjs
|
|
6
|
+
- SHA-256: `71c0ee126aae06386084ca2f955376122375f9448d623ed9f0dc2b07494f1387`
|
|
7
|
+
- Declarations: unmodified `types/node.d.ts` from that SDK source, saved as `.d.mts` for the ESM entry.
|
|
8
|
+
- Distribution contract: https://git.intra.gaoding.com/gaoding/gd-tracker/-/blob/master/website/docs/sdk/node-sdk.md
|
|
9
|
+
|
|
10
|
+
The build verifies and copies the standalone artifact into `dist/vendor`. Both public CLI tarballs include it. End-user installation and command execution never download executable SDK code or install private SDK dependencies. Upgrade the version, hash and declarations together.
|