@dypt/cli 0.1.21 → 0.1.23
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/README.md +35 -0
- package/dist/index.js +73 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,18 @@ npm install -g @dypt/cli
|
|
|
16
16
|
|
|
17
17
|
## Basic usage
|
|
18
18
|
|
|
19
|
+
For a single admin diagnostic request, set `DYPT_DB_MEASUREMENT` to an opaque
|
|
20
|
+
`m_` identifier (12–64 letters, digits, underscores, or hyphens after the
|
|
21
|
+
prefix). For example:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
DYPT_DB_MEASUREMENT=m_cli_usage_20260927 dypt task list --limit 10
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The server accepts the header only for the authenticated admin CLI actor and
|
|
28
|
+
emits one Sentry measurement event for that request. Use a distinct identifier
|
|
29
|
+
for each invocation, including an idempotent replay.
|
|
30
|
+
|
|
19
31
|
### Sign in
|
|
20
32
|
|
|
21
33
|
Authenticate the CLI with your dypt account:
|
|
@@ -217,6 +229,21 @@ dypt task list --limit 10 --json
|
|
|
217
229
|
dypt task get 123 --json
|
|
218
230
|
```
|
|
219
231
|
|
|
232
|
+
### Transport failures
|
|
233
|
+
|
|
234
|
+
Network failures exit `1`. With `--json`, fetch failures emit a
|
|
235
|
+
`CLI_TRANSPORT_ERROR` object on stderr containing a safe `message`, allowlisted
|
|
236
|
+
`causeCode` (or `null`), `category`, and `retryableRead`. Human output includes
|
|
237
|
+
the same safe cause code. URLs, tokens, headers, request bodies and raw error
|
|
238
|
+
messages are not included in these transport diagnostics.
|
|
239
|
+
|
|
240
|
+
`retryableRead` is guidance for a caller's bounded **read-only** retry, not
|
|
241
|
+
permission to replay writes. The CLI does not automatically retry requests or
|
|
242
|
+
claim a failed mutation made no change. Verify a mutation's outcome before
|
|
243
|
+
retrying it. Temporary DNS (`EAI_AGAIN`), connection resets and timeouts may
|
|
244
|
+
qualify; permanent DNS (`ENOTFOUND`), access and certificate errors do not.
|
|
245
|
+
Check network and sandbox configuration without automatically changing it.
|
|
246
|
+
|
|
220
247
|
### Maintenance responses
|
|
221
248
|
|
|
222
249
|
If dypt is in maintenance mode, API-backed commands stop after the first `503`
|
|
@@ -310,3 +337,11 @@ email [support@dypt.app](mailto:support@dypt.app).
|
|
|
310
337
|
|
|
311
338
|
This package is distributed under a custom proprietary license. See
|
|
312
339
|
[LICENSE](./LICENSE).
|
|
340
|
+
|
|
341
|
+
### Note-search workload limit
|
|
342
|
+
|
|
343
|
+
`dypt note search` returns a complete array for searches with at most 1,000
|
|
344
|
+
candidate notes. Broader searches fail with `CLI_NOTE_SEARCH_TOO_BROAD` and ask
|
|
345
|
+
you to narrow the query; results are never silently truncated. This is a fixed
|
|
346
|
+
workload limit, so retrying the same broad query will not help. Candidates
|
|
347
|
+
subsequently rejected by current permissions also count toward this limit.
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Argument, Command, Option } from "commander";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "@dypt/cli",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.23",
|
|
13
13
|
description: "Command-line interface for dypt task management",
|
|
14
14
|
license: "SEE LICENSE IN LICENSE",
|
|
15
15
|
homepage: "https://dypt.app",
|
|
@@ -286,6 +286,65 @@ async function clearCliToken(baseUrl = getBaseUrl(), filePath) {
|
|
|
286
286
|
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
|
|
287
287
|
import superjson from "superjson";
|
|
288
288
|
|
|
289
|
+
// src/lib/transport.ts
|
|
290
|
+
var causes = {
|
|
291
|
+
ENOTFOUND: ["dns", false],
|
|
292
|
+
EAI_AGAIN: ["dns", true],
|
|
293
|
+
ECONNRESET: ["connection", true],
|
|
294
|
+
ECONNREFUSED: ["connection", true],
|
|
295
|
+
EPIPE: ["connection", true],
|
|
296
|
+
UND_ERR_SOCKET: ["connection", true],
|
|
297
|
+
ETIMEDOUT: ["timeout", true],
|
|
298
|
+
UND_ERR_CONNECT_TIMEOUT: ["timeout", true],
|
|
299
|
+
UND_ERR_HEADERS_TIMEOUT: ["timeout", true],
|
|
300
|
+
UND_ERR_BODY_TIMEOUT: ["timeout", true],
|
|
301
|
+
EACCES: ["access", false],
|
|
302
|
+
EPERM: ["access", false],
|
|
303
|
+
CERT_HAS_EXPIRED: ["tls", false],
|
|
304
|
+
DEPTH_ZERO_SELF_SIGNED_CERT: ["tls", false],
|
|
305
|
+
UNABLE_TO_VERIFY_LEAF_SIGNATURE: ["tls", false],
|
|
306
|
+
ERR_TLS_CERT_ALTNAME_INVALID: ["tls", false]
|
|
307
|
+
};
|
|
308
|
+
function errorChain(error) {
|
|
309
|
+
const seen = /* @__PURE__ */ new Set();
|
|
310
|
+
const pending = [error];
|
|
311
|
+
while (pending.length && seen.size < 16) {
|
|
312
|
+
const current = pending.shift();
|
|
313
|
+
if (!current || typeof current !== "object" || seen.has(current)) continue;
|
|
314
|
+
seen.add(current);
|
|
315
|
+
pending.push(current.cause);
|
|
316
|
+
if (current instanceof AggregateError)
|
|
317
|
+
pending.push(...current.errors.slice(0, 16));
|
|
318
|
+
}
|
|
319
|
+
return [...seen];
|
|
320
|
+
}
|
|
321
|
+
var CliTransportError = class extends Error {
|
|
322
|
+
constructor(error) {
|
|
323
|
+
super("Unable to complete the dypt network request.");
|
|
324
|
+
this.code = "CLI_TRANSPORT_ERROR";
|
|
325
|
+
this.name = "CliTransportError";
|
|
326
|
+
const known = errorChain(error).map((item) => item.code).filter(
|
|
327
|
+
(code) => typeof code === "string" && Object.hasOwn(causes, code)
|
|
328
|
+
);
|
|
329
|
+
this.causeCode = known.find((code) => !causes[code][1]) ?? known[0] ?? null;
|
|
330
|
+
[this.category, this.retryableRead] = this.causeCode ? causes[this.causeCode] : ["unknown", false];
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function formatTransportFailure(error, json) {
|
|
334
|
+
const transport = errorChain(error).find(
|
|
335
|
+
(item) => item instanceof CliTransportError
|
|
336
|
+
);
|
|
337
|
+
if (!transport) return null;
|
|
338
|
+
const { code, message, causeCode, category, retryableRead } = transport;
|
|
339
|
+
const guidance = retryableRead ? "Only read-only requests may be retried; verify the outcome before retrying a write." : "Check network, DNS, TLS and sandbox access; do not change permissions automatically.";
|
|
340
|
+
return {
|
|
341
|
+
exitCode: 1,
|
|
342
|
+
output: json ? JSON.stringify({
|
|
343
|
+
error: { code, message, causeCode, category, retryableRead }
|
|
344
|
+
}) : `${message} ${category}${causeCode ? ` (${causeCode})` : ""}. ${guidance}`
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
289
348
|
// src/lib/maintenance.ts
|
|
290
349
|
var DYPT_MAINTENANCE_CODE = "DYPT_MAINTENANCE";
|
|
291
350
|
var DYPT_MAINTENANCE_EXIT_CODE = 75;
|
|
@@ -332,7 +391,12 @@ async function getMaintenanceError(response) {
|
|
|
332
391
|
);
|
|
333
392
|
}
|
|
334
393
|
async function fetchWithMaintenanceCheck(input, init) {
|
|
335
|
-
|
|
394
|
+
let response;
|
|
395
|
+
try {
|
|
396
|
+
response = await globalThis.fetch(input, init);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
throw new CliTransportError(error);
|
|
399
|
+
}
|
|
336
400
|
const maintenanceError = await getMaintenanceError(response);
|
|
337
401
|
if (maintenanceError) throw maintenanceError;
|
|
338
402
|
return response;
|
|
@@ -384,6 +448,8 @@ function formatRetryGuidance(error) {
|
|
|
384
448
|
return " Retry later.";
|
|
385
449
|
}
|
|
386
450
|
function formatCliFailure(error, json) {
|
|
451
|
+
const transportFailure = formatTransportFailure(error, json);
|
|
452
|
+
if (transportFailure) return transportFailure;
|
|
387
453
|
const maintenanceError = findMaintenanceError(error);
|
|
388
454
|
const readRateLimitError = findCliReadRateLimitError(error);
|
|
389
455
|
if (readRateLimitError) {
|
|
@@ -455,9 +521,11 @@ async function createCliTrpcClient(options = {}) {
|
|
|
455
521
|
transformer: superjson,
|
|
456
522
|
fetch: fetchWithMaintenanceCheck,
|
|
457
523
|
headers() {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
524
|
+
const measurementId = process.env.DYPT_DB_MEASUREMENT;
|
|
525
|
+
return {
|
|
526
|
+
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
|
|
527
|
+
...measurementId ? { "x-dypt-db-measurement": measurementId } : {}
|
|
528
|
+
};
|
|
461
529
|
}
|
|
462
530
|
})
|
|
463
531
|
]
|