@drisp/protocol 0.8.6 → 0.8.8
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/dist/v2.d.ts +701 -9
- package/dist/v2.js +522 -309
- package/package.json +1 -1
- package/schema/v2/checkpoint.json +5 -0
- package/schema/v2/client.json +1 -2
- package/schema/v2/command.json +1 -2
- package/schema/v2/deliveredCommand.json +458 -0
- package/schema/v2/grant.json +5 -0
- package/schema/v2/run.json +9 -5
- package/schema/v2/runner.json +6 -0
package/dist/v2.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-HMYWICNI.js";
|
|
4
4
|
|
|
5
5
|
// src/v2.ts
|
|
6
|
-
import { z as
|
|
6
|
+
import { z as z3 } from "zod";
|
|
7
7
|
|
|
8
8
|
// src/history.ts
|
|
9
9
|
function readableHistory(records) {
|
|
@@ -73,8 +73,8 @@ function attemptForecast(declaredCap) {
|
|
|
73
73
|
}
|
|
74
74
|
function attemptCost(attempt) {
|
|
75
75
|
const forecast = attemptForecast(attempt.tokenCap);
|
|
76
|
-
|
|
77
|
-
return Math.
|
|
76
|
+
const cost = attempt.closed ? attempt.spent ?? forecast : Math.max(forecast, attempt.spent ?? 0);
|
|
77
|
+
return attempt.tokenCap > 0 ? Math.min(attempt.tokenCap, cost) : cost;
|
|
78
78
|
}
|
|
79
79
|
function budgetCheck(input) {
|
|
80
80
|
const used = input.attempts.reduce((sum, attempt) => sum + attemptCost(attempt), 0);
|
|
@@ -110,6 +110,192 @@ function forecastOfClass(sizeClass, calibration) {
|
|
|
110
110
|
return calibration?.[sizeClass]?.forecast ?? SIZE_CLASS_FORECASTS[sizeClass];
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// src/tracker.ts
|
|
114
|
+
import { z as z2 } from "zod";
|
|
115
|
+
var id = z2.string().min(1).max(160);
|
|
116
|
+
var text = z2.string().max(1e5);
|
|
117
|
+
var deliveryEvidenceKindSchema = z2.enum(["pr_opened", "merged", "staging", "qa_started", "qa_passed", "released"]);
|
|
118
|
+
var deliveryStageSchema = z2.strictObject({
|
|
119
|
+
id,
|
|
120
|
+
name: z2.string().trim().min(1).max(100),
|
|
121
|
+
category: z2.enum(["backlog", "unstarted", "started", "completed", "canceled"]),
|
|
122
|
+
behavior: z2.enum(["manual", "agent_start", ...deliveryEvidenceKindSchema.options]).default("manual")
|
|
123
|
+
});
|
|
124
|
+
var deliveryTransitionSchema = z2.strictObject({
|
|
125
|
+
from: id,
|
|
126
|
+
to: id,
|
|
127
|
+
requires: z2.array(deliveryEvidenceKindSchema).default([])
|
|
128
|
+
});
|
|
129
|
+
var deliveryWorkflowSchema = z2.strictObject({
|
|
130
|
+
revision: z2.number().int().nonnegative(),
|
|
131
|
+
stages: z2.array(deliveryStageSchema).min(1).max(100),
|
|
132
|
+
transitions: z2.array(deliveryTransitionSchema).max(1e4),
|
|
133
|
+
attentionColumn: z2.boolean().default(true)
|
|
134
|
+
}).superRefine((workflow, ctx) => {
|
|
135
|
+
const ids = new Set(workflow.stages.map((s) => s.id));
|
|
136
|
+
if (ids.size !== workflow.stages.length) ctx.addIssue({ code: "custom", message: "Duplicate stage ID" });
|
|
137
|
+
const edges = /* @__PURE__ */ new Set();
|
|
138
|
+
for (const edge of workflow.transitions) {
|
|
139
|
+
const key = JSON.stringify([edge.from, edge.to]);
|
|
140
|
+
if (!ids.has(edge.from) || !ids.has(edge.to) || edge.from === edge.to || edges.has(key))
|
|
141
|
+
ctx.addIssue({ code: "custom", message: "Invalid or duplicate transition" });
|
|
142
|
+
edges.add(key);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
function defaultDeliveryWorkflow() {
|
|
146
|
+
const stages = [
|
|
147
|
+
{ id: "backlog", name: "Backlog", category: "backlog", behavior: "manual" },
|
|
148
|
+
{ id: "todo", name: "Todo", category: "unstarted", behavior: "manual" },
|
|
149
|
+
{ id: "progress", name: "In Progress", category: "started", behavior: "agent_start" },
|
|
150
|
+
{ id: "review", name: "In Review", category: "started", behavior: "pr_opened" },
|
|
151
|
+
{ id: "stage-ready", name: "Ready for Staging", category: "started", behavior: "merged" },
|
|
152
|
+
{ id: "staging", name: "In Staging", category: "started", behavior: "staging" },
|
|
153
|
+
{ id: "qa", name: "In QA", category: "started", behavior: "qa_started" },
|
|
154
|
+
{ id: "prod-ready", name: "Ready for Prod", category: "started", behavior: "qa_passed" },
|
|
155
|
+
{ id: "released", name: "Released", category: "completed", behavior: "released" },
|
|
156
|
+
{ id: "canceled", name: "Canceled", category: "canceled", behavior: "manual" },
|
|
157
|
+
{ id: "duplicate", name: "Duplicate", category: "canceled", behavior: "manual" }
|
|
158
|
+
];
|
|
159
|
+
const transitions = stages.slice(1, 9).map((stage, i) => ({
|
|
160
|
+
from: stages[i].id,
|
|
161
|
+
to: stage.id,
|
|
162
|
+
// Recheck the entire delivery path when a revision or staging deployment changes mid-flight.
|
|
163
|
+
requires: stages.slice(0, i + 2).flatMap((s) => deliveryEvidenceKindSchema.safeParse(s.behavior).success ? [s.behavior] : [])
|
|
164
|
+
}));
|
|
165
|
+
for (const stage of stages) {
|
|
166
|
+
for (const target of ["todo", "canceled", "duplicate"]) {
|
|
167
|
+
if (target !== stage.id && !transitions.some((t) => t.from === stage.id && t.to === target))
|
|
168
|
+
transitions.push({ from: stage.id, to: target, requires: [] });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return { revision: 0, stages, transitions, attentionColumn: true };
|
|
172
|
+
}
|
|
173
|
+
var trackerSourceSchema = z2.strictObject({ workspace: id, id, identifier: id, url: z2.string().url() });
|
|
174
|
+
var trackerPlanSchema = z2.strictObject({ id, name: z2.string().trim().min(1).max(200), description: text.default(""), source: trackerSourceSchema.optional() });
|
|
175
|
+
var trackerCommentSchema = z2.strictObject({ id, body: text, author: id, createdAt: z2.number(), sourceId: id.optional() });
|
|
176
|
+
var trackerEvidenceSchema = z2.strictObject({
|
|
177
|
+
id,
|
|
178
|
+
kind: deliveryEvidenceKindSchema,
|
|
179
|
+
revision: id,
|
|
180
|
+
reference: z2.string().min(1).max(2e3),
|
|
181
|
+
deploymentId: id.optional(),
|
|
182
|
+
runId: id.optional(),
|
|
183
|
+
createdAt: z2.number(),
|
|
184
|
+
author: id
|
|
185
|
+
});
|
|
186
|
+
var trackerIssueSchema = z2.strictObject({
|
|
187
|
+
id,
|
|
188
|
+
identifier: id,
|
|
189
|
+
title: z2.string().trim().min(1).max(500),
|
|
190
|
+
description: text,
|
|
191
|
+
stageId: id,
|
|
192
|
+
planId: id.nullable(),
|
|
193
|
+
parentId: id.nullable(),
|
|
194
|
+
assignee: id.nullable(),
|
|
195
|
+
priority: z2.number().int().min(0).max(4),
|
|
196
|
+
labels: z2.array(z2.string().max(100)).max(100),
|
|
197
|
+
blockedBy: z2.array(id).max(100),
|
|
198
|
+
externalBlockers: z2.array(z2.string().max(2e3)).max(100),
|
|
199
|
+
agentEligible: z2.boolean(),
|
|
200
|
+
automationHeld: z2.boolean(),
|
|
201
|
+
revision: id.nullable(),
|
|
202
|
+
attention: z2.strictObject({
|
|
203
|
+
id,
|
|
204
|
+
message: z2.string().trim().min(1).max(1e4),
|
|
205
|
+
runId: id.optional(),
|
|
206
|
+
origin: z2.enum(["manual", "run"]).default("manual")
|
|
207
|
+
}).nullable(),
|
|
208
|
+
threadId: id,
|
|
209
|
+
runIds: z2.array(id),
|
|
210
|
+
comments: z2.array(trackerCommentSchema),
|
|
211
|
+
evidence: z2.array(trackerEvidenceSchema),
|
|
212
|
+
history: z2.array(z2.strictObject({ at: z2.number(), actor: id, action: z2.string(), from: id.optional(), to: id.optional() })),
|
|
213
|
+
source: trackerSourceSchema.optional(),
|
|
214
|
+
sourceAssignee: z2.string().optional(),
|
|
215
|
+
createdAt: z2.number(),
|
|
216
|
+
updatedAt: z2.number(),
|
|
217
|
+
version: z2.number().int().nonnegative()
|
|
218
|
+
});
|
|
219
|
+
var trackerSnapshotSchema = z2.strictObject({
|
|
220
|
+
workflow: deliveryWorkflowSchema,
|
|
221
|
+
issues: z2.array(trackerIssueSchema),
|
|
222
|
+
plans: z2.array(trackerPlanSchema),
|
|
223
|
+
members: z2.array(id)
|
|
224
|
+
});
|
|
225
|
+
var issueFields = {
|
|
226
|
+
title: z2.string().trim().min(1).max(500),
|
|
227
|
+
description: text.default(""),
|
|
228
|
+
planId: id.nullable().default(null),
|
|
229
|
+
parentId: id.nullable().default(null),
|
|
230
|
+
assignee: id.nullable().default(null),
|
|
231
|
+
priority: z2.number().int().min(0).max(4).default(0),
|
|
232
|
+
labels: z2.array(z2.string().max(100)).max(100).default([]),
|
|
233
|
+
blockedBy: z2.array(id).max(100).default([]),
|
|
234
|
+
externalBlockers: z2.array(z2.string().max(2e3)).max(100).default([]),
|
|
235
|
+
agentEligible: z2.boolean().default(false),
|
|
236
|
+
revision: id.nullable().default(null)
|
|
237
|
+
};
|
|
238
|
+
var trackerImportSchema = z2.strictObject({
|
|
239
|
+
workspace: id,
|
|
240
|
+
teamId: id,
|
|
241
|
+
stages: z2.array(deliveryStageSchema).min(1).max(100),
|
|
242
|
+
stageMapping: z2.record(z2.string(), id),
|
|
243
|
+
adoptWorkflow: z2.boolean(),
|
|
244
|
+
plans: z2.array(z2.strictObject({ source: trackerSourceSchema, name: z2.string().min(1).max(200), description: text })).max(500),
|
|
245
|
+
issues: z2.array(z2.strictObject({
|
|
246
|
+
source: trackerSourceSchema,
|
|
247
|
+
title: issueFields.title,
|
|
248
|
+
description: text,
|
|
249
|
+
stageId: id,
|
|
250
|
+
planId: id.nullable(),
|
|
251
|
+
parentId: id.nullable(),
|
|
252
|
+
assignee: id.nullable(),
|
|
253
|
+
sourceAssignee: z2.string().optional(),
|
|
254
|
+
priority: issueFields.priority,
|
|
255
|
+
labels: issueFields.labels,
|
|
256
|
+
blockedBy: z2.array(id).max(100),
|
|
257
|
+
externalBlockers: z2.array(z2.string().max(2e3)).max(100).default([]),
|
|
258
|
+
comments: z2.array(trackerCommentSchema).max(1e3),
|
|
259
|
+
createdAt: z2.number()
|
|
260
|
+
})).max(2e3),
|
|
261
|
+
omissions: z2.array(z2.string().max(2e3)).max(500).default([])
|
|
262
|
+
});
|
|
263
|
+
var trackerOperationSchema = z2.discriminatedUnion("kind", [
|
|
264
|
+
z2.strictObject({ kind: z2.literal("tracker.sync") }),
|
|
265
|
+
z2.strictObject({ kind: z2.literal("issue.create"), id: id.max(147), stageId: id.optional(), ...issueFields }),
|
|
266
|
+
z2.strictObject({ kind: z2.literal("issue.update"), id, version: z2.number().int(), changes: trackerIssueSchema.pick({
|
|
267
|
+
title: true,
|
|
268
|
+
description: true,
|
|
269
|
+
planId: true,
|
|
270
|
+
parentId: true,
|
|
271
|
+
assignee: true,
|
|
272
|
+
priority: true,
|
|
273
|
+
labels: true,
|
|
274
|
+
blockedBy: true,
|
|
275
|
+
externalBlockers: true,
|
|
276
|
+
agentEligible: true,
|
|
277
|
+
revision: true
|
|
278
|
+
}).partial() }),
|
|
279
|
+
z2.strictObject({ kind: z2.literal("plan.save"), ...trackerPlanSchema.shape }),
|
|
280
|
+
z2.strictObject({ kind: z2.literal("workflow.save"), workflow: deliveryWorkflowSchema, replacements: z2.record(z2.string(), id).default({}) }),
|
|
281
|
+
z2.strictObject({ kind: z2.literal("issue.transition"), id, version: z2.number().int(), stageId: id }),
|
|
282
|
+
z2.strictObject({ kind: z2.literal("issue.attention"), id, version: z2.number().int(), message: z2.string().trim().min(1).max(1e4), runId: id.optional() }),
|
|
283
|
+
z2.strictObject({ kind: z2.literal("issue.resolve"), id, version: z2.number().int(), attentionId: id }),
|
|
284
|
+
z2.strictObject({ kind: z2.literal("issue.resume"), id, version: z2.number().int() }),
|
|
285
|
+
z2.strictObject({ kind: z2.literal("issue.revision"), id, version: z2.number().int(), revision: id, runId: id }),
|
|
286
|
+
z2.strictObject({ kind: z2.literal("issue.comment"), id, commentId: id, body: text }),
|
|
287
|
+
z2.strictObject({ kind: z2.literal("issue.evidence"), id, evidenceId: id, evidence: trackerEvidenceSchema.omit({ id: true, author: true, createdAt: true }) }),
|
|
288
|
+
z2.strictObject({ kind: z2.literal("import.preview"), input: trackerImportSchema }),
|
|
289
|
+
z2.strictObject({ kind: z2.literal("import.commit"), previewId: id })
|
|
290
|
+
]);
|
|
291
|
+
var trackerImportPreviewSchema = z2.strictObject({
|
|
292
|
+
previewId: id,
|
|
293
|
+
creates: z2.number().int(),
|
|
294
|
+
skips: z2.number().int(),
|
|
295
|
+
plans: z2.number().int(),
|
|
296
|
+
omissions: z2.array(z2.string())
|
|
297
|
+
});
|
|
298
|
+
|
|
113
299
|
// src/v2.ts
|
|
114
300
|
var protocolVersion = { major: 2, minor: 3 };
|
|
115
301
|
var conversationContinuationCapability = "conversation_continuation";
|
|
@@ -117,31 +303,32 @@ var abandonedConversationContinuationCapability = "abandoned_conversation_contin
|
|
|
117
303
|
var repositoryAccessCapability = "repository_checkout_v1";
|
|
118
304
|
var workflowInstallCapability = "workflow_install_v1";
|
|
119
305
|
var runDelegationCapability = "run_delegation_v1";
|
|
306
|
+
var orchestratorGuidanceCapability = "orchestrator_guidance_v1";
|
|
120
307
|
var runUsageCapability = "run_usage_v1";
|
|
121
308
|
var delegationTokenPrefix = "drisp_dlg_";
|
|
122
|
-
var runArtifactNameSchema =
|
|
309
|
+
var runArtifactNameSchema = z3.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
|
|
123
310
|
var runArtifactMaxBytes = 64 * 1024;
|
|
124
|
-
var secretEnvironmentSchema =
|
|
125
|
-
|
|
126
|
-
|
|
311
|
+
var secretEnvironmentSchema = z3.record(
|
|
312
|
+
z3.string().regex(/^(?:OPENAI_API_KEY|ANTHROPIC_API_KEY|CLAUDE_CODE_OAUTH_TOKEN|NPM_TOKEN|NODE_AUTH_TOKEN|PIP_INDEX_URL|PIP_EXTRA_INDEX_URL|UV_INDEX_URL|DRISP_TEST_[A-Z0-9_]+)$/),
|
|
313
|
+
z3.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
|
|
127
314
|
);
|
|
128
|
-
var permissionAnswerSchema =
|
|
129
|
-
kind:
|
|
130
|
-
decision:
|
|
131
|
-
reason:
|
|
315
|
+
var permissionAnswerSchema = z3.strictObject({
|
|
316
|
+
kind: z3.literal("permission"),
|
|
317
|
+
decision: z3.enum(["allow", "deny"]),
|
|
318
|
+
reason: z3.string().max(4096).optional()
|
|
132
319
|
});
|
|
133
|
-
var
|
|
134
|
-
var sequence =
|
|
320
|
+
var id2 = z3.string().min(1).max(160);
|
|
321
|
+
var sequence = z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
135
322
|
var positive = sequence.refine((n) => n > 0);
|
|
136
|
-
var timestamp =
|
|
137
|
-
var scopeSchema =
|
|
138
|
-
|
|
139
|
-
|
|
323
|
+
var timestamp = z3.iso.datetime();
|
|
324
|
+
var scopeSchema = z3.discriminatedUnion("visibility", [
|
|
325
|
+
z3.strictObject({ visibility: z3.literal("organization") }),
|
|
326
|
+
z3.strictObject({ visibility: z3.literal("private"), ownerUserId: id2 })
|
|
140
327
|
]);
|
|
141
|
-
var installedWorkflowsSchema =
|
|
142
|
-
var harnessSchema =
|
|
143
|
-
var harnessReadinessSchema =
|
|
144
|
-
var runnerReadinessSchema =
|
|
328
|
+
var installedWorkflowsSchema = z3.array(InstalledWorkflowSchema).max(256);
|
|
329
|
+
var harnessSchema = z3.enum(["claude-code", "codex"]);
|
|
330
|
+
var harnessReadinessSchema = z3.strictObject({ installed: z3.boolean(), signedIn: z3.boolean() });
|
|
331
|
+
var runnerReadinessSchema = z3.strictObject({
|
|
145
332
|
"claude-code": harnessReadinessSchema.optional(),
|
|
146
333
|
codex: harnessReadinessSchema.optional()
|
|
147
334
|
});
|
|
@@ -156,25 +343,27 @@ function readinessFixCommand(harness, readiness) {
|
|
|
156
343
|
return void 0;
|
|
157
344
|
}
|
|
158
345
|
var runnerUpdateCommand = "npm i -g @drisp/cli";
|
|
159
|
-
var interruptionSchema =
|
|
160
|
-
interruptionId:
|
|
346
|
+
var interruptionSchema = z3.strictObject({
|
|
347
|
+
interruptionId: id2,
|
|
161
348
|
revision: positive,
|
|
162
349
|
/** `waiting` (root ADR-0008) is non-human: a Run parked until one of its children closes or parks. */
|
|
163
|
-
kind:
|
|
164
|
-
message:
|
|
165
|
-
|
|
350
|
+
kind: z3.enum(["permission", "question", "guidance", "recovery", "waiting"]),
|
|
351
|
+
message: z3.string().max(16384),
|
|
352
|
+
/** Explicit technical question for a parent; absent always reserves the answer to a member. */
|
|
353
|
+
respondent: z3.enum(["orchestrator"]).optional(),
|
|
354
|
+
requestId: id2.optional()
|
|
166
355
|
});
|
|
167
|
-
var workflowIdentitySchema =
|
|
168
|
-
name:
|
|
169
|
-
version:
|
|
356
|
+
var workflowIdentitySchema = z3.strictObject({
|
|
357
|
+
name: z3.string().min(1).max(128),
|
|
358
|
+
version: z3.string().min(1).max(128).optional()
|
|
170
359
|
});
|
|
171
|
-
var buildCloseReasonSchema =
|
|
360
|
+
var buildCloseReasonSchema = z3.enum([
|
|
172
361
|
"workflow_template_mismatch",
|
|
173
362
|
"child_project_dir_invalid",
|
|
174
363
|
"build_not_approved",
|
|
175
364
|
"approval_question_missing"
|
|
176
365
|
]);
|
|
177
|
-
var runCloseReasonSchema =
|
|
366
|
+
var runCloseReasonSchema = z3.enum([
|
|
178
367
|
"execution_terminal",
|
|
179
368
|
"cancelled_before_start",
|
|
180
369
|
"admission_failed",
|
|
@@ -192,53 +381,53 @@ var runCloseReasonSchema = z2.enum([
|
|
|
192
381
|
...buildCloseReasonSchema.options
|
|
193
382
|
]);
|
|
194
383
|
var factIdentity = {
|
|
195
|
-
runId:
|
|
196
|
-
attemptId:
|
|
384
|
+
runId: id2,
|
|
385
|
+
attemptId: id2,
|
|
197
386
|
executionRevision: positive,
|
|
198
387
|
emittedAt: timestamp
|
|
199
388
|
};
|
|
200
|
-
var runUsageSchema =
|
|
389
|
+
var runUsageSchema = z3.strictObject({ counted: sequence, cacheRead: sequence });
|
|
201
390
|
var reportedUsage = { usage: runUsageSchema.optional() };
|
|
202
|
-
var controlRecordSchema =
|
|
391
|
+
var controlRecordSchema = z3.discriminatedUnion("kind", [
|
|
203
392
|
/** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
|
|
204
|
-
|
|
393
|
+
z3.strictObject({ kind: z3.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
|
|
205
394
|
/** Instance-scoped, not tied to a Run: the Runner's full Readiness, sent when it changes after hello. */
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
kind:
|
|
210
|
-
runId:
|
|
211
|
-
attemptId:
|
|
212
|
-
reason:
|
|
395
|
+
z3.strictObject({ kind: z3.literal("readiness.changed"), readiness: runnerReadinessSchema }),
|
|
396
|
+
z3.strictObject({ kind: z3.literal("assignment.accepted"), runId: id2, attemptId: id2 }),
|
|
397
|
+
z3.strictObject({
|
|
398
|
+
kind: z3.literal("assignment.rejected"),
|
|
399
|
+
runId: id2,
|
|
400
|
+
attemptId: id2,
|
|
401
|
+
reason: z3.string().max(1024)
|
|
213
402
|
}),
|
|
214
|
-
|
|
215
|
-
kind:
|
|
403
|
+
z3.strictObject({
|
|
404
|
+
kind: z3.literal("run.started"),
|
|
216
405
|
...factIdentity,
|
|
217
406
|
/** Absent from runners that predate Workflow reporting. */
|
|
218
407
|
workflow: workflowIdentitySchema.optional()
|
|
219
408
|
}),
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
kind:
|
|
409
|
+
z3.strictObject({ kind: z3.literal("run.resumed"), ...factIdentity }),
|
|
410
|
+
z3.strictObject({
|
|
411
|
+
kind: z3.literal("run.attention"),
|
|
223
412
|
...factIdentity,
|
|
224
413
|
interruption: interruptionSchema,
|
|
225
|
-
occupancy:
|
|
414
|
+
occupancy: z3.enum(["held", "released"]),
|
|
226
415
|
historyThrough: sequence,
|
|
227
|
-
continuation:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
416
|
+
continuation: z3.discriminatedUnion("kind", [
|
|
417
|
+
z3.strictObject({ kind: z3.literal("live_request") }),
|
|
418
|
+
z3.strictObject({ kind: z3.literal("local_checkpoint"), checkpointId: id2 }),
|
|
419
|
+
z3.strictObject({ kind: z3.literal("portable_checkpoint"), checkpointId: id2 }),
|
|
420
|
+
z3.strictObject({ kind: z3.literal("repair_required"), detail: z3.string().max(4096) })
|
|
232
421
|
]),
|
|
233
422
|
...reportedUsage
|
|
234
423
|
}),
|
|
235
|
-
|
|
236
|
-
kind:
|
|
424
|
+
z3.strictObject({
|
|
425
|
+
kind: z3.literal("run.finished"),
|
|
237
426
|
...factIdentity,
|
|
238
|
-
status:
|
|
427
|
+
status: z3.enum(["completed", "failed", "cancelled"]),
|
|
239
428
|
historyThrough: sequence,
|
|
240
429
|
/** No setup/harness executed and no workspace was produced; safe to retire without export. */
|
|
241
|
-
workspaceUnavailable:
|
|
430
|
+
workspaceUnavailable: z3.literal(true).optional(),
|
|
242
431
|
/**
|
|
243
432
|
* Why a Build Run failed, as its close reason (docs/specs/build-orchestrator.md). Sent only for a grant with
|
|
244
433
|
* `parent` or `delegationToken`, which only a Hub that knows this field issues.
|
|
@@ -250,92 +439,93 @@ var controlRecordSchema = z2.discriminatedUnion("kind", [
|
|
|
250
439
|
* The usage of a Run while it executes, for a grant marked `reportUsage`. Not an execution fact: it carries no
|
|
251
440
|
* execution revision, so it never advances, parks or closes the Run, and never wakes its parent.
|
|
252
441
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
kind:
|
|
257
|
-
runId:
|
|
258
|
-
attemptId:
|
|
259
|
-
commandId:
|
|
260
|
-
reason:
|
|
442
|
+
z3.strictObject({ kind: z3.literal("run.usage"), runId: id2, attemptId: id2, ...runUsageSchema.shape }),
|
|
443
|
+
z3.strictObject({ kind: z3.literal("command.applied"), runId: id2, attemptId: id2, commandId: id2 }),
|
|
444
|
+
z3.strictObject({
|
|
445
|
+
kind: z3.literal("command.rejected"),
|
|
446
|
+
runId: id2,
|
|
447
|
+
attemptId: id2,
|
|
448
|
+
commandId: id2,
|
|
449
|
+
reason: z3.string().max(1024)
|
|
261
450
|
}),
|
|
262
|
-
|
|
451
|
+
z3.strictObject({ kind: z3.literal("revoked_not_started"), runId: id2, attemptId: id2 })
|
|
263
452
|
]);
|
|
264
|
-
var repositoryRefSchema =
|
|
453
|
+
var repositoryRefSchema = z3.string().min(1).max(512).regex(
|
|
265
454
|
/^(?![-/])(?!.*\.\.)(?!.*@\{)(?!.*(?:^|\/)\.)(?!.*\.lock(?:\/|$))(?!.*\/\/)[^\x00-\x20\x7f~^:?*\[\\]+(?<![/.])$/
|
|
266
455
|
);
|
|
267
|
-
var repositoryWorkingDirectorySchema =
|
|
456
|
+
var repositoryWorkingDirectorySchema = z3.string().min(1).max(1024).regex(
|
|
268
457
|
/^(?:\.|(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))[^\x00-\x1f\x7f\\:]+(?<!\/))$/
|
|
269
458
|
);
|
|
270
459
|
var repositoryIdentity = {
|
|
271
|
-
repositoryId:
|
|
272
|
-
installationId:
|
|
273
|
-
owner:
|
|
274
|
-
name:
|
|
460
|
+
repositoryId: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
461
|
+
installationId: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
462
|
+
owner: z3.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
|
|
463
|
+
name: z3.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
|
|
275
464
|
};
|
|
276
|
-
var repositoryBindingSchema =
|
|
277
|
-
id,
|
|
278
|
-
label:
|
|
465
|
+
var repositoryBindingSchema = z3.strictObject({
|
|
466
|
+
id: id2,
|
|
467
|
+
label: z3.string().min(1).max(160),
|
|
279
468
|
...repositoryIdentity,
|
|
280
469
|
defaultRef: repositoryRefSchema,
|
|
281
470
|
workingDirectory: repositoryWorkingDirectorySchema,
|
|
282
|
-
setupCommands:
|
|
471
|
+
setupCommands: z3.array(z3.string().min(1).max(8192)).max(16),
|
|
283
472
|
revision: positive,
|
|
284
|
-
enabled:
|
|
473
|
+
enabled: z3.boolean()
|
|
285
474
|
});
|
|
286
|
-
var repositorySourceSchema =
|
|
287
|
-
bindingId:
|
|
475
|
+
var repositorySourceSchema = z3.strictObject({
|
|
476
|
+
bindingId: id2,
|
|
288
477
|
...repositoryIdentity,
|
|
289
478
|
ref: repositoryRefSchema,
|
|
290
|
-
commitSha:
|
|
479
|
+
commitSha: z3.string().regex(/^[0-9a-f]{40}$/),
|
|
291
480
|
branch: repositoryRefSchema,
|
|
292
481
|
workingDirectory: repositoryWorkingDirectorySchema,
|
|
293
|
-
setupCommands:
|
|
482
|
+
setupCommands: z3.array(z3.string().min(1).max(8192)).max(16),
|
|
294
483
|
configRevision: positive
|
|
295
484
|
});
|
|
296
|
-
var workflowSourceSchema =
|
|
297
|
-
var workflowReferenceSchema =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
name:
|
|
485
|
+
var workflowSourceSchema = z3.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
|
|
486
|
+
var workflowReferenceSchema = z3.union([
|
|
487
|
+
z3.string().max(512),
|
|
488
|
+
z3.strictObject({
|
|
489
|
+
name: z3.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
|
|
301
490
|
source: workflowSourceSchema.optional(),
|
|
302
|
-
ref:
|
|
303
|
-
version:
|
|
491
|
+
ref: z3.string().min(1).max(512).optional(),
|
|
492
|
+
version: z3.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
|
|
304
493
|
})
|
|
305
494
|
]);
|
|
306
495
|
var workflowName = (workflow) => typeof workflow === "object" ? workflow.name : workflow;
|
|
307
496
|
var installReference = (workflow) => typeof workflow === "object" && workflow.source !== void 0 ? workflow : void 0;
|
|
308
497
|
var sameWorkflow = (a, b) => canonicalJson(a ?? null) === canonicalJson(b ?? null);
|
|
309
|
-
var runSpecSchema =
|
|
310
|
-
prompt:
|
|
311
|
-
projectDir:
|
|
498
|
+
var runSpecSchema = z3.strictObject({
|
|
499
|
+
prompt: z3.string().min(1).max(131072),
|
|
500
|
+
projectDir: z3.string().min(1).max(4096),
|
|
312
501
|
harness: harnessSchema,
|
|
313
502
|
workflow: workflowReferenceSchema.optional(),
|
|
314
503
|
repository: repositorySourceSchema.optional()
|
|
315
504
|
});
|
|
316
|
-
var runKeySchema =
|
|
317
|
-
var delegationSchema =
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
var
|
|
323
|
-
var
|
|
324
|
-
var
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
505
|
+
var runKeySchema = z3.string().min(1).max(160);
|
|
506
|
+
var delegationSchema = z3.strictObject({
|
|
507
|
+
// Omitted: follow the Runner capacity. An explicit value is a per-Build ceiling.
|
|
508
|
+
maxChildren: z3.number().int().min(1).max(64).optional(),
|
|
509
|
+
tokenBudget: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER)
|
|
510
|
+
});
|
|
511
|
+
var tokenCapSchema = z3.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
512
|
+
var runParentIntentSchema = z3.strictObject({ runId: id2, tokenCap: tokenCapSchema.optional() });
|
|
513
|
+
var runParentSchema = z3.strictObject({ runId: id2, tokenCap: tokenCapSchema });
|
|
514
|
+
var commandSchema = z3.strictObject({
|
|
515
|
+
commandId: id2,
|
|
516
|
+
hubEpoch: id2,
|
|
517
|
+
runId: id2,
|
|
328
518
|
expectedRecordRevision: sequence.optional(),
|
|
329
|
-
intent:
|
|
330
|
-
|
|
331
|
-
kind:
|
|
332
|
-
sessionId:
|
|
519
|
+
intent: z3.discriminatedUnion("kind", [
|
|
520
|
+
z3.strictObject({
|
|
521
|
+
kind: z3.literal("start"),
|
|
522
|
+
sessionId: id2,
|
|
333
523
|
/**
|
|
334
524
|
* Absent: the Hub resolves the Runner member-first (root ADR-0005): the Session's conversation Runner, else
|
|
335
525
|
* the starting member's own ready Personal Runner, else the Team default, else the start is refused.
|
|
336
526
|
*/
|
|
337
|
-
runnerId:
|
|
338
|
-
computeProfileId:
|
|
527
|
+
runnerId: id2.optional(),
|
|
528
|
+
computeProfileId: id2.optional(),
|
|
339
529
|
scope: scopeSchema,
|
|
340
530
|
spec: runSpecSchema,
|
|
341
531
|
key: runKeySchema.optional(),
|
|
@@ -344,160 +534,167 @@ var commandSchema = z2.strictObject({
|
|
|
344
534
|
/** Delegated starts only, and required on them. */
|
|
345
535
|
parent: runParentIntentSchema.optional()
|
|
346
536
|
}),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
kind:
|
|
352
|
-
interruptionId:
|
|
537
|
+
z3.strictObject({ kind: z3.literal("cancel") }),
|
|
538
|
+
z3.strictObject({ kind: z3.literal("abandon") }),
|
|
539
|
+
z3.strictObject({ kind: z3.literal("steer"), text: z3.string().min(1).max(131072) }),
|
|
540
|
+
z3.strictObject({
|
|
541
|
+
kind: z3.literal("answer"),
|
|
542
|
+
interruptionId: id2,
|
|
353
543
|
expectedInterruptionRevision: positive,
|
|
354
|
-
requestId:
|
|
355
|
-
answer:
|
|
544
|
+
requestId: id2.optional(),
|
|
545
|
+
answer: z3.json()
|
|
356
546
|
}),
|
|
357
|
-
|
|
358
|
-
kind:
|
|
359
|
-
interruptionId:
|
|
360
|
-
guidance:
|
|
547
|
+
z3.strictObject({
|
|
548
|
+
kind: z3.literal("resume"),
|
|
549
|
+
interruptionId: id2,
|
|
550
|
+
guidance: z3.string().max(131072).optional()
|
|
361
551
|
}),
|
|
362
552
|
/**
|
|
363
553
|
* A member rewrites an Orchestrator's `delegation.tokenBudget` (root ADR-0011), never below what its children
|
|
364
554
|
* used. With `resume`, a parked Orchestrator with no live child is resumed when the value is strictly greater.
|
|
365
555
|
* Hub-only: never delivered to a Runner.
|
|
366
556
|
*/
|
|
367
|
-
|
|
368
|
-
kind:
|
|
557
|
+
z3.strictObject({
|
|
558
|
+
kind: z3.literal("setBudget"),
|
|
369
559
|
tokenBudget: delegationSchema.shape.tokenBudget,
|
|
370
|
-
resume:
|
|
560
|
+
resume: z3.boolean().optional()
|
|
371
561
|
})
|
|
372
562
|
])
|
|
373
563
|
});
|
|
374
|
-
var
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
564
|
+
var deliveredCommandSchema = commandSchema.extend({ orchestratorRunId: id2.optional() });
|
|
565
|
+
var grantSchema = z3.strictObject({
|
|
566
|
+
commandId: id2,
|
|
567
|
+
hubEpoch: id2,
|
|
568
|
+
runId: id2,
|
|
569
|
+
sessionId: id2,
|
|
570
|
+
runnerId: id2,
|
|
571
|
+
installationId: id2,
|
|
572
|
+
attemptId: id2,
|
|
382
573
|
generation: positive,
|
|
383
574
|
baseExecutionRevision: sequence,
|
|
384
575
|
baseHistorySeq: sequence,
|
|
385
576
|
cloudHistoryThrough: sequence,
|
|
386
|
-
purpose:
|
|
577
|
+
purpose: z3.enum(["start", "resume"]),
|
|
387
578
|
spec: runSpecSchema,
|
|
388
|
-
continuation:
|
|
579
|
+
continuation: z3.json().optional(),
|
|
580
|
+
/** Authenticated source of a delegated continuation; absence retains member semantics. */
|
|
581
|
+
orchestratorRunId: id2.optional(),
|
|
389
582
|
/** A new Run in a durable conversation; never resumes the predecessor's lifecycle. */
|
|
390
|
-
previousRun:
|
|
391
|
-
runId:
|
|
583
|
+
previousRun: z3.strictObject({
|
|
584
|
+
runId: id2,
|
|
392
585
|
executionRevision: sequence,
|
|
393
586
|
historyProduced: sequence,
|
|
394
587
|
/** Hub-confirmed administrative closure; allows an exact parked predecessor snapshot. */
|
|
395
|
-
closeReason:
|
|
396
|
-
checkpoint:
|
|
588
|
+
closeReason: z3.literal("abandoned").optional(),
|
|
589
|
+
checkpoint: z3.strictObject({ checkpointId: id2, checksum: z3.string().regex(/^[a-f0-9]{64}$/) }).optional()
|
|
397
590
|
}).optional(),
|
|
398
|
-
checkpoint:
|
|
591
|
+
checkpoint: z3.strictObject({ checkpointId: id2, checksum: z3.string().regex(/^[a-f0-9]{64}$/) }).optional(),
|
|
399
592
|
/** This attempt's delegation token: only for a Run started with `delegation`, only to a `run_delegation_v1` Runner. */
|
|
400
|
-
delegationToken:
|
|
593
|
+
delegationToken: z3.string().min(32).max(256).optional(),
|
|
401
594
|
/** Copied from the start intent of a delegated child. */
|
|
402
595
|
parent: runParentSchema.optional(),
|
|
403
596
|
/** The runner reports this attempt's usage: set only for a `run_usage_v1` Runner. */
|
|
404
|
-
reportUsage:
|
|
597
|
+
reportUsage: z3.literal(true).optional()
|
|
405
598
|
});
|
|
406
|
-
var historyRecordSchema =
|
|
407
|
-
eventId:
|
|
408
|
-
attemptId:
|
|
599
|
+
var historyRecordSchema = z3.strictObject({
|
|
600
|
+
eventId: id2,
|
|
601
|
+
attemptId: id2,
|
|
409
602
|
emittedAt: timestamp,
|
|
410
|
-
kind:
|
|
411
|
-
data:
|
|
412
|
-
});
|
|
413
|
-
var runnerFrameSchema =
|
|
414
|
-
|
|
415
|
-
type:
|
|
416
|
-
role:
|
|
417
|
-
protocol:
|
|
418
|
-
runnerId:
|
|
419
|
-
installationId:
|
|
420
|
-
softwareVersion:
|
|
421
|
-
capabilities:
|
|
603
|
+
kind: z3.string().min(1).max(128),
|
|
604
|
+
data: z3.json()
|
|
605
|
+
});
|
|
606
|
+
var runnerFrameSchema = z3.discriminatedUnion("type", [
|
|
607
|
+
z3.strictObject({
|
|
608
|
+
type: z3.literal("hello"),
|
|
609
|
+
role: z3.literal("runner"),
|
|
610
|
+
protocol: z3.strictObject({ major: z3.literal(2), minor: sequence }),
|
|
611
|
+
runnerId: id2,
|
|
612
|
+
installationId: id2,
|
|
613
|
+
softwareVersion: z3.string().max(128),
|
|
614
|
+
capabilities: z3.array(z3.string().max(128)).max(64),
|
|
422
615
|
/** Absent from older runners: the Hub treats the inventory as unknown, never as empty. */
|
|
423
616
|
workflows: installedWorkflowsSchema.optional(),
|
|
424
617
|
/** Absent from older runners, and from a runner that has not finished its first check: unknown, not "not ready". */
|
|
425
618
|
readiness: runnerReadinessSchema.optional(),
|
|
426
|
-
control:
|
|
619
|
+
control: z3.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
|
|
427
620
|
}),
|
|
428
|
-
|
|
429
|
-
type:
|
|
621
|
+
z3.strictObject({
|
|
622
|
+
type: z3.literal("control.batch"),
|
|
430
623
|
firstSeq: positive,
|
|
431
|
-
records:
|
|
624
|
+
records: z3.array(controlRecordSchema).min(1).max(128)
|
|
432
625
|
}),
|
|
433
|
-
|
|
434
|
-
type:
|
|
435
|
-
runId:
|
|
626
|
+
z3.strictObject({
|
|
627
|
+
type: z3.literal("history.batch"),
|
|
628
|
+
runId: id2,
|
|
436
629
|
firstSeq: positive,
|
|
437
|
-
records:
|
|
630
|
+
records: z3.array(historyRecordSchema).min(1).max(128)
|
|
438
631
|
}),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
type:
|
|
442
|
-
inventoryId:
|
|
632
|
+
z3.strictObject({ type: z3.literal("ping"), nonce: id2 }),
|
|
633
|
+
z3.strictObject({
|
|
634
|
+
type: z3.literal("reconcile.page"),
|
|
635
|
+
inventoryId: id2.default("single-page"),
|
|
443
636
|
page: sequence.default(0),
|
|
444
|
-
complete:
|
|
445
|
-
runs:
|
|
446
|
-
|
|
447
|
-
runId:
|
|
448
|
-
attemptId:
|
|
637
|
+
complete: z3.boolean(),
|
|
638
|
+
runs: z3.array(
|
|
639
|
+
z3.strictObject({
|
|
640
|
+
runId: id2,
|
|
641
|
+
attemptId: id2,
|
|
449
642
|
executionRevision: sequence,
|
|
450
|
-
phase:
|
|
643
|
+
phase: z3.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
|
|
451
644
|
})
|
|
452
645
|
).max(128)
|
|
453
646
|
})
|
|
454
647
|
]);
|
|
455
|
-
var runViewSchema =
|
|
456
|
-
runId:
|
|
457
|
-
sessionId:
|
|
458
|
-
runnerId:
|
|
459
|
-
computeProfileId:
|
|
648
|
+
var runViewSchema = z3.object({
|
|
649
|
+
runId: id2,
|
|
650
|
+
sessionId: id2,
|
|
651
|
+
runnerId: id2,
|
|
652
|
+
computeProfileId: id2.optional(),
|
|
460
653
|
scope: scopeSchema,
|
|
461
654
|
recordRevision: positive,
|
|
462
|
-
label:
|
|
655
|
+
label: z3.string().max(160).optional(),
|
|
463
656
|
key: runKeySchema.optional(),
|
|
464
657
|
parent: runParentSchema.optional(),
|
|
465
658
|
/**
|
|
466
659
|
* Not strict, unlike the start intent's: a Hub keeps more on the Run's delegation (`initialTokenBudget`) than it
|
|
467
660
|
* shows, and a client never refuses a view for a field it does not read.
|
|
468
661
|
*/
|
|
469
|
-
delegation:
|
|
662
|
+
delegation: z3.object({
|
|
663
|
+
...delegationSchema.shape,
|
|
664
|
+
// A resolved Runner default may exceed the explicit settings ceiling on configured Runners.
|
|
665
|
+
maxChildren: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
666
|
+
}).optional(),
|
|
470
667
|
/** The largest cumulative usage the Run's Runner reported; absent until one does (an older Runner never does). */
|
|
471
668
|
usage: runUsageSchema.optional(),
|
|
472
669
|
/** Resolved by the runner at start; absent until the Run starts and for runners that predate reporting. */
|
|
473
670
|
workflow: workflowIdentitySchema.optional(),
|
|
474
|
-
execution:
|
|
475
|
-
status:
|
|
671
|
+
execution: z3.object({
|
|
672
|
+
status: z3.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
|
|
476
673
|
revision: positive,
|
|
477
|
-
attemptId:
|
|
478
|
-
occupancy:
|
|
674
|
+
attemptId: id2,
|
|
675
|
+
occupancy: z3.enum(["held", "released"]),
|
|
479
676
|
startedAt: timestamp.optional(),
|
|
480
677
|
endedAt: timestamp.optional(),
|
|
481
678
|
interruption: interruptionSchema.optional()
|
|
482
679
|
}).nullable(),
|
|
483
|
-
scheduling:
|
|
484
|
-
closed:
|
|
485
|
-
closeReason:
|
|
486
|
-
cancellation:
|
|
680
|
+
scheduling: z3.enum(["queued", "dispatching", "admitted", "idle"]),
|
|
681
|
+
closed: z3.boolean(),
|
|
682
|
+
closeReason: z3.string().optional(),
|
|
683
|
+
cancellation: id2.optional(),
|
|
487
684
|
pendingResume: commandSchema.shape.intent.optional(),
|
|
488
685
|
/** Derived per viewer; absent on older Hubs. Never grants execution authority. */
|
|
489
|
-
runnerStopped:
|
|
490
|
-
canAbandon:
|
|
686
|
+
runnerStopped: z3.boolean().optional(),
|
|
687
|
+
canAbandon: z3.boolean().optional(),
|
|
491
688
|
historyThrough: sequence,
|
|
492
689
|
expectedHistoryThrough: sequence.optional(),
|
|
493
690
|
createdAt: sequence,
|
|
494
|
-
checkpoint:
|
|
691
|
+
checkpoint: z3.object({ id: id2, state: z3.enum(["pending", "ready"]), checksum: z3.string().optional() }).optional()
|
|
495
692
|
});
|
|
496
|
-
var clientFrameSchema =
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
693
|
+
var clientFrameSchema = z3.discriminatedUnion("type", [
|
|
694
|
+
z3.strictObject({ type: z3.literal("watch"), hubEpoch: id2, runIds: z3.array(id2).max(100) }),
|
|
695
|
+
z3.strictObject({ type: z3.literal("watch.ack"), subscriptionId: id2, through: sequence }),
|
|
696
|
+
z3.strictObject({ type: z3.literal("command.submit"), command: commandSchema }),
|
|
697
|
+
z3.strictObject({ type: z3.literal("ping"), nonce: id2 })
|
|
501
698
|
]);
|
|
502
699
|
function canonicalJson(value) {
|
|
503
700
|
if (value === null || typeof value !== "object") {
|
|
@@ -508,76 +705,76 @@ function canonicalJson(value) {
|
|
|
508
705
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
509
706
|
return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
|
|
510
707
|
}
|
|
511
|
-
var checkpointPathSchema =
|
|
708
|
+
var checkpointPathSchema = z3.string().min(1).max(4096).refine(
|
|
512
709
|
(path) => !path.startsWith("/") && !path.includes("\\") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".." && part !== ".git")
|
|
513
710
|
);
|
|
514
|
-
var checkpointSchema =
|
|
515
|
-
version:
|
|
516
|
-
checkpointId:
|
|
517
|
-
orgId:
|
|
518
|
-
phase:
|
|
519
|
-
runId:
|
|
520
|
-
sessionId:
|
|
521
|
-
sourceAttemptId:
|
|
522
|
-
executionRevision:
|
|
523
|
-
historyProduced:
|
|
524
|
-
historyAck:
|
|
711
|
+
var checkpointSchema = z3.strictObject({
|
|
712
|
+
version: z3.literal(1),
|
|
713
|
+
checkpointId: z3.string().min(1),
|
|
714
|
+
orgId: z3.string().min(1),
|
|
715
|
+
phase: z3.enum(["parked", "terminal"]),
|
|
716
|
+
runId: z3.string().min(1),
|
|
717
|
+
sessionId: z3.string().min(1),
|
|
718
|
+
sourceAttemptId: z3.string().min(1),
|
|
719
|
+
executionRevision: z3.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
720
|
+
historyProduced: z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
721
|
+
historyAck: z3.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
525
722
|
grant: grantSchema,
|
|
526
|
-
gitHead:
|
|
527
|
-
gitBase:
|
|
528
|
-
gitBundle:
|
|
529
|
-
indexPatch:
|
|
530
|
-
files:
|
|
531
|
-
|
|
723
|
+
gitHead: z3.string().regex(/^[0-9a-f]{40,64}$/),
|
|
724
|
+
gitBase: z3.string().regex(/^[0-9a-f]{40,64}$/).optional(),
|
|
725
|
+
gitBundle: z3.string(),
|
|
726
|
+
indexPatch: z3.string(),
|
|
727
|
+
files: z3.array(
|
|
728
|
+
z3.strictObject({ path: checkpointPathSchema, content: z3.string(), executable: z3.boolean() })
|
|
532
729
|
).max(1e5),
|
|
533
|
-
deleted:
|
|
534
|
-
sessionRows:
|
|
535
|
-
history:
|
|
536
|
-
|
|
730
|
+
deleted: z3.array(checkpointPathSchema).max(1e5),
|
|
731
|
+
sessionRows: z3.array(z3.strictObject({ kind: z3.string(), id: z3.string(), payload: z3.string() })),
|
|
732
|
+
history: z3.array(
|
|
733
|
+
z3.strictObject({ seq: z3.number().int().positive(), record: historyRecordSchema })
|
|
537
734
|
)
|
|
538
735
|
});
|
|
539
736
|
var connectCodeAlphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
540
|
-
var connectCodeSchema =
|
|
541
|
-
var connectCodeRequestSchema =
|
|
542
|
-
var connectCodeResponseSchema =
|
|
737
|
+
var connectCodeSchema = z3.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
|
|
738
|
+
var connectCodeRequestSchema = z3.strictObject({ hubEpoch: z3.string() });
|
|
739
|
+
var connectCodeResponseSchema = z3.strictObject({
|
|
543
740
|
code: connectCodeSchema,
|
|
544
741
|
expiresAt: sequence
|
|
545
742
|
});
|
|
546
|
-
var connectRedeemRequestSchema =
|
|
547
|
-
code:
|
|
548
|
-
installationId:
|
|
549
|
-
hostname:
|
|
550
|
-
os:
|
|
551
|
-
softwareVersion:
|
|
552
|
-
});
|
|
553
|
-
var connectRedeemResponseSchema =
|
|
554
|
-
orgId:
|
|
555
|
-
hubEpoch:
|
|
556
|
-
runnerId:
|
|
557
|
-
installationId:
|
|
558
|
-
name:
|
|
559
|
-
token:
|
|
560
|
-
credentialId:
|
|
743
|
+
var connectRedeemRequestSchema = z3.strictObject({
|
|
744
|
+
code: z3.string().min(8).max(16),
|
|
745
|
+
installationId: id2,
|
|
746
|
+
hostname: z3.string().min(1).max(255),
|
|
747
|
+
os: z3.string().min(1).max(64),
|
|
748
|
+
softwareVersion: z3.string().min(1).max(128)
|
|
749
|
+
});
|
|
750
|
+
var connectRedeemResponseSchema = z3.strictObject({
|
|
751
|
+
orgId: id2,
|
|
752
|
+
hubEpoch: z3.string(),
|
|
753
|
+
runnerId: id2,
|
|
754
|
+
installationId: id2,
|
|
755
|
+
name: z3.string(),
|
|
756
|
+
token: z3.string().min(32),
|
|
757
|
+
credentialId: id2,
|
|
561
758
|
expiresAt: sequence
|
|
562
759
|
});
|
|
563
|
-
var connectAlreadyConnectedSchema =
|
|
564
|
-
error:
|
|
565
|
-
orgId:
|
|
566
|
-
runnerId:
|
|
567
|
-
name:
|
|
760
|
+
var connectAlreadyConnectedSchema = z3.strictObject({
|
|
761
|
+
error: z3.literal("runner_already_connected"),
|
|
762
|
+
orgId: id2,
|
|
763
|
+
runnerId: id2,
|
|
764
|
+
name: z3.string()
|
|
568
765
|
});
|
|
569
|
-
var audienceSchema =
|
|
570
|
-
var runnerListEntrySchema =
|
|
571
|
-
id,
|
|
572
|
-
online:
|
|
573
|
-
capacity:
|
|
574
|
-
managed:
|
|
575
|
-
draining:
|
|
576
|
-
stopped:
|
|
577
|
-
name:
|
|
578
|
-
connectedBy:
|
|
766
|
+
var audienceSchema = z3.enum(["personal", "team"]);
|
|
767
|
+
var runnerListEntrySchema = z3.object({
|
|
768
|
+
id: id2,
|
|
769
|
+
online: z3.number(),
|
|
770
|
+
capacity: z3.number(),
|
|
771
|
+
managed: z3.number(),
|
|
772
|
+
draining: z3.number(),
|
|
773
|
+
stopped: z3.number(),
|
|
774
|
+
name: z3.string().nullable(),
|
|
775
|
+
connectedBy: z3.string().nullable(),
|
|
579
776
|
audience: audienceSchema.nullable(),
|
|
580
|
-
softwareVersion:
|
|
777
|
+
softwareVersion: z3.string().nullable(),
|
|
581
778
|
/** Milliseconds since the epoch of the last hello or disconnect; null before the first connection. */
|
|
582
779
|
lastSeen: sequence.nullable(),
|
|
583
780
|
/** Absent when the runner has not reported an inventory: unknown, not none. */
|
|
@@ -587,108 +784,108 @@ var runnerListEntrySchema = z2.object({
|
|
|
587
784
|
* Runner seen by an admin (who may still Disconnect it), or a Runner a member did not connect. Absent from Hubs
|
|
588
785
|
* older than Audience, like the list's `viewer`, `teamDefault` and `runsGoTo`.
|
|
589
786
|
*/
|
|
590
|
-
readOnly:
|
|
787
|
+
readOnly: z3.boolean().optional(),
|
|
591
788
|
/** What the Runner last reported; absent when it never has (an older runner, or one not yet connected). */
|
|
592
789
|
readiness: runnerReadinessSchema.optional(),
|
|
593
790
|
/**
|
|
594
791
|
* True when the Runner reported a version below the Hub's minimum: it is listed as "Update required" and takes no
|
|
595
792
|
* Runs until it is updated (`runnerUpdateCommand`). Absent from Hubs older than Readiness.
|
|
596
793
|
*/
|
|
597
|
-
updateRequired:
|
|
794
|
+
updateRequired: z3.boolean().optional(),
|
|
598
795
|
/**
|
|
599
796
|
* True while it is paused as "Needs an owner": the member who connected this Team Runner left the Team, so it
|
|
600
797
|
* takes no Runs until an admin adopts it (`/runners/{id}/adopt`) or Disconnects it. Absent from older Hubs.
|
|
601
798
|
*/
|
|
602
|
-
needsOwner:
|
|
799
|
+
needsOwner: z3.boolean().optional()
|
|
603
800
|
});
|
|
604
|
-
var teamDefaultSchema =
|
|
605
|
-
|
|
606
|
-
|
|
801
|
+
var teamDefaultSchema = z3.discriminatedUnion("kind", [
|
|
802
|
+
z3.strictObject({ kind: z3.literal("runner"), runnerId: id2 }),
|
|
803
|
+
z3.strictObject({ kind: z3.literal("profile"), profileId: id2 })
|
|
607
804
|
]);
|
|
608
|
-
var teamDefaultRequestSchema =
|
|
609
|
-
hubEpoch:
|
|
805
|
+
var teamDefaultRequestSchema = z3.strictObject({
|
|
806
|
+
hubEpoch: z3.string(),
|
|
610
807
|
teamDefault: teamDefaultSchema.nullable()
|
|
611
808
|
});
|
|
612
|
-
var runnerUpdateRequestSchema =
|
|
613
|
-
hubEpoch:
|
|
614
|
-
name:
|
|
615
|
-
capacity:
|
|
809
|
+
var runnerUpdateRequestSchema = z3.strictObject({
|
|
810
|
+
hubEpoch: z3.string(),
|
|
811
|
+
name: z3.string().max(100).optional(),
|
|
812
|
+
capacity: z3.number().int().min(1).max(64).optional(),
|
|
616
813
|
audience: audienceSchema.optional()
|
|
617
814
|
}).refine(
|
|
618
815
|
(update) => update.name !== void 0 || update.capacity !== void 0 || update.audience !== void 0,
|
|
619
816
|
{ message: "nothing to update" }
|
|
620
817
|
);
|
|
621
|
-
var runsGoToSchema =
|
|
818
|
+
var runsGoToSchema = z3.union([
|
|
622
819
|
/** The viewer's own Runner: Personal, or one they connected that was widened to Team (DRI-42). */
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
820
|
+
z3.strictObject({ via: z3.literal("personal"), runnerId: id2 }),
|
|
821
|
+
z3.strictObject({ via: z3.literal("team_default"), runnerId: id2 }),
|
|
822
|
+
z3.strictObject({ via: z3.literal("team_default"), profileId: id2 }),
|
|
626
823
|
/** `runner_needs_owner`: the Team default is a Runner paused because the member who connected it left. */
|
|
627
|
-
|
|
824
|
+
z3.strictObject({ via: z3.literal("none"), reason: z3.enum(["no_runner_available", "runner_needs_owner"]) })
|
|
628
825
|
]);
|
|
629
|
-
var runnerListSchema =
|
|
630
|
-
capabilities:
|
|
631
|
-
historyRetentionDays:
|
|
826
|
+
var runnerListSchema = z3.object({
|
|
827
|
+
capabilities: z3.record(z3.string(), z3.boolean()).optional(),
|
|
828
|
+
historyRetentionDays: z3.number().int().positive().nullable().optional(),
|
|
632
829
|
/** Who the list was filtered for: a member sees their own and Team Runners, an admin every Runner. */
|
|
633
|
-
viewer:
|
|
830
|
+
viewer: z3.object({ userId: z3.string(), admin: z3.boolean() }).optional(),
|
|
634
831
|
teamDefault: teamDefaultSchema.nullable().optional(),
|
|
635
832
|
runsGoTo: runsGoToSchema.optional(),
|
|
636
833
|
/** The lowest Runner version this Hub sends Runs to. Absent from Hubs older than Readiness. */
|
|
637
|
-
minimumRunnerVersion:
|
|
638
|
-
runners:
|
|
639
|
-
profiles:
|
|
640
|
-
id:
|
|
641
|
-
label:
|
|
642
|
-
projectDir:
|
|
643
|
-
repositoryRequired:
|
|
834
|
+
minimumRunnerVersion: z3.string().optional(),
|
|
835
|
+
runners: z3.array(runnerListEntrySchema),
|
|
836
|
+
profiles: z3.array(z3.object({
|
|
837
|
+
id: z3.string(),
|
|
838
|
+
label: z3.string(),
|
|
839
|
+
projectDir: z3.string(),
|
|
840
|
+
repositoryRequired: z3.boolean().optional(),
|
|
644
841
|
/** Marketplace refs baked into the profile's image; absent when the profile declares none. */
|
|
645
|
-
workflows:
|
|
646
|
-
workflowSources:
|
|
842
|
+
workflows: z3.array(z3.string()).optional(),
|
|
843
|
+
workflowSources: z3.array(z3.string()).optional()
|
|
647
844
|
}))
|
|
648
845
|
});
|
|
649
|
-
var runnerDisconnectRequestSchema =
|
|
846
|
+
var runnerDisconnectRequestSchema = z3.strictObject({ hubEpoch: z3.string() });
|
|
650
847
|
var hubEpochRequestSchema = runnerDisconnectRequestSchema;
|
|
651
|
-
var runnerDisconnectPreviewSchema =
|
|
652
|
-
runnerId:
|
|
653
|
-
name:
|
|
654
|
-
runs:
|
|
655
|
-
runId:
|
|
656
|
-
label:
|
|
848
|
+
var runnerDisconnectPreviewSchema = z3.object({
|
|
849
|
+
runnerId: id2,
|
|
850
|
+
name: z3.string().nullable(),
|
|
851
|
+
runs: z3.array(z3.object({
|
|
852
|
+
runId: id2,
|
|
853
|
+
label: z3.string().optional(),
|
|
657
854
|
/** Working: executing now. Parked: waiting for a person, Runner released. Queued: not started yet. */
|
|
658
|
-
state:
|
|
855
|
+
state: z3.enum(["working", "parked", "queued"])
|
|
659
856
|
})),
|
|
660
|
-
hiddenRuns:
|
|
857
|
+
hiddenRuns: z3.number().int().nonnegative()
|
|
661
858
|
});
|
|
662
|
-
var runnerDisconnectResponseSchema =
|
|
663
|
-
disconnected:
|
|
859
|
+
var runnerDisconnectResponseSchema = z3.object({
|
|
860
|
+
disconnected: z3.literal(true),
|
|
664
861
|
/** How many Runs were Stopped with the reason `runner_disconnected`. */
|
|
665
|
-
stoppedRuns:
|
|
862
|
+
stoppedRuns: z3.number().int().nonnegative()
|
|
666
863
|
});
|
|
667
864
|
var runnerAdoptRequestSchema = hubEpochRequestSchema;
|
|
668
865
|
var connectStartRequestSchema = connectRedeemRequestSchema.omit({ code: true });
|
|
669
|
-
var connectStartResponseSchema =
|
|
866
|
+
var connectStartResponseSchema = z3.strictObject({
|
|
670
867
|
/** The machine's secret for polling; never shown. */
|
|
671
|
-
deviceCode:
|
|
868
|
+
deviceCode: z3.string().min(32).max(160),
|
|
672
869
|
code: connectCodeSchema,
|
|
673
870
|
expiresAt: sequence,
|
|
674
|
-
intervalSec:
|
|
871
|
+
intervalSec: z3.number().int().positive(),
|
|
675
872
|
/** The web console page that approves `code`. */
|
|
676
|
-
verificationUrl:
|
|
873
|
+
verificationUrl: z3.string().url()
|
|
677
874
|
});
|
|
678
|
-
var connectPollRequestSchema =
|
|
679
|
-
var connectPendingResponseSchema =
|
|
680
|
-
hostname:
|
|
681
|
-
os:
|
|
682
|
-
softwareVersion:
|
|
875
|
+
var connectPollRequestSchema = z3.strictObject({ deviceCode: z3.string().min(32).max(160) });
|
|
876
|
+
var connectPendingResponseSchema = z3.strictObject({
|
|
877
|
+
hostname: z3.string(),
|
|
878
|
+
os: z3.string(),
|
|
879
|
+
softwareVersion: z3.string(),
|
|
683
880
|
requestedAt: sequence,
|
|
684
881
|
expiresAt: sequence
|
|
685
882
|
});
|
|
686
|
-
var connectApproveRequestSchema =
|
|
687
|
-
code:
|
|
883
|
+
var connectApproveRequestSchema = z3.strictObject({
|
|
884
|
+
code: z3.string().min(8).max(16),
|
|
688
885
|
audience: audienceSchema,
|
|
689
|
-
hubEpoch:
|
|
886
|
+
hubEpoch: z3.string().optional()
|
|
690
887
|
});
|
|
691
|
-
var connectDenyRequestSchema =
|
|
888
|
+
var connectDenyRequestSchema = z3.strictObject({ code: z3.string().min(8).max(16) });
|
|
692
889
|
export {
|
|
693
890
|
CALIBRATION_MIN_RUNS,
|
|
694
891
|
CALIBRATION_WINDOW_DAYS,
|
|
@@ -723,8 +920,14 @@ export {
|
|
|
723
920
|
connectStartResponseSchema,
|
|
724
921
|
controlRecordSchema,
|
|
725
922
|
conversationContinuationCapability,
|
|
923
|
+
defaultDeliveryWorkflow,
|
|
726
924
|
delegationSchema,
|
|
727
925
|
delegationTokenPrefix,
|
|
926
|
+
deliveredCommandSchema,
|
|
927
|
+
deliveryEvidenceKindSchema,
|
|
928
|
+
deliveryStageSchema,
|
|
929
|
+
deliveryTransitionSchema,
|
|
930
|
+
deliveryWorkflowSchema,
|
|
728
931
|
forecastOfCap,
|
|
729
932
|
forecastOfClass,
|
|
730
933
|
grantSchema,
|
|
@@ -735,6 +938,7 @@ export {
|
|
|
735
938
|
installReference,
|
|
736
939
|
installedWorkflowsSchema,
|
|
737
940
|
interruptionSchema,
|
|
941
|
+
orchestratorGuidanceCapability,
|
|
738
942
|
permissionAnswerSchema,
|
|
739
943
|
protocolVersion,
|
|
740
944
|
readableHistory,
|
|
@@ -772,6 +976,15 @@ export {
|
|
|
772
976
|
sequence,
|
|
773
977
|
teamDefaultRequestSchema,
|
|
774
978
|
teamDefaultSchema,
|
|
979
|
+
trackerCommentSchema,
|
|
980
|
+
trackerEvidenceSchema,
|
|
981
|
+
trackerImportPreviewSchema,
|
|
982
|
+
trackerImportSchema,
|
|
983
|
+
trackerIssueSchema,
|
|
984
|
+
trackerOperationSchema,
|
|
985
|
+
trackerPlanSchema,
|
|
986
|
+
trackerSnapshotSchema,
|
|
987
|
+
trackerSourceSchema,
|
|
775
988
|
workflowIdentitySchema,
|
|
776
989
|
workflowInstallCapability,
|
|
777
990
|
workflowName,
|