@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,142 @@
|
|
|
1
|
+
/** RFC 0065 durable background-task wire contract (snake_case, server -> consumer). */
|
|
2
|
+
|
|
3
|
+
export const SESSION_TASK_KINDS = ["command", "workflow", "subagent", "other"] as const;
|
|
4
|
+
export const SESSION_TASK_STATUSES = [
|
|
5
|
+
"queued", "running", "succeeded", "failed", "cancelled", "interrupted",
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
export const SESSION_TASK_LIMITS = {
|
|
9
|
+
idChars: 128,
|
|
10
|
+
labelChars: 240,
|
|
11
|
+
progressUnitChars: 48,
|
|
12
|
+
errorCodeChars: 128,
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type SessionTaskKindWire = (typeof SESSION_TASK_KINDS)[number];
|
|
16
|
+
export type SessionTaskStatusWire = (typeof SESSION_TASK_STATUSES)[number];
|
|
17
|
+
|
|
18
|
+
export interface SessionTaskUsageWire {
|
|
19
|
+
input_tokens?: number;
|
|
20
|
+
output_tokens?: number;
|
|
21
|
+
total_tokens?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SessionTaskWire {
|
|
25
|
+
schema_version: 1;
|
|
26
|
+
task_id: string;
|
|
27
|
+
session_id: string;
|
|
28
|
+
turn_id?: string;
|
|
29
|
+
parent_task_id?: string;
|
|
30
|
+
kind: SessionTaskKindWire;
|
|
31
|
+
label: string;
|
|
32
|
+
status: SessionTaskStatusWire;
|
|
33
|
+
started_at?: string;
|
|
34
|
+
completed_at?: string;
|
|
35
|
+
progress?: { completed?: number; total?: number; unit?: string };
|
|
36
|
+
usage?: SessionTaskUsageWire;
|
|
37
|
+
tool_uses?: number;
|
|
38
|
+
transcript_anchor?: { message_id: string; activity_id?: string };
|
|
39
|
+
cancelable: boolean;
|
|
40
|
+
error_code?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const KIND_SET = new Set<string>(SESSION_TASK_KINDS);
|
|
44
|
+
const STATUS_SET = new Set<string>(SESSION_TASK_STATUSES);
|
|
45
|
+
|
|
46
|
+
/** Validate an untrusted task projection before exposing it through the SDK. */
|
|
47
|
+
export function parseSessionTaskWire(value: unknown): SessionTaskWire | null {
|
|
48
|
+
if (!isRecord(value) || value.schema_version !== 1) return null;
|
|
49
|
+
if (!boundedString(value.task_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
50
|
+
if (!boundedString(value.session_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
51
|
+
if (!KIND_SET.has(String(value.kind)) || !STATUS_SET.has(String(value.status))) return null;
|
|
52
|
+
if (!boundedString(value.label, SESSION_TASK_LIMITS.labelChars)) return null;
|
|
53
|
+
if (typeof value.cancelable !== "boolean") return null;
|
|
54
|
+
if (value.turn_id !== undefined && !boundedString(value.turn_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
55
|
+
if (value.parent_task_id !== undefined && !boundedString(value.parent_task_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
56
|
+
if (value.started_at !== undefined && !validTimestamp(value.started_at)) return null;
|
|
57
|
+
if (value.completed_at !== undefined && !validTimestamp(value.completed_at)) return null;
|
|
58
|
+
if (value.error_code !== undefined && !boundedString(value.error_code, SESSION_TASK_LIMITS.errorCodeChars)) return null;
|
|
59
|
+
|
|
60
|
+
const progress = parseProgress(value.progress);
|
|
61
|
+
if (value.progress !== undefined && progress === null) return null;
|
|
62
|
+
const usage = parseUsage(value.usage);
|
|
63
|
+
if (value.usage !== undefined && usage === null) return null;
|
|
64
|
+
const anchor = parseAnchor(value.transcript_anchor);
|
|
65
|
+
if (value.transcript_anchor !== undefined && anchor === null) return null;
|
|
66
|
+
if (value.tool_uses !== undefined && !nonNegativeInteger(value.tool_uses)) return null;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
schema_version: 1,
|
|
70
|
+
task_id: value.task_id as string,
|
|
71
|
+
session_id: value.session_id as string,
|
|
72
|
+
...(value.turn_id !== undefined ? { turn_id: value.turn_id as string } : {}),
|
|
73
|
+
...(value.parent_task_id !== undefined ? { parent_task_id: value.parent_task_id as string } : {}),
|
|
74
|
+
kind: value.kind as SessionTaskKindWire,
|
|
75
|
+
label: value.label as string,
|
|
76
|
+
status: value.status as SessionTaskStatusWire,
|
|
77
|
+
...(value.started_at !== undefined ? { started_at: value.started_at as string } : {}),
|
|
78
|
+
...(value.completed_at !== undefined ? { completed_at: value.completed_at as string } : {}),
|
|
79
|
+
...(progress ? { progress } : {}),
|
|
80
|
+
...(usage ? { usage } : {}),
|
|
81
|
+
...(value.tool_uses !== undefined ? { tool_uses: value.tool_uses as number } : {}),
|
|
82
|
+
...(anchor ? { transcript_anchor: anchor } : {}),
|
|
83
|
+
cancelable: value.cancelable,
|
|
84
|
+
...(value.error_code !== undefined ? { error_code: value.error_code as string } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function parseProgress(value: unknown): SessionTaskWire["progress"] | null {
|
|
89
|
+
if (value === undefined) return null;
|
|
90
|
+
if (!isRecord(value)) return null;
|
|
91
|
+
if (value.completed !== undefined && !nonNegativeNumber(value.completed)) return null;
|
|
92
|
+
if (value.total !== undefined && !nonNegativeNumber(value.total)) return null;
|
|
93
|
+
if (value.unit !== undefined && !boundedString(value.unit, SESSION_TASK_LIMITS.progressUnitChars)) return null;
|
|
94
|
+
return {
|
|
95
|
+
...(value.completed !== undefined ? { completed: value.completed as number } : {}),
|
|
96
|
+
...(value.total !== undefined ? { total: value.total as number } : {}),
|
|
97
|
+
...(value.unit !== undefined ? { unit: value.unit as string } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function parseUsage(value: unknown): SessionTaskUsageWire | null {
|
|
102
|
+
if (value === undefined) return null;
|
|
103
|
+
if (!isRecord(value)) return null;
|
|
104
|
+
const output: SessionTaskUsageWire = {};
|
|
105
|
+
for (const key of ["input_tokens", "output_tokens", "total_tokens"] as const) {
|
|
106
|
+
if (value[key] !== undefined) {
|
|
107
|
+
if (!nonNegativeInteger(value[key])) return null;
|
|
108
|
+
output[key] = value[key] as number;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return output;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function parseAnchor(value: unknown): SessionTaskWire["transcript_anchor"] | null {
|
|
115
|
+
if (value === undefined) return null;
|
|
116
|
+
if (!isRecord(value) || !boundedString(value.message_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
117
|
+
if (value.activity_id !== undefined && !boundedString(value.activity_id, SESSION_TASK_LIMITS.idChars)) return null;
|
|
118
|
+
return {
|
|
119
|
+
message_id: value.message_id,
|
|
120
|
+
...(value.activity_id !== undefined ? { activity_id: value.activity_id as string } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function validTimestamp(value: unknown): value is string {
|
|
125
|
+
return boundedString(value, 64) && Number.isFinite(Date.parse(value));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function boundedString(value: unknown, max: number): value is string {
|
|
129
|
+
return typeof value === "string" && value.length > 0 && value.length <= max;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function nonNegativeInteger(value: unknown): value is number {
|
|
133
|
+
return Number.isSafeInteger(value) && (value as number) >= 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function nonNegativeNumber(value: unknown): value is number {
|
|
137
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
141
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// The canonical data-plane SSE wire-event vocabulary: the `event:` type strings
|
|
2
|
+
// the Dharta data plane emits over the streaming turn endpoint, plus the raw
|
|
3
|
+
// `data` shapes a client decodes. This is the cross-plane contract - the Python
|
|
4
|
+
// data plane emits these, the TypeScript widget consumes them, and a conformance
|
|
5
|
+
// test on each side pins both against `wire-events.json` so they cannot drift.
|
|
6
|
+
//
|
|
7
|
+
// These are the RAW wire shapes (snake_case, flat optional bags), not the
|
|
8
|
+
// widget's normalized client-facing `AgentEvent`. The widget maps wire -> normal
|
|
9
|
+
// in its transport layer; that normalization is widget-internal and not part of
|
|
10
|
+
// this contract.
|
|
11
|
+
|
|
12
|
+
import type { ActivityPresentationWire } from "./activity.js";
|
|
13
|
+
import type { SessionTaskWire } from "./tasks.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Managed-Agents adapter event types (the default, full-fidelity stream).
|
|
17
|
+
* Keep in sync with `wire-events.json` (the language-neutral source of truth a
|
|
18
|
+
* test asserts against) and the Python `MANAGED_AGENT_EVENT_TYPES`.
|
|
19
|
+
*/
|
|
20
|
+
export const MANAGED_AGENT_EVENT_TYPES = [
|
|
21
|
+
"session.status_running",
|
|
22
|
+
"session.trace",
|
|
23
|
+
"session.warming",
|
|
24
|
+
"agent.message",
|
|
25
|
+
"agent.thinking",
|
|
26
|
+
"agent.activity",
|
|
27
|
+
"agent.tool_use",
|
|
28
|
+
"agent.tool_result",
|
|
29
|
+
"session.usage",
|
|
30
|
+
"session.status_idle",
|
|
31
|
+
"session.error",
|
|
32
|
+
// RFC 0060 H2: a non-terminal session-level warning (e.g. the post-turn durable snapshot
|
|
33
|
+
// was refused at the storage hard cap, so recent changes were not saved).
|
|
34
|
+
"session.warning",
|
|
35
|
+
// Session message inbox: a user.message posted mid-turn is queued (never 409ed).
|
|
36
|
+
// message_dequeued's `mode` is "steered" (injected into the live turn) or "turn"
|
|
37
|
+
// (it began the next turn, incl. inbox drain at turn end). Both non-terminal.
|
|
38
|
+
"session.message_queued",
|
|
39
|
+
"session.message_dequeued",
|
|
40
|
+
"session.task_started",
|
|
41
|
+
"session.task_updated",
|
|
42
|
+
"session.task_completed",
|
|
43
|
+
"artifact.committed",
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
export type ManagedAgentEventType = (typeof MANAGED_AGENT_EVENT_TYPES)[number];
|
|
47
|
+
|
|
48
|
+
/** Responses adapter event types (the portable OpenAI-compatible fallback). */
|
|
49
|
+
export const RESPONSES_EVENT_TYPES = [
|
|
50
|
+
"response.created",
|
|
51
|
+
"response.output_text.delta",
|
|
52
|
+
"response.completed",
|
|
53
|
+
"response.failed",
|
|
54
|
+
] as const;
|
|
55
|
+
|
|
56
|
+
export type ResponsesEventType = (typeof RESPONSES_EVENT_TYPES)[number];
|
|
57
|
+
|
|
58
|
+
export type TurnFailurePhase =
|
|
59
|
+
| "admission"
|
|
60
|
+
| "resolution"
|
|
61
|
+
| "dispatch"
|
|
62
|
+
| "streaming"
|
|
63
|
+
| "finalization"
|
|
64
|
+
| "continuation";
|
|
65
|
+
|
|
66
|
+
export type TurnFailureRemediation =
|
|
67
|
+
| "retry"
|
|
68
|
+
| "retry_turn"
|
|
69
|
+
| "reconnect_model"
|
|
70
|
+
| "select_model_funding"
|
|
71
|
+
| "start_new_session"
|
|
72
|
+
| "wait_and_retry"
|
|
73
|
+
| "contact_support"
|
|
74
|
+
| "none";
|
|
75
|
+
|
|
76
|
+
export interface TurnFailureWire {
|
|
77
|
+
code?: string;
|
|
78
|
+
message?: string;
|
|
79
|
+
retryable?: boolean;
|
|
80
|
+
phase?: TurnFailurePhase;
|
|
81
|
+
remediation?: TurnFailureRemediation;
|
|
82
|
+
request_id?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A raw Managed-Agents SSE event, decoded from `event:<type>\ndata:{...}`. A
|
|
87
|
+
* flat bag of optional fields because which ones are present depends on `type`
|
|
88
|
+
* (see MANAGED_AGENT_EVENT_TYPES); the consumer narrows on `type`.
|
|
89
|
+
*/
|
|
90
|
+
export interface ManagedAgentWireEvent extends TurnFailureWire {
|
|
91
|
+
type: string;
|
|
92
|
+
seq?: number;
|
|
93
|
+
text?: string;
|
|
94
|
+
part_id?: string;
|
|
95
|
+
// On `agent.message` / `agent.thinking`: when true, `text` is an INCREMENTAL
|
|
96
|
+
// delta to APPEND to the part (the OpenAI-compatible streaming contract, e.g.
|
|
97
|
+
// goose). Absent/false = full-message-so-far snapshot the client REPLACEs.
|
|
98
|
+
delta?: boolean;
|
|
99
|
+
tool?: string;
|
|
100
|
+
tool_use_id?: string;
|
|
101
|
+
input?: unknown;
|
|
102
|
+
output?: unknown;
|
|
103
|
+
is_error?: boolean;
|
|
104
|
+
// MCP-UI (SEP-1865) metadata on a tool_result, when present.
|
|
105
|
+
_meta?: unknown;
|
|
106
|
+
stop_reason?: string;
|
|
107
|
+
request_id?: string;
|
|
108
|
+
// On a requires_action idle: "tool_permission" (approve/deny) vs
|
|
109
|
+
// "user_question" (AskUserQuestion — answer via result="answer").
|
|
110
|
+
kind?: string;
|
|
111
|
+
target?: string;
|
|
112
|
+
options?: unknown;
|
|
113
|
+
// On a requires_action idle with kind "user_question": the AskUserQuestion
|
|
114
|
+
// questions array ({question, header, options[{label, description}],
|
|
115
|
+
// multiSelect}) so the client renders the choices.
|
|
116
|
+
questions?: unknown;
|
|
117
|
+
usage?: Record<string, unknown>;
|
|
118
|
+
turn_id?: string;
|
|
119
|
+
started_at?: string;
|
|
120
|
+
observed_at?: string;
|
|
121
|
+
completed_at?: string;
|
|
122
|
+
// The turn's W3C trace id (32-hex), on a `session.trace` event. Lets a client
|
|
123
|
+
// deep-link this turn to its trace in the org's observability backend (RFC 0053
|
|
124
|
+
// A5). Present only when the data plane has OpenTelemetry configured.
|
|
125
|
+
trace_id?: string;
|
|
126
|
+
// Session message inbox (session.message_queued / session.message_dequeued):
|
|
127
|
+
// the inbox entry id, and on dequeue how it left — "steered" (injected into
|
|
128
|
+
// the live turn) or "turn" (it began the next foreground turn).
|
|
129
|
+
queue_id?: string;
|
|
130
|
+
queued_at?: string;
|
|
131
|
+
mode?: string;
|
|
132
|
+
artifact?: Record<string, unknown>;
|
|
133
|
+
// RFC 0065: bounded semantic projection of this visible tool event. Raw
|
|
134
|
+
// input/output remain additive for headless compatibility.
|
|
135
|
+
activity?: ActivityPresentationWire;
|
|
136
|
+
task?: SessionTaskWire;
|
|
137
|
+
task_seq?: number;
|
|
138
|
+
version?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A raw Responses-adapter SSE event (OpenAI-compatible response stream). */
|
|
142
|
+
export interface ResponsesWireEvent {
|
|
143
|
+
type: string;
|
|
144
|
+
delta?: string;
|
|
145
|
+
response?: {
|
|
146
|
+
id?: string;
|
|
147
|
+
usage?: Record<string, unknown>;
|
|
148
|
+
error?: TurnFailureWire;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Canonical data-plane SSE wire-event vocabulary. Language-neutral source of truth. The TypeScript consts in src/wire-events.ts and the Python MANAGED_AGENT_EVENT_TYPES / RESPONSES_EVENT_TYPES are each asserted to match this file by a conformance test, so the two planes cannot drift. Edit here first, then both sides.",
|
|
3
|
+
"managed_agents": [
|
|
4
|
+
"session.status_running",
|
|
5
|
+
"session.trace",
|
|
6
|
+
"session.warming",
|
|
7
|
+
"agent.message",
|
|
8
|
+
"agent.thinking",
|
|
9
|
+
"agent.activity",
|
|
10
|
+
"agent.tool_use",
|
|
11
|
+
"agent.tool_result",
|
|
12
|
+
"session.usage",
|
|
13
|
+
"session.status_idle",
|
|
14
|
+
"session.error",
|
|
15
|
+
"session.warning",
|
|
16
|
+
"session.message_queued",
|
|
17
|
+
"session.message_dequeued",
|
|
18
|
+
"session.task_started",
|
|
19
|
+
"session.task_updated",
|
|
20
|
+
"session.task_completed",
|
|
21
|
+
"artifact.committed"
|
|
22
|
+
],
|
|
23
|
+
"responses": [
|
|
24
|
+
"response.created",
|
|
25
|
+
"response.output_text.delta",
|
|
26
|
+
"response.completed",
|
|
27
|
+
"response.failed"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -29,7 +29,20 @@ const { api_key, secret } = await dharta.apiKeys.create("ci-runner", ["write"]);
|
|
|
29
29
|
console.log("Store this now, it won't be shown again:", secret);
|
|
30
30
|
|
|
31
31
|
// Store a BYOK provider key (encrypted at rest server-side)
|
|
32
|
-
await dharta.
|
|
32
|
+
await dharta.modelConnections.create("anthropic", process.env.ANTHROPIC_API_KEY!, "primary");
|
|
33
|
+
|
|
34
|
+
// Address a connector by its numeric id or its organization-unique slug
|
|
35
|
+
await dharta.modelConnections.rotate("anthropic-primary", { plaintext: process.env.ANTHROPIC_API_KEY! });
|
|
36
|
+
await dharta.modelConnections.configureModels("anthropic-primary", {
|
|
37
|
+
enabled: ["claude-sonnet-5"],
|
|
38
|
+
default: "claude-sonnet-5",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Organization defaults every agent inherits
|
|
42
|
+
await dharta.organization.modelSettings.update({
|
|
43
|
+
connector_order: ["anthropic-primary", "karta"],
|
|
44
|
+
model_reference: "claude-sonnet-5",
|
|
45
|
+
});
|
|
33
46
|
|
|
34
47
|
// Manage webhook endpoints
|
|
35
48
|
const { webhook_endpoint, secret: signingSecret } = await dharta.webhookEndpoints.create({
|
|
@@ -44,16 +57,16 @@ const billing = await dharta.billing.status();
|
|
|
44
57
|
|
|
45
58
|
## Errors
|
|
46
59
|
|
|
47
|
-
Every 4xx/5xx response throws a typed `
|
|
60
|
+
Every 4xx/5xx response throws a typed `DhartaError` subclass that
|
|
48
61
|
preserves `status` and the parsed JSON `body`:
|
|
49
62
|
|
|
50
63
|
```ts
|
|
51
|
-
import {
|
|
64
|
+
import { DhartaValidationError } from "@dharta/sdk";
|
|
52
65
|
|
|
53
66
|
try {
|
|
54
67
|
await dharta.apiKeys.create("");
|
|
55
68
|
} catch (e) {
|
|
56
|
-
if (e instanceof
|
|
69
|
+
if (e instanceof DhartaValidationError) {
|
|
57
70
|
console.warn(e.body); // { error: "validation_failed", message: "Name is required" }
|
|
58
71
|
} else {
|
|
59
72
|
throw e;
|
|
@@ -61,9 +74,9 @@ try {
|
|
|
61
74
|
}
|
|
62
75
|
```
|
|
63
76
|
|
|
64
|
-
Subclasses: `
|
|
65
|
-
`
|
|
66
|
-
else throws the base `
|
|
77
|
+
Subclasses: `DhartaAuthError` (401), `DhartaForbiddenError` (403),
|
|
78
|
+
`DhartaNotFoundError` (404), `DhartaValidationError` (422). Anything
|
|
79
|
+
else throws the base `DhartaError`.
|
|
67
80
|
|
|
68
81
|
## Development
|
|
69
82
|
|
|
@@ -78,7 +91,8 @@ npm test # vitest against a stub fetch
|
|
|
78
91
|
| Resource | Methods |
|
|
79
92
|
| -------------------- | ---------------------------------------------------------------------- |
|
|
80
93
|
| `apiKeys` | `list()`, `create(name, scopes?)`, `revoke(id)` |
|
|
81
|
-
| `
|
|
94
|
+
| `modelConnections` | `list()`, `create(provider, plaintext, name?)`, `rotate(idOrSlug, params)`, `models(idOrSlug)`, `configureModels(idOrSlug, params)`, `revoke(id)` |
|
|
95
|
+
| `organization.modelSettings` | `get()`, `update(params)` |
|
|
82
96
|
| `webhookEndpoints` | `list()`, `create(params)`, `update(id, params)`, `enable(id)`, `delete(id)` |
|
|
83
97
|
| `usage` | `summary()` |
|
|
84
98
|
| `billing` | `status()` |
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { ErrorBody } from "./types.js";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class DhartaError extends Error {
|
|
3
3
|
readonly status: number;
|
|
4
4
|
readonly body: ErrorBody | string | null;
|
|
5
|
-
|
|
5
|
+
readonly retryAfterSeconds?: number;
|
|
6
|
+
constructor(message: string, status: number, body: ErrorBody | string | null, retryAfterSeconds?: number);
|
|
6
7
|
}
|
|
7
|
-
export declare class
|
|
8
|
+
export declare class DhartaAuthError extends DhartaError {
|
|
8
9
|
constructor(body: ErrorBody | string | null);
|
|
9
10
|
}
|
|
10
|
-
export declare class
|
|
11
|
+
export declare class DhartaForbiddenError extends DhartaError {
|
|
11
12
|
constructor(body: ErrorBody | string | null);
|
|
12
13
|
}
|
|
13
|
-
export declare class
|
|
14
|
+
export declare class DhartaNotFoundError extends DhartaError {
|
|
14
15
|
constructor(body: ErrorBody | string | null);
|
|
15
16
|
}
|
|
16
|
-
export declare class
|
|
17
|
+
export declare class DhartaValidationError extends DhartaError {
|
|
17
18
|
constructor(body: ErrorBody | string | null);
|
|
18
19
|
}
|
|
19
|
-
export declare function errorFor(status: number, body: ErrorBody | string | null):
|
|
20
|
+
export declare function errorFor(status: number, body: ErrorBody | string | null, retryAfterSeconds?: number): DhartaError;
|
|
21
|
+
export declare function parseRetryAfterSeconds(header: string | null): number | undefined;
|
|
20
22
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IAMzC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAEpC,YACE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAC/B,iBAAiB,CAAC,EAAE,MAAM,EAO3B;CACF;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,YAAY,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAG1C;CACF;AAED,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,YAAY,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAG1C;CACF;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,YAAY,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAG1C;CACF;AAED,qBAAa,qBAAsB,SAAQ,WAAW;IACpD,YAAY,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAG1C;CACF;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EAC/B,iBAAiB,CAAC,EAAE,MAAM,GACzB,WAAW,CAUb;AAID,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAMhF"}
|
|
@@ -1,51 +1,69 @@
|
|
|
1
|
-
// Base class so consumers can `catch (e:
|
|
1
|
+
// Base class so consumers can `catch (e: DhartaError)` without
|
|
2
2
|
// switching on status codes manually for the common cases.
|
|
3
|
-
export class
|
|
3
|
+
export class DhartaError extends Error {
|
|
4
4
|
status;
|
|
5
5
|
body;
|
|
6
|
-
|
|
6
|
+
// Seconds the server asked the caller to wait, from the `Retry-After`
|
|
7
|
+
// header, when it sent one. Undefined otherwise, including when the header
|
|
8
|
+
// is an HTTP-date rather than a delay: a caller that wants to sleep needs a
|
|
9
|
+
// number, and guessing one from a clock this client cannot trust is worse
|
|
10
|
+
// than saying nothing. Only 429 sends it today.
|
|
11
|
+
retryAfterSeconds;
|
|
12
|
+
constructor(message, status, body, retryAfterSeconds) {
|
|
7
13
|
super(message);
|
|
8
|
-
this.name = "
|
|
14
|
+
this.name = "DhartaError";
|
|
9
15
|
this.status = status;
|
|
10
16
|
this.body = body;
|
|
17
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
|
-
export class
|
|
20
|
+
export class DhartaAuthError extends DhartaError {
|
|
14
21
|
constructor(body) {
|
|
15
22
|
super("Unauthenticated or invalid API key", 401, body);
|
|
16
|
-
this.name = "
|
|
23
|
+
this.name = "DhartaAuthError";
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
|
-
export class
|
|
26
|
+
export class DhartaForbiddenError extends DhartaError {
|
|
20
27
|
constructor(body) {
|
|
21
28
|
super("Forbidden — caller lacks required scope", 403, body);
|
|
22
|
-
this.name = "
|
|
29
|
+
this.name = "DhartaForbiddenError";
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
export class
|
|
32
|
+
export class DhartaNotFoundError extends DhartaError {
|
|
26
33
|
constructor(body) {
|
|
27
34
|
super("Resource not found", 404, body);
|
|
28
|
-
this.name = "
|
|
35
|
+
this.name = "DhartaNotFoundError";
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
|
-
export class
|
|
38
|
+
export class DhartaValidationError extends DhartaError {
|
|
32
39
|
constructor(body) {
|
|
33
40
|
super("Validation failed", 422, body);
|
|
34
|
-
this.name = "
|
|
41
|
+
this.name = "DhartaValidationError";
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
|
-
export function errorFor(status, body) {
|
|
44
|
+
export function errorFor(status, body, retryAfterSeconds) {
|
|
38
45
|
if (status === 401)
|
|
39
|
-
return new
|
|
46
|
+
return new DhartaAuthError(body);
|
|
40
47
|
if (status === 403)
|
|
41
|
-
return new
|
|
48
|
+
return new DhartaForbiddenError(body);
|
|
42
49
|
if (status === 404)
|
|
43
|
-
return new
|
|
50
|
+
return new DhartaNotFoundError(body);
|
|
44
51
|
if (status === 422)
|
|
45
|
-
return new
|
|
52
|
+
return new DhartaValidationError(body);
|
|
46
53
|
const msg = body && typeof body === "object" && "message" in body && body.message
|
|
47
54
|
? body.message
|
|
48
55
|
: `Dharta API error ${status}`;
|
|
49
|
-
return new
|
|
56
|
+
return new DhartaError(String(msg), status, body, retryAfterSeconds);
|
|
57
|
+
}
|
|
58
|
+
// `Retry-After` as a whole number of seconds, or undefined when the header is
|
|
59
|
+
// absent, an HTTP-date, or otherwise not a non-negative integer count.
|
|
60
|
+
export function parseRetryAfterSeconds(header) {
|
|
61
|
+
if (header === null)
|
|
62
|
+
return undefined;
|
|
63
|
+
const trimmed = header.trim();
|
|
64
|
+
if (!/^\d+$/.test(trimmed))
|
|
65
|
+
return undefined;
|
|
66
|
+
const seconds = Number(trimmed);
|
|
67
|
+
return Number.isFinite(seconds) ? seconds : undefined;
|
|
50
68
|
}
|
|
51
69
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,+DAA+D;AAC/D,2DAA2D;AAC3D,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,IAAI,CAA4B;IACzC,sEAAsE;IACtE,2EAA2E;IAC3E,4EAA4E;IAC5E,0EAA0E;IAC1E,gDAAgD;IACvC,iBAAiB,CAAU;IAEpC,YACE,OAAe,EACf,MAAc,EACd,IAA+B,EAC/B,iBAA0B;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YAAY,IAA+B;QACzC,KAAK,CAAC,oCAAoC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,IAA+B;QACzC,KAAK,CAAC,yCAAyC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YAAY,IAA+B;QACzC,KAAK,CAAC,oBAAoB,EAAE,GAAG,EAAE,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AG,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
import type { MutationOptions } from "./idempotency.js";
|
|
3
|
+
import type { FleetAnomalyFinding, FleetExportParams, FleetOperation, FleetOperationParams, FleetRollout, FleetSavedView, FleetSavedViewParams, FleetSnoozeDuration, FleetAnalyticsSaveParams } from "./types.js";
|
|
4
|
+
export interface FleetRollbackResult {
|
|
5
|
+
rollout: FleetRollout;
|
|
6
|
+
operation: FleetOperation;
|
|
7
|
+
}
|
|
8
|
+
export declare class FleetOperationsResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
create(params: FleetOperationParams, options?: MutationOptions): Promise<FleetOperation>;
|
|
12
|
+
confirm(id: string, phrase: string, options?: MutationOptions): Promise<FleetOperation>;
|
|
13
|
+
cancel(id: string, options?: MutationOptions): Promise<FleetOperation>;
|
|
14
|
+
retry(id: string, options?: MutationOptions): Promise<FleetOperation>;
|
|
15
|
+
private post;
|
|
16
|
+
}
|
|
17
|
+
export declare class FleetRolloutsResource {
|
|
18
|
+
private readonly http;
|
|
19
|
+
constructor(http: HttpClient);
|
|
20
|
+
advance(id: string, options?: MutationOptions): Promise<FleetRollout>;
|
|
21
|
+
pause(id: string, options?: MutationOptions): Promise<FleetRollout>;
|
|
22
|
+
resume(id: string, options?: MutationOptions): Promise<FleetRollout>;
|
|
23
|
+
evaluate(id: string, options?: MutationOptions): Promise<FleetRollout>;
|
|
24
|
+
rollback(id: string, options?: MutationOptions): Promise<FleetRollbackResult>;
|
|
25
|
+
private post;
|
|
26
|
+
}
|
|
27
|
+
export declare class FleetFindingsResource {
|
|
28
|
+
private readonly http;
|
|
29
|
+
constructor(http: HttpClient);
|
|
30
|
+
acknowledge(id: string, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
31
|
+
snooze(id: string, duration?: FleetSnoozeDuration, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
32
|
+
resolve(id: string, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
33
|
+
reopen(id: string, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
34
|
+
classify(id: string, classification: string, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
35
|
+
assign(id: string, membershipId?: number | string | null, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
36
|
+
promote(id: string, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
37
|
+
updateRunbook(id: string, runbookUrl: string | null, options?: MutationOptions): Promise<FleetAnomalyFinding>;
|
|
38
|
+
private post;
|
|
39
|
+
}
|
|
40
|
+
export declare class FleetSavedViewsResource {
|
|
41
|
+
private readonly http;
|
|
42
|
+
constructor(http: HttpClient);
|
|
43
|
+
create(params: FleetSavedViewParams, options?: MutationOptions): Promise<FleetSavedView>;
|
|
44
|
+
update(id: string, params: Partial<FleetSavedViewParams>, options?: MutationOptions): Promise<FleetSavedView>;
|
|
45
|
+
delete(id: string, options?: MutationOptions): Promise<void>;
|
|
46
|
+
favorite(id: string, options?: MutationOptions): Promise<void>;
|
|
47
|
+
unfavorite(id: string, options?: MutationOptions): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare class FleetAnalyticsResource {
|
|
50
|
+
private readonly http;
|
|
51
|
+
constructor(http: HttpClient);
|
|
52
|
+
save(params: FleetAnalyticsSaveParams, options?: MutationOptions): Promise<FleetSavedView>;
|
|
53
|
+
unpin(id: string, options?: MutationOptions): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export declare class FleetExportsResource {
|
|
56
|
+
private readonly http;
|
|
57
|
+
constructor(http: HttpClient);
|
|
58
|
+
create(params: FleetExportParams, options?: MutationOptions): Promise<string>;
|
|
59
|
+
}
|
|
60
|
+
export declare class FleetResource {
|
|
61
|
+
readonly operations: FleetOperationsResource;
|
|
62
|
+
readonly rollouts: FleetRolloutsResource;
|
|
63
|
+
readonly findings: FleetFindingsResource;
|
|
64
|
+
readonly savedViews: FleetSavedViewsResource;
|
|
65
|
+
readonly analytics: FleetAnalyticsResource;
|
|
66
|
+
readonly exports: FleetExportsResource;
|
|
67
|
+
constructor(http: HttpClient);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=fleet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet.d.ts","sourceRoot":"","sources":["../src/fleet.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAkBpB,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,qBAAa,uBAAuB;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,UAAU,EAAI;IAI3C,MAAM,CACV,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAQzB;IAMK,OAAO,CACX,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAEzB;IAEK,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAE/E;IAEK,KAAK,CAAC,EAAE,EAAE,MAAM,EA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