@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,520 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ArtifactDeclaration,
|
|
3
|
+
ArtifactDeclarationV1,
|
|
4
|
+
ArtifactDeclarationV2,
|
|
5
|
+
ArtifactExecutionRenewalWire,
|
|
6
|
+
ArtifactExecutionSessionWire,
|
|
7
|
+
ArtifactManifestDocumentV2,
|
|
8
|
+
ArtifactSummaryV1,
|
|
9
|
+
ArtifactSummaryV2,
|
|
10
|
+
} from "./artifact-runtime.generated.js";
|
|
11
|
+
import { ARTIFACT_RUNTIME_CATALOG } from "./artifact-runtime.generated.js";
|
|
12
|
+
import { isRfc3339DateTime, RFC3339_DATE_TIME } from "./artifact-runtime-formats.js";
|
|
13
|
+
import {
|
|
14
|
+
validateArtifactV1 as generatedValidateV1,
|
|
15
|
+
validateArtifactV2 as generatedValidateV2,
|
|
16
|
+
validateArtifactManifestDocument as generatedValidateManifest,
|
|
17
|
+
validateArtifactSummaryV1 as generatedValidateSummaryV1,
|
|
18
|
+
validateArtifactSummaryV2 as generatedValidateSummaryV2,
|
|
19
|
+
validateArtifactExecutionSession as generatedValidateExecutionSession,
|
|
20
|
+
validateArtifactExecutionRenewal as generatedValidateExecutionRenewal,
|
|
21
|
+
} from "./artifact-runtime-validators.generated.js";
|
|
22
|
+
|
|
23
|
+
export * from "./artifact-runtime.generated.js";
|
|
24
|
+
|
|
25
|
+
const catalog = ARTIFACT_RUNTIME_CATALOG;
|
|
26
|
+
|
|
27
|
+
export const ARTIFACT_CONTRACT_VERSION = catalog.contract_version;
|
|
28
|
+
export const ARTIFACT_MANIFEST_BOUNDS = catalog.manifest;
|
|
29
|
+
export const ARTIFACT_TREE_BOUNDS = catalog.trees;
|
|
30
|
+
export const ARTIFACT_RUNTIME_CONTRACT = catalog.runtime;
|
|
31
|
+
export const ARTIFACT_PORTABLE_SHARING_CONTRACT = catalog.portable_sharing;
|
|
32
|
+
export const ARTIFACT_ACCESS_CONTRACT = catalog.access;
|
|
33
|
+
export const ARTIFACT_HTTP_CONTRACT = catalog.http;
|
|
34
|
+
|
|
35
|
+
function openApiValue(value: unknown): unknown {
|
|
36
|
+
if (Array.isArray(value)) return value.map(openApiValue);
|
|
37
|
+
if (typeof value !== "object" || value === null) return value;
|
|
38
|
+
return Object.fromEntries(
|
|
39
|
+
Object.entries(value).map(([key, item]) => [
|
|
40
|
+
key,
|
|
41
|
+
key === "$ref" && typeof item === "string"
|
|
42
|
+
? item.replace("#/$defs/", "#/components/schemas/")
|
|
43
|
+
: openApiValue(item),
|
|
44
|
+
]),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const ARTIFACT_OPENAPI_SCHEMAS = openApiValue(catalog.schemas) as Record<
|
|
49
|
+
string,
|
|
50
|
+
unknown
|
|
51
|
+
>;
|
|
52
|
+
|
|
53
|
+
export class ArtifactContractError extends Error {
|
|
54
|
+
constructor(readonly code: string) {
|
|
55
|
+
super(code);
|
|
56
|
+
this.name = "ArtifactContractError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The subset of Ajv's ErrorObject that the x-dharta-error mapping reads. The
|
|
62
|
+
* validators are Ajv-standalone output compiled at codegen time (see
|
|
63
|
+
* generate-artifact-runtime-bindings.mjs), so these are the exact error
|
|
64
|
+
* objects Ajv produces — typed locally so Ajv itself stays a devDependency.
|
|
65
|
+
*/
|
|
66
|
+
interface WireValidationError {
|
|
67
|
+
keyword: string;
|
|
68
|
+
schemaPath: string;
|
|
69
|
+
params: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface WireValidateFunction {
|
|
73
|
+
(value: unknown): boolean;
|
|
74
|
+
errors?: WireValidationError[] | null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const validateV1 = generatedValidateV1 as WireValidateFunction;
|
|
78
|
+
const validateV2 = generatedValidateV2 as WireValidateFunction;
|
|
79
|
+
const validateManifest = generatedValidateManifest as WireValidateFunction;
|
|
80
|
+
const validateSummaryV1 = generatedValidateSummaryV1 as WireValidateFunction;
|
|
81
|
+
const validateSummaryV2 = generatedValidateSummaryV2 as WireValidateFunction;
|
|
82
|
+
const validateExecutionSession =
|
|
83
|
+
generatedValidateExecutionSession as WireValidateFunction;
|
|
84
|
+
const validateExecutionRenewal =
|
|
85
|
+
generatedValidateExecutionRenewal as WireValidateFunction;
|
|
86
|
+
|
|
87
|
+
const schemaBundle = { $defs: catalog.schemas };
|
|
88
|
+
const v1ErrorSchema = { ...catalog.schemas.artifact_v1, ...schemaBundle };
|
|
89
|
+
const v2ErrorSchema = { ...catalog.schemas.artifact_v2, ...schemaBundle };
|
|
90
|
+
const manifestErrorSchema = { ...catalog.schemas.manifest_document, ...schemaBundle };
|
|
91
|
+
|
|
92
|
+
interface Rfc3339Instant {
|
|
93
|
+
epochSecond: number;
|
|
94
|
+
fraction: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function rfc3339Instant(value: string): Rfc3339Instant | null {
|
|
98
|
+
const fields = RFC3339_DATE_TIME.exec(value);
|
|
99
|
+
if (!fields || !isRfc3339DateTime(value)) return null;
|
|
100
|
+
const year = Number(fields[1]);
|
|
101
|
+
const month = Number(fields[2]);
|
|
102
|
+
const day = Number(fields[3]);
|
|
103
|
+
const hour = Number(fields[4]);
|
|
104
|
+
const minute = Number(fields[5]);
|
|
105
|
+
const second = Number(fields[6]);
|
|
106
|
+
const instant = new Date(0);
|
|
107
|
+
instant.setUTCFullYear(year, month - 1, day);
|
|
108
|
+
instant.setUTCHours(hour, minute, second, 0);
|
|
109
|
+
const offsetMinutes = fields[8] === "Z"
|
|
110
|
+
? 0
|
|
111
|
+
: (fields[9] === "-" ? -1 : 1) * (Number(fields[10]) * 60 + Number(fields[11]));
|
|
112
|
+
return {
|
|
113
|
+
epochSecond: (instant.getTime() - offsetMinutes * 60_000) / 1_000,
|
|
114
|
+
fraction: fields[7] ?? "",
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function compareInstants(left: Rfc3339Instant, right: Rfc3339Instant): number {
|
|
119
|
+
if (left.epochSecond !== right.epochSecond) {
|
|
120
|
+
return left.epochSecond < right.epochSecond ? -1 : 1;
|
|
121
|
+
}
|
|
122
|
+
const width = Math.max(left.fraction.length, right.fraction.length);
|
|
123
|
+
const leftFraction = left.fraction.padEnd(width, "0");
|
|
124
|
+
const rightFraction = right.fraction.padEnd(width, "0");
|
|
125
|
+
return leftFraction < rightFraction ? -1 : leftFraction > rightFraction ? 1 : 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ArtifactSummaryWire = ArtifactSummaryV1 | ArtifactSummaryV2;
|
|
129
|
+
|
|
130
|
+
const accessPatterns = {
|
|
131
|
+
publicToken: new RegExp(ARTIFACT_ACCESS_CONTRACT.public_token_pattern),
|
|
132
|
+
executionId: new RegExp(ARTIFACT_ACCESS_CONTRACT.execution_id_pattern),
|
|
133
|
+
artifactVersionId: new RegExp(ARTIFACT_ACCESS_CONTRACT.artifact_version_id_pattern),
|
|
134
|
+
handoffToken: new RegExp(ARTIFACT_ACCESS_CONTRACT.handoff_token_pattern),
|
|
135
|
+
originLabel: new RegExp(ARTIFACT_ACCESS_CONTRACT.origin_label_pattern),
|
|
136
|
+
} as const;
|
|
137
|
+
|
|
138
|
+
export function isArtifactPublicToken(value: unknown): value is string {
|
|
139
|
+
return typeof value === "string" && accessPatterns.publicToken.test(value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function isArtifactExecutionId(value: unknown): value is string {
|
|
143
|
+
return typeof value === "string" && accessPatterns.executionId.test(value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function isArtifactVersionId(value: unknown): value is string {
|
|
147
|
+
return typeof value === "string" && accessPatterns.artifactVersionId.test(value);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function isArtifactHandoffToken(value: unknown): value is string {
|
|
151
|
+
return typeof value === "string" && accessPatterns.handoffToken.test(value);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function isArtifactOriginLabel(value: unknown): value is string {
|
|
155
|
+
return typeof value === "string" && accessPatterns.originLabel.test(value);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function schemaNode(schema: unknown, schemaPath: string): unknown {
|
|
159
|
+
// schemaPath is a JSON Schema URI fragment: absolute (base URI + "#/...")
|
|
160
|
+
// when the failing keyword lives in the $id-anchored standalone bundle,
|
|
161
|
+
// relative ("#/...") from nested subschema validators. Only the fragment
|
|
162
|
+
// addresses into the error schema, which carries the target subschema at
|
|
163
|
+
// its root plus the shared $defs, so both forms resolve.
|
|
164
|
+
const hash = schemaPath.indexOf("#");
|
|
165
|
+
const fragment = hash === -1 ? schemaPath : schemaPath.slice(hash + 1);
|
|
166
|
+
const parts = fragment
|
|
167
|
+
.replace(/^\/?/, "")
|
|
168
|
+
.split("/")
|
|
169
|
+
.filter(Boolean)
|
|
170
|
+
.map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
171
|
+
let node: unknown = schema;
|
|
172
|
+
for (const part of parts) {
|
|
173
|
+
if (typeof node !== "object" || node === null || !(part in node)) break;
|
|
174
|
+
node = (node as Record<string, unknown>)[part];
|
|
175
|
+
}
|
|
176
|
+
return node;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function declaredError(schema: unknown, error: WireValidationError): string {
|
|
180
|
+
if (error.keyword === "required") {
|
|
181
|
+
const parentPath = error.schemaPath.replace(/\/required$/, "");
|
|
182
|
+
const parent = schemaNode(schema, parentPath);
|
|
183
|
+
const missing = error.params.missingProperty;
|
|
184
|
+
if (typeof parent === "object" && parent !== null && typeof missing === "string") {
|
|
185
|
+
const properties = (parent as Record<string, unknown>).properties;
|
|
186
|
+
if (typeof properties === "object" && properties !== null) {
|
|
187
|
+
const property = (properties as Record<string, unknown>)[missing];
|
|
188
|
+
if (typeof property === "object" && property !== null) {
|
|
189
|
+
const code = (property as Record<string, unknown>)["x-dharta-error"];
|
|
190
|
+
if (typeof code === "string") return code;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let path = error.schemaPath;
|
|
197
|
+
while (path) {
|
|
198
|
+
const node = schemaNode(schema, path);
|
|
199
|
+
if (typeof node === "object" && node !== null) {
|
|
200
|
+
const code = (node as Record<string, unknown>)["x-dharta-error"];
|
|
201
|
+
if (typeof code === "string") return code;
|
|
202
|
+
}
|
|
203
|
+
const parent = path.replace(/\/[^/]+$/, "");
|
|
204
|
+
if (parent === path) break;
|
|
205
|
+
path = parent;
|
|
206
|
+
}
|
|
207
|
+
return "artifact_contract_invalid";
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function validateArtifact(
|
|
211
|
+
value: unknown,
|
|
212
|
+
): { validator: WireValidateFunction; schema: unknown } {
|
|
213
|
+
if (typeof value !== "object" || value === null) {
|
|
214
|
+
throw new ArtifactContractError("artifact_contract_invalid");
|
|
215
|
+
}
|
|
216
|
+
const version = (value as Record<string, unknown>).contract_version;
|
|
217
|
+
const selected = version === 1
|
|
218
|
+
? { validator: validateV1, schema: v1ErrorSchema }
|
|
219
|
+
: { validator: validateV2, schema: v2ErrorSchema };
|
|
220
|
+
if (!selected.validator(value)) {
|
|
221
|
+
const first = selected.validator.errors?.[0];
|
|
222
|
+
throw new ArtifactContractError(
|
|
223
|
+
first ? declaredError(selected.schema, first) : "artifact_contract_invalid",
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
if (version === 2) validateV2ByteAndDepthBounds(value as Record<string, unknown>);
|
|
227
|
+
return selected;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function utf8Bytes(value: string): number {
|
|
231
|
+
let bytes = 0;
|
|
232
|
+
for (const character of value) {
|
|
233
|
+
const point = character.codePointAt(0) ?? 0;
|
|
234
|
+
bytes += point <= 0x7f ? 1 : point <= 0x7ff ? 2 : point <= 0xffff ? 3 : 4;
|
|
235
|
+
}
|
|
236
|
+
return bytes;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function hasUnpairedSurrogate(value: string): boolean {
|
|
240
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
241
|
+
const unit = value.charCodeAt(index);
|
|
242
|
+
if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
243
|
+
const next = value.charCodeAt(index + 1);
|
|
244
|
+
if (!(next >= 0xdc00 && next <= 0xdfff)) return true;
|
|
245
|
+
index += 1;
|
|
246
|
+
} else if (unit >= 0xdc00 && unit <= 0xdfff) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function validateV2ByteAndDepthBounds(value: Record<string, unknown>): void {
|
|
254
|
+
const root = value.root as string;
|
|
255
|
+
const title = value.title as string;
|
|
256
|
+
if (hasUnpairedSurrogate(title)) {
|
|
257
|
+
throw new ArtifactContractError("artifact_title_invalid");
|
|
258
|
+
}
|
|
259
|
+
if (
|
|
260
|
+
hasUnpairedSurrogate(root)
|
|
261
|
+
||
|
|
262
|
+
utf8Bytes(root) > ARTIFACT_MANIFEST_BOUNDS.max_root_bytes
|
|
263
|
+
|| root.split("/").length > ARTIFACT_MANIFEST_BOUNDS.max_root_depth
|
|
264
|
+
) {
|
|
265
|
+
throw new ArtifactContractError("artifact_root_invalid");
|
|
266
|
+
}
|
|
267
|
+
const entry = value.entry;
|
|
268
|
+
if (typeof entry === "string") {
|
|
269
|
+
if (
|
|
270
|
+
hasUnpairedSurrogate(entry)
|
|
271
|
+
|| utf8Bytes(entry) > ARTIFACT_MANIFEST_BOUNDS.max_entry_bytes
|
|
272
|
+
|| entry.split("/").length > ARTIFACT_MANIFEST_BOUNDS.max_entry_depth
|
|
273
|
+
) {
|
|
274
|
+
throw new ArtifactContractError("artifact_entry_invalid");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const run = value.run;
|
|
278
|
+
if (typeof run === "string") {
|
|
279
|
+
if (
|
|
280
|
+
hasUnpairedSurrogate(run)
|
|
281
|
+
|| utf8Bytes(run) > ARTIFACT_MANIFEST_BOUNDS.max_run_bytes
|
|
282
|
+
) {
|
|
283
|
+
throw new ArtifactContractError("artifact_run_invalid");
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const inputs = value.inputs as Record<string, { source: string }>;
|
|
287
|
+
for (const input of Object.values(inputs)) {
|
|
288
|
+
if (
|
|
289
|
+
hasUnpairedSurrogate(input.source)
|
|
290
|
+
|| utf8Bytes(input.source) > ARTIFACT_MANIFEST_BOUNDS.max_input_source_bytes
|
|
291
|
+
) {
|
|
292
|
+
throw new ArtifactContractError("artifact_input_source_invalid");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export type Immutable<T> = T extends (...args: never[]) => unknown
|
|
298
|
+
? T
|
|
299
|
+
: T extends readonly (infer Item)[]
|
|
300
|
+
? readonly Immutable<Item>[]
|
|
301
|
+
: T extends object
|
|
302
|
+
? { readonly [Key in keyof T]: Immutable<T[Key]> }
|
|
303
|
+
: T;
|
|
304
|
+
|
|
305
|
+
function cloneAndFreeze<T>(value: T): Immutable<T> {
|
|
306
|
+
if (Array.isArray(value)) {
|
|
307
|
+
return Object.freeze(value.map((item) => cloneAndFreeze(item))) as Immutable<T>;
|
|
308
|
+
}
|
|
309
|
+
if (typeof value === "object" && value !== null) {
|
|
310
|
+
const clone = Object.fromEntries(
|
|
311
|
+
Object.entries(value).map(([key, item]) => [key, cloneAndFreeze(item)]),
|
|
312
|
+
);
|
|
313
|
+
return Object.freeze(clone) as Immutable<T>;
|
|
314
|
+
}
|
|
315
|
+
return value as Immutable<T>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function canonicalizeArtifactDeclaration(value: unknown): unknown {
|
|
319
|
+
if (
|
|
320
|
+
typeof value !== "object"
|
|
321
|
+
|| value === null
|
|
322
|
+
|| Array.isArray(value)
|
|
323
|
+
) {
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
326
|
+
const artifact = value as Record<string, unknown>;
|
|
327
|
+
const activation = artifact.agent_activation;
|
|
328
|
+
if (
|
|
329
|
+
artifact.contract_version !== 2
|
|
330
|
+
|| typeof activation !== "object"
|
|
331
|
+
|| activation === null
|
|
332
|
+
|| Array.isArray(activation)
|
|
333
|
+
) {
|
|
334
|
+
return value;
|
|
335
|
+
}
|
|
336
|
+
const policy = activation as Record<string, unknown>;
|
|
337
|
+
if (!Array.isArray(policy.authorities)) return value;
|
|
338
|
+
return {
|
|
339
|
+
...artifact,
|
|
340
|
+
agent_activation: {
|
|
341
|
+
...policy,
|
|
342
|
+
authorities: [...policy.authorities].sort(),
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function parseWire<T>(
|
|
348
|
+
value: unknown,
|
|
349
|
+
validator: WireValidateFunction,
|
|
350
|
+
code: string,
|
|
351
|
+
): Immutable<T> {
|
|
352
|
+
const candidate = cloneAndFreeze(value);
|
|
353
|
+
if (!validator(candidate)) throw new ArtifactContractError(code);
|
|
354
|
+
return candidate as Immutable<T>;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Validate a summary exactly as it crosses the public wire boundary. */
|
|
358
|
+
export function parseArtifactSummaryWire(
|
|
359
|
+
value: unknown,
|
|
360
|
+
): Immutable<ArtifactSummaryWire> {
|
|
361
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
362
|
+
throw new ArtifactContractError("artifact_summary_invalid");
|
|
363
|
+
}
|
|
364
|
+
const validator = (value as Record<string, unknown>).contract_version === 1
|
|
365
|
+
? validateSummaryV1
|
|
366
|
+
: validateSummaryV2;
|
|
367
|
+
return parseWire<ArtifactSummaryWire>(value, validator, "artifact_summary_invalid");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Project an internal Artifact record onto the canonical public summary shape.
|
|
372
|
+
* This is intentionally schema-driven so producers cannot grow a second,
|
|
373
|
+
* hand-maintained allowlist when the wire contract evolves.
|
|
374
|
+
*/
|
|
375
|
+
export function projectArtifactSummaryWire(
|
|
376
|
+
value: unknown,
|
|
377
|
+
contractVersion?: 1 | 2,
|
|
378
|
+
): Immutable<ArtifactSummaryWire> {
|
|
379
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
380
|
+
throw new ArtifactContractError("artifact_summary_invalid");
|
|
381
|
+
}
|
|
382
|
+
const row = value as Record<string, unknown>;
|
|
383
|
+
const version = contractVersion ?? (row.contract_version === 1 ? 1 : 2);
|
|
384
|
+
const schema = version === 1
|
|
385
|
+
? catalog.schemas.artifact_summary_v1
|
|
386
|
+
: catalog.schemas.artifact_summary_v2;
|
|
387
|
+
const projected = Object.fromEntries(
|
|
388
|
+
Object.keys(schema.properties)
|
|
389
|
+
.filter((key) => row[key] !== undefined)
|
|
390
|
+
.map((key) => [key, row[key]]),
|
|
391
|
+
);
|
|
392
|
+
projected.contract_version = version;
|
|
393
|
+
return parseArtifactSummaryWire(projected);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export function parseArtifactExecutionSessionWire(
|
|
397
|
+
value: unknown,
|
|
398
|
+
): Immutable<ArtifactExecutionSessionWire> {
|
|
399
|
+
const session = parseWire<ArtifactExecutionSessionWire>(
|
|
400
|
+
value,
|
|
401
|
+
validateExecutionSession,
|
|
402
|
+
"artifact_execution_session_invalid",
|
|
403
|
+
);
|
|
404
|
+
validateExecutionWindow(session);
|
|
405
|
+
return session;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export function parseArtifactExecutionRenewalWire(
|
|
409
|
+
value: unknown,
|
|
410
|
+
): Immutable<ArtifactExecutionRenewalWire> {
|
|
411
|
+
const renewal = parseWire<ArtifactExecutionRenewalWire>(
|
|
412
|
+
value,
|
|
413
|
+
validateExecutionRenewal,
|
|
414
|
+
"artifact_execution_renewal_invalid",
|
|
415
|
+
);
|
|
416
|
+
validateExecutionWindow(renewal);
|
|
417
|
+
return renewal;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function validateExecutionWindow(value: {
|
|
421
|
+
lease_expires_at: string;
|
|
422
|
+
absolute_expires_at: string;
|
|
423
|
+
}): void {
|
|
424
|
+
const lease = rfc3339Instant(value.lease_expires_at);
|
|
425
|
+
const absolute = rfc3339Instant(value.absolute_expires_at);
|
|
426
|
+
if (!lease || !absolute || compareInstants(lease, absolute) > 0) {
|
|
427
|
+
throw new ArtifactContractError("artifact_execution_window_invalid");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export function parseArtifactDeclaration(
|
|
432
|
+
value: unknown,
|
|
433
|
+
): Immutable<ArtifactDeclaration> {
|
|
434
|
+
const candidate = cloneAndFreeze(value);
|
|
435
|
+
validateArtifact(candidate);
|
|
436
|
+
return cloneAndFreeze(
|
|
437
|
+
canonicalizeArtifactDeclaration(candidate),
|
|
438
|
+
) as Immutable<ArtifactDeclaration>;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export function parseArtifactManifestDocument(
|
|
442
|
+
value: unknown,
|
|
443
|
+
): Immutable<ArtifactManifestDocumentV2> {
|
|
444
|
+
const candidate = cloneAndFreeze(value);
|
|
445
|
+
if (!validateManifest(candidate)) {
|
|
446
|
+
if (
|
|
447
|
+
typeof candidate === "object"
|
|
448
|
+
&& candidate !== null
|
|
449
|
+
&& Array.isArray((candidate as Record<string, unknown>).artifacts)
|
|
450
|
+
) {
|
|
451
|
+
for (const artifact of (candidate as { artifacts: readonly unknown[] }).artifacts) {
|
|
452
|
+
validateArtifact(artifact);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
const first = validateManifest.errors?.[0];
|
|
456
|
+
throw new ArtifactContractError(
|
|
457
|
+
first ? declaredError(manifestErrorSchema, first) : "artifact_document_invalid",
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
const document = candidate as Immutable<ArtifactManifestDocumentV2>;
|
|
461
|
+
for (const artifact of document.artifacts) validateArtifact(artifact);
|
|
462
|
+
return cloneAndFreeze({
|
|
463
|
+
...document,
|
|
464
|
+
artifacts: document.artifacts.map(canonicalizeArtifactDeclaration),
|
|
465
|
+
}) as Immutable<ArtifactManifestDocumentV2>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface ArtifactTreeSummary {
|
|
469
|
+
scope: "root" | "input" | "all_inputs" | "static_share";
|
|
470
|
+
files: number;
|
|
471
|
+
bytes: number;
|
|
472
|
+
escaping_symlink: boolean;
|
|
473
|
+
secret_path: boolean;
|
|
474
|
+
reserved_path_collision: boolean;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export function validateArtifactTree(value: unknown): void {
|
|
478
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
479
|
+
throw new ArtifactContractError("artifact_tree_invalid");
|
|
480
|
+
}
|
|
481
|
+
const summary = value as Record<string, unknown>;
|
|
482
|
+
if (!["root", "input", "all_inputs", "static_share"].includes(String(summary.scope))) {
|
|
483
|
+
throw new ArtifactContractError("artifact_tree_scope_invalid");
|
|
484
|
+
}
|
|
485
|
+
if (
|
|
486
|
+
!Number.isInteger(summary.files)
|
|
487
|
+
|| !Number.isInteger(summary.bytes)
|
|
488
|
+
|| (summary.files as number) < 0
|
|
489
|
+
|| (summary.bytes as number) < 0
|
|
490
|
+
|| typeof summary.escaping_symlink !== "boolean"
|
|
491
|
+
|| typeof summary.secret_path !== "boolean"
|
|
492
|
+
|| typeof summary.reserved_path_collision !== "boolean"
|
|
493
|
+
) {
|
|
494
|
+
throw new ArtifactContractError("artifact_tree_invalid");
|
|
495
|
+
}
|
|
496
|
+
if (summary.escaping_symlink && ARTIFACT_TREE_BOUNDS.reject_symlinks_escaping_tree) {
|
|
497
|
+
throw new ArtifactContractError("artifact_tree_symlink_escape");
|
|
498
|
+
}
|
|
499
|
+
if (summary.secret_path && ARTIFACT_TREE_BOUNDS.reject_secret_paths) {
|
|
500
|
+
throw new ArtifactContractError("artifact_tree_secret_path");
|
|
501
|
+
}
|
|
502
|
+
if (summary.reserved_path_collision) {
|
|
503
|
+
throw new ArtifactContractError("artifact_tree_reserved_path_collision");
|
|
504
|
+
}
|
|
505
|
+
const scope = summary.scope as ArtifactTreeSummary["scope"];
|
|
506
|
+
const bound = ARTIFACT_TREE_BOUNDS[scope];
|
|
507
|
+
if ((summary.files as number) > bound.max_files) {
|
|
508
|
+
throw new ArtifactContractError("artifact_tree_files_exceeded");
|
|
509
|
+
}
|
|
510
|
+
if ((summary.bytes as number) > bound.max_bytes) {
|
|
511
|
+
throw new ArtifactContractError("artifact_tree_bytes_exceeded");
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export function acceptsArtifactRootContentType(value: string): boolean {
|
|
516
|
+
const essence = value.split(";", 1)[0]?.trim().toLowerCase();
|
|
517
|
+
return essence === ARTIFACT_HTTP_CONTRACT.root_media_type_essence;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export type { ArtifactDeclarationV1, ArtifactDeclarationV2 };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const MODEL_AUTH_CREDENTIAL_KINDS = [
|
|
2
|
+
"api_key",
|
|
3
|
+
"oauth_session",
|
|
4
|
+
"provider_managed_session",
|
|
5
|
+
"workload_identity",
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
export const MODEL_AUTH_FUNDING_SOURCES = [
|
|
9
|
+
"api_usage",
|
|
10
|
+
"subscription_entitlement",
|
|
11
|
+
"enterprise_entitlement",
|
|
12
|
+
"platform",
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
export const MODEL_AUTH_OWNER_KINDS = ["organization", "individual", "install", "platform"] as const;
|
|
16
|
+
|
|
17
|
+
export const MODEL_AUTH_STORAGE_KINDS = [
|
|
18
|
+
"control_plane_encrypted",
|
|
19
|
+
"install_local_ref",
|
|
20
|
+
"os_keyring",
|
|
21
|
+
"provider_client_owned",
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export const MODEL_AUTH_EXECUTION_SCOPES = [
|
|
25
|
+
"local",
|
|
26
|
+
"private_interactive",
|
|
27
|
+
"background",
|
|
28
|
+
"shared",
|
|
29
|
+
"public",
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
export type ModelAuthCredentialKind = (typeof MODEL_AUTH_CREDENTIAL_KINDS)[number];
|
|
33
|
+
export type ModelAuthFundingSource = (typeof MODEL_AUTH_FUNDING_SOURCES)[number];
|
|
34
|
+
export type ModelAuthOwnerKind = (typeof MODEL_AUTH_OWNER_KINDS)[number];
|
|
35
|
+
export type ModelAuthStorageKind = (typeof MODEL_AUTH_STORAGE_KINDS)[number];
|
|
36
|
+
export type ModelAuthExecutionScope = (typeof MODEL_AUTH_EXECUTION_SCOPES)[number];
|
|
37
|
+
|
|
38
|
+
export interface ModelAuthCapability {
|
|
39
|
+
id: string;
|
|
40
|
+
provider: string;
|
|
41
|
+
credential_kind: ModelAuthCredentialKind;
|
|
42
|
+
funding_source: ModelAuthFundingSource;
|
|
43
|
+
owner_kinds: readonly ModelAuthOwnerKind[];
|
|
44
|
+
storage_kinds: readonly ModelAuthStorageKind[];
|
|
45
|
+
execution_scopes: readonly ModelAuthExecutionScope[];
|
|
46
|
+
admission: "enabled" | "disabled";
|
|
47
|
+
runtime_switch: string;
|
|
48
|
+
adapter: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const MODEL_AUTH_REASON_CODES = [
|
|
52
|
+
"model_auth_missing",
|
|
53
|
+
"model_auth_expiring",
|
|
54
|
+
"model_auth_expired",
|
|
55
|
+
"model_auth_refresh_failed",
|
|
56
|
+
"model_auth_reauthorization_required",
|
|
57
|
+
"model_auth_refresh_outcome_indeterminate",
|
|
58
|
+
"model_auth_entitlement_exhausted",
|
|
59
|
+
"model_auth_revoked",
|
|
60
|
+
"model_auth_capability_disabled",
|
|
61
|
+
"model_auth_scope_ineligible",
|
|
62
|
+
"model_auth_funding_selection_required",
|
|
63
|
+
"model_auth_new_session_required",
|
|
64
|
+
"model_auth_account_mismatch",
|
|
65
|
+
"model_auth_adapter_unavailable",
|
|
66
|
+
"model_auth_misconfigured",
|
|
67
|
+
"model_auth_provider_unavailable",
|
|
68
|
+
] as const;
|
|
69
|
+
|
|
70
|
+
export type ModelAuthReasonCode = (typeof MODEL_AUTH_REASON_CODES)[number];
|
|
71
|
+
|
|
72
|
+
export interface ModelAuthReason {
|
|
73
|
+
code: ModelAuthReasonCode;
|
|
74
|
+
fails_turn: boolean;
|
|
75
|
+
stage: "authorization" | "dispatch" | "policy" | "setup";
|
|
76
|
+
retry_class:
|
|
77
|
+
| "after_policy_change"
|
|
78
|
+
| "after_reauthorization"
|
|
79
|
+
| "never"
|
|
80
|
+
| "operator_intervention"
|
|
81
|
+
| "provider_later";
|
|
82
|
+
}
|