@bobannomi/app-host 0.6.1 → 0.8.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/index.js CHANGED
@@ -115,18 +115,6 @@ function appHostErrorMessage(code, details) {
115
115
  return "The desktop host could not read the response stream.";
116
116
  case "response_delivery_failed":
117
117
  return "The desktop host could not deliver the response.";
118
- case "skill_marketplace_unavailable":
119
- return "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B98\u65B9\u6280\u80FD\u5E02\u573A\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
120
- case "skill_marketplace_install_failed":
121
- return "\u6280\u80FD\u5B89\u88C5\u6216\u66F4\u65B0\u672A\u5B8C\u6210\uFF0C\u8BF7\u5237\u65B0\u5DF2\u5B89\u88C5\u6280\u80FD\u540E\u91CD\u8BD5\u3002";
122
- case "skill_marketplace_busy":
123
- return "\u540E\u53F0\u6B63\u5728\u8FD0\u884C\u4EFB\u52A1\u6216\u5904\u7406\u6280\u80FD\u53D8\u66F4\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
124
- case "skill_marketplace_local_conflict":
125
- return "\u6240\u9009\u8303\u56F4\u5185\u5DF2\u6709\u540C\u540D\u6280\u80FD\u6216\u672C\u5730\u6539\u52A8\uFF0C\u8BF7\u68C0\u67E5\u5DF2\u5B89\u88C5\u7684\u6280\u80FD\u3002";
126
- case "skill_marketplace_selection_changed":
127
- return "\u6240\u9009\u6280\u80FD\u6216\u7248\u672C\u5DF2\u53D8\u5316\uFF0C\u8BF7\u5237\u65B0\u6280\u80FD\u5E02\u573A\u540E\u91CD\u8BD5\u3002";
128
- case "skill_marketplace_project_unavailable":
129
- return "\u5F53\u524D\u9879\u76EE\u65E0\u6CD5\u5B89\u88C5\u6280\u80FD\uFF0C\u8BF7\u9009\u62E9\u5DF2\u767B\u8BB0\u7684\u9879\u76EE\u3002";
130
118
  default:
131
119
  return "The desktop host could not complete the operation.";
132
120
  }
@@ -168,7 +156,7 @@ var AppHostError = class extends Error {
168
156
  };
169
157
 
170
158
  // ../domain-contracts/src/app-host/wire-validation.ts
171
- var text = (max = 1024, empty3 = false) => (v) => typeof v === "string" && (empty3 || v.length > 0) && new TextEncoder().encode(v).byteLength <= max;
159
+ var text = (max = 1024, empty2 = false) => (v) => typeof v === "string" && (empty2 || v.length > 0) && new TextEncoder().encode(v).byteLength <= max;
172
160
  var id = (v) => typeof v === "string" && HOST_REQUEST_ID.test(v);
173
161
  var count = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
174
162
  var bool = (v) => typeof v === "boolean";
@@ -271,6 +259,11 @@ var FETCH_MAX_STREAMS = 16;
271
259
  var FETCH_METADATA_BYTES = 64 * 1024;
272
260
  var FETCH_HEADERS_TIMEOUT_MS = 3e4;
273
261
  var FETCH_IDLE_TIMEOUT_MS = 12e4;
262
+ function pageFetchHeadersTimeout(method, target2) {
263
+ const path = target2.split("?", 1)[0];
264
+ const preparesExtension = method === "GET" ? path === "/skills/marketplace" || path === "/plugins/marketplace/catalog" : method === "POST" && /^\/(?:skills\/marketplace\/install|plugins\/(?:archive|git|marketplace)\/(?:preview|install))$/.test(path ?? "");
265
+ return preparesExtension ? 33e4 : FETCH_HEADERS_TIMEOUT_MS;
266
+ }
274
267
  function isPageFetchFrame(value) {
275
268
  let size = 0;
276
269
  const visit = (entry, depth, binary = false) => {
@@ -663,7 +656,7 @@ function createAppCommandsApi(rpc) {
663
656
  rpc.requireFeature();
664
657
  snapshot = structuredClone(snapshot);
665
658
  const registrationId = crypto.randomUUID();
666
- let revision3 = 0;
659
+ let revision2 = 0;
667
660
  let disposed = false;
668
661
  let remoteValid = true;
669
662
  let disposal;
@@ -671,11 +664,11 @@ function createAppCommandsApi(rpc) {
671
664
  let conflicts = [];
672
665
  let queue = Promise.resolve();
673
666
  const off = rpc.onInvoke((event) => {
674
- if (!disposed && event.registrationId === registrationId && event.revision === revision3 && current.commands.some(
667
+ if (!disposed && event.registrationId === registrationId && event.revision === revision2 && current.commands.some(
675
668
  (c) => c.id === event.commandId && c.enabled !== false
676
669
  )) {
677
670
  void Promise.resolve().then(() => {
678
- if (!disposed && event.revision === revision3)
671
+ if (!disposed && event.revision === revision2)
679
672
  return invoke(event.commandId);
680
673
  }).catch(() => {
681
674
  });
@@ -695,14 +688,14 @@ function createAppCommandsApi(rpc) {
695
688
  const call = async (method, next) => {
696
689
  const params = {
697
690
  registrationId,
698
- revision: revision3,
691
+ revision: revision2,
699
692
  ...next === void 0 ? {} : { snapshot: next }
700
693
  };
701
694
  const result = await rpc.request(
702
695
  method,
703
696
  params
704
697
  );
705
- if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !== revision3)
698
+ if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !== revision2)
706
699
  throw new AppHostError("host_unavailable");
707
700
  conflicts = [...result.shortcutConflicts ?? []];
708
701
  };
@@ -712,7 +705,7 @@ function createAppCommandsApi(rpc) {
712
705
  try {
713
706
  await rpc.request("commands.dispose", {
714
707
  registrationId,
715
- revision: ++revision3
708
+ revision: ++revision2
716
709
  });
717
710
  } catch {
718
711
  }
@@ -736,7 +729,7 @@ function createAppCommandsApi(rpc) {
736
729
  const task = queue.then(async () => {
737
730
  if (disposed) throw new AppHostError("connection_revoked");
738
731
  rpc.requireFeature();
739
- revision3++;
732
+ revision2++;
740
733
  current = next;
741
734
  try {
742
735
  await call("commands.update", next);
@@ -754,7 +747,7 @@ function createAppCommandsApi(rpc) {
754
747
  stop();
755
748
  disposal = queue.then(async () => {
756
749
  if (!remoteValid) return;
757
- revision3++;
750
+ revision2++;
758
751
  try {
759
752
  await call("commands.dispose");
760
753
  } finally {
@@ -791,7 +784,7 @@ function text2(value, limit = 256) {
791
784
  return typeof value === "string" && value.length > 0 && value.length <= limit;
792
785
  }
793
786
  function keys(value, ...names) {
794
- return Object.keys(value).length === names.length && names.every((name2) => Object.hasOwn(value, name2));
787
+ return Object.keys(value).length === names.length && names.every((name) => Object.hasOwn(value, name));
795
788
  }
796
789
  function isWorkbenchComputerMethod(method) {
797
790
  return WORKBENCH_COMPUTER_METHODS.includes(method);
@@ -879,9 +872,9 @@ function createConversationPreparationApi(rpc) {
879
872
  // src/client-connections.ts
880
873
  var connections = /* @__PURE__ */ new WeakMap();
881
874
  function createClientConnection(wire, streams) {
882
- const { connectionId, baseUrl, cwd: cwd2, defaultTaskLocation } = wire;
875
+ const { connectionId, baseUrl, cwd, defaultTaskLocation } = wire;
883
876
  const connection = {
884
- ...cwd2 === void 0 ? {} : { cwd: cwd2 },
877
+ ...cwd === void 0 ? {} : { cwd },
885
878
  ...defaultTaskLocation === void 0 ? {} : { defaultTaskLocation },
886
879
  clientOptions: { baseUrl, fetch: streams.fetchFor(connectionId, baseUrl) },
887
880
  isClosed: () => streams.isClosed?.(connectionId) === true
@@ -1056,7 +1049,7 @@ function createAppDesktopApi(rpc, owner, filesFeature = () => {
1056
1049
  if (!validDesktopResultForInput(method, params, value)) throw new AppHostError("host_unavailable");
1057
1050
  return value;
1058
1051
  };
1059
- 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)]));
1052
+ const group = (name) => Object.fromEntries(DESKTOP_METHODS.filter((method) => !DESKTOP_ADAPTED_METHODS.includes(method) && method.startsWith(`desktop.${name}.`)).map((method) => [method.split(".")[2], (params) => call(method, params)]));
1060
1053
  const getOperation = async (input, validate2) => {
1061
1054
  if (!validate2(input)) throw new AppHostError("invalid_request");
1062
1055
  return call("desktop.files.getOperation", input);
@@ -1109,66 +1102,6 @@ function canonicalDesktopRequest(value) {
1109
1102
  return JSON.stringify(normalize(value));
1110
1103
  }
1111
1104
 
1112
- // src/extensions.ts
1113
- var empty = object({});
1114
- var cwd = object({ cwd: text(4096) });
1115
- var plugin = object({ cwd: text(4096), pluginId: text(256) });
1116
- var selection = object({ cwd: text(4096), selectionId: text(256) });
1117
- var cancel = object({ selectionId: text(256) });
1118
- var name = object({ name: text(256) });
1119
- var login = object({ loginId: text(256) });
1120
- var skillSelection = { id: text(64), version: text(32), sha256: digest };
1121
- var personalSkillInstall = object({ ...skillSelection, scope: enumeration("personal") });
1122
- var projectSkillInstall = object({
1123
- ...skillSelection,
1124
- scope: enumeration("project"),
1125
- projectPath: (value) => typeof value === "string" && value.trim().length > 0 && text(4096)(value)
1126
- });
1127
- var EXTENSION_INPUTS = {
1128
- context: empty,
1129
- "plugins.loadIcon": object({ src: text(8192) }),
1130
- "plugins.snapshot": cwd,
1131
- "plugins.enable": plugin,
1132
- "plugins.disable": plugin,
1133
- "plugins.uninstall": plugin,
1134
- "plugins.reload": cwd,
1135
- "plugins.importArchive": cwd,
1136
- "plugins.confirmArchive": selection,
1137
- "plugins.cancelArchive": cancel,
1138
- "plugins.importGit": object({ cwd: text(4096), url: text(8192) }, { ref: text(1024) }),
1139
- "plugins.confirmGit": selection,
1140
- "plugins.cancelGit": cancel,
1141
- "plugins.marketplaceCatalog": object({ cwd: text(4096) }, { refresh: bool }),
1142
- "plugins.marketplaceAddSource": object({ url: text(8192) }),
1143
- "plugins.marketplaceSetSourceEnabled": object({ sourceId: text(256), enabled: bool }),
1144
- "plugins.marketplaceRemoveSource": object({ sourceId: text(256) }),
1145
- "plugins.marketplacePreview": object({ cwd: text(4096), sourceId: text(256), pluginId: text(256) }, { version: text(256) }),
1146
- "plugins.marketplaceConfirm": selection,
1147
- "plugins.marketplaceCancel": cancel,
1148
- "plugins.marketplaceOperation": object({ cwd: text(4096), operationId: text(256) }),
1149
- "skills.snapshot": object({ projectPath: text(4096) }),
1150
- "skills.remove": object({ id: text(4096), expectedContent: text(8 * 1024 * 1024, true), projectPath: text(4096) }),
1151
- "skills.marketplaceCatalog": empty,
1152
- "skills.marketplaceInstall": (value) => personalSkillInstall(value) || projectSkillInstall(value),
1153
- "mcp.snapshot": empty,
1154
- "mcp.exportConfig": empty,
1155
- "mcp.getConfig": name,
1156
- "mcp.add": object({ name: text(256), config: jsonObject }),
1157
- "mcp.update": object({ name: text(256), config: jsonObject, expectedConfig: jsonObject }),
1158
- "mcp.remove": name,
1159
- "mcp.setEnabled": object({ name: text(256), enabled: bool }),
1160
- "mcp.login": object({ name: text(256), scopes: array(text(2048), 128) }),
1161
- "mcp.loginStatus": login,
1162
- "mcp.cancelLogin": login,
1163
- "mcp.logout": name
1164
- };
1165
- function validExtensionRequest(value) {
1166
- if (!object({ operation: text(128), input: jsonObject })(value)) return false;
1167
- const request = value;
1168
- return Object.hasOwn(EXTENSION_INPUTS, request.operation) && EXTENSION_INPUTS[request.operation](request.input);
1169
- }
1170
- var validExtensionResult = (value) => value === void 0 || json(value);
1171
-
1172
1105
  // src/projects.ts
1173
1106
  var id2 = text(256);
1174
1107
  var scope = { dataScopeId: id2 };
@@ -1256,7 +1189,7 @@ var found = object({ files: array(text(32768), 1e3), truncated: bool });
1256
1189
  var picked = object({ ...root2, ...identity, workspaceId: id });
1257
1190
  var url = object({ url: text(131072) });
1258
1191
  var openers = (value) => validDesktopResult("desktop.files.listOpeners", value);
1259
- var empty2 = (value) => value === void 0;
1192
+ var empty = (value) => value === void 0;
1260
1193
  var checks = {
1261
1194
  pick: nullable(picked),
1262
1195
  list: tree,
@@ -1264,9 +1197,9 @@ var checks = {
1264
1197
  read: preview,
1265
1198
  write: preview,
1266
1199
  getWrite: nullable(preview),
1267
- reveal: empty2,
1268
- openWith: empty2,
1269
- copyPath: empty2,
1200
+ reveal: empty,
1201
+ openWith: empty,
1202
+ copyPath: empty,
1270
1203
  listOpeners: openers,
1271
1204
  webPreview: url
1272
1205
  };
@@ -1274,77 +1207,6 @@ function validLocalWorkspaceResult(value, action2) {
1274
1207
  return action2 ? checks[action2](value) : Object.values(checks).some((check) => check(value));
1275
1208
  }
1276
1209
 
1277
- // ../domain-contracts/src/app-host/model-providers.ts
1278
- var provider = text(256);
1279
- var imageInputSupport = enumeration("native", "unsupported", "unknown");
1280
- var limits = { contextWindow: count, maxOutputTokens: count };
1281
- function headerValues(check) {
1282
- return (value) => {
1283
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1284
- const keys3 = Object.keys(value);
1285
- return keys3.length <= 128 && keys3.every((key) => /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,256}$/.test(key)) && object(Object.fromEntries(keys3.map((key) => [key, check])))(value);
1286
- };
1287
- }
1288
- var headers = headerValues(text(8192, true));
1289
- var secretHeaders = headerValues(nullable(text(8192)));
1290
- var customProvider = object({
1291
- id: provider,
1292
- displayName: text(1024),
1293
- baseUrl: text(4096),
1294
- apiFormat: enumeration("openai"),
1295
- models: array(object({ id: text(1024), displayName: text(1024) }, { imageInputSupport, ...limits }), 16384)
1296
- }, { apiKey: text(8192), headers, secretHeaders });
1297
- function validModelProviderRequest(value) {
1298
- return object({ action: enumeration("list", "refresh") })(value) || object({ action: enumeration("connect"), provider, apiKey: text(8192) }, { headers, secretHeaders })(value) || object({ action: enumeration("updateHeaders"), provider, headers }, { secretHeaders })(value) || object({ action: enumeration("createCustom", "syncAccount"), value: customProvider })(value) || object({ action: enumeration("updateCustom"), provider, value: customProvider })(value) || object({ action: enumeration("disconnect", "removeCustom"), provider }, { disableDefault: bool })(value) || object({ action: enumeration("disconnect", "removeCustom"), provider, replacement: object({ provider, model: text(1024) }) })(value);
1299
- }
1300
- var validModel = object({ id: text(1024), label: text(1024) }, { imageInputSupport, declaredLimits: object({}, limits) });
1301
- var validConnection2 = object({
1302
- name: provider,
1303
- displayName: text(1024),
1304
- connected: bool,
1305
- active: bool,
1306
- credentialSource: enumeration("credentials", "environment", "subscription", "local", "configured", "none"),
1307
- models: array(validModel, 16384)
1308
- }, { source: enumeration("builtin", "catalog", "custom", "subscription"), custom: bool, credentialLabel: text(1024), baseUrl: text(4096), headers, secretHeaderNames: array(text(256), 128) });
1309
- function validModelProviderConnections(value) {
1310
- return array(validConnection2, 4096)(value);
1311
- }
1312
- var modelId = text(1024);
1313
- var effort = nullable(text(256));
1314
- var revision = text(8192);
1315
- var accountGatewayProof = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
1316
- function validProviderDefaultsRequest(value) {
1317
- 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);
1318
- }
1319
- var verifiedProvider = object({ model: modelId, checkedAt: count });
1320
- var verified = (value) => {
1321
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1322
- const keys3 = Object.keys(value);
1323
- return keys3.length <= 4096 && keys3.every(provider) && object(Object.fromEntries(keys3.map((key) => [key, verifiedProvider])))(value);
1324
- };
1325
- var defaultsModel = object({ id: modelId, label: text(1024), provider: text(1024), providerName: provider }, {
1326
- reasoningEfforts: array(text(256, true)),
1327
- contextWindow: count,
1328
- inputModalities: array(text(256)),
1329
- inputCapabilities: object({ image: imageInputSupport })
1330
- });
1331
- var validProviderDefaultsSnapshot = object({
1332
- models: array(defaultsModel, 16384),
1333
- provider: nullable(provider),
1334
- model: nullable(modelId),
1335
- effort,
1336
- disabled: bool,
1337
- revision,
1338
- verified,
1339
- fastModeAvailable: enumeration(false),
1340
- fastModeReason: text(1024)
1341
- }, { accountGatewayMatches: bool });
1342
- var validProviderConnectionTestResult = object({
1343
- status: enumeration("verified", "failed"),
1344
- detail: text(8192),
1345
- checkedAt: count
1346
- }, { category: enumeration("authentication", "address", "network", "model", "unsupported", "service") });
1347
-
1348
1210
  // src/system.ts
1349
1211
  var SYSTEM_SETTINGS_SECTIONS = [
1350
1212
  "general",
@@ -1382,29 +1244,10 @@ var SYSTEM_SHORTCUT_IDS = [
1382
1244
  "resetZoom",
1383
1245
  "showShortcuts"
1384
1246
  ];
1385
- var CHANNEL_SETTINGS_ACTIONS = [
1386
- "snapshot",
1387
- "runtimeStatus",
1388
- "connect",
1389
- "patch",
1390
- "remove",
1391
- "allowAdd",
1392
- "allowRemove",
1393
- "startRegistration",
1394
- "registrationStatus",
1395
- "cancelRegistration",
1396
- "startRuntime",
1397
- "stopRuntime"
1398
- ];
1399
- var channelSettingsKey = /* @__PURE__ */ Symbol.for("nomi.workbench-channel-settings");
1400
- var channelSettingsValue = (value) => !!value && typeof value === "object" && !Array.isArray(value);
1401
1247
  var SYSTEM_METHODS = [
1402
1248
  "system.projects",
1403
1249
  "system.workspace",
1404
- "system.extensions",
1405
- "system.modelProviders",
1406
- "system.channelSettings",
1407
- "system.providerDefaults",
1250
+ "system.pickFile",
1408
1251
  "system.open",
1409
1252
  "system.getPresentationPreferences",
1410
1253
  "system.setTheme",
@@ -1479,7 +1322,11 @@ var validDesktopNavigationTarget = (v) => object(
1479
1322
  scheduledRunId: text(256)
1480
1323
  },
1481
1324
  { sessionId: text(256) }
1482
- )(v);
1325
+ )(v) || object({
1326
+ id: text(256),
1327
+ dataScopeId: text(256),
1328
+ kind: enumeration("extensions")
1329
+ })(v);
1483
1330
  function isSystemMethod(v) {
1484
1331
  return SYSTEM_METHODS.includes(v);
1485
1332
  }
@@ -1501,21 +1348,13 @@ function validSystemInput(method, value) {
1501
1348
  return validProjectRequest(value);
1502
1349
  case "system.workspace":
1503
1350
  return validLocalWorkspaceRequest(value);
1504
- case "system.extensions":
1505
- return validExtensionRequest(value);
1506
- case "system.modelProviders":
1507
- return validModelProviderRequest(value);
1508
- case "system.channelSettings": {
1509
- const action2 = enumeration(...CHANNEL_SETTINGS_ACTIONS);
1510
- if (object({ action: enumeration("allowRemove"), input: text() })(value)) return true;
1511
- if (object({
1512
- action: enumeration("connect", "patch", "allowAdd", "startRegistration"),
1513
- input: channelSettingsValue
1514
- })(value)) return true;
1515
- return object({ action: (entry) => action2(entry) && !["allowRemove", "connect", "patch", "allowAdd", "startRegistration"].includes(entry) })(value);
1516
- }
1517
- case "system.providerDefaults":
1518
- return validProviderDefaultsRequest(value);
1351
+ case "system.pickFile":
1352
+ return object({}, {
1353
+ filters: array(object({
1354
+ name: text(100),
1355
+ extensions: array((extension) => typeof extension === "string" && /^[a-z0-9][a-z0-9.-]{0,15}$/i.test(extension), 16)
1356
+ }), 16)
1357
+ })(value);
1519
1358
  case "system.setTheme":
1520
1359
  return object({ theme: themeMode })(value);
1521
1360
  case "system.setWindowMaterial":
@@ -1529,9 +1368,6 @@ function validSystemInput(method, value) {
1529
1368
  { page: enumeration("scheduled") },
1530
1369
  { taskId: text(256), scheduledRunId: text(256) }
1531
1370
  )(value) && (!Object.hasOwn(value, "scheduledRunId") || Object.hasOwn(value, "taskId")) || object(
1532
- { page: enumeration("extensions") },
1533
- { tab: enumeration("plugins", "skills", "mcp") }
1534
- )(value) || object(
1535
1371
  { page: enumeration("settings") },
1536
1372
  { section: enumeration(...SYSTEM_SETTINGS_SECTIONS) }
1537
1373
  )(value) || object({ page: enumeration("pet") })(value) || object(
@@ -1561,14 +1397,8 @@ function validSystemResult(method, value) {
1561
1397
  return validProjectSnapshot(value);
1562
1398
  case "system.workspace":
1563
1399
  return validLocalWorkspaceResult(value);
1564
- case "system.extensions":
1565
- return validExtensionResult(value);
1566
- case "system.modelProviders":
1567
- return validModelProviderConnections(value);
1568
- case "system.channelSettings":
1569
- return object({ value: channelSettingsValue })(value) || object({ error: enumeration("invalid_configuration", "conflict") })(value);
1570
- case "system.providerDefaults":
1571
- return validProviderDefaultsSnapshot(value) || validProviderConnectionTestResult(value);
1400
+ case "system.pickFile":
1401
+ return nullable(text(4096))(value);
1572
1402
  case "system.open":
1573
1403
  return object({ opened: enumeration(true) })(value);
1574
1404
  case "system.getPresentationPreferences":
@@ -1608,14 +1438,7 @@ function createAppSystemApi(requester, connectionOwner) {
1608
1438
  if (!validLocalWorkspaceResult(result, input.action)) throw new AppHostError("host_unavailable");
1609
1439
  return result;
1610
1440
  }),
1611
- extensions: (input) => send("system.extensions", input),
1612
- modelProviders: (input) => send("system.modelProviders", input),
1613
- providerDefaults: (async (input) => {
1614
- const result = await send("system.providerDefaults", input);
1615
- if (!(input.action === "test" ? validProviderConnectionTestResult(result) : validProviderDefaultsSnapshot(result)))
1616
- throw new AppHostError("invalid_request");
1617
- return result;
1618
- }),
1441
+ pickFile: (input = {}) => send("system.pickFile", input),
1619
1442
  open: (input) => {
1620
1443
  if (input.page !== "session-settings") return send("system.open", input);
1621
1444
  const { target: target2 } = input;
@@ -1639,9 +1462,6 @@ function createAppSystemApi(requester, connectionOwner) {
1639
1462
  navigationReady: () => send("system.navigationReady", {}),
1640
1463
  completeNavigation: (input) => send("system.completeNavigation", input)
1641
1464
  };
1642
- Object.defineProperty(system, channelSettingsKey, {
1643
- value: (input) => send("system.channelSettings", input)
1644
- });
1645
1465
  return system;
1646
1466
  }
1647
1467
 
@@ -1785,8 +1605,8 @@ function createAppAttachmentsApi(rpc, streams) {
1785
1605
 
1786
1606
  // src/auxiliary.ts
1787
1607
  var AUXILIARY_METHODS = ["sessions.getAuxiliaryOptions", "sessions.openAuxiliary", "sessions.getAuxiliary", "sessions.closeAuxiliary"];
1788
- var selection2 = object({ optionsRevision: text(), model: text(), workMode: text(), effort: text(1024, true) });
1789
- var tuple = object({ connectionId: text(), sessionId: text(), requestId: id, id: text(), selection: selection2 });
1608
+ var selection = object({ optionsRevision: text(), model: text(), workMode: text(), effort: text(1024, true) });
1609
+ var tuple = object({ connectionId: text(), sessionId: text(), requestId: id, id: text(), selection });
1790
1610
  var receipt2 = object({ requestId: id, id: text(), state: enumeration("opening", "open", "closing", "closed") }, { leaseId: text(), sessionId: text() });
1791
1611
  function isAuxiliaryMethod(method) {
1792
1612
  return AUXILIARY_METHODS.includes(method);
@@ -1943,7 +1763,7 @@ function isAppLifecycleFrame(value) {
1943
1763
  function createAppLifecycle(options) {
1944
1764
  const handlers = /* @__PURE__ */ new Set();
1945
1765
  let active;
1946
- const cancel2 = () => {
1766
+ const cancel = () => {
1947
1767
  const old = active;
1948
1768
  active = void 0;
1949
1769
  old?.controller.abort();
@@ -1961,14 +1781,14 @@ function createAppLifecycle(options) {
1961
1781
  };
1962
1782
  const finish = (pending, ready) => {
1963
1783
  if (active !== pending || pending.controller.signal.aborted) return;
1964
- if (!ready) cancel2();
1784
+ if (!ready) cancel();
1965
1785
  options.send({ protocol: 1, type: "lifecycle-result", id: pending.id, ready });
1966
1786
  };
1967
1787
  return {
1968
1788
  api,
1969
1789
  receive(frame) {
1970
1790
  if (frame.type === "lifecycle-cancel") {
1971
- if (active?.id === frame.id) cancel2();
1791
+ if (active?.id === frame.id) cancel();
1972
1792
  return;
1973
1793
  }
1974
1794
  if (active) {
@@ -1986,7 +1806,7 @@ function createAppLifecycle(options) {
1986
1806
  }))).then(() => finish(pending, true), () => finish(pending, false));
1987
1807
  },
1988
1808
  close() {
1989
- cancel2();
1809
+ cancel();
1990
1810
  handlers.clear();
1991
1811
  }
1992
1812
  };
@@ -2113,7 +1933,14 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2113
1933
  const touch = (s) => {
2114
1934
  if (s.stopped || closed) return;
2115
1935
  clearTimeout(s.idleTimer);
2116
- s.idleTimer = setTimeout(() => finish(s, timeout("idle_timeout"), true), FETCH_IDLE_TIMEOUT_MS);
1936
+ const deadline = s.uploadDone && !s.headers ? Math.max(FETCH_IDLE_TIMEOUT_MS, s.headersTimeoutMs + 1e3) : FETCH_IDLE_TIMEOUT_MS;
1937
+ s.idleTimer = setTimeout(() => finish(s, timeout("idle_timeout"), true), deadline);
1938
+ };
1939
+ const waitForHeaders = (s) => {
1940
+ if (!s.headers) {
1941
+ s.headTimer = setTimeout(() => finish(s, timeout("headers_timeout"), true), s.headersTimeoutMs);
1942
+ touch(s);
1943
+ }
2117
1944
  };
2118
1945
  const shutdown = () => {
2119
1946
  if (closed) return;
@@ -2136,6 +1963,8 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2136
1963
  s.uploadDone = true;
2137
1964
  s.reader = void 0;
2138
1965
  reader.releaseLock();
1966
+ touch(s);
1967
+ waitForHeaders(s);
2139
1968
  send({ protocol: 2, type: "fetch-end", id: s.id, direction: "upload", sequence: s.uploadSequence });
2140
1969
  complete(s);
2141
1970
  return;
@@ -2191,6 +2020,7 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2191
2020
  if (s.headers || message.hasBody && (s.request.method === "HEAD" || [204, 205, 304].includes(message.status))) throw error("invalid_request");
2192
2021
  s.headers = true;
2193
2022
  clearTimeout(s.headTimer);
2023
+ touch(s);
2194
2024
  const body = message.hasBody ? new ReadableStream({
2195
2025
  start(controller) {
2196
2026
  s.controller = controller;
@@ -2271,9 +2101,10 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2271
2101
  const request = new Request(input, init);
2272
2102
  const id3 = String(nextId + 1);
2273
2103
  let frame;
2104
+ let path;
2274
2105
  try {
2275
2106
  pageFetchPath(baseUrl, inputUrl);
2276
- pageFetchPath(baseUrl, request.url);
2107
+ path = pageFetchPath(baseUrl, request.url);
2277
2108
  if (request.signal.aborted) throw new DOMException("The operation was aborted", "AbortError");
2278
2109
  if (streams.size >= FETCH_MAX_STREAMS) throw error("invalid_request");
2279
2110
  frame = { protocol: 2, type: "fetch-open", id: id3, connectionId, url: request.url, method: request.method, headers: [...request.headers], hasBody: !!request.body };
@@ -2299,6 +2130,7 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2299
2130
  reject,
2300
2131
  headers: false,
2301
2132
  stopped: false,
2133
+ headersTimeoutMs: pageFetchHeadersTimeout(request.method, path),
2302
2134
  uploadDone: !request.body || frame.inlineBody !== void 0,
2303
2135
  downloadEnded: false,
2304
2136
  downloadDone: false,
@@ -2309,10 +2141,10 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2309
2141
  outstanding: 0,
2310
2142
  grantSequence: 0,
2311
2143
  downloadSequence: 0,
2312
- headTimer: setTimeout(() => finish(s, timeout("headers_timeout"), true), FETCH_HEADERS_TIMEOUT_MS),
2313
2144
  idleTimer: setTimeout(() => finish(s, timeout("idle_timeout"), true), FETCH_IDLE_TIMEOUT_MS),
2314
2145
  offAbort: () => request.signal.removeEventListener("abort", abort)
2315
2146
  };
2147
+ if (s.uploadDone) waitForHeaders(s);
2316
2148
  streams.set(id3, s);
2317
2149
  request.signal.addEventListener("abort", abort, { once: true });
2318
2150
  try {
@@ -2342,7 +2174,6 @@ function createDocumentPageFetchClient(options, getDocumentCloseError) {
2342
2174
  }
2343
2175
 
2344
2176
  // src/connection.ts
2345
- var SKILL_MARKETPLACE_TIMEOUT_MS = 3e5;
2346
2177
  var failure = (code) => new AppHostError(code);
2347
2178
  function invalidHostResponse(reason, frameKind, stage, operation) {
2348
2179
  const details = { reason, frameKind, stage, ...operation };
@@ -2865,11 +2696,11 @@ var DocumentConnection = class {
2865
2696
  get: (key) => this.request("storage.get", { key }),
2866
2697
  set: (key, value) => this.request("storage.set", { key, value }),
2867
2698
  delete: (key) => this.request("storage.delete", { key }),
2868
- putFile: async (name2, data) => {
2869
- if (!(data instanceof Blob) || !nonempty(name2) || data.size + new TextEncoder().encode(JSON.stringify({ name: name2 })).byteLength > APP_HOST_MAX_PAYLOAD_BYTES)
2699
+ putFile: async (name, data) => {
2700
+ if (!(data instanceof Blob) || !nonempty(name) || data.size + new TextEncoder().encode(JSON.stringify({ name })).byteLength > APP_HOST_MAX_PAYLOAD_BYTES)
2870
2701
  throw failure("invalid_request");
2871
2702
  return this.request("storage.putFile", {
2872
- name: name2,
2703
+ name,
2873
2704
  bytes: new Uint8Array(await data.arrayBuffer())
2874
2705
  });
2875
2706
  },
@@ -2925,14 +2756,8 @@ var DocumentConnection = class {
2925
2756
  const selectionRequestId = method === "workspace.select" ? params.requestId : void 0;
2926
2757
  let timeout = APP_HOST_REQUEST_TIMEOUT_MS;
2927
2758
  if (method === "workbench.computer.stopLocal") timeout = 1e3;
2928
- if (method === "auth.openLogin" || method === "workspace.select" || method === "workbench.computer.shareWindow" || method === "system.workspace" && "action" in params && params.action === "pick")
2759
+ if (method === "auth.openLogin" || method === "workspace.select" || method === "system.pickFile" || method === "workbench.computer.shareWindow" || method === "system.workspace" && "action" in params && params.action === "pick")
2929
2760
  timeout = APP_HOST_LOGIN_TRANSPORT_TIMEOUT_MS;
2930
- if (method === "system.extensions") {
2931
- const { operation } = params;
2932
- if (operation === "skills.marketplaceCatalog" || operation === "skills.marketplaceInstall") {
2933
- timeout = SKILL_MARKETPLACE_TIMEOUT_MS;
2934
- }
2935
- }
2936
2761
  return new Promise((resolve, reject) => {
2937
2762
  const id3 = String(++this.nextId);
2938
2763
  const timer = setTimeout(() => {
@@ -3100,7 +2925,7 @@ function parsePluginAppConversationInput(value) {
3100
2925
  source: parsePluginAppSource(input.source),
3101
2926
  lease: { token: identifier2(lease.token), backendGeneration: identifier2(lease.backendGeneration) },
3102
2927
  requestId: identifier2(input.requestId),
3103
- expectedRevision: revision2(input.expectedRevision),
2928
+ expectedRevision: revision(input.expectedRevision),
3104
2929
  text: input.text,
3105
2930
  data: copyPluginAppJson(input.data, PLUGIN_APP_INPUT_LIMITS.handoffBytes)
3106
2931
  };
@@ -3110,13 +2935,13 @@ function record3(value) {
3110
2935
  return value;
3111
2936
  }
3112
2937
  function fields3(value, names) {
3113
- if (Object.keys(value).length !== names.length || names.some((name2) => !Object.hasOwn(value, name2))) throw new InputError("plugin_app_invalid_request");
2938
+ if (Object.keys(value).length !== names.length || names.some((name) => !Object.hasOwn(value, name))) throw new InputError("plugin_app_invalid_request");
3114
2939
  }
3115
2940
  function identifier2(value) {
3116
2941
  if (typeof value !== "string" || !value.trim() || value.length > 1024) throw new InputError("plugin_app_invalid_request");
3117
2942
  return value;
3118
2943
  }
3119
- function revision2(value) {
2944
+ function revision(value) {
3120
2945
  if (!Number.isSafeInteger(value) || value < 0) throw new InputError("plugin_app_invalid_request");
3121
2946
  return value;
3122
2947
  }
@@ -3160,7 +2985,6 @@ function parsePluginAppComposerContexts2(value) {
3160
2985
  }
3161
2986
  export {
3162
2987
  AppHostError,
3163
- EXTENSION_INPUTS,
3164
2988
  WINDOW_METHODS,
3165
2989
  canonicalDesktopRequest,
3166
2990
  connectAppHost,
@@ -3170,8 +2994,6 @@ export {
3170
2994
  parsePluginAppComposerContexts2 as parsePluginAppComposerContexts,
3171
2995
  validAppCommandSnapshot,
3172
2996
  validAppWindowState,
3173
- validExtensionRequest,
3174
- validExtensionResult,
3175
2997
  validWindowEvent,
3176
2998
  validWindowInput,
3177
2999
  validWindowResult