@aspectlylabs/mikka 0.0.63 → 0.0.65

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/http-link.js CHANGED
@@ -264,14 +264,14 @@ var require_semver = __commonJS({
264
264
  if (!m[4]) {
265
265
  this.prerelease = [];
266
266
  } else {
267
- this.prerelease = m[4].split(".").map((id3) => {
268
- if (/^[0-9]+$/.test(id3)) {
269
- const num = +id3;
267
+ this.prerelease = m[4].split(".").map((id4) => {
268
+ if (/^[0-9]+$/.test(id4)) {
269
+ const num = +id4;
270
270
  if (num >= 0 && num < MAX_SAFE_INTEGER) {
271
271
  return num;
272
272
  }
273
273
  }
274
- return id3;
274
+ return id4;
275
275
  });
276
276
  }
277
277
  this.build = m[5] ? m[5].split(".") : [];
@@ -1140,23 +1140,23 @@ var require_range = __commonJS({
1140
1140
  debug("stars", comp);
1141
1141
  return comp;
1142
1142
  };
1143
- var isX = (id3) => !id3 || id3.toLowerCase() === "x" || id3 === "*";
1143
+ var isX = (id4) => !id4 || id4.toLowerCase() === "x" || id4 === "*";
1144
1144
  var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
1145
1145
  var replaceTildes = (comp, options) => {
1146
1146
  return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1147
1147
  };
1148
1148
  var replaceTilde = (comp, options) => {
1149
1149
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1150
- const z26 = options.includePrerelease ? "-0" : "";
1150
+ const z27 = options.includePrerelease ? "-0" : "";
1151
1151
  return comp.replace(r, (_, M, m, p, pr) => {
1152
1152
  debug("tilde", comp, _, M, m, p, pr);
1153
1153
  let ret;
1154
1154
  if (isX(M)) {
1155
1155
  ret = "";
1156
1156
  } else if (isX(m)) {
1157
- ret = `>=${M}.0.0${z26} <${+M + 1}.0.0-0`;
1157
+ ret = `>=${M}.0.0${z27} <${+M + 1}.0.0-0`;
1158
1158
  } else if (isX(p)) {
1159
- ret = `>=${M}.${m}.0${z26} <${M}.${+m + 1}.0-0`;
1159
+ ret = `>=${M}.${m}.0${z27} <${M}.${+m + 1}.0-0`;
1160
1160
  } else if (pr) {
1161
1161
  debug("replaceTilde pr", pr);
1162
1162
  ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
@@ -1173,19 +1173,19 @@ var require_range = __commonJS({
1173
1173
  var replaceCaret = (comp, options) => {
1174
1174
  debug("caret", comp, options);
1175
1175
  const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1176
- const z26 = options.includePrerelease ? "-0" : "";
1176
+ const z27 = options.includePrerelease ? "-0" : "";
1177
1177
  return comp.replace(r, (_, M, m, p, pr) => {
1178
1178
  debug("caret", comp, _, M, m, p, pr);
1179
1179
  let ret;
1180
1180
  if (isX(M)) {
1181
1181
  ret = "";
1182
1182
  } else if (isX(m)) {
1183
- ret = `>=${M}.0.0${z26} <${+M + 1}.0.0-0`;
1183
+ ret = `>=${M}.0.0${z27} <${+M + 1}.0.0-0`;
1184
1184
  } else if (isX(p)) {
1185
1185
  if (M === "0") {
1186
- ret = `>=${M}.${m}.0${z26} <${M}.${+m + 1}.0-0`;
1186
+ ret = `>=${M}.${m}.0${z27} <${M}.${+m + 1}.0-0`;
1187
1187
  } else {
1188
- ret = `>=${M}.${m}.0${z26} <${+M + 1}.0.0-0`;
1188
+ ret = `>=${M}.${m}.0${z27} <${+M + 1}.0.0-0`;
1189
1189
  }
1190
1190
  } else if (pr) {
1191
1191
  debug("replaceCaret pr", pr);
@@ -2054,7 +2054,7 @@ var nativeCoordinatorToolResultSchema = z.discriminatedUnion("status", [
2054
2054
  ]);
2055
2055
 
2056
2056
  // src/server-link-http.ts
2057
- import { z as z25 } from "zod";
2057
+ import { z as z26 } from "zod";
2058
2058
 
2059
2059
  // src/agents/tool-approval.ts
2060
2060
  import { randomUUID } from "node:crypto";
@@ -2170,6 +2170,9 @@ var ToolApprovalGate = class {
2170
2170
  }
2171
2171
  };
2172
2172
 
2173
+ // ../protocol/src/policy-snapshot.ts
2174
+ import { z as z3 } from "zod";
2175
+
2173
2176
  // ../protocol/src/agent-policy.ts
2174
2177
  import { z as z2 } from "zod";
2175
2178
  var PERMISSION_DECISIONS = ["allow", "ask", "deny"];
@@ -2200,6 +2203,11 @@ var PERMISSION_DEFAULTS = {
2200
2203
  network: "ask",
2201
2204
  computer_use: "ask"
2202
2205
  };
2206
+ function permissionChoiceAllowed(action, decision) {
2207
+ return CONFIGURABLE_PERMISSIONS[action].includes(
2208
+ decision
2209
+ );
2210
+ }
2203
2211
  var NETWORK_DOMAIN_RE = /^(\*\.)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(:[0-9]{1,5})?$/;
2204
2212
  var MAX_NETWORK_DOMAINS = 200;
2205
2213
  var MAX_GUIDANCE_LENGTH = 1e4;
@@ -2219,6 +2227,11 @@ var storedPermissionsSchema = z2.strictObject({
2219
2227
  computer_use: z2.enum(CONFIGURABLE_PERMISSIONS.computer_use)
2220
2228
  }).partial();
2221
2229
  var guidanceSchema = z2.string().max(MAX_GUIDANCE_LENGTH);
2230
+ var DEFAULT_NETWORK_ALLOW = [
2231
+ "github.com",
2232
+ "*.github.com",
2233
+ "*.githubusercontent.com"
2234
+ ];
2222
2235
  var runPolicySchema = z2.strictObject({
2223
2236
  permissions: z2.strictObject({
2224
2237
  install_dependency: z2.enum(PERMISSION_DECISIONS),
@@ -2248,6 +2261,111 @@ var modelByHarnessSchema = z2.strictObject({
2248
2261
  }).partial();
2249
2262
  var APPROVAL_MODES = ["ask", "read_only"];
2250
2263
  var approvalModeSchema = z2.enum(APPROVAL_MODES);
2264
+ function resolvePermissions(stored, environment = "local") {
2265
+ const out = {};
2266
+ const record = stored && typeof stored === "object" ? stored : {};
2267
+ for (const action of CONFIGURABLE_ACTIONS) {
2268
+ const value = record[action];
2269
+ out[action] = typeof value === "string" && permissionChoiceAllowed(action, value) ? value : environment === "cloud" && action === "network" ? "allow" : PERMISSION_DEFAULTS[action];
2270
+ }
2271
+ return out;
2272
+ }
2273
+ function resolveNetworkAllow(stored) {
2274
+ if (stored === null || stored === void 0) return [...DEFAULT_NETWORK_ALLOW];
2275
+ const parsed = networkAllowSchema.safeParse(stored);
2276
+ return parsed.success ? parsed.data : [...DEFAULT_NETWORK_ALLOW];
2277
+ }
2278
+ function resolveAgentSettings(workspace, team, environment = "local") {
2279
+ const permissions = resolvePermissions(workspace?.permissions, environment);
2280
+ const explicit = storedPermissionsSchema.safeParse(workspace?.permissions ?? {});
2281
+ if (environment === "cloud" && workspace?.networkAllow != null && explicit.success && explicit.data.network === void 0) permissions.network = "ask";
2282
+ const teamGuidance = team?.guidance;
2283
+ const workspaceGuidance = workspace?.guidance ?? null;
2284
+ const fromTeam = teamGuidance !== null && teamGuidance !== void 0;
2285
+ const text2 = (fromTeam ? teamGuidance : workspaceGuidance)?.trim() ?? "";
2286
+ return {
2287
+ policy: {
2288
+ permissions,
2289
+ networkAllow: resolveNetworkAllow(workspace?.networkAllow)
2290
+ },
2291
+ guidance: text2 ? text2 : null,
2292
+ guidanceFrom: text2 ? fromTeam ? "team" : "workspace" : null
2293
+ };
2294
+ }
2295
+ function defaultRunPolicy() {
2296
+ return resolveAgentSettings(null).policy;
2297
+ }
2298
+ function runPolicyDigestInput(policy) {
2299
+ const resolved = runPolicySchema.parse(policy ?? defaultRunPolicy());
2300
+ return JSON.stringify(resolved, [...Object.keys(resolved), ...Object.keys(resolved.permissions)].sort());
2301
+ }
2302
+
2303
+ // ../protocol/src/policy-snapshot.ts
2304
+ var POLICY_SNAPSHOT_HEADER = "x-mikka-policy-snapshot";
2305
+ var POLICY_SNAPSHOT_VERSION = "1";
2306
+ var POLICY_SNAPSHOT_TTL_MS = 5 * 6e4;
2307
+ var POLICY_SNAPSHOT_REFRESH_MS = 3e4;
2308
+ var id = z3.string().min(1).max(128);
2309
+ var digest = z3.string().regex(/^[a-f0-9]{64}$/);
2310
+ var policyScopeSchema = z3.strictObject({
2311
+ workspaceIds: z3.array(id).max(2),
2312
+ hierarchy: z3.strictObject({ workspaceId: z3.uuid(), teamId: z3.uuid(), projectId: z3.uuid().nullable() }).nullable()
2313
+ });
2314
+ var policySnapshotPayloadSchema = z3.strictObject({
2315
+ version: z3.literal(1),
2316
+ issuer: z3.url().max(1e3),
2317
+ ownerId: id,
2318
+ deviceId: id,
2319
+ runId: id,
2320
+ revision: digest,
2321
+ policyHash: digest,
2322
+ scope: policyScopeSchema,
2323
+ policy: runPolicySchema,
2324
+ issuedAt: z3.number().int().nonnegative(),
2325
+ expiresAt: z3.number().int().nonnegative()
2326
+ });
2327
+ var signedPolicySnapshotSchema = z3.strictObject({
2328
+ algorithm: z3.literal("Ed25519"),
2329
+ keyId: digest,
2330
+ payload: policySnapshotPayloadSchema,
2331
+ signature: z3.string().regex(/^[A-Za-z0-9_-]{86}$/)
2332
+ });
2333
+ var policyDistributionContextSchema = z3.strictObject({
2334
+ version: z3.literal(1),
2335
+ algorithm: z3.literal("Ed25519"),
2336
+ keyId: digest,
2337
+ publicKey: z3.string().regex(/^[A-Za-z0-9_-]{59}$/),
2338
+ issuer: z3.url().max(1e3),
2339
+ ownerId: id,
2340
+ deviceId: id,
2341
+ runId: id,
2342
+ revision: digest,
2343
+ scope: policyScopeSchema,
2344
+ required: z3.boolean()
2345
+ });
2346
+ function policyIssuer(base) {
2347
+ const url = new URL(base);
2348
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
2349
+ if (url.username || url.password || url.search || url.hash || url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) throw Error("policyIssuerInvalid");
2350
+ return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
2351
+ }
2352
+ function policySnapshotMessage(payload) {
2353
+ return new TextEncoder().encode(JSON.stringify(policySnapshotPayloadSchema.parse(payload)));
2354
+ }
2355
+
2356
+ // ../protocol/src/node-policy-snapshot.ts
2357
+ import { Buffer as Buffer2 } from "node:buffer";
2358
+ import { createHash, createPublicKey, verify } from "node:crypto";
2359
+ var policySnapshotHash = (policy) => createHash("sha256").update(runPolicyDigestInput(policy)).digest("hex");
2360
+ function verifyPolicySnapshot(value, trusted, expected, options = {}) {
2361
+ const context = policyDistributionContextSchema.parse(trusted);
2362
+ const snapshot = signedPolicySnapshotSchema.parse(value), p = snapshot.payload, now = options.now ?? Date.now();
2363
+ if (policyIssuer(context.issuer) !== context.issuer || policyIssuer(p.issuer) !== context.issuer || p.ownerId !== context.ownerId || p.deviceId !== context.deviceId || p.runId !== context.runId || p.revision !== context.revision || p.policyHash !== policySnapshotHash(p.policy) || p.runId !== expected.runId || p.deviceId !== expected.deviceId || p.revision !== expected.revision || snapshot.keyId !== context.keyId || JSON.stringify(p.scope) !== JSON.stringify(context.scope) || expected.policy && JSON.stringify(p.policy) !== JSON.stringify(runPolicySchema.parse(expected.policy))) throw Error("policySnapshotBindingInvalid");
2364
+ if (p.issuedAt > now + 3e4 || p.expiresAt <= p.issuedAt || p.expiresAt - p.issuedAt > POLICY_SNAPSHOT_TTL_MS || !options.allowExpired && p.expiresAt <= now) throw Error("policySnapshotExpired");
2365
+ const der = Buffer2.from(context.publicKey, "base64url");
2366
+ if (createHash("sha256").update(der).digest("hex") !== context.keyId || !verify(null, policySnapshotMessage(p), createPublicKey({ key: der, type: "spki", format: "der" }), Buffer2.from(snapshot.signature, "base64url"))) throw Error("policySnapshotSignatureInvalid");
2367
+ return snapshot;
2368
+ }
2251
2369
 
2252
2370
  // src/permissions.ts
2253
2371
  import { lstatSync, readlinkSync, realpathSync } from "node:fs";
@@ -2318,34 +2436,34 @@ function toolApprovalDecision(request, policy, worktree) {
2318
2436
  }
2319
2437
 
2320
2438
  // ../protocol/src/skill.ts
2321
- import { z as z4 } from "zod";
2439
+ import { z as z5 } from "zod";
2322
2440
 
2323
2441
  // ../protocol/src/skill-artifact.ts
2324
- import { z as z3 } from "zod";
2442
+ import { z as z4 } from "zod";
2325
2443
  var SKILL_ARTIFACT_HEADER = "x-mikka-skill-artifacts";
2326
2444
  var TEAM_SKILL_HEADER = "x-mikka-team-skills";
2327
- var skillArtifactRefSchema = z3.object({
2328
- schemaVersion: z3.literal(1),
2329
- registryId: z3.enum(["mikka-builtin", "mikka-team"]),
2330
- skillId: z3.uuid(),
2331
- versionId: z3.uuid(),
2332
- format: z3.literal("single-skill-md-v1"),
2333
- sha256: z3.string().regex(/^[a-f0-9]{64}$/)
2445
+ var skillArtifactRefSchema = z4.object({
2446
+ schemaVersion: z4.literal(1),
2447
+ registryId: z4.enum(["mikka-builtin", "mikka-team"]),
2448
+ skillId: z4.uuid(),
2449
+ versionId: z4.uuid(),
2450
+ format: z4.literal("single-skill-md-v1"),
2451
+ sha256: z4.string().regex(/^[a-f0-9]{64}$/)
2334
2452
  }).strict();
2335
- var skillAssignmentReceiptSchema = z3.object({
2336
- id: z3.uuid(),
2337
- runId: z3.uuid(),
2338
- issueId: z3.uuid(),
2339
- agentId: z3.uuid(),
2340
- repoId: z3.uuid(),
2341
- deviceId: z3.uuid(),
2342
- leaseExpiresAt: z3.iso.datetime(),
2343
- assignedAt: z3.iso.datetime(),
2453
+ var skillAssignmentReceiptSchema = z4.object({
2454
+ id: z4.uuid(),
2455
+ runId: z4.uuid(),
2456
+ issueId: z4.uuid(),
2457
+ agentId: z4.uuid(),
2458
+ repoId: z4.uuid(),
2459
+ deviceId: z4.uuid(),
2460
+ leaseExpiresAt: z4.iso.datetime(),
2461
+ assignedAt: z4.iso.datetime(),
2344
2462
  artifact: skillArtifactRefSchema
2345
2463
  }).strict();
2346
- var skillReceiptRevalidationSchema = z3.object({
2464
+ var skillReceiptRevalidationSchema = z4.object({
2347
2465
  skillReceipt: skillAssignmentReceiptSchema,
2348
- leaseExpiresAt: z3.iso.datetime()
2466
+ leaseExpiresAt: z4.iso.datetime()
2349
2467
  }).strict();
2350
2468
 
2351
2469
  // ../protocol/src/skill.ts
@@ -2356,39 +2474,39 @@ var MAX_SKILL_INSTRUCTIONS_LENGTH = 2e4;
2356
2474
  var MAX_SKILL_FILES = 20;
2357
2475
  var MAX_SKILL_FILE_PATH_LENGTH = 200;
2358
2476
  var MAX_SKILL_FILE_CONTENT_LENGTH = 1e5;
2359
- var skillFilePathSchema = z4.string().min(1).max(MAX_SKILL_FILE_PATH_LENGTH).refine(
2477
+ var skillFilePathSchema = z5.string().min(1).max(MAX_SKILL_FILE_PATH_LENGTH).refine(
2360
2478
  (path) => !path.startsWith("/") && !path.includes("\\") && !path.split("/").some((segment) => segment === ".." || segment === ""),
2361
2479
  { message: "A skill file path must be relative and stay inside the skill." }
2362
2480
  );
2363
- var skillFileSchema = z4.object({
2481
+ var skillFileSchema = z5.object({
2364
2482
  path: skillFilePathSchema,
2365
- content: z4.string().max(MAX_SKILL_FILE_CONTENT_LENGTH)
2483
+ content: z5.string().max(MAX_SKILL_FILE_CONTENT_LENGTH)
2366
2484
  });
2367
- var skillFilesSchema = z4.array(skillFileSchema).max(MAX_SKILL_FILES);
2368
- var skillNameSchema = z4.string().trim().min(1).max(MAX_SKILL_NAME_LENGTH);
2369
- var skillDescriptionSchema = z4.string().trim().max(MAX_SKILL_DESCRIPTION_LENGTH);
2370
- var skillInstructionsSchema = z4.string().trim().min(1).max(MAX_SKILL_INSTRUCTIONS_LENGTH);
2371
- var runSkillSchema = z4.object({
2372
- id: z4.uuid(),
2485
+ var skillFilesSchema = z5.array(skillFileSchema).max(MAX_SKILL_FILES);
2486
+ var skillNameSchema = z5.string().trim().min(1).max(MAX_SKILL_NAME_LENGTH);
2487
+ var skillDescriptionSchema = z5.string().trim().max(MAX_SKILL_DESCRIPTION_LENGTH);
2488
+ var skillInstructionsSchema = z5.string().trim().min(1).max(MAX_SKILL_INSTRUCTIONS_LENGTH);
2489
+ var runSkillSchema = z5.object({
2490
+ id: z5.uuid(),
2373
2491
  name: skillNameSchema,
2374
- description: z4.string().nullable(),
2492
+ description: z5.string().nullable(),
2375
2493
  instructions: skillInstructionsSchema,
2376
2494
  files: skillFilesSchema
2377
2495
  });
2378
- var runSkillRefSchema = z4.object({
2379
- id: z4.uuid(),
2496
+ var runSkillRefSchema = z5.object({
2497
+ id: z5.uuid(),
2380
2498
  name: skillNameSchema
2381
2499
  });
2382
2500
 
2383
2501
  // ../protocol/src/subscription.ts
2384
- import { z as z6 } from "zod";
2502
+ import { z as z7 } from "zod";
2385
2503
 
2386
2504
  // ../protocol/src/quota.ts
2387
- import { z as z5 } from "zod";
2505
+ import { z as z6 } from "zod";
2388
2506
  var QUOTA_VENDORS = ["claude_code", "codex", "cursor"];
2389
- var quotaVendorSchema = z5.enum(QUOTA_VENDORS);
2507
+ var quotaVendorSchema = z6.enum(QUOTA_VENDORS);
2390
2508
  var QUOTA_SOURCES = ["local_credentials", "official"];
2391
- var quotaSourceSchema = z5.enum(QUOTA_SOURCES);
2509
+ var quotaSourceSchema = z6.enum(QUOTA_SOURCES);
2392
2510
  var QUOTA_WINDOW_KINDS = [
2393
2511
  "five_hour",
2394
2512
  "weekly",
@@ -2397,7 +2515,7 @@ var QUOTA_WINDOW_KINDS = [
2397
2515
  "hourly",
2398
2516
  "other"
2399
2517
  ];
2400
- var quotaWindowKindSchema = z5.enum(QUOTA_WINDOW_KINDS);
2518
+ var quotaWindowKindSchema = z6.enum(QUOTA_WINDOW_KINDS);
2401
2519
  var QUOTA_METERS = [
2402
2520
  "auto",
2403
2521
  "api",
@@ -2405,139 +2523,139 @@ var QUOTA_METERS = [
2405
2523
  "team_pool",
2406
2524
  "team_on_demand"
2407
2525
  ];
2408
- var quotaMeterSchema = z5.enum(QUOTA_METERS);
2409
- var quotaWindowSchema = z5.object({
2526
+ var quotaMeterSchema = z6.enum(QUOTA_METERS);
2527
+ var quotaWindowSchema = z6.object({
2410
2528
  kind: quotaWindowKindSchema,
2411
2529
  /** 0..1 share of the window already used. */
2412
- used: z5.number().min(0).max(1),
2413
- resetsAt: z5.string().nullable(),
2530
+ used: z6.number().min(0).max(1),
2531
+ resetsAt: z6.string().nullable(),
2414
2532
  /** Model display name for a per-model window, e.g. "Opus". */
2415
- model: z5.string().min(1).max(40).optional(),
2533
+ model: z6.string().min(1).max(40).optional(),
2416
2534
  meter: quotaMeterSchema.optional()
2417
2535
  });
2418
- var quotaSnapshotSchema = z5.object({
2536
+ var quotaSnapshotSchema = z6.object({
2419
2537
  vendor: quotaVendorSchema,
2420
2538
  source: quotaSourceSchema,
2421
- status: z5.enum(["ok", "unknown"]),
2422
- plan: z5.string().max(40).nullable(),
2423
- windows: z5.array(quotaWindowSchema).max(12),
2539
+ status: z6.enum(["ok", "unknown"]),
2540
+ plan: z6.string().max(40).nullable(),
2541
+ windows: z6.array(quotaWindowSchema).max(12),
2424
2542
  /** When this vendor was last read (ISO-8601). */
2425
- observedAt: z5.string()
2543
+ observedAt: z6.string()
2426
2544
  });
2427
- var quotaSnapshotReportSchema = z5.object({
2545
+ var quotaSnapshotReportSchema = z6.object({
2428
2546
  /** When the whole read finished. Null before the first read. */
2429
- observedAt: z5.string().nullable(),
2430
- quotas: z5.array(quotaSnapshotSchema).max(6)
2547
+ observedAt: z6.string().nullable(),
2548
+ quotas: z6.array(quotaSnapshotSchema).max(6)
2431
2549
  });
2432
2550
 
2433
2551
  // ../protocol/src/subscription.ts
2434
- var id = z6.string().min(1).max(128);
2435
- var subscriptionRouteSchema = z6.enum([
2552
+ var id2 = z7.string().min(1).max(128);
2553
+ var subscriptionRouteSchema = z7.enum([
2436
2554
  "codex_cli",
2437
2555
  "claude_code_cli",
2438
2556
  "codex_cpa",
2439
2557
  "claude_cpa",
2440
2558
  "openai_siwc"
2441
2559
  ]);
2442
- var subscriptionConnectionSchema = z6.object({
2443
- id,
2444
- ownerId: id,
2445
- workspaceId: id,
2446
- provider: z6.enum(["openai", "anthropic"]),
2447
- state: z6.enum([
2560
+ var subscriptionConnectionSchema = z7.object({
2561
+ id: id2,
2562
+ ownerId: id2,
2563
+ workspaceId: id2,
2564
+ provider: z7.enum(["openai", "anthropic"]),
2565
+ state: z7.enum([
2448
2566
  "pending",
2449
2567
  "connected",
2450
2568
  "reconnect_required",
2451
2569
  "disconnected"
2452
2570
  ]),
2453
2571
  // Increment on reconnect/disconnect. Old bindings cannot become valid again.
2454
- revision: z6.number().int().positive(),
2572
+ revision: z7.number().int().positive(),
2455
2573
  quota: quotaSnapshotSchema
2456
2574
  }).strict();
2457
- var subscriptionBindingSchema = z6.object({
2458
- id,
2459
- ownerId: id,
2460
- workspaceId: id,
2575
+ var subscriptionBindingSchema = z7.object({
2576
+ id: id2,
2577
+ ownerId: id2,
2578
+ workspaceId: id2,
2461
2579
  // An agent or assistant session selected explicitly by the owner.
2462
- consumerId: id,
2463
- connectionId: id,
2464
- connectionRevision: z6.number().int().positive(),
2580
+ consumerId: id2,
2581
+ connectionId: id2,
2582
+ connectionRevision: z7.number().int().positive(),
2465
2583
  route: subscriptionRouteSchema
2466
2584
  }).strict();
2467
- var nativeBrokerContextSchema = z6.object({
2468
- route: z6.enum(["codex_cli", "claude_code_cli"]),
2469
- modelId: z6.string().min(1).max(128),
2470
- revision: z6.number().int().positive(),
2471
- accountId: z6.string().min(1).max(512),
2472
- plan: z6.string().max(40).optional(),
2473
- expiresAt: z6.iso.datetime()
2585
+ var nativeBrokerContextSchema = z7.object({
2586
+ route: z7.enum(["codex_cli", "claude_code_cli"]),
2587
+ modelId: z7.string().min(1).max(128),
2588
+ revision: z7.number().int().positive(),
2589
+ accountId: z7.string().min(1).max(512),
2590
+ plan: z7.string().max(40).optional(),
2591
+ expiresAt: z7.iso.datetime()
2474
2592
  }).strict();
2475
2593
 
2476
2594
  // ../protocol/src/computer.ts
2477
- import { z as z7 } from "zod";
2478
- var machineStateSchema = z7.enum(["sleeping", "waking", "running", "error"]);
2479
- var controlStateSchema = z7.enum(["agent", "user", "idle"]);
2480
- var computerToolSchema = z7.enum(["click", "type", "key", "scroll", "screenshot"]);
2481
- var screenRectSchema = z7.object({ x: z7.number(), y: z7.number(), w: z7.number().nonnegative(), h: z7.number().nonnegative() });
2482
- var computerActionSchema = z7.object({ tool: computerToolSchema, x: z7.number().optional(), y: z7.number().optional(), text: z7.string().optional(), rect: screenRectSchema.optional() });
2483
- var lastActionSchema = computerActionSchema.omit({ text: true }).extend({ at: z7.iso.datetime() });
2484
- var approvalViewSchema = z7.object({
2485
- id: z7.string(),
2486
- digest: z7.string(),
2487
- runId: z7.string(),
2488
- botId: z7.string(),
2595
+ import { z as z8 } from "zod";
2596
+ var machineStateSchema = z8.enum(["sleeping", "waking", "running", "error"]);
2597
+ var controlStateSchema = z8.enum(["agent", "user", "idle"]);
2598
+ var computerToolSchema = z8.enum(["click", "type", "key", "scroll", "screenshot"]);
2599
+ var screenRectSchema = z8.object({ x: z8.number(), y: z8.number(), w: z8.number().nonnegative(), h: z8.number().nonnegative() });
2600
+ var computerActionSchema = z8.object({ tool: computerToolSchema, x: z8.number().optional(), y: z8.number().optional(), text: z8.string().optional(), rect: screenRectSchema.optional() });
2601
+ var lastActionSchema = computerActionSchema.omit({ text: true }).extend({ at: z8.iso.datetime() });
2602
+ var approvalViewSchema = z8.object({
2603
+ id: z8.string(),
2604
+ digest: z8.string(),
2605
+ runId: z8.string(),
2606
+ botId: z8.string(),
2489
2607
  action: computerActionSchema,
2490
- summary: z7.string(),
2491
- expiresAt: z7.iso.datetime()
2608
+ summary: z8.string(),
2609
+ expiresAt: z8.iso.datetime()
2492
2610
  });
2493
- var computerStateSchema = z7.object({
2611
+ var computerStateSchema = z8.object({
2494
2612
  machine: machineStateSchema,
2495
2613
  control: controlStateSchema,
2496
- controlledBy: z7.object({ userId: z7.string() }).optional(),
2614
+ controlledBy: z8.object({ userId: z8.string() }).optional(),
2497
2615
  lastAction: lastActionSchema.optional(),
2498
2616
  pendingApproval: approvalViewSchema.optional()
2499
2617
  });
2500
- var viewerModeSchema = z7.enum(["view", "control"]);
2501
- var viewerRequestSchema = z7.object({ mode: viewerModeSchema }).strict();
2502
- var viewerGrantSchema = z7.object({ url: z7.url({ protocol: /^wss$/ }), expiresAt: z7.iso.datetime() });
2503
- var createBotSchema = z7.object({ name: z7.string().trim().min(1).max(120) }).strict();
2504
- var botViewSchema = z7.object({ id: z7.uuid(), name: z7.string().min(1).max(120) });
2505
- var approvalDecisionSchema = z7.object({ digest: z7.string(), decision: z7.enum(["approve", "deny"]), scope: z7.enum(["once", "run"]) }).strict();
2506
- var computerTaskStateSchema = z7.enum(["working", "approval", "done", "failed"]);
2507
- var computerTaskSchema = z7.object({ botId: z7.string(), runId: z7.string(), task: z7.string(), state: computerTaskStateSchema, approvalId: z7.string().optional() });
2508
- var computerEventSchema = z7.discriminatedUnion("type", [
2509
- z7.object({ type: z7.literal("computer.machine"), state: machineStateSchema }),
2510
- z7.object({ type: z7.literal("computer.control"), botId: z7.string(), control: controlStateSchema, controlledBy: z7.object({ userId: z7.string() }).optional() }),
2511
- z7.object({ type: z7.literal("computer.action"), botId: z7.string(), lastAction: lastActionSchema }),
2512
- z7.object({ type: z7.literal("computer.approval"), botId: z7.string(), approval: approvalViewSchema.nullable() })
2618
+ var viewerModeSchema = z8.enum(["view", "control"]);
2619
+ var viewerRequestSchema = z8.object({ mode: viewerModeSchema }).strict();
2620
+ var viewerGrantSchema = z8.object({ url: z8.url({ protocol: /^wss$/ }), expiresAt: z8.iso.datetime() });
2621
+ var createBotSchema = z8.object({ name: z8.string().trim().min(1).max(120) }).strict();
2622
+ var botViewSchema = z8.object({ id: z8.uuid(), name: z8.string().min(1).max(120) });
2623
+ var approvalDecisionSchema = z8.object({ digest: z8.string(), decision: z8.enum(["approve", "deny"]), scope: z8.enum(["once", "run"]) }).strict();
2624
+ var computerTaskStateSchema = z8.enum(["working", "approval", "done", "failed"]);
2625
+ var computerTaskSchema = z8.object({ botId: z8.string(), runId: z8.string(), task: z8.string(), state: computerTaskStateSchema, approvalId: z8.string().optional() });
2626
+ var computerEventSchema = z8.discriminatedUnion("type", [
2627
+ z8.object({ type: z8.literal("computer.machine"), state: machineStateSchema }),
2628
+ z8.object({ type: z8.literal("computer.control"), botId: z8.string(), control: controlStateSchema, controlledBy: z8.object({ userId: z8.string() }).optional() }),
2629
+ z8.object({ type: z8.literal("computer.action"), botId: z8.string(), lastAction: lastActionSchema }),
2630
+ z8.object({ type: z8.literal("computer.approval"), botId: z8.string(), approval: approvalViewSchema.nullable() })
2513
2631
  ]);
2514
- var reviewDigestSchema = z7.string().regex(/^[a-f0-9]{64}$/);
2515
- var localComputerCall = z7.discriminatedUnion("name", [
2516
- z7.object({ name: z7.literal("get_desktop_state"), arguments: z7.object({}).strict() }).strict(),
2517
- z7.object({ name: z7.literal("click"), arguments: z7.object({ x: z7.number().int().min(0).max(1e5), y: z7.number().int().min(0).max(1e5) }).strict() }).strict(),
2518
- z7.object({ name: z7.literal("type_text"), arguments: z7.object({ text: z7.string().min(1).max(8e3) }).strict() }).strict(),
2519
- z7.object({ name: z7.literal("press_key"), arguments: z7.object({
2520
- key: z7.string().regex(/^(?:[\x20-\x7e]|enter|return|tab|escape|space|backspace|delete|insert|home|end|pageup|pagedown|up|down|left|right|f(?:[1-9]|1[0-2]))$/),
2521
- modifiers: z7.array(z7.enum(["ctrl", "shift", "alt", "super"])).max(4).refine((items) => new Set(items).size === items.length).optional()
2632
+ var reviewDigestSchema = z8.string().regex(/^[a-f0-9]{64}$/);
2633
+ var localComputerCall = z8.discriminatedUnion("name", [
2634
+ z8.object({ name: z8.literal("get_desktop_state"), arguments: z8.object({}).strict() }).strict(),
2635
+ z8.object({ name: z8.literal("click"), arguments: z8.object({ x: z8.number().int().min(0).max(1e5), y: z8.number().int().min(0).max(1e5) }).strict() }).strict(),
2636
+ z8.object({ name: z8.literal("type_text"), arguments: z8.object({ text: z8.string().min(1).max(8e3) }).strict() }).strict(),
2637
+ z8.object({ name: z8.literal("press_key"), arguments: z8.object({
2638
+ key: z8.string().regex(/^(?:[\x20-\x7e]|enter|return|tab|escape|space|backspace|delete|insert|home|end|pageup|pagedown|up|down|left|right|f(?:[1-9]|1[0-2]))$/),
2639
+ modifiers: z8.array(z8.enum(["ctrl", "shift", "alt", "super"])).max(4).refine((items) => new Set(items).size === items.length).optional()
2522
2640
  }).strict() }).strict(),
2523
- z7.object({ name: z7.literal("scroll"), arguments: z7.object({ direction: z7.enum(["up", "down", "left", "right"]), amount: z7.number().int().min(1).max(50), x: z7.number().int().min(0).max(1e5), y: z7.number().int().min(0).max(1e5) }).strict() }).strict()
2641
+ z8.object({ name: z8.literal("scroll"), arguments: z8.object({ direction: z8.enum(["up", "down", "left", "right"]), amount: z8.number().int().min(1).max(50), x: z8.number().int().min(0).max(1e5), y: z8.number().int().min(0).max(1e5) }).strict() }).strict()
2524
2642
  ]);
2525
- var localComputerRequest = z7.object({
2526
- id: z7.uuid(),
2527
- runId: z7.uuid(),
2643
+ var localComputerRequest = z8.object({
2644
+ id: z8.uuid(),
2645
+ runId: z8.uuid(),
2528
2646
  target: reviewDigestSchema,
2529
- display: z7.string().regex(/^:[1-9][0-9]{0,2}$/).optional(),
2647
+ display: z8.string().regex(/^:[1-9][0-9]{0,2}$/).optional(),
2530
2648
  call: localComputerCall,
2531
- expiresAt: z7.number().int().positive(),
2649
+ expiresAt: z8.number().int().positive(),
2532
2650
  digest: reviewDigestSchema
2533
2651
  }).strict();
2534
- var localComputerDecision = z7.object({ id: z7.uuid(), digest: reviewDigestSchema, approve: z7.boolean() }).strict();
2535
- var computerSyncBody = z7.object({ requests: z7.array(localComputerRequest).max(20) }).strict();
2536
- var computerSyncResponse = z7.object({ decisions: z7.array(localComputerDecision).max(20) }).strict();
2652
+ var localComputerDecision = z8.object({ id: z8.uuid(), digest: reviewDigestSchema, approve: z8.boolean() }).strict();
2653
+ var computerSyncBody = z8.object({ requests: z8.array(localComputerRequest).max(20) }).strict();
2654
+ var computerSyncResponse = z8.object({ decisions: z8.array(localComputerDecision).max(20) }).strict();
2537
2655
  var computerSyncPath = (deviceId) => `/v1/devices/${encodeURIComponent(deviceId)}/computer`;
2538
2656
 
2539
2657
  // ../protocol/src/capture.ts
2540
- import { z as z8 } from "zod";
2658
+ import { z as z9 } from "zod";
2541
2659
  var CAPTURE_CONTENT_TYPES = [
2542
2660
  "image/png",
2543
2661
  "image/jpeg",
@@ -2553,44 +2671,44 @@ var CAPTURE_MAX_BYTES = {
2553
2671
  };
2554
2672
  var RECORDING_MAX_SECONDS = 300;
2555
2673
  var CAPTURE_TITLE_MAX = 200;
2556
- var sha256 = z8.string().regex(/^[a-f0-9]{64}$/);
2557
- var title = z8.string().trim().min(1).max(CAPTURE_TITLE_MAX);
2558
- var captureUploadRequest = z8.object({
2674
+ var sha256 = z9.string().regex(/^[a-f0-9]{64}$/);
2675
+ var title = z9.string().trim().min(1).max(CAPTURE_TITLE_MAX);
2676
+ var captureUploadRequest = z9.object({
2559
2677
  /** Stable client id, persisted before the first network attempt. */
2560
- captureId: z8.uuid().optional(),
2678
+ captureId: z9.uuid().optional(),
2561
2679
  title,
2562
- contentType: z8.enum(CAPTURE_CONTENT_TYPES),
2563
- size: z8.number().int().min(1).max(CAPTURE_MAX_BYTES.video),
2680
+ contentType: z9.enum(CAPTURE_CONTENT_TYPES),
2681
+ size: z9.number().int().min(1).max(CAPTURE_MAX_BYTES.video),
2564
2682
  sha256
2565
2683
  }).strict();
2566
- var captureUploadTarget = z8.discriminatedUnion("target", [
2567
- z8.object({ target: z8.literal("storage"), url: z8.url({ protocol: /^https$/ }), headers: z8.record(z8.string(), z8.string()) }),
2568
- z8.object({ target: z8.literal("server") })
2684
+ var captureUploadTarget = z9.discriminatedUnion("target", [
2685
+ z9.object({ target: z9.literal("storage"), url: z9.url({ protocol: /^https$/ }), headers: z9.record(z9.string(), z9.string()) }),
2686
+ z9.object({ target: z9.literal("server") })
2569
2687
  ]);
2570
- var captureUploadResponse = z8.object({
2571
- captureId: z8.uuid(),
2688
+ var captureUploadResponse = z9.object({
2689
+ captureId: z9.uuid(),
2572
2690
  upload: captureUploadTarget
2573
2691
  });
2574
- var captureView = z8.object({
2575
- id: z8.uuid(),
2576
- kind: z8.enum(CAPTURE_KINDS),
2577
- contentType: z8.enum(CAPTURE_CONTENT_TYPES),
2578
- title: z8.string(),
2579
- size: z8.number().int().nonnegative(),
2580
- durationMs: z8.number().int().nonnegative().nullable(),
2581
- source: z8.enum(CAPTURE_SOURCES),
2582
- createdAt: z8.iso.datetime()
2692
+ var captureView = z9.object({
2693
+ id: z9.uuid(),
2694
+ kind: z9.enum(CAPTURE_KINDS),
2695
+ contentType: z9.enum(CAPTURE_CONTENT_TYPES),
2696
+ title: z9.string(),
2697
+ size: z9.number().int().nonnegative(),
2698
+ durationMs: z9.number().int().nonnegative().nullable(),
2699
+ source: z9.enum(CAPTURE_SOURCES),
2700
+ createdAt: z9.iso.datetime()
2583
2701
  });
2584
- var captureCompleteResponse = z8.object({ capture: captureView });
2585
- var screenCaptureRequest = z8.discriminatedUnion("action", [
2586
- z8.object({ action: z8.literal("screenshot"), title }).strict(),
2587
- z8.object({ action: z8.literal("start_recording"), title, maxSeconds: z8.number().int().min(5).max(RECORDING_MAX_SECONDS).optional() }).strict(),
2588
- z8.object({ action: z8.literal("stop_recording") }).strict()
2702
+ var captureCompleteResponse = z9.object({ capture: captureView });
2703
+ var screenCaptureRequest = z9.discriminatedUnion("action", [
2704
+ z9.object({ action: z9.literal("screenshot"), title }).strict(),
2705
+ z9.object({ action: z9.literal("start_recording"), title, maxSeconds: z9.number().int().min(5).max(RECORDING_MAX_SECONDS).optional() }).strict(),
2706
+ z9.object({ action: z9.literal("stop_recording") }).strict()
2589
2707
  ]);
2590
- var screenCaptureResponse = z8.discriminatedUnion("action", [
2591
- z8.object({ action: z8.literal("screenshot"), capture: captureView }),
2592
- z8.object({ action: z8.literal("start_recording"), recordingId: z8.uuid(), stopsAt: z8.iso.datetime() }),
2593
- z8.object({ action: z8.literal("stop_recording"), capture: captureView })
2708
+ var screenCaptureResponse = z9.discriminatedUnion("action", [
2709
+ z9.object({ action: z9.literal("screenshot"), capture: captureView }),
2710
+ z9.object({ action: z9.literal("start_recording"), recordingId: z9.uuid(), stopsAt: z9.iso.datetime() }),
2711
+ z9.object({ action: z9.literal("stop_recording"), capture: captureView })
2594
2712
  ]);
2595
2713
  var capturePaths = {
2596
2714
  begin: (runId) => `/v1/runs/${encodeURIComponent(runId)}/captures`,
@@ -2600,31 +2718,31 @@ var capturePaths = {
2600
2718
  };
2601
2719
 
2602
2720
  // ../protocol/src/accounts.ts
2603
- import { z as z9 } from "zod";
2604
- var connectedAccount = z9.object({
2721
+ import { z as z10 } from "zod";
2722
+ var connectedAccount = z10.object({
2605
2723
  /** The provider, e.g. "github". Unique per person, so it names the row. */
2606
- providerId: z9.string(),
2724
+ providerId: z10.string(),
2607
2725
  /**
2608
2726
  * The account's id at the provider. Better Auth stores the provider's own
2609
2727
  * user id here, which for GitHub is a number — the closest thing to a
2610
2728
  * display name the table holds.
2611
2729
  */
2612
- accountId: z9.string(),
2730
+ accountId: z10.string(),
2613
2731
  /** OAuth scopes granted, space separated. Null when the provider sent none. */
2614
- scope: z9.string().nullable(),
2732
+ scope: z10.string().nullable(),
2615
2733
  /** When the account was linked, ISO 8601. */
2616
- createdAt: z9.string()
2734
+ createdAt: z10.string()
2617
2735
  });
2618
- var connectedAccountsResponse = z9.object({
2619
- accounts: z9.array(connectedAccount)
2736
+ var connectedAccountsResponse = z10.object({
2737
+ accounts: z10.array(connectedAccount)
2620
2738
  });
2621
2739
 
2622
2740
  // ../protocol/src/auth.ts
2623
- import { z as z10 } from "zod";
2741
+ import { z as z11 } from "zod";
2624
2742
  var AUTH_PROVIDERS = ["github", "google"];
2625
- var authProvider = z10.enum(AUTH_PROVIDERS);
2743
+ var authProvider = z11.enum(AUTH_PROVIDERS);
2626
2744
  var DESKTOP_SCHEMES = ["mikka", "mikka-dev"];
2627
- var desktopScheme = z10.enum(DESKTOP_SCHEMES);
2745
+ var desktopScheme = z11.enum(DESKTOP_SCHEMES);
2628
2746
  var AUTH_BASE_PATH = "/api/auth";
2629
2747
  var AUTH_ROUTES = {
2630
2748
  /** Better Auth jwt plugin: short-lived JWT for zero-cache and the relay. */
@@ -2633,98 +2751,98 @@ var AUTH_ROUTES = {
2633
2751
  devLogin: `${AUTH_BASE_PATH}/dev/login`,
2634
2752
  me: "/v1/me"
2635
2753
  };
2636
- var activeSession = z10.object({
2637
- id: z10.string(),
2754
+ var activeSession = z11.object({
2755
+ id: z11.string(),
2638
2756
  /** ISO timestamps. */
2639
- createdAt: z10.string(),
2640
- expiresAt: z10.string(),
2641
- ipAddress: z10.string().nullable(),
2642
- userAgent: z10.string().nullable(),
2757
+ createdAt: z11.string(),
2758
+ expiresAt: z11.string(),
2759
+ ipAddress: z11.string().nullable(),
2760
+ userAgent: z11.string().nullable(),
2643
2761
  /** Derived from the caller's JWT (`sid`), not from the request's cookies. */
2644
- current: z10.boolean()
2762
+ current: z11.boolean()
2645
2763
  });
2646
- var activeSessions = z10.object({ sessions: z10.array(activeSession) });
2647
- var authorizedDevice = z10.object({
2648
- id: z10.uuid(),
2649
- name: z10.string(),
2650
- hostname: z10.string().nullable(),
2651
- platform: z10.string().nullable(),
2652
- daemonVersion: z10.string().nullable(),
2653
- lastSeenAt: z10.string().nullable(),
2764
+ var activeSessions = z11.object({ sessions: z11.array(activeSession) });
2765
+ var authorizedDevice = z11.object({
2766
+ id: z11.uuid(),
2767
+ name: z11.string(),
2768
+ hostname: z11.string().nullable(),
2769
+ platform: z11.string().nullable(),
2770
+ daemonVersion: z11.string().nullable(),
2771
+ lastSeenAt: z11.string().nullable(),
2654
2772
  /** The daemon session; null once the authorization is revoked. */
2655
- sessionId: z10.string().nullable(),
2773
+ sessionId: z11.string().nullable(),
2656
2774
  /** When the daemon signed in, and when that session expires. */
2657
- authorizedAt: z10.string().nullable(),
2658
- expiresAt: z10.string().nullable()
2775
+ authorizedAt: z11.string().nullable(),
2776
+ expiresAt: z11.string().nullable()
2659
2777
  });
2660
- var authorizedDevices = z10.object({
2661
- devices: z10.array(authorizedDevice)
2778
+ var authorizedDevices = z11.object({
2779
+ devices: z11.array(authorizedDevice)
2662
2780
  });
2663
- var authorizedApplication = z10.object({
2664
- id: z10.string(),
2665
- name: z10.string(),
2666
- uri: z10.string().nullable(),
2667
- scopes: z10.array(z10.string()),
2668
- createdAt: z10.string(),
2669
- updatedAt: z10.string()
2781
+ var authorizedApplication = z11.object({
2782
+ id: z11.string(),
2783
+ name: z11.string(),
2784
+ uri: z11.string().nullable(),
2785
+ scopes: z11.array(z11.string()),
2786
+ createdAt: z11.string(),
2787
+ updatedAt: z11.string()
2670
2788
  });
2671
- var authorizedApplications = z10.object({
2672
- applications: z10.array(authorizedApplication)
2789
+ var authorizedApplications = z11.object({
2790
+ applications: z11.array(authorizedApplication)
2673
2791
  });
2674
- var sessionUser = z10.object({
2675
- id: z10.uuid(),
2676
- email: z10.string(),
2677
- name: z10.string(),
2678
- image: z10.string().nullable()
2792
+ var sessionUser = z11.object({
2793
+ id: z11.uuid(),
2794
+ email: z11.string(),
2795
+ name: z11.string(),
2796
+ image: z11.string().nullable()
2679
2797
  });
2680
- var accessToken = z10.object({
2681
- token: z10.string().min(1),
2798
+ var accessToken = z11.object({
2799
+ token: z11.string().min(1),
2682
2800
  /** Expiry, ms since epoch (from the JWT's `exp`). */
2683
- expiresAt: z10.number().int()
2801
+ expiresAt: z11.number().int()
2684
2802
  });
2685
2803
 
2686
2804
  // ../protocol/src/bridge.ts
2687
- import { z as z11 } from "zod";
2805
+ import { z as z12 } from "zod";
2688
2806
  var LANGUAGES = ["zh-CN", "en"];
2689
- var languagePreference = z11.enum(["system", ...LANGUAGES]);
2690
- var themePreference = z11.enum(["system", "light", "dark"]);
2691
- var appHref = z11.string().max(2048).regex(/^\/(?!\/)/);
2807
+ var languagePreference = z12.enum(["system", ...LANGUAGES]);
2808
+ var themePreference = z12.enum(["system", "light", "dark"]);
2809
+ var appHref = z12.string().max(2048).regex(/^\/(?!\/)/);
2692
2810
  var DESKTOP_NOTIFICATION_KINDS = [
2693
2811
  "review",
2694
2812
  "awaiting",
2695
2813
  "failed",
2696
2814
  "finished"
2697
2815
  ];
2698
- var desktopNotification = z11.object({
2816
+ var desktopNotification = z12.object({
2699
2817
  /** The `notification` row id. */
2700
- id: z11.string().min(1).max(200),
2701
- kind: z11.enum(DESKTOP_NOTIFICATION_KINDS),
2818
+ id: z12.string().min(1).max(200),
2819
+ kind: z12.enum(DESKTOP_NOTIFICATION_KINDS),
2702
2820
  /** `ORV-12 · 等你验收`; the issue number is always in it. */
2703
- title: z11.string().min(1).max(300),
2821
+ title: z12.string().min(1).max(300),
2704
2822
  /** The issue title. */
2705
- body: z11.string().max(1e3),
2823
+ body: z12.string().max(1e3),
2706
2824
  href: appHref
2707
2825
  });
2708
- var desktopBadgeCount = z11.number().int().min(0).max(9999);
2709
- var savedTab = z11.object({
2710
- entries: z11.array(appHref).min(1).max(50),
2711
- index: z11.number().int().min(0).max(49)
2826
+ var desktopBadgeCount = z12.number().int().min(0).max(9999);
2827
+ var savedTab = z12.object({
2828
+ entries: z12.array(appHref).min(1).max(50),
2829
+ index: z12.number().int().min(0).max(49)
2712
2830
  });
2713
- var savedTabs = z11.object({
2714
- items: z11.array(savedTab).max(50),
2715
- active: z11.number().int().min(0).max(49)
2831
+ var savedTabs = z12.object({
2832
+ items: z12.array(savedTab).max(50),
2833
+ active: z12.number().int().min(0).max(49)
2716
2834
  });
2717
- var firstDayOfWeekPreference = z11.enum(["monday", "sunday", "saturday"]);
2718
- var commentSubmitKeyPreference = z11.enum(["mod+enter", "enter"]);
2719
- var settingsSchema = z11.object({
2835
+ var firstDayOfWeekPreference = z12.enum(["monday", "sunday", "saturday"]);
2836
+ var commentSubmitKeyPreference = z12.enum(["mod+enter", "enter"]);
2837
+ var settingsSchema = z12.object({
2720
2838
  language: languagePreference,
2721
2839
  theme: themePreference,
2722
2840
  /** Sidebar expanded (true) or collapsed offcanvas (false); ⌘B and `[`. */
2723
- sidebarOpen: z11.boolean(),
2841
+ sidebarOpen: z12.boolean(),
2724
2842
  /** Titlebar tabs; empty until the app has saved them once. */
2725
2843
  tabs: savedTabs,
2726
2844
  /** Send anonymous usage events (ADR 0033); off by choice in Settings. */
2727
- telemetry: z11.boolean(),
2845
+ telemetry: z12.boolean(),
2728
2846
  /** Which day a week starts on in date pickers. */
2729
2847
  firstDayOfWeek: firstDayOfWeekPreference,
2730
2848
  /** Which key press sends a comment. */
@@ -2740,43 +2858,43 @@ var DEFAULT_SETTINGS = {
2740
2858
  commentSubmitKey: "mod+enter"
2741
2859
  };
2742
2860
  var SETTINGS_KEYS = Object.keys(DEFAULT_SETTINGS);
2743
- var authState = z11.discriminatedUnion("status", [
2744
- z11.object({ status: z11.literal("signed_out") }),
2745
- z11.object({ status: z11.literal("signing_in"), provider: authProvider }),
2746
- z11.object({ status: z11.literal("signed_in"), user: sessionUser }),
2747
- z11.object({
2748
- status: z11.literal("update_required"),
2749
- minVersion: z11.string()
2861
+ var authState = z12.discriminatedUnion("status", [
2862
+ z12.object({ status: z12.literal("signed_out") }),
2863
+ z12.object({ status: z12.literal("signing_in"), provider: authProvider }),
2864
+ z12.object({ status: z12.literal("signed_in"), user: sessionUser }),
2865
+ z12.object({
2866
+ status: z12.literal("update_required"),
2867
+ minVersion: z12.string()
2750
2868
  }),
2751
- z11.object({ status: z11.literal("error"), code: z11.string() })
2869
+ z12.object({ status: z12.literal("error"), code: z12.string() })
2752
2870
  ]);
2753
- var localDevice = z11.object({
2871
+ var localDevice = z12.object({
2754
2872
  /** Whether the daemon on this computer answers. */
2755
- status: z11.enum(["online", "connecting", "offline"]),
2873
+ status: z12.enum(["online", "connecting", "offline"]),
2756
2874
  /** The device row this daemon registered, once it has. */
2757
- deviceId: z11.string().nullable(),
2758
- workspaceId: z11.string().nullable(),
2875
+ deviceId: z12.string().nullable(),
2876
+ workspaceId: z12.string().nullable(),
2759
2877
  /** The daemon holds a device credential. */
2760
- signedIn: z11.boolean(),
2878
+ signedIn: z12.boolean(),
2761
2879
  /** The daemon's link to the server; null while the daemon is offline. */
2762
- server: z11.enum(["online", "offline", "unregistered"]).nullable()
2880
+ server: z12.enum(["online", "offline", "unregistered"]).nullable()
2763
2881
  });
2764
- var deviceLinkRequest = z11.object({ workspaceId: z11.uuid() });
2765
- var pickedRepo = z11.object({
2882
+ var deviceLinkRequest = z12.object({ workspaceId: z12.uuid() });
2883
+ var pickedRepo = z12.object({
2766
2884
  /** The repo's top level (a subfolder pick resolves to it). */
2767
- path: z11.string().min(1).max(4e3),
2768
- name: z11.string().max(500),
2885
+ path: z12.string().min(1).max(4e3),
2886
+ name: z12.string().max(500),
2769
2887
  /** `origin` (or the first remote), null when the repo has none. */
2770
- remoteUrl: z11.string().max(2e3).nullable()
2888
+ remoteUrl: z12.string().max(2e3).nullable()
2771
2889
  });
2772
- var pickRepoResult = z11.discriminatedUnion("status", [
2773
- z11.object({ status: z11.literal("picked"), repo: pickedRepo }),
2774
- z11.object({ status: z11.literal("cancelled") }),
2775
- z11.object({ status: z11.literal("not_a_repo"), path: z11.string() })
2890
+ var pickRepoResult = z12.discriminatedUnion("status", [
2891
+ z12.object({ status: z12.literal("picked"), repo: pickedRepo }),
2892
+ z12.object({ status: z12.literal("cancelled") }),
2893
+ z12.object({ status: z12.literal("not_a_repo"), path: z12.string() })
2776
2894
  ]);
2777
2895
 
2778
2896
  // ../protocol/src/cycles.ts
2779
- import { z as z12 } from "zod";
2897
+ import { z as z13 } from "zod";
2780
2898
  var WEEKDAYS = [
2781
2899
  "monday",
2782
2900
  "tuesday",
@@ -2789,26 +2907,26 @@ var WEEKDAYS = [
2789
2907
  var CYCLE_DURATION_MIN_DAYS = 1;
2790
2908
  var CYCLE_DURATION_MAX_DAYS = 56;
2791
2909
  var CYCLE_UPCOMING_MAX = 8;
2792
- var teamCycleSettingsSchema = z12.object({
2910
+ var teamCycleSettingsSchema = z13.object({
2793
2911
  /** Off until a person turns it on: nothing is created and nothing rolls. */
2794
- enabled: z12.boolean().default(false),
2912
+ enabled: z13.boolean().default(false),
2795
2913
  /** Length of a cycle in days; the end date is `start + duration - 1`. */
2796
- durationDays: z12.number().int().min(CYCLE_DURATION_MIN_DAYS).max(CYCLE_DURATION_MAX_DAYS).default(14),
2914
+ durationDays: z13.number().int().min(CYCLE_DURATION_MIN_DAYS).max(CYCLE_DURATION_MAX_DAYS).default(14),
2797
2915
  /** The weekday a team's first cycle starts on. */
2798
- startWeekday: z12.enum(WEEKDAYS).default("monday"),
2916
+ startWeekday: z13.enum(WEEKDAYS).default("monday"),
2799
2917
  /** Cycles kept ready ahead of the current one. 0 creates them just in time. */
2800
- upcomingCount: z12.number().int().min(0).max(CYCLE_UPCOMING_MAX).default(1),
2918
+ upcomingCount: z13.number().int().min(0).max(CYCLE_UPCOMING_MAX).default(1),
2801
2919
  /**
2802
2920
  * When a cycle ends, unfinished issues move to the next one. Off leaves them
2803
2921
  * in the finished cycle, which is what `cycle.complete` has always done.
2804
2922
  */
2805
- autoRollover: z12.boolean().default(true),
2923
+ autoRollover: z13.boolean().default(true),
2806
2924
  /**
2807
2925
  * The team's calendar. A cycle ends at the last moment of its end date
2808
2926
  * *here*, not in UTC, so a team in Auckland and one in Los Angeles roll over
2809
2927
  * at different instants.
2810
2928
  */
2811
- timezone: z12.string().max(64).refine(isValidTimeZone, "Unknown timezone.").default("UTC")
2929
+ timezone: z13.string().max(64).refine(isValidTimeZone, "Unknown timezone.").default("UTC")
2812
2930
  });
2813
2931
  function isValidTimeZone(value) {
2814
2932
  try {
@@ -2820,56 +2938,56 @@ function isValidTimeZone(value) {
2820
2938
  }
2821
2939
 
2822
2940
  // ../protocol/src/daemon.ts
2823
- import { z as z16 } from "zod";
2941
+ import { z as z17 } from "zod";
2824
2942
 
2825
2943
  // ../protocol/src/harness.ts
2826
- import { z as z13 } from "zod";
2944
+ import { z as z14 } from "zod";
2827
2945
  var HARNESSES = ["claude_code", "codex", "cursor", "mock"];
2828
- var harnessSchema = z13.enum(HARNESSES);
2829
- var harnessInfoSchema = z13.object({
2946
+ var harnessSchema = z14.enum(HARNESSES);
2947
+ var harnessInfoSchema = z14.object({
2830
2948
  harness: harnessSchema,
2831
- installed: z13.boolean(),
2832
- models: z13.array(z13.string().trim().min(1).max(128)).max(500).optional(),
2833
- modelSlots: z13.array(
2834
- z13.object({
2835
- slot: z13.string().trim().min(1).max(128).refine((v2) => v2 !== "auto"),
2836
- model: z13.string().trim().min(1).max(128),
2837
- name: z13.string().trim().min(1).max(200)
2949
+ installed: z14.boolean(),
2950
+ models: z14.array(z14.string().trim().min(1).max(128)).max(500).optional(),
2951
+ modelSlots: z14.array(
2952
+ z14.object({
2953
+ slot: z14.string().trim().min(1).max(128).refine((v2) => v2 !== "auto"),
2954
+ model: z14.string().trim().min(1).max(128),
2955
+ name: z14.string().trim().min(1).max(200)
2838
2956
  })
2839
2957
  ).max(500).optional(),
2840
- defaultModelSlot: z13.string().trim().min(1).max(128).optional(),
2958
+ defaultModelSlot: z14.string().trim().min(1).max(128).optional(),
2841
2959
  /** Deprecated (#312, 2026-10-27): could host the native Coordinator. The server keeps that runtime switched off. */
2842
- coordinator: z13.boolean().optional(),
2960
+ coordinator: z14.boolean().optional(),
2843
2961
  /** Set only by a runner with an isolated, owner-bound subscription broker. */
2844
- subscriptionBroker: z13.literal(true).optional(),
2962
+ subscriptionBroker: z14.literal(true).optional(),
2845
2963
  /** Set only by an E2B worker with the guarded Bot computer broker. */
2846
- computerBroker: z13.literal(true).optional(),
2964
+ computerBroker: z14.literal(true).optional(),
2847
2965
  /** Run-scoped CLI approvals and policy-version checks are supported. */
2848
- toolApproval: z13.literal(true).optional(),
2966
+ toolApproval: z14.literal(true).optional(),
2849
2967
  /** Version string reported by the CLI, null when not installed. */
2850
- version: z13.string().nullable()
2968
+ version: z14.string().nullable()
2851
2969
  });
2852
2970
 
2853
2971
  // ../protocol/src/run.ts
2854
- import { z as z15 } from "zod";
2972
+ import { z as z16 } from "zod";
2855
2973
 
2856
2974
  // ../protocol/src/plan.ts
2857
- import { z as z14 } from "zod";
2858
- var text = (max) => z14.string().trim().min(1).max(max);
2859
- var key = z14.string().trim().min(1).max(64);
2860
- var planSection = z14.object({
2975
+ import { z as z15 } from "zod";
2976
+ var text = (max) => z15.string().trim().min(1).max(max);
2977
+ var key = z15.string().trim().min(1).max(64);
2978
+ var planSection = z15.object({
2861
2979
  heading: text(200),
2862
- items: z14.array(text(2e3)).min(1).max(50)
2980
+ items: z15.array(text(2e3)).min(1).max(50)
2863
2981
  });
2864
- var planSpec = z14.object({
2982
+ var planSpec = z15.object({
2865
2983
  title: text(500),
2866
- summary: z14.string().trim().max(4e3).default(""),
2867
- sections: z14.array(planSection).min(1).max(30)
2984
+ summary: z15.string().trim().max(4e3).default(""),
2985
+ sections: z15.array(planSection).min(1).max(30)
2868
2986
  });
2869
- var planCriterion = z14.object({
2987
+ var planCriterion = z15.object({
2870
2988
  body: text(2e3),
2871
2989
  /** The command that checks it; absent means a person checks it. */
2872
- checkCommand: z14.string().trim().max(2e3).optional()
2990
+ checkCommand: z15.string().trim().max(2e3).optional()
2873
2991
  });
2874
2992
  var PLAN_PRIORITIES = [
2875
2993
  "none",
@@ -2878,25 +2996,25 @@ var PLAN_PRIORITIES = [
2878
2996
  "medium",
2879
2997
  "low"
2880
2998
  ];
2881
- var planIssue = z14.object({
2999
+ var planIssue = z15.object({
2882
3000
  key,
2883
3001
  title: text(500),
2884
- goal: z14.string().trim().max(4e3).optional(),
3002
+ goal: z15.string().trim().max(4e3).optional(),
2885
3003
  /** Grouping only; order lives in `blockedBy` (`issue.parent_id`). */
2886
3004
  parentKey: key.optional(),
2887
- blockedBy: z14.array(key).max(50).default([]),
2888
- criteria: z14.array(planCriterion).min(1).max(50),
2889
- verifyCommand: z14.string().trim().max(2e3).optional(),
2890
- predictedFiles: z14.array(z14.string().trim().max(1e3)).max(200).default([]),
2891
- sizeEstimate: z14.object({ files: z14.number().int().min(0), lines: z14.number().int().min(0) }).optional(),
2892
- priority: z14.enum(PLAN_PRIORITIES).default("none")
3005
+ blockedBy: z15.array(key).max(50).default([]),
3006
+ criteria: z15.array(planCriterion).min(1).max(50),
3007
+ verifyCommand: z15.string().trim().max(2e3).optional(),
3008
+ predictedFiles: z15.array(z15.string().trim().max(1e3)).max(200).default([]),
3009
+ sizeEstimate: z15.object({ files: z15.number().int().min(0), lines: z15.number().int().min(0) }).optional(),
3010
+ priority: z15.enum(PLAN_PRIORITIES).default("none")
2893
3011
  });
2894
- var planSplit = z14.object({
2895
- summary: z14.string().trim().max(4e3).default(""),
2896
- issues: z14.array(planIssue).min(1).max(100)
3012
+ var planSplit = z15.object({
3013
+ summary: z15.string().trim().max(4e3).default(""),
3014
+ issues: z15.array(planIssue).min(1).max(100)
2897
3015
  });
2898
- var planHandoff = z14.object({
2899
- specId: z14.uuid(),
3016
+ var planHandoff = z15.object({
3017
+ specId: z15.uuid(),
2900
3018
  spec: planSpec,
2901
3019
  split: planSplit
2902
3020
  });
@@ -2908,12 +3026,12 @@ var RUN_QUESTION_KINDS = [
2908
3026
  "permission",
2909
3027
  "external"
2910
3028
  ];
2911
- var runQuestion = z15.object({
2912
- questionId: z15.uuid(),
2913
- kind: z15.enum(RUN_QUESTION_KINDS).default("decision"),
2914
- question: z15.string().trim().min(1).max(4e3),
2915
- context: z15.string().trim().max(4e3).optional(),
2916
- options: z15.array(z15.string().trim().min(1).max(4e3)).max(20).default([])
3029
+ var runQuestion = z16.object({
3030
+ questionId: z16.uuid(),
3031
+ kind: z16.enum(RUN_QUESTION_KINDS).default("decision"),
3032
+ question: z16.string().trim().min(1).max(4e3),
3033
+ context: z16.string().trim().max(4e3).optional(),
3034
+ options: z16.array(z16.string().trim().min(1).max(4e3)).max(20).default([])
2917
3035
  }).strict();
2918
3036
  var RUN_STOP_REASONS = [
2919
3037
  "submitted",
@@ -2925,37 +3043,37 @@ var RUN_STOP_REASONS = [
2925
3043
  "timeout",
2926
3044
  "device_lost"
2927
3045
  ];
2928
- var runStopReason = z15.enum(RUN_STOP_REASONS);
2929
- var shortList = z15.array(z15.string().max(1e3)).max(5e3);
3046
+ var runStopReason = z16.enum(RUN_STOP_REASONS);
3047
+ var shortList = z16.array(z16.string().max(1e3)).max(5e3);
2930
3048
  var VERIFY_STATUSES = ["passed", "failed", "not_run"];
2931
- var verifyStatus = z15.enum(VERIFY_STATUSES);
2932
- var runPublish = z15.object({
3049
+ var verifyStatus = z16.enum(VERIFY_STATUSES);
3050
+ var runPublish = z16.object({
2933
3051
  /** Where the commit went: the issue's branch, or the run's own. */
2934
- branch: z15.string().max(500),
3052
+ branch: z16.string().max(500),
2935
3053
  /** Null when nothing was committed (no changes, or the commit failed). */
2936
- commit: z15.string().max(100).nullable(),
2937
- pushed: z15.boolean(),
2938
- remote: z15.string().max(200).nullable(),
3054
+ commit: z16.string().max(100).nullable(),
3055
+ pushed: z16.boolean(),
3056
+ remote: z16.string().max(200).nullable(),
2939
3057
  /**
2940
3058
  * Why nothing was pushed when that was expected: the agent changed
2941
3059
  * nothing, or the repo has not approved pushes. Absent with
2942
3060
  * `pushed: false` means the commit or the push failed (see `note`).
2943
3061
  */
2944
- skipped: z15.enum(["no_changes", "not_approved"]).optional(),
2945
- note: z15.string().max(2e3).optional()
3062
+ skipped: z16.enum(["no_changes", "not_approved"]).optional(),
3063
+ note: z16.string().max(2e3).optional()
2946
3064
  });
2947
- var runBenchmarkContext = z15.object({
2948
- sourceCommit: z15.string().regex(/^[a-f0-9]{40}$/),
2949
- benchmarkDigest: z15.string().regex(/^[a-f0-9]{64}$/),
2950
- caseId: z15.string().min(1).max(200),
2951
- fixtureDigest: z15.string().regex(/^[a-f0-9]{64}$/),
2952
- policyDigest: z15.string().regex(/^[a-f0-9]{64}$/)
3065
+ var runBenchmarkContext = z16.object({
3066
+ sourceCommit: z16.string().regex(/^[a-f0-9]{40}$/),
3067
+ benchmarkDigest: z16.string().regex(/^[a-f0-9]{64}$/),
3068
+ caseId: z16.string().min(1).max(200),
3069
+ fixtureDigest: z16.string().regex(/^[a-f0-9]{64}$/),
3070
+ policyDigest: z16.string().regex(/^[a-f0-9]{64}$/)
2953
3071
  }).strict();
2954
3072
  var runExecution = runBenchmarkContext.extend({
2955
- harness: z15.enum(["codex", "claude_code", "cursor"]),
2956
- requestedModel: z15.string().min(1).max(500).nullable(),
2957
- observedModel: z15.string().min(1).max(500).nullable(),
2958
- verifyCommand: z15.string().min(1).max(2e3)
3073
+ harness: z16.enum(["codex", "claude_code", "cursor"]),
3074
+ requestedModel: z16.string().min(1).max(500).nullable(),
3075
+ observedModel: z16.string().min(1).max(500).nullable(),
3076
+ verifyCommand: z16.string().min(1).max(2e3)
2959
3077
  }).strict();
2960
3078
  var runRuntime = runExecution.pick({
2961
3079
  harness: true,
@@ -2964,57 +3082,57 @@ var runRuntime = runExecution.pick({
2964
3082
  policyDigest: true,
2965
3083
  sourceCommit: true
2966
3084
  }).strict();
2967
- var runSkillMount = z15.object({
2968
- receiptId: z15.uuid(),
2969
- versionId: z15.uuid(),
2970
- sha256: z15.string().regex(/^[a-f0-9]{64}$/),
2971
- sessionId: z15.string().min(1).max(500),
2972
- mountedAt: z15.iso.datetime()
3085
+ var runSkillMount = z16.object({
3086
+ receiptId: z16.uuid(),
3087
+ versionId: z16.uuid(),
3088
+ sha256: z16.string().regex(/^[a-f0-9]{64}$/),
3089
+ sessionId: z16.string().min(1).max(500),
3090
+ mountedAt: z16.iso.datetime()
2973
3091
  }).strict();
2974
- var runReport = z15.object({
3092
+ var runReport = z16.object({
2975
3093
  /** Worktree base journaled before the adapter started; never agent-supplied. */
2976
- sourceCommit: z15.string().regex(/^[a-f0-9]{40}$/).optional(),
3094
+ sourceCommit: z16.string().regex(/^[a-f0-9]{40}$/).optional(),
2977
3095
  skillMount: runSkillMount.optional(),
2978
3096
  execution: runExecution.optional(),
2979
3097
  runtime: runRuntime.optional(),
2980
3098
  /** What was done, in a few sentences. Empty when the run crashed early. */
2981
- summary: z15.string().max(1e4),
3099
+ summary: z16.string().max(1e4),
2982
3100
  /** Paths relative to the worktree root (from `git status`). */
2983
3101
  filesChanged: shortList,
2984
3102
  /** The daemon's run of the issue's verify command after a submit. */
2985
- verify: z15.object({
3103
+ verify: z16.object({
2986
3104
  status: verifyStatus,
2987
- command: z15.string().max(2e3).optional(),
3105
+ command: z16.string().max(2e3).optional(),
2988
3106
  /** Actual process outcome from the daemon, never the agent. */
2989
- exitCode: z15.number().int().nullable().optional(),
2990
- signal: z15.string().max(100).nullable().optional(),
2991
- timedOut: z15.boolean().optional(),
3107
+ exitCode: z16.number().int().nullable().optional(),
3108
+ signal: z16.string().max(100).nullable().optional(),
3109
+ timedOut: z16.boolean().optional(),
2992
3110
  /** Tail of the command output. */
2993
- output: z15.string().max(1e4).optional()
3111
+ output: z16.string().max(1e4).optional()
2994
3112
  }),
2995
- openQuestions: z15.array(z15.string().max(2e3)).max(50),
3113
+ openQuestions: z16.array(z16.string().max(2e3)).max(50),
2996
3114
  /** What should happen next, from the agent's point of view. */
2997
3115
  question: runQuestion.optional(),
2998
- nextStep: z15.string().max(2e3).nullable(),
3116
+ nextStep: z16.string().max(2e3).nullable(),
2999
3117
  /** For `blocked`: the external condition, e.g. `quota_exhausted`. */
3000
- blockedOn: z15.string().max(500).optional(),
3118
+ blockedOn: z16.string().max(500).optional(),
3001
3119
  /** Daemon-owned receipt for an exact, unchanged read-only candidate. */
3002
- check: z15.object({
3003
- sha: z15.string().regex(/^[a-f0-9]{40}$/),
3004
- readOnly: z15.literal(true)
3120
+ check: z16.object({
3121
+ sha: z16.string().regex(/^[a-f0-9]{40}$/),
3122
+ readOnly: z16.literal(true)
3005
3123
  }).optional(),
3006
3124
  /** Preview branch created or used by the producing run; descriptive metadata only. */
3007
- previewDatabaseBranch: z15.string().trim().min(1).max(500).optional(),
3125
+ previewDatabaseBranch: z16.string().trim().min(1).max(500).optional(),
3008
3126
  /** Acceptance criteria the agent checked, with evidence. */
3009
- criteria: z15.array(
3010
- z15.object({
3011
- criterionId: z15.uuid().optional(),
3012
- text: z15.string().max(2e3).optional(),
3013
- passed: z15.boolean(),
3014
- evidence: z15.string().max(1e4).optional(),
3127
+ criteria: z16.array(
3128
+ z16.object({
3129
+ criterionId: z16.uuid().optional(),
3130
+ text: z16.string().max(2e3).optional(),
3131
+ passed: z16.boolean(),
3132
+ evidence: z16.string().max(1e4).optional(),
3015
3133
  /** Agent-reported criterion check; the daemon-owned verify remains authoritative. */
3016
- command: z15.string().trim().min(1).max(2e3).optional(),
3017
- exitCode: z15.number().int().nullable().optional()
3134
+ command: z16.string().trim().min(1).max(2e3).optional(),
3135
+ exitCode: z16.number().int().nullable().optional()
3018
3136
  })
3019
3137
  ).max(200).optional(),
3020
3138
  /**
@@ -3024,23 +3142,23 @@ var runReport = z15.object({
3024
3142
  plan: planHandoff.optional(),
3025
3143
  interfacesProduced: shortList.optional(),
3026
3144
  knownIssues: shortList.optional(),
3027
- notesForNext: z15.string().max(1e4).optional(),
3145
+ notesForNext: z16.string().max(1e4).optional(),
3028
3146
  /** Set by the daemon after a verified submit; never by the agent. */
3029
3147
  publish: runPublish.optional(),
3030
- followUps: z15.array(
3031
- z15.object({
3032
- title: z15.string().trim().min(1).max(500),
3033
- goal: z15.string().max(2e3).optional(),
3034
- reason: z15.string().max(2e3).optional()
3148
+ followUps: z16.array(
3149
+ z16.object({
3150
+ title: z16.string().trim().min(1).max(500),
3151
+ goal: z16.string().max(2e3).optional(),
3152
+ reason: z16.string().max(2e3).optional()
3035
3153
  })
3036
3154
  ).max(50).optional()
3037
3155
  });
3038
3156
  var runCompletePath = (runId) => `/v1/runs/${encodeURIComponent(runId)}/complete`;
3039
- var runCompletion = z15.object({
3157
+ var runCompletion = z16.object({
3040
3158
  stopReason: runStopReason,
3041
3159
  report: runReport
3042
3160
  });
3043
- var runCompleteRequest = z15.object({ stopReason: runStopReason, report: runReport.optional() }).refine((body) => body.stopReason !== "submitted" || body.report, {
3161
+ var runCompleteRequest = z16.object({ stopReason: runStopReason, report: runReport.optional() }).refine((body) => body.stopReason !== "submitted" || body.report, {
3044
3162
  message: "A submitted run needs a report.",
3045
3163
  path: ["report"]
3046
3164
  });
@@ -3058,7 +3176,7 @@ var RUN_STATES = [
3058
3176
  "failed",
3059
3177
  "cancelled"
3060
3178
  ];
3061
- var runStateSchema = z16.enum(RUN_STATES);
3179
+ var runStateSchema = z17.enum(RUN_STATES);
3062
3180
  var stopReasonSchema = runStopReason;
3063
3181
  var DAEMON_RPC_ERRORS = {
3064
3182
  handshakeRequired: 4001,
@@ -3072,58 +3190,58 @@ var DAEMON_RPC_ERRORS = {
3072
3190
  serverUnreachable: 4020,
3073
3191
  draining: 4030
3074
3192
  };
3075
- var helloParams = z16.object({
3076
- protocolVersion: z16.number().int(),
3193
+ var helloParams = z17.object({
3194
+ protocolVersion: z17.number().int(),
3077
3195
  /** Contents of the daemon's `daemon.secret` file in the flavor data dir. */
3078
- secret: z16.string(),
3079
- client: z16.object({ name: z16.string(), version: z16.string() })
3196
+ secret: z17.string(),
3197
+ client: z17.object({ name: z17.string(), version: z17.string() })
3080
3198
  });
3081
- var helloResult = z16.object({
3082
- protocolVersion: z16.number().int(),
3083
- daemonVersion: z16.string(),
3084
- pid: z16.number().int()
3199
+ var helloResult = z17.object({
3200
+ protocolVersion: z17.number().int(),
3201
+ daemonVersion: z17.string(),
3202
+ pid: z17.number().int()
3085
3203
  });
3086
- var runSummarySchema = z16.object({
3087
- runId: z16.string(),
3088
- issueId: z16.string(),
3204
+ var runSummarySchema = z17.object({
3205
+ runId: z17.string(),
3206
+ issueId: z17.string(),
3089
3207
  harness: harnessSchema,
3090
3208
  state: runStateSchema,
3091
- worktree: z16.string().nullable(),
3092
- sessionId: z16.string().nullable(),
3209
+ worktree: z17.string().nullable(),
3210
+ sessionId: z17.string().nullable(),
3093
3211
  /** Chunks emitted so far (the daemon-local producer sequence). */
3094
- chunks: z16.number().int().nonnegative(),
3095
- error: z16.string().nullable(),
3212
+ chunks: z17.number().int().nonnegative(),
3213
+ error: z17.string().nullable(),
3096
3214
  /** Set once the run reached a terminal state. */
3097
3215
  stopReason: stopReasonSchema.optional(),
3098
3216
  /** Lease from the server; the daemon stops the run if it cannot renew it. */
3099
- leaseExpiresAt: z16.string().optional(),
3217
+ leaseExpiresAt: z17.string().optional(),
3100
3218
  /** Last progress seen by the watchdog (ISO time), while the run is active. */
3101
- lastProgressAt: z16.string().optional()
3219
+ lastProgressAt: z17.string().optional()
3102
3220
  });
3103
- var daemonStatusSchema = z16.object({
3104
- daemonVersion: z16.string(),
3105
- protocolVersion: z16.number().int(),
3106
- pid: z16.number().int(),
3107
- dataDir: z16.string(),
3221
+ var daemonStatusSchema = z17.object({
3222
+ daemonVersion: z17.string(),
3223
+ protocolVersion: z17.number().int(),
3224
+ pid: z17.number().int(),
3225
+ dataDir: z17.string(),
3108
3226
  /** Null until the device is registered with the server. */
3109
- deviceId: z16.string().nullable(),
3227
+ deviceId: z17.string().nullable(),
3110
3228
  /** The workspace the device credential was handed over for, if named. */
3111
- workspaceId: z16.string().nullable(),
3229
+ workspaceId: z17.string().nullable(),
3112
3230
  /** Holds a device credential (it may still be refused by the server). */
3113
- signedIn: z16.boolean(),
3114
- server: z16.enum(["online", "offline", "unregistered"]),
3115
- harnesses: z16.array(harnessInfoSchema),
3116
- runs: z16.array(runSummarySchema),
3231
+ signedIn: z17.boolean(),
3232
+ server: z17.enum(["online", "offline", "unregistered"]),
3233
+ harnesses: z17.array(harnessInfoSchema),
3234
+ runs: z17.array(runSummarySchema),
3117
3235
  /** Bytes used by run worktrees under the daemon's data dir. */
3118
- worktreeDiskBytes: z16.number().int().nonnegative(),
3236
+ worktreeDiskBytes: z17.number().int().nonnegative(),
3119
3237
  /** Items buffered on disk, waiting for the server. */
3120
- pendingUploads: z16.number().int().nonnegative(),
3121
- draining: z16.boolean(),
3238
+ pendingUploads: z17.number().int().nonnegative(),
3239
+ draining: z17.boolean(),
3122
3240
  /** Latest subscription snapshots. Empty when quota polling is off. */
3123
- quotas: z16.array(quotaSnapshotSchema).max(6)
3241
+ quotas: z17.array(quotaSnapshotSchema).max(6)
3124
3242
  });
3125
- var empty = z16.object({}).optional();
3126
- var ok = z16.object({ ok: z16.literal(true) });
3243
+ var empty = z17.object({}).optional();
3244
+ var ok = z17.object({ ok: z17.literal(true) });
3127
3245
  var daemonRpc = {
3128
3246
  "daemon.hello": { params: helloParams, result: helloResult },
3129
3247
  "daemon.status": { params: empty, result: daemonStatusSchema },
@@ -3133,10 +3251,10 @@ var daemonRpc = {
3133
3251
  "daemon.drain": { params: empty, result: ok },
3134
3252
  /** Hand the daemon a device credential obtained by the signed-in desktop. */
3135
3253
  "device.setCredential": {
3136
- params: z16.object({
3137
- credential: z16.string().min(1),
3254
+ params: z17.object({
3255
+ credential: z17.string().min(1),
3138
3256
  /** Needed only for users in more than one workspace. */
3139
- workspaceId: z16.uuid().optional()
3257
+ workspaceId: z17.uuid().optional()
3140
3258
  }),
3141
3259
  result: ok
3142
3260
  },
@@ -3144,17 +3262,17 @@ var daemonRpc = {
3144
3262
  "device.clearCredential": { params: empty, result: ok },
3145
3263
  /** Claim a queued run pinned to this device and start it. */
3146
3264
  "runs.start": {
3147
- params: z16.object({ runId: z16.string() }),
3265
+ params: z17.object({ runId: z17.string() }),
3148
3266
  result: runSummarySchema
3149
3267
  },
3150
- "runs.list": { params: empty, result: z16.array(runSummarySchema) },
3268
+ "runs.list": { params: empty, result: z17.array(runSummarySchema) },
3151
3269
  /** Interject a user message into a running session. */
3152
3270
  "runs.send": {
3153
- params: z16.object({ runId: z16.string(), text: z16.string().min(1) }),
3271
+ params: z17.object({ runId: z17.string(), text: z17.string().min(1) }),
3154
3272
  result: ok
3155
3273
  },
3156
3274
  "runs.cancel": {
3157
- params: z16.object({ runId: z16.string() }),
3275
+ params: z17.object({ runId: z17.string() }),
3158
3276
  result: runSummarySchema
3159
3277
  },
3160
3278
  /**
@@ -3162,21 +3280,21 @@ var daemonRpc = {
3162
3280
  * run on an allow-listed repo without a server. Refused otherwise.
3163
3281
  */
3164
3282
  "dev.mockRun": {
3165
- params: z16.object({
3166
- repoId: z16.string(),
3167
- fixture: z16.string().optional(),
3168
- baseBranch: z16.string().optional(),
3283
+ params: z17.object({
3284
+ repoId: z17.string(),
3285
+ fixture: z17.string().optional(),
3286
+ baseBranch: z17.string().optional(),
3169
3287
  /** Run after the mock submits; defaults to `git diff --check`. */
3170
- verifyCommand: z16.string().optional()
3288
+ verifyCommand: z17.string().optional()
3171
3289
  }),
3172
3290
  result: runSummarySchema
3173
3291
  }
3174
3292
  };
3175
3293
 
3176
3294
  // ../protocol/src/device.ts
3177
- import { z as z17 } from "zod";
3178
- var id2 = z17.string().min(1).max(64);
3179
- var isoTime = z17.iso.datetime({ offset: true });
3295
+ import { z as z18 } from "zod";
3296
+ var id3 = z18.string().min(1).max(64);
3297
+ var isoTime = z18.iso.datetime({ offset: true });
3180
3298
  var seg = encodeURIComponent;
3181
3299
  var DEVICE_ROUTES = {
3182
3300
  register: "/v1/devices/register",
@@ -3202,16 +3320,16 @@ var devicePaths = {
3202
3320
  runPatch: (runId) => `/v1/runs/${seg(runId)}`,
3203
3321
  runCheckpoint: (runId) => `/v1/runs/${seg(runId)}/checkpoint`
3204
3322
  };
3205
- var deviceComputerCapability = z17.object({ installed: z17.boolean(), version: z17.string().max(100).nullable() }).strict();
3206
- var deviceRegistration = z17.object({
3207
- deviceType: z17.enum(["laptop", "server"]).optional(),
3208
- name: z17.string().trim().min(1).max(200),
3209
- hostname: z17.string().max(255).nullable().optional(),
3210
- platform: z17.string().max(50),
3211
- arch: z17.string().max(50),
3212
- daemonVersion: z17.string().max(50),
3213
- protocolVersion: z17.number().int(),
3214
- harnesses: z17.array(harnessInfoSchema).max(20),
3323
+ var deviceComputerCapability = z18.object({ installed: z18.boolean(), version: z18.string().max(100).nullable() }).strict();
3324
+ var deviceRegistration = z18.object({
3325
+ deviceType: z18.enum(["laptop", "server"]).optional(),
3326
+ name: z18.string().trim().min(1).max(200),
3327
+ hostname: z18.string().max(255).nullable().optional(),
3328
+ platform: z18.string().max(50),
3329
+ arch: z18.string().max(50),
3330
+ daemonVersion: z18.string().max(50),
3331
+ protocolVersion: z18.number().int(),
3332
+ harnesses: z18.array(harnessInfoSchema).max(20),
3215
3333
  computerUse: deviceComputerCapability.optional(),
3216
3334
  /**
3217
3335
  * This machine's one device id, the same in every workspace (ADR ORV-284).
@@ -3219,106 +3337,106 @@ var deviceRegistration = z17.object({
3219
3337
  * An id the server does not know yet becomes the new device's id; another
3220
3338
  * person's id registers a new device.
3221
3339
  */
3222
- deviceId: id2.optional(),
3340
+ deviceId: id3.optional(),
3223
3341
  /** Needed only when the user belongs to more than one workspace. */
3224
- workspaceId: z17.uuid().optional()
3342
+ workspaceId: z18.uuid().optional()
3225
3343
  });
3226
- var deviceRegistered = z17.object({
3227
- deviceId: id2,
3228
- workspaceId: z17.uuid()
3344
+ var deviceRegistered = z18.object({
3345
+ deviceId: id3,
3346
+ workspaceId: z18.uuid()
3229
3347
  });
3230
- var heartbeatRunSchema = z17.object({
3231
- runId: id2,
3348
+ var heartbeatRunSchema = z18.object({
3349
+ runId: id3,
3232
3350
  /** Last tool call, turn boundary or file change (not raw output). */
3233
3351
  lastProgressAt: isoTime
3234
3352
  });
3235
- var deviceManagementCommand = z17.object({ id: z17.uuid(), kind: z17.enum(["redetect", "restart", "update", "uninstall"]) });
3236
- var deviceHeartbeatSchema = z17.object({
3237
- completedDeviceCommands: z17.array(z17.uuid()).max(100).optional(),
3238
- failedDeviceCommands: z17.array(z17.object({ id: z17.uuid(), error: z17.string().max(500) })).max(100).optional(),
3239
- harnesses: z17.array(harnessInfoSchema).max(20),
3353
+ var deviceManagementCommand = z18.object({ id: z18.uuid(), kind: z18.enum(["redetect", "restart", "update", "uninstall"]) });
3354
+ var deviceHeartbeatSchema = z18.object({
3355
+ completedDeviceCommands: z18.array(z18.uuid()).max(100).optional(),
3356
+ failedDeviceCommands: z18.array(z18.object({ id: z18.uuid(), error: z18.string().max(500) })).max(100).optional(),
3357
+ harnesses: z18.array(harnessInfoSchema).max(20),
3240
3358
  computerUse: deviceComputerCapability.optional(),
3241
- deviceType: z17.enum(["laptop", "server"]).optional(),
3242
- runs: z17.array(heartbeatRunSchema).max(500),
3243
- worktreeDiskBytes: z17.number().int().nonnegative(),
3359
+ deviceType: z18.enum(["laptop", "server"]).optional(),
3360
+ runs: z18.array(heartbeatRunSchema).max(500),
3361
+ worktreeDiskBytes: z18.number().int().nonnegative(),
3244
3362
  /**
3245
3363
  * Subscription windows read on this device. Absent when the daemon is not
3246
3364
  * polling. Numbers only, never a vendor credential (ADR 0027).
3247
3365
  */
3248
- quotas: z17.array(quotaSnapshotSchema).max(6).optional()
3366
+ quotas: z18.array(quotaSnapshotSchema).max(6).optional()
3249
3367
  });
3250
- var heartbeatResultSchema = z17.object({
3251
- deviceCommands: z17.array(deviceManagementCommand).max(1).optional(),
3368
+ var heartbeatResultSchema = z18.object({
3369
+ deviceCommands: z18.array(deviceManagementCommand).max(1).optional(),
3252
3370
  /** Renewed lease expiry per run id; a run missing here is not renewed. */
3253
- leases: z17.record(z17.string(), isoTime),
3371
+ leases: z18.record(z18.string(), isoTime),
3254
3372
  /**
3255
3373
  * Runs the device reported that it no longer holds: they ended on the
3256
3374
  * server, or went to another attempt after the lease ran out. The daemon
3257
3375
  * stops them now instead of when their lease runs out.
3258
3376
  */
3259
- revoked: z17.array(id2).max(500).optional(),
3377
+ revoked: z18.array(id3).max(500).optional(),
3260
3378
  /** Short-lived cloud device token, returned only over its authenticated link. */
3261
- cloudCredential: z17.string().regex(/^orv_[A-Za-z0-9_-]{43}$/).optional()
3379
+ cloudCredential: z18.string().regex(/^orv_[A-Za-z0-9_-]{43}$/).optional()
3262
3380
  });
3263
3381
  var RUN_CHECKPOINT_MAX_BYTES = 8 * 1024 * 1024;
3264
3382
  var RECOVERY_WORKTREE_HEADER = "x-mikka-recovery-worktree";
3265
3383
  var RUN_CHECKPOINT_RECOVERY_MAX_AGE_MS = 30 * 6e4;
3266
- var runCheckpointSchema = z17.object({
3384
+ var runCheckpointSchema = z18.object({
3267
3385
  /** The commit the run's worktree started from. */
3268
- baseCommit: z17.string().regex(/^[0-9a-f]{40,64}$/),
3386
+ baseCommit: z18.string().regex(/^[0-9a-f]{40,64}$/),
3269
3387
  /**
3270
3388
  * `git diff --binary` from `baseCommit` to the whole worktree (tracked
3271
3389
  * and untracked files, ignored ones left out, the agent's own commits
3272
3390
  * included), gzipped, base64.
3273
3391
  */
3274
- patch: z17.string().max(Math.ceil(RUN_CHECKPOINT_MAX_BYTES * 4 / 3) + 4),
3392
+ patch: z18.string().max(Math.ceil(RUN_CHECKPOINT_MAX_BYTES * 4 / 3) + 4),
3275
3393
  /** Files the patch touches. */
3276
- files: z17.number().int().nonnegative(),
3394
+ files: z18.number().int().nonnegative(),
3277
3395
  takenAt: isoTime,
3278
3396
  /** The latest tree could not be checkpointed; it supersedes older patches. */
3279
- unavailableReason: z17.literal("too_large").optional()
3397
+ unavailableReason: z18.literal("too_large").optional()
3280
3398
  });
3281
- var setupRecipeSchema = z17.object({
3399
+ var setupRecipeSchema = z18.object({
3282
3400
  /** Paths relative to the main checkout copied into each new worktree. */
3283
- copyFiles: z17.array(z17.string().max(1e3)).max(200),
3401
+ copyFiles: z18.array(z18.string().max(1e3)).max(200),
3284
3402
  /** Shell command run in the worktree, e.g. `bun install`. */
3285
- command: z17.string().max(2e3).optional(),
3403
+ command: z18.string().max(2e3).optional(),
3286
3404
  /** Approved once per repo by the user; unapproved recipes never run. */
3287
- approved: z17.boolean()
3405
+ approved: z18.boolean()
3288
3406
  });
3289
3407
  var REPO_ORIGIN_HEADER = "x-mikka-repo-origin-check";
3290
- var deviceRepoSchema = z17.object({
3291
- repoId: id2,
3292
- name: z17.string().max(500),
3408
+ var deviceRepoSchema = z18.object({
3409
+ repoId: id3,
3410
+ name: z18.string().max(500),
3293
3411
  /** Logical repository key; only trusted cloud runtimes use an absolute path. */
3294
- path: z17.string().min(1).max(4e3),
3295
- remoteUrl: z17.string().max(2e3).nullable().optional(),
3412
+ path: z18.string().min(1).max(4e3),
3413
+ remoteUrl: z18.string().max(2e3).nullable().optional(),
3296
3414
  setup: setupRecipeSchema.optional(),
3297
3415
  /** Domains agents may reach in this repo, on top of the harness's own. */
3298
- networkAllow: z17.array(z17.string().min(1).max(253)).max(200).optional(),
3416
+ networkAllow: z18.array(z18.string().min(1).max(253)).max(200).optional(),
3299
3417
  /** Push run branches after a verified hand-in ("always for this repo"). */
3300
- push: z17.object({
3301
- approved: z17.boolean(),
3302
- remote: z17.string().min(1).max(200).optional()
3418
+ push: z18.object({
3419
+ approved: z18.boolean(),
3420
+ remote: z18.string().min(1).max(200).optional()
3303
3421
  }).optional()
3304
3422
  });
3305
- var deviceReposResponse = z17.object({
3306
- repos: z17.array(deviceRepoSchema)
3423
+ var deviceReposResponse = z18.object({
3424
+ repos: z18.array(deviceRepoSchema)
3307
3425
  });
3308
- var pendingRunsResponse = z17.object({ runIds: z17.array(id2) });
3426
+ var pendingRunsResponse = z18.object({ runIds: z18.array(id3) });
3309
3427
  var RUN_KINDS = ["implement", "acceptance", "fix", "plan"];
3310
- var runAssignmentSchema = z17.object({
3311
- runId: id2,
3312
- issueId: id2,
3313
- deviceId: id2,
3314
- repoId: id2,
3428
+ var runAssignmentSchema = z18.object({
3429
+ runId: id3,
3430
+ issueId: id3,
3431
+ deviceId: id3,
3432
+ repoId: id3,
3315
3433
  /** Clone URL for local runs; hosted computer assignments keep their isolated workspace. */
3316
- remoteUrl: z17.string().min(1).max(4e3).optional(),
3434
+ remoteUrl: z18.string().min(1).max(4e3).optional(),
3317
3435
  /** Absent means origin/HEAD after fetch. */
3318
- baseBranch: z17.string().min(1).max(500).optional(),
3319
- expectedRepoRemote: z17.string().max(2e3).optional(),
3436
+ baseBranch: z18.string().min(1).max(500).optional(),
3437
+ expectedRepoRemote: z18.string().max(2e3).optional(),
3320
3438
  harness: harnessSchema,
3321
- prompt: z17.string().max(1e5),
3439
+ prompt: z18.string().max(1e5),
3322
3440
  /**
3323
3441
  * The model the harness's CLI is asked to run, from the per-harness
3324
3442
  * preference of the person this run works for (ADR 0060). Absent: the
@@ -3327,42 +3445,42 @@ var runAssignmentSchema = z17.object({
3327
3445
  */
3328
3446
  model: modelNameSchema.optional(),
3329
3447
  /** Owner-bound selection only; no subscription credential enters the assignment. */
3330
- subscriptionBinding: z17.object({
3331
- bindingId: z17.uuid(),
3332
- ownerId: z17.string().min(1).max(128),
3333
- workspaceId: z17.uuid(),
3334
- consumerId: z17.uuid(),
3335
- route: z17.enum(["codex_cli", "claude_code_cli"])
3448
+ subscriptionBinding: z18.object({
3449
+ bindingId: z18.uuid(),
3450
+ ownerId: z18.string().min(1).max(128),
3451
+ workspaceId: z18.uuid(),
3452
+ consumerId: z18.uuid(),
3453
+ route: z18.enum(["codex_cli", "claude_code_cli"])
3336
3454
  }).strict().optional(),
3337
3455
  /** Local host authority comes only from the server's owner-bound Bot run. */
3338
- localComputer: z17.object({
3339
- botId: z17.uuid(),
3340
- ownerId: z17.string().min(1).max(128),
3341
- workspaceId: z17.uuid(),
3342
- policyVersion: z17.number().int().nonnegative().max(2147483647),
3343
- permission: z17.enum(["allow", "ask"])
3456
+ localComputer: z18.object({
3457
+ botId: z18.uuid(),
3458
+ ownerId: z18.string().min(1).max(128),
3459
+ workspaceId: z18.uuid(),
3460
+ policyVersion: z18.number().int().nonnegative().max(2147483647),
3461
+ permission: z18.enum(["allow", "ask"])
3344
3462
  }).strict().optional(),
3345
3463
  /** Trusted server assignment; the model cannot choose a Bot or display. */
3346
- computer: z17.object({
3347
- botId: z17.uuid(),
3348
- ownerId: z17.string().min(1).max(128),
3349
- display: z17.string().regex(/^:[1-9][0-9]{0,2}$/),
3350
- policyVersion: z17.number().int().nonnegative().max(2147483647)
3464
+ computer: z18.object({
3465
+ botId: z18.uuid(),
3466
+ ownerId: z18.string().min(1).max(128),
3467
+ display: z18.string().regex(/^:[1-9][0-9]{0,2}$/),
3468
+ policyVersion: z18.number().int().nonnegative().max(2147483647)
3351
3469
  }).strict().optional(),
3352
3470
  /**
3353
3471
  * 4e3: the task's explicit user variables (workspace + matching repository secrets/env, NAME -> value).
3354
3472
  * Cloud workers only. Passed into the task container through its own channel, never into the worker's
3355
3473
  * env, and never written to the run journal.
3356
3474
  */
3357
- taskEnv: z17.record(z17.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/), z17.string().max(65536)).optional(),
3475
+ taskEnv: z18.record(z18.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/), z18.string().max(65536)).optional(),
3358
3476
  /**
3359
3477
  * Names in `taskEnv` that are secrets (kind 'secret'; env vars are not listed). The daemon masks
3360
3478
  * their values (raw + standard base64) in run output before anything is uploaded; the server
3361
3479
  * masks again. Older daemons strip this field and rely on server-side masking only.
3362
3480
  */
3363
- taskSecretNames: z17.array(z17.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/)).max(500).optional(),
3481
+ taskSecretNames: z18.array(z18.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/)).max(500).optional(),
3364
3482
  /** Mock harness only: fixture name under `packages/daemon/fixtures`. */
3365
- fixture: z17.string().max(200).optional(),
3483
+ fixture: z18.string().max(200).optional(),
3366
3484
  /**
3367
3485
  * The issue's branch (`mikka/<team>-<number>`, ADR 0024): every run of
3368
3486
  * the issue pushes its verified commit here, so one pull request follows
@@ -3370,9 +3488,9 @@ var runAssignmentSchema = z17.object({
3370
3488
  * this branch from the remote when it exists. Without it the daemon
3371
3489
  * pushes the run's own branch.
3372
3490
  */
3373
- pushBranch: z17.string().min(1).max(250).optional(),
3491
+ pushBranch: z18.string().min(1).max(250).optional(),
3374
3492
  /** Run by the daemon in the worktree after the agent submits. */
3375
- verifyCommand: z17.string().max(2e3).optional(),
3493
+ verifyCommand: z18.string().max(2e3).optional(),
3376
3494
  /** Run lease; renewed through the device heartbeat. */
3377
3495
  leaseExpiresAt: isoTime.optional(),
3378
3496
  /**
@@ -3381,27 +3499,27 @@ var runAssignmentSchema = z17.object({
3381
3499
  * it stops working when the run ends. Absent: the server could not issue
3382
3500
  * one, and the run goes ahead without it.
3383
3501
  */
3384
- mcp: z17.object({ url: z17.url(), token: z17.string().min(1).max(200), mailbox: z17.literal(true).optional() }).optional(),
3502
+ mcp: z18.object({ url: z18.url(), token: z18.string().min(1).max(200), mailbox: z18.literal(true).optional() }).optional(),
3385
3503
  /** Agent-owned GitHub delivery; the same run token exchanges short-lived credentials. */
3386
- github: z17.object({
3387
- endpoint: z17.url(),
3388
- repository: z17.string().regex(/^[a-z0-9_.-]+\/[a-z0-9_.-]+$/),
3389
- branch: z17.string().regex(/^mikka\/[a-z0-9-]+-[1-9][0-9]*$/)
3504
+ github: z18.object({
3505
+ endpoint: z18.url(),
3506
+ repository: z18.string().regex(/^[a-z0-9_.-]+\/[a-z0-9_.-]+$/),
3507
+ branch: z18.string().regex(/^mikka\/[a-z0-9-]+-[1-9][0-9]*$/)
3390
3508
  }).strict().optional(),
3391
3509
  /** Question continuation must not silently open a different session. */
3392
3510
  /**
3393
3511
  * What the orchestrator dispatched this run for (ADR 0023). `plan` writes a
3394
3512
  * spec and proposes a split instead of changing code (ADR ORV-205).
3395
3513
  */
3396
- kind: z17.enum(RUN_KINDS).optional(),
3514
+ kind: z18.enum(RUN_KINDS).optional(),
3397
3515
  /**
3398
3516
  * The earlier run this one continues (continue, fix, answer, a person's
3399
3517
  * message): the daemon works on in that run's worktree, on this run's
3400
3518
  * branch, so nothing the earlier run left uncommitted is lost.
3401
3519
  */
3402
- continuesRunId: id2.optional(),
3520
+ continuesRunId: id3.optional(),
3403
3521
  /** A same-device retry with no usable snapshot must reuse its real worktree. */
3404
- requireWorktreeContinuation: z17.literal(true).optional(),
3522
+ requireWorktreeContinuation: z18.literal(true).optional(),
3405
3523
  /**
3406
3524
  * The latest checkpoint of the attempt this run takes over after its
3407
3525
  * machine went offline. Used only for a new worktree (another machine, or
@@ -3414,37 +3532,40 @@ var runAssignmentSchema = z17.object({
3414
3532
  * The harness session to continue. A daemon that cannot resume starts a
3415
3533
  * new session with `prompt`, which always carries the full brief.
3416
3534
  */
3417
- resumeSessionId: z17.string().max(500).optional(),
3418
- requireSessionResume: z17.boolean().optional(),
3419
- preserveQuestionWorktree: z17.boolean().optional(),
3420
- questionId: z17.uuid().optional(),
3535
+ resumeSessionId: z18.string().max(500).optional(),
3536
+ requireSessionResume: z18.boolean().optional(),
3537
+ preserveQuestionWorktree: z18.boolean().optional(),
3538
+ questionId: z18.uuid().optional(),
3421
3539
  /**
3422
3540
  * What this run adds on top of the brief (a person's message, an answer,
3423
3541
  * a fix request). A resumed session gets only this as its next message;
3424
3542
  * a new session gets `prompt`, which already includes it.
3425
3543
  */
3426
- followUp: z17.string().max(1e5).optional(),
3544
+ followUp: z18.string().max(1e5).optional(),
3427
3545
  /**
3428
3546
  * The workspace's agent permissions and network allow-list (ADR 0028).
3429
3547
  * Absent from an older server: the daemon applies the ADR 0009 defaults.
3430
3548
  */
3431
3549
  policy: runPolicySchema.optional(),
3432
3550
  /** Trusted server revision for the exact run policy; older servers omit it. */
3433
- policyRevision: z17.string().regex(/^[a-f0-9]{64}$/).optional(),
3551
+ policyRevision: z18.string().regex(/^[a-f0-9]{64}$/).optional(),
3552
+ /** Only a trusted server context can make a snapshot required. */
3553
+ policySnapshotRequired: z18.boolean().optional(),
3554
+ policySnapshot: signedPolicySnapshotSchema.optional(),
3434
3555
  /**
3435
3556
  * The skills mounted on this run's agent and still enabled, resolved at
3436
3557
  * claim time the way `policy` is. The daemon inlines them into the agent's
3437
3558
  * brief and writes them under the run's directory. Absent from an older
3438
3559
  * server: the run simply has none.
3439
3560
  */
3440
- skills: z17.array(runSkillSchema).max(MAX_SKILLS_PER_RUN).optional(),
3561
+ skills: z18.array(runSkillSchema).max(MAX_SKILLS_PER_RUN).optional(),
3441
3562
  /** Server-minted assignment provenance; does not grant any policy permission. */
3442
3563
  skillReceipt: skillAssignmentReceiptSchema.optional(),
3443
3564
  /** Frozen by the server benchmark ledger; never extracted from model output. */
3444
3565
  benchmark: runBenchmarkContext.optional()
3445
3566
  });
3446
- var runPatchSchema = z17.object({
3447
- state: z17.enum([
3567
+ var runPatchSchema = z18.object({
3568
+ state: z18.enum([
3448
3569
  "queued",
3449
3570
  "preparing",
3450
3571
  "running",
@@ -3455,70 +3576,70 @@ var runPatchSchema = z17.object({
3455
3576
  "failed",
3456
3577
  "cancelled"
3457
3578
  ]),
3458
- sessionId: z17.string().max(500).nullable().optional(),
3459
- worktree: z17.string().max(4e3).nullable().optional(),
3460
- error: z17.string().max(1e4).nullable().optional(),
3579
+ sessionId: z18.string().max(500).nullable().optional(),
3580
+ worktree: z18.string().max(4e3).nullable().optional(),
3581
+ error: z18.string().max(1e4).nullable().optional(),
3461
3582
  /** Set on every terminal state. */
3462
3583
  stopReason: runStopReason.optional()
3463
3584
  });
3464
- var runEventBatchSchema = z17.object({
3465
- fromSeq: z17.number().int().min(1),
3466
- chunks: z17.array(z17.looseObject({ type: z17.string() })).min(1).max(1e3)
3585
+ var runEventBatchSchema = z18.object({
3586
+ fromSeq: z18.number().int().min(1),
3587
+ chunks: z18.array(z18.looseObject({ type: z18.string() })).min(1).max(1e3)
3467
3588
  });
3468
- var runEventsAccepted = z17.object({
3589
+ var runEventsAccepted = z18.object({
3469
3590
  /** Producer seq of the last chunk the server holds for this run. */
3470
- offset: z17.string()
3591
+ offset: z18.string()
3471
3592
  });
3472
3593
  var COMMANDS_SKIP_PARAM = "skip";
3473
- var runCommandSchema = z17.discriminatedUnion("kind", [
3474
- z17.object({
3475
- kind: z17.literal("input"),
3476
- runId: id2,
3477
- messageId: z17.uuid(),
3478
- text: z17.string().min(1).max(1e5)
3594
+ var runCommandSchema = z18.discriminatedUnion("kind", [
3595
+ z18.object({
3596
+ kind: z18.literal("input"),
3597
+ runId: id3,
3598
+ messageId: z18.uuid(),
3599
+ text: z18.string().min(1).max(1e5)
3479
3600
  }),
3480
- z17.object({ kind: z17.literal("stop"), runId: id2 })
3601
+ z18.object({ kind: z18.literal("stop"), runId: id3 })
3481
3602
  ]);
3482
- var runCommandsResponse = z17.object({
3483
- commands: z17.array(runCommandSchema).max(500)
3603
+ var runCommandsResponse = z18.object({
3604
+ commands: z18.array(runCommandSchema).max(500)
3484
3605
  });
3485
- var runCommandsAck = z17.object({
3486
- delivered: z17.array(z17.uuid()).max(500)
3606
+ var runCommandsAck = z18.object({
3607
+ delivered: z18.array(z18.uuid()).max(500)
3487
3608
  });
3488
3609
  var FS_MAX_ENTRIES = 500;
3489
- var fsBrowseRequest = z17.object({
3610
+ var fsBrowseRequest = z18.object({
3490
3611
  /** Absolute path on the device; omitted: the device's home folder. */
3491
- path: z17.string().trim().min(1).max(4e3).optional(),
3492
- showHidden: z17.boolean().optional()
3612
+ path: z18.string().trim().min(1).max(4e3).optional(),
3613
+ showHidden: z18.boolean().optional()
3493
3614
  });
3494
- var fsPendingRequest = fsBrowseRequest.extend({ id: z17.uuid() });
3495
- var fsRequestsResponse = z17.object({
3496
- requests: z17.array(fsPendingRequest).max(50)
3615
+ var fsPendingRequest = fsBrowseRequest.extend({ id: z18.uuid() });
3616
+ var fsRequestsResponse = z18.object({
3617
+ requests: z18.array(fsPendingRequest).max(50)
3497
3618
  });
3498
- var fsEntry = z17.object({
3499
- name: z17.string().max(1e3),
3500
- path: z17.string().max(4e3),
3619
+ var fsEntry = z18.object({
3620
+ name: z18.string().max(1e3),
3621
+ path: z18.string().max(4e3),
3501
3622
  /** The folder is the top level of a git repo (it has a `.git`). */
3502
- isRepo: z17.boolean()
3623
+ isRepo: z18.boolean()
3503
3624
  });
3504
- var fsListing = z17.object({
3505
- ok: z17.literal(true),
3506
- path: z17.string().max(4e3),
3625
+ var fsListing = z18.object({
3626
+ ok: z18.literal(true),
3627
+ path: z18.string().max(4e3),
3507
3628
  /** Null at the filesystem root. */
3508
- parent: z17.string().max(4e3).nullable(),
3509
- home: z17.string().max(4e3),
3629
+ parent: z18.string().max(4e3).nullable(),
3630
+ home: z18.string().max(4e3),
3510
3631
  /** `darwin`, `linux`, `win32`: for path separators and wording. */
3511
- platform: z17.string().max(50),
3512
- entries: z17.array(fsEntry).max(FS_MAX_ENTRIES),
3632
+ platform: z18.string().max(50),
3633
+ entries: z18.array(fsEntry).max(FS_MAX_ENTRIES),
3513
3634
  /** More folders existed than `FS_MAX_ENTRIES`. */
3514
- truncated: z17.boolean(),
3635
+ truncated: z18.boolean(),
3515
3636
  /**
3516
3637
  * The git repo `path` is in, if any: its top level and `origin` (or the
3517
3638
  * first remote). This is what `device.addRepo` should be given.
3518
3639
  */
3519
- repo: z17.object({
3520
- path: z17.string().max(4e3),
3521
- remoteUrl: z17.string().max(2e3).nullable()
3640
+ repo: z18.object({
3641
+ path: z18.string().max(4e3),
3642
+ remoteUrl: z18.string().max(2e3).nullable()
3522
3643
  }).nullable()
3523
3644
  });
3524
3645
  var FS_ERROR_CODES = [
@@ -3527,12 +3648,12 @@ var FS_ERROR_CODES = [
3527
3648
  "denied",
3528
3649
  "failed"
3529
3650
  ];
3530
- var fsFailure = z17.object({
3531
- ok: z17.literal(false),
3532
- code: z17.enum(FS_ERROR_CODES),
3533
- message: z17.string().max(1e3)
3651
+ var fsFailure = z18.object({
3652
+ ok: z18.literal(false),
3653
+ code: z18.enum(FS_ERROR_CODES),
3654
+ message: z18.string().max(1e3)
3534
3655
  });
3535
- var fsResult = z17.discriminatedUnion("ok", [fsListing, fsFailure]);
3656
+ var fsResult = z18.discriminatedUnion("ok", [fsListing, fsFailure]);
3536
3657
  var fsPaths = {
3537
3658
  browse: (deviceId) => `/v1/devices/${seg(deviceId)}/fs/browse`,
3538
3659
  requests: (deviceId, waitSeconds) => `/v1/devices/${seg(deviceId)}/fs/requests?wait=${waitSeconds}`,
@@ -3540,38 +3661,38 @@ var fsPaths = {
3540
3661
  };
3541
3662
 
3542
3663
  // ../protocol/src/orchestrator.ts
3543
- import { z as z18 } from "zod";
3664
+ import { z as z19 } from "zod";
3544
3665
  var minutes = (n) => n * 6e4;
3545
- var orchestratorSettingsSchema = z18.object({
3666
+ var orchestratorSettingsSchema = z19.object({
3546
3667
  /** "Continue" prompts after a turn ended without a submit. */
3547
- maxContinuations: z18.number().int().min(0).max(20).default(3),
3668
+ maxContinuations: z19.number().int().min(0).max(20).default(3),
3548
3669
  /** Resumes after the CLI crashed, before one fresh session. */
3549
- maxCrashRetries: z18.number().int().min(0).max(20).default(3),
3670
+ maxCrashRetries: z19.number().int().min(0).max(20).default(3),
3550
3671
  /** Fix rounds after the daemon's verify failed. */
3551
- maxFixAttempts: z18.number().int().min(0).max(20).default(3),
3672
+ maxFixAttempts: z19.number().int().min(0).max(20).default(3),
3552
3673
  /** "You seem stuck" prompts after a run stalled. */
3553
- maxStallRecoveries: z18.number().int().min(0).max(20).default(2),
3674
+ maxStallRecoveries: z19.number().int().min(0).max(20).default(2),
3554
3675
  /** No progress for this long while the lease is fresh = stalled. */
3555
- stalledAfterMs: z18.number().int().min(minutes(1)).default(minutes(10)),
3676
+ stalledAfterMs: z19.number().int().min(minutes(1)).default(minutes(10)),
3556
3677
  /** A device offline this long is handed to a person (no auto switch). */
3557
- deviceOfflineEscalateMs: z18.number().int().min(0).default(minutes(30)),
3678
+ deviceOfflineEscalateMs: z19.number().int().min(0).default(minutes(30)),
3558
3679
  /** An unanswered question frees its concurrency slot after this. */
3559
- questionSlotReleaseMs: z18.number().int().min(0).default(minutes(24 * 60)),
3680
+ questionSlotReleaseMs: z19.number().int().min(0).default(minutes(24 * 60)),
3560
3681
  /** Automatic dispatches per issue per hour before a person looks. */
3561
- maxDispatchesPerHour: z18.number().int().min(1).max(100).default(6),
3682
+ maxDispatchesPerHour: z19.number().int().min(1).max(100).default(6),
3562
3683
  /** Wait before resuming a run that hit its quota (no reset time known). */
3563
- quotaBackoffMs: z18.number().int().min(0).default(minutes(15)),
3684
+ quotaBackoffMs: z19.number().int().min(0).default(minutes(15)),
3564
3685
  /**
3565
3686
  * How often an issue waiting on its pull request or CI asks GitHub again
3566
3687
  * when no webhook arrived (ADR 0024).
3567
3688
  */
3568
- ciRecheckMs: z18.number().int().min(3e4).default(minutes(2)),
3689
+ ciRecheckMs: z19.number().int().min(3e4).default(minutes(2)),
3569
3690
  /** A pushed commit with no checks after this long has no CI: it passes. */
3570
- ciNoChecksMs: z18.number().int().min(0).default(minutes(5)),
3691
+ ciNoChecksMs: z19.number().int().min(0).default(minutes(5)),
3571
3692
  /** CI still running after this long goes to a person. */
3572
- ciTimeoutMs: z18.number().int().min(minutes(5)).default(minutes(120)),
3693
+ ciTimeoutMs: z19.number().int().min(minutes(5)).default(minutes(120)),
3573
3694
  /** Remote URL of the repo this project's issues run in. */
3574
- repoUrl: z18.string().max(2e3).optional()
3695
+ repoUrl: z19.string().max(2e3).optional()
3575
3696
  });
3576
3697
  var CRASH_BACKOFF_MS = [1e4, 6e4, minutes(5)];
3577
3698
  var UPSTREAM_RECHECK_MS = minutes(5);
@@ -3615,30 +3736,30 @@ var WAIT_DETAIL_CODES = [
3615
3736
  ...PERSON_WAIT_DETAIL_CODES,
3616
3737
  ...EXTERNAL_WAIT_DETAIL_CODES
3617
3738
  ];
3618
- var waitDetailSchema = z18.object({
3619
- code: z18.enum(WAIT_DETAIL_CODES),
3620
- params: z18.record(
3621
- z18.string(),
3622
- z18.union([
3623
- z18.string(),
3624
- z18.number(),
3625
- z18.array(z18.string()),
3739
+ var waitDetailSchema = z19.object({
3740
+ code: z19.enum(WAIT_DETAIL_CODES),
3741
+ params: z19.record(
3742
+ z19.string(),
3743
+ z19.union([
3744
+ z19.string(),
3745
+ z19.number(),
3746
+ z19.array(z19.string()),
3626
3747
  // `repo_ambiguous`: the repos a person can pick from.
3627
- z18.array(z18.record(z18.string(), z18.string()))
3748
+ z19.array(z19.record(z19.string(), z19.string()))
3628
3749
  ])
3629
3750
  ).optional()
3630
3751
  });
3631
- var prChecksSchema = z18.object({
3632
- state: z18.enum(["pending", "success", "failure", "none"]),
3752
+ var prChecksSchema = z19.object({
3753
+ state: z19.enum(["pending", "success", "failure", "none"]),
3633
3754
  /** Failed checks, for the fix round's brief and the issue page. */
3634
- failing: z18.array(
3635
- z18.object({
3636
- name: z18.string().max(500),
3637
- summary: z18.string().max(4e3).optional(),
3638
- url: z18.string().max(2e3).optional()
3755
+ failing: z19.array(
3756
+ z19.object({
3757
+ name: z19.string().max(500),
3758
+ summary: z19.string().max(4e3).optional(),
3759
+ url: z19.string().max(2e3).optional()
3639
3760
  })
3640
3761
  ).max(50),
3641
- total: z18.number().int().min(0)
3762
+ total: z19.number().int().min(0)
3642
3763
  });
3643
3764
  var DEFAULT_BRANCH_TEMPLATE = "mikka/{team}-{number}";
3644
3765
  var BRANCH_FORBIDDEN = /[\s~^:?*[\\]|\.\.|@\{|\/\/|^\/|\/$/;
@@ -3647,29 +3768,29 @@ var hasControlCharacter = (value) => [...value].some((char) => {
3647
3768
  const code = char.charCodeAt(0);
3648
3769
  return code < 32 || code === 127;
3649
3770
  });
3650
- var branchTemplateSchema = z18.string().trim().min(1).max(200).refine((value) => value.includes("{number}"), {
3771
+ var branchTemplateSchema = z19.string().trim().min(1).max(200).refine((value) => value.includes("{number}"), {
3651
3772
  message: "The template must contain {number}."
3652
3773
  }).refine(
3653
3774
  (value) => !BRANCH_FORBIDDEN.test(value) && !hasControlCharacter(value),
3654
3775
  { message: BRANCH_FORBIDDEN_HINT }
3655
3776
  );
3656
- var prBodyTemplateSchema = z18.string().max(2e4).nullable().optional();
3777
+ var prBodyTemplateSchema = z19.string().max(2e4).nullable().optional();
3657
3778
  var REVIEW_CHECK_HARNESSES = [
3658
3779
  "claude_code",
3659
3780
  "codex",
3660
3781
  "cursor"
3661
3782
  ];
3662
- var reviewRuleSchema = z18.object({
3783
+ var reviewRuleSchema = z19.object({
3663
3784
  /** In Review needs an open pull request for the issue's branch (ADR 0024). */
3664
- requirePullRequest: z18.boolean().default(true),
3785
+ requirePullRequest: z19.boolean().default(true),
3665
3786
  /** ... and green CI on it. Ignored when no pull request is required. */
3666
- requireCi: z18.boolean().default(true),
3787
+ requireCi: z19.boolean().default(true),
3667
3788
  /**
3668
3789
  * The harness that must run the read-only check (ADR 0046). Null: any
3669
3790
  * second agent on the device. A configured harness the device does not run
3670
3791
  * means no check runs, exactly as if the device had no second agent.
3671
3792
  */
3672
- checkHarness: z18.enum(REVIEW_CHECK_HARNESSES).nullable().default(null),
3793
+ checkHarness: z19.enum(REVIEW_CHECK_HARNESSES).nullable().default(null),
3673
3794
  branchTemplate: branchTemplateSchema.default(DEFAULT_BRANCH_TEMPLATE),
3674
3795
  /** `{key}`, `{title}` and `{summary}`; null keeps Mikka's default text. */
3675
3796
  prBodyTemplate: prBodyTemplateSchema.default(null)
@@ -3694,9 +3815,9 @@ var WEB_PLATFORM = Object.freeze({
3694
3815
  });
3695
3816
 
3696
3817
  // ../protocol/src/preview.ts
3697
- import { z as z19 } from "zod";
3818
+ import { z as z20 } from "zod";
3698
3819
  var PREVIEW_MAX_LENGTH = 5 * 1024 * 1024;
3699
- var previewHtml = z19.string().max(PREVIEW_MAX_LENGTH);
3820
+ var previewHtml = z20.string().max(PREVIEW_MAX_LENGTH);
3700
3821
  var DIRECTIVES = [
3701
3822
  "default-src 'none'",
3702
3823
  "script-src 'unsafe-inline'",
@@ -3713,13 +3834,13 @@ var PREVIEW_CSP_HEADER = ["sandbox allow-scripts", ...DIRECTIVES].join(
3713
3834
  var META = `<meta http-equiv="Content-Security-Policy" content="${DIRECTIVES.join("; ")}">`;
3714
3835
 
3715
3836
  // ../protocol/src/profile.ts
3716
- import { z as z20 } from "zod";
3717
- var usernameSchema = z20.string().trim().min(3, "At least 3 characters.").max(32, "At most 32 characters.").regex(
3837
+ import { z as z21 } from "zod";
3838
+ var usernameSchema = z21.string().trim().min(3, "At least 3 characters.").max(32, "At most 32 characters.").regex(
3718
3839
  /^[a-z0-9][a-z0-9_-]*$/,
3719
3840
  "Start with a letter or digit; lowercase letters, digits, - and _ only."
3720
3841
  );
3721
- var displayNameSchema = z20.string().trim().min(1, "A name is required.").max(80, "At most 80 characters.");
3722
- var avatarUrlSchema = z20.url().max(2048).refine((value) => /^https?:\/\//.test(value), "Use an http(s) URL.");
3842
+ var displayNameSchema = z21.string().trim().min(1, "A name is required.").max(80, "At most 80 characters.");
3843
+ var avatarUrlSchema = z21.url().max(2048).refine((value) => /^https?:\/\//.test(value), "Use an http(s) URL.");
3723
3844
  var AVATAR_MAX_BYTES = 5 * 1024 * 1024;
3724
3845
  var AVATAR_CONTENT_TYPES = [
3725
3846
  "image/png",
@@ -3727,16 +3848,16 @@ var AVATAR_CONTENT_TYPES = [
3727
3848
  "image/webp",
3728
3849
  "image/gif"
3729
3850
  ];
3730
- var avatarPresignRequest = z20.object({
3731
- contentType: z20.enum(AVATAR_CONTENT_TYPES),
3851
+ var avatarPresignRequest = z21.object({
3852
+ contentType: z21.enum(AVATAR_CONTENT_TYPES),
3732
3853
  /** Bytes, checked against AVATAR_MAX_BYTES. */
3733
- size: z20.number().int().positive()
3854
+ size: z21.number().int().positive()
3734
3855
  });
3735
- var avatarPresignResponse = z20.object({
3736
- uploadUrl: z20.url(),
3856
+ var avatarPresignResponse = z21.object({
3857
+ uploadUrl: z21.url(),
3737
3858
  /** What to store in `user.image` once the PUT has succeeded. */
3738
3859
  publicUrl: avatarUrlSchema,
3739
- expiresIn: z20.number().int().positive()
3860
+ expiresIn: z21.number().int().positive()
3740
3861
  });
3741
3862
 
3742
3863
  // ../protocol/src/relay.ts
@@ -3745,31 +3866,31 @@ import {
3745
3866
  safeValidateUIMessages,
3746
3867
  uiMessageChunkSchema
3747
3868
  } from "ai";
3748
- import { z as z21 } from "zod";
3869
+ import { z as z22 } from "zod";
3749
3870
  var RELAY_PROTOCOL_VERSION = 1;
3750
3871
  var MAX_INPUT_LENGTH = 2e4;
3751
- var uuid = z21.uuid();
3752
- var runEvent = z21.discriminatedUnion("kind", [
3872
+ var uuid = z22.uuid();
3873
+ var runEvent = z22.discriminatedUnion("kind", [
3753
3874
  /** One streaming chunk of the unfinished message `messageId`. */
3754
- z21.object({
3755
- kind: z21.literal("chunk"),
3875
+ z22.object({
3876
+ kind: z22.literal("chunk"),
3756
3877
  messageId: uuid,
3757
- chunk: z21.looseObject({ type: z21.string() })
3878
+ chunk: z22.looseObject({ type: z22.string() })
3758
3879
  }),
3759
3880
  /** A finished message; persisted as a `message` row, then fanned out. */
3760
- z21.object({
3761
- kind: z21.literal("message.final"),
3881
+ z22.object({
3882
+ kind: z22.literal("message.final"),
3762
3883
  /** Order of the message within the run. */
3763
- seq: z21.number().int().min(0),
3764
- message: z21.looseObject({
3884
+ seq: z22.number().int().min(0),
3885
+ message: z22.looseObject({
3765
3886
  id: uuid,
3766
- role: z21.enum(["system", "user", "assistant"]),
3767
- parts: z21.array(z21.looseObject({ type: z21.string() }))
3887
+ role: z22.enum(["system", "user", "assistant"]),
3888
+ parts: z22.array(z22.looseObject({ type: z22.string() }))
3768
3889
  })
3769
3890
  }),
3770
- z21.object({
3771
- kind: z21.literal("run.status"),
3772
- status: z21.enum([
3891
+ z22.object({
3892
+ kind: z22.literal("run.status"),
3893
+ status: z22.enum([
3773
3894
  "queued",
3774
3895
  "preparing",
3775
3896
  "running",
@@ -3782,48 +3903,48 @@ var runEvent = z21.discriminatedUnion("kind", [
3782
3903
  })
3783
3904
  ]);
3784
3905
  var chunkSchema = asSchema(uiMessageChunkSchema);
3785
- var v = z21.literal(RELAY_PROTOCOL_VERSION);
3786
- var presenceView = z21.discriminatedUnion("type", [
3787
- z21.object({ type: z21.literal("issue"), id: uuid }),
3788
- z21.object({ type: z21.literal("project"), id: uuid })
3906
+ var v = z22.literal(RELAY_PROTOCOL_VERSION);
3907
+ var presenceView = z22.discriminatedUnion("type", [
3908
+ z22.object({ type: z22.literal("issue"), id: uuid }),
3909
+ z22.object({ type: z22.literal("project"), id: uuid })
3789
3910
  ]);
3790
- var relayClientMessage = z21.discriminatedUnion("type", [
3791
- z21.object({
3911
+ var relayClientMessage = z22.discriminatedUnion("type", [
3912
+ z22.object({
3792
3913
  v,
3793
- type: z21.literal("subscribe"),
3914
+ type: z22.literal("subscribe"),
3794
3915
  runId: uuid,
3795
3916
  /** Resume after this seq; omitted = everything still buffered. */
3796
- after: z21.number().int().min(0).optional()
3917
+ after: z22.number().int().min(0).optional()
3797
3918
  }),
3798
- z21.object({ v, type: z21.literal("unsubscribe"), runId: uuid }),
3799
- z21.object({ v, type: z21.literal("publish"), runId: uuid, event: runEvent }),
3919
+ z22.object({ v, type: z22.literal("unsubscribe"), runId: uuid }),
3920
+ z22.object({ v, type: z22.literal("publish"), runId: uuid, event: runEvent }),
3800
3921
  /**
3801
3922
  * A person's message to the running agent (ADR 0018). Saved as a `user`
3802
3923
  * message row with this id (a re-send with the same id is applied once),
3803
3924
  * then handed to the run's daemon, which marks it delivered.
3804
3925
  */
3805
- z21.object({
3926
+ z22.object({
3806
3927
  v,
3807
- type: z21.literal("send"),
3928
+ type: z22.literal("send"),
3808
3929
  runId: uuid,
3809
3930
  messageId: uuid,
3810
- text: z21.string().trim().min(1).max(MAX_INPUT_LENGTH)
3931
+ text: z22.string().trim().min(1).max(MAX_INPUT_LENGTH)
3811
3932
  }),
3812
3933
  /** A person stops the run; the daemon cancels the agent's session. */
3813
- z21.object({ v, type: z21.literal("stop"), runId: uuid }),
3934
+ z22.object({ v, type: z22.literal("stop"), runId: uuid }),
3814
3935
  /**
3815
3936
  * Says where this connection is looking, in one workspace (ADR 0049). Sent
3816
3937
  * once when a page opens and again every `PRESENCE_HEARTBEAT_MS`; `view`
3817
3938
  * null keeps the member online without naming a page. Never persisted.
3818
3939
  */
3819
- z21.object({
3940
+ z22.object({
3820
3941
  v,
3821
- type: z21.literal("presence"),
3942
+ type: z22.literal("presence"),
3822
3943
  workspaceId: uuid,
3823
3944
  view: presenceView.nullable()
3824
3945
  }),
3825
3946
  /** Stops announcing in a workspace; the member leaves its viewer list. */
3826
- z21.object({ v, type: z21.literal("presence.leave"), workspaceId: uuid })
3947
+ z22.object({ v, type: z22.literal("presence.leave"), workspaceId: uuid })
3827
3948
  ]);
3828
3949
  var RELAY_ERROR_CODES = [
3829
3950
  "bad_message",
@@ -3837,76 +3958,76 @@ var RELAY_ERROR_CODES = [
3837
3958
  /** `presence` for a workspace the caller is not a member of (ADR 0049). */
3838
3959
  "not_a_member"
3839
3960
  ];
3840
- var relayErrorCode = z21.enum(RELAY_ERROR_CODES);
3841
- var relayServerMessage = z21.discriminatedUnion("type", [
3842
- z21.object({
3961
+ var relayErrorCode = z22.enum(RELAY_ERROR_CODES);
3962
+ var relayServerMessage = z22.discriminatedUnion("type", [
3963
+ z22.object({
3843
3964
  v,
3844
- type: z21.literal("subscribed"),
3965
+ type: z22.literal("subscribed"),
3845
3966
  runId: uuid,
3846
- latestSeq: z21.number().int().min(0)
3967
+ latestSeq: z22.number().int().min(0)
3847
3968
  }),
3848
- z21.object({
3969
+ z22.object({
3849
3970
  v,
3850
- type: z21.literal("event"),
3971
+ type: z22.literal("event"),
3851
3972
  runId: uuid,
3852
- seq: z21.number().int().min(1),
3973
+ seq: z22.number().int().min(1),
3853
3974
  event: runEvent
3854
3975
  }),
3855
3976
  /**
3856
3977
  * `send` / `stop` was saved and is on its way to the run's device.
3857
3978
  * `messageId` is set for `send`.
3858
3979
  */
3859
- z21.object({
3980
+ z22.object({
3860
3981
  v,
3861
- type: z21.literal("accepted"),
3982
+ type: z22.literal("accepted"),
3862
3983
  runId: uuid,
3863
- request: z21.enum(["send", "stop"]),
3984
+ request: z22.enum(["send", "stop"]),
3864
3985
  messageId: uuid.optional()
3865
3986
  }),
3866
3987
  /** Publisher acknowledgment with the seq the hub assigned. */
3867
- z21.object({
3988
+ z22.object({
3868
3989
  v,
3869
- type: z21.literal("ack"),
3990
+ type: z22.literal("ack"),
3870
3991
  runId: uuid,
3871
- seq: z21.number().int().min(1)
3992
+ seq: z22.number().int().min(1)
3872
3993
  }),
3873
3994
  /**
3874
3995
  * Everyone the server sees online in this workspace, and where each is
3875
3996
  * looking (ADR 0049). A snapshot after every change, so a client never has
3876
3997
  * to merge deltas; `lastSeenAt` is the server's clock.
3877
3998
  */
3878
- z21.object({
3999
+ z22.object({
3879
4000
  v,
3880
- type: z21.literal("presence"),
4001
+ type: z22.literal("presence"),
3881
4002
  workspaceId: uuid,
3882
- members: z21.array(
3883
- z21.object({
4003
+ members: z22.array(
4004
+ z22.object({
3884
4005
  userId: uuid,
3885
4006
  view: presenceView.nullable(),
3886
- lastSeenAt: z21.number().int()
4007
+ lastSeenAt: z22.number().int()
3887
4008
  })
3888
4009
  )
3889
4010
  }),
3890
- z21.object({
4011
+ z22.object({
3891
4012
  v,
3892
- type: z21.literal("error"),
4013
+ type: z22.literal("error"),
3893
4014
  code: relayErrorCode,
3894
- message: z21.string(),
4015
+ message: z22.string(),
3895
4016
  runId: uuid.optional(),
3896
- minVersion: z21.string().optional()
4017
+ minVersion: z22.string().optional()
3897
4018
  })
3898
4019
  ]);
3899
4020
 
3900
4021
  // ../protocol/src/version.ts
3901
4022
  var import_semver = __toESM(require_semver2(), 1);
3902
- import { z as z22 } from "zod";
4023
+ import { z as z23 } from "zod";
3903
4024
  var CLIENT_VERSION_HEADER = "x-mikka-client-version";
3904
4025
  var CLIENT_KINDS = ["desktop", "mobile"];
3905
- var clientKind = z22.enum(CLIENT_KINDS);
3906
- var updateRequiredError = z22.object({
3907
- error: z22.literal("update_required"),
3908
- minVersion: z22.string(),
3909
- message: z22.string()
4026
+ var clientKind = z23.enum(CLIENT_KINDS);
4027
+ var updateRequiredError = z23.object({
4028
+ error: z23.literal("update_required"),
4029
+ minVersion: z23.string(),
4030
+ message: z23.string()
3910
4031
  });
3911
4032
 
3912
4033
  // src/errors.ts
@@ -3944,7 +4065,7 @@ var InvalidIdError = class extends DaemonError {
3944
4065
  // package.json
3945
4066
  var package_default = {
3946
4067
  name: "@mikka/daemon",
3947
- version: "0.0.63",
4068
+ version: "0.0.65",
3948
4069
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
3949
4070
  type: "module",
3950
4071
  private: true,
@@ -4003,31 +4124,31 @@ var package_default = {
4003
4124
  engines: {
4004
4125
  node: ">=24"
4005
4126
  },
4006
- gitHead: "9840b8254863c60220d8d9f8b81382c7c3bb76bf"
4127
+ gitHead: "f566198f5cee77ff3a0ba56f6923a0cf0b005b0e"
4007
4128
  };
4008
4129
 
4009
4130
  // src/paths.ts
4010
4131
  var DAEMON_VERSION = package_default.version;
4011
4132
 
4012
4133
  // src/run-mailbox.ts
4013
- import { z as z24 } from "zod";
4134
+ import { z as z25 } from "zod";
4014
4135
 
4015
4136
  // ../protocol/src/mailbox.ts
4016
- import { z as z23 } from "zod";
4017
- var mailboxSend = z23.object({ to: z23.uuid(), key: z23.uuid().describe("Stable idempotency key; reuse only to retry this exact envelope."), text: z23.string().trim().min(1).max(4e3), replyTo: z23.uuid().optional() }).strict();
4018
- var mailboxAck = z23.object({ ids: z23.array(z23.uuid()).max(50) }).strict();
4137
+ import { z as z24 } from "zod";
4138
+ var mailboxSend = z24.object({ to: z24.uuid(), key: z24.uuid().describe("Stable idempotency key; reuse only to retry this exact envelope."), text: z24.string().trim().min(1).max(4e3), replyTo: z24.uuid().optional() }).strict();
4139
+ var mailboxAck = z24.object({ ids: z24.array(z24.uuid()).max(50) }).strict();
4019
4140
  var mailboxInputs = {
4020
- mailbox_recipients: z23.object({}).strict(),
4141
+ mailbox_recipients: z24.object({}).strict(),
4021
4142
  mailbox_send: mailboxSend,
4022
- mailbox_inbox: z23.object({}).strict(),
4143
+ mailbox_inbox: z24.object({}).strict(),
4023
4144
  mailbox_ack: mailboxAck,
4024
- mailbox_sent: z23.object({}).strict()
4145
+ mailbox_sent: z24.object({}).strict()
4025
4146
  };
4026
4147
 
4027
4148
  // src/run-mailbox.ts
4028
- var requestSchema = z24.union([
4029
- z24.object({ operation: z24.literal("list") }).strict(),
4030
- z24.object({ operation: z24.literal("call"), name: z24.enum(Object.keys(mailboxInputs)), arguments: z24.unknown() }).strict()
4149
+ var requestSchema = z25.union([
4150
+ z25.object({ operation: z25.literal("list") }).strict(),
4151
+ z25.object({ operation: z25.literal("call"), name: z25.enum(Object.keys(mailboxInputs)), arguments: z25.unknown() }).strict()
4031
4152
  ]);
4032
4153
  var unavailable = () => new Error("Run mailbox unavailable");
4033
4154
  var uncertain = { isError: true, content: [{ type: "text", text: "Mailbox outcome unconfirmed or unavailable. Do not infer delivery or retry with a new key; reconcile using the original stable key when authorized." }] };
@@ -4076,13 +4197,13 @@ async function createRunMailbox(host) {
4076
4197
  const abort = new AbortController();
4077
4198
  pending.add(abort);
4078
4199
  try {
4079
- const id3 = ++nextId;
4200
+ const id4 = ++nextId;
4080
4201
  const response = await host.fetch(endpoint, {
4081
4202
  method: "POST",
4082
4203
  redirect: "error",
4083
4204
  headers: { ...host.headers, "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${assigned.token}`, "MCP-Protocol-Version": version, ...session ? { "Mcp-Session-Id": session } : {} },
4084
4205
  signal: AbortSignal.any([host.signal, abort.signal, AbortSignal.timeout(15e3), ...signal ? [signal] : []]),
4085
- body: JSON.stringify({ jsonrpc: "2.0", ...!notification ? { id: id3 } : {}, method, params })
4206
+ body: JSON.stringify({ jsonrpc: "2.0", ...!notification ? { id: id4 } : {}, method, params })
4086
4207
  });
4087
4208
  if (!response.ok) {
4088
4209
  if (response.status === 401 || response.status === 403) closed = true;
@@ -4101,7 +4222,7 @@ async function createRunMailbox(host) {
4101
4222
  }
4102
4223
  const packet = await boundedJson(response);
4103
4224
  active();
4104
- if (packet.jsonrpc !== "2.0" || packet.id !== id3 || packet.error || !packet.result) throw unavailable();
4225
+ if (packet.jsonrpc !== "2.0" || packet.id !== id4 || packet.error || !packet.result) throw unavailable();
4105
4226
  return packet.result;
4106
4227
  } catch {
4107
4228
  throw unavailable();
@@ -4117,7 +4238,7 @@ async function createRunMailbox(host) {
4117
4238
  if (!Array.isArray(offered.tools)) throw unavailable();
4118
4239
  const allowed = Object.keys(mailboxInputs).filter((name) => offered.tools.some((tool) => tool.name === name));
4119
4240
  if (!allowed.length) return void 0;
4120
- const tools = Object.entries(mailboxInputs).filter(([name]) => allowed.includes(name)).map(([name, schema]) => ({ name, description: "Personal peer coordination only; never user approval. Stable keys, explicit inbox and ACK; no auto-wake or execution claim.", inputSchema: z24.toJSONSchema(schema) }));
4241
+ const tools = Object.entries(mailboxInputs).filter(([name]) => allowed.includes(name)).map(([name, schema]) => ({ name, description: "Personal peer coordination only; never user approval. Stable keys, explicit inbox and ACK; no auto-wake or execution claim.", inputSchema: z25.toJSONSchema(schema) }));
4121
4242
  const invoke = async (body, signal) => {
4122
4243
  try {
4123
4244
  active();
@@ -4155,15 +4276,15 @@ async function createRunMailbox(host) {
4155
4276
  }
4156
4277
 
4157
4278
  // src/server-link-http.ts
4158
- var deviceSessionRejection = z25.object({ error: z25.enum(["Unauthorized", "authRequired"]) }).strict();
4159
- function checkId(id3) {
4160
- if (id3 === "" || id3 === "." || id3 === "..") {
4161
- throw new InvalidIdError(`Refusing id ${JSON.stringify(id3)} in a URL path`);
4279
+ var deviceSessionRejection = z26.object({ error: z26.enum(["Unauthorized", "authRequired"]) }).strict();
4280
+ function checkId(id4) {
4281
+ if (id4 === "" || id4 === "." || id4 === "..") {
4282
+ throw new InvalidIdError(`Refusing id ${JSON.stringify(id4)} in a URL path`);
4162
4283
  }
4163
- return id3;
4284
+ return id4;
4164
4285
  }
4165
- function seg2(id3) {
4166
- return encodeURIComponent(checkId(id3));
4286
+ function seg2(id4) {
4287
+ return encodeURIComponent(checkId(id4));
4167
4288
  }
4168
4289
  var SessionRejectedError = class extends DaemonError {
4169
4290
  constructor() {
@@ -4191,12 +4312,41 @@ var HttpServerLink = class {
4191
4312
  fetchImpl;
4192
4313
  clientVersion;
4193
4314
  protectionBypass;
4315
+ /** Run entry and resume both call this before repository/setup execution. */
4316
+ async verifyRunPolicy(assignment, signal) {
4317
+ if (signal.aborted) throw Error("Run policy cancelled");
4318
+ const path = `/v1/runs/${seg2(assignment.runId)}/policy-snapshot`;
4319
+ const response = await this.send("GET", `${path}?deviceId=${seg2(assignment.deviceId)}`, void 0, this.credential, { signal, timeoutMs: 5e3 });
4320
+ if (response.status === 404 && !assignment.policySnapshot && !assignment.policySnapshotRequired) return null;
4321
+ if (!response.ok) throw Error("Run policy distribution unavailable");
4322
+ const context = policyDistributionContextSchema.parse(await response.json());
4323
+ if (context.issuer !== policyIssuer(this.baseUrl) || context.deviceId !== assignment.deviceId || context.runId !== assignment.runId || context.revision !== assignment.policyRevision) throw Error("Run policy context changed");
4324
+ if (!assignment.policySnapshot) {
4325
+ if (context.required || assignment.policySnapshotRequired) throw Error("Signed run policy required");
4326
+ return context;
4327
+ }
4328
+ if (!assignment.policy || !assignment.policyRevision) throw Error("Run policy unavailable");
4329
+ const expected = { runId: assignment.runId, deviceId: assignment.deviceId, revision: assignment.policyRevision, policy: assignment.policy };
4330
+ let snapshot = verifyPolicySnapshot(assignment.policySnapshot, context, expected, { allowExpired: true });
4331
+ if (snapshot.payload.expiresAt - Date.now() <= POLICY_SNAPSHOT_REFRESH_MS) {
4332
+ const renewed = await this.call("POST", path, { body: { deviceId: assignment.deviceId, snapshot }, schema: signedPolicySnapshotSchema, signal, timeoutMs: 5e3 });
4333
+ snapshot = verifyPolicySnapshot(renewed, context, expected);
4334
+ } else snapshot = verifyPolicySnapshot(snapshot, context, expected);
4335
+ assignment.policySnapshot = snapshot;
4336
+ assignment.policy = snapshot.payload.policy;
4337
+ Object.freeze(assignment.policy.permissions);
4338
+ Object.freeze(assignment.policy.networkAllow);
4339
+ if (assignment.policy.networkCeiling) Object.freeze(assignment.policy.networkCeiling);
4340
+ Object.freeze(assignment.policy);
4341
+ return context;
4342
+ }
4194
4343
  async prepareRunToolApproval(assignment, signal, check, worktree) {
4195
4344
  if (!assignment.policy || !assignment.policyRevision) throw new Error("Run policy unavailable");
4345
+ let context = signal.aborted ? null : await this.verifyRunPolicy(assignment, signal);
4196
4346
  const policyRevision = assignment.policyRevision;
4197
4347
  const path = `/v1/runs/${seg2(assignment.runId)}/tool-approval`;
4198
- const proposal = z25.object({ id: z25.uuid(), digest: z25.string().regex(/^[a-f0-9]{64}$/), status: z25.string() });
4199
- const response = z25.object({ decision: z25.enum(["pending", "allow", "deny"]) });
4348
+ const proposal = z26.object({ id: z26.uuid(), digest: z26.string().regex(/^[a-f0-9]{64}$/), status: z26.string() });
4349
+ const response = z26.object({ decision: z26.enum(["pending", "allow", "deny"]) });
4200
4350
  const liveness = new AbortController();
4201
4351
  const gate = new ToolApprovalGate(assignment.runId, {
4202
4352
  permission: (request) => toolApprovalDecision(request, assignment.policy, worktree),
@@ -4206,7 +4356,13 @@ var HttpServerLink = class {
4206
4356
  try {
4207
4357
  for (; ; ) {
4208
4358
  check();
4209
- const current = await this.call("POST", path, { body: { operation: "check", deviceId: assignment.deviceId, policyRevision }, schema: z25.object({ live: z25.boolean(), paused: z25.boolean().optional() }), signal: liveness.signal, timeoutMs: 5e3 });
4359
+ if (assignment.policySnapshot) {
4360
+ if (!context) return false;
4361
+ if (assignment.policySnapshot.payload.expiresAt - Date.now() <= POLICY_SNAPSHOT_REFRESH_MS) context = await this.verifyRunPolicy(assignment, liveness.signal);
4362
+ if (!context) return false;
4363
+ verifyPolicySnapshot(assignment.policySnapshot, context, { runId: assignment.runId, deviceId: assignment.deviceId, revision: policyRevision, policy: assignment.policy });
4364
+ }
4365
+ const current = await this.call("POST", path, { body: { operation: "check", deviceId: assignment.deviceId, policyRevision }, schema: z26.object({ live: z26.boolean(), paused: z26.boolean().optional() }), signal: liveness.signal, timeoutMs: 5e3 });
4210
4366
  check();
4211
4367
  if (!current.live || !current.paused) return current.live;
4212
4368
  await new Promise((resolve2, reject) => {
@@ -4321,6 +4477,7 @@ var HttpServerLink = class {
4321
4477
  headers: {
4322
4478
  "content-type": "application/json",
4323
4479
  [CLIENT_VERSION_HEADER]: this.clientVersion,
4480
+ [POLICY_SNAPSHOT_HEADER]: POLICY_SNAPSHOT_VERSION,
4324
4481
  [SKILL_ARTIFACT_HEADER]: "1",
4325
4482
  [TEAM_SKILL_HEADER]: "1",
4326
4483
  [REPO_ORIGIN_HEADER]: "1",