@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.
Files changed (293) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +215 -11
  3. package/dist/agent.js +3 -2
  4. package/dist/agent.js.map +1 -1
  5. package/dist/api-error.js +6 -6
  6. package/dist/api-error.js.map +1 -1
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.js +860 -149
  9. package/dist/cli.js.map +1 -1
  10. package/dist/command-tree.d.ts +3 -0
  11. package/dist/command-tree.js +10 -0
  12. package/dist/command-tree.js.map +1 -0
  13. package/dist/commands/agents.d.ts +54 -17
  14. package/dist/commands/agents.js +246 -136
  15. package/dist/commands/agents.js.map +1 -1
  16. package/dist/commands/analytics.js +6 -5
  17. package/dist/commands/analytics.js.map +1 -1
  18. package/dist/commands/api.js +71 -86
  19. package/dist/commands/api.js.map +1 -1
  20. package/dist/commands/appearance.js +5 -6
  21. package/dist/commands/appearance.js.map +1 -1
  22. package/dist/commands/artifact.js +7 -6
  23. package/dist/commands/artifact.js.map +1 -1
  24. package/dist/commands/audit-log.js +2 -1
  25. package/dist/commands/audit-log.js.map +1 -1
  26. package/dist/commands/auth.js +26 -6
  27. package/dist/commands/auth.js.map +1 -1
  28. package/dist/commands/caps.js +11 -15
  29. package/dist/commands/caps.js.map +1 -1
  30. package/dist/commands/deploy.js +25 -10
  31. package/dist/commands/deploy.js.map +1 -1
  32. package/dist/commands/dev.d.ts +10 -1
  33. package/dist/commands/dev.js +56 -25
  34. package/dist/commands/dev.js.map +1 -1
  35. package/dist/commands/doctor.d.ts +2 -0
  36. package/dist/commands/doctor.js +60 -0
  37. package/dist/commands/doctor.js.map +1 -1
  38. package/dist/commands/embed-keys.js +4 -13
  39. package/dist/commands/embed-keys.js.map +1 -1
  40. package/dist/commands/env.js +4 -7
  41. package/dist/commands/env.js.map +1 -1
  42. package/dist/commands/files.js +3 -4
  43. package/dist/commands/files.js.map +1 -1
  44. package/dist/commands/fleet.d.ts +129 -0
  45. package/dist/commands/fleet.js +408 -0
  46. package/dist/commands/fleet.js.map +1 -0
  47. package/dist/commands/genui.d.ts +2 -0
  48. package/dist/commands/genui.js +53 -0
  49. package/dist/commands/genui.js.map +1 -0
  50. package/dist/commands/git-credential.js +2 -3
  51. package/dist/commands/git-credential.js.map +1 -1
  52. package/dist/commands/kartas.d.ts +9 -0
  53. package/dist/commands/kartas.js +33 -11
  54. package/dist/commands/kartas.js.map +1 -1
  55. package/dist/commands/keys.d.ts +17 -18
  56. package/dist/commands/keys.js +108 -19
  57. package/dist/commands/keys.js.map +1 -1
  58. package/dist/commands/login.js +2 -1
  59. package/dist/commands/login.js.map +1 -1
  60. package/dist/commands/members.d.ts +10 -0
  61. package/dist/commands/members.js +20 -6
  62. package/dist/commands/members.js.map +1 -1
  63. package/dist/commands/model-connections.d.ts +44 -0
  64. package/dist/commands/model-connections.js +435 -0
  65. package/dist/commands/model-connections.js.map +1 -0
  66. package/dist/commands/open.d.ts +2 -2
  67. package/dist/commands/open.js +4 -3
  68. package/dist/commands/open.js.map +1 -1
  69. package/dist/commands/org.d.ts +9 -0
  70. package/dist/commands/org.js +42 -0
  71. package/dist/commands/org.js.map +1 -0
  72. package/dist/commands/organization.d.ts +16 -0
  73. package/dist/commands/organization.js +118 -0
  74. package/dist/commands/organization.js.map +1 -0
  75. package/dist/commands/parity.js +1 -3
  76. package/dist/commands/parity.js.map +1 -1
  77. package/dist/commands/repos.d.ts +4 -0
  78. package/dist/commands/repos.js +17 -0
  79. package/dist/commands/repos.js.map +1 -0
  80. package/dist/commands/rollback.js +2 -3
  81. package/dist/commands/rollback.js.map +1 -1
  82. package/dist/commands/schedules.js +26 -21
  83. package/dist/commands/schedules.js.map +1 -1
  84. package/dist/commands/scopes.js +8 -1
  85. package/dist/commands/scopes.js.map +1 -1
  86. package/dist/commands/sessions.js +9 -3
  87. package/dist/commands/sessions.js.map +1 -1
  88. package/dist/commands/setup.js +5 -4
  89. package/dist/commands/setup.js.map +1 -1
  90. package/dist/commands/update.d.ts +1 -0
  91. package/dist/commands/update.js +24 -11
  92. package/dist/commands/update.js.map +1 -1
  93. package/dist/commands/webhooks.d.ts +4 -1
  94. package/dist/commands/webhooks.js +21 -16
  95. package/dist/commands/webhooks.js.map +1 -1
  96. package/dist/completions.js +24 -13
  97. package/dist/completions.js.map +1 -1
  98. package/dist/config.d.ts +12 -0
  99. package/dist/config.js +121 -7
  100. package/dist/config.js.map +1 -1
  101. package/dist/context.d.ts +2 -0
  102. package/dist/context.js +23 -7
  103. package/dist/context.js.map +1 -1
  104. package/dist/docs/cli-reference.d.ts +2 -0
  105. package/dist/docs/cli-reference.js +191 -0
  106. package/dist/docs/cli-reference.js.map +1 -0
  107. package/dist/exit-codes.d.ts +25 -0
  108. package/dist/exit-codes.js +107 -0
  109. package/dist/exit-codes.js.map +1 -0
  110. package/dist/genui.d.ts +178 -0
  111. package/dist/genui.js +1130 -0
  112. package/dist/genui.js.map +1 -0
  113. package/dist/harnesses.js +2 -1
  114. package/dist/harnesses.js.map +1 -1
  115. package/dist/jq.d.ts +4 -0
  116. package/dist/jq.js +91 -0
  117. package/dist/jq.js.map +1 -0
  118. package/dist/login-offer.js +6 -2
  119. package/dist/login-offer.js.map +1 -1
  120. package/dist/manifest.d.ts +12 -0
  121. package/dist/manifest.js +126 -0
  122. package/dist/manifest.js.map +1 -1
  123. package/dist/model-auth.d.ts +29 -0
  124. package/dist/model-auth.js +117 -0
  125. package/dist/model-auth.js.map +1 -0
  126. package/dist/model-settings.d.ts +23 -0
  127. package/dist/model-settings.js +186 -0
  128. package/dist/model-settings.js.map +1 -0
  129. package/dist/money.js +2 -1
  130. package/dist/money.js.map +1 -1
  131. package/dist/output.d.ts +6 -0
  132. package/dist/output.js +54 -0
  133. package/dist/output.js.map +1 -1
  134. package/dist/runtime.d.ts +1 -1
  135. package/dist/runtime.js +1 -1
  136. package/dist/scaffold.js +2 -1
  137. package/dist/scaffold.js.map +1 -1
  138. package/dist/validators.js +17 -11
  139. package/dist/validators.js.map +1 -1
  140. package/dist/version-check.d.ts +1 -1
  141. package/dist/version-check.js +1 -1
  142. package/dist/version-check.js.map +1 -1
  143. package/node_modules/@dharta/contracts/LICENSE +21 -0
  144. package/node_modules/@dharta/contracts/README.md +45 -0
  145. package/node_modules/@dharta/contracts/artifact-runtime.json +750 -0
  146. package/node_modules/@dharta/contracts/dist/activity.d.ts +62 -0
  147. package/node_modules/@dharta/contracts/dist/activity.d.ts.map +1 -0
  148. package/node_modules/@dharta/contracts/dist/activity.js +178 -0
  149. package/node_modules/@dharta/contracts/dist/activity.js.map +1 -0
  150. package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.d.ts +20 -0
  151. package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.d.ts.map +1 -0
  152. package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.js +53 -0
  153. package/node_modules/@dharta/contracts/dist/artifact-runtime-formats.js.map +1 -0
  154. package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.d.ts +37 -0
  155. package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.d.ts.map +1 -0
  156. package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.js +5107 -0
  157. package/node_modules/@dharta/contracts/dist/artifact-runtime-validators.generated.js.map +1 -0
  158. package/node_modules/@dharta/contracts/dist/artifact-runtime.d.ts +154 -0
  159. package/node_modules/@dharta/contracts/dist/artifact-runtime.d.ts.map +1 -0
  160. package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.d.ts +1670 -0
  161. package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.d.ts.map +1 -0
  162. package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.js +1903 -0
  163. package/node_modules/@dharta/contracts/dist/artifact-runtime.generated.js.map +1 -0
  164. package/node_modules/@dharta/contracts/dist/artifact-runtime.js +377 -0
  165. package/node_modules/@dharta/contracts/dist/artifact-runtime.js.map +1 -0
  166. package/node_modules/@dharta/contracts/dist/index.d.ts +6 -0
  167. package/node_modules/@dharta/contracts/dist/index.d.ts.map +1 -0
  168. package/node_modules/@dharta/contracts/dist/index.js +6 -0
  169. package/node_modules/@dharta/contracts/dist/index.js.map +1 -0
  170. package/node_modules/@dharta/contracts/dist/model-auth.d.ts +31 -0
  171. package/node_modules/@dharta/contracts/dist/model-auth.d.ts.map +1 -0
  172. package/node_modules/@dharta/contracts/dist/model-auth.js +45 -0
  173. package/node_modules/@dharta/contracts/dist/model-auth.js.map +1 -0
  174. package/node_modules/@dharta/contracts/dist/tasks.d.ts +44 -0
  175. package/node_modules/@dharta/contracts/dist/tasks.d.ts.map +1 -0
  176. package/node_modules/@dharta/contracts/dist/tasks.js +127 -0
  177. package/node_modules/@dharta/contracts/dist/tasks.js.map +1 -0
  178. package/node_modules/@dharta/contracts/dist/wire-events.d.ts +71 -0
  179. package/node_modules/@dharta/contracts/dist/wire-events.d.ts.map +1 -0
  180. package/node_modules/@dharta/contracts/dist/wire-events.js +48 -0
  181. package/node_modules/@dharta/contracts/dist/wire-events.js.map +1 -0
  182. package/node_modules/@dharta/contracts/model-auth-capabilities-v1.json +168 -0
  183. package/node_modules/@dharta/contracts/model-auth-reasons-v1.json +38 -0
  184. package/node_modules/@dharta/contracts/package.json +44 -0
  185. package/node_modules/@dharta/contracts/src/activity.ts +215 -0
  186. package/node_modules/@dharta/contracts/src/artifact-runtime-formats.ts +54 -0
  187. package/node_modules/@dharta/contracts/src/artifact-runtime-validators.generated.ts +29 -0
  188. package/node_modules/@dharta/contracts/src/artifact-runtime.generated.ts +2093 -0
  189. package/node_modules/@dharta/contracts/src/artifact-runtime.ts +520 -0
  190. package/node_modules/@dharta/contracts/src/index.ts +5 -0
  191. package/node_modules/@dharta/contracts/src/model-auth.ts +82 -0
  192. package/node_modules/@dharta/contracts/src/tasks.ts +142 -0
  193. package/node_modules/@dharta/contracts/src/wire-events.ts +150 -0
  194. package/node_modules/@dharta/contracts/wire-events.json +29 -0
  195. package/node_modules/@dharta/sdk/LICENSE +1 -1
  196. package/node_modules/@dharta/sdk/README.md +22 -8
  197. package/node_modules/@dharta/sdk/dist/errors.d.ts +9 -7
  198. package/node_modules/@dharta/sdk/dist/errors.d.ts.map +1 -1
  199. package/node_modules/@dharta/sdk/dist/errors.js +36 -18
  200. package/node_modules/@dharta/sdk/dist/errors.js.map +1 -1
  201. package/node_modules/@dharta/sdk/dist/fleet.d.ts +69 -0
  202. package/node_modules/@dharta/sdk/dist/fleet.d.ts.map +1 -0
  203. package/node_modules/@dharta/sdk/dist/fleet.js +240 -0
  204. package/node_modules/@dharta/sdk/dist/fleet.js.map +1 -0
  205. package/node_modules/@dharta/sdk/dist/http.d.ts +6 -2
  206. package/node_modules/@dharta/sdk/dist/http.d.ts.map +1 -1
  207. package/node_modules/@dharta/sdk/dist/http.js +71 -12
  208. package/node_modules/@dharta/sdk/dist/http.js.map +1 -1
  209. package/node_modules/@dharta/sdk/dist/idempotency.d.ts +12 -0
  210. package/node_modules/@dharta/sdk/dist/idempotency.d.ts.map +1 -0
  211. package/node_modules/@dharta/sdk/dist/idempotency.js +72 -0
  212. package/node_modules/@dharta/sdk/dist/idempotency.js.map +1 -0
  213. package/node_modules/@dharta/sdk/dist/index.d.ts +20 -6
  214. package/node_modules/@dharta/sdk/dist/index.d.ts.map +1 -1
  215. package/node_modules/@dharta/sdk/dist/index.js +27 -4
  216. package/node_modules/@dharta/sdk/dist/index.js.map +1 -1
  217. package/node_modules/@dharta/sdk/dist/resources.d.ts +108 -13
  218. package/node_modules/@dharta/sdk/dist/resources.d.ts.map +1 -1
  219. package/node_modules/@dharta/sdk/dist/resources.js +403 -57
  220. package/node_modules/@dharta/sdk/dist/resources.js.map +1 -1
  221. package/node_modules/@dharta/sdk/dist/types.d.ts +436 -16
  222. package/node_modules/@dharta/sdk/dist/types.d.ts.map +1 -1
  223. package/node_modules/@dharta/sdk/dist/types.js +31 -2
  224. package/node_modules/@dharta/sdk/dist/types.js.map +1 -1
  225. package/node_modules/@dharta/sdk/package.json +9 -3
  226. package/node_modules/@dharta/sdk/src/errors.ts +41 -18
  227. package/node_modules/@dharta/sdk/src/fleet.ts +339 -0
  228. package/node_modules/@dharta/sdk/src/http.ts +110 -17
  229. package/node_modules/@dharta/sdk/src/idempotency.ts +101 -0
  230. package/node_modules/@dharta/sdk/src/index.ts +50 -11
  231. package/node_modules/@dharta/sdk/src/resources.ts +549 -68
  232. package/node_modules/@dharta/sdk/src/types.ts +629 -20
  233. package/package.json +16 -6
  234. package/src/agent.ts +3 -2
  235. package/src/api-error.ts +6 -5
  236. package/src/cli.ts +978 -163
  237. package/src/command-tree.ts +13 -0
  238. package/src/commands/agents.ts +365 -167
  239. package/src/commands/analytics.ts +6 -5
  240. package/src/commands/api.ts +73 -92
  241. package/src/commands/appearance.ts +5 -6
  242. package/src/commands/artifact.ts +7 -6
  243. package/src/commands/audit-log.ts +2 -1
  244. package/src/commands/auth.ts +25 -5
  245. package/src/commands/caps.ts +11 -15
  246. package/src/commands/deploy.ts +18 -4
  247. package/src/commands/dev.ts +86 -25
  248. package/src/commands/doctor.ts +69 -0
  249. package/src/commands/embed-keys.ts +4 -14
  250. package/src/commands/env.ts +4 -7
  251. package/src/commands/files.ts +3 -4
  252. package/src/commands/fleet.ts +672 -0
  253. package/src/commands/genui.ts +59 -0
  254. package/src/commands/git-credential.ts +2 -3
  255. package/src/commands/kartas.ts +45 -11
  256. package/src/commands/keys.ts +152 -35
  257. package/src/commands/login.ts +2 -1
  258. package/src/commands/members.ts +31 -6
  259. package/src/commands/model-connections.ts +547 -0
  260. package/src/commands/open.ts +5 -4
  261. package/src/commands/org.ts +57 -0
  262. package/src/commands/organization.ts +153 -0
  263. package/src/commands/parity.ts +1 -3
  264. package/src/commands/repos.ts +23 -0
  265. package/src/commands/rollback.ts +2 -3
  266. package/src/commands/schedules.ts +33 -22
  267. package/src/commands/scopes.ts +8 -1
  268. package/src/commands/sessions.ts +9 -3
  269. package/src/commands/setup.ts +5 -4
  270. package/src/commands/update.ts +28 -12
  271. package/src/commands/webhooks.ts +30 -19
  272. package/src/completions.ts +25 -13
  273. package/src/config.ts +141 -9
  274. package/src/context.ts +34 -7
  275. package/src/docs/cli-reference.ts +206 -0
  276. package/src/exit-codes.ts +122 -0
  277. package/src/genui.ts +1398 -0
  278. package/src/harnesses.ts +2 -1
  279. package/src/jq.ts +109 -0
  280. package/src/login-offer.ts +6 -2
  281. package/src/manifest.ts +134 -0
  282. package/src/model-auth.ts +173 -0
  283. package/src/model-settings.ts +222 -0
  284. package/src/money.ts +5 -1
  285. package/src/output.ts +60 -0
  286. package/src/runtime.ts +1 -1
  287. package/src/scaffold.ts +2 -1
  288. package/src/validators.ts +18 -11
  289. package/src/version-check.ts +1 -1
  290. package/dist/commands/model-keys.d.ts +0 -22
  291. package/dist/commands/model-keys.js +0 -222
  292. package/dist/commands/model-keys.js.map +0 -1
  293. package/src/commands/model-keys.ts +0 -278
@@ -12,17 +12,23 @@ export const API_KEY_SCOPES = [
12
12
  "directories:read",
13
13
  "embed_keys:read",
14
14
  "env:read",
15
+ "instance_env:read",
16
+ "kartas:read",
15
17
  "keys:read",
16
18
  "members:read",
17
- "model_keys:read",
19
+ "model_connections:read",
18
20
  "releases:read",
19
21
  "schedules:read",
20
22
  "sessions:read",
21
23
  "source_repos:read",
22
24
  "webhooks:read",
25
+ "fleet:read",
23
26
  "agents:write",
24
27
  "appearance:write",
25
28
  "env:write",
29
+ "fleet:write",
30
+ "instance_env:write",
31
+ "kartas:write",
26
32
  "releases:write",
27
33
  "schedules:write",
28
34
  "webhooks:write",
@@ -32,34 +38,53 @@ export const API_KEY_SCOPES = [
32
38
  "env:secrets:read",
33
39
  "source_archives:read",
34
40
  "workspace_tokens:create",
41
+ "workspace:read",
35
42
  "audit_log:export",
43
+ "fleet:subjects:read",
36
44
  "members:invite",
37
45
  "members:write",
38
46
  "members:owner_role:write",
39
47
  "agents:delete",
40
48
  "keys:write",
41
- "model_keys:write",
49
+ "model_connections:write",
50
+ "fleet:subjects:write",
51
+ "fleet:operations:write",
42
52
  "billing:read",
53
+ "organization:write",
54
+ "organization:support_access:write",
43
55
  ] as const;
44
56
 
45
57
  export type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
46
58
 
47
- export type ModelKeyProvider =
59
+ export type ModelConnectionProvider =
48
60
  | "anthropic"
49
61
  | "openai"
50
- | "bedrock"
51
- | "vertex"
52
62
  | "openrouter"
53
63
  | "xai"
54
64
  | "google";
55
65
 
56
- export type ModelApiFormat =
66
+ export type ModelConnectionApiFormat =
57
67
  | "anthropic_messages"
58
68
  | "openai_chat_completions"
59
- | "openai_responses"
69
+ | "openai_responses";
70
+
71
+ export type ModelApiFormat =
72
+ | ModelConnectionApiFormat
60
73
  | "bedrock_converse"
61
74
  | "vertex_generate_content";
62
75
 
76
+ export type ResolvedModelProvider = ModelConnectionProvider | "bedrock" | "vertex";
77
+ export type ResolvedModelCredentialKind = "api_key" | "workload_identity";
78
+
79
+ // The commercial and protocol access path of a stored connector, derived by
80
+ // the server from `provider` + `credential_kind`. Read-only: you never send it.
81
+ export type ModelAdapterKind =
82
+ | "anthropic_api"
83
+ | "openai_api"
84
+ | "openrouter_api"
85
+ | "xai_api"
86
+ | "google_gemini_api";
87
+
63
88
  export type ModelReasoningEffort = "low" | "medium" | "high";
64
89
 
65
90
  export interface ModelParameters {
@@ -94,13 +119,194 @@ export const WEBHOOK_EVENT_TYPES = [
94
119
 
95
120
  export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
96
121
 
122
+ // The one agent shape every agent mutation returns
123
+ // (Api::Serializers::Agent server-side).
124
+ export interface Agent {
125
+ id: number;
126
+ slug: string;
127
+ name: string;
128
+ deploy_enabled: boolean;
129
+ serving_status: string;
130
+ dashboard_edits_enabled: boolean;
131
+ workspace_inspectable?: boolean;
132
+ workspace_access?: Record<string, Record<string, boolean>>;
133
+ // Whether this agent's kartas write to the durable store. A cost setting.
134
+ durable_workspace_enabled?: boolean;
135
+ deploy_branch?: string;
136
+ archived_at?: string | null;
137
+ // The agent's STORED model policy, never the resolved one. Read the
138
+ // resolved route from GET /api/agents/{slug}.
139
+ model?: {
140
+ // Which policy `connector_order` expresses. `inherit` is an empty order,
141
+ // `platform` selects the Dharta platform connector, `connection` selects
142
+ // one of this organization's own model connections.
143
+ source: "inherit" | "platform" | "connection";
144
+ // Non-null exactly when `source` is `connection`.
145
+ model_connection_id: number | null;
146
+ parameters: ModelParameters;
147
+ connector_order: string[];
148
+ model_reference: string;
149
+ };
150
+ }
151
+
152
+ export interface AgentChangeResponse {
153
+ agent: Agent;
154
+ // False when the request asked for the value the agent already had.
155
+ changed: boolean;
156
+ }
157
+
158
+ export interface Release {
159
+ // bigint primary key server-side, returned as a JSON number.
160
+ id: number;
161
+ version: number;
162
+ label?: string;
163
+ status: string;
164
+ kind?: string;
165
+ current?: boolean;
166
+ activatable?: boolean;
167
+ commit_sha?: string | null;
168
+ error_message?: string | null;
169
+ build_kind?: string | null;
170
+ pushed_via?: string | null;
171
+ harness_slug?: string | null;
172
+ harness_version?: string | null;
173
+ created_at?: string;
174
+ built_at?: string | null;
175
+ }
176
+
177
+ export interface AgentCreateParams {
178
+ // Display name. The slug is derived from it when `slug` is absent. IGNORED
179
+ // with `githubRepositoryId`: that fork creates a source repo, not an agent,
180
+ // and the agent names itself from the dharta.toml the sync finds.
181
+ name?: string;
182
+ slug?: string;
183
+ // Link this installed GitHub repository instead of creating an empty hosted
184
+ // repo. `githubRepositories.list()` returns the ids you may send.
185
+ githubRepositoryId?: number | string;
186
+ // Only read with `githubRepositoryId`. The repository's default branch when
187
+ // absent.
188
+ deployBranch?: string;
189
+ }
190
+
191
+ export interface AgentCreateResponse {
192
+ agent: {
193
+ id: number;
194
+ slug: string;
195
+ name: string;
196
+ deploy_branch: string;
197
+ };
198
+ clone_url: string;
199
+ created: boolean;
200
+ }
201
+
202
+ // What the GitHub fork of `POST /api/agents` answers. It links a source repo,
203
+ // so there is no agent yet: one appears when the sync finds a single enabled
204
+ // dharta.toml on the deploy branch.
205
+ export interface AgentLinkGithubResponse {
206
+ source_repo: {
207
+ slug: string;
208
+ deploy_branch: string;
209
+ github_repository: string;
210
+ clone_url?: string;
211
+ };
212
+ created: boolean;
213
+ }
214
+
215
+ // One entry of `githubRepositories.list()`: an installed repository, and the
216
+ // `id` to send as `githubRepositoryId`.
217
+ export interface GithubRepository {
218
+ id: number;
219
+ full_name: string;
220
+ default_branch: string;
221
+ // Always sent: the listing joins the installation, and `linked` is computed
222
+ // for every row.
223
+ linked: boolean;
224
+ installation: { account_login: string; account_type: string | null };
225
+ }
226
+
227
+ export function isAgentLinkGithubResponse(
228
+ value: AgentCreateResponse | AgentLinkGithubResponse,
229
+ ): value is AgentLinkGithubResponse {
230
+ return "source_repo" in value;
231
+ }
232
+
233
+ export interface AgentFromTemplateParams {
234
+ // Template key from `GET /agent_templates`.
235
+ template: string;
236
+ name: string;
237
+ // Derived from `name` when absent.
238
+ slug?: string;
239
+ description?: string;
240
+ // Harness slug, e.g. "claude-code". Dharta's default when absent.
241
+ harness?: string;
242
+ // Requires `harness`. The harness default when absent.
243
+ harnessVersion?: string;
244
+ }
245
+
246
+ export interface AgentFromTemplateResponse {
247
+ agent: Agent;
248
+ clone_url: string;
249
+ created: boolean;
250
+ release: Release | null;
251
+ accepted?: boolean;
252
+ // Present while release v1 is still building.
253
+ phase?: string;
254
+ state?: string;
255
+ retryable?: boolean;
256
+ }
257
+
258
+ export interface AgentDeployResponse {
259
+ agent: Agent;
260
+ queued: boolean;
261
+ source_repo: {
262
+ slug: string;
263
+ deploy_branch: string;
264
+ github_repository: string | null;
265
+ };
266
+ sync_generation?: number | null;
267
+ sync_attempt?: number | null;
268
+ }
269
+
270
+ export interface ReleaseRetryResponse {
271
+ agent: { id: number; slug: string; name: string };
272
+ release: Release;
273
+ retried_release: Release;
274
+ message?: string;
275
+ accepted?: boolean;
276
+ phase?: string;
277
+ state?: string;
278
+ retryable?: boolean;
279
+ }
280
+
281
+ export interface AgentCodeUpdateParams {
282
+ // Edited files as { path => content }. Only the paths you send change.
283
+ files: Record<string, string>;
284
+ // The release version the edits were made against, from
285
+ // `GET /api/agents/{slug}/releases`. Required: optimistic concurrency is
286
+ // always on, and a save against any other version is a 409, never a clobber.
287
+ baseVersion: number;
288
+ }
289
+
290
+ export interface AgentCodeUpdateResponse {
291
+ version: number;
292
+ status: string;
293
+ // All three are always sent; `changed` is `[]` on a no-op save.
294
+ changed: string[];
295
+ no_change: boolean;
296
+ pending: boolean;
297
+ }
298
+
97
299
  export interface ApiKey {
98
- id: string;
300
+ // Numeric: api_keys has a bigint primary key and the API answers the integer.
301
+ id: number;
99
302
  name: string;
100
303
  prefix: string;
101
304
  scopes: ApiKeyScope[];
102
- mode?: "live" | "test";
103
- expires_at?: string | null;
305
+ // Always answered, on every key and in the rotate response. `expires_at` is
306
+ // null for a key that never expires; a rotation copies the original's
307
+ // deadline rather than granting a fresh one.
308
+ mode: "live" | "test";
309
+ expires_at: string | null;
104
310
  created_at: string;
105
311
  last_used_at: string | null;
106
312
  revoked_at: string | null;
@@ -112,38 +318,204 @@ export interface ApiKeyCreateResponse {
112
318
  secret: string;
113
319
  }
114
320
 
115
- export interface ModelKey {
321
+ export const API_KEY_BULK_ACTIONS = ["disable", "enable", "revoke"] as const;
322
+
323
+ export type ApiKeyBulkAction = (typeof API_KEY_BULK_ACTIONS)[number];
324
+
325
+ export const API_KEY_ROTATION_GRACE_PERIODS = ["now", "24h", "7d"] as const;
326
+
327
+ export type ApiKeyRotationGracePeriod = (typeof API_KEY_ROTATION_GRACE_PERIODS)[number];
328
+
329
+ export interface ApiKeyRotateResponse {
330
+ api_key: ApiKey;
331
+ // Plaintext secret for the replacement - shown exactly once. Store it now.
332
+ secret: string;
333
+ previous_key: ApiKey;
334
+ // When the rotated key stops working. Already past for `grace_period: "now"`.
335
+ grace_ends_at: string;
336
+ }
337
+
338
+ export interface ApiKeyStateResponse {
339
+ api_key: ApiKey;
340
+ // False when the key was already in that state, which is a no-op, not an error.
341
+ changed: boolean;
342
+ }
343
+
344
+ export interface ApiKeyBulkUpdateResponse {
345
+ action: ApiKeyBulkAction;
346
+ updated: ApiKey[];
347
+ // Keys the action does not apply to, left unchanged.
348
+ skipped: ApiKey[];
349
+ }
350
+
351
+ export interface ModelConnection {
116
352
  id: number;
117
- provider: ModelKeyProvider;
353
+ // Organization-unique connector slug. Address a connector by this or by
354
+ // `id` on every /model_connections path, and by slug in a model reference.
355
+ slug: string;
356
+ provider: ModelConnectionProvider;
118
357
  name: string;
119
358
  tail: string;
120
- auth_type: "api_key" | "oauth_subscription";
359
+ credential_kind: "api_key";
360
+ funding_source: "api_usage";
361
+ owner_kind: "organization";
362
+ storage_kind: "control_plane_encrypted";
363
+ adapter_kind: ModelAdapterKind;
364
+ connector_access_path_revision: number;
365
+ connector_access_path_digest: string;
121
366
  endpoint_url: string | null;
122
- api_format: ModelApiFormat | null;
367
+ api_format: ModelConnectionApiFormat | null;
123
368
  created_at: string;
124
369
  last_verified_at: string | null;
125
370
  verification_error: string | null;
126
371
  revoked_at: string | null;
127
372
  }
128
373
 
129
- export interface ModelKeyCreateParams {
130
- provider: ModelKeyProvider;
374
+ export interface ModelConnectionCreateParams {
375
+ provider: ModelConnectionProvider;
131
376
  plaintext: string;
132
377
  name?: string;
133
- auth_type?: "api_key" | "oauth_subscription";
378
+ // Omit to let the server derive the slug from `name`.
379
+ slug?: string;
134
380
  endpoint_url?: string;
135
- api_format?: ModelApiFormat;
381
+ api_format?: ModelConnectionApiFormat;
136
382
  }
137
383
 
384
+ export interface ModelConnectionRotateParams {
385
+ plaintext: string;
386
+ name?: string;
387
+ }
388
+
389
+ // One model a connection can serve. Only explicitly stored offers can be
390
+ // enabled or selected as the connection default.
391
+ export interface ModelConnectionOffer {
392
+ model_id: string;
393
+ enabled: boolean;
394
+ default: boolean;
395
+ }
396
+
397
+ export interface ModelConnectionOffers {
398
+ connector: {
399
+ id: number;
400
+ slug: string;
401
+ provider: ModelConnectionProvider;
402
+ };
403
+ models: ModelConnectionOffer[];
404
+ }
405
+
406
+ export interface ModelConnectionOffersUpdateParams {
407
+ // Replaces the whole enabled set.
408
+ enabled: string[];
409
+ // Must be one of `enabled`. Null clears the connector default.
410
+ default?: string | null;
411
+ }
412
+
413
+ // What the organization's model settings resolve to for an inheriting agent,
414
+ // reduced to non-secret fields. Either it resolved, or it carries a stable
415
+ // RFC 0070 error code and nothing else. Narrow on `error` before reading the
416
+ // rest:
417
+ //
418
+ // const r = settings.resolved;
419
+ // if (r.error) console.log(r.error); else console.log(r.connector, r.model_id);
420
+ export type ResolvedOrganizationModel =
421
+ | {
422
+ // The connector slug, or `karta` for the platform connector.
423
+ connector: string;
424
+ model_id: string;
425
+ provider: ResolvedModelProvider;
426
+ credential_kind: ResolvedModelCredentialKind;
427
+ error?: never;
428
+ }
429
+ | {
430
+ error: string;
431
+ connector?: never;
432
+ model_id?: never;
433
+ provider?: never;
434
+ credential_kind?: never;
435
+ };
436
+
437
+ // A model reference on the wire: the shorthand string, or the typed mapping.
438
+ // The mapping's fields are exact per kind, matching the server's parser.
439
+ export type ModelReferenceInput =
440
+ | string
441
+ | { kind: "default" }
442
+ | { kind: "model"; model: string }
443
+ | { kind: "target"; connector: string; model: string }
444
+ | { kind: "route"; route: string };
445
+
446
+ // A patch over the portable model parameters. A null clears one parameter and
447
+ // leaves the rest inherited; an absent key leaves it unchanged.
448
+ export interface ModelParametersPatch {
449
+ temperature?: number | null;
450
+ top_p?: number | null;
451
+ max_output_tokens?: number | null;
452
+ reasoning_effort?: ModelReasoningEffort | null;
453
+ provider_options?: ModelParameters["provider_options"] | null;
454
+ }
455
+
456
+ export interface OrganizationModelSettings {
457
+ // Ordered connector slugs, including the synthetic platform slug `karta`.
458
+ // Empty means unset, which resolves as `["karta"]`.
459
+ connector_order: string[];
460
+ // The stored model reference shorthand: "", "<model>",
461
+ // "connector:<slug>/<model>", or "route:<name>".
462
+ model_reference: string;
463
+ model_parameters: ModelParameters;
464
+ // Optional endpoint override: the public HTTPS endpoint the organization
465
+ // default calls instead of the provider's standard API. Null when unset.
466
+ provider_endpoint_url: string | null;
467
+ // Wire protocol for that endpoint. Stored NOT NULL, so it always has a value
468
+ // and is read only when an endpoint URL is set.
469
+ provider_endpoint_kind: ModelSettingsEndpointKind;
470
+ resolved: ResolvedOrganizationModel;
471
+ }
472
+
473
+ // Mirrors OrganizationSettings::ENDPOINT_KINDS server-side. The first three are
474
+ // the historical spellings; the rest name a provider API format directly.
475
+ export const MODEL_SETTINGS_ENDPOINT_KINDS = [
476
+ "anthropic",
477
+ "openai",
478
+ "openai-compatible",
479
+ "anthropic_messages",
480
+ "openai_chat_completions",
481
+ "openai_responses",
482
+ "bedrock_converse",
483
+ "vertex_generate_content",
484
+ ] as const;
485
+
486
+ export type ModelSettingsEndpointKind = (typeof MODEL_SETTINGS_ENDPOINT_KINDS)[number];
487
+
488
+ // Only the keys you send change. A null inside `model_parameters` clears that
489
+ // one parameter.
490
+ export interface OrganizationModelSettingsUpdateParams {
491
+ // An array of connector slugs, or one string with whitespace or comma
492
+ // separators. Empty means the platform connector serves turns.
493
+ connector_order?: string[] | string;
494
+ model_reference?: ModelReferenceInput;
495
+ model_parameters?: ModelParametersPatch;
496
+ // Send "" or null to clear the override; both mean the same thing. The kind
497
+ // is switched, never cleared: clearing an override means clearing the URL.
498
+ provider_endpoint_url?: string | null;
499
+ provider_endpoint_kind?: ModelSettingsEndpointKind;
500
+ }
501
+
502
+ // `Api::WebhookEndpointsController#serialize`, field for field.
503
+ //
504
+ // `id` is the integer primary key. It read `string` here and `uuid` in the
505
+ // OpenAPI document, so a caller comparing an id to one it stored got false.
506
+ //
507
+ // `consecutive_failures` used to be required and the serializer has never
508
+ // returned it, so `endpoint.consecutive_failures` was `undefined` typed as
509
+ // `number` - the failure the type system exists to prevent.
138
510
  export interface WebhookEndpoint {
139
- id: string;
511
+ id: number;
140
512
  name: string;
141
513
  url: string;
142
514
  event_types: WebhookEventType[];
143
515
  enabled: boolean;
144
- consecutive_failures: number;
145
516
  disabled_at: string | null;
146
517
  created_at: string;
518
+ updated_at: string;
147
519
  }
148
520
 
149
521
  export interface WebhookEndpointCreateResponse {
@@ -151,6 +523,35 @@ export interface WebhookEndpointCreateResponse {
151
523
  secret: string;
152
524
  }
153
525
 
526
+ export interface WebhookDelivery {
527
+ id: number;
528
+ webhook_endpoint_id: number;
529
+ event_id: string;
530
+ event_type: string;
531
+ attempt: number;
532
+ next_attempt_at: string | null;
533
+ created_at: string;
534
+ }
535
+
536
+ export interface KartaShare {
537
+ id: number;
538
+ prefix: string;
539
+ name: string;
540
+ agent_instance_id: string;
541
+ agent: { id: number; slug: string; name: string } | null;
542
+ allowed_origins: string[];
543
+ created_at: string;
544
+ revoked_at: string | null;
545
+ }
546
+
547
+ export interface KartaShareCreateResponse {
548
+ share: KartaShare;
549
+ // Publishable key - shown exactly once. Store it now.
550
+ secret: string;
551
+ // The link to hand out, secret included.
552
+ url: string;
553
+ }
554
+
154
555
  export interface UsageSummary {
155
556
  totals: {
156
557
  input_tokens?: number;
@@ -172,8 +573,216 @@ export interface BillingStatus {
172
573
  current_period_end: string | null;
173
574
  }
174
575
 
576
+ // A pending organization invitation, as `GET /api/members` lists them and
577
+ // `POST /api/members/invitations/{id}/resend` returns one. `id` is an integer
578
+ // primary key rather than a uuid: invitations predate that convention.
579
+ export interface MemberInvitation {
580
+ id: number;
581
+ email: string;
582
+ role: string;
583
+ expires_at: string | null;
584
+ created_at: string;
585
+ }
586
+
175
587
  export interface ErrorBody {
176
588
  error: string;
177
589
  message?: string;
178
590
  details?: Record<string, unknown>;
179
591
  }
592
+
593
+ // --- Fleet (RFC 0048 PR7) -------------------------------------------------
594
+
595
+ export type FleetEntityType = "agents" | "kartas" | "users" | "sessions";
596
+
597
+ export type FleetSnoozeDuration = "1h" | "1d" | "1w";
598
+
599
+ export interface FleetOperation {
600
+ id: string;
601
+ entity_type: string;
602
+ action: string;
603
+ status: string;
604
+ parameters: Record<string, unknown>;
605
+ selection: {
606
+ mode: string;
607
+ // Set when the selection freezes, and nothing requires an operation's
608
+ // selection to be frozen. Every path that creates one today freezes first,
609
+ // but that is a property of the callers, not of the model.
610
+ manifest_digest: string | null;
611
+ };
612
+ targets: {
613
+ total: number;
614
+ pending: number;
615
+ running: number;
616
+ succeeded: number;
617
+ failed: number;
618
+ skipped: number;
619
+ cancelled: number;
620
+ };
621
+ // A NOT NULL jsonb column with a `{}` default, so it is an empty object
622
+ // rather than null when a preview produced no summary.
623
+ dry_run_summary: Record<string, unknown>;
624
+ warnings: string[];
625
+ requires_step_up: boolean;
626
+ // Present only while the operation is a draft: it is what `confirm` takes.
627
+ confirmation_phrase?: string | null;
628
+ last_error_code: string | null;
629
+ last_error_message: string | null;
630
+ approved_at: string | null;
631
+ started_at: string | null;
632
+ finished_at: string | null;
633
+ cancel_requested_at: string | null;
634
+ created_at: string;
635
+ }
636
+
637
+ export interface FleetOperationParams {
638
+ action_key: string;
639
+ entity_type?: FleetEntityType;
640
+ // "explicit" names rows by id. "snapshot" and "all_matching" freeze whatever
641
+ // the filter or saved view matched at preview time. The server defaults to
642
+ // "all_matching", which is every row the filter selects - and every row of
643
+ // the entity type when there is no filter.
644
+ selection_mode?: "explicit" | "snapshot" | "all_matching";
645
+ explicit_ids?: string[];
646
+ saved_view_id?: string;
647
+ filter?: string;
648
+ // The server permits exactly these keys and drops anything else without
649
+ // saying so: team_slug, environment, lifecycle, label_assignment, label_key,
650
+ // rollout_ring, release_version, model_id, harness_version, cap_cents.
651
+ // `action_key` decides which of them apply.
652
+ parameters?: Record<string, unknown>;
653
+ }
654
+
655
+ export interface FleetRolloutPartition {
656
+ position: number;
657
+ name: string;
658
+ percentage: number;
659
+ target_count: number;
660
+ status: string;
661
+ status_reason: string | null;
662
+ observation_window_minutes: number;
663
+ unhealthy_windows: number;
664
+ started_at: string | null;
665
+ observing_at: string | null;
666
+ next_evaluation_at: string | null;
667
+ last_evaluated_at: string | null;
668
+ finished_at: string | null;
669
+ }
670
+
671
+ export interface FleetRollout {
672
+ id: string;
673
+ name: string;
674
+ status: string;
675
+ status_reason: string | null;
676
+ // Release versions are integers, and the rollout always has a target. Only
677
+ // the rollback version is nullable: a rollout that has never been rolled back
678
+ // has nothing to go back to.
679
+ target_release_version: number;
680
+ rollback_release_version: number | null;
681
+ current_partition_position: number;
682
+ consecutive_unhealthy_windows: number;
683
+ automatic_pause_enabled: boolean;
684
+ automatic_rollback_enabled: boolean;
685
+ anomaly_gate_enabled: boolean;
686
+ shadow_mode: boolean;
687
+ started_at: string | null;
688
+ paused_at: string | null;
689
+ finished_at: string | null;
690
+ created_at: string;
691
+ partitions: FleetRolloutPartition[];
692
+ }
693
+
694
+ // The detector's own evidence sample is not part of this shape. It holds
695
+ // session and end-user references, which stay behind the console and the
696
+ // expiring `fleet:subjects:read` scope.
697
+ export interface FleetAnomalyFinding {
698
+ id: string;
699
+ metric: string;
700
+ detector: string;
701
+ status: string;
702
+ // Never null: an untriaged finding reads "unclassified".
703
+ classification: string;
704
+ severity: string;
705
+ title: string;
706
+ detail: string;
707
+ assigned_membership_id: number | null;
708
+ runbook_url: string | null;
709
+ scope_definition: Record<string, unknown>;
710
+ filter_digest: string;
711
+ // The detector always produces a full measurement, so these are NOT NULL
712
+ // columns and the serializer emits every one. `relative_deviation` is the
713
+ // exception: its column is nullable.
714
+ observed_value: number;
715
+ expected_low: number;
716
+ expected_high: number;
717
+ absolute_deviation: number;
718
+ relative_deviation: number | null;
719
+ sample_count: number;
720
+ occurrence_count: number;
721
+ confidence: number;
722
+ materiality: number;
723
+ complete: boolean;
724
+ // The four detection timestamps are NOT NULL. The lifecycle ones below are
725
+ // not: a finding that was never resolved has no resolved_at.
726
+ started_at: string;
727
+ peak_at: string;
728
+ detected_at: string;
729
+ last_seen_at: string;
730
+ recovery_at: string | null;
731
+ resolved_at: string | null;
732
+ snoozed_until: string | null;
733
+ promoted_at: string | null;
734
+ }
735
+
736
+ export interface FleetSavedView {
737
+ id: string;
738
+ url: string;
739
+ entity_type: string;
740
+ name: string;
741
+ description: string | null;
742
+ visibility: string;
743
+ team_id: number | null;
744
+ owner_membership_id: number | null;
745
+ organization_default: boolean;
746
+ definition_version: number;
747
+ definition: Record<string, unknown>;
748
+ favorite: boolean;
749
+ updated_at: string;
750
+ }
751
+
752
+ export interface FleetSavedViewParams {
753
+ entity_type: string;
754
+ name: string;
755
+ definition: Record<string, unknown>;
756
+ // null clears a description that was set; omitting the key leaves it alone.
757
+ description?: string | null;
758
+ visibility?: "private" | "team" | "organization";
759
+ // null clears the owning team, which is how a team view becomes an
760
+ // organization or private one.
761
+ organization_team_id?: number | null;
762
+ organization_default?: boolean;
763
+ }
764
+
765
+ export interface FleetAnalyticsSaveParams {
766
+ name: string;
767
+ // Optional: the explorer defaults to `turns` when no metric is given.
768
+ metric?: string;
769
+ description?: string;
770
+ range?: string;
771
+ starts_at?: string;
772
+ ends_at?: string;
773
+ scope_kind?: string;
774
+ scope_ids?: string;
775
+ bucket?: string;
776
+ aggregation?: string;
777
+ comparison?: string;
778
+ comparison_saved_view?: string;
779
+ breakdown?: string[];
780
+ events?: string[];
781
+ filters?: Record<string, unknown>;
782
+ }
783
+
784
+ export interface FleetExportParams {
785
+ entity_type: FleetEntityType;
786
+ // Row identifiers, as the catalog returns them.
787
+ explicit_ids: string[];
788
+ }