@bobannomi/app-host 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/protocol.js CHANGED
@@ -19,7 +19,9 @@ var APP_HOST_ERROR_RETRY = {
19
19
  root_changed: "never",
20
20
  resource_revision_conflict: "query",
21
21
  request_conflict: "never",
22
- cursor_stale: "query"
22
+ cursor_stale: "query",
23
+ model_provider_not_configured: "never",
24
+ model_not_configured: "never"
23
25
  };
24
26
  var HOST_REQUEST_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
25
27
  function isSafeErrorDetails(value, depth = 0) {
@@ -45,6 +47,8 @@ function isAppHostErrorInfo(value) {
45
47
  }
46
48
  function appHostErrorMessage(code, details) {
47
49
  const reason = details && typeof details === "object" && !Array.isArray(details) ? details.reason : void 0;
50
+ if (code === "model_provider_not_configured") return "\u8BF7\u5148\u914D\u7F6E\u6240\u9009\u4F9B\u5E94\u5546\u7684\u8FDE\u63A5\u3002";
51
+ if (code === "model_not_configured") return "\u8BF7\u5728\u4F9B\u5E94\u5546\u914D\u7F6E\u4E2D\u4FDD\u5B58\u6240\u9009\u6A21\u578B\u3002";
48
52
  if (code === "host_unavailable") {
49
53
  switch (reason) {
50
54
  case "host_port_timeout":
@@ -114,7 +118,7 @@ var AppHostError = class extends Error {
114
118
  };
115
119
 
116
120
  // ../domain-contracts/src/app-host/wire-validation.ts
117
- var text = (max = 1024, empty2 = false) => (v) => typeof v === "string" && (empty2 || v.length > 0) && new TextEncoder().encode(v).byteLength <= max;
121
+ var text = (max = 1024, empty3 = false) => (v) => typeof v === "string" && (empty3 || v.length > 0) && new TextEncoder().encode(v).byteLength <= max;
118
122
  var id = (v) => typeof v === "string" && HOST_REQUEST_ID.test(v);
119
123
  var count = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
120
124
  var bool = (v) => typeof v === "boolean";
@@ -183,124 +187,6 @@ function validConnection(v) {
183
187
  return wireConnection(v) && /^[A-Za-z0-9-]+$/.test(v.connectionId) && v.baseUrl === `https://app-host.invalid/connections/${v.connectionId}`;
184
188
  }
185
189
 
186
- // ../domain-contracts/src/app-host/agent.ts
187
- function fields(value, required, optional = []) {
188
- if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
189
- return false;
190
- return required.every((key) => Object.hasOwn(value, key)) && Reflect.ownKeys(value).every((key) => {
191
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
192
- return typeof key === "string" && [...required, ...optional].includes(key) && descriptor.enumerable && Object.hasOwn(descriptor, "value");
193
- });
194
- }
195
- var text2 = (value) => typeof value === "string" && value.trim().length > 0;
196
- var workspaceId = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
197
- function rows(value, check) {
198
- return Array.isArray(value) && value.length <= 1024 && value.every(check);
199
- }
200
- function validAgentInput(method, value) {
201
- if (!json(value)) return false;
202
- if (method === "agent.listModels") return fields(value, []);
203
- if (method === "agent.resolveSkills") return fields(value, ["skillIds"]) && Array.isArray(value.skillIds) && value.skillIds.length <= 128 && value.skillIds.every((v) => text(256)(v)) && new Set(value.skillIds).size === value.skillIds.length;
204
- if (method !== "agent.getConnection" || !fields(value, [], ["workspaceId", "executionRoot", "privateSessionId"])) return false;
205
- return (!Object.hasOwn(value, "workspaceId") || workspaceId(value.workspaceId)) && (!Object.hasOwn(value, "privateSessionId") || workspaceId(value.privateSessionId) && !Object.hasOwn(value, "workspaceId") && !Object.hasOwn(value, "executionRoot")) && (!Object.hasOwn(value, "executionRoot") || workspaceId(value.executionRoot) && Object.hasOwn(value, "workspaceId"));
206
- }
207
- function validAgentResult(method, value) {
208
- if (!json(value)) return false;
209
- switch (method) {
210
- case "agent.getConnection":
211
- return fields(value, ["connectionId", "baseUrl"], ["cwd", "defaultTaskLocation"]) && (!Object.hasOwn(value, "defaultTaskLocation") || value.defaultTaskLocation === "current" || value.defaultTaskLocation === "worktree") && (!Object.hasOwn(value, "cwd") || text2(value.cwd)) && text2(value.connectionId) && value.baseUrl === `https://app-host.invalid/connections/${value.connectionId}` && /^[A-Za-z0-9-]+$/.test(value.connectionId);
212
- case "agent.listModels":
213
- return rows(
214
- value,
215
- (row) => fields(row, ["id", "name"], ["reasoning", "reasoningEfforts", "vision", "contextWindow", "outputLimit", "inputModalities", "toolCalling"]) && text2(row.id) && text2(row.name) && ["reasoning", "vision", "toolCalling"].every((key) => !Object.hasOwn(row, key) || typeof row[key] === "boolean") && ["contextWindow", "outputLimit"].every((key) => !Object.hasOwn(row, key) || Number.isSafeInteger(row[key]) && row[key] > 0) && ["reasoningEfforts", "inputModalities"].every((key) => !Object.hasOwn(row, key) || Array.isArray(row[key]) && row[key].length <= 32 && row[key].every((value2) => text(128)(value2)) && new Set(row[key]).size === row[key].length)
216
- );
217
- case "agent.resolveSkills":
218
- return rows(
219
- value,
220
- (row) => fields(row, ["type", "name", "path"]) && row.type === "skill" && text2(row.name) && text2(row.path)
221
- );
222
- }
223
- return false;
224
- }
225
-
226
- // ../domain-contracts/src/app-host/service.ts
227
- function fields2(value, required, optional = []) {
228
- if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
229
- return false;
230
- return required.every((k) => Object.hasOwn(value, k)) && Reflect.ownKeys(value).every((k) => {
231
- const d = Object.getOwnPropertyDescriptor(value, k);
232
- return typeof k === "string" && [...required, ...optional].includes(k) && d.enumerable && Object.hasOwn(d, "value");
233
- });
234
- }
235
- var version = (v) => typeof v === "string" && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.test(
236
- v
237
- );
238
- function json2(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
239
- if (depth > 100) return false;
240
- if (value === null || typeof value === "string" || typeof value === "boolean")
241
- return true;
242
- if (typeof value === "number") return Number.isFinite(value);
243
- if (typeof value !== "object" || ancestors.has(value)) return false;
244
- const array2 = Array.isArray(value);
245
- if (array2 ? Object.getPrototypeOf(value) !== Array.prototype || Reflect.ownKeys(value).length !== value.length + 1 : ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
246
- return false;
247
- ancestors.add(value);
248
- const result = Reflect.ownKeys(value).every((k) => {
249
- if (array2 && k === "length") return true;
250
- const d = Object.getOwnPropertyDescriptor(value, k);
251
- return typeof k === "string" && (!array2 || /^(0|[1-9]\d*)$/.test(k) && Number(k) < value.length) && d.enumerable && Object.hasOwn(d, "value") && json2(d.value, ancestors, depth + 1);
252
- });
253
- ancestors.delete(value);
254
- return result;
255
- }
256
- function validServiceStatus(value) {
257
- return fields2(value, ["state"], ["reason", "instanceId", "apiVersion"]) && [
258
- "absent",
259
- "unauthorized",
260
- "stopped",
261
- "starting",
262
- "recovering",
263
- "ready",
264
- "failed"
265
- ].includes(value.state) && (!Object.hasOwn(value, "reason") || [
266
- "dependency_missing",
267
- "service_start_failed",
268
- "service_unavailable",
269
- "result_unknown",
270
- "incompatible",
271
- "revoked"
272
- ].includes(value.reason)) && (!Object.hasOwn(value, "instanceId") || typeof value.instanceId === "string" && HOST_REQUEST_ID.test(value.instanceId)) && (!Object.hasOwn(value, "apiVersion") || version(value.apiVersion)) && (value.state !== "ready" || Object.hasOwn(value, "instanceId") && Object.hasOwn(value, "apiVersion"));
273
- }
274
- function validWork(value) {
275
- return fields2(value, ["requestId", "state", "updatedAt"], ["result", "error"]) && typeof value.requestId === "string" && HOST_REQUEST_ID.test(value.requestId) && [
276
- "not_accepted",
277
- "accepted",
278
- "running",
279
- "completed",
280
- "failed",
281
- "interrupted",
282
- "unknown"
283
- ].includes(value.state) && typeof value.updatedAt === "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/.test(
284
- value.updatedAt
285
- ) && Number.isFinite(Date.parse(value.updatedAt)) && ["result", "error"].every(
286
- (k) => !Object.hasOwn(value, k) || json2(value[k]) && new TextEncoder().encode(JSON.stringify(value[k])).length <= 16384
287
- );
288
- }
289
- function validServiceResult(method, value) {
290
- switch (method) {
291
- case "service.getStatus":
292
- return validServiceStatus(value);
293
- case "service.getConnection":
294
- return fields2(value, ["connectionId", "baseUrl", "apiVersion"]) && typeof value.connectionId === "string" && /^[A-Za-z0-9-]+$/.test(value.connectionId) && value.baseUrl === `https://app-host.invalid/connections/${value.connectionId}` && version(value.apiVersion);
295
- case "service.getWork":
296
- return validWork(value);
297
- case "service.listWork":
298
- return Array.isArray(value) && value.length <= 5120 && value.every(validWork) && new Set(value.map((w) => w.requestId)).size === value.length;
299
- case "service.interruptWork":
300
- return fields2(value, ["requested"]) && typeof value.requested === "boolean";
301
- }
302
- }
303
-
304
190
  // ../domain-contracts/src/app-host/fetch.ts
305
191
  var APP_HOST_FEATURES = [
306
192
  "fetch-v1",
@@ -372,7 +258,7 @@ function isPageFetchFrame(value) {
372
258
  return false;
373
259
  const v = value;
374
260
  if (v.protocol !== 2 || typeof v.type !== "string") return false;
375
- const fields4 = {
261
+ const fields2 = {
376
262
  "fetch-open": ["id", "connectionId", "url", "method", "headers", "hasBody"],
377
263
  "fetch-headers": ["id", "status", "statusText", "headers", "hasBody"],
378
264
  "fetch-credit": ["id", "direction", "sequence", "chunks", "bytes"],
@@ -383,7 +269,7 @@ function isPageFetchFrame(value) {
383
269
  "fetch-error": ["id", "error"],
384
270
  "fetch-close": ["connectionId"]
385
271
  };
386
- const required = fields4[v.type];
272
+ const required = fields2[v.type];
387
273
  const inline = v.type === "fetch-open" && Object.hasOwn(v, "inlineBody");
388
274
  if (!required || Object.keys(v).length !== required.length + 2 + Number(inline) || !required.every((k) => Object.hasOwn(v, k)))
389
275
  return false;
@@ -416,101 +302,10 @@ function pageFetchPath(baseUrl, input) {
416
302
  const rawPath = input.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]+/, "").split("?")[0];
417
303
  if (rawPath.includes("//") || /%(?:2e|2f|5c|25)/i.test(rawPath) || rawPath.split("/").some((p) => p === "." || p === "..") || /[\u0000-\u001f\u007f]/.test(decodeURIComponent(rawPath)))
418
304
  throw new TypeError("Ambiguous fetch path");
419
- const base = new URL(baseUrl), url = new URL(input);
420
- if (base.protocol !== "https:" || base.hostname !== "app-host.invalid" || base.username || base.password || base.search || base.hash || url.origin !== base.origin || url.username || url.password || url.hash || url.pathname !== base.pathname && !url.pathname.startsWith(base.pathname + "/"))
305
+ const base = new URL(baseUrl), url2 = new URL(input);
306
+ if (base.protocol !== "https:" || base.hostname !== "app-host.invalid" || base.username || base.password || base.search || base.hash || url2.origin !== base.origin || url2.username || url2.password || url2.hash || url2.pathname !== base.pathname && !url2.pathname.startsWith(base.pathname + "/"))
421
307
  throw new TypeError("Fetch target mismatch");
422
- return (url.pathname.slice(base.pathname.length) || "/") + url.search;
423
- }
424
-
425
- // ../domain-contracts/src/app-host/service-host-protocol.ts
426
- var SERVICE_HOST_METHODS = ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.getConnection", "agent.resolveSkills", "sessions.getConnection", "workspace.gitStatus", "workspace.createTaskWorktree", "workspace.getWorktree", "workspace.releaseExecutionRoot", "work.list", "work.get"];
427
- var SERVICE_HOST_MAX_FRAME_BYTES = 512 * 1024;
428
- var SERVICE_HOST_MAX_PENDING = 64;
429
- var validServiceContext = (v) => json(v) && object({ protocolVersion: enumeration(1), registrationId: id, instanceId: id, dataScopeId: text(256), scope: object({ appId: text(256), installationId: id, contentDigest: digest }), installationRevision: count, phase: enumeration("starting", "ready") })(v);
430
- var worktreeBody = { workspaceId: id, expectedHead: text(256), branch: text(1024) };
431
- var worktreeReceipt = object({ requestId: id, state: enumeration("accepted", "completed", "failed", "unknown") }, { result: object({ executionRoot: id, workspaceId: id, branch: text(1024), sourceHead: text(256) }) });
432
- function validServiceHostInput(method, v) {
433
- if (!json(v)) return false;
434
- if (method.startsWith("agent.")) return validAgentInput(method, v);
435
- switch (method) {
436
- case "secrets.get":
437
- case "secrets.delete":
438
- return object({ key: (x) => typeof x === "string" && /^[a-zA-Z0-9._:-]{1,128}$/.test(x) })(v);
439
- case "secrets.set":
440
- return object({ key: (x) => typeof x === "string" && /^[a-zA-Z0-9._:-]{1,128}$/.test(x), value: text(16384) })(v);
441
- case "context.get":
442
- case "work.list":
443
- return object({})(v);
444
- case "context.resolveInvocation":
445
- return object({ ticket: text(8192) })(v);
446
- case "sessions.getConnection":
447
- return object({ dataScopeId: text(256), sessionId: text(256) })(v);
448
- case "workspace.gitStatus":
449
- return object({ workspaceId: id })(v);
450
- case "workspace.createTaskWorktree":
451
- return object({ requestId: id, ...worktreeBody })(v);
452
- case "workspace.getWorktree":
453
- return object({ requestId: id, original: object(worktreeBody) })(v);
454
- case "workspace.releaseExecutionRoot":
455
- return object({ requestId: id, workspaceId: id, executionRoot: id })(v);
456
- case "work.get":
457
- return object({ requestId: id })(v);
458
- default:
459
- return false;
460
- }
461
- }
462
- function validServiceHostResult(method, v) {
463
- if (!json(v)) return false;
464
- if (method.startsWith("agent.")) return validAgentResult(method, v);
465
- switch (method) {
466
- case "secrets.get":
467
- return v === null || text(16384)(v);
468
- case "secrets.set":
469
- return object({ stored: enumeration(true) })(v);
470
- case "secrets.delete":
471
- return object({ deleted: enumeration(true) })(v);
472
- case "context.get":
473
- return validServiceContext(v);
474
- case "context.resolveInvocation":
475
- return object({ invocationId: id, dataScopeId: text(256), sessionId: text(256), runId: text(256) }, { inputId: text(256), workspaceId: id, executionRoot: id, privateSessionId: id })(v);
476
- case "sessions.getConnection":
477
- return validAgentResult("agent.getConnection", v);
478
- case "workspace.gitStatus":
479
- return object({ root: text(32768), commonDir: text(32768), head: text(256), branch: text(1024, true), changes: array(text(32768), 1e4) })(v);
480
- case "workspace.createTaskWorktree":
481
- return worktreeReceipt(v);
482
- case "workspace.getWorktree":
483
- return v === null || worktreeReceipt(v);
484
- case "workspace.releaseExecutionRoot":
485
- return object({ requestId: id, executionRoot: id, state: enumeration("released", "retained-dirty", "in-use", "unknown") })(v);
486
- case "work.list":
487
- return validServiceResult("service.listWork", v);
488
- case "work.get":
489
- return v === null || validServiceResult("service.getWork", v);
490
- default:
491
- return false;
492
- }
493
- }
494
- function isServiceHostFrame(v) {
495
- if (isPageFetchFrame(v)) return true;
496
- if (!json(v) || new TextEncoder().encode(JSON.stringify(v)).byteLength > SERVICE_HOST_MAX_FRAME_BYTES || !object({ protocol: enumeration(1), type: text(64) }, { id, context: validServiceContext, method: enumeration(...SERVICE_HOST_METHODS), params: json, ok: enumeration(true, false), value: json, error: isAppHostErrorInfo })(v)) return false;
497
- const frame = v;
498
- switch (frame.type) {
499
- case "service-host-connect":
500
- return object({ protocol: enumeration(1), type: enumeration(frame.type), id })(v);
501
- case "service-host-ready":
502
- return object({ protocol: enumeration(1), type: enumeration(frame.type), id, context: validServiceContext })(v);
503
- case "service-host-context":
504
- return object({ protocol: enumeration(1), type: enumeration(frame.type), context: validServiceContext })(v);
505
- case "service-host-close":
506
- return object({ protocol: enumeration(1), type: enumeration(frame.type) })(v);
507
- case "service-host-request":
508
- return object({ protocol: enumeration(1), type: enumeration(frame.type), id, method: enumeration(...SERVICE_HOST_METHODS), params: (x) => validServiceHostInput(frame.method, x) })(v);
509
- case "service-host-response":
510
- return frame.ok ? object({ protocol: enumeration(1), type: enumeration(frame.type), id, ok: enumeration(true), value: json })(v) : object({ protocol: enumeration(1), type: enumeration(frame.type), id, ok: enumeration(false), error: isAppHostErrorInfo })(v);
511
- default:
512
- return false;
513
- }
308
+ return (url2.pathname.slice(base.pathname.length) || "/") + url2.search;
514
309
  }
515
310
 
516
311
  // ../domain-contracts/src/app-host/agent-api-policy.ts
@@ -565,6 +360,7 @@ var routes = [
565
360
  { method: "POST", pattern: /^\/jobs\/[^/]+\/cancel$/, id: "jobs.cancel" }
566
361
  ];
567
362
  function matchAgentApiRoute(method, path) {
363
+ if (path === "/attachments/storage") return void 0;
568
364
  return routes.find((route) => route.method === method && route.pattern.test(path));
569
365
  }
570
366
  function normalizeAgentApiPath(raw) {
@@ -621,7 +417,6 @@ var workspaceConversationResult = object({
621
417
  revision: count,
622
418
  session: sessionRecord,
623
419
  operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
624
- indexBindingPending: (v) => v === true,
625
420
  workspaceId: id,
626
421
  executionRoot: id,
627
422
  privateSessionId: id,
@@ -652,7 +447,6 @@ function validSessionControlInput(method, value) {
652
447
  const target2 = value;
653
448
  return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
654
449
  }
655
- if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
656
450
  if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
657
451
  if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
658
452
  if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
@@ -662,17 +456,16 @@ function validSessionControlInput(method, value) {
662
456
  function validSessionControlResult(method, value) {
663
457
  if (!json(value)) return false;
664
458
  if (method === "sessions.getDraftComposerOptions") return object({ source: enumeration("instance"), optionsRevision: text(), skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") }), 128), plugins: array(object({ id: text(), name: text(), agents: array(option, 128) }), 128) })(value);
665
- if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
666
459
  if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
667
460
  return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
668
- if (method === "sessions.getControls") return object({ dataScopeId: text(), sessionId: text(), source: enumeration("instance", "auxiliary", "im"), revision: count, optionsRevision: text(), actions: object(Object.fromEntries(["readContext", "configure", "compact", "edit", "fork", "resume", "goalRead", "goalWrite", "goalStop"].map((k) => [k, bool]))), models: choices, roles: choices, efforts: effortChoices, workModes: choices, skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") })), commands: choices, contexts: choices }, { permissionModes: array(option, 128), appServiceBindings: array(option, 128), plugins: array(object({ id: text(), name: text(), agents: choices })) })(value);
461
+ if (method === "sessions.getControls") return object({ dataScopeId: text(), sessionId: text(), source: enumeration("instance", "auxiliary", "im"), revision: count, optionsRevision: text(), actions: object(Object.fromEntries(["readContext", "configure", "compact", "edit", "fork", "resume", "goalRead", "goalWrite", "goalStop"].map((k) => [k, bool]))), models: choices, roles: choices, efforts: effortChoices, workModes: choices, skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") })), commands: choices, contexts: choices }, { permissionModes: array(option, 128), plugins: array(object({ id: text(), name: text(), agents: choices })) })(value);
669
462
  if (method === "sessions.getControlResult") return value === null || receipt(value);
670
463
  if (!receipt(value)) return false;
671
464
  return false;
672
465
  }
673
466
 
674
467
  // ../domain-contracts/src/app-host/workspace.ts
675
- function fields3(v, required, optional = []) {
468
+ function fields(v, required, optional = []) {
676
469
  if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) return false;
677
470
  return required.every((k) => Object.hasOwn(v, k)) && Reflect.ownKeys(v).every((k) => {
678
471
  const d = Object.getOwnPropertyDescriptor(v, k);
@@ -681,7 +474,7 @@ function fields3(v, required, optional = []) {
681
474
  }
682
475
  var uuid = (v) => typeof v === "string" && HOST_REQUEST_ID.test(v);
683
476
  var str = (v) => typeof v === "string";
684
- function rows2(v, check) {
477
+ function rows(v, check) {
685
478
  if (!Array.isArray(v) || Object.getPrototypeOf(v) !== Array.prototype || v.length > 200 || Reflect.ownKeys(v).length !== v.length + 1) return false;
686
479
  for (let i = 0; i < v.length; i++) {
687
480
  const d = Object.getOwnPropertyDescriptor(v, String(i));
@@ -689,18 +482,18 @@ function rows2(v, check) {
689
482
  }
690
483
  return true;
691
484
  }
692
- var ref = (v) => fields3(v, ["id", "displayName"]) && uuid(v.id) && str(v.displayName) && v.displayName.length > 0;
485
+ var ref = (v) => fields(v, ["id", "displayName"]) && uuid(v.id) && str(v.displayName) && v.displayName.length > 0;
693
486
  function validWorkspaceInput(method, v) {
694
487
  switch (method) {
695
488
  case "workspace.select":
696
489
  case "workspace.getSelection":
697
- return fields3(v, ["requestId"]) && uuid(v.requestId);
490
+ return fields(v, ["requestId"]) && uuid(v.requestId);
698
491
  case "workspace.get":
699
- return fields3(v, ["workspaceId"]) && uuid(v.workspaceId);
492
+ return fields(v, ["workspaceId"]) && uuid(v.workspaceId);
700
493
  case "workspace.listFiles":
701
- return fields3(v, ["workspaceId", "directory"], ["cursor"]) && uuid(v.workspaceId) && str(v.directory) && (!Object.hasOwn(v, "cursor") || uuid(v.cursor));
494
+ return fields(v, ["workspaceId", "directory"], ["cursor"]) && uuid(v.workspaceId) && str(v.directory) && (!Object.hasOwn(v, "cursor") || uuid(v.cursor));
702
495
  case "workspace.readText":
703
- return fields3(v, ["workspaceId", "path"]) && uuid(v.workspaceId) && str(v.path) && v.path.length > 0;
496
+ return fields(v, ["workspaceId", "path"]) && uuid(v.workspaceId) && str(v.path) && v.path.length > 0;
704
497
  }
705
498
  }
706
499
  function validWorkspaceResult(method, v) {
@@ -710,13 +503,13 @@ function validWorkspaceResult(method, v) {
710
503
  case "workspace.get":
711
504
  return ref(v);
712
505
  case "workspace.getSelection":
713
- if (!fields3(v, ["requestId", "status"], ["workspace", "unavailable"]) || !uuid(v.requestId)) return false;
714
- if (v.status === "completed") return fields3(v, ["requestId", "status", "workspace"]) && ref(v.workspace) || fields3(v, ["requestId", "status", "unavailable"]) && v.unavailable === true;
715
- return fields3(v, ["requestId", "status"]) && ["pending", "cancelled", "expired", "failed", "unknown"].includes(v.status);
506
+ if (!fields(v, ["requestId", "status"], ["workspace", "unavailable"]) || !uuid(v.requestId)) return false;
507
+ if (v.status === "completed") return fields(v, ["requestId", "status", "workspace"]) && ref(v.workspace) || fields(v, ["requestId", "status", "unavailable"]) && v.unavailable === true;
508
+ return fields(v, ["requestId", "status"]) && ["pending", "cancelled", "expired", "failed", "unknown"].includes(v.status);
716
509
  case "workspace.listFiles":
717
- return fields3(v, ["entries"], ["nextCursor"]) && rows2(v.entries, (e) => fields3(e, ["path", "name", "kind"]) && str(e.path) && str(e.name) && (e.kind === "file" || e.kind === "directory")) && (!Object.hasOwn(v, "nextCursor") || uuid(v.nextCursor));
510
+ return fields(v, ["entries"], ["nextCursor"]) && rows(v.entries, (e) => fields(e, ["path", "name", "kind"]) && str(e.path) && str(e.name) && (e.kind === "file" || e.kind === "directory")) && (!Object.hasOwn(v, "nextCursor") || uuid(v.nextCursor));
718
511
  case "workspace.readText":
719
- return fields3(v, ["path", "text", "revision"]) && str(v.path) && v.path.length > 0 && str(v.text) && typeof v.revision === "string" && /^[a-f0-9]{64}$/.test(v.revision);
512
+ return fields(v, ["path", "text", "revision"]) && str(v.path) && v.path.length > 0 && str(v.text) && typeof v.revision === "string" && /^[a-f0-9]{64}$/.test(v.revision);
720
513
  }
721
514
  }
722
515
 
@@ -1051,8 +844,7 @@ function createResourceCatalogApi(rpc) {
1051
844
  // src/session-controls.ts
1052
845
  var CONVERSATION_PREPARATION_METHODS = [
1053
846
  "sessions.createConversation",
1054
- "sessions.getConversationCreationResult",
1055
- "sessions.bindConversationIndex"
847
+ "sessions.getConversationCreationResult"
1056
848
  ];
1057
849
  function isConversationPreparationMethod(method) {
1058
850
  return CONVERSATION_PREPARATION_METHODS.includes(method);
@@ -1087,10 +879,23 @@ function resolveClientConnection(connection, owner) {
1087
879
 
1088
880
  // src/desktop.ts
1089
881
  var BROWSER_CAPTURE_PREVIEW_MAX_BYTES = 8 * 1024 * 1024;
882
+ var DESKTOP_ADAPTED_METHODS = ["desktop.files.openRead", "desktop.files.getOperation"];
1090
883
  var target = { targetId: text(256) };
1091
884
  var mount = { ...target, mountId: text(256) };
1092
885
  var source = object({ sessionId: text(), appId: text() });
1093
886
  var action = { ...mount, source, requestId: id, expectedRevision: count };
887
+ var fileWriteBody = { path: text(32768), expectedSha256: digest, text: text(8 * 1024 * 1024, true) };
888
+ var gitBranchBody = { expectedHead: text(), branch: text() };
889
+ var validFileOperationQuery = object({
890
+ ...target,
891
+ requestId: id,
892
+ original: object({ kind: enumeration("files.writeText"), body: object(fileWriteBody) })
893
+ });
894
+ var validGitOperationQuery = object({
895
+ ...target,
896
+ requestId: id,
897
+ original: object({ kind: enumeration("git.switchBranch", "git.createBranch"), body: object(gitBranchBody) })
898
+ });
1094
899
  var page = { ...target, tabId: text(256), pageRevision: count };
1095
900
  var mode = enumeration("off", "pick", "review");
1096
901
  var voidResult = (v) => v === void 0;
@@ -1100,7 +905,7 @@ var annotationFields = { target: text(8192), selector: text(8192), locatorKind:
1100
905
  var validBrowserSnapshot = object({ pageUrl: text(16384, true), pageRevision: count, ready: bool, mode, interactionVersion: count, eventSequence: count, selection: nullable(object({ selectionId: text(), target: object(annotationFields), rect })), focusedAnnotationId: nullable(text()), viewport: nullable(object({ width: finite2, height: finite2 })), annotations: array(object({ record: object({ ...annotationFields, id: text(), pageUrl: text(16384, true), comment: text(65536, true) }), status: enumeration("visible", "offscreen", "missing"), rect: nullable(rect) }), 4096) });
1101
906
  var root = object({ path: text(32768), identity: object({ dev: text(), ino: text() }) }, { workspaceId: text() });
1102
907
  var validDesktopTarget = object({ id: text(), dataScopeId: text(), draftId: text(), draftRevision: count }, { root, sessionId: text() });
1103
- var kind = enumeration("files.writeText", "git.switchBranch", "git.createBranch", "git.createTaskWorktree");
908
+ var kind = enumeration("files.writeText", "git.switchBranch", "git.createBranch");
1104
909
  var validWorkspaceOperation = object({ requestId: id, kind, state: enumeration("prepared", "running", "completed", "failed", "unknown"), createdAt: count, updatedAt: count }, { result: json, error: object({ code: text(128) }) });
1105
910
  var origin = (v) => object({ kind: enumeration("surface"), surfaceId: text() })(v) || object({ kind: enumeration("tool-result"), sourcePartId: text() })(v);
1106
911
  var appRecord = object({ id: text(), sessionId: text(), pluginId: text(), pluginVersion: text(), pluginDigest: text(), definitionDigest: text(), backendId: text(), backendKind: enumeration("native-tools", "mcp-server"), resourceUri: text(8192), origin, logicalKey: text(8192), status: enumeration("open", "closed", "revoked"), controlRevision: count, createdAt: count, updatedAt: count }, { activeActionRunId: text(), lastActionRunId: text() });
@@ -1123,7 +928,7 @@ var rules = {
1123
928
  "desktop.files.search": { input: object({ ...target, query: text(4096, true) }, { directory: text(32768, true), limit: positive }), result: object({ matches: array(object({ path: text(32768), line: count, text: text(65536, true) }), 1e4), truncated: bool }) },
1124
929
  "desktop.files.openRead": { input: object({ ...target, path: text(32768) }), result: validConnection },
1125
930
  "desktop.files.readText": { input: object({ ...target, path: text(32768) }), result: object({ path: text(32768), text: text(8 * 1024 * 1024, true), sha256: digest, byteLength: count, encoding: enumeration("utf-8"), truncated: bool }) },
1126
- "desktop.files.writeText": { input: object({ ...target, requestId: id, path: text(32768), expectedSha256: digest, text: text(8 * 1024 * 1024, true) }), result: validWorkspaceOperation },
931
+ "desktop.files.writeText": { input: object({ ...target, requestId: id, ...fileWriteBody }), result: validWorkspaceOperation },
1127
932
  "desktop.files.getOperation": { input: object({ ...target, requestId: id, original: object({ kind, body: json }) }), result: nullable(validWorkspaceOperation) },
1128
933
  "desktop.files.revealPath": { input: object({ ...target, path: text(32768) }), result: voidResult },
1129
934
  "desktop.files.listOpeners": { input: object(target), result: array(object({ id: text(256), label: text(1024), kind: enumeration("editor", "folder", "terminal"), iconDataUrl: nullable(text(1024 * 1024)) }, { isDefault: bool }), 256) },
@@ -1139,9 +944,8 @@ var rules = {
1139
944
  "desktop.git.listBranches": { input: object(target), result: object({ branches: array(text(1024), 1e4) }) },
1140
945
  "desktop.git.changes": { input: object(target, { range: enumeration("uncommitted", "working", "staged"), ignoreWhitespace: bool }), result: object({ files: array(object({ path: text(32768), status: enumeration("added", "modified", "deleted", "renamed", "copied", "untracked"), additions: nullable(count), deletions: nullable(count), binary: bool }, { oldPath: text(32768) }), 1e4), totalAdditions: count, totalDeletions: count }) },
1141
946
  "desktop.git.diff": { input: object(target, { path: text(32768), base: text(), head: text(), range: enumeration("uncommitted", "working", "staged"), ignoreWhitespace: bool }), result: object({ text: text(8 * 1024 * 1024, true), truncated: bool }) },
1142
- "desktop.git.switchBranch": { input: object({ ...target, requestId: id, expectedHead: text(), branch: text() }), result: validWorkspaceOperation },
1143
- "desktop.git.createBranch": { input: object({ ...target, requestId: id, expectedHead: text(), branch: text() }), result: validWorkspaceOperation },
1144
- "desktop.git.createTaskWorktree": { input: object({ ...target, requestId: id, expectedHead: text(), branch: text() }), result: validWorkspaceOperation },
947
+ "desktop.git.switchBranch": { input: object({ ...target, requestId: id, ...gitBranchBody }), result: validWorkspaceOperation },
948
+ "desktop.git.createBranch": { input: object({ ...target, requestId: id, ...gitBranchBody }), result: validWorkspaceOperation },
1145
949
  "desktop.terminals.create": { input: object({ ...target, requestId: id, cols: positive, rows: positive }, { name: text(256) }), result: object({ resourceId: text(), terminalId: text(), cwd: text(32768), status: enumeration("running", "exited") }) },
1146
950
  "desktop.terminals.list": { input: object(target), result: array(object({ id: text(), name: text(1024, true), scope: (v) => object({ kind: enumeration("session"), sessionId: text() })(v) || object({ kind: enumeration("project"), projectId: text() })(v), runtime: enumeration("local", "environment"), source: enumeration("user", "agent"), status: enumeration("running", "stopping", "completed", "killed", "failed"), cwd: text(32768), shell: text(32768, true), cols: positive, rows: positive, createdAt: text() }, { projectId: text(), sessionId: text(), environmentKind: enumeration("native", "wsl"), distribution: text(), command: text(65536, true), exitedAt: text(), exitCode: nullable(finite2) }), 1e4) },
1147
951
  "desktop.terminals.restart": { input: object({ ...target, terminalId: text(), requestId: id }), result: object({ resourceId: text(), terminalId: text(), cwd: text(32768), status: enumeration("running", "exited") }) },
@@ -1234,24 +1038,48 @@ function createAppDesktopApi(rpc, owner, filesFeature = () => {
1234
1038
  if (!validDesktopResultForInput(method, params, value)) throw new AppHostError("host_unavailable");
1235
1039
  return value;
1236
1040
  };
1237
- const group = (name2) => Object.fromEntries(DESKTOP_METHODS.filter((m) => m !== "desktop.files.openRead" && m.startsWith(`desktop.${name2}.`)).map((method) => [method.split(".")[2], (params) => call(method, params)]));
1238
- return { bindTarget(input) {
1239
- if (!object({ draftId: text(), draftRevision: count }, { directory: text(32768), workspaceId: text(), connection: (v) => !!v && typeof v === "object", sessionId: text() })(input)) throw new AppHostError("invalid_request");
1240
- const { connection, ...rest } = input;
1241
- return call("desktop.bindTarget", { ...rest, ...connection === void 0 ? {} : { connectionId: resolveClientConnection(connection, owner) } });
1242
- }, releaseTarget: (input) => call("desktop.releaseTarget", input), files: Object.assign(group("files"), { async readFile(input, options = {}) {
1243
- if (!object({ ...target, path: text(32768) }, { range: object({ start: count }, { end: count }) })(input) || input.range?.end !== void 0 && input.range.end < input.range.start) throw new AppHostError("invalid_request");
1244
- filesFeature();
1245
- const { range: range2, ...params } = input;
1246
- const wire = await call("desktop.files.openRead", params);
1247
- const fetchFile = owner.fetchFor(wire.connectionId, wire.baseUrl);
1248
- try {
1249
- return await fetchFile(wire.baseUrl + "/", { ...options.signal ? { signal: options.signal } : {}, ...range2 ? { headers: { Range: `bytes=${range2.start}-${range2.end ?? ""}` } } : {} });
1250
- } catch (error) {
1251
- owner.close(wire.connectionId);
1252
- throw error;
1253
- }
1254
- } }), clipboard: group("clipboard"), git: group("git"), terminals: group("terminals"), windows: group("windows"), browser: group("browser"), pluginApps: group("pluginApps") };
1041
+ const group = (name2) => Object.fromEntries(DESKTOP_METHODS.filter((method) => !DESKTOP_ADAPTED_METHODS.includes(method) && method.startsWith(`desktop.${name2}.`)).map((method) => [method.split(".")[2], (params) => call(method, params)]));
1042
+ const getOperation = async (input, validate) => {
1043
+ if (!validate(input)) throw new AppHostError("invalid_request");
1044
+ return call("desktop.files.getOperation", input);
1045
+ };
1046
+ return {
1047
+ bindTarget(input) {
1048
+ if (!object({ draftId: text(), draftRevision: count }, { directory: text(32768), workspaceId: text(), connection: (v) => !!v && typeof v === "object", sessionId: text() })(input)) throw new AppHostError("invalid_request");
1049
+ const { connection, ...rest } = input;
1050
+ return call("desktop.bindTarget", { ...rest, ...connection === void 0 ? {} : { connectionId: resolveClientConnection(connection, owner) } });
1051
+ },
1052
+ releaseTarget: (input) => call("desktop.releaseTarget", input),
1053
+ files: {
1054
+ ...group("files"),
1055
+ getOperation: (input) => getOperation(input, validFileOperationQuery),
1056
+ async readFile(input, options = {}) {
1057
+ if (!object({ ...target, path: text(32768) }, { range: object({ start: count }, { end: count }) })(input) || input.range?.end !== void 0 && input.range.end < input.range.start) throw new AppHostError("invalid_request");
1058
+ filesFeature();
1059
+ const { range: range2, ...params } = input;
1060
+ const wire = await call("desktop.files.openRead", params);
1061
+ const fetchFile = owner.fetchFor(wire.connectionId, wire.baseUrl);
1062
+ try {
1063
+ return await fetchFile(wire.baseUrl + "/", {
1064
+ ...options.signal ? { signal: options.signal } : {},
1065
+ ...range2 ? { headers: { Range: `bytes=${range2.start}-${range2.end ?? ""}` } } : {}
1066
+ });
1067
+ } catch (error) {
1068
+ owner.close(wire.connectionId);
1069
+ throw error;
1070
+ }
1071
+ }
1072
+ },
1073
+ clipboard: group("clipboard"),
1074
+ git: {
1075
+ ...group("git"),
1076
+ getOperation: (input) => getOperation(input, validGitOperationQuery)
1077
+ },
1078
+ terminals: group("terminals"),
1079
+ windows: group("windows"),
1080
+ browser: group("browser"),
1081
+ pluginApps: group("pluginApps")
1082
+ };
1255
1083
  }
1256
1084
  function canonicalDesktopRequest(value) {
1257
1085
  if (!json(value)) throw new AppHostError("invalid_request");
@@ -1319,10 +1147,18 @@ function createAppAuxiliarySessionsApi(rpc, streams) {
1319
1147
  const { connection, ...rest } = input;
1320
1148
  return { ...rest, connectionId: resolveClientConnection(connection, streams) };
1321
1149
  };
1322
- return { getAuxiliaryOptions: (input) => request("sessions.getAuxiliaryOptions", { sessionId: input.sessionId, connectionId: resolveClientConnection(input.connection, streams) }), async openAuxiliary(input) {
1323
- const wire = await request("sessions.openAuxiliary", resolve(input));
1324
- return { leaseId: wire.receipt.leaseId, sessionId: wire.receipt.sessionId, connection: createClientConnection(wire, streams) };
1325
- }, getAuxiliary: (input) => request("sessions.getAuxiliary", resolve(input)), closeAuxiliary: (input) => request("sessions.closeAuxiliary", resolve(input)) };
1150
+ return {
1151
+ getOptions: (input) => request("sessions.getAuxiliaryOptions", {
1152
+ sessionId: input.sessionId,
1153
+ connectionId: resolveClientConnection(input.connection, streams)
1154
+ }),
1155
+ async open(input) {
1156
+ const wire = await request("sessions.openAuxiliary", resolve(input));
1157
+ return { leaseId: wire.receipt.leaseId, sessionId: wire.receipt.sessionId, connection: createClientConnection(wire, streams) };
1158
+ },
1159
+ get: (input) => request("sessions.getAuxiliary", resolve(input)),
1160
+ close: (input) => request("sessions.closeAuxiliary", resolve(input))
1161
+ };
1326
1162
  }
1327
1163
 
1328
1164
  // src/extensions.ts
@@ -1401,12 +1237,94 @@ function validProjectRequest(value) {
1401
1237
  case "archive":
1402
1238
  return object({ action: (v) => v === "archive", ...project })(value);
1403
1239
  case "rebind":
1404
- return object({ action: (v) => v === "rebind", ...scope, workspaceId: id2, previousWorkspaceId: id2 }, { projectId: id2, previousPath: text(32768) })(value);
1240
+ return object({ action: (v) => v === "rebind", ...project, previousWorkspaceId: id2, expectedPath: text(32768) })(value);
1405
1241
  default:
1406
1242
  return false;
1407
1243
  }
1408
1244
  }
1409
- var validProjectSnapshot = (value) => object({ dataScopeId: id2, projects: array(object({ workspaceId: id2, name: text(1024), path: text(32768), available: bool, lastOpenedAt: count }, { projectId: id2, defaultShell: text(4096) }), 1e4) })(value);
1245
+ var validProjectSnapshot = (value) => object({
1246
+ dataScopeId: id2,
1247
+ projects: array(object({ workspaceId: id2, projectId: id2, name: text(1024), path: text(32768), available: bool, lastOpenedAt: count }, {
1248
+ defaultShell: text(4096),
1249
+ rootIdentity: object({ dev: text(32), ino: text(32) })
1250
+ }), 1e4)
1251
+ }, { selectedWorkspaceId: id2 })(value);
1252
+
1253
+ // src/local-workspace.ts
1254
+ var root2 = { rootPath: text(32768) };
1255
+ var identity = { identity: object({ dev: text(32), ino: text(32) }) };
1256
+ var file = { ...root2, path: text(32768) };
1257
+ var write = { ...file, requestId: id, content: text(125e4, true), originalContent: text(125e4, true) };
1258
+ var actionOf = (value) => value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, "action")?.value : void 0;
1259
+ function validLocalWorkspaceRequest(value) {
1260
+ const action2 = actionOf(value);
1261
+ const field = { action: enumeration(action2) };
1262
+ switch (action2) {
1263
+ case "pick":
1264
+ case "listOpeners":
1265
+ return object(field)(value);
1266
+ case "list":
1267
+ return object({ ...field, ...root2 }, { ...identity, path: text(32768, true) })(value);
1268
+ case "find":
1269
+ return object({ ...field, ...root2, query: text(1024) }, identity)(value);
1270
+ case "write":
1271
+ case "getWrite":
1272
+ return object({ ...field, ...write }, identity)(value);
1273
+ case "openWith":
1274
+ return object({ ...field, ...file, openerId: text(256) }, identity)(value);
1275
+ case "copyPath":
1276
+ return object({ ...field, ...file }, { ...identity, absolute: bool })(value);
1277
+ case "read":
1278
+ case "reveal":
1279
+ case "webPreview":
1280
+ return object({ ...field, ...file }, identity)(value);
1281
+ default:
1282
+ return false;
1283
+ }
1284
+ }
1285
+ var bytes = (limit) => (value) => value instanceof ArrayBuffer && value.byteLength <= limit;
1286
+ var preview = object({
1287
+ path: text(32768),
1288
+ name: text(32768),
1289
+ language: text(4096),
1290
+ size: count,
1291
+ binary: bool,
1292
+ content: nullable(text(125e4, true)),
1293
+ scope: enumeration("project", "extra-root"),
1294
+ relativePath: text(32768),
1295
+ rootLabel: text(32768),
1296
+ previewBytes: nullable(bytes(50 * 1024 * 1024)),
1297
+ mediaType: enumeration(null, "image/avif", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"),
1298
+ imagePreviewError: enumeration(null, "image_too_large", "image_unsupported")
1299
+ }, {
1300
+ rootIdentity: identity.identity,
1301
+ documentPreview: object({ format: enumeration("pdf", "epub", "docx", "xlsx", "pptx"), bytes: bytes(64 * 1024 * 1024) })
1302
+ });
1303
+ var tree = object({
1304
+ ...root2,
1305
+ entries: array(object({ path: text(32768), type: enumeration("file", "directory") }, { size: count }), 1e4)
1306
+ }, { truncated: bool });
1307
+ var found = object({ files: array(text(32768), 1e3), truncated: bool });
1308
+ var picked = object({ ...root2, ...identity, workspaceId: id });
1309
+ var url = object({ url: text(131072) });
1310
+ var openers = (value) => validDesktopResult("desktop.files.listOpeners", value);
1311
+ var empty2 = (value) => value === void 0;
1312
+ var checks = {
1313
+ pick: nullable(picked),
1314
+ list: tree,
1315
+ find: found,
1316
+ read: preview,
1317
+ write: preview,
1318
+ getWrite: nullable(preview),
1319
+ reveal: empty2,
1320
+ openWith: empty2,
1321
+ copyPath: empty2,
1322
+ listOpeners: openers,
1323
+ webPreview: url
1324
+ };
1325
+ function validLocalWorkspaceResult(value, action2) {
1326
+ return action2 ? checks[action2](value) : Object.values(checks).some((check) => check(value));
1327
+ }
1410
1328
 
1411
1329
  // ../domain-contracts/src/app-host/model-providers.ts
1412
1330
  var provider = text(256);
@@ -1446,8 +1364,9 @@ function validModelProviderConnections(value) {
1446
1364
  var modelId = text(1024);
1447
1365
  var effort = nullable(text(256));
1448
1366
  var revision = text(8192);
1367
+ var accountGatewayProof = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
1449
1368
  function validProviderDefaultsRequest(value) {
1450
- return object({ action: enumeration("snapshot") })(value) || object({ action: enumeration("updateModel"), model: modelId }, { provider, effort, expectedRevision: revision })(value) || object({ action: enumeration("updateEffort"), effort, expectedRevision: revision })(value) || object({ action: enumeration("test"), provider, model: modelId })(value);
1369
+ return object({ action: enumeration("snapshot") }, { accountGatewayProof })(value) || object({ action: enumeration("updateModel"), model: modelId }, { provider, effort, expectedRevision: revision })(value) || object({ action: enumeration("updateEffort"), effort, expectedRevision: revision })(value) || object({ action: enumeration("test"), provider, model: modelId })(value);
1451
1370
  }
1452
1371
  var verifiedProvider = object({ model: modelId, checkedAt: count });
1453
1372
  var verified = (value) => {
@@ -1471,7 +1390,7 @@ var validProviderDefaultsSnapshot = object({
1471
1390
  verified,
1472
1391
  fastModeAvailable: enumeration(false),
1473
1392
  fastModeReason: text(1024)
1474
- });
1393
+ }, { accountGatewayMatches: bool });
1475
1394
  var validProviderConnectionTestResult = object({
1476
1395
  status: enumeration("verified", "failed"),
1477
1396
  detail: text(8192),
@@ -1518,6 +1437,7 @@ var SYSTEM_SHORTCUT_IDS = [
1518
1437
  ];
1519
1438
  var SYSTEM_METHODS = [
1520
1439
  "system.projects",
1440
+ "system.workspace",
1521
1441
  "system.extensions",
1522
1442
  "system.modelProviders",
1523
1443
  "system.providerDefaults",
@@ -1615,6 +1535,8 @@ function validSystemInput(method, value) {
1615
1535
  switch (method) {
1616
1536
  case "system.projects":
1617
1537
  return validProjectRequest(value);
1538
+ case "system.workspace":
1539
+ return validLocalWorkspaceRequest(value);
1618
1540
  case "system.extensions":
1619
1541
  return validExtensionRequest(value);
1620
1542
  case "system.modelProviders":
@@ -1664,6 +1586,8 @@ function validSystemResult(method, value) {
1664
1586
  switch (method) {
1665
1587
  case "system.projects":
1666
1588
  return validProjectSnapshot(value);
1589
+ case "system.workspace":
1590
+ return validLocalWorkspaceResult(value);
1667
1591
  case "system.extensions":
1668
1592
  return validExtensionResult(value);
1669
1593
  case "system.modelProviders":
@@ -1704,6 +1628,11 @@ function createAppSystemApi(requester, connectionOwner) {
1704
1628
  }
1705
1629
  return {
1706
1630
  projects: (input) => send("system.projects", input),
1631
+ workspace: (async (input) => {
1632
+ const result = await send("system.workspace", input);
1633
+ if (!validLocalWorkspaceResult(result, input.action)) throw new AppHostError("host_unavailable");
1634
+ return result;
1635
+ }),
1707
1636
  extensions: (input) => send("system.extensions", input),
1708
1637
  modelProviders: (input) => send("system.modelProviders", input),
1709
1638
  providerDefaults: (async (input) => {
@@ -1730,8 +1659,8 @@ function createAppSystemApi(requester, connectionOwner) {
1730
1659
  getPresentationPreferences: () => send("system.getPresentationPreferences", {}),
1731
1660
  setTheme: (theme) => send("system.setTheme", { theme }),
1732
1661
  setWindowMaterial: (preference) => send("system.setWindowMaterial", { preference }),
1733
- copyText: (text3) => send("system.copyText", { text: text3 }),
1734
- openExternal: (url) => send("system.openExternal", { url }),
1662
+ copyText: (text2) => send("system.copyText", { text: text2 }),
1663
+ openExternal: (url2) => send("system.openExternal", { url: url2 }),
1735
1664
  navigationReady: () => send("system.navigationReady", {}),
1736
1665
  completeNavigation: (input) => send("system.completeNavigation", input)
1737
1666
  };
@@ -1759,11 +1688,14 @@ function isAppLifecycleFrame(value) {
1759
1688
  const descriptors = Object.getOwnPropertyDescriptors(value);
1760
1689
  if (Reflect.ownKeys(descriptors).some((key) => typeof key !== "string" || !descriptors[key].enumerable || !Object.hasOwn(descriptors[key], "value"))) return false;
1761
1690
  const frame = value;
1762
- const fields4 = frame.type === "lifecycle-prepare" ? ["protocol", "type", "id", "reason"] : frame.type === "lifecycle-cancel" ? ["protocol", "type", "id"] : frame.type === "lifecycle-result" ? ["protocol", "type", "id", "ready"] : void 0;
1763
- if (!fields4 || Reflect.ownKeys(value).length !== fields4.length || !fields4.every((key) => Object.hasOwn(value, key)) || frame.protocol !== 1 || typeof frame.id !== "string" || !HOST_REQUEST_ID.test(frame.id)) return false;
1691
+ const fields2 = frame.type === "lifecycle-prepare" ? ["protocol", "type", "id", "reason"] : frame.type === "lifecycle-cancel" ? ["protocol", "type", "id"] : frame.type === "lifecycle-result" ? ["protocol", "type", "id", "ready"] : void 0;
1692
+ if (!fields2 || Reflect.ownKeys(value).length !== fields2.length || !fields2.every((key) => Object.hasOwn(value, key)) || frame.protocol !== 1 || typeof frame.id !== "string" || !HOST_REQUEST_ID.test(frame.id)) return false;
1764
1693
  return frame.type === "lifecycle-prepare" ? ["switch", "reload", "disable", "quit"].includes(frame.reason) : frame.type === "lifecycle-result" ? typeof frame.ready === "boolean" : true;
1765
1694
  }
1766
1695
 
1696
+ // src/workspace.ts
1697
+ var validPickOptions = object({}, { requestId: (value) => value === void 0 || id(value) });
1698
+
1767
1699
  // src/protocol.ts
1768
1700
  var APP_HOST_PROTOCOL = 1;
1769
1701
  var APP_HOST_READY = "nomi.app-host.ready";
@@ -1834,9 +1766,6 @@ export {
1834
1766
  FETCH_WINDOW_CHUNKS,
1835
1767
  HOST_REQUEST_ID,
1836
1768
  RESOURCE_CATALOG_METHODS,
1837
- SERVICE_HOST_MAX_FRAME_BYTES,
1838
- SERVICE_HOST_MAX_PENDING,
1839
- SERVICE_HOST_METHODS,
1840
1769
  SYSTEM_METHODS,
1841
1770
  SYSTEM_SETTINGS_SECTIONS,
1842
1771
  SYSTEM_SHORTCUT_IDS,
@@ -1859,7 +1788,6 @@ export {
1859
1788
  isPageFetchFrame,
1860
1789
  isResourceCatalogMethod,
1861
1790
  isSafeErrorDetails,
1862
- isServiceHostFrame,
1863
1791
  isSystemMethod,
1864
1792
  isWindowMethod,
1865
1793
  matchAgentApiRoute,
@@ -1891,9 +1819,6 @@ export {
1891
1819
  validResourceCatalogInput,
1892
1820
  validResourceCatalogResult,
1893
1821
  validResourceChanged,
1894
- validServiceContext,
1895
- validServiceHostInput,
1896
- validServiceHostResult,
1897
1822
  validSessionResourceInput,
1898
1823
  validSessionResourceResult,
1899
1824
  validSessionSettingsTarget,