@dharta/cli 0.6.77 → 0.6.78
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/LICENSE +1 -1
- package/README.md +215 -11
- package/dist/agent.js +3 -2
- package/dist/agent.js.map +1 -1
- package/dist/api-error.js +6 -6
- package/dist/api-error.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +860 -149
- package/dist/cli.js.map +1 -1
- package/dist/command-tree.d.ts +3 -0
- package/dist/command-tree.js +10 -0
- package/dist/command-tree.js.map +1 -0
- package/dist/commands/agents.d.ts +54 -17
- package/dist/commands/agents.js +246 -136
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/analytics.js +6 -5
- package/dist/commands/analytics.js.map +1 -1
- package/dist/commands/api.js +71 -86
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/appearance.js +5 -6
- package/dist/commands/appearance.js.map +1 -1
- package/dist/commands/artifact.js +7 -6
- package/dist/commands/artifact.js.map +1 -1
- package/dist/commands/audit-log.js +2 -1
- package/dist/commands/audit-log.js.map +1 -1
- package/dist/commands/auth.js +26 -6
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/caps.js +11 -15
- package/dist/commands/caps.js.map +1 -1
- package/dist/commands/deploy.js +25 -10
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +10 -1
- package/dist/commands/dev.js +56 -25
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +60 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/embed-keys.js +4 -13
- package/dist/commands/embed-keys.js.map +1 -1
- package/dist/commands/env.js +4 -7
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/files.js +3 -4
- package/dist/commands/files.js.map +1 -1
- package/dist/commands/fleet.d.ts +129 -0
- package/dist/commands/fleet.js +408 -0
- package/dist/commands/fleet.js.map +1 -0
- package/dist/commands/genui.d.ts +2 -0
- package/dist/commands/genui.js +53 -0
- package/dist/commands/genui.js.map +1 -0
- package/dist/commands/git-credential.js +2 -3
- package/dist/commands/git-credential.js.map +1 -1
- package/dist/commands/kartas.d.ts +9 -0
- package/dist/commands/kartas.js +33 -11
- package/dist/commands/kartas.js.map +1 -1
- package/dist/commands/keys.d.ts +17 -18
- package/dist/commands/keys.js +108 -19
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/login.js +2 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/members.d.ts +10 -0
- package/dist/commands/members.js +20 -6
- package/dist/commands/members.js.map +1 -1
- package/dist/commands/model-connections.d.ts +44 -0
- package/dist/commands/model-connections.js +435 -0
- package/dist/commands/model-connections.js.map +1 -0
- package/dist/commands/open.d.ts +2 -2
- package/dist/commands/open.js +4 -3
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/org.d.ts +9 -0
- package/dist/commands/org.js +42 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/organization.d.ts +16 -0
- package/dist/commands/organization.js +118 -0
- package/dist/commands/organization.js.map +1 -0
- package/dist/commands/parity.js +1 -3
- package/dist/commands/parity.js.map +1 -1
- package/dist/commands/repos.d.ts +4 -0
- package/dist/commands/repos.js +17 -0
- package/dist/commands/repos.js.map +1 -0
- package/dist/commands/rollback.js +2 -3
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/schedules.js +26 -21
- package/dist/commands/schedules.js.map +1 -1
- package/dist/commands/scopes.js +8 -1
- package/dist/commands/scopes.js.map +1 -1
- package/dist/commands/sessions.js +9 -3
- package/dist/commands/sessions.js.map +1 -1
- package/dist/commands/setup.js +5 -4
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/update.d.ts +1 -0
- package/dist/commands/update.js +24 -11
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/webhooks.d.ts +4 -1
- package/dist/commands/webhooks.js +21 -16
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/completions.js +24 -13
- package/dist/completions.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.js +121 -7
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.js +23 -7
- package/dist/context.js.map +1 -1
- package/dist/docs/cli-reference.d.ts +2 -0
- package/dist/docs/cli-reference.js +191 -0
- package/dist/docs/cli-reference.js.map +1 -0
- package/dist/exit-codes.d.ts +25 -0
- package/dist/exit-codes.js +107 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/genui.d.ts +178 -0
- package/dist/genui.js +1130 -0
- package/dist/genui.js.map +1 -0
- package/dist/harnesses.js +2 -1
- package/dist/harnesses.js.map +1 -1
- package/dist/jq.d.ts +4 -0
- package/dist/jq.js +91 -0
- package/dist/jq.js.map +1 -0
- package/dist/login-offer.js +6 -2
- package/dist/login-offer.js.map +1 -1
- package/dist/manifest.d.ts +12 -0
- package/dist/manifest.js +126 -0
- package/dist/manifest.js.map +1 -1
- package/dist/model-auth.d.ts +29 -0
- package/dist/model-auth.js +117 -0
- package/dist/model-auth.js.map +1 -0
- package/dist/model-settings.d.ts +23 -0
- package/dist/model-settings.js +186 -0
- package/dist/model-settings.js.map +1 -0
- package/dist/money.js +2 -1
- package/dist/money.js.map +1 -1
- package/dist/output.d.ts +6 -0
- package/dist/output.js +54 -0
- package/dist/output.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/scaffold.js +2 -1
- package/dist/scaffold.js.map +1 -1
- package/dist/validators.js +17 -11
- package/dist/validators.js.map +1 -1
- package/dist/version-check.d.ts +1 -1
- package/dist/version-check.js +1 -1
- package/dist/version-check.js.map +1 -1
- package/node_modules/@dharta/contracts/LICENSE +21 -0
- package/node_modules/@dharta/contracts/README.md +45 -0
- package/node_modules/@dharta/contracts/artifact-runtime.json +750 -0
- package/node_modules/@dharta/contracts/dist/activity.d.ts +62 -0
- package/node_modules/@dharta/contracts/dist/activity.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/activity.js +178 -0
- package/node_modules/@dharta/contracts/dist/activity.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.d.ts +20 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.js +53 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.d.ts +37 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.js +5107 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.d.ts +154 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.d.ts +1670 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.js +1903 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.js +377 -0
- package/node_modules/@dharta/contracts/dist/artifact-runtime.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/index.d.ts +6 -0
- package/node_modules/@dharta/contracts/dist/index.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/index.js +6 -0
- package/node_modules/@dharta/contracts/dist/index.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/model-auth.d.ts +31 -0
- package/node_modules/@dharta/contracts/dist/model-auth.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/model-auth.js +45 -0
- package/node_modules/@dharta/contracts/dist/model-auth.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/tasks.d.ts +44 -0
- package/node_modules/@dharta/contracts/dist/tasks.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/tasks.js +127 -0
- package/node_modules/@dharta/contracts/dist/tasks.js.map +1 -0
- package/node_modules/@dharta/contracts/dist/wire-events.d.ts +71 -0
- package/node_modules/@dharta/contracts/dist/wire-events.d.ts.map +1 -0
- package/node_modules/@dharta/contracts/dist/wire-events.js +48 -0
- package/node_modules/@dharta/contracts/dist/wire-events.js.map +1 -0
- package/node_modules/@dharta/contracts/model-auth-capabilities-v1.json +168 -0
- package/node_modules/@dharta/contracts/model-auth-reasons-v1.json +38 -0
- package/node_modules/@dharta/contracts/package.json +44 -0
- package/node_modules/@dharta/contracts/src/activity.ts +215 -0
- package/node_modules/@dharta/contracts/src/artifact-runtime-formats.ts +54 -0
- package/node_modules/@dharta/contracts/src/artifact-runtime-validators.generated.ts +29 -0
- package/node_modules/@dharta/contracts/src/artifact-runtime.generated.ts +2093 -0
- package/node_modules/@dharta/contracts/src/artifact-runtime.ts +520 -0
- package/node_modules/@dharta/contracts/src/index.ts +5 -0
- package/node_modules/@dharta/contracts/src/model-auth.ts +82 -0
- package/node_modules/@dharta/contracts/src/tasks.ts +142 -0
- package/node_modules/@dharta/contracts/src/wire-events.ts +150 -0
- package/node_modules/@dharta/contracts/wire-events.json +29 -0
- package/node_modules/@dharta/sdk/LICENSE +1 -1
- package/node_modules/@dharta/sdk/README.md +22 -8
- package/node_modules/@dharta/sdk/dist/errors.d.ts +9 -7
- package/node_modules/@dharta/sdk/dist/errors.d.ts.map +1 -1
- package/node_modules/@dharta/sdk/dist/errors.js +36 -18
- package/node_modules/@dharta/sdk/dist/errors.js.map +1 -1
- package/node_modules/@dharta/sdk/dist/fleet.d.ts +69 -0
- package/node_modules/@dharta/sdk/dist/fleet.d.ts.map +1 -0
- package/node_modules/@dharta/sdk/dist/fleet.js +240 -0
- package/node_modules/@dharta/sdk/dist/fleet.js.map +1 -0
- package/node_modules/@dharta/sdk/dist/http.d.ts +6 -2
- package/node_modules/@dharta/sdk/dist/http.d.ts.map +1 -1
- package/node_modules/@dharta/sdk/dist/http.js +71 -12
- package/node_modules/@dharta/sdk/dist/http.js.map +1 -1
- package/node_modules/@dharta/sdk/dist/idempotency.d.ts +12 -0
- package/node_modules/@dharta/sdk/dist/idempotency.d.ts.map +1 -0
- package/node_modules/@dharta/sdk/dist/idempotency.js +72 -0
- package/node_modules/@dharta/sdk/dist/idempotency.js.map +1 -0
- package/node_modules/@dharta/sdk/dist/index.d.ts +20 -6
- package/node_modules/@dharta/sdk/dist/index.d.ts.map +1 -1
- package/node_modules/@dharta/sdk/dist/index.js +27 -4
- package/node_modules/@dharta/sdk/dist/index.js.map +1 -1
- package/node_modules/@dharta/sdk/dist/resources.d.ts +108 -13
- package/node_modules/@dharta/sdk/dist/resources.d.ts.map +1 -1
- package/node_modules/@dharta/sdk/dist/resources.js +403 -57
- package/node_modules/@dharta/sdk/dist/resources.js.map +1 -1
- package/node_modules/@dharta/sdk/dist/types.d.ts +436 -16
- package/node_modules/@dharta/sdk/dist/types.d.ts.map +1 -1
- package/node_modules/@dharta/sdk/dist/types.js +31 -2
- package/node_modules/@dharta/sdk/dist/types.js.map +1 -1
- package/node_modules/@dharta/sdk/package.json +9 -3
- package/node_modules/@dharta/sdk/src/errors.ts +41 -18
- package/node_modules/@dharta/sdk/src/fleet.ts +339 -0
- package/node_modules/@dharta/sdk/src/http.ts +110 -17
- package/node_modules/@dharta/sdk/src/idempotency.ts +101 -0
- package/node_modules/@dharta/sdk/src/index.ts +50 -11
- package/node_modules/@dharta/sdk/src/resources.ts +549 -68
- package/node_modules/@dharta/sdk/src/types.ts +629 -20
- package/package.json +16 -6
- package/src/agent.ts +3 -2
- package/src/api-error.ts +6 -5
- package/src/cli.ts +978 -163
- package/src/command-tree.ts +13 -0
- package/src/commands/agents.ts +365 -167
- package/src/commands/analytics.ts +6 -5
- package/src/commands/api.ts +73 -92
- package/src/commands/appearance.ts +5 -6
- package/src/commands/artifact.ts +7 -6
- package/src/commands/audit-log.ts +2 -1
- package/src/commands/auth.ts +25 -5
- package/src/commands/caps.ts +11 -15
- package/src/commands/deploy.ts +18 -4
- package/src/commands/dev.ts +86 -25
- package/src/commands/doctor.ts +69 -0
- package/src/commands/embed-keys.ts +4 -14
- package/src/commands/env.ts +4 -7
- package/src/commands/files.ts +3 -4
- package/src/commands/fleet.ts +672 -0
- package/src/commands/genui.ts +59 -0
- package/src/commands/git-credential.ts +2 -3
- package/src/commands/kartas.ts +45 -11
- package/src/commands/keys.ts +152 -35
- package/src/commands/login.ts +2 -1
- package/src/commands/members.ts +31 -6
- package/src/commands/model-connections.ts +547 -0
- package/src/commands/open.ts +5 -4
- package/src/commands/org.ts +57 -0
- package/src/commands/organization.ts +153 -0
- package/src/commands/parity.ts +1 -3
- package/src/commands/repos.ts +23 -0
- package/src/commands/rollback.ts +2 -3
- package/src/commands/schedules.ts +33 -22
- package/src/commands/scopes.ts +8 -1
- package/src/commands/sessions.ts +9 -3
- package/src/commands/setup.ts +5 -4
- package/src/commands/update.ts +28 -12
- package/src/commands/webhooks.ts +30 -19
- package/src/completions.ts +25 -13
- package/src/config.ts +141 -9
- package/src/context.ts +34 -7
- package/src/docs/cli-reference.ts +206 -0
- package/src/exit-codes.ts +122 -0
- package/src/genui.ts +1398 -0
- package/src/harnesses.ts +2 -1
- package/src/jq.ts +109 -0
- package/src/login-offer.ts +6 -2
- package/src/manifest.ts +134 -0
- package/src/model-auth.ts +173 -0
- package/src/model-settings.ts +222 -0
- package/src/money.ts +5 -1
- package/src/output.ts +60 -0
- package/src/runtime.ts +1 -1
- package/src/scaffold.ts +2 -1
- package/src/validators.ts +18 -11
- package/src/version-check.ts +1 -1
- package/dist/commands/model-keys.d.ts +0 -22
- package/dist/commands/model-keys.js +0 -222
- package/dist/commands/model-keys.js.map +0 -1
- package/src/commands/model-keys.ts +0 -278
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Exit-code taxonomy (RFC 0048 D1/P5). A script that pipes `dharta` needs to
|
|
2
|
+
// branch on *why* a command failed without parsing English, so every failure
|
|
3
|
+
// maps to one of these codes. The numbers are a public contract: change a
|
|
4
|
+
// meaning and every caller's `if [ $? -eq 4 ]` silently means something else.
|
|
5
|
+
//
|
|
6
|
+
// `dharta doctor` is the one exception: it reports an unhealthy local setup
|
|
7
|
+
// with its own exit 1 without throwing, so it never reaches this map.
|
|
8
|
+
import { INVALID_IDEMPOTENCY_KEY_CODE } from "@dharta/sdk";
|
|
9
|
+
export const EXIT_SUCCESS = 0;
|
|
10
|
+
export const EXIT_GENERAL = 1;
|
|
11
|
+
export const EXIT_USAGE = 2;
|
|
12
|
+
export const EXIT_NOT_AUTHENTICATED = 3;
|
|
13
|
+
export const EXIT_FORBIDDEN = 4;
|
|
14
|
+
export const EXIT_NOT_FOUND = 5;
|
|
15
|
+
export const EXIT_VALIDATION = 6;
|
|
16
|
+
export const EXIT_NETWORK = 7;
|
|
17
|
+
// A wrong invocation: an unknown flag, a bad choice, a missing argument, a
|
|
18
|
+
// profile that is not in the config file. Commander raises its own version of
|
|
19
|
+
// this; throw CliUsageError for the ones the CLI detects itself.
|
|
20
|
+
//
|
|
21
|
+
// The line, applied across every curated command (RFC 0048 P9): a throw that
|
|
22
|
+
// rejects a value the caller TYPED is a usage error. A throw that reports the
|
|
23
|
+
// state of the world - a file that is not there, a server too old to answer, a
|
|
24
|
+
// build that failed - is a plain Error and exits 1. `test/usage-exit-code.test.ts`
|
|
25
|
+
// holds both halves: a table exercising each validator, and a source scan that
|
|
26
|
+
// makes a new plain Error in a command module argue for itself.
|
|
27
|
+
export class CliUsageError extends Error {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "CliUsageError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// The control plane answered with a non-2xx status.
|
|
34
|
+
export class CliApiError extends Error {
|
|
35
|
+
status;
|
|
36
|
+
body;
|
|
37
|
+
constructor(message, status, body) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "CliApiError";
|
|
40
|
+
this.status = status;
|
|
41
|
+
this.body = body;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// The control plane could not be reached at all (DNS, refused connection, TLS).
|
|
45
|
+
// Distinct from CliApiError: retrying may help, and no request was authorized.
|
|
46
|
+
export class CliNetworkError extends Error {
|
|
47
|
+
url;
|
|
48
|
+
constructor(message, url) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "CliNetworkError";
|
|
51
|
+
this.url = url;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function isCommanderError(err) {
|
|
55
|
+
const code = err?.code;
|
|
56
|
+
return typeof code === "string" && code.startsWith("commander.");
|
|
57
|
+
}
|
|
58
|
+
export function exitCodeForError(err) {
|
|
59
|
+
if (isCommanderError(err)) {
|
|
60
|
+
const exitCode = err.exitCode;
|
|
61
|
+
return exitCode === 0 ? EXIT_SUCCESS : EXIT_USAGE;
|
|
62
|
+
}
|
|
63
|
+
if (err instanceof CliUsageError)
|
|
64
|
+
return EXIT_USAGE;
|
|
65
|
+
// The SDK rejects a malformed Idempotency-Key wherever it was supplied,
|
|
66
|
+
// including a header a caller wrote by hand with `dharta api -H`, which never
|
|
67
|
+
// passes through a CLI validator. It is still a value the caller typed, so it
|
|
68
|
+
// gets the code every other rejected value gets. Matched on the stable `code`
|
|
69
|
+
// rather than the class, so a duplicated SDK install cannot break it.
|
|
70
|
+
if (isInvalidIdempotencyKeyError(err))
|
|
71
|
+
return EXIT_USAGE;
|
|
72
|
+
if (err instanceof CliNetworkError)
|
|
73
|
+
return EXIT_NETWORK;
|
|
74
|
+
const status = err?.status;
|
|
75
|
+
if (typeof status === "number")
|
|
76
|
+
return exitCodeForStatus(status);
|
|
77
|
+
if (isNotAuthenticatedError(err))
|
|
78
|
+
return EXIT_NOT_AUTHENTICATED;
|
|
79
|
+
return EXIT_GENERAL;
|
|
80
|
+
}
|
|
81
|
+
// `Not logged in.` is raised locally when no credential is stored, before any
|
|
82
|
+
// request goes out. It is the same condition a 401 reports, so it gets the same
|
|
83
|
+
// exit code - otherwise `dharta whoami` means one thing logged out and another
|
|
84
|
+
// with a revoked key. Commands that fall back when unauthenticated test the
|
|
85
|
+
// same predicate, so the two readings cannot drift apart.
|
|
86
|
+
export function isInvalidIdempotencyKeyError(err) {
|
|
87
|
+
return err?.code === INVALID_IDEMPOTENCY_KEY_CODE;
|
|
88
|
+
}
|
|
89
|
+
export function isNotAuthenticatedError(err) {
|
|
90
|
+
return err instanceof Error && /^Not logged in\b/.test(err.message);
|
|
91
|
+
}
|
|
92
|
+
export function exitCodeForStatus(status) {
|
|
93
|
+
switch (status) {
|
|
94
|
+
case 401:
|
|
95
|
+
return EXIT_NOT_AUTHENTICATED;
|
|
96
|
+
case 403:
|
|
97
|
+
return EXIT_FORBIDDEN;
|
|
98
|
+
case 404:
|
|
99
|
+
return EXIT_NOT_FOUND;
|
|
100
|
+
case 409:
|
|
101
|
+
case 422:
|
|
102
|
+
return EXIT_VALIDATION;
|
|
103
|
+
default:
|
|
104
|
+
return EXIT_GENERAL;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=exit-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../src/exit-codes.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,EAAE;AACF,4EAA4E;AAC5E,sEAAsE;AAEtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,cAAc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QACzB;YACE,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC"}
|
package/dist/genui.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export declare const BUNDLE_FORMAT = "dharta.genui-bundle.v1";
|
|
2
|
+
export declare const MAX_BUNDLE_BYTES: number;
|
|
3
|
+
export declare const MAX_COMPONENTS = 128;
|
|
4
|
+
export declare const MAX_WORKER_BYTES: number;
|
|
5
|
+
export declare const MAX_HTML_BYTES: number;
|
|
6
|
+
export declare const MAX_EVENTS = 64;
|
|
7
|
+
export declare const MAX_EVENT_NAME_LENGTH = 128;
|
|
8
|
+
export declare const EVENT_CADENCES: readonly ["agent_action", "reference", "side_effect"];
|
|
9
|
+
export declare const TIER1_BUILTINS: readonly ["Badge", "Button", "Card", "Checkbox", "Column", "Divider", "Heading", "Row", "Select", "Text", "TextField"];
|
|
10
|
+
export declare const IDENTIFIER: RegExp;
|
|
11
|
+
export declare const DEFAULT_SOURCE_DIR = "genui/components";
|
|
12
|
+
export declare const COMPONENT_SPEC_FILE = "component.json";
|
|
13
|
+
export declare const TIER2_SOURCE_FILE = "worker.js";
|
|
14
|
+
export declare const TIER3_SOURCE_FILE = "index.html";
|
|
15
|
+
/** A `[genui]` section, or a bundle, that the data plane would reject. */
|
|
16
|
+
export declare class GenuiError extends Error {
|
|
17
|
+
}
|
|
18
|
+
export interface GenuiComponent {
|
|
19
|
+
name: string;
|
|
20
|
+
tier: 1 | 2 | 3;
|
|
21
|
+
}
|
|
22
|
+
export interface GenuiSection {
|
|
23
|
+
catalogId: string;
|
|
24
|
+
version: number;
|
|
25
|
+
/** Release-relative path to the built bundle; null when Tier-1 only. */
|
|
26
|
+
bundle: string | null;
|
|
27
|
+
bundleSha256: string | null;
|
|
28
|
+
components: GenuiComponent[];
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
/** Release-relative component source folder, from `[genui.build] source`. */
|
|
31
|
+
source: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ParseGenuiOptions {
|
|
34
|
+
/**
|
|
35
|
+
* The data plane requires bundle_sha256 whenever bundle is set, and so does
|
|
36
|
+
* every read path here. `dharta genui build` is the one exception: it is the
|
|
37
|
+
* thing that produces the digest, so it must be able to parse a manifest that
|
|
38
|
+
* declares a bundle it has not built yet.
|
|
39
|
+
*/
|
|
40
|
+
requireDigest?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The manifest's raw text. Supplied so `version` can be judged by its TOML
|
|
43
|
+
* literal rather than by the JavaScript number it parsed to - see
|
|
44
|
+
* `rejectFloatVersion`.
|
|
45
|
+
*/
|
|
46
|
+
text?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse the `[genui]` table out of a loaded `dharta.toml`. Returns null when
|
|
50
|
+
* there is no section (generative UI is opt-in); throws `GenuiError` on a
|
|
51
|
+
* section the data plane would reject.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseGenuiSection(manifest: Record<string, unknown>, options?: ParseGenuiOptions): GenuiSection | null;
|
|
54
|
+
/**
|
|
55
|
+
* The catalog the data plane synthesizes when `[genui]` declares no bundle
|
|
56
|
+
* (bundle.py load_genui_bundle_with_bytes). It runs the SAME payload validation
|
|
57
|
+
* over it, so a Tier-1-only catalog is not unvalidated: a component whose name
|
|
58
|
+
* is not a Dharta builtin, or a 129th component, is rejected at deploy.
|
|
59
|
+
*/
|
|
60
|
+
export declare function synthesizeBundlePayload(section: GenuiSection): Record<string, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Throw `GenuiError` unless `payload` is a bundle this manifest can ship.
|
|
63
|
+
*
|
|
64
|
+
* `rawText` is the bundle file's bytes as read off disk, when there was one.
|
|
65
|
+
* The whole integer rule lives here because JavaScript cannot see it in the
|
|
66
|
+
* parsed value: `JSON.parse` collapses `1.0` to `1`, while Python's
|
|
67
|
+
* `json.loads` yields a float that fails `isinstance(..., int)`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function validateBundlePayload(payload: unknown, section: GenuiSection, rawText?: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Byte-for-byte reproducible JSON, matching the data plane's own canonical form
|
|
72
|
+
* (`json.dumps(..., ensure_ascii=True, separators=(",", ":"), sort_keys=True)`):
|
|
73
|
+
* sorted keys, compact separators, ASCII only. The digest recorded in
|
|
74
|
+
* dharta.toml is over these exact bytes, so a rebuild of unchanged sources must
|
|
75
|
+
* produce an unchanged file.
|
|
76
|
+
*
|
|
77
|
+
* Written out key by key rather than sorted into an object and handed to
|
|
78
|
+
* `JSON.stringify`, because a JavaScript object does not preserve the order you
|
|
79
|
+
* insert integer-like keys in: it emits those first, in ascending numeric
|
|
80
|
+
* order. `{"1","10","2","alpha"}` is Python's order and `{"1","2","10","alpha"}`
|
|
81
|
+
* is what an object round-trip produces, which is a different digest for the
|
|
82
|
+
* same catalog.
|
|
83
|
+
*
|
|
84
|
+
* Numbers are JavaScript doubles, and this writes back whatever `JSON.parse`
|
|
85
|
+
* produced. `1.0` therefore serializes as `1` and `-0.0` as `0` - the source
|
|
86
|
+
* spelling is already gone by the time the value gets here, and re-deriving it
|
|
87
|
+
* is not possible. Both forms are the same double on the data plane too, so
|
|
88
|
+
* this only ever narrows the spelling, never the value.
|
|
89
|
+
*
|
|
90
|
+
* Two shapes a double cannot carry at all: an integer beyond
|
|
91
|
+
* `Number.MAX_SAFE_INTEGER`, which arrives already rounded, and a float that
|
|
92
|
+
* overflows a double, which arrives as `Infinity` and would be written out as
|
|
93
|
+
* `null`. `findUnsafeNumberLiteral` refuses both in a component.json rather
|
|
94
|
+
* than letting the build ship a number the source never wrote.
|
|
95
|
+
*/
|
|
96
|
+
export declare function canonicalJson(value: unknown): string;
|
|
97
|
+
export declare function sha256Hex(bytes: Buffer | string): string;
|
|
98
|
+
/** A `dharta.toml` read once and reused by every genui code path. */
|
|
99
|
+
export interface ManifestSource {
|
|
100
|
+
path: string;
|
|
101
|
+
text: string;
|
|
102
|
+
parsed: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
export interface LoadedGenui extends ManifestSource {
|
|
105
|
+
section: GenuiSection | null;
|
|
106
|
+
}
|
|
107
|
+
/** Read `dir/dharta.toml`. Throws when it is missing or unparseable. */
|
|
108
|
+
export declare function readManifest(dir: string): Promise<ManifestSource>;
|
|
109
|
+
/**
|
|
110
|
+
* Read and parse an agent's `[genui]` section once. Every command path threads
|
|
111
|
+
* the result rather than re-reading the manifest: `dharta dev`'s doctor already
|
|
112
|
+
* holds a parsed one and hands it straight in.
|
|
113
|
+
*/
|
|
114
|
+
export declare function loadGenui(source: string | ManifestSource, options?: ParseGenuiOptions): Promise<LoadedGenui>;
|
|
115
|
+
export interface GenuiCheck {
|
|
116
|
+
manifest: string;
|
|
117
|
+
/** Null when there is no [genui] section, or when it failed to parse. */
|
|
118
|
+
section: GenuiSection | null;
|
|
119
|
+
/** Every reason the data plane would reject this release. Empty = accepted. */
|
|
120
|
+
problems: string[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Report every reason the data plane would reject this agent's `[genui]`
|
|
124
|
+
* declaration. Shared by `dharta genui check`, `dharta dev`'s doctor
|
|
125
|
+
* (warnings), and the deploy pre-flight (refusal) so all three say the same
|
|
126
|
+
* thing. Pass an already-read manifest to avoid a second read.
|
|
127
|
+
*/
|
|
128
|
+
export declare function checkGenui(source: string | ManifestSource): Promise<GenuiCheck>;
|
|
129
|
+
export interface GenuiPreflightOptions {
|
|
130
|
+
/**
|
|
131
|
+
* The files this deploy will actually ship, release-relative. Deploy sends a
|
|
132
|
+
* Git-filtered tree (committed HEAD, or a gitignore-honoring tarball) while
|
|
133
|
+
* every check here reads the WORKING tree, so an ignored bundle passes
|
|
134
|
+
* locally and arrives missing. Asking the deploy's own file list - rather
|
|
135
|
+
* than re-deriving the answer from ignore rules - gets force-added files and
|
|
136
|
+
* non-ASCII names right for free. Optional: without it the pre-flight simply
|
|
137
|
+
* skips that question.
|
|
138
|
+
*/
|
|
139
|
+
deployFiles?: () => Promise<string[]>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Deploy pre-flight: refuse locally, before anything is pushed or uploaded,
|
|
143
|
+
* with the message the release validator would return.
|
|
144
|
+
*/
|
|
145
|
+
export declare function genuiPreflight(dir: string, options?: GenuiPreflightOptions): Promise<void>;
|
|
146
|
+
export interface GenuiStatus {
|
|
147
|
+
manifest: string;
|
|
148
|
+
/** False when there is no [genui] section: generative UI is off for this agent. */
|
|
149
|
+
configured: boolean;
|
|
150
|
+
catalogId?: string;
|
|
151
|
+
version?: number;
|
|
152
|
+
enabled?: boolean;
|
|
153
|
+
bundle?: string | null;
|
|
154
|
+
bundleSha256?: string | null;
|
|
155
|
+
components: GenuiComponent[];
|
|
156
|
+
}
|
|
157
|
+
/** `dharta genui check`: the structured result. Throws when something is wrong. */
|
|
158
|
+
export declare function genuiCheckData(dir: string): Promise<GenuiStatus>;
|
|
159
|
+
export declare function formatGenuiStatus(status: GenuiStatus): string;
|
|
160
|
+
export interface BuildResult {
|
|
161
|
+
status: "built" | "nothing-to-build";
|
|
162
|
+
/** Release-relative bundle path, when one was written. */
|
|
163
|
+
bundle?: string;
|
|
164
|
+
digest?: string;
|
|
165
|
+
components: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Compile `[genui.build] source` into a validated bundle payload. Nothing is
|
|
169
|
+
* written: this is the seam at the data plane's contract, so a caller can
|
|
170
|
+
* assert on the exact object a release would carry.
|
|
171
|
+
*/
|
|
172
|
+
export declare function compileBundlePayload(section: GenuiSection, dir: string): Promise<Record<string, unknown>>;
|
|
173
|
+
/**
|
|
174
|
+
* Compile `[genui.build] source` into the bundle at `[genui] bundle` and record
|
|
175
|
+
* its digest in dharta.toml. Validates everything the data plane validates
|
|
176
|
+
* before writing, so a bad catalog fails here rather than at deploy.
|
|
177
|
+
*/
|
|
178
|
+
export declare function buildGenui(dir: string, log: (line: string) => void): Promise<BuildResult>;
|