@drisp/protocol 0.8.4 → 0.8.5
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 +41 -1
- package/dist/v2.js +284 -249
- package/package.json +1 -1
package/dist/v2.d.ts
CHANGED
|
@@ -26,6 +26,46 @@ declare function attemptCost(attempt: {
|
|
|
26
26
|
tokenCap: number;
|
|
27
27
|
closed: boolean;
|
|
28
28
|
}): number;
|
|
29
|
+
/** A class needs this many finished Runs of a harness before its forecast is measured (DRI-244). */
|
|
30
|
+
declare const CALIBRATION_MIN_RUNS = 10;
|
|
31
|
+
/** Only Runs closed within this many days count. */
|
|
32
|
+
declare const CALIBRATION_WINDOW_DAYS = 90;
|
|
33
|
+
/** What one size class measured to: the figure the plan uses, and how many finished Runs it rests on. */
|
|
34
|
+
type ClassCalibration = Readonly<Partial<Record<SizeClass, {
|
|
35
|
+
forecast: number;
|
|
36
|
+
runs: number;
|
|
37
|
+
}>>>;
|
|
38
|
+
/** The measured classes per harness name; a harness or class with too few Runs is absent. */
|
|
39
|
+
type Calibration = Readonly<Partial<Record<string, ClassCalibration>>>;
|
|
40
|
+
/** One finished Run's final counted tokens (cache reads excluded), by its harness and the class its cap belongs to. */
|
|
41
|
+
type CalibrationSample = {
|
|
42
|
+
harness: string;
|
|
43
|
+
sizeClass: SizeClass;
|
|
44
|
+
counted: number | undefined;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The forecast of each class and harness with at least `CALIBRATION_MIN_RUNS` samples: max(constant, p90 of the
|
|
48
|
+
* samples), the p90 by nearest rank. The constants are the floor, so calibration only raises a forecast. A sample with
|
|
49
|
+
* no figure is ignored. Which Runs are samples (completed, first attempt, in the window) is the Hub's to say.
|
|
50
|
+
*/
|
|
51
|
+
declare function calibrate(samples: readonly CalibrationSample[]): Calibration;
|
|
52
|
+
/** `GET /calibration`: the measured classes per harness name. */
|
|
53
|
+
declare const calibrationSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
54
|
+
S: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
forecast: z.ZodNumber;
|
|
56
|
+
runs: z.ZodNumber;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
M: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
forecast: z.ZodNumber;
|
|
60
|
+
runs: z.ZodNumber;
|
|
61
|
+
}, z.core.$strict>>;
|
|
62
|
+
L: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
forecast: z.ZodNumber;
|
|
64
|
+
runs: z.ZodNumber;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
/** A class's forecast: its measured figure when `calibration` has one, else the constant. */
|
|
68
|
+
declare function forecastOfClass(sizeClass: SizeClass, calibration: ClassCalibration | undefined): number;
|
|
29
69
|
|
|
30
70
|
declare const protocolVersion: {
|
|
31
71
|
readonly major: 2;
|
|
@@ -1476,4 +1516,4 @@ type ConnectPendingResponse = z.infer<typeof connectPendingResponseSchema>;
|
|
|
1476
1516
|
type TeamDefault = z.infer<typeof teamDefaultSchema>;
|
|
1477
1517
|
type RunsGoTo = z.infer<typeof runsGoToSchema>;
|
|
1478
1518
|
|
|
1479
|
-
export { type Audience, type BuildCloseReason, type Checkpoint, type Command, type ConnectAlreadyConnected, type ConnectPendingResponse, type ConnectRedeemRequest, type ConnectRedeemResponse, type ConnectStartRequest, type ConnectStartResponse, type ControlRecord, type Delegation, type ExecutionFact, type Grant, type Harness, type HarnessReadiness, type HistoryRecord, type InstalledWorkflow, type RepositoryBinding, type RepositorySource, type RunCloseReason, type RunParent, type RunUsage, type RunView, type RunnerAdoptRequest, type RunnerDisconnectPreview, type RunnerDisconnectResponse, type RunnerFrame, type RunnerList, type RunnerListEntry, type RunnerReadiness, type RunsGoTo, SIZE_CLASS_CAPS, SIZE_CLASS_FORECASTS, type Scope, type SizeClass, type TeamDefault, type WorkflowIdentity, type WorkflowInstallReference, type WorkflowReference, abandonedConversationContinuationCapability, attemptCost, audienceSchema, buildCloseReasonSchema, canonicalJson, checkpointPathSchema, checkpointSchema, classOfCap, clientFrameSchema, commandSchema, connectAlreadyConnectedSchema, connectApproveRequestSchema, connectCodeAlphabet, connectCodeRequestSchema, connectCodeResponseSchema, connectCodeSchema, connectDenyRequestSchema, connectPendingResponseSchema, connectPollRequestSchema, connectRedeemRequestSchema, connectRedeemResponseSchema, connectStartRequestSchema, connectStartResponseSchema, controlRecordSchema, conversationContinuationCapability, delegationSchema, delegationTokenPrefix, forecastOfCap, grantSchema, harnessReadinessSchema, harnessSchema, historyRecordSchema, hubEpochRequestSchema, installReference, installedWorkflowsSchema, interruptionSchema, permissionAnswerSchema, protocolVersion, readableHistory, readinessFixCommand, repositoryAccessCapability, repositoryBindingSchema, repositoryRefSchema, repositorySourceSchema, repositoryWorkingDirectorySchema, runArtifactMaxBytes, runArtifactNameSchema, runCloseReasonSchema, runDelegationCapability, runKeySchema, runParentIntentSchema, runParentSchema, runSpecSchema, runUsageCapability, runUsageSchema, runViewSchema, runnerAdoptRequestSchema, runnerDisconnectPreviewSchema, runnerDisconnectRequestSchema, runnerDisconnectResponseSchema, runnerFrameSchema, runnerListEntrySchema, runnerListSchema, runnerReadinessSchema, runnerUpdateCommand, runnerUpdateRequestSchema, runsGoToSchema, sameWorkflow, scopeSchema, secretEnvironmentSchema, sequence, teamDefaultRequestSchema, teamDefaultSchema, workflowIdentitySchema, workflowInstallCapability, workflowName, workflowReferenceSchema, workflowSourceSchema };
|
|
1519
|
+
export { type Audience, type BuildCloseReason, CALIBRATION_MIN_RUNS, CALIBRATION_WINDOW_DAYS, type Calibration, type CalibrationSample, type Checkpoint, type ClassCalibration, type Command, type ConnectAlreadyConnected, type ConnectPendingResponse, type ConnectRedeemRequest, type ConnectRedeemResponse, type ConnectStartRequest, type ConnectStartResponse, type ControlRecord, type Delegation, type ExecutionFact, type Grant, type Harness, type HarnessReadiness, type HistoryRecord, type InstalledWorkflow, type RepositoryBinding, type RepositorySource, type RunCloseReason, type RunParent, type RunUsage, type RunView, type RunnerAdoptRequest, type RunnerDisconnectPreview, type RunnerDisconnectResponse, type RunnerFrame, type RunnerList, type RunnerListEntry, type RunnerReadiness, type RunsGoTo, SIZE_CLASS_CAPS, SIZE_CLASS_FORECASTS, type Scope, type SizeClass, type TeamDefault, type WorkflowIdentity, type WorkflowInstallReference, type WorkflowReference, abandonedConversationContinuationCapability, attemptCost, audienceSchema, buildCloseReasonSchema, calibrate, calibrationSchema, canonicalJson, checkpointPathSchema, checkpointSchema, classOfCap, clientFrameSchema, commandSchema, connectAlreadyConnectedSchema, connectApproveRequestSchema, connectCodeAlphabet, connectCodeRequestSchema, connectCodeResponseSchema, connectCodeSchema, connectDenyRequestSchema, connectPendingResponseSchema, connectPollRequestSchema, connectRedeemRequestSchema, connectRedeemResponseSchema, connectStartRequestSchema, connectStartResponseSchema, controlRecordSchema, conversationContinuationCapability, delegationSchema, delegationTokenPrefix, forecastOfCap, forecastOfClass, grantSchema, harnessReadinessSchema, harnessSchema, historyRecordSchema, hubEpochRequestSchema, installReference, installedWorkflowsSchema, interruptionSchema, permissionAnswerSchema, protocolVersion, readableHistory, readinessFixCommand, repositoryAccessCapability, repositoryBindingSchema, repositoryRefSchema, repositorySourceSchema, repositoryWorkingDirectorySchema, runArtifactMaxBytes, runArtifactNameSchema, runCloseReasonSchema, runDelegationCapability, runKeySchema, runParentIntentSchema, runParentSchema, runSpecSchema, runUsageCapability, runUsageSchema, runViewSchema, runnerAdoptRequestSchema, runnerDisconnectPreviewSchema, runnerDisconnectRequestSchema, runnerDisconnectResponseSchema, runnerFrameSchema, runnerListEntrySchema, runnerListSchema, runnerReadinessSchema, runnerUpdateCommand, runnerUpdateRequestSchema, runsGoToSchema, sameWorkflow, scopeSchema, secretEnvironmentSchema, sequence, teamDefaultRequestSchema, teamDefaultSchema, workflowIdentitySchema, workflowInstallCapability, workflowName, workflowReferenceSchema, workflowSourceSchema };
|
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 } from "zod";
|
|
6
|
+
import { z as z2 } from "zod";
|
|
7
7
|
|
|
8
8
|
// src/history.ts
|
|
9
9
|
function readableHistory(records) {
|
|
@@ -48,6 +48,7 @@ function readableHistory(records) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/budget.ts
|
|
51
|
+
import { z } from "zod";
|
|
51
52
|
var SIZE_CLASS_CAPS = {
|
|
52
53
|
S: 3e6,
|
|
53
54
|
M: 6e6,
|
|
@@ -71,6 +72,35 @@ function attemptCost(attempt) {
|
|
|
71
72
|
const forecast = forecastOfCap(attempt.tokenCap);
|
|
72
73
|
return attempt.tokenCap > 0 ? Math.min(attempt.tokenCap, forecast) : forecast;
|
|
73
74
|
}
|
|
75
|
+
var CALIBRATION_MIN_RUNS = 10;
|
|
76
|
+
var CALIBRATION_WINDOW_DAYS = 90;
|
|
77
|
+
function calibrate(samples) {
|
|
78
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const { harness, sizeClass, counted } of samples) {
|
|
80
|
+
if (counted === void 0 || !Number.isFinite(counted) || counted < 0) continue;
|
|
81
|
+
const key = `${harness}\0${sizeClass}`;
|
|
82
|
+
const group = byKey.get(key) ?? { harness, sizeClass, counted: [] };
|
|
83
|
+
group.counted.push(counted);
|
|
84
|
+
byKey.set(key, group);
|
|
85
|
+
}
|
|
86
|
+
const result = {};
|
|
87
|
+
for (const { harness, sizeClass, counted } of byKey.values()) {
|
|
88
|
+
if (counted.length < CALIBRATION_MIN_RUNS) continue;
|
|
89
|
+
const sorted = [...counted].sort((a, b) => a - b);
|
|
90
|
+
const p90 = sorted[Math.ceil(sorted.length * 0.9) - 1];
|
|
91
|
+
(result[harness] ??= {})[sizeClass] = { forecast: Math.max(SIZE_CLASS_FORECASTS[sizeClass], p90), runs: sorted.length };
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
var classCalibrationSchema = z.strictObject({
|
|
96
|
+
S: z.strictObject({ forecast: z.number(), runs: z.number() }).optional(),
|
|
97
|
+
M: z.strictObject({ forecast: z.number(), runs: z.number() }).optional(),
|
|
98
|
+
L: z.strictObject({ forecast: z.number(), runs: z.number() }).optional()
|
|
99
|
+
});
|
|
100
|
+
var calibrationSchema = z.record(z.string(), classCalibrationSchema);
|
|
101
|
+
function forecastOfClass(sizeClass, calibration) {
|
|
102
|
+
return calibration?.[sizeClass]?.forecast ?? SIZE_CLASS_FORECASTS[sizeClass];
|
|
103
|
+
}
|
|
74
104
|
|
|
75
105
|
// src/v2.ts
|
|
76
106
|
var protocolVersion = { major: 2, minor: 3 };
|
|
@@ -81,29 +111,29 @@ var workflowInstallCapability = "workflow_install_v1";
|
|
|
81
111
|
var runDelegationCapability = "run_delegation_v1";
|
|
82
112
|
var runUsageCapability = "run_usage_v1";
|
|
83
113
|
var delegationTokenPrefix = "drisp_dlg_";
|
|
84
|
-
var runArtifactNameSchema =
|
|
114
|
+
var runArtifactNameSchema = z2.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
|
|
85
115
|
var runArtifactMaxBytes = 64 * 1024;
|
|
86
|
-
var secretEnvironmentSchema =
|
|
87
|
-
|
|
88
|
-
|
|
116
|
+
var secretEnvironmentSchema = z2.record(
|
|
117
|
+
z2.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_]+)$/),
|
|
118
|
+
z2.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
|
|
89
119
|
);
|
|
90
|
-
var permissionAnswerSchema =
|
|
91
|
-
kind:
|
|
92
|
-
decision:
|
|
93
|
-
reason:
|
|
120
|
+
var permissionAnswerSchema = z2.strictObject({
|
|
121
|
+
kind: z2.literal("permission"),
|
|
122
|
+
decision: z2.enum(["allow", "deny"]),
|
|
123
|
+
reason: z2.string().max(4096).optional()
|
|
94
124
|
});
|
|
95
|
-
var id =
|
|
96
|
-
var sequence =
|
|
125
|
+
var id = z2.string().min(1).max(160);
|
|
126
|
+
var sequence = z2.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
97
127
|
var positive = sequence.refine((n) => n > 0);
|
|
98
|
-
var timestamp =
|
|
99
|
-
var scopeSchema =
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
var timestamp = z2.iso.datetime();
|
|
129
|
+
var scopeSchema = z2.discriminatedUnion("visibility", [
|
|
130
|
+
z2.strictObject({ visibility: z2.literal("organization") }),
|
|
131
|
+
z2.strictObject({ visibility: z2.literal("private"), ownerUserId: id })
|
|
102
132
|
]);
|
|
103
|
-
var installedWorkflowsSchema =
|
|
104
|
-
var harnessSchema =
|
|
105
|
-
var harnessReadinessSchema =
|
|
106
|
-
var runnerReadinessSchema =
|
|
133
|
+
var installedWorkflowsSchema = z2.array(InstalledWorkflowSchema).max(256);
|
|
134
|
+
var harnessSchema = z2.enum(["claude-code", "codex"]);
|
|
135
|
+
var harnessReadinessSchema = z2.strictObject({ installed: z2.boolean(), signedIn: z2.boolean() });
|
|
136
|
+
var runnerReadinessSchema = z2.strictObject({
|
|
107
137
|
"claude-code": harnessReadinessSchema.optional(),
|
|
108
138
|
codex: harnessReadinessSchema.optional()
|
|
109
139
|
});
|
|
@@ -118,25 +148,25 @@ function readinessFixCommand(harness, readiness) {
|
|
|
118
148
|
return void 0;
|
|
119
149
|
}
|
|
120
150
|
var runnerUpdateCommand = "npm i -g @drisp/cli";
|
|
121
|
-
var interruptionSchema =
|
|
151
|
+
var interruptionSchema = z2.strictObject({
|
|
122
152
|
interruptionId: id,
|
|
123
153
|
revision: positive,
|
|
124
154
|
/** `waiting` (root ADR-0008) is non-human: a Run parked until one of its children closes or parks. */
|
|
125
|
-
kind:
|
|
126
|
-
message:
|
|
155
|
+
kind: z2.enum(["permission", "question", "guidance", "recovery", "waiting"]),
|
|
156
|
+
message: z2.string().max(16384),
|
|
127
157
|
requestId: id.optional()
|
|
128
158
|
});
|
|
129
|
-
var workflowIdentitySchema =
|
|
130
|
-
name:
|
|
131
|
-
version:
|
|
159
|
+
var workflowIdentitySchema = z2.strictObject({
|
|
160
|
+
name: z2.string().min(1).max(128),
|
|
161
|
+
version: z2.string().min(1).max(128).optional()
|
|
132
162
|
});
|
|
133
|
-
var buildCloseReasonSchema =
|
|
163
|
+
var buildCloseReasonSchema = z2.enum([
|
|
134
164
|
"workflow_template_mismatch",
|
|
135
165
|
"child_project_dir_invalid",
|
|
136
166
|
"build_not_approved",
|
|
137
167
|
"approval_question_missing"
|
|
138
168
|
]);
|
|
139
|
-
var runCloseReasonSchema =
|
|
169
|
+
var runCloseReasonSchema = z2.enum([
|
|
140
170
|
"execution_terminal",
|
|
141
171
|
"cancelled_before_start",
|
|
142
172
|
"admission_failed",
|
|
@@ -159,48 +189,48 @@ var factIdentity = {
|
|
|
159
189
|
executionRevision: positive,
|
|
160
190
|
emittedAt: timestamp
|
|
161
191
|
};
|
|
162
|
-
var runUsageSchema =
|
|
192
|
+
var runUsageSchema = z2.strictObject({ counted: sequence, cacheRead: sequence });
|
|
163
193
|
var reportedUsage = { usage: runUsageSchema.optional() };
|
|
164
|
-
var controlRecordSchema =
|
|
194
|
+
var controlRecordSchema = z2.discriminatedUnion("kind", [
|
|
165
195
|
/** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
|
|
166
|
-
|
|
196
|
+
z2.strictObject({ kind: z2.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
|
|
167
197
|
/** Instance-scoped, not tied to a Run: the Runner's full Readiness, sent when it changes after hello. */
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
kind:
|
|
198
|
+
z2.strictObject({ kind: z2.literal("readiness.changed"), readiness: runnerReadinessSchema }),
|
|
199
|
+
z2.strictObject({ kind: z2.literal("assignment.accepted"), runId: id, attemptId: id }),
|
|
200
|
+
z2.strictObject({
|
|
201
|
+
kind: z2.literal("assignment.rejected"),
|
|
172
202
|
runId: id,
|
|
173
203
|
attemptId: id,
|
|
174
|
-
reason:
|
|
204
|
+
reason: z2.string().max(1024)
|
|
175
205
|
}),
|
|
176
|
-
|
|
177
|
-
kind:
|
|
206
|
+
z2.strictObject({
|
|
207
|
+
kind: z2.literal("run.started"),
|
|
178
208
|
...factIdentity,
|
|
179
209
|
/** Absent from runners that predate Workflow reporting. */
|
|
180
210
|
workflow: workflowIdentitySchema.optional()
|
|
181
211
|
}),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
kind:
|
|
212
|
+
z2.strictObject({ kind: z2.literal("run.resumed"), ...factIdentity }),
|
|
213
|
+
z2.strictObject({
|
|
214
|
+
kind: z2.literal("run.attention"),
|
|
185
215
|
...factIdentity,
|
|
186
216
|
interruption: interruptionSchema,
|
|
187
|
-
occupancy:
|
|
217
|
+
occupancy: z2.enum(["held", "released"]),
|
|
188
218
|
historyThrough: sequence,
|
|
189
|
-
continuation:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
219
|
+
continuation: z2.discriminatedUnion("kind", [
|
|
220
|
+
z2.strictObject({ kind: z2.literal("live_request") }),
|
|
221
|
+
z2.strictObject({ kind: z2.literal("local_checkpoint"), checkpointId: id }),
|
|
222
|
+
z2.strictObject({ kind: z2.literal("portable_checkpoint"), checkpointId: id }),
|
|
223
|
+
z2.strictObject({ kind: z2.literal("repair_required"), detail: z2.string().max(4096) })
|
|
194
224
|
]),
|
|
195
225
|
...reportedUsage
|
|
196
226
|
}),
|
|
197
|
-
|
|
198
|
-
kind:
|
|
227
|
+
z2.strictObject({
|
|
228
|
+
kind: z2.literal("run.finished"),
|
|
199
229
|
...factIdentity,
|
|
200
|
-
status:
|
|
230
|
+
status: z2.enum(["completed", "failed", "cancelled"]),
|
|
201
231
|
historyThrough: sequence,
|
|
202
232
|
/** No setup/harness executed and no workspace was produced; safe to retire without export. */
|
|
203
|
-
workspaceUnavailable:
|
|
233
|
+
workspaceUnavailable: z2.literal(true).optional(),
|
|
204
234
|
/**
|
|
205
235
|
* Why a Build Run failed, as its close reason (docs/specs/build-orchestrator.md). Sent only for a grant with
|
|
206
236
|
* `parent` or `delegationToken`, which only a Hub that knows this field issues.
|
|
@@ -212,85 +242,85 @@ var controlRecordSchema = z.discriminatedUnion("kind", [
|
|
|
212
242
|
* The usage of a Run while it executes, for a grant marked `reportUsage`. Not an execution fact: it carries no
|
|
213
243
|
* execution revision, so it never advances, parks or closes the Run, and never wakes its parent.
|
|
214
244
|
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
kind:
|
|
245
|
+
z2.strictObject({ kind: z2.literal("run.usage"), runId: id, attemptId: id, ...runUsageSchema.shape }),
|
|
246
|
+
z2.strictObject({ kind: z2.literal("command.applied"), runId: id, attemptId: id, commandId: id }),
|
|
247
|
+
z2.strictObject({
|
|
248
|
+
kind: z2.literal("command.rejected"),
|
|
219
249
|
runId: id,
|
|
220
250
|
attemptId: id,
|
|
221
251
|
commandId: id,
|
|
222
|
-
reason:
|
|
252
|
+
reason: z2.string().max(1024)
|
|
223
253
|
}),
|
|
224
|
-
|
|
254
|
+
z2.strictObject({ kind: z2.literal("revoked_not_started"), runId: id, attemptId: id })
|
|
225
255
|
]);
|
|
226
|
-
var repositoryRefSchema =
|
|
256
|
+
var repositoryRefSchema = z2.string().min(1).max(512).regex(
|
|
227
257
|
/^(?![-/])(?!.*\.\.)(?!.*@\{)(?!.*(?:^|\/)\.)(?!.*\.lock(?:\/|$))(?!.*\/\/)[^\x00-\x20\x7f~^:?*\[\\]+(?<![/.])$/
|
|
228
258
|
);
|
|
229
|
-
var repositoryWorkingDirectorySchema =
|
|
259
|
+
var repositoryWorkingDirectorySchema = z2.string().min(1).max(1024).regex(
|
|
230
260
|
/^(?:\.|(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))[^\x00-\x1f\x7f\\:]+(?<!\/))$/
|
|
231
261
|
);
|
|
232
262
|
var repositoryIdentity = {
|
|
233
|
-
repositoryId:
|
|
234
|
-
installationId:
|
|
235
|
-
owner:
|
|
236
|
-
name:
|
|
263
|
+
repositoryId: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
264
|
+
installationId: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
265
|
+
owner: z2.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
|
|
266
|
+
name: z2.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
|
|
237
267
|
};
|
|
238
|
-
var repositoryBindingSchema =
|
|
268
|
+
var repositoryBindingSchema = z2.strictObject({
|
|
239
269
|
id,
|
|
240
|
-
label:
|
|
270
|
+
label: z2.string().min(1).max(160),
|
|
241
271
|
...repositoryIdentity,
|
|
242
272
|
defaultRef: repositoryRefSchema,
|
|
243
273
|
workingDirectory: repositoryWorkingDirectorySchema,
|
|
244
|
-
setupCommands:
|
|
274
|
+
setupCommands: z2.array(z2.string().min(1).max(8192)).max(16),
|
|
245
275
|
revision: positive,
|
|
246
|
-
enabled:
|
|
276
|
+
enabled: z2.boolean()
|
|
247
277
|
});
|
|
248
|
-
var repositorySourceSchema =
|
|
278
|
+
var repositorySourceSchema = z2.strictObject({
|
|
249
279
|
bindingId: id,
|
|
250
280
|
...repositoryIdentity,
|
|
251
281
|
ref: repositoryRefSchema,
|
|
252
|
-
commitSha:
|
|
282
|
+
commitSha: z2.string().regex(/^[0-9a-f]{40}$/),
|
|
253
283
|
branch: repositoryRefSchema,
|
|
254
284
|
workingDirectory: repositoryWorkingDirectorySchema,
|
|
255
|
-
setupCommands:
|
|
285
|
+
setupCommands: z2.array(z2.string().min(1).max(8192)).max(16),
|
|
256
286
|
configRevision: positive
|
|
257
287
|
});
|
|
258
|
-
var workflowSourceSchema =
|
|
259
|
-
var workflowReferenceSchema =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
name:
|
|
288
|
+
var workflowSourceSchema = z2.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
|
|
289
|
+
var workflowReferenceSchema = z2.union([
|
|
290
|
+
z2.string().max(512),
|
|
291
|
+
z2.strictObject({
|
|
292
|
+
name: z2.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
|
|
263
293
|
source: workflowSourceSchema.optional(),
|
|
264
|
-
ref:
|
|
265
|
-
version:
|
|
294
|
+
ref: z2.string().min(1).max(512).optional(),
|
|
295
|
+
version: z2.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
|
|
266
296
|
})
|
|
267
297
|
]);
|
|
268
298
|
var workflowName = (workflow) => typeof workflow === "object" ? workflow.name : workflow;
|
|
269
299
|
var installReference = (workflow) => typeof workflow === "object" && workflow.source !== void 0 ? workflow : void 0;
|
|
270
300
|
var sameWorkflow = (a, b) => canonicalJson(a ?? null) === canonicalJson(b ?? null);
|
|
271
|
-
var runSpecSchema =
|
|
272
|
-
prompt:
|
|
273
|
-
projectDir:
|
|
301
|
+
var runSpecSchema = z2.strictObject({
|
|
302
|
+
prompt: z2.string().min(1).max(131072),
|
|
303
|
+
projectDir: z2.string().min(1).max(4096),
|
|
274
304
|
harness: harnessSchema,
|
|
275
305
|
workflow: workflowReferenceSchema.optional(),
|
|
276
306
|
repository: repositorySourceSchema.optional()
|
|
277
307
|
});
|
|
278
|
-
var runKeySchema =
|
|
279
|
-
var delegationSchema =
|
|
280
|
-
maxChildren:
|
|
281
|
-
tokenBudget:
|
|
308
|
+
var runKeySchema = z2.string().min(1).max(160);
|
|
309
|
+
var delegationSchema = z2.strictObject({
|
|
310
|
+
maxChildren: z2.number().int().min(1).max(8),
|
|
311
|
+
tokenBudget: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER)
|
|
282
312
|
});
|
|
283
|
-
var tokenCapSchema =
|
|
284
|
-
var runParentIntentSchema =
|
|
285
|
-
var runParentSchema =
|
|
286
|
-
var commandSchema =
|
|
313
|
+
var tokenCapSchema = z2.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
314
|
+
var runParentIntentSchema = z2.strictObject({ runId: id, tokenCap: tokenCapSchema.optional() });
|
|
315
|
+
var runParentSchema = z2.strictObject({ runId: id, tokenCap: tokenCapSchema });
|
|
316
|
+
var commandSchema = z2.strictObject({
|
|
287
317
|
commandId: id,
|
|
288
318
|
hubEpoch: id,
|
|
289
319
|
runId: id,
|
|
290
320
|
expectedRecordRevision: sequence.optional(),
|
|
291
|
-
intent:
|
|
292
|
-
|
|
293
|
-
kind:
|
|
321
|
+
intent: z2.discriminatedUnion("kind", [
|
|
322
|
+
z2.strictObject({
|
|
323
|
+
kind: z2.literal("start"),
|
|
294
324
|
sessionId: id,
|
|
295
325
|
/**
|
|
296
326
|
* Absent: the Hub resolves the Runner member-first (root ADR-0005): the Session's conversation Runner, else
|
|
@@ -306,24 +336,24 @@ var commandSchema = z.strictObject({
|
|
|
306
336
|
/** Delegated starts only, and required on them. */
|
|
307
337
|
parent: runParentIntentSchema.optional()
|
|
308
338
|
}),
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
kind:
|
|
339
|
+
z2.strictObject({ kind: z2.literal("cancel") }),
|
|
340
|
+
z2.strictObject({ kind: z2.literal("abandon") }),
|
|
341
|
+
z2.strictObject({ kind: z2.literal("steer"), text: z2.string().min(1).max(131072) }),
|
|
342
|
+
z2.strictObject({
|
|
343
|
+
kind: z2.literal("answer"),
|
|
314
344
|
interruptionId: id,
|
|
315
345
|
expectedInterruptionRevision: positive,
|
|
316
346
|
requestId: id.optional(),
|
|
317
|
-
answer:
|
|
347
|
+
answer: z2.json()
|
|
318
348
|
}),
|
|
319
|
-
|
|
320
|
-
kind:
|
|
349
|
+
z2.strictObject({
|
|
350
|
+
kind: z2.literal("resume"),
|
|
321
351
|
interruptionId: id,
|
|
322
|
-
guidance:
|
|
352
|
+
guidance: z2.string().max(131072).optional()
|
|
323
353
|
})
|
|
324
354
|
])
|
|
325
355
|
});
|
|
326
|
-
var grantSchema =
|
|
356
|
+
var grantSchema = z2.strictObject({
|
|
327
357
|
commandId: id,
|
|
328
358
|
hubEpoch: id,
|
|
329
359
|
runId: id,
|
|
@@ -335,121 +365,121 @@ var grantSchema = z.strictObject({
|
|
|
335
365
|
baseExecutionRevision: sequence,
|
|
336
366
|
baseHistorySeq: sequence,
|
|
337
367
|
cloudHistoryThrough: sequence,
|
|
338
|
-
purpose:
|
|
368
|
+
purpose: z2.enum(["start", "resume"]),
|
|
339
369
|
spec: runSpecSchema,
|
|
340
|
-
continuation:
|
|
370
|
+
continuation: z2.json().optional(),
|
|
341
371
|
/** A new Run in a durable conversation; never resumes the predecessor's lifecycle. */
|
|
342
|
-
previousRun:
|
|
372
|
+
previousRun: z2.strictObject({
|
|
343
373
|
runId: id,
|
|
344
374
|
executionRevision: sequence,
|
|
345
375
|
historyProduced: sequence,
|
|
346
376
|
/** Hub-confirmed administrative closure; allows an exact parked predecessor snapshot. */
|
|
347
|
-
closeReason:
|
|
348
|
-
checkpoint:
|
|
377
|
+
closeReason: z2.literal("abandoned").optional(),
|
|
378
|
+
checkpoint: z2.strictObject({ checkpointId: id, checksum: z2.string().regex(/^[a-f0-9]{64}$/) }).optional()
|
|
349
379
|
}).optional(),
|
|
350
|
-
checkpoint:
|
|
380
|
+
checkpoint: z2.strictObject({ checkpointId: id, checksum: z2.string().regex(/^[a-f0-9]{64}$/) }).optional(),
|
|
351
381
|
/** This attempt's delegation token: only for a Run started with `delegation`, only to a `run_delegation_v1` Runner. */
|
|
352
|
-
delegationToken:
|
|
382
|
+
delegationToken: z2.string().min(32).max(256).optional(),
|
|
353
383
|
/** Copied from the start intent of a delegated child. */
|
|
354
384
|
parent: runParentSchema.optional(),
|
|
355
385
|
/** The runner reports this attempt's usage: set only for a `run_usage_v1` Runner. */
|
|
356
|
-
reportUsage:
|
|
386
|
+
reportUsage: z2.literal(true).optional()
|
|
357
387
|
});
|
|
358
|
-
var historyRecordSchema =
|
|
388
|
+
var historyRecordSchema = z2.strictObject({
|
|
359
389
|
eventId: id,
|
|
360
390
|
attemptId: id,
|
|
361
391
|
emittedAt: timestamp,
|
|
362
|
-
kind:
|
|
363
|
-
data:
|
|
392
|
+
kind: z2.string().min(1).max(128),
|
|
393
|
+
data: z2.json()
|
|
364
394
|
});
|
|
365
|
-
var runnerFrameSchema =
|
|
366
|
-
|
|
367
|
-
type:
|
|
368
|
-
role:
|
|
369
|
-
protocol:
|
|
395
|
+
var runnerFrameSchema = z2.discriminatedUnion("type", [
|
|
396
|
+
z2.strictObject({
|
|
397
|
+
type: z2.literal("hello"),
|
|
398
|
+
role: z2.literal("runner"),
|
|
399
|
+
protocol: z2.strictObject({ major: z2.literal(2), minor: sequence }),
|
|
370
400
|
runnerId: id,
|
|
371
401
|
installationId: id,
|
|
372
|
-
softwareVersion:
|
|
373
|
-
capabilities:
|
|
402
|
+
softwareVersion: z2.string().max(128),
|
|
403
|
+
capabilities: z2.array(z2.string().max(128)).max(64),
|
|
374
404
|
/** Absent from older runners: the Hub treats the inventory as unknown, never as empty. */
|
|
375
405
|
workflows: installedWorkflowsSchema.optional(),
|
|
376
406
|
/** Absent from older runners, and from a runner that has not finished its first check: unknown, not "not ready". */
|
|
377
407
|
readiness: runnerReadinessSchema.optional(),
|
|
378
|
-
control:
|
|
408
|
+
control: z2.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
|
|
379
409
|
}),
|
|
380
|
-
|
|
381
|
-
type:
|
|
410
|
+
z2.strictObject({
|
|
411
|
+
type: z2.literal("control.batch"),
|
|
382
412
|
firstSeq: positive,
|
|
383
|
-
records:
|
|
413
|
+
records: z2.array(controlRecordSchema).min(1).max(128)
|
|
384
414
|
}),
|
|
385
|
-
|
|
386
|
-
type:
|
|
415
|
+
z2.strictObject({
|
|
416
|
+
type: z2.literal("history.batch"),
|
|
387
417
|
runId: id,
|
|
388
418
|
firstSeq: positive,
|
|
389
|
-
records:
|
|
419
|
+
records: z2.array(historyRecordSchema).min(1).max(128)
|
|
390
420
|
}),
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
type:
|
|
421
|
+
z2.strictObject({ type: z2.literal("ping"), nonce: id }),
|
|
422
|
+
z2.strictObject({
|
|
423
|
+
type: z2.literal("reconcile.page"),
|
|
394
424
|
inventoryId: id.default("single-page"),
|
|
395
425
|
page: sequence.default(0),
|
|
396
|
-
complete:
|
|
397
|
-
runs:
|
|
398
|
-
|
|
426
|
+
complete: z2.boolean(),
|
|
427
|
+
runs: z2.array(
|
|
428
|
+
z2.strictObject({
|
|
399
429
|
runId: id,
|
|
400
430
|
attemptId: id,
|
|
401
431
|
executionRevision: sequence,
|
|
402
|
-
phase:
|
|
432
|
+
phase: z2.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
|
|
403
433
|
})
|
|
404
434
|
).max(128)
|
|
405
435
|
})
|
|
406
436
|
]);
|
|
407
|
-
var runViewSchema =
|
|
437
|
+
var runViewSchema = z2.object({
|
|
408
438
|
runId: id,
|
|
409
439
|
sessionId: id,
|
|
410
440
|
runnerId: id,
|
|
411
441
|
computeProfileId: id.optional(),
|
|
412
442
|
scope: scopeSchema,
|
|
413
443
|
recordRevision: positive,
|
|
414
|
-
label:
|
|
444
|
+
label: z2.string().max(160).optional(),
|
|
415
445
|
key: runKeySchema.optional(),
|
|
416
446
|
parent: runParentSchema.optional(),
|
|
417
447
|
/**
|
|
418
448
|
* Not strict, unlike the start intent's: a Hub keeps more on the Run's delegation (`initialTokenBudget`) than it
|
|
419
449
|
* shows, and a client never refuses a view for a field it does not read.
|
|
420
450
|
*/
|
|
421
|
-
delegation:
|
|
451
|
+
delegation: z2.object(delegationSchema.shape).optional(),
|
|
422
452
|
/** The largest cumulative usage the Run's Runner reported; absent until one does (an older Runner never does). */
|
|
423
453
|
usage: runUsageSchema.optional(),
|
|
424
454
|
/** Resolved by the runner at start; absent until the Run starts and for runners that predate reporting. */
|
|
425
455
|
workflow: workflowIdentitySchema.optional(),
|
|
426
|
-
execution:
|
|
427
|
-
status:
|
|
456
|
+
execution: z2.object({
|
|
457
|
+
status: z2.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
|
|
428
458
|
revision: positive,
|
|
429
459
|
attemptId: id,
|
|
430
|
-
occupancy:
|
|
460
|
+
occupancy: z2.enum(["held", "released"]),
|
|
431
461
|
startedAt: timestamp.optional(),
|
|
432
462
|
endedAt: timestamp.optional(),
|
|
433
463
|
interruption: interruptionSchema.optional()
|
|
434
464
|
}).nullable(),
|
|
435
|
-
scheduling:
|
|
436
|
-
closed:
|
|
437
|
-
closeReason:
|
|
465
|
+
scheduling: z2.enum(["queued", "dispatching", "admitted", "idle"]),
|
|
466
|
+
closed: z2.boolean(),
|
|
467
|
+
closeReason: z2.string().optional(),
|
|
438
468
|
cancellation: id.optional(),
|
|
439
469
|
pendingResume: commandSchema.shape.intent.optional(),
|
|
440
470
|
/** Derived per viewer; absent on older Hubs. Never grants execution authority. */
|
|
441
|
-
runnerStopped:
|
|
442
|
-
canAbandon:
|
|
471
|
+
runnerStopped: z2.boolean().optional(),
|
|
472
|
+
canAbandon: z2.boolean().optional(),
|
|
443
473
|
historyThrough: sequence,
|
|
444
474
|
expectedHistoryThrough: sequence.optional(),
|
|
445
475
|
createdAt: sequence,
|
|
446
|
-
checkpoint:
|
|
476
|
+
checkpoint: z2.object({ id, state: z2.enum(["pending", "ready"]), checksum: z2.string().optional() }).optional()
|
|
447
477
|
});
|
|
448
|
-
var clientFrameSchema =
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
478
|
+
var clientFrameSchema = z2.discriminatedUnion("type", [
|
|
479
|
+
z2.strictObject({ type: z2.literal("watch"), hubEpoch: id, runIds: z2.array(id).max(100) }),
|
|
480
|
+
z2.strictObject({ type: z2.literal("watch.ack"), subscriptionId: id, through: sequence }),
|
|
481
|
+
z2.strictObject({ type: z2.literal("command.submit"), command: commandSchema }),
|
|
482
|
+
z2.strictObject({ type: z2.literal("ping"), nonce: id })
|
|
453
483
|
]);
|
|
454
484
|
function canonicalJson(value) {
|
|
455
485
|
if (value === null || typeof value !== "object") {
|
|
@@ -460,76 +490,76 @@ function canonicalJson(value) {
|
|
|
460
490
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
461
491
|
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(",")}}`;
|
|
462
492
|
}
|
|
463
|
-
var checkpointPathSchema =
|
|
493
|
+
var checkpointPathSchema = z2.string().min(1).max(4096).refine(
|
|
464
494
|
(path) => !path.startsWith("/") && !path.includes("\\") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".." && part !== ".git")
|
|
465
495
|
);
|
|
466
|
-
var checkpointSchema =
|
|
467
|
-
version:
|
|
468
|
-
checkpointId:
|
|
469
|
-
orgId:
|
|
470
|
-
phase:
|
|
471
|
-
runId:
|
|
472
|
-
sessionId:
|
|
473
|
-
sourceAttemptId:
|
|
474
|
-
executionRevision:
|
|
475
|
-
historyProduced:
|
|
476
|
-
historyAck:
|
|
496
|
+
var checkpointSchema = z2.strictObject({
|
|
497
|
+
version: z2.literal(1),
|
|
498
|
+
checkpointId: z2.string().min(1),
|
|
499
|
+
orgId: z2.string().min(1),
|
|
500
|
+
phase: z2.enum(["parked", "terminal"]),
|
|
501
|
+
runId: z2.string().min(1),
|
|
502
|
+
sessionId: z2.string().min(1),
|
|
503
|
+
sourceAttemptId: z2.string().min(1),
|
|
504
|
+
executionRevision: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
505
|
+
historyProduced: z2.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
506
|
+
historyAck: z2.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
477
507
|
grant: grantSchema,
|
|
478
|
-
gitHead:
|
|
479
|
-
gitBase:
|
|
480
|
-
gitBundle:
|
|
481
|
-
indexPatch:
|
|
482
|
-
files:
|
|
483
|
-
|
|
508
|
+
gitHead: z2.string().regex(/^[0-9a-f]{40,64}$/),
|
|
509
|
+
gitBase: z2.string().regex(/^[0-9a-f]{40,64}$/).optional(),
|
|
510
|
+
gitBundle: z2.string(),
|
|
511
|
+
indexPatch: z2.string(),
|
|
512
|
+
files: z2.array(
|
|
513
|
+
z2.strictObject({ path: checkpointPathSchema, content: z2.string(), executable: z2.boolean() })
|
|
484
514
|
).max(1e5),
|
|
485
|
-
deleted:
|
|
486
|
-
sessionRows:
|
|
487
|
-
history:
|
|
488
|
-
|
|
515
|
+
deleted: z2.array(checkpointPathSchema).max(1e5),
|
|
516
|
+
sessionRows: z2.array(z2.strictObject({ kind: z2.string(), id: z2.string(), payload: z2.string() })),
|
|
517
|
+
history: z2.array(
|
|
518
|
+
z2.strictObject({ seq: z2.number().int().positive(), record: historyRecordSchema })
|
|
489
519
|
)
|
|
490
520
|
});
|
|
491
521
|
var connectCodeAlphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
492
|
-
var connectCodeSchema =
|
|
493
|
-
var connectCodeRequestSchema =
|
|
494
|
-
var connectCodeResponseSchema =
|
|
522
|
+
var connectCodeSchema = z2.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
|
|
523
|
+
var connectCodeRequestSchema = z2.strictObject({ hubEpoch: z2.string() });
|
|
524
|
+
var connectCodeResponseSchema = z2.strictObject({
|
|
495
525
|
code: connectCodeSchema,
|
|
496
526
|
expiresAt: sequence
|
|
497
527
|
});
|
|
498
|
-
var connectRedeemRequestSchema =
|
|
499
|
-
code:
|
|
528
|
+
var connectRedeemRequestSchema = z2.strictObject({
|
|
529
|
+
code: z2.string().min(8).max(16),
|
|
500
530
|
installationId: id,
|
|
501
|
-
hostname:
|
|
502
|
-
os:
|
|
503
|
-
softwareVersion:
|
|
531
|
+
hostname: z2.string().min(1).max(255),
|
|
532
|
+
os: z2.string().min(1).max(64),
|
|
533
|
+
softwareVersion: z2.string().min(1).max(128)
|
|
504
534
|
});
|
|
505
|
-
var connectRedeemResponseSchema =
|
|
535
|
+
var connectRedeemResponseSchema = z2.strictObject({
|
|
506
536
|
orgId: id,
|
|
507
|
-
hubEpoch:
|
|
537
|
+
hubEpoch: z2.string(),
|
|
508
538
|
runnerId: id,
|
|
509
539
|
installationId: id,
|
|
510
|
-
name:
|
|
511
|
-
token:
|
|
540
|
+
name: z2.string(),
|
|
541
|
+
token: z2.string().min(32),
|
|
512
542
|
credentialId: id,
|
|
513
543
|
expiresAt: sequence
|
|
514
544
|
});
|
|
515
|
-
var connectAlreadyConnectedSchema =
|
|
516
|
-
error:
|
|
545
|
+
var connectAlreadyConnectedSchema = z2.strictObject({
|
|
546
|
+
error: z2.literal("runner_already_connected"),
|
|
517
547
|
orgId: id,
|
|
518
548
|
runnerId: id,
|
|
519
|
-
name:
|
|
549
|
+
name: z2.string()
|
|
520
550
|
});
|
|
521
|
-
var audienceSchema =
|
|
522
|
-
var runnerListEntrySchema =
|
|
551
|
+
var audienceSchema = z2.enum(["personal", "team"]);
|
|
552
|
+
var runnerListEntrySchema = z2.object({
|
|
523
553
|
id,
|
|
524
|
-
online:
|
|
525
|
-
capacity:
|
|
526
|
-
managed:
|
|
527
|
-
draining:
|
|
528
|
-
stopped:
|
|
529
|
-
name:
|
|
530
|
-
connectedBy:
|
|
554
|
+
online: z2.number(),
|
|
555
|
+
capacity: z2.number(),
|
|
556
|
+
managed: z2.number(),
|
|
557
|
+
draining: z2.number(),
|
|
558
|
+
stopped: z2.number(),
|
|
559
|
+
name: z2.string().nullable(),
|
|
560
|
+
connectedBy: z2.string().nullable(),
|
|
531
561
|
audience: audienceSchema.nullable(),
|
|
532
|
-
softwareVersion:
|
|
562
|
+
softwareVersion: z2.string().nullable(),
|
|
533
563
|
/** Milliseconds since the epoch of the last hello or disconnect; null before the first connection. */
|
|
534
564
|
lastSeen: sequence.nullable(),
|
|
535
565
|
/** Absent when the runner has not reported an inventory: unknown, not none. */
|
|
@@ -539,115 +569,119 @@ var runnerListEntrySchema = z.object({
|
|
|
539
569
|
* Runner seen by an admin (who may still Disconnect it), or a Runner a member did not connect. Absent from Hubs
|
|
540
570
|
* older than Audience, like the list's `viewer`, `teamDefault` and `runsGoTo`.
|
|
541
571
|
*/
|
|
542
|
-
readOnly:
|
|
572
|
+
readOnly: z2.boolean().optional(),
|
|
543
573
|
/** What the Runner last reported; absent when it never has (an older runner, or one not yet connected). */
|
|
544
574
|
readiness: runnerReadinessSchema.optional(),
|
|
545
575
|
/**
|
|
546
576
|
* True when the Runner reported a version below the Hub's minimum: it is listed as "Update required" and takes no
|
|
547
577
|
* Runs until it is updated (`runnerUpdateCommand`). Absent from Hubs older than Readiness.
|
|
548
578
|
*/
|
|
549
|
-
updateRequired:
|
|
579
|
+
updateRequired: z2.boolean().optional(),
|
|
550
580
|
/**
|
|
551
581
|
* True while it is paused as "Needs an owner": the member who connected this Team Runner left the Team, so it
|
|
552
582
|
* takes no Runs until an admin adopts it (`/runners/{id}/adopt`) or Disconnects it. Absent from older Hubs.
|
|
553
583
|
*/
|
|
554
|
-
needsOwner:
|
|
584
|
+
needsOwner: z2.boolean().optional()
|
|
555
585
|
});
|
|
556
|
-
var teamDefaultSchema =
|
|
557
|
-
|
|
558
|
-
|
|
586
|
+
var teamDefaultSchema = z2.discriminatedUnion("kind", [
|
|
587
|
+
z2.strictObject({ kind: z2.literal("runner"), runnerId: id }),
|
|
588
|
+
z2.strictObject({ kind: z2.literal("profile"), profileId: id })
|
|
559
589
|
]);
|
|
560
|
-
var teamDefaultRequestSchema =
|
|
561
|
-
hubEpoch:
|
|
590
|
+
var teamDefaultRequestSchema = z2.strictObject({
|
|
591
|
+
hubEpoch: z2.string(),
|
|
562
592
|
teamDefault: teamDefaultSchema.nullable()
|
|
563
593
|
});
|
|
564
|
-
var runnerUpdateRequestSchema =
|
|
565
|
-
hubEpoch:
|
|
566
|
-
name:
|
|
567
|
-
capacity:
|
|
594
|
+
var runnerUpdateRequestSchema = z2.strictObject({
|
|
595
|
+
hubEpoch: z2.string(),
|
|
596
|
+
name: z2.string().max(100).optional(),
|
|
597
|
+
capacity: z2.number().int().min(1).max(64).optional(),
|
|
568
598
|
audience: audienceSchema.optional()
|
|
569
599
|
}).refine(
|
|
570
600
|
(update) => update.name !== void 0 || update.capacity !== void 0 || update.audience !== void 0,
|
|
571
601
|
{ message: "nothing to update" }
|
|
572
602
|
);
|
|
573
|
-
var runsGoToSchema =
|
|
603
|
+
var runsGoToSchema = z2.union([
|
|
574
604
|
/** The viewer's own Runner: Personal, or one they connected that was widened to Team (DRI-42). */
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
605
|
+
z2.strictObject({ via: z2.literal("personal"), runnerId: id }),
|
|
606
|
+
z2.strictObject({ via: z2.literal("team_default"), runnerId: id }),
|
|
607
|
+
z2.strictObject({ via: z2.literal("team_default"), profileId: id }),
|
|
578
608
|
/** `runner_needs_owner`: the Team default is a Runner paused because the member who connected it left. */
|
|
579
|
-
|
|
609
|
+
z2.strictObject({ via: z2.literal("none"), reason: z2.enum(["no_runner_available", "runner_needs_owner"]) })
|
|
580
610
|
]);
|
|
581
|
-
var runnerListSchema =
|
|
582
|
-
capabilities:
|
|
583
|
-
historyRetentionDays:
|
|
611
|
+
var runnerListSchema = z2.object({
|
|
612
|
+
capabilities: z2.record(z2.string(), z2.boolean()).optional(),
|
|
613
|
+
historyRetentionDays: z2.number().int().positive().nullable().optional(),
|
|
584
614
|
/** Who the list was filtered for: a member sees their own and Team Runners, an admin every Runner. */
|
|
585
|
-
viewer:
|
|
615
|
+
viewer: z2.object({ userId: z2.string(), admin: z2.boolean() }).optional(),
|
|
586
616
|
teamDefault: teamDefaultSchema.nullable().optional(),
|
|
587
617
|
runsGoTo: runsGoToSchema.optional(),
|
|
588
618
|
/** The lowest Runner version this Hub sends Runs to. Absent from Hubs older than Readiness. */
|
|
589
|
-
minimumRunnerVersion:
|
|
590
|
-
runners:
|
|
591
|
-
profiles:
|
|
592
|
-
id:
|
|
593
|
-
label:
|
|
594
|
-
projectDir:
|
|
595
|
-
repositoryRequired:
|
|
619
|
+
minimumRunnerVersion: z2.string().optional(),
|
|
620
|
+
runners: z2.array(runnerListEntrySchema),
|
|
621
|
+
profiles: z2.array(z2.object({
|
|
622
|
+
id: z2.string(),
|
|
623
|
+
label: z2.string(),
|
|
624
|
+
projectDir: z2.string(),
|
|
625
|
+
repositoryRequired: z2.boolean().optional(),
|
|
596
626
|
/** Marketplace refs baked into the profile's image; absent when the profile declares none. */
|
|
597
|
-
workflows:
|
|
598
|
-
workflowSources:
|
|
627
|
+
workflows: z2.array(z2.string()).optional(),
|
|
628
|
+
workflowSources: z2.array(z2.string()).optional()
|
|
599
629
|
}))
|
|
600
630
|
});
|
|
601
|
-
var runnerDisconnectRequestSchema =
|
|
631
|
+
var runnerDisconnectRequestSchema = z2.strictObject({ hubEpoch: z2.string() });
|
|
602
632
|
var hubEpochRequestSchema = runnerDisconnectRequestSchema;
|
|
603
|
-
var runnerDisconnectPreviewSchema =
|
|
633
|
+
var runnerDisconnectPreviewSchema = z2.object({
|
|
604
634
|
runnerId: id,
|
|
605
|
-
name:
|
|
606
|
-
runs:
|
|
635
|
+
name: z2.string().nullable(),
|
|
636
|
+
runs: z2.array(z2.object({
|
|
607
637
|
runId: id,
|
|
608
|
-
label:
|
|
638
|
+
label: z2.string().optional(),
|
|
609
639
|
/** Working: executing now. Parked: waiting for a person, Runner released. Queued: not started yet. */
|
|
610
|
-
state:
|
|
640
|
+
state: z2.enum(["working", "parked", "queued"])
|
|
611
641
|
})),
|
|
612
|
-
hiddenRuns:
|
|
642
|
+
hiddenRuns: z2.number().int().nonnegative()
|
|
613
643
|
});
|
|
614
|
-
var runnerDisconnectResponseSchema =
|
|
615
|
-
disconnected:
|
|
644
|
+
var runnerDisconnectResponseSchema = z2.object({
|
|
645
|
+
disconnected: z2.literal(true),
|
|
616
646
|
/** How many Runs were Stopped with the reason `runner_disconnected`. */
|
|
617
|
-
stoppedRuns:
|
|
647
|
+
stoppedRuns: z2.number().int().nonnegative()
|
|
618
648
|
});
|
|
619
649
|
var runnerAdoptRequestSchema = hubEpochRequestSchema;
|
|
620
650
|
var connectStartRequestSchema = connectRedeemRequestSchema.omit({ code: true });
|
|
621
|
-
var connectStartResponseSchema =
|
|
651
|
+
var connectStartResponseSchema = z2.strictObject({
|
|
622
652
|
/** The machine's secret for polling; never shown. */
|
|
623
|
-
deviceCode:
|
|
653
|
+
deviceCode: z2.string().min(32).max(160),
|
|
624
654
|
code: connectCodeSchema,
|
|
625
655
|
expiresAt: sequence,
|
|
626
|
-
intervalSec:
|
|
656
|
+
intervalSec: z2.number().int().positive(),
|
|
627
657
|
/** The web console page that approves `code`. */
|
|
628
|
-
verificationUrl:
|
|
658
|
+
verificationUrl: z2.string().url()
|
|
629
659
|
});
|
|
630
|
-
var connectPollRequestSchema =
|
|
631
|
-
var connectPendingResponseSchema =
|
|
632
|
-
hostname:
|
|
633
|
-
os:
|
|
634
|
-
softwareVersion:
|
|
660
|
+
var connectPollRequestSchema = z2.strictObject({ deviceCode: z2.string().min(32).max(160) });
|
|
661
|
+
var connectPendingResponseSchema = z2.strictObject({
|
|
662
|
+
hostname: z2.string(),
|
|
663
|
+
os: z2.string(),
|
|
664
|
+
softwareVersion: z2.string(),
|
|
635
665
|
requestedAt: sequence,
|
|
636
666
|
expiresAt: sequence
|
|
637
667
|
});
|
|
638
|
-
var connectApproveRequestSchema =
|
|
639
|
-
code:
|
|
668
|
+
var connectApproveRequestSchema = z2.strictObject({
|
|
669
|
+
code: z2.string().min(8).max(16),
|
|
640
670
|
audience: audienceSchema,
|
|
641
|
-
hubEpoch:
|
|
671
|
+
hubEpoch: z2.string().optional()
|
|
642
672
|
});
|
|
643
|
-
var connectDenyRequestSchema =
|
|
673
|
+
var connectDenyRequestSchema = z2.strictObject({ code: z2.string().min(8).max(16) });
|
|
644
674
|
export {
|
|
675
|
+
CALIBRATION_MIN_RUNS,
|
|
676
|
+
CALIBRATION_WINDOW_DAYS,
|
|
645
677
|
SIZE_CLASS_CAPS,
|
|
646
678
|
SIZE_CLASS_FORECASTS,
|
|
647
679
|
abandonedConversationContinuationCapability,
|
|
648
680
|
attemptCost,
|
|
649
681
|
audienceSchema,
|
|
650
682
|
buildCloseReasonSchema,
|
|
683
|
+
calibrate,
|
|
684
|
+
calibrationSchema,
|
|
651
685
|
canonicalJson,
|
|
652
686
|
checkpointPathSchema,
|
|
653
687
|
checkpointSchema,
|
|
@@ -672,6 +706,7 @@ export {
|
|
|
672
706
|
delegationSchema,
|
|
673
707
|
delegationTokenPrefix,
|
|
674
708
|
forecastOfCap,
|
|
709
|
+
forecastOfClass,
|
|
675
710
|
grantSchema,
|
|
676
711
|
harnessReadinessSchema,
|
|
677
712
|
harnessSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drisp/protocol",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "Wire contract between a drisp runner and the hub: zod schemas, inferred types, and JSON Schema for the instance-socket frames, Run, Turn, Interruption, and the event stream",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|