@aspectlylabs/mikka 0.0.715 → 0.0.716

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/client.js CHANGED
@@ -2755,6 +2755,14 @@ var USER_ERROR_CODES = {
2755
2755
  "adapter_start_failed",
2756
2756
  "cleanup_failed"
2757
2757
  ],
2758
+ /** Agent/Bot interop: reads, sends and Drive across threads and Bots (decision 2026-11-19-2200). */
2759
+ interop_not_found: [],
2760
+ interop_invalid_request: [],
2761
+ interop_scope_required: [],
2762
+ interop_send_unavailable: ["run_not_active", "thread_replaced", "thread_cannot_continue", "delivery_unavailable", "delivery_uncertain", "bot_unavailable", "continuation_requires_grant"],
2763
+ interop_diff_unavailable: ["no_checkpoint", "masked"],
2764
+ interop_drive_conflict: [],
2765
+ interop_drive_unavailable: ["file_too_large"],
2758
2766
  cloud_machine_unfunded: []
2759
2767
  };
2760
2768
 
@@ -5102,7 +5110,7 @@ import { join } from "node:path";
5102
5110
  // package.json
5103
5111
  var package_default = {
5104
5112
  name: "@mikka/daemon",
5105
- version: "0.0.715",
5113
+ version: "0.0.716",
5106
5114
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
5107
5115
  type: "module",
5108
5116
  private: true,
@@ -5170,7 +5178,7 @@ var package_default = {
5170
5178
  engines: {
5171
5179
  node: ">=22"
5172
5180
  },
5173
- gitHead: "edfb82d33849f2fa0deb42030db1f8eca68f1eb4"
5181
+ gitHead: "c0661a23ac7ffd231ef10ad15ce379b20991c120"
5174
5182
  };
5175
5183
 
5176
5184
  // src/paths.ts
package/http-link.js CHANGED
@@ -1147,16 +1147,16 @@ var require_range = __commonJS({
1147
1147
  };
1148
1148
  var replaceTilde = (comp, options) => {
1149
1149
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1150
- const z36 = options.includePrerelease ? "-0" : "";
1150
+ const z37 = 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${z36} <${+M + 1}.0.0-0`;
1157
+ ret = `>=${M}.0.0${z37} <${+M + 1}.0.0-0`;
1158
1158
  } else if (isX(p)) {
1159
- ret = `>=${M}.${m}.0${z36} <${M}.${+m + 1}.0-0`;
1159
+ ret = `>=${M}.${m}.0${z37} <${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 z36 = options.includePrerelease ? "-0" : "";
1176
+ const z37 = 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${z36} <${+M + 1}.0.0-0`;
1183
+ ret = `>=${M}.0.0${z37} <${+M + 1}.0.0-0`;
1184
1184
  } else if (isX(p)) {
1185
1185
  if (M === "0") {
1186
- ret = `>=${M}.${m}.0${z36} <${M}.${+m + 1}.0-0`;
1186
+ ret = `>=${M}.${m}.0${z37} <${M}.${+m + 1}.0-0`;
1187
1187
  } else {
1188
- ret = `>=${M}.${m}.0${z36} <${+M + 1}.0.0-0`;
1188
+ ret = `>=${M}.${m}.0${z37} <${+M + 1}.0.0-0`;
1189
1189
  }
1190
1190
  } else if (pr) {
1191
1191
  debug("replaceCaret pr", pr);
@@ -2198,6 +2198,14 @@ var USER_ERROR_CODES = {
2198
2198
  "adapter_start_failed",
2199
2199
  "cleanup_failed"
2200
2200
  ],
2201
+ /** Agent/Bot interop: reads, sends and Drive across threads and Bots (decision 2026-11-19-2200). */
2202
+ interop_not_found: [],
2203
+ interop_invalid_request: [],
2204
+ interop_scope_required: [],
2205
+ interop_send_unavailable: ["run_not_active", "thread_replaced", "thread_cannot_continue", "delivery_unavailable", "delivery_uncertain", "bot_unavailable", "continuation_requires_grant"],
2206
+ interop_diff_unavailable: ["no_checkpoint", "masked"],
2207
+ interop_drive_conflict: [],
2208
+ interop_drive_unavailable: ["file_too_large"],
2201
2209
  cloud_machine_unfunded: []
2202
2210
  };
2203
2211
 
@@ -3079,7 +3087,7 @@ var workspaceReadCommand = z6.strictObject({
3079
3087
  });
3080
3088
 
3081
3089
  // src/server-link-http.ts
3082
- import { z as z35 } from "zod";
3090
+ import { z as z36 } from "zod";
3083
3091
 
3084
3092
  // ../protocol/src/chat-attachments.ts
3085
3093
  import { z as z7 } from "zod";
@@ -3174,7 +3182,7 @@ var ToolApprovalGate = class {
3174
3182
  /** Resolves on the next push or revocation. A paused run waits here instead
3175
3183
  * of asking the server on a timer. */
3176
3184
  changed(signal) {
3177
- return new Promise((resolve, reject) => {
3185
+ return new Promise((resolve2, reject) => {
3178
3186
  if (signal.aborted || this.revoked) {
3179
3187
  reject(new Error("cancelled"));
3180
3188
  return;
@@ -3183,7 +3191,7 @@ var ToolApprovalGate = class {
3183
3191
  this.changes.delete(wake);
3184
3192
  signal.removeEventListener("abort", abort);
3185
3193
  if (error) reject(error);
3186
- else resolve();
3194
+ else resolve2();
3187
3195
  };
3188
3196
  const wake = () => done(this.revoked ? new Error("cancelled") : void 0);
3189
3197
  const abort = () => done(new Error("cancelled"));
@@ -5599,7 +5607,7 @@ var InvalidIdError = class extends DaemonError {
5599
5607
  // package.json
5600
5608
  var package_default = {
5601
5609
  name: "@mikka/daemon",
5602
- version: "0.0.715",
5610
+ version: "0.0.716",
5603
5611
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
5604
5612
  type: "module",
5605
5613
  private: true,
@@ -5667,7 +5675,7 @@ var package_default = {
5667
5675
  engines: {
5668
5676
  node: ">=22"
5669
5677
  },
5670
- gitHead: "edfb82d33849f2fa0deb42030db1f8eca68f1eb4"
5678
+ gitHead: "c0661a23ac7ffd231ef10ad15ce379b20991c120"
5671
5679
  };
5672
5680
 
5673
5681
  // src/paths.ts
@@ -5821,9 +5829,250 @@ async function createRunMailbox(host) {
5821
5829
  return { tools, request: invoke, close };
5822
5830
  }
5823
5831
 
5832
+ // src/run-drive.ts
5833
+ import { createHash as createHash2 } from "node:crypto";
5834
+ import { lstat, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
5835
+ import { dirname, extname, join, relative, resolve, sep } from "node:path";
5836
+ import { z as z35 } from "zod";
5837
+ var READ_LIMIT = 1024 * 1024;
5838
+ var WRITE_LIMIT = 4 * 1024 * 1024;
5839
+ var MAX_FILES = 2e3;
5840
+ var STATE_DIR = ".state";
5841
+ var scopeSchema = z35.object({ scope: z35.enum(["bot", "thread", "environment", "workspace"]), scopeId: z35.uuid(), write: z35.boolean() }).strict();
5842
+ var listingSchema = z35.object({
5843
+ volume: z35.object({ id: z35.string(), headDigest: z35.string(), entries: z35.array(z35.object({ path: z35.string(), sizeBytes: z35.number(), sha256: z35.string() })) }).nullable()
5844
+ }).passthrough();
5845
+ var stateSchema = z35.object({ volumeId: z35.string().nullable(), headDigest: z35.string().nullable(), files: z35.record(z35.string(), z35.string()) }).strict();
5846
+ var sha5 = (bytes) => createHash2("sha256").update(bytes).digest("hex");
5847
+ function localDrivePath(folder, path3) {
5848
+ if (!path3 || path3.startsWith("/") || path3.includes("\\") || path3.split("/").some((part) => !part || part === "." || part === "..")) return null;
5849
+ const target = resolve(folder, ...path3.split("/"));
5850
+ return target.startsWith(resolve(folder) + sep) ? target : null;
5851
+ }
5852
+ function conflictPath(path3, runId) {
5853
+ const ext = extname(path3);
5854
+ return `${ext ? path3.slice(0, -ext.length) : path3}.conflict-${runId.slice(0, 8)}${ext}`;
5855
+ }
5856
+ async function walk(folder) {
5857
+ const found = [];
5858
+ const visit = async (dir) => {
5859
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
5860
+ if (found.length >= MAX_FILES) return;
5861
+ const full = join(dir, entry.name);
5862
+ if (entry.isSymbolicLink()) continue;
5863
+ if (entry.isDirectory()) await visit(full);
5864
+ else if (entry.isFile()) found.push(relative(folder, full).split(sep).join("/"));
5865
+ }
5866
+ };
5867
+ await visit(folder).catch((error) => {
5868
+ if (error.code !== "ENOENT") throw error;
5869
+ });
5870
+ return found;
5871
+ }
5872
+ function createDriveMirror(options) {
5873
+ const { root, runId, call } = options;
5874
+ const warn = options.warn ?? (() => {
5875
+ });
5876
+ const folderOf = (scope) => join(root, scope.scope, scope.scopeId);
5877
+ const stateFile = (scope) => join(root, STATE_DIR, `${scope.scope}-${scope.scopeId}.json`);
5878
+ const target = (scope) => ({ scope: scope.scope, scopeId: scope.scopeId });
5879
+ const readState = async (scope) => {
5880
+ try {
5881
+ return stateSchema.parse(JSON.parse(await readFile(stateFile(scope), "utf8")));
5882
+ } catch {
5883
+ return { volumeId: null, headDigest: null, files: {} };
5884
+ }
5885
+ };
5886
+ const saveState = async (scope, state) => {
5887
+ await mkdir(join(root, STATE_DIR), { recursive: true, mode: 448 });
5888
+ await writeFile(stateFile(scope), JSON.stringify(state), { mode: 384 });
5889
+ };
5890
+ const list = async (scope, volumeId) => {
5891
+ const result = await call("drive_list", { ...target(scope), ...volumeId ? { volumeId } : {} });
5892
+ if (result.isError) throw new Error(`drive_list ${String(result.value.error ?? "failed")}`);
5893
+ return listingSchema.parse(result.value).volume;
5894
+ };
5895
+ const download = async (scope, volumeId, path3, file, expected2) => {
5896
+ const result = await call("drive_read", { ...target(scope), volumeId, path: path3, encoding: "base64" });
5897
+ if (result.isError || typeof result.value.content !== "string") throw new Error(`drive_read ${String(result.value.error ?? "failed")}`);
5898
+ const bytes = Buffer.from(result.value.content, "base64");
5899
+ if (sha5(bytes) !== expected2) throw new Error("drive_read digest mismatch");
5900
+ await mkdir(dirname(file), { recursive: true });
5901
+ await writeFile(file, bytes);
5902
+ };
5903
+ async function pullScope(scope) {
5904
+ const folder = folderOf(scope);
5905
+ await mkdir(folder, { recursive: true, mode: 448 });
5906
+ const previous = await readState(scope);
5907
+ const volume = await list(scope);
5908
+ const state = { volumeId: volume?.id ?? null, headDigest: volume?.headDigest ?? null, files: {} };
5909
+ const remote = /* @__PURE__ */ new Set();
5910
+ for (const entry of volume?.entries ?? []) {
5911
+ const file = localDrivePath(folder, entry.path);
5912
+ if (!file) continue;
5913
+ remote.add(entry.path);
5914
+ if (entry.sizeBytes > READ_LIMIT) continue;
5915
+ let local = null;
5916
+ try {
5917
+ local = sha5(await readFile(file));
5918
+ } catch {
5919
+ }
5920
+ if (local !== entry.sha256) await download(scope, volume.id, entry.path, file, entry.sha256);
5921
+ state.files[entry.path] = entry.sha256;
5922
+ }
5923
+ for (const path3 of Object.keys(previous.files)) {
5924
+ if (remote.has(path3)) continue;
5925
+ const file = localDrivePath(folder, path3);
5926
+ if (file) await rm(file, { force: true });
5927
+ }
5928
+ await saveState(scope, state);
5929
+ }
5930
+ async function write(scope, state, path3, bytes) {
5931
+ const content = bytes === null ? {} : { content: bytes.toString("base64"), encoding: "base64" };
5932
+ const fingerprint = sha5(`${path3}\0${bytes === null ? "delete" : sha5(bytes)}`).slice(0, 32);
5933
+ for (let attempt = 0; attempt < 3; attempt++) {
5934
+ const result = await call("drive_write", {
5935
+ ...target(scope),
5936
+ ...state.volumeId ? { volumeId: state.volumeId } : {},
5937
+ path: path3,
5938
+ ...content,
5939
+ expectedDigest: state.headDigest ?? "0".repeat(64),
5940
+ mutationId: `sync:${runId}:${fingerprint}:${attempt}`
5941
+ });
5942
+ if (!result.isError) {
5943
+ state.volumeId = String(result.value.volumeId);
5944
+ state.headDigest = String(result.value.headDigest);
5945
+ return "ok";
5946
+ }
5947
+ if (result.value.error !== "interop_drive_conflict") throw new Error(`drive_write ${String(result.value.error ?? "failed")}`);
5948
+ const volume = await list(scope, state.volumeId);
5949
+ state.volumeId = volume?.id ?? state.volumeId;
5950
+ state.headDigest = volume?.headDigest ?? (typeof result.value.headDigest === "string" ? result.value.headDigest : state.headDigest);
5951
+ const remoteSha = volume?.entries.find((entry) => entry.path === path3)?.sha256 ?? null;
5952
+ if (remoteSha !== (state.files[path3] ?? null)) return "conflict";
5953
+ }
5954
+ return "conflict";
5955
+ }
5956
+ async function pushScope(scope) {
5957
+ if (!scope.write) return;
5958
+ const folder = folderOf(scope);
5959
+ const state = await readState(scope);
5960
+ const local = /* @__PURE__ */ new Map();
5961
+ for (const path3 of await walk(folder)) {
5962
+ const file = localDrivePath(folder, path3);
5963
+ if (!file || (await lstat(file)).size > WRITE_LIMIT) continue;
5964
+ local.set(path3, await readFile(file));
5965
+ }
5966
+ const changes = [];
5967
+ for (const [path3, bytes] of local) if (state.files[path3] !== sha5(bytes)) changes.push({ path: path3, bytes });
5968
+ for (const path3 of Object.keys(state.files)) if (!local.has(path3)) changes.push({ path: path3, bytes: null });
5969
+ if (!changes.length) return;
5970
+ let conflicted = false;
5971
+ for (const change of changes) {
5972
+ const outcome = await write(scope, state, change.path, change.bytes);
5973
+ if (outcome === "ok") {
5974
+ if (change.bytes === null) delete state.files[change.path];
5975
+ else state.files[change.path] = sha5(change.bytes);
5976
+ continue;
5977
+ }
5978
+ conflicted = true;
5979
+ if (change.bytes !== null) {
5980
+ const copy = conflictPath(change.path, runId);
5981
+ if (await write(scope, state, copy, change.bytes) === "ok") state.files[copy] = sha5(change.bytes);
5982
+ warn("drive sync conflict kept as a copy", { scope: scope.scope, path: change.path });
5983
+ }
5984
+ }
5985
+ await saveState(scope, state);
5986
+ if (conflicted) await pullScope(scope);
5987
+ }
5988
+ const each = async (work, label) => {
5989
+ for (const scope of options.scopes) {
5990
+ try {
5991
+ await work(scope);
5992
+ } catch (error) {
5993
+ warn(`drive ${label} failed`, { scope: scope.scope, error: error instanceof Error ? error.name : "Error" });
5994
+ }
5995
+ }
5996
+ };
5997
+ let pushing;
5998
+ return {
5999
+ folders: options.scopes.map((scope) => ({ scope: scope.scope, path: folderOf(scope), write: scope.write })),
6000
+ pull: () => each(pullScope, "pull"),
6001
+ // Pushes never overlap: a checkpoint and the terminal push run one after the other.
6002
+ push: () => pushing = (pushing ?? Promise.resolve()).then(() => each(pushScope, "push"))
6003
+ };
6004
+ }
6005
+ async function createRunDrive(host) {
6006
+ const assigned = host.assignment.mcp;
6007
+ if (!assigned) return void 0;
6008
+ let endpoint;
6009
+ try {
6010
+ endpoint = new URL(assigned.url);
6011
+ } catch {
6012
+ return void 0;
6013
+ }
6014
+ if (endpoint.href !== host.endpoint.href || !trustedServerEndpoint(endpoint) || !/^mkw_[A-Za-z0-9_-]{43}$/.test(assigned.token)) return void 0;
6015
+ let nextId = 0, session = null, version = "2025-03-26";
6016
+ const rpc = async (method, params, notification = false) => {
6017
+ const id4 = ++nextId;
6018
+ const response = await host.fetch(endpoint, {
6019
+ method: "POST",
6020
+ redirect: "error",
6021
+ headers: {
6022
+ ...host.headers,
6023
+ "content-type": "application/json",
6024
+ accept: "application/json, text/event-stream",
6025
+ authorization: `Bearer ${assigned.token}`,
6026
+ "MCP-Protocol-Version": version,
6027
+ ...session ? { "Mcp-Session-Id": session } : {}
6028
+ },
6029
+ signal: AbortSignal.any([host.signal, AbortSignal.timeout(3e4)]),
6030
+ body: JSON.stringify({ jsonrpc: "2.0", ...!notification ? { id: id4 } : {}, method, params })
6031
+ });
6032
+ if (!response.ok) {
6033
+ await response.body?.cancel();
6034
+ throw new Error(`drive rpc ${response.status}`);
6035
+ }
6036
+ const sid = response.headers.get("mcp-session-id");
6037
+ if (sid && sid.length <= 256 && !/[\r\n]/.test(sid)) session = sid;
6038
+ if (notification) {
6039
+ await response.body?.cancel();
6040
+ return null;
6041
+ }
6042
+ const text2 = await response.text();
6043
+ if (text2.length > 8 * 1024 * 1024) throw new Error("drive rpc too large");
6044
+ const packet = response.headers.get("content-type")?.split(";")[0] === "text/event-stream" ? JSON.parse(text2.split(/\r?\n/).find((line) => line.startsWith("data:"))?.slice(5) ?? "null") : JSON.parse(text2);
6045
+ if (packet?.jsonrpc !== "2.0" || packet.id !== id4 || packet.error || !packet.result) throw new Error("drive rpc failed");
6046
+ return packet.result;
6047
+ };
6048
+ const call = async (name, args) => {
6049
+ const result = await rpc("tools/call", { name, arguments: args });
6050
+ const text2 = result.content?.find((part) => part.type === "text")?.text;
6051
+ if (typeof text2 !== "string") throw new Error("drive tool result missing");
6052
+ return { isError: result.isError === true, value: JSON.parse(text2) };
6053
+ };
6054
+ try {
6055
+ const initialized = await rpc("initialize", { protocolVersion: version, capabilities: {}, clientInfo: { name: "mikka-run-drive", version: "1" } });
6056
+ if (["2025-03-26", "2025-06-18", "2025-11-25"].includes(initialized.protocolVersion)) version = initialized.protocolVersion;
6057
+ await rpc("notifications/initialized", {}, true);
6058
+ const plan = await call("drive_sync_scopes", {});
6059
+ if (plan.isError) return void 0;
6060
+ const scopes = z35.array(scopeSchema).max(8).parse(plan.value.scopes);
6061
+ if (!scopes.length) return void 0;
6062
+ return createDriveMirror({ root: host.root, runId: host.assignment.runId, scopes, call, warn: host.warn });
6063
+ } catch (error) {
6064
+ host.warn?.("drive mirror unavailable", { error: error instanceof Error ? error.name : "Error" });
6065
+ return void 0;
6066
+ }
6067
+ }
6068
+
6069
+ // src/server-link-http.ts
6070
+ import { homedir } from "node:os";
6071
+ import { join as joinPath } from "node:path";
6072
+
5824
6073
  // src/tracing.ts
5825
6074
  import { AsyncLocalStorage } from "node:async_hooks";
5826
- import { createHash as createHash2 } from "node:crypto";
6075
+ import { createHash as createHash3 } from "node:crypto";
5827
6076
  import { ROOT_CONTEXT as ROOT_CONTEXT2, SpanStatusCode as SpanStatusCode3, isSpanContextValid, trace as trace3 } from "@opentelemetry/api";
5828
6077
  import { ExportResultCode as ExportResultCode2, W3CTraceContextPropagator } from "@opentelemetry/core";
5829
6078
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
@@ -6259,7 +6508,7 @@ function daemonSampleRate(settings, env = process.env) {
6259
6508
  return Math.min(1, Math.max(0, rate));
6260
6509
  }
6261
6510
  function runIdHash(runId) {
6262
- return createHash2("sha256").update(runId).digest("hex").slice(0, 16);
6511
+ return createHash3("sha256").update(runId).digest("hex").slice(0, 16);
6263
6512
  }
6264
6513
  function routeTemplate(path3) {
6265
6514
  const clean = path3.split(/[?#]/, 1)[0];
@@ -6679,8 +6928,8 @@ var DaemonTracer = class {
6679
6928
  let timer;
6680
6929
  await Promise.race([
6681
6930
  work,
6682
- new Promise((resolve) => {
6683
- timer = setTimeout(resolve, timeoutMs);
6931
+ new Promise((resolve2) => {
6932
+ timer = setTimeout(resolve2, timeoutMs);
6684
6933
  timer.unref();
6685
6934
  })
6686
6935
  ]).finally(() => {
@@ -6988,7 +7237,7 @@ var RunRuntimeTimings = class {
6988
7237
  var runRuntimeTimings = new RunRuntimeTimings();
6989
7238
 
6990
7239
  // src/server-link-http.ts
6991
- var deviceSessionRejection = z35.object({ error: z35.enum(["Unauthorized", "authRequired"]) }).strict();
7240
+ var deviceSessionRejection = z36.object({ error: z36.enum(["Unauthorized", "authRequired"]) }).strict();
6992
7241
  var refusalCode = (body) => {
6993
7242
  if (typeof body !== "object" || body === null) return void 0;
6994
7243
  const { code, error } = body;
@@ -7096,12 +7345,12 @@ var HttpServerLink = class {
7096
7345
  }
7097
7346
  /** Asks the server's Decisions API for one run. Never throws; null on any failure. */
7098
7347
  decide = async (runId, request2, signal) => {
7099
- const answer = z35.discriminatedUnion("type", [
7100
- z35.object({ type: z35.literal("predicate"), name: z35.string(), probability: z35.number() }),
7101
- z35.object({ type: z35.literal("choice"), name: z35.string(), choice: z35.string() })
7348
+ const answer = z36.discriminatedUnion("type", [
7349
+ z36.object({ type: z36.literal("predicate"), name: z36.string(), probability: z36.number() }),
7350
+ z36.object({ type: z36.literal("choice"), name: z36.string(), choice: z36.string() })
7102
7351
  ]);
7103
7352
  try {
7104
- const { answers } = await this.call("POST", `/v1/runs/${seg2(runId)}/decision`, { body: request2, schema: z35.object({ answers: z35.array(answer).nullable() }), signal, timeoutMs: 6e3 });
7353
+ const { answers } = await this.call("POST", `/v1/runs/${seg2(runId)}/decision`, { body: request2, schema: z36.object({ answers: z36.array(answer).nullable() }), signal, timeoutMs: 6e3 });
7105
7354
  return answers ? new Map(answers.map((item) => [item.name, item])) : null;
7106
7355
  } catch {
7107
7356
  return null;
@@ -7140,6 +7389,16 @@ var HttpServerLink = class {
7140
7389
  headers: { [CLIENT_VERSION_HEADER]: this.clientVersion, ...deviceSessionHeaders, ...this.protectionBypass ? { "x-vercel-protection-bypass": this.protectionBypass } : {} }
7141
7390
  });
7142
7391
  }
7392
+ async prepareRunDrive(assignment, signal) {
7393
+ return createRunDrive({
7394
+ assignment,
7395
+ signal,
7396
+ endpoint: serverUrl(this.baseUrl, "/api/mcp"),
7397
+ root: joinPath(process.env.HOME || homedir(), ".mikka", "drive"),
7398
+ fetch: (url, init) => this.taskFetch(assignment.runId, "task_data", url, init),
7399
+ headers: { [CLIENT_VERSION_HEADER]: this.clientVersion, ...deviceSessionHeaders, ...this.protectionBypass ? { "x-vercel-protection-bypass": this.protectionBypass } : {} }
7400
+ });
7401
+ }
7143
7402
  async claimCoordinator(deviceId, signal) {
7144
7403
  const response = await this.send("POST", `/v1/devices/${seg2(deviceId)}/coordinator`, { operation: "claim" }, this.credential, { signal });
7145
7404
  if (response.status === 404) return null;
package/login.js CHANGED
@@ -1147,16 +1147,16 @@ var require_range = __commonJS({
1147
1147
  };
1148
1148
  var replaceTilde = (comp, options) => {
1149
1149
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1150
- const z37 = options.includePrerelease ? "-0" : "";
1150
+ const z38 = 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${z37} <${+M + 1}.0.0-0`;
1157
+ ret = `>=${M}.0.0${z38} <${+M + 1}.0.0-0`;
1158
1158
  } else if (isX(p)) {
1159
- ret = `>=${M}.${m}.0${z37} <${M}.${+m + 1}.0-0`;
1159
+ ret = `>=${M}.${m}.0${z38} <${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 z37 = options.includePrerelease ? "-0" : "";
1176
+ const z38 = 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${z37} <${+M + 1}.0.0-0`;
1183
+ ret = `>=${M}.0.0${z38} <${+M + 1}.0.0-0`;
1184
1184
  } else if (isX(p)) {
1185
1185
  if (M === "0") {
1186
- ret = `>=${M}.${m}.0${z37} <${M}.${+m + 1}.0-0`;
1186
+ ret = `>=${M}.${m}.0${z38} <${M}.${+m + 1}.0-0`;
1187
1187
  } else {
1188
- ret = `>=${M}.${m}.0${z37} <${+M + 1}.0.0-0`;
1188
+ ret = `>=${M}.${m}.0${z38} <${+M + 1}.0.0-0`;
1189
1189
  }
1190
1190
  } else if (pr) {
1191
1191
  debug("replaceCaret pr", pr);
@@ -2796,6 +2796,14 @@ var USER_ERROR_CODES = {
2796
2796
  "adapter_start_failed",
2797
2797
  "cleanup_failed"
2798
2798
  ],
2799
+ /** Agent/Bot interop: reads, sends and Drive across threads and Bots (decision 2026-11-19-2200). */
2800
+ interop_not_found: [],
2801
+ interop_invalid_request: [],
2802
+ interop_scope_required: [],
2803
+ interop_send_unavailable: ["run_not_active", "thread_replaced", "thread_cannot_continue", "delivery_unavailable", "delivery_uncertain", "bot_unavailable", "continuation_requires_grant"],
2804
+ interop_diff_unavailable: ["no_checkpoint", "masked"],
2805
+ interop_drive_conflict: [],
2806
+ interop_drive_unavailable: ["file_too_large"],
2799
2807
  cloud_machine_unfunded: []
2800
2808
  };
2801
2809
 
@@ -5133,7 +5141,7 @@ var computerSyncResponse = z31.object({ decisions: z31.array(localComputerDecisi
5133
5141
 
5134
5142
  // src/login.ts
5135
5143
  import { arch, hostname, platform } from "node:os";
5136
- import { z as z36 } from "zod";
5144
+ import { z as z37 } from "zod";
5137
5145
 
5138
5146
  // src/errors.ts
5139
5147
  var DaemonError = class extends Error {
@@ -5156,7 +5164,7 @@ var ServerUnreachableError = class extends DaemonError {
5156
5164
  // package.json
5157
5165
  var package_default = {
5158
5166
  name: "@mikka/daemon",
5159
- version: "0.0.715",
5167
+ version: "0.0.716",
5160
5168
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
5161
5169
  type: "module",
5162
5170
  private: true,
@@ -5224,14 +5232,14 @@ var package_default = {
5224
5232
  engines: {
5225
5233
  node: ">=22"
5226
5234
  },
5227
- gitHead: "edfb82d33849f2fa0deb42030db1f8eca68f1eb4"
5235
+ gitHead: "c0661a23ac7ffd231ef10ad15ce379b20991c120"
5228
5236
  };
5229
5237
 
5230
5238
  // src/paths.ts
5231
5239
  var DAEMON_VERSION = package_default.version;
5232
5240
 
5233
5241
  // src/server-link-http.ts
5234
- import { z as z35 } from "zod";
5242
+ import { z as z36 } from "zod";
5235
5243
 
5236
5244
  // ../protocol/src/chat-attachments.ts
5237
5245
  import { z as z32 } from "zod";
@@ -5354,6 +5362,16 @@ var requestSchema = z34.union([
5354
5362
  z34.object({ operation: z34.literal("call"), name: z34.enum(Object.keys(mailboxInputs)), arguments: z34.unknown() }).strict()
5355
5363
  ]);
5356
5364
 
5365
+ // src/run-drive.ts
5366
+ import { z as z35 } from "zod";
5367
+ var READ_LIMIT = 1024 * 1024;
5368
+ var WRITE_LIMIT = 4 * 1024 * 1024;
5369
+ var scopeSchema = z35.object({ scope: z35.enum(["bot", "thread", "environment", "workspace"]), scopeId: z35.uuid(), write: z35.boolean() }).strict();
5370
+ var listingSchema = z35.object({
5371
+ volume: z35.object({ id: z35.string(), headDigest: z35.string(), entries: z35.array(z35.object({ path: z35.string(), sizeBytes: z35.number(), sha256: z35.string() })) }).nullable()
5372
+ }).passthrough();
5373
+ var stateSchema = z35.object({ volumeId: z35.string().nullable(), headDigest: z35.string().nullable(), files: z35.record(z35.string(), z35.string()) }).strict();
5374
+
5357
5375
  // src/tracing.ts
5358
5376
  import { AsyncLocalStorage } from "node:async_hooks";
5359
5377
  import { createHash } from "node:crypto";
@@ -6517,7 +6535,7 @@ var RunRuntimeTimings = class {
6517
6535
  var runRuntimeTimings = new RunRuntimeTimings();
6518
6536
 
6519
6537
  // src/server-link-http.ts
6520
- var deviceSessionRejection = z35.object({ error: z35.enum(["Unauthorized", "authRequired"]) }).strict();
6538
+ var deviceSessionRejection = z36.object({ error: z36.enum(["Unauthorized", "authRequired"]) }).strict();
6521
6539
  var deviceSessionHeaders = { [DEVICE_SESSION_HEADER]: String(DEVICE_SESSION_VERSION) };
6522
6540
  function serverUrl(base, path3) {
6523
6541
  return new URL(`${base.replace(/\/+$/, "")}${path3}`);
@@ -6528,16 +6546,16 @@ var updateRequired = () => new LoginError("failed", "This daemon is too old for
6528
6546
  var DEVICE_CODE_PATH = `${AUTH_BASE_PATH}/device/code`;
6529
6547
  var DEVICE_TOKEN_PATH = `${AUTH_BASE_PATH}/device/token`;
6530
6548
  var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
6531
- var deviceCodeResponse = z36.object({
6532
- device_code: z36.string().min(1),
6533
- user_code: z36.string().min(1),
6534
- verification_uri: z36.string(),
6535
- verification_uri_complete: z36.string().optional(),
6536
- expires_in: z36.number().positive(),
6537
- interval: z36.number().positive().default(5)
6538
- });
6539
- var tokenResponse = z36.object({ access_token: z36.string().regex(/^orv_[A-Za-z0-9_-]{43}$/) });
6540
- var errorResponse = z36.object({ error: z36.string() });
6549
+ var deviceCodeResponse = z37.object({
6550
+ device_code: z37.string().min(1),
6551
+ user_code: z37.string().min(1),
6552
+ verification_uri: z37.string(),
6553
+ verification_uri_complete: z37.string().optional(),
6554
+ expires_in: z37.number().positive(),
6555
+ interval: z37.number().positive().default(5)
6556
+ });
6557
+ var tokenResponse = z37.object({ access_token: z37.string().regex(/^orv_[A-Za-z0-9_-]{43}$/) });
6558
+ var errorResponse = z37.object({ error: z37.string() });
6541
6559
  var LoginError = class extends DaemonError {
6542
6560
  constructor(reason, message) {
6543
6561
  super(4003, message);