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