@bobannomi/app-host 0.7.0 → 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.d.ts +15 -220
- package/dist/index.js +61 -245
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +18 -221
- package/dist/protocol.js +58 -228
- package/dist/protocol.js.map +3 -3
- package/package.json +2 -2
package/dist/protocol.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,
|
|
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) => {
|
|
@@ -361,6 +354,11 @@ function pageFetchPath(baseUrl, input) {
|
|
|
361
354
|
|
|
362
355
|
// ../domain-contracts/src/app-host/agent-api-policy.ts
|
|
363
356
|
var routes = [
|
|
357
|
+
{ method: "POST", pattern: /^\/providers\/(manage|defaults)$/, id: "providers.manage", builtinWorkbench: true },
|
|
358
|
+
{ method: "GET", pattern: /^\/channels\/(runtime\/status|feishu(?:\/registration)?)$/, id: "channels.manage", builtinWorkbench: true },
|
|
359
|
+
{ method: "POST", pattern: /^\/channels\/(runtime\/(start|stop)|feishu\/(connect|allow|registration))$/, id: "channels.manage", builtinWorkbench: true },
|
|
360
|
+
{ method: "PATCH", pattern: /^\/channels\/feishu$/, id: "channels.manage", builtinWorkbench: true },
|
|
361
|
+
{ method: "DELETE", pattern: /^\/channels\/feishu(?:\/(allow|registration))?$/, id: "channels.manage", builtinWorkbench: true },
|
|
364
362
|
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+(?:\/run|\/runs\/[^/]+)?)?|runs)$/, id: "schedules.read" },
|
|
365
363
|
{ method: "POST", pattern: /^\/schedules\/tasks(?:\/[^/]+\/run)?$/, id: "schedules.create" },
|
|
366
364
|
{ method: "PATCH", pattern: /^\/schedules\/(tasks\/[^/]+|runs\/[^/]+\/read)$/, id: "schedules.update" },
|
|
@@ -368,6 +366,20 @@ var routes = [
|
|
|
368
366
|
{ method: "GET", pattern: /^\/(health|capabilities)$/, id: "protocol.read" },
|
|
369
367
|
{ method: "GET", pattern: /^\/(models|agent-personas|skills)$/, id: "resources.read" },
|
|
370
368
|
{ method: "POST", pattern: /^\/skills\/install$/, id: "skills.install" },
|
|
369
|
+
{ method: "GET", pattern: /^\/skills\/marketplace$/, id: "skills.marketplace" },
|
|
370
|
+
{ method: "POST", pattern: /^\/skills\/marketplace\/install$/, id: "skills.marketplace" },
|
|
371
|
+
{ method: "DELETE", pattern: /^\/skills\/[^/]+$/, id: "skills.remove" },
|
|
372
|
+
{ method: "GET", pattern: /^\/plugins(?:\/icon|\/marketplace\/(?:catalog|sources|operations\/[^/]+))?$/, id: "plugins.manage" },
|
|
373
|
+
{ method: "POST", pattern: /^\/plugins\/(?:reload|(?:archive|git)\/(?:preview|install)|[^/]+\/(?:enable|disable)|marketplace\/(?:sources|preview|install|cancel))$/, id: "plugins.manage" },
|
|
374
|
+
{ method: "PATCH", pattern: /^\/plugins\/marketplace\/sources\/[^/]+$/, id: "plugins.manage" },
|
|
375
|
+
{ method: "DELETE", pattern: /^\/plugins\/(?:[^/]+|marketplace\/sources\/[^/]+)$/, id: "plugins.manage" },
|
|
376
|
+
{ method: "GET", pattern: /^\/mcp\/config\/servers(?:\/config\/(?:entry|export|inventory))?$/, id: "mcp.config" },
|
|
377
|
+
{ method: "POST", pattern: /^\/mcp\/config\/servers$/, id: "mcp.config" },
|
|
378
|
+
{ method: "PUT", pattern: /^\/mcp\/config\/servers\/config\/entry(?:\/enabled)?$/, id: "mcp.config" },
|
|
379
|
+
{ method: "DELETE", pattern: /^\/mcp\/config\/servers\/config\/entry$/, id: "mcp.config" },
|
|
380
|
+
{ method: "POST", pattern: /^\/mcp\/oauth\/(?:login|logout)$/, id: "mcp.oauth" },
|
|
381
|
+
{ method: "GET", pattern: /^\/mcp\/oauth\/operations\/[^/]+(?:\/events)?$/, id: "mcp.oauth" },
|
|
382
|
+
{ method: "DELETE", pattern: /^\/mcp\/oauth\/operations\/[^/]+$/, id: "mcp.oauth" },
|
|
371
383
|
{ method: "POST", pattern: /^\/model-connections$/, id: "models.prepare" },
|
|
372
384
|
{ method: "GET", pattern: /^\/sessions\/[^/]+\/goal(?:\/requests\/[^/]+)?$/, id: "goals.read" },
|
|
373
385
|
{ method: "POST", pattern: /^\/sessions\/[^/]+\/goals$/, id: "goals.write" },
|
|
@@ -662,7 +674,7 @@ function createAppCommandsApi(rpc) {
|
|
|
662
674
|
rpc.requireFeature();
|
|
663
675
|
snapshot = structuredClone(snapshot);
|
|
664
676
|
const registrationId = crypto.randomUUID();
|
|
665
|
-
let
|
|
677
|
+
let revision = 0;
|
|
666
678
|
let disposed = false;
|
|
667
679
|
let remoteValid = true;
|
|
668
680
|
let disposal;
|
|
@@ -670,11 +682,11 @@ function createAppCommandsApi(rpc) {
|
|
|
670
682
|
let conflicts = [];
|
|
671
683
|
let queue = Promise.resolve();
|
|
672
684
|
const off = rpc.onInvoke((event) => {
|
|
673
|
-
if (!disposed && event.registrationId === registrationId && event.revision ===
|
|
685
|
+
if (!disposed && event.registrationId === registrationId && event.revision === revision && current.commands.some(
|
|
674
686
|
(c) => c.id === event.commandId && c.enabled !== false
|
|
675
687
|
)) {
|
|
676
688
|
void Promise.resolve().then(() => {
|
|
677
|
-
if (!disposed && event.revision ===
|
|
689
|
+
if (!disposed && event.revision === revision)
|
|
678
690
|
return invoke(event.commandId);
|
|
679
691
|
}).catch(() => {
|
|
680
692
|
});
|
|
@@ -694,14 +706,14 @@ function createAppCommandsApi(rpc) {
|
|
|
694
706
|
const call = async (method, next) => {
|
|
695
707
|
const params = {
|
|
696
708
|
registrationId,
|
|
697
|
-
revision
|
|
709
|
+
revision,
|
|
698
710
|
...next === void 0 ? {} : { snapshot: next }
|
|
699
711
|
};
|
|
700
712
|
const result = await rpc.request(
|
|
701
713
|
method,
|
|
702
714
|
params
|
|
703
715
|
);
|
|
704
|
-
if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !==
|
|
716
|
+
if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !== revision)
|
|
705
717
|
throw new AppHostError("host_unavailable");
|
|
706
718
|
conflicts = [...result.shortcutConflicts ?? []];
|
|
707
719
|
};
|
|
@@ -711,7 +723,7 @@ function createAppCommandsApi(rpc) {
|
|
|
711
723
|
try {
|
|
712
724
|
await rpc.request("commands.dispose", {
|
|
713
725
|
registrationId,
|
|
714
|
-
revision: ++
|
|
726
|
+
revision: ++revision
|
|
715
727
|
});
|
|
716
728
|
} catch {
|
|
717
729
|
}
|
|
@@ -735,7 +747,7 @@ function createAppCommandsApi(rpc) {
|
|
|
735
747
|
const task = queue.then(async () => {
|
|
736
748
|
if (disposed) throw new AppHostError("connection_revoked");
|
|
737
749
|
rpc.requireFeature();
|
|
738
|
-
|
|
750
|
+
revision++;
|
|
739
751
|
current = next;
|
|
740
752
|
try {
|
|
741
753
|
await call("commands.update", next);
|
|
@@ -753,7 +765,7 @@ function createAppCommandsApi(rpc) {
|
|
|
753
765
|
stop();
|
|
754
766
|
disposal = queue.then(async () => {
|
|
755
767
|
if (!remoteValid) return;
|
|
756
|
-
|
|
768
|
+
revision++;
|
|
757
769
|
try {
|
|
758
770
|
await call("commands.dispose");
|
|
759
771
|
} finally {
|
|
@@ -933,9 +945,9 @@ function validConversationPreparationResult(method, result) {
|
|
|
933
945
|
// src/client-connections.ts
|
|
934
946
|
var connections = /* @__PURE__ */ new WeakMap();
|
|
935
947
|
function createClientConnection(wire, streams) {
|
|
936
|
-
const { connectionId, baseUrl, cwd
|
|
948
|
+
const { connectionId, baseUrl, cwd, defaultTaskLocation } = wire;
|
|
937
949
|
const connection = {
|
|
938
|
-
...
|
|
950
|
+
...cwd === void 0 ? {} : { cwd },
|
|
939
951
|
...defaultTaskLocation === void 0 ? {} : { defaultTaskLocation },
|
|
940
952
|
clientOptions: { baseUrl, fetch: streams.fetchFor(connectionId, baseUrl) },
|
|
941
953
|
isClosed: () => streams.isClosed?.(connectionId) === true
|
|
@@ -1110,7 +1122,7 @@ function createAppDesktopApi(rpc, owner, filesFeature = () => {
|
|
|
1110
1122
|
if (!validDesktopResultForInput(method, params, value)) throw new AppHostError("host_unavailable");
|
|
1111
1123
|
return value;
|
|
1112
1124
|
};
|
|
1113
|
-
const group = (
|
|
1125
|
+
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)]));
|
|
1114
1126
|
const getOperation = async (input, validate) => {
|
|
1115
1127
|
if (!validate(input)) throw new AppHostError("invalid_request");
|
|
1116
1128
|
return call("desktop.files.getOperation", input);
|
|
@@ -1233,67 +1245,6 @@ function createAppAuxiliarySessionsApi(rpc, streams) {
|
|
|
1233
1245
|
};
|
|
1234
1246
|
}
|
|
1235
1247
|
|
|
1236
|
-
// src/extensions.ts
|
|
1237
|
-
var empty = object({});
|
|
1238
|
-
var cwd = object({ cwd: text(4096) });
|
|
1239
|
-
var plugin = object({ cwd: text(4096), pluginId: text(256) });
|
|
1240
|
-
var selection2 = object({ cwd: text(4096), selectionId: text(256) });
|
|
1241
|
-
var cancel = object({ selectionId: text(256) });
|
|
1242
|
-
var name = object({ name: text(256) });
|
|
1243
|
-
var login = object({ loginId: text(256) });
|
|
1244
|
-
var skillSelection = { id: text(64), version: text(32), sha256: digest };
|
|
1245
|
-
var skillInstallOptions = { allowWhileRunning: bool };
|
|
1246
|
-
var personalSkillInstall = object({ ...skillSelection, scope: enumeration("personal") }, skillInstallOptions);
|
|
1247
|
-
var projectSkillInstall = object({
|
|
1248
|
-
...skillSelection,
|
|
1249
|
-
scope: enumeration("project"),
|
|
1250
|
-
projectPath: (value) => typeof value === "string" && value.trim().length > 0 && text(4096)(value)
|
|
1251
|
-
}, skillInstallOptions);
|
|
1252
|
-
var EXTENSION_INPUTS = {
|
|
1253
|
-
context: empty,
|
|
1254
|
-
"plugins.loadIcon": object({ src: text(8192) }),
|
|
1255
|
-
"plugins.snapshot": cwd,
|
|
1256
|
-
"plugins.enable": plugin,
|
|
1257
|
-
"plugins.disable": plugin,
|
|
1258
|
-
"plugins.uninstall": plugin,
|
|
1259
|
-
"plugins.reload": cwd,
|
|
1260
|
-
"plugins.importArchive": cwd,
|
|
1261
|
-
"plugins.confirmArchive": selection2,
|
|
1262
|
-
"plugins.cancelArchive": cancel,
|
|
1263
|
-
"plugins.importGit": object({ cwd: text(4096), url: text(8192) }, { ref: text(1024) }),
|
|
1264
|
-
"plugins.confirmGit": selection2,
|
|
1265
|
-
"plugins.cancelGit": cancel,
|
|
1266
|
-
"plugins.marketplaceCatalog": object({ cwd: text(4096) }, { refresh: bool }),
|
|
1267
|
-
"plugins.marketplaceAddSource": object({ url: text(8192) }),
|
|
1268
|
-
"plugins.marketplaceSetSourceEnabled": object({ sourceId: text(256), enabled: bool }),
|
|
1269
|
-
"plugins.marketplaceRemoveSource": object({ sourceId: text(256) }),
|
|
1270
|
-
"plugins.marketplacePreview": object({ cwd: text(4096), sourceId: text(256), pluginId: text(256) }, { version: text(256) }),
|
|
1271
|
-
"plugins.marketplaceConfirm": selection2,
|
|
1272
|
-
"plugins.marketplaceCancel": cancel,
|
|
1273
|
-
"plugins.marketplaceOperation": object({ cwd: text(4096), operationId: text(256) }),
|
|
1274
|
-
"skills.snapshot": object({ projectPath: text(4096) }),
|
|
1275
|
-
"skills.remove": object({ id: text(4096), expectedContent: text(8 * 1024 * 1024, true), projectPath: text(4096) }),
|
|
1276
|
-
"skills.marketplaceCatalog": empty,
|
|
1277
|
-
"skills.marketplaceInstall": (value) => personalSkillInstall(value) || projectSkillInstall(value),
|
|
1278
|
-
"mcp.snapshot": empty,
|
|
1279
|
-
"mcp.exportConfig": empty,
|
|
1280
|
-
"mcp.getConfig": name,
|
|
1281
|
-
"mcp.add": object({ name: text(256), config: jsonObject }),
|
|
1282
|
-
"mcp.update": object({ name: text(256), config: jsonObject, expectedConfig: jsonObject }),
|
|
1283
|
-
"mcp.remove": name,
|
|
1284
|
-
"mcp.setEnabled": object({ name: text(256), enabled: bool }),
|
|
1285
|
-
"mcp.login": object({ name: text(256), scopes: array(text(2048), 128) }),
|
|
1286
|
-
"mcp.loginStatus": login,
|
|
1287
|
-
"mcp.cancelLogin": login,
|
|
1288
|
-
"mcp.logout": name
|
|
1289
|
-
};
|
|
1290
|
-
function validExtensionRequest(value) {
|
|
1291
|
-
if (!object({ operation: text(128), input: jsonObject })(value)) return false;
|
|
1292
|
-
const request = value;
|
|
1293
|
-
return Object.hasOwn(EXTENSION_INPUTS, request.operation) && EXTENSION_INPUTS[request.operation](request.input);
|
|
1294
|
-
}
|
|
1295
|
-
var validExtensionResult = (value) => value === void 0 || json(value);
|
|
1296
|
-
|
|
1297
1248
|
// src/projects.ts
|
|
1298
1249
|
var id2 = text(256);
|
|
1299
1250
|
var scope = { dataScopeId: id2 };
|
|
@@ -1381,7 +1332,7 @@ var found = object({ files: array(text(32768), 1e3), truncated: bool });
|
|
|
1381
1332
|
var picked = object({ ...root2, ...identity, workspaceId: id });
|
|
1382
1333
|
var url = object({ url: text(131072) });
|
|
1383
1334
|
var openers = (value) => validDesktopResult("desktop.files.listOpeners", value);
|
|
1384
|
-
var
|
|
1335
|
+
var empty = (value) => value === void 0;
|
|
1385
1336
|
var checks = {
|
|
1386
1337
|
pick: nullable(picked),
|
|
1387
1338
|
list: tree,
|
|
@@ -1389,9 +1340,9 @@ var checks = {
|
|
|
1389
1340
|
read: preview,
|
|
1390
1341
|
write: preview,
|
|
1391
1342
|
getWrite: nullable(preview),
|
|
1392
|
-
reveal:
|
|
1393
|
-
openWith:
|
|
1394
|
-
copyPath:
|
|
1343
|
+
reveal: empty,
|
|
1344
|
+
openWith: empty,
|
|
1345
|
+
copyPath: empty,
|
|
1395
1346
|
listOpeners: openers,
|
|
1396
1347
|
webPreview: url
|
|
1397
1348
|
};
|
|
@@ -1399,77 +1350,6 @@ function validLocalWorkspaceResult(value, action2) {
|
|
|
1399
1350
|
return action2 ? checks[action2](value) : Object.values(checks).some((check) => check(value));
|
|
1400
1351
|
}
|
|
1401
1352
|
|
|
1402
|
-
// ../domain-contracts/src/app-host/model-providers.ts
|
|
1403
|
-
var provider = text(256);
|
|
1404
|
-
var imageInputSupport = enumeration("native", "unsupported", "unknown");
|
|
1405
|
-
var limits = { contextWindow: count, maxOutputTokens: count };
|
|
1406
|
-
function headerValues(check) {
|
|
1407
|
-
return (value) => {
|
|
1408
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1409
|
-
const keys2 = Object.keys(value);
|
|
1410
|
-
return keys2.length <= 128 && keys2.every((key) => /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,256}$/.test(key)) && object(Object.fromEntries(keys2.map((key) => [key, check])))(value);
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
var headers = headerValues(text(8192, true));
|
|
1414
|
-
var secretHeaders = headerValues(nullable(text(8192)));
|
|
1415
|
-
var customProvider = object({
|
|
1416
|
-
id: provider,
|
|
1417
|
-
displayName: text(1024),
|
|
1418
|
-
baseUrl: text(4096),
|
|
1419
|
-
apiFormat: enumeration("openai"),
|
|
1420
|
-
models: array(object({ id: text(1024), displayName: text(1024) }, { imageInputSupport, ...limits }), 16384)
|
|
1421
|
-
}, { apiKey: text(8192), headers, secretHeaders });
|
|
1422
|
-
function validModelProviderRequest(value) {
|
|
1423
|
-
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);
|
|
1424
|
-
}
|
|
1425
|
-
var validModel = object({ id: text(1024), label: text(1024) }, { imageInputSupport, declaredLimits: object({}, limits) });
|
|
1426
|
-
var validConnection2 = object({
|
|
1427
|
-
name: provider,
|
|
1428
|
-
displayName: text(1024),
|
|
1429
|
-
connected: bool,
|
|
1430
|
-
active: bool,
|
|
1431
|
-
credentialSource: enumeration("credentials", "environment", "subscription", "local", "configured", "none"),
|
|
1432
|
-
models: array(validModel, 16384)
|
|
1433
|
-
}, { source: enumeration("builtin", "catalog", "custom", "subscription"), custom: bool, credentialLabel: text(1024), baseUrl: text(4096), headers, secretHeaderNames: array(text(256), 128) });
|
|
1434
|
-
function validModelProviderConnections(value) {
|
|
1435
|
-
return array(validConnection2, 4096)(value);
|
|
1436
|
-
}
|
|
1437
|
-
var modelId = text(1024);
|
|
1438
|
-
var effort = nullable(text(256));
|
|
1439
|
-
var revision = text(8192);
|
|
1440
|
-
var accountGatewayProof = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
1441
|
-
function validProviderDefaultsRequest(value) {
|
|
1442
|
-
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);
|
|
1443
|
-
}
|
|
1444
|
-
var verifiedProvider = object({ model: modelId, checkedAt: count });
|
|
1445
|
-
var verified = (value) => {
|
|
1446
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1447
|
-
const keys2 = Object.keys(value);
|
|
1448
|
-
return keys2.length <= 4096 && keys2.every(provider) && object(Object.fromEntries(keys2.map((key) => [key, verifiedProvider])))(value);
|
|
1449
|
-
};
|
|
1450
|
-
var defaultsModel = object({ id: modelId, label: text(1024), provider: text(1024), providerName: provider }, {
|
|
1451
|
-
reasoningEfforts: array(text(256, true)),
|
|
1452
|
-
contextWindow: count,
|
|
1453
|
-
inputModalities: array(text(256)),
|
|
1454
|
-
inputCapabilities: object({ image: imageInputSupport })
|
|
1455
|
-
});
|
|
1456
|
-
var validProviderDefaultsSnapshot = object({
|
|
1457
|
-
models: array(defaultsModel, 16384),
|
|
1458
|
-
provider: nullable(provider),
|
|
1459
|
-
model: nullable(modelId),
|
|
1460
|
-
effort,
|
|
1461
|
-
disabled: bool,
|
|
1462
|
-
revision,
|
|
1463
|
-
verified,
|
|
1464
|
-
fastModeAvailable: enumeration(false),
|
|
1465
|
-
fastModeReason: text(1024)
|
|
1466
|
-
}, { accountGatewayMatches: bool });
|
|
1467
|
-
var validProviderConnectionTestResult = object({
|
|
1468
|
-
status: enumeration("verified", "failed"),
|
|
1469
|
-
detail: text(8192),
|
|
1470
|
-
checkedAt: count
|
|
1471
|
-
}, { category: enumeration("authentication", "address", "network", "model", "unsupported", "service") });
|
|
1472
|
-
|
|
1473
1353
|
// src/system.ts
|
|
1474
1354
|
var SYSTEM_SETTINGS_SECTIONS = [
|
|
1475
1355
|
"general",
|
|
@@ -1507,34 +1387,10 @@ var SYSTEM_SHORTCUT_IDS = [
|
|
|
1507
1387
|
"resetZoom",
|
|
1508
1388
|
"showShortcuts"
|
|
1509
1389
|
];
|
|
1510
|
-
var CHANNEL_SETTINGS_ACTIONS = [
|
|
1511
|
-
"snapshot",
|
|
1512
|
-
"runtimeStatus",
|
|
1513
|
-
"connect",
|
|
1514
|
-
"patch",
|
|
1515
|
-
"remove",
|
|
1516
|
-
"allowAdd",
|
|
1517
|
-
"allowRemove",
|
|
1518
|
-
"startRegistration",
|
|
1519
|
-
"registrationStatus",
|
|
1520
|
-
"cancelRegistration",
|
|
1521
|
-
"startRuntime",
|
|
1522
|
-
"stopRuntime"
|
|
1523
|
-
];
|
|
1524
|
-
var channelSettingsKey = /* @__PURE__ */ Symbol.for("nomi.workbench-channel-settings");
|
|
1525
|
-
var channelSettingsValue = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1526
|
-
function workbenchChannelSettings(system) {
|
|
1527
|
-
const request = system[channelSettingsKey];
|
|
1528
|
-
if (!request) throw new AppHostError("incompatible");
|
|
1529
|
-
return request;
|
|
1530
|
-
}
|
|
1531
1390
|
var SYSTEM_METHODS = [
|
|
1532
1391
|
"system.projects",
|
|
1533
1392
|
"system.workspace",
|
|
1534
|
-
"system.
|
|
1535
|
-
"system.modelProviders",
|
|
1536
|
-
"system.channelSettings",
|
|
1537
|
-
"system.providerDefaults",
|
|
1393
|
+
"system.pickFile",
|
|
1538
1394
|
"system.open",
|
|
1539
1395
|
"system.getPresentationPreferences",
|
|
1540
1396
|
"system.setTheme",
|
|
@@ -1609,7 +1465,11 @@ var validDesktopNavigationTarget = (v) => object(
|
|
|
1609
1465
|
scheduledRunId: text(256)
|
|
1610
1466
|
},
|
|
1611
1467
|
{ sessionId: text(256) }
|
|
1612
|
-
)(v)
|
|
1468
|
+
)(v) || object({
|
|
1469
|
+
id: text(256),
|
|
1470
|
+
dataScopeId: text(256),
|
|
1471
|
+
kind: enumeration("extensions")
|
|
1472
|
+
})(v);
|
|
1613
1473
|
function isSystemMethod(v) {
|
|
1614
1474
|
return SYSTEM_METHODS.includes(v);
|
|
1615
1475
|
}
|
|
@@ -1631,21 +1491,13 @@ function validSystemInput(method, value) {
|
|
|
1631
1491
|
return validProjectRequest(value);
|
|
1632
1492
|
case "system.workspace":
|
|
1633
1493
|
return validLocalWorkspaceRequest(value);
|
|
1634
|
-
case "system.
|
|
1635
|
-
return
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
if (object({
|
|
1642
|
-
action: enumeration("connect", "patch", "allowAdd", "startRegistration"),
|
|
1643
|
-
input: channelSettingsValue
|
|
1644
|
-
})(value)) return true;
|
|
1645
|
-
return object({ action: (entry) => action2(entry) && !["allowRemove", "connect", "patch", "allowAdd", "startRegistration"].includes(entry) })(value);
|
|
1646
|
-
}
|
|
1647
|
-
case "system.providerDefaults":
|
|
1648
|
-
return validProviderDefaultsRequest(value);
|
|
1494
|
+
case "system.pickFile":
|
|
1495
|
+
return object({}, {
|
|
1496
|
+
filters: array(object({
|
|
1497
|
+
name: text(100),
|
|
1498
|
+
extensions: array((extension) => typeof extension === "string" && /^[a-z0-9][a-z0-9.-]{0,15}$/i.test(extension), 16)
|
|
1499
|
+
}), 16)
|
|
1500
|
+
})(value);
|
|
1649
1501
|
case "system.setTheme":
|
|
1650
1502
|
return object({ theme: themeMode })(value);
|
|
1651
1503
|
case "system.setWindowMaterial":
|
|
@@ -1659,9 +1511,6 @@ function validSystemInput(method, value) {
|
|
|
1659
1511
|
{ page: enumeration("scheduled") },
|
|
1660
1512
|
{ taskId: text(256), scheduledRunId: text(256) }
|
|
1661
1513
|
)(value) && (!Object.hasOwn(value, "scheduledRunId") || Object.hasOwn(value, "taskId")) || object(
|
|
1662
|
-
{ page: enumeration("extensions") },
|
|
1663
|
-
{ tab: enumeration("plugins", "skills", "mcp") }
|
|
1664
|
-
)(value) || object(
|
|
1665
1514
|
{ page: enumeration("settings") },
|
|
1666
1515
|
{ section: enumeration(...SYSTEM_SETTINGS_SECTIONS) }
|
|
1667
1516
|
)(value) || object({ page: enumeration("pet") })(value) || object(
|
|
@@ -1691,14 +1540,8 @@ function validSystemResult(method, value) {
|
|
|
1691
1540
|
return validProjectSnapshot(value);
|
|
1692
1541
|
case "system.workspace":
|
|
1693
1542
|
return validLocalWorkspaceResult(value);
|
|
1694
|
-
case "system.
|
|
1695
|
-
return
|
|
1696
|
-
case "system.modelProviders":
|
|
1697
|
-
return validModelProviderConnections(value);
|
|
1698
|
-
case "system.channelSettings":
|
|
1699
|
-
return object({ value: channelSettingsValue })(value) || object({ error: enumeration("invalid_configuration", "conflict") })(value);
|
|
1700
|
-
case "system.providerDefaults":
|
|
1701
|
-
return validProviderDefaultsSnapshot(value) || validProviderConnectionTestResult(value);
|
|
1543
|
+
case "system.pickFile":
|
|
1544
|
+
return nullable(text(4096))(value);
|
|
1702
1545
|
case "system.open":
|
|
1703
1546
|
return object({ opened: enumeration(true) })(value);
|
|
1704
1547
|
case "system.getPresentationPreferences":
|
|
@@ -1738,14 +1581,7 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1738
1581
|
if (!validLocalWorkspaceResult(result, input.action)) throw new AppHostError("host_unavailable");
|
|
1739
1582
|
return result;
|
|
1740
1583
|
}),
|
|
1741
|
-
|
|
1742
|
-
modelProviders: (input) => send("system.modelProviders", input),
|
|
1743
|
-
providerDefaults: (async (input) => {
|
|
1744
|
-
const result = await send("system.providerDefaults", input);
|
|
1745
|
-
if (!(input.action === "test" ? validProviderConnectionTestResult(result) : validProviderDefaultsSnapshot(result)))
|
|
1746
|
-
throw new AppHostError("invalid_request");
|
|
1747
|
-
return result;
|
|
1748
|
-
}),
|
|
1584
|
+
pickFile: (input = {}) => send("system.pickFile", input),
|
|
1749
1585
|
open: (input) => {
|
|
1750
1586
|
if (input.page !== "session-settings") return send("system.open", input);
|
|
1751
1587
|
const { target: target2 } = input;
|
|
@@ -1769,9 +1605,6 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1769
1605
|
navigationReady: () => send("system.navigationReady", {}),
|
|
1770
1606
|
completeNavigation: (input) => send("system.completeNavigation", input)
|
|
1771
1607
|
};
|
|
1772
|
-
Object.defineProperty(system, channelSettingsKey, {
|
|
1773
|
-
value: (input) => send("system.channelSettings", input)
|
|
1774
|
-
});
|
|
1775
1608
|
return system;
|
|
1776
1609
|
}
|
|
1777
1610
|
|
|
@@ -1816,7 +1649,7 @@ function text2(value, limit = 256) {
|
|
|
1816
1649
|
return typeof value === "string" && value.length > 0 && value.length <= limit;
|
|
1817
1650
|
}
|
|
1818
1651
|
function keys(value, ...names) {
|
|
1819
|
-
return Object.keys(value).length === names.length && names.every((
|
|
1652
|
+
return Object.keys(value).length === names.length && names.every((name) => Object.hasOwn(value, name));
|
|
1820
1653
|
}
|
|
1821
1654
|
function isWorkbenchComputerMethod(method) {
|
|
1822
1655
|
return WORKBENCH_COMPUTER_METHODS.includes(method);
|
|
@@ -1949,7 +1782,6 @@ export {
|
|
|
1949
1782
|
BROWSER_CAPTURE_PREVIEW_MAX_BYTES,
|
|
1950
1783
|
COMMANDS_METHODS,
|
|
1951
1784
|
DESKTOP_METHODS,
|
|
1952
|
-
EXTENSION_INPUTS,
|
|
1953
1785
|
FETCH_CHUNK_BYTES,
|
|
1954
1786
|
FETCH_HEADERS_TIMEOUT_MS,
|
|
1955
1787
|
FETCH_IDLE_TIMEOUT_MS,
|
|
@@ -1988,6 +1820,7 @@ export {
|
|
|
1988
1820
|
isWorkbenchComputerMethod,
|
|
1989
1821
|
matchAgentApiRoute,
|
|
1990
1822
|
normalizeAgentApiPath,
|
|
1823
|
+
pageFetchHeadersTimeout,
|
|
1991
1824
|
pageFetchPath,
|
|
1992
1825
|
validAppCommandSnapshot,
|
|
1993
1826
|
validAppWindowState,
|
|
@@ -2007,8 +1840,6 @@ export {
|
|
|
2007
1840
|
validDesktopResult,
|
|
2008
1841
|
validDesktopResultForInput,
|
|
2009
1842
|
validDesktopTarget,
|
|
2010
|
-
validExtensionRequest,
|
|
2011
|
-
validExtensionResult,
|
|
2012
1843
|
validPresentationSnapshot,
|
|
2013
1844
|
validProjectRequest,
|
|
2014
1845
|
validProjectSnapshot,
|
|
@@ -2030,7 +1861,6 @@ export {
|
|
|
2030
1861
|
validWorkspaceInput,
|
|
2031
1862
|
validWorkspaceOperation,
|
|
2032
1863
|
validWorkspaceResult,
|
|
2033
|
-
workbenchChannelSettings,
|
|
2034
1864
|
workbenchComputer,
|
|
2035
1865
|
workbenchComputerKey
|
|
2036
1866
|
};
|