@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.
Files changed (3) hide show
  1. package/dist/v2.d.ts +41 -1
  2. package/dist/v2.js +284 -249
  3. 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 = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
114
+ var runArtifactNameSchema = z2.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
85
115
  var runArtifactMaxBytes = 64 * 1024;
86
- var secretEnvironmentSchema = z.record(
87
- z.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_]+)$/),
88
- z.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
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 = z.strictObject({
91
- kind: z.literal("permission"),
92
- decision: z.enum(["allow", "deny"]),
93
- reason: z.string().max(4096).optional()
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 = z.string().min(1).max(160);
96
- var sequence = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
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 = z.iso.datetime();
99
- var scopeSchema = z.discriminatedUnion("visibility", [
100
- z.strictObject({ visibility: z.literal("organization") }),
101
- z.strictObject({ visibility: z.literal("private"), ownerUserId: id })
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 = z.array(InstalledWorkflowSchema).max(256);
104
- var harnessSchema = z.enum(["claude-code", "codex"]);
105
- var harnessReadinessSchema = z.strictObject({ installed: z.boolean(), signedIn: z.boolean() });
106
- var runnerReadinessSchema = z.strictObject({
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 = z.strictObject({
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: z.enum(["permission", "question", "guidance", "recovery", "waiting"]),
126
- message: z.string().max(16384),
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 = z.strictObject({
130
- name: z.string().min(1).max(128),
131
- version: z.string().min(1).max(128).optional()
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 = z.enum([
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 = z.enum([
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 = z.strictObject({ counted: sequence, cacheRead: sequence });
192
+ var runUsageSchema = z2.strictObject({ counted: sequence, cacheRead: sequence });
163
193
  var reportedUsage = { usage: runUsageSchema.optional() };
164
- var controlRecordSchema = z.discriminatedUnion("kind", [
194
+ var controlRecordSchema = z2.discriminatedUnion("kind", [
165
195
  /** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
166
- z.strictObject({ kind: z.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
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
- z.strictObject({ kind: z.literal("readiness.changed"), readiness: runnerReadinessSchema }),
169
- z.strictObject({ kind: z.literal("assignment.accepted"), runId: id, attemptId: id }),
170
- z.strictObject({
171
- kind: z.literal("assignment.rejected"),
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: z.string().max(1024)
204
+ reason: z2.string().max(1024)
175
205
  }),
176
- z.strictObject({
177
- kind: z.literal("run.started"),
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
- z.strictObject({ kind: z.literal("run.resumed"), ...factIdentity }),
183
- z.strictObject({
184
- kind: z.literal("run.attention"),
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: z.enum(["held", "released"]),
217
+ occupancy: z2.enum(["held", "released"]),
188
218
  historyThrough: sequence,
189
- continuation: z.discriminatedUnion("kind", [
190
- z.strictObject({ kind: z.literal("live_request") }),
191
- z.strictObject({ kind: z.literal("local_checkpoint"), checkpointId: id }),
192
- z.strictObject({ kind: z.literal("portable_checkpoint"), checkpointId: id }),
193
- z.strictObject({ kind: z.literal("repair_required"), detail: z.string().max(4096) })
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
- z.strictObject({
198
- kind: z.literal("run.finished"),
227
+ z2.strictObject({
228
+ kind: z2.literal("run.finished"),
199
229
  ...factIdentity,
200
- status: z.enum(["completed", "failed", "cancelled"]),
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: z.literal(true).optional(),
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
- z.strictObject({ kind: z.literal("run.usage"), runId: id, attemptId: id, ...runUsageSchema.shape }),
216
- z.strictObject({ kind: z.literal("command.applied"), runId: id, attemptId: id, commandId: id }),
217
- z.strictObject({
218
- kind: z.literal("command.rejected"),
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: z.string().max(1024)
252
+ reason: z2.string().max(1024)
223
253
  }),
224
- z.strictObject({ kind: z.literal("revoked_not_started"), runId: id, attemptId: id })
254
+ z2.strictObject({ kind: z2.literal("revoked_not_started"), runId: id, attemptId: id })
225
255
  ]);
226
- var repositoryRefSchema = z.string().min(1).max(512).regex(
256
+ var repositoryRefSchema = z2.string().min(1).max(512).regex(
227
257
  /^(?![-/])(?!.*\.\.)(?!.*@\{)(?!.*(?:^|\/)\.)(?!.*\.lock(?:\/|$))(?!.*\/\/)[^\x00-\x20\x7f~^:?*\[\\]+(?<![/.])$/
228
258
  );
229
- var repositoryWorkingDirectorySchema = z.string().min(1).max(1024).regex(
259
+ var repositoryWorkingDirectorySchema = z2.string().min(1).max(1024).regex(
230
260
  /^(?:\.|(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))[^\x00-\x1f\x7f\\:]+(?<!\/))$/
231
261
  );
232
262
  var repositoryIdentity = {
233
- repositoryId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
234
- installationId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
235
- owner: z.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
236
- name: z.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
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 = z.strictObject({
268
+ var repositoryBindingSchema = z2.strictObject({
239
269
  id,
240
- label: z.string().min(1).max(160),
270
+ label: z2.string().min(1).max(160),
241
271
  ...repositoryIdentity,
242
272
  defaultRef: repositoryRefSchema,
243
273
  workingDirectory: repositoryWorkingDirectorySchema,
244
- setupCommands: z.array(z.string().min(1).max(8192)).max(16),
274
+ setupCommands: z2.array(z2.string().min(1).max(8192)).max(16),
245
275
  revision: positive,
246
- enabled: z.boolean()
276
+ enabled: z2.boolean()
247
277
  });
248
- var repositorySourceSchema = z.strictObject({
278
+ var repositorySourceSchema = z2.strictObject({
249
279
  bindingId: id,
250
280
  ...repositoryIdentity,
251
281
  ref: repositoryRefSchema,
252
- commitSha: z.string().regex(/^[0-9a-f]{40}$/),
282
+ commitSha: z2.string().regex(/^[0-9a-f]{40}$/),
253
283
  branch: repositoryRefSchema,
254
284
  workingDirectory: repositoryWorkingDirectorySchema,
255
- setupCommands: z.array(z.string().min(1).max(8192)).max(16),
285
+ setupCommands: z2.array(z2.string().min(1).max(8192)).max(16),
256
286
  configRevision: positive
257
287
  });
258
- var workflowSourceSchema = z.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
259
- var workflowReferenceSchema = z.union([
260
- z.string().max(512),
261
- z.strictObject({
262
- name: z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
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: z.string().min(1).max(512).optional(),
265
- version: z.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
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 = z.strictObject({
272
- prompt: z.string().min(1).max(131072),
273
- projectDir: z.string().min(1).max(4096),
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 = z.string().min(1).max(160);
279
- var delegationSchema = z.strictObject({
280
- maxChildren: z.number().int().min(1).max(8),
281
- tokenBudget: z.number().int().positive().max(Number.MAX_SAFE_INTEGER)
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 = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
284
- var runParentIntentSchema = z.strictObject({ runId: id, tokenCap: tokenCapSchema.optional() });
285
- var runParentSchema = z.strictObject({ runId: id, tokenCap: tokenCapSchema });
286
- var commandSchema = z.strictObject({
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: z.discriminatedUnion("kind", [
292
- z.strictObject({
293
- kind: z.literal("start"),
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
- z.strictObject({ kind: z.literal("cancel") }),
310
- z.strictObject({ kind: z.literal("abandon") }),
311
- z.strictObject({ kind: z.literal("steer"), text: z.string().min(1).max(131072) }),
312
- z.strictObject({
313
- kind: z.literal("answer"),
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: z.json()
347
+ answer: z2.json()
318
348
  }),
319
- z.strictObject({
320
- kind: z.literal("resume"),
349
+ z2.strictObject({
350
+ kind: z2.literal("resume"),
321
351
  interruptionId: id,
322
- guidance: z.string().max(131072).optional()
352
+ guidance: z2.string().max(131072).optional()
323
353
  })
324
354
  ])
325
355
  });
326
- var grantSchema = z.strictObject({
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: z.enum(["start", "resume"]),
368
+ purpose: z2.enum(["start", "resume"]),
339
369
  spec: runSpecSchema,
340
- continuation: z.json().optional(),
370
+ continuation: z2.json().optional(),
341
371
  /** A new Run in a durable conversation; never resumes the predecessor's lifecycle. */
342
- previousRun: z.strictObject({
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: z.literal("abandoned").optional(),
348
- checkpoint: z.strictObject({ checkpointId: id, checksum: z.string().regex(/^[a-f0-9]{64}$/) }).optional()
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: z.strictObject({ checkpointId: id, checksum: z.string().regex(/^[a-f0-9]{64}$/) }).optional(),
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: z.string().min(32).max(256).optional(),
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: z.literal(true).optional()
386
+ reportUsage: z2.literal(true).optional()
357
387
  });
358
- var historyRecordSchema = z.strictObject({
388
+ var historyRecordSchema = z2.strictObject({
359
389
  eventId: id,
360
390
  attemptId: id,
361
391
  emittedAt: timestamp,
362
- kind: z.string().min(1).max(128),
363
- data: z.json()
392
+ kind: z2.string().min(1).max(128),
393
+ data: z2.json()
364
394
  });
365
- var runnerFrameSchema = z.discriminatedUnion("type", [
366
- z.strictObject({
367
- type: z.literal("hello"),
368
- role: z.literal("runner"),
369
- protocol: z.strictObject({ major: z.literal(2), minor: sequence }),
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: z.string().max(128),
373
- capabilities: z.array(z.string().max(128)).max(64),
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: z.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
408
+ control: z2.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
379
409
  }),
380
- z.strictObject({
381
- type: z.literal("control.batch"),
410
+ z2.strictObject({
411
+ type: z2.literal("control.batch"),
382
412
  firstSeq: positive,
383
- records: z.array(controlRecordSchema).min(1).max(128)
413
+ records: z2.array(controlRecordSchema).min(1).max(128)
384
414
  }),
385
- z.strictObject({
386
- type: z.literal("history.batch"),
415
+ z2.strictObject({
416
+ type: z2.literal("history.batch"),
387
417
  runId: id,
388
418
  firstSeq: positive,
389
- records: z.array(historyRecordSchema).min(1).max(128)
419
+ records: z2.array(historyRecordSchema).min(1).max(128)
390
420
  }),
391
- z.strictObject({ type: z.literal("ping"), nonce: id }),
392
- z.strictObject({
393
- type: z.literal("reconcile.page"),
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: z.boolean(),
397
- runs: z.array(
398
- z.strictObject({
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: z.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
432
+ phase: z2.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
403
433
  })
404
434
  ).max(128)
405
435
  })
406
436
  ]);
407
- var runViewSchema = z.object({
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: z.string().max(160).optional(),
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: z.object(delegationSchema.shape).optional(),
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: z.object({
427
- status: z.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
456
+ execution: z2.object({
457
+ status: z2.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
428
458
  revision: positive,
429
459
  attemptId: id,
430
- occupancy: z.enum(["held", "released"]),
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: z.enum(["queued", "dispatching", "admitted", "idle"]),
436
- closed: z.boolean(),
437
- closeReason: z.string().optional(),
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: z.boolean().optional(),
442
- canAbandon: z.boolean().optional(),
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: z.object({ id, state: z.enum(["pending", "ready"]), checksum: z.string().optional() }).optional()
476
+ checkpoint: z2.object({ id, state: z2.enum(["pending", "ready"]), checksum: z2.string().optional() }).optional()
447
477
  });
448
- var clientFrameSchema = z.discriminatedUnion("type", [
449
- z.strictObject({ type: z.literal("watch"), hubEpoch: id, runIds: z.array(id).max(100) }),
450
- z.strictObject({ type: z.literal("watch.ack"), subscriptionId: id, through: sequence }),
451
- z.strictObject({ type: z.literal("command.submit"), command: commandSchema }),
452
- z.strictObject({ type: z.literal("ping"), nonce: id })
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 = z.string().min(1).max(4096).refine(
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 = z.strictObject({
467
- version: z.literal(1),
468
- checkpointId: z.string().min(1),
469
- orgId: z.string().min(1),
470
- phase: z.enum(["parked", "terminal"]),
471
- runId: z.string().min(1),
472
- sessionId: z.string().min(1),
473
- sourceAttemptId: z.string().min(1),
474
- executionRevision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
475
- historyProduced: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
476
- historyAck: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
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: z.string().regex(/^[0-9a-f]{40,64}$/),
479
- gitBase: z.string().regex(/^[0-9a-f]{40,64}$/).optional(),
480
- gitBundle: z.string(),
481
- indexPatch: z.string(),
482
- files: z.array(
483
- z.strictObject({ path: checkpointPathSchema, content: z.string(), executable: z.boolean() })
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: z.array(checkpointPathSchema).max(1e5),
486
- sessionRows: z.array(z.strictObject({ kind: z.string(), id: z.string(), payload: z.string() })),
487
- history: z.array(
488
- z.strictObject({ seq: z.number().int().positive(), record: historyRecordSchema })
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 = z.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
493
- var connectCodeRequestSchema = z.strictObject({ hubEpoch: z.string() });
494
- var connectCodeResponseSchema = z.strictObject({
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 = z.strictObject({
499
- code: z.string().min(8).max(16),
528
+ var connectRedeemRequestSchema = z2.strictObject({
529
+ code: z2.string().min(8).max(16),
500
530
  installationId: id,
501
- hostname: z.string().min(1).max(255),
502
- os: z.string().min(1).max(64),
503
- softwareVersion: z.string().min(1).max(128)
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 = z.strictObject({
535
+ var connectRedeemResponseSchema = z2.strictObject({
506
536
  orgId: id,
507
- hubEpoch: z.string(),
537
+ hubEpoch: z2.string(),
508
538
  runnerId: id,
509
539
  installationId: id,
510
- name: z.string(),
511
- token: z.string().min(32),
540
+ name: z2.string(),
541
+ token: z2.string().min(32),
512
542
  credentialId: id,
513
543
  expiresAt: sequence
514
544
  });
515
- var connectAlreadyConnectedSchema = z.strictObject({
516
- error: z.literal("runner_already_connected"),
545
+ var connectAlreadyConnectedSchema = z2.strictObject({
546
+ error: z2.literal("runner_already_connected"),
517
547
  orgId: id,
518
548
  runnerId: id,
519
- name: z.string()
549
+ name: z2.string()
520
550
  });
521
- var audienceSchema = z.enum(["personal", "team"]);
522
- var runnerListEntrySchema = z.object({
551
+ var audienceSchema = z2.enum(["personal", "team"]);
552
+ var runnerListEntrySchema = z2.object({
523
553
  id,
524
- online: z.number(),
525
- capacity: z.number(),
526
- managed: z.number(),
527
- draining: z.number(),
528
- stopped: z.number(),
529
- name: z.string().nullable(),
530
- connectedBy: z.string().nullable(),
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: z.string().nullable(),
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: z.boolean().optional(),
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: z.boolean().optional(),
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: z.boolean().optional()
584
+ needsOwner: z2.boolean().optional()
555
585
  });
556
- var teamDefaultSchema = z.discriminatedUnion("kind", [
557
- z.strictObject({ kind: z.literal("runner"), runnerId: id }),
558
- z.strictObject({ kind: z.literal("profile"), profileId: id })
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 = z.strictObject({
561
- hubEpoch: z.string(),
590
+ var teamDefaultRequestSchema = z2.strictObject({
591
+ hubEpoch: z2.string(),
562
592
  teamDefault: teamDefaultSchema.nullable()
563
593
  });
564
- var runnerUpdateRequestSchema = z.strictObject({
565
- hubEpoch: z.string(),
566
- name: z.string().max(100).optional(),
567
- capacity: z.number().int().min(1).max(64).optional(),
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 = z.union([
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
- z.strictObject({ via: z.literal("personal"), runnerId: id }),
576
- z.strictObject({ via: z.literal("team_default"), runnerId: id }),
577
- z.strictObject({ via: z.literal("team_default"), profileId: id }),
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
- z.strictObject({ via: z.literal("none"), reason: z.enum(["no_runner_available", "runner_needs_owner"]) })
609
+ z2.strictObject({ via: z2.literal("none"), reason: z2.enum(["no_runner_available", "runner_needs_owner"]) })
580
610
  ]);
581
- var runnerListSchema = z.object({
582
- capabilities: z.record(z.string(), z.boolean()).optional(),
583
- historyRetentionDays: z.number().int().positive().nullable().optional(),
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: z.object({ userId: z.string(), admin: z.boolean() }).optional(),
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: z.string().optional(),
590
- runners: z.array(runnerListEntrySchema),
591
- profiles: z.array(z.object({
592
- id: z.string(),
593
- label: z.string(),
594
- projectDir: z.string(),
595
- repositoryRequired: z.boolean().optional(),
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: z.array(z.string()).optional(),
598
- workflowSources: z.array(z.string()).optional()
627
+ workflows: z2.array(z2.string()).optional(),
628
+ workflowSources: z2.array(z2.string()).optional()
599
629
  }))
600
630
  });
601
- var runnerDisconnectRequestSchema = z.strictObject({ hubEpoch: z.string() });
631
+ var runnerDisconnectRequestSchema = z2.strictObject({ hubEpoch: z2.string() });
602
632
  var hubEpochRequestSchema = runnerDisconnectRequestSchema;
603
- var runnerDisconnectPreviewSchema = z.object({
633
+ var runnerDisconnectPreviewSchema = z2.object({
604
634
  runnerId: id,
605
- name: z.string().nullable(),
606
- runs: z.array(z.object({
635
+ name: z2.string().nullable(),
636
+ runs: z2.array(z2.object({
607
637
  runId: id,
608
- label: z.string().optional(),
638
+ label: z2.string().optional(),
609
639
  /** Working: executing now. Parked: waiting for a person, Runner released. Queued: not started yet. */
610
- state: z.enum(["working", "parked", "queued"])
640
+ state: z2.enum(["working", "parked", "queued"])
611
641
  })),
612
- hiddenRuns: z.number().int().nonnegative()
642
+ hiddenRuns: z2.number().int().nonnegative()
613
643
  });
614
- var runnerDisconnectResponseSchema = z.object({
615
- disconnected: z.literal(true),
644
+ var runnerDisconnectResponseSchema = z2.object({
645
+ disconnected: z2.literal(true),
616
646
  /** How many Runs were Stopped with the reason `runner_disconnected`. */
617
- stoppedRuns: z.number().int().nonnegative()
647
+ stoppedRuns: z2.number().int().nonnegative()
618
648
  });
619
649
  var runnerAdoptRequestSchema = hubEpochRequestSchema;
620
650
  var connectStartRequestSchema = connectRedeemRequestSchema.omit({ code: true });
621
- var connectStartResponseSchema = z.strictObject({
651
+ var connectStartResponseSchema = z2.strictObject({
622
652
  /** The machine's secret for polling; never shown. */
623
- deviceCode: z.string().min(32).max(160),
653
+ deviceCode: z2.string().min(32).max(160),
624
654
  code: connectCodeSchema,
625
655
  expiresAt: sequence,
626
- intervalSec: z.number().int().positive(),
656
+ intervalSec: z2.number().int().positive(),
627
657
  /** The web console page that approves `code`. */
628
- verificationUrl: z.string().url()
658
+ verificationUrl: z2.string().url()
629
659
  });
630
- var connectPollRequestSchema = z.strictObject({ deviceCode: z.string().min(32).max(160) });
631
- var connectPendingResponseSchema = z.strictObject({
632
- hostname: z.string(),
633
- os: z.string(),
634
- softwareVersion: z.string(),
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 = z.strictObject({
639
- code: z.string().min(8).max(16),
668
+ var connectApproveRequestSchema = z2.strictObject({
669
+ code: z2.string().min(8).max(16),
640
670
  audience: audienceSchema,
641
- hubEpoch: z.string().optional()
671
+ hubEpoch: z2.string().optional()
642
672
  });
643
- var connectDenyRequestSchema = z.strictObject({ code: z.string().min(8).max(16) });
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.4",
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",