@drisp/protocol 0.6.0 → 0.6.2
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/chunk-HMYWICNI.js +202 -0
- package/dist/domain-B-kg2pa_.d.ts +376 -0
- package/dist/index.d.ts +2 -377
- package/dist/index.js +153 -319
- package/dist/v2.d.ts +1283 -0
- package/dist/v2.js +613 -0
- package/package.json +56 -51
- package/schema/v2/checkpoint.json +566 -0
- package/schema/v2/client.json +479 -0
- package/schema/v2/command.json +388 -0
- package/schema/v2/connectAlreadyConnected.json +30 -0
- package/schema/v2/connectApproveRequest.json +26 -0
- package/schema/v2/connectCode.json +20 -0
- package/schema/v2/connectCodeRequest.json +13 -0
- package/schema/v2/connectDenyRequest.json +15 -0
- package/schema/v2/connectPending.json +33 -0
- package/schema/v2/connectPollRequest.json +15 -0
- package/schema/v2/connectRedeem.json +52 -0
- package/schema/v2/connectRedeemRequest.json +39 -0
- package/schema/v2/connectStart.json +37 -0
- package/schema/v2/connectStartRequest.json +33 -0
- package/schema/v2/grant.json +337 -0
- package/schema/v2/permissionAnswer.json +26 -0
- package/schema/v2/run.json +620 -0
- package/schema/v2/runner.json +1090 -0
- package/schema/v2/runnerAdoptRequest.json +13 -0
- package/schema/v2/runnerDisconnect.json +20 -0
- package/schema/v2/runnerDisconnectPreview.json +58 -0
- package/schema/v2/runnerDisconnectRequest.json +13 -0
- package/schema/v2/runnerList.json +459 -0
- package/schema/v2/runnerUpdateRequest.json +29 -0
- package/schema/v2/teamDefaultRequest.json +63 -0
package/dist/v2.js
ADDED
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InstalledWorkflowSchema
|
|
3
|
+
} from "./chunk-HMYWICNI.js";
|
|
4
|
+
|
|
5
|
+
// src/v2.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
// src/history.ts
|
|
9
|
+
function readableHistory(records) {
|
|
10
|
+
const pending = /* @__PURE__ */ new Map();
|
|
11
|
+
const result = [];
|
|
12
|
+
for (const record of records) {
|
|
13
|
+
if (record.kind !== "history.fragment") {
|
|
14
|
+
result.push(record);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const value = record.data;
|
|
18
|
+
if (!value || value.version !== 1 || typeof value.eventId !== "string" || typeof value.kind !== "string" || typeof value.text !== "string" || !Number.isSafeInteger(value.index) || !Number.isSafeInteger(value.total))
|
|
19
|
+
continue;
|
|
20
|
+
const index = value.index, total = value.total;
|
|
21
|
+
if (total < 1 || total > 1024 || index < 0 || index >= total) continue;
|
|
22
|
+
if (index === 0) pending.set(value.eventId, { kind: value.kind, next: 0, total, text: "" });
|
|
23
|
+
const item = pending.get(value.eventId);
|
|
24
|
+
if (!item || item.next !== index || item.total !== total || item.kind !== value.kind) {
|
|
25
|
+
pending.delete(value.eventId);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
item.text += value.text;
|
|
29
|
+
item.next++;
|
|
30
|
+
if (item.text.length > 16 * 1024 * 1024) {
|
|
31
|
+
pending.delete(value.eventId);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (item.next === total) {
|
|
35
|
+
pending.delete(value.eventId);
|
|
36
|
+
try {
|
|
37
|
+
result.push({
|
|
38
|
+
...record,
|
|
39
|
+
eventId: value.eventId,
|
|
40
|
+
kind: item.kind,
|
|
41
|
+
data: JSON.parse(item.text)
|
|
42
|
+
});
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/v2.ts
|
|
51
|
+
var protocolVersion = { major: 2, minor: 1 };
|
|
52
|
+
var conversationContinuationCapability = "conversation_continuation";
|
|
53
|
+
var abandonedConversationContinuationCapability = "abandoned_conversation_continuation";
|
|
54
|
+
var repositoryAccessCapability = "repository_checkout_v1";
|
|
55
|
+
var workflowInstallCapability = "workflow_install_v1";
|
|
56
|
+
var secretEnvironmentSchema = z.record(
|
|
57
|
+
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_]+)$/),
|
|
58
|
+
z.string().regex(/^projects\/[a-zA-Z0-9-]+\/secrets\/[a-zA-Z0-9_-]+\/versions\/(?:latest|[0-9]+)$/)
|
|
59
|
+
);
|
|
60
|
+
var permissionAnswerSchema = z.strictObject({
|
|
61
|
+
kind: z.literal("permission"),
|
|
62
|
+
decision: z.enum(["allow", "deny"]),
|
|
63
|
+
reason: z.string().max(4096).optional()
|
|
64
|
+
});
|
|
65
|
+
var id = z.string().min(1).max(160);
|
|
66
|
+
var sequence = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
67
|
+
var positive = sequence.refine((n) => n > 0);
|
|
68
|
+
var timestamp = z.iso.datetime();
|
|
69
|
+
var scopeSchema = z.discriminatedUnion("visibility", [
|
|
70
|
+
z.strictObject({ visibility: z.literal("organization") }),
|
|
71
|
+
z.strictObject({ visibility: z.literal("private"), ownerUserId: id })
|
|
72
|
+
]);
|
|
73
|
+
var installedWorkflowsSchema = z.array(InstalledWorkflowSchema).max(256);
|
|
74
|
+
var harnessSchema = z.enum(["claude-code", "codex"]);
|
|
75
|
+
var harnessReadinessSchema = z.strictObject({ installed: z.boolean(), signedIn: z.boolean() });
|
|
76
|
+
var runnerReadinessSchema = z.strictObject({
|
|
77
|
+
"claude-code": harnessReadinessSchema.optional(),
|
|
78
|
+
codex: harnessReadinessSchema.optional()
|
|
79
|
+
});
|
|
80
|
+
var harnessInstallCommands = {
|
|
81
|
+
"claude-code": "npm i -g @anthropic-ai/claude-code",
|
|
82
|
+
codex: "npm i -g @openai/codex"
|
|
83
|
+
};
|
|
84
|
+
var harnessSignInCommands = { "claude-code": "claude auth login", codex: "codex login" };
|
|
85
|
+
function readinessFixCommand(harness, readiness) {
|
|
86
|
+
if (!readiness.installed) return harnessInstallCommands[harness];
|
|
87
|
+
if (!readiness.signedIn) return harnessSignInCommands[harness];
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
var runnerUpdateCommand = "npm i -g @drisp/cli";
|
|
91
|
+
var interruptionSchema = z.strictObject({
|
|
92
|
+
interruptionId: id,
|
|
93
|
+
revision: positive,
|
|
94
|
+
kind: z.enum(["permission", "question", "guidance", "recovery"]),
|
|
95
|
+
message: z.string().max(16384),
|
|
96
|
+
requestId: id.optional()
|
|
97
|
+
});
|
|
98
|
+
var workflowIdentitySchema = z.strictObject({
|
|
99
|
+
name: z.string().min(1).max(128),
|
|
100
|
+
version: z.string().min(1).max(128).optional()
|
|
101
|
+
});
|
|
102
|
+
var factIdentity = {
|
|
103
|
+
runId: id,
|
|
104
|
+
attemptId: id,
|
|
105
|
+
executionRevision: positive,
|
|
106
|
+
emittedAt: timestamp
|
|
107
|
+
};
|
|
108
|
+
var controlRecordSchema = z.discriminatedUnion("kind", [
|
|
109
|
+
/** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
|
|
110
|
+
z.strictObject({ kind: z.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
|
|
111
|
+
/** Instance-scoped, not tied to a Run: the Runner's full Readiness, sent when it changes after hello. */
|
|
112
|
+
z.strictObject({ kind: z.literal("readiness.changed"), readiness: runnerReadinessSchema }),
|
|
113
|
+
z.strictObject({ kind: z.literal("assignment.accepted"), runId: id, attemptId: id }),
|
|
114
|
+
z.strictObject({
|
|
115
|
+
kind: z.literal("assignment.rejected"),
|
|
116
|
+
runId: id,
|
|
117
|
+
attemptId: id,
|
|
118
|
+
reason: z.string().max(1024)
|
|
119
|
+
}),
|
|
120
|
+
z.strictObject({
|
|
121
|
+
kind: z.literal("run.started"),
|
|
122
|
+
...factIdentity,
|
|
123
|
+
/** Absent from runners that predate Workflow reporting. */
|
|
124
|
+
workflow: workflowIdentitySchema.optional()
|
|
125
|
+
}),
|
|
126
|
+
z.strictObject({ kind: z.literal("run.resumed"), ...factIdentity }),
|
|
127
|
+
z.strictObject({
|
|
128
|
+
kind: z.literal("run.attention"),
|
|
129
|
+
...factIdentity,
|
|
130
|
+
interruption: interruptionSchema,
|
|
131
|
+
occupancy: z.enum(["held", "released"]),
|
|
132
|
+
historyThrough: sequence,
|
|
133
|
+
continuation: z.discriminatedUnion("kind", [
|
|
134
|
+
z.strictObject({ kind: z.literal("live_request") }),
|
|
135
|
+
z.strictObject({ kind: z.literal("local_checkpoint"), checkpointId: id }),
|
|
136
|
+
z.strictObject({ kind: z.literal("portable_checkpoint"), checkpointId: id }),
|
|
137
|
+
z.strictObject({ kind: z.literal("repair_required"), detail: z.string().max(4096) })
|
|
138
|
+
])
|
|
139
|
+
}),
|
|
140
|
+
z.strictObject({
|
|
141
|
+
kind: z.literal("run.finished"),
|
|
142
|
+
...factIdentity,
|
|
143
|
+
status: z.enum(["completed", "failed", "cancelled"]),
|
|
144
|
+
historyThrough: sequence,
|
|
145
|
+
/** No setup/harness executed and no workspace was produced; safe to retire without export. */
|
|
146
|
+
workspaceUnavailable: z.literal(true).optional()
|
|
147
|
+
}),
|
|
148
|
+
z.strictObject({ kind: z.literal("command.applied"), runId: id, attemptId: id, commandId: id }),
|
|
149
|
+
z.strictObject({
|
|
150
|
+
kind: z.literal("command.rejected"),
|
|
151
|
+
runId: id,
|
|
152
|
+
attemptId: id,
|
|
153
|
+
commandId: id,
|
|
154
|
+
reason: z.string().max(1024)
|
|
155
|
+
}),
|
|
156
|
+
z.strictObject({ kind: z.literal("revoked_not_started"), runId: id, attemptId: id })
|
|
157
|
+
]);
|
|
158
|
+
var repositoryRefSchema = z.string().min(1).max(512).regex(
|
|
159
|
+
/^(?![-/])(?!.*\.\.)(?!.*@\{)(?!.*(?:^|\/)\.)(?!.*\.lock(?:\/|$))(?!.*\/\/)[^\x00-\x20\x7f~^:?*\[\\]+(?<![/.])$/
|
|
160
|
+
);
|
|
161
|
+
var repositoryWorkingDirectorySchema = z.string().min(1).max(1024).regex(
|
|
162
|
+
/^(?:\.|(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))[^\x00-\x1f\x7f\\:]+(?<!\/))$/
|
|
163
|
+
);
|
|
164
|
+
var repositoryIdentity = {
|
|
165
|
+
repositoryId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
166
|
+
installationId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
167
|
+
owner: z.string().min(1).max(100).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/),
|
|
168
|
+
name: z.string().min(1).max(100).regex(/^(?!\.{1,2}$)[a-zA-Z0-9_.-]+$/)
|
|
169
|
+
};
|
|
170
|
+
var repositoryBindingSchema = z.strictObject({
|
|
171
|
+
id,
|
|
172
|
+
label: z.string().min(1).max(160),
|
|
173
|
+
...repositoryIdentity,
|
|
174
|
+
defaultRef: repositoryRefSchema,
|
|
175
|
+
workingDirectory: repositoryWorkingDirectorySchema,
|
|
176
|
+
setupCommands: z.array(z.string().min(1).max(8192)).max(16),
|
|
177
|
+
revision: positive,
|
|
178
|
+
enabled: z.boolean()
|
|
179
|
+
});
|
|
180
|
+
var repositorySourceSchema = z.strictObject({
|
|
181
|
+
bindingId: id,
|
|
182
|
+
...repositoryIdentity,
|
|
183
|
+
ref: repositoryRefSchema,
|
|
184
|
+
commitSha: z.string().regex(/^[0-9a-f]{40}$/),
|
|
185
|
+
branch: repositoryRefSchema,
|
|
186
|
+
workingDirectory: repositoryWorkingDirectorySchema,
|
|
187
|
+
setupCommands: z.array(z.string().min(1).max(8192)).max(16),
|
|
188
|
+
configRevision: positive
|
|
189
|
+
});
|
|
190
|
+
var workflowSourceSchema = z.string().max(201).regex(/^[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*$/);
|
|
191
|
+
var workflowReferenceSchema = z.union([
|
|
192
|
+
z.string().max(512),
|
|
193
|
+
z.strictObject({
|
|
194
|
+
name: z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),
|
|
195
|
+
source: workflowSourceSchema.optional(),
|
|
196
|
+
ref: z.string().min(1).max(512).optional(),
|
|
197
|
+
version: z.string().min(1).max(128).regex(/^\d[A-Za-z0-9_.+-]*$/).optional()
|
|
198
|
+
})
|
|
199
|
+
]);
|
|
200
|
+
var workflowName = (workflow) => typeof workflow === "object" ? workflow.name : workflow;
|
|
201
|
+
var installReference = (workflow) => typeof workflow === "object" && workflow.source !== void 0 ? workflow : void 0;
|
|
202
|
+
var sameWorkflow = (a, b) => canonicalJson(a ?? null) === canonicalJson(b ?? null);
|
|
203
|
+
var runSpecSchema = z.strictObject({
|
|
204
|
+
prompt: z.string().min(1).max(131072),
|
|
205
|
+
projectDir: z.string().min(1).max(4096),
|
|
206
|
+
harness: harnessSchema,
|
|
207
|
+
workflow: workflowReferenceSchema.optional(),
|
|
208
|
+
repository: repositorySourceSchema.optional()
|
|
209
|
+
});
|
|
210
|
+
var commandSchema = z.strictObject({
|
|
211
|
+
commandId: id,
|
|
212
|
+
hubEpoch: id,
|
|
213
|
+
runId: id,
|
|
214
|
+
expectedRecordRevision: sequence.optional(),
|
|
215
|
+
intent: z.discriminatedUnion("kind", [
|
|
216
|
+
z.strictObject({
|
|
217
|
+
kind: z.literal("start"),
|
|
218
|
+
sessionId: id,
|
|
219
|
+
/**
|
|
220
|
+
* Absent: the Hub resolves the Runner member-first (root ADR-0005): the Session's conversation Runner, else
|
|
221
|
+
* the starting member's own ready Personal Runner, else the Team default, else the start is refused.
|
|
222
|
+
*/
|
|
223
|
+
runnerId: id.optional(),
|
|
224
|
+
computeProfileId: id.optional(),
|
|
225
|
+
scope: scopeSchema,
|
|
226
|
+
spec: runSpecSchema
|
|
227
|
+
}),
|
|
228
|
+
z.strictObject({ kind: z.literal("cancel") }),
|
|
229
|
+
z.strictObject({ kind: z.literal("abandon") }),
|
|
230
|
+
z.strictObject({ kind: z.literal("steer"), text: z.string().min(1).max(131072) }),
|
|
231
|
+
z.strictObject({
|
|
232
|
+
kind: z.literal("answer"),
|
|
233
|
+
interruptionId: id,
|
|
234
|
+
expectedInterruptionRevision: positive,
|
|
235
|
+
requestId: id.optional(),
|
|
236
|
+
answer: z.json()
|
|
237
|
+
}),
|
|
238
|
+
z.strictObject({
|
|
239
|
+
kind: z.literal("resume"),
|
|
240
|
+
interruptionId: id,
|
|
241
|
+
guidance: z.string().max(131072).optional()
|
|
242
|
+
})
|
|
243
|
+
])
|
|
244
|
+
});
|
|
245
|
+
var grantSchema = z.strictObject({
|
|
246
|
+
commandId: id,
|
|
247
|
+
hubEpoch: id,
|
|
248
|
+
runId: id,
|
|
249
|
+
sessionId: id,
|
|
250
|
+
runnerId: id,
|
|
251
|
+
installationId: id,
|
|
252
|
+
attemptId: id,
|
|
253
|
+
generation: positive,
|
|
254
|
+
baseExecutionRevision: sequence,
|
|
255
|
+
baseHistorySeq: sequence,
|
|
256
|
+
cloudHistoryThrough: sequence,
|
|
257
|
+
purpose: z.enum(["start", "resume"]),
|
|
258
|
+
spec: runSpecSchema,
|
|
259
|
+
continuation: z.json().optional(),
|
|
260
|
+
/** A new Run in a durable conversation; never resumes the predecessor's lifecycle. */
|
|
261
|
+
previousRun: z.strictObject({
|
|
262
|
+
runId: id,
|
|
263
|
+
executionRevision: sequence,
|
|
264
|
+
historyProduced: sequence,
|
|
265
|
+
/** Hub-confirmed administrative closure; allows an exact parked predecessor snapshot. */
|
|
266
|
+
closeReason: z.literal("abandoned").optional(),
|
|
267
|
+
checkpoint: z.strictObject({ checkpointId: id, checksum: z.string().regex(/^[a-f0-9]{64}$/) }).optional()
|
|
268
|
+
}).optional(),
|
|
269
|
+
checkpoint: z.strictObject({ checkpointId: id, checksum: z.string().regex(/^[a-f0-9]{64}$/) }).optional()
|
|
270
|
+
});
|
|
271
|
+
var historyRecordSchema = z.strictObject({
|
|
272
|
+
eventId: id,
|
|
273
|
+
attemptId: id,
|
|
274
|
+
emittedAt: timestamp,
|
|
275
|
+
kind: z.string().min(1).max(128),
|
|
276
|
+
data: z.json()
|
|
277
|
+
});
|
|
278
|
+
var runnerFrameSchema = z.discriminatedUnion("type", [
|
|
279
|
+
z.strictObject({
|
|
280
|
+
type: z.literal("hello"),
|
|
281
|
+
role: z.literal("runner"),
|
|
282
|
+
protocol: z.strictObject({ major: z.literal(2), minor: sequence }),
|
|
283
|
+
runnerId: id,
|
|
284
|
+
installationId: id,
|
|
285
|
+
softwareVersion: z.string().max(128),
|
|
286
|
+
capabilities: z.array(z.string().max(128)).max(64),
|
|
287
|
+
/** Absent from older runners: the Hub treats the inventory as unknown, never as empty. */
|
|
288
|
+
workflows: installedWorkflowsSchema.optional(),
|
|
289
|
+
/** Absent from older runners, and from a runner that has not finished its first check: unknown, not "not ready". */
|
|
290
|
+
readiness: runnerReadinessSchema.optional(),
|
|
291
|
+
control: z.strictObject({ firstRetainedSeq: positive, lastProducedSeq: sequence })
|
|
292
|
+
}),
|
|
293
|
+
z.strictObject({
|
|
294
|
+
type: z.literal("control.batch"),
|
|
295
|
+
firstSeq: positive,
|
|
296
|
+
records: z.array(controlRecordSchema).min(1).max(128)
|
|
297
|
+
}),
|
|
298
|
+
z.strictObject({
|
|
299
|
+
type: z.literal("history.batch"),
|
|
300
|
+
runId: id,
|
|
301
|
+
firstSeq: positive,
|
|
302
|
+
records: z.array(historyRecordSchema).min(1).max(128)
|
|
303
|
+
}),
|
|
304
|
+
z.strictObject({ type: z.literal("ping"), nonce: id }),
|
|
305
|
+
z.strictObject({
|
|
306
|
+
type: z.literal("reconcile.page"),
|
|
307
|
+
inventoryId: id.default("single-page"),
|
|
308
|
+
page: sequence.default(0),
|
|
309
|
+
complete: z.boolean(),
|
|
310
|
+
runs: z.array(
|
|
311
|
+
z.strictObject({
|
|
312
|
+
runId: id,
|
|
313
|
+
attemptId: id,
|
|
314
|
+
executionRevision: sequence,
|
|
315
|
+
phase: z.enum(["admitted", "prepared", "executing", "parked", "terminal", "recovery"])
|
|
316
|
+
})
|
|
317
|
+
).max(128)
|
|
318
|
+
})
|
|
319
|
+
]);
|
|
320
|
+
var runViewSchema = z.object({
|
|
321
|
+
runId: id,
|
|
322
|
+
sessionId: id,
|
|
323
|
+
runnerId: id,
|
|
324
|
+
computeProfileId: id.optional(),
|
|
325
|
+
scope: scopeSchema,
|
|
326
|
+
recordRevision: positive,
|
|
327
|
+
label: z.string().max(160).optional(),
|
|
328
|
+
/** Resolved by the runner at start; absent until the Run starts and for runners that predate reporting. */
|
|
329
|
+
workflow: workflowIdentitySchema.optional(),
|
|
330
|
+
execution: z.object({
|
|
331
|
+
status: z.enum(["running", "awaiting_attention", "completed", "failed", "cancelled"]),
|
|
332
|
+
revision: positive,
|
|
333
|
+
attemptId: id,
|
|
334
|
+
occupancy: z.enum(["held", "released"]),
|
|
335
|
+
startedAt: timestamp.optional(),
|
|
336
|
+
endedAt: timestamp.optional(),
|
|
337
|
+
interruption: interruptionSchema.optional()
|
|
338
|
+
}).nullable(),
|
|
339
|
+
scheduling: z.enum(["queued", "dispatching", "admitted", "idle"]),
|
|
340
|
+
closed: z.boolean(),
|
|
341
|
+
closeReason: z.string().optional(),
|
|
342
|
+
cancellation: id.optional(),
|
|
343
|
+
pendingResume: commandSchema.shape.intent.optional(),
|
|
344
|
+
/** Derived per viewer; absent on older Hubs. Never grants execution authority. */
|
|
345
|
+
runnerStopped: z.boolean().optional(),
|
|
346
|
+
canAbandon: z.boolean().optional(),
|
|
347
|
+
historyThrough: sequence,
|
|
348
|
+
expectedHistoryThrough: sequence.optional(),
|
|
349
|
+
createdAt: sequence,
|
|
350
|
+
checkpoint: z.object({ id, state: z.enum(["pending", "ready"]), checksum: z.string().optional() }).optional()
|
|
351
|
+
});
|
|
352
|
+
var clientFrameSchema = z.discriminatedUnion("type", [
|
|
353
|
+
z.strictObject({ type: z.literal("watch"), hubEpoch: id, runIds: z.array(id).max(100) }),
|
|
354
|
+
z.strictObject({ type: z.literal("watch.ack"), subscriptionId: id, through: sequence }),
|
|
355
|
+
z.strictObject({ type: z.literal("command.submit"), command: commandSchema }),
|
|
356
|
+
z.strictObject({ type: z.literal("ping"), nonce: id })
|
|
357
|
+
]);
|
|
358
|
+
function canonicalJson(value) {
|
|
359
|
+
if (value === null || typeof value !== "object") {
|
|
360
|
+
const encoded = JSON.stringify(value);
|
|
361
|
+
if (encoded === void 0) throw new Error("Non-JSON value");
|
|
362
|
+
return encoded;
|
|
363
|
+
}
|
|
364
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
365
|
+
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(",")}}`;
|
|
366
|
+
}
|
|
367
|
+
var checkpointPathSchema = z.string().min(1).max(4096).refine(
|
|
368
|
+
(path) => !path.startsWith("/") && !path.includes("\\") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".." && part !== ".git")
|
|
369
|
+
);
|
|
370
|
+
var checkpointSchema = z.strictObject({
|
|
371
|
+
version: z.literal(1),
|
|
372
|
+
checkpointId: z.string().min(1),
|
|
373
|
+
orgId: z.string().min(1),
|
|
374
|
+
phase: z.enum(["parked", "terminal"]),
|
|
375
|
+
runId: z.string().min(1),
|
|
376
|
+
sessionId: z.string().min(1),
|
|
377
|
+
sourceAttemptId: z.string().min(1),
|
|
378
|
+
executionRevision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
379
|
+
historyProduced: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
380
|
+
historyAck: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
381
|
+
grant: grantSchema,
|
|
382
|
+
gitHead: z.string().regex(/^[0-9a-f]{40,64}$/),
|
|
383
|
+
gitBase: z.string().regex(/^[0-9a-f]{40,64}$/).optional(),
|
|
384
|
+
gitBundle: z.string(),
|
|
385
|
+
indexPatch: z.string(),
|
|
386
|
+
files: z.array(
|
|
387
|
+
z.strictObject({ path: checkpointPathSchema, content: z.string(), executable: z.boolean() })
|
|
388
|
+
).max(1e5),
|
|
389
|
+
deleted: z.array(checkpointPathSchema).max(1e5),
|
|
390
|
+
sessionRows: z.array(z.strictObject({ kind: z.string(), id: z.string(), payload: z.string() })),
|
|
391
|
+
history: z.array(
|
|
392
|
+
z.strictObject({ seq: z.number().int().positive(), record: historyRecordSchema })
|
|
393
|
+
)
|
|
394
|
+
});
|
|
395
|
+
var connectCodeAlphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
396
|
+
var connectCodeSchema = z.string().regex(/^[A-HJKMNP-Z2-9]{8}$/);
|
|
397
|
+
var connectCodeRequestSchema = z.strictObject({ hubEpoch: z.string() });
|
|
398
|
+
var connectCodeResponseSchema = z.strictObject({
|
|
399
|
+
code: connectCodeSchema,
|
|
400
|
+
expiresAt: sequence
|
|
401
|
+
});
|
|
402
|
+
var connectRedeemRequestSchema = z.strictObject({
|
|
403
|
+
code: z.string().min(8).max(16),
|
|
404
|
+
installationId: id,
|
|
405
|
+
hostname: z.string().min(1).max(255),
|
|
406
|
+
os: z.string().min(1).max(64),
|
|
407
|
+
softwareVersion: z.string().min(1).max(128)
|
|
408
|
+
});
|
|
409
|
+
var connectRedeemResponseSchema = z.strictObject({
|
|
410
|
+
orgId: id,
|
|
411
|
+
hubEpoch: z.string(),
|
|
412
|
+
runnerId: id,
|
|
413
|
+
installationId: id,
|
|
414
|
+
name: z.string(),
|
|
415
|
+
token: z.string().min(32),
|
|
416
|
+
credentialId: id,
|
|
417
|
+
expiresAt: sequence
|
|
418
|
+
});
|
|
419
|
+
var connectAlreadyConnectedSchema = z.strictObject({
|
|
420
|
+
error: z.literal("runner_already_connected"),
|
|
421
|
+
orgId: id,
|
|
422
|
+
runnerId: id,
|
|
423
|
+
name: z.string()
|
|
424
|
+
});
|
|
425
|
+
var audienceSchema = z.enum(["personal", "team"]);
|
|
426
|
+
var runnerListEntrySchema = z.object({
|
|
427
|
+
id,
|
|
428
|
+
online: z.number(),
|
|
429
|
+
capacity: z.number(),
|
|
430
|
+
managed: z.number(),
|
|
431
|
+
draining: z.number(),
|
|
432
|
+
stopped: z.number(),
|
|
433
|
+
name: z.string().nullable(),
|
|
434
|
+
connectedBy: z.string().nullable(),
|
|
435
|
+
audience: audienceSchema.nullable(),
|
|
436
|
+
softwareVersion: z.string().nullable(),
|
|
437
|
+
/** Milliseconds since the epoch of the last hello or disconnect; null before the first connection. */
|
|
438
|
+
lastSeen: sequence.nullable(),
|
|
439
|
+
/** Absent when the runner has not reported an inventory: unknown, not none. */
|
|
440
|
+
workflows: installedWorkflowsSchema.optional(),
|
|
441
|
+
/**
|
|
442
|
+
* True when the viewer may not rename it, change its capacity or change its Audience: a teammate's Personal
|
|
443
|
+
* Runner seen by an admin (who may still Disconnect it), or a Runner a member did not connect. Absent from Hubs
|
|
444
|
+
* older than Audience, like the list's `viewer`, `teamDefault` and `runsGoTo`.
|
|
445
|
+
*/
|
|
446
|
+
readOnly: z.boolean().optional(),
|
|
447
|
+
/** What the Runner last reported; absent when it never has (an older runner, or one not yet connected). */
|
|
448
|
+
readiness: runnerReadinessSchema.optional(),
|
|
449
|
+
/**
|
|
450
|
+
* True when the Runner reported a version below the Hub's minimum: it is listed as "Update required" and takes no
|
|
451
|
+
* Runs until it is updated (`runnerUpdateCommand`). Absent from Hubs older than Readiness.
|
|
452
|
+
*/
|
|
453
|
+
updateRequired: z.boolean().optional(),
|
|
454
|
+
/**
|
|
455
|
+
* True while it is paused as "Needs an owner": the member who connected this Team Runner left the Team, so it
|
|
456
|
+
* takes no Runs until an admin adopts it (`/runners/{id}/adopt`) or Disconnects it. Absent from older Hubs.
|
|
457
|
+
*/
|
|
458
|
+
needsOwner: z.boolean().optional()
|
|
459
|
+
});
|
|
460
|
+
var teamDefaultSchema = z.discriminatedUnion("kind", [
|
|
461
|
+
z.strictObject({ kind: z.literal("runner"), runnerId: id }),
|
|
462
|
+
z.strictObject({ kind: z.literal("profile"), profileId: id })
|
|
463
|
+
]);
|
|
464
|
+
var teamDefaultRequestSchema = z.strictObject({
|
|
465
|
+
hubEpoch: z.string(),
|
|
466
|
+
teamDefault: teamDefaultSchema.nullable()
|
|
467
|
+
});
|
|
468
|
+
var runnerUpdateRequestSchema = z.strictObject({
|
|
469
|
+
hubEpoch: z.string(),
|
|
470
|
+
name: z.string().max(100).optional(),
|
|
471
|
+
capacity: z.number().int().min(1).max(64).optional(),
|
|
472
|
+
audience: audienceSchema.optional()
|
|
473
|
+
}).refine(
|
|
474
|
+
(update) => update.name !== void 0 || update.capacity !== void 0 || update.audience !== void 0,
|
|
475
|
+
{ message: "nothing to update" }
|
|
476
|
+
);
|
|
477
|
+
var runsGoToSchema = z.union([
|
|
478
|
+
/** The viewer's own Runner: Personal, or one they connected that was widened to Team (DRI-42). */
|
|
479
|
+
z.strictObject({ via: z.literal("personal"), runnerId: id }),
|
|
480
|
+
z.strictObject({ via: z.literal("team_default"), runnerId: id }),
|
|
481
|
+
z.strictObject({ via: z.literal("team_default"), profileId: id }),
|
|
482
|
+
/** `runner_needs_owner`: the Team default is a Runner paused because the member who connected it left. */
|
|
483
|
+
z.strictObject({ via: z.literal("none"), reason: z.enum(["no_runner_available", "runner_needs_owner"]) })
|
|
484
|
+
]);
|
|
485
|
+
var runnerListSchema = z.object({
|
|
486
|
+
capabilities: z.record(z.string(), z.boolean()).optional(),
|
|
487
|
+
historyRetentionDays: z.number().int().positive().nullable().optional(),
|
|
488
|
+
/** Who the list was filtered for: a member sees their own and Team Runners, an admin every Runner. */
|
|
489
|
+
viewer: z.object({ userId: z.string(), admin: z.boolean() }).optional(),
|
|
490
|
+
teamDefault: teamDefaultSchema.nullable().optional(),
|
|
491
|
+
runsGoTo: runsGoToSchema.optional(),
|
|
492
|
+
/** The lowest Runner version this Hub sends Runs to. Absent from Hubs older than Readiness. */
|
|
493
|
+
minimumRunnerVersion: z.string().optional(),
|
|
494
|
+
runners: z.array(runnerListEntrySchema),
|
|
495
|
+
profiles: z.array(z.object({
|
|
496
|
+
id: z.string(),
|
|
497
|
+
label: z.string(),
|
|
498
|
+
projectDir: z.string(),
|
|
499
|
+
repositoryRequired: z.boolean().optional(),
|
|
500
|
+
/** Marketplace refs baked into the profile's image; absent when the profile declares none. */
|
|
501
|
+
workflows: z.array(z.string()).optional(),
|
|
502
|
+
workflowSources: z.array(z.string()).optional()
|
|
503
|
+
}))
|
|
504
|
+
});
|
|
505
|
+
var runnerDisconnectRequestSchema = z.strictObject({ hubEpoch: z.string() });
|
|
506
|
+
var hubEpochRequestSchema = runnerDisconnectRequestSchema;
|
|
507
|
+
var runnerDisconnectPreviewSchema = z.object({
|
|
508
|
+
runnerId: id,
|
|
509
|
+
name: z.string().nullable(),
|
|
510
|
+
runs: z.array(z.object({
|
|
511
|
+
runId: id,
|
|
512
|
+
label: z.string().optional(),
|
|
513
|
+
/** Working: executing now. Parked: waiting for a person, Runner released. Queued: not started yet. */
|
|
514
|
+
state: z.enum(["working", "parked", "queued"])
|
|
515
|
+
})),
|
|
516
|
+
hiddenRuns: z.number().int().nonnegative()
|
|
517
|
+
});
|
|
518
|
+
var runnerDisconnectResponseSchema = z.object({
|
|
519
|
+
disconnected: z.literal(true),
|
|
520
|
+
/** How many Runs were Stopped with the reason `runner_disconnected`. */
|
|
521
|
+
stoppedRuns: z.number().int().nonnegative()
|
|
522
|
+
});
|
|
523
|
+
var runnerAdoptRequestSchema = hubEpochRequestSchema;
|
|
524
|
+
var connectStartRequestSchema = connectRedeemRequestSchema.omit({ code: true });
|
|
525
|
+
var connectStartResponseSchema = z.strictObject({
|
|
526
|
+
/** The machine's secret for polling; never shown. */
|
|
527
|
+
deviceCode: z.string().min(32).max(160),
|
|
528
|
+
code: connectCodeSchema,
|
|
529
|
+
expiresAt: sequence,
|
|
530
|
+
intervalSec: z.number().int().positive(),
|
|
531
|
+
/** The web console page that approves `code`. */
|
|
532
|
+
verificationUrl: z.string().url()
|
|
533
|
+
});
|
|
534
|
+
var connectPollRequestSchema = z.strictObject({ deviceCode: z.string().min(32).max(160) });
|
|
535
|
+
var connectPendingResponseSchema = z.strictObject({
|
|
536
|
+
hostname: z.string(),
|
|
537
|
+
os: z.string(),
|
|
538
|
+
softwareVersion: z.string(),
|
|
539
|
+
requestedAt: sequence,
|
|
540
|
+
expiresAt: sequence
|
|
541
|
+
});
|
|
542
|
+
var connectApproveRequestSchema = z.strictObject({
|
|
543
|
+
code: z.string().min(8).max(16),
|
|
544
|
+
audience: audienceSchema,
|
|
545
|
+
hubEpoch: z.string().optional()
|
|
546
|
+
});
|
|
547
|
+
var connectDenyRequestSchema = z.strictObject({ code: z.string().min(8).max(16) });
|
|
548
|
+
export {
|
|
549
|
+
abandonedConversationContinuationCapability,
|
|
550
|
+
audienceSchema,
|
|
551
|
+
canonicalJson,
|
|
552
|
+
checkpointPathSchema,
|
|
553
|
+
checkpointSchema,
|
|
554
|
+
clientFrameSchema,
|
|
555
|
+
commandSchema,
|
|
556
|
+
connectAlreadyConnectedSchema,
|
|
557
|
+
connectApproveRequestSchema,
|
|
558
|
+
connectCodeAlphabet,
|
|
559
|
+
connectCodeRequestSchema,
|
|
560
|
+
connectCodeResponseSchema,
|
|
561
|
+
connectCodeSchema,
|
|
562
|
+
connectDenyRequestSchema,
|
|
563
|
+
connectPendingResponseSchema,
|
|
564
|
+
connectPollRequestSchema,
|
|
565
|
+
connectRedeemRequestSchema,
|
|
566
|
+
connectRedeemResponseSchema,
|
|
567
|
+
connectStartRequestSchema,
|
|
568
|
+
connectStartResponseSchema,
|
|
569
|
+
controlRecordSchema,
|
|
570
|
+
conversationContinuationCapability,
|
|
571
|
+
grantSchema,
|
|
572
|
+
harnessReadinessSchema,
|
|
573
|
+
harnessSchema,
|
|
574
|
+
historyRecordSchema,
|
|
575
|
+
hubEpochRequestSchema,
|
|
576
|
+
installReference,
|
|
577
|
+
installedWorkflowsSchema,
|
|
578
|
+
interruptionSchema,
|
|
579
|
+
permissionAnswerSchema,
|
|
580
|
+
protocolVersion,
|
|
581
|
+
readableHistory,
|
|
582
|
+
readinessFixCommand,
|
|
583
|
+
repositoryAccessCapability,
|
|
584
|
+
repositoryBindingSchema,
|
|
585
|
+
repositoryRefSchema,
|
|
586
|
+
repositorySourceSchema,
|
|
587
|
+
repositoryWorkingDirectorySchema,
|
|
588
|
+
runSpecSchema,
|
|
589
|
+
runViewSchema,
|
|
590
|
+
runnerAdoptRequestSchema,
|
|
591
|
+
runnerDisconnectPreviewSchema,
|
|
592
|
+
runnerDisconnectRequestSchema,
|
|
593
|
+
runnerDisconnectResponseSchema,
|
|
594
|
+
runnerFrameSchema,
|
|
595
|
+
runnerListEntrySchema,
|
|
596
|
+
runnerListSchema,
|
|
597
|
+
runnerReadinessSchema,
|
|
598
|
+
runnerUpdateCommand,
|
|
599
|
+
runnerUpdateRequestSchema,
|
|
600
|
+
runsGoToSchema,
|
|
601
|
+
sameWorkflow,
|
|
602
|
+
scopeSchema,
|
|
603
|
+
secretEnvironmentSchema,
|
|
604
|
+
sequence,
|
|
605
|
+
teamDefaultRequestSchema,
|
|
606
|
+
teamDefaultSchema,
|
|
607
|
+
workflowIdentitySchema,
|
|
608
|
+
workflowInstallCapability,
|
|
609
|
+
workflowName,
|
|
610
|
+
workflowReferenceSchema,
|
|
611
|
+
workflowSourceSchema
|
|
612
|
+
};
|
|
613
|
+
//# sourceMappingURL=v2.js.map
|