@bobannomi/app-host 0.7.0 → 0.8.1
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/README.md +5 -5
- package/dist/index.d.ts +19 -239
- package/dist/index.js +131 -297
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +19 -254
- package/dist/protocol.js +65 -261
- 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";
|
|
@@ -245,7 +233,6 @@ var APP_HOST_FEATURES = [
|
|
|
245
233
|
"service-v1",
|
|
246
234
|
"extended-errors-v1",
|
|
247
235
|
"workspace-v1",
|
|
248
|
-
"session-resources-v1",
|
|
249
236
|
"session-controls-v1",
|
|
250
237
|
"conversation-creation-session-v1",
|
|
251
238
|
"trusted-desktop-v1",
|
|
@@ -271,6 +258,11 @@ var FETCH_MAX_STREAMS = 16;
|
|
|
271
258
|
var FETCH_METADATA_BYTES = 64 * 1024;
|
|
272
259
|
var FETCH_HEADERS_TIMEOUT_MS = 3e4;
|
|
273
260
|
var FETCH_IDLE_TIMEOUT_MS = 12e4;
|
|
261
|
+
function pageFetchHeadersTimeout(method, target2) {
|
|
262
|
+
const path = target2.split("?", 1)[0];
|
|
263
|
+
const preparesExtension = method === "GET" ? path === "/skills/marketplace" || path === "/plugins/marketplace/catalog" : method === "POST" && /^\/(?:skills\/marketplace\/install|plugins\/(?:archive|git|marketplace)\/(?:preview|install)|plugins\/archive\/uploads(?:\/install)?)$/.test(path ?? "");
|
|
264
|
+
return preparesExtension ? 33e4 : FETCH_HEADERS_TIMEOUT_MS;
|
|
265
|
+
}
|
|
274
266
|
function isPageFetchFrame(value) {
|
|
275
267
|
let size = 0;
|
|
276
268
|
const visit = (entry, depth, binary = false) => {
|
|
@@ -292,17 +284,17 @@ function isPageFetchFrame(value) {
|
|
|
292
284
|
return size <= FETCH_METADATA_BYTES;
|
|
293
285
|
}
|
|
294
286
|
if (!entry || typeof entry !== "object") return false;
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
287
|
+
const array3 = Array.isArray(entry);
|
|
288
|
+
if (array3 ? Object.getPrototypeOf(entry) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
297
289
|
return false;
|
|
298
290
|
const keys2 = Reflect.ownKeys(entry);
|
|
299
|
-
if (keys2.length > FETCH_METADATA_BYTES ||
|
|
291
|
+
if (keys2.length > FETCH_METADATA_BYTES || array3 && keys2.length !== entry.length + 1)
|
|
300
292
|
return false;
|
|
301
293
|
return keys2.every((key) => {
|
|
302
|
-
if (
|
|
294
|
+
if (array3 && key === "length") return true;
|
|
303
295
|
const d = Object.getOwnPropertyDescriptor(entry, key);
|
|
304
296
|
size += typeof key === "string" ? key.length + 3 : 0;
|
|
305
|
-
return typeof key === "string" && d.enumerable && Object.hasOwn(d, "value") && (!
|
|
297
|
+
return typeof key === "string" && d.enumerable && Object.hasOwn(d, "value") && (!array3 || /^(0|[1-9][0-9]*)$/.test(key) && Number(key) < entry.length) && visit(d.value, depth + 1, depth === 0 && key === "bytes") && size <= FETCH_METADATA_BYTES;
|
|
306
298
|
});
|
|
307
299
|
};
|
|
308
300
|
if (!visit(value, 0) || !value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -361,6 +353,14 @@ function pageFetchPath(baseUrl, input) {
|
|
|
361
353
|
|
|
362
354
|
// ../domain-contracts/src/app-host/agent-api-policy.ts
|
|
363
355
|
var routes = [
|
|
356
|
+
{ method: "POST", pattern: /^\/git\/workspace\/(read|branch|branch-result)$/, id: "git.workspace" },
|
|
357
|
+
{ method: "GET", pattern: /^\/projects\/directories$/, id: "projects.directories" },
|
|
358
|
+
{ method: "PATCH", pattern: /^\/projects\/directories\/default-shell$/, id: "projects.directories" },
|
|
359
|
+
{ method: "POST", pattern: /^\/providers\/(manage|defaults)$/, id: "providers.manage" },
|
|
360
|
+
{ method: "GET", pattern: /^\/channels\/(runtime\/status|feishu(?:\/registration)?)$/, id: "channels.manage" },
|
|
361
|
+
{ method: "POST", pattern: /^\/channels\/(runtime\/(start|stop)|feishu\/(connect|allow|registration))$/, id: "channels.manage" },
|
|
362
|
+
{ method: "PATCH", pattern: /^\/channels\/feishu$/, id: "channels.manage" },
|
|
363
|
+
{ method: "DELETE", pattern: /^\/channels\/feishu(?:\/(allow|registration))?$/, id: "channels.manage" },
|
|
364
364
|
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+(?:\/run|\/runs\/[^/]+)?)?|runs)$/, id: "schedules.read" },
|
|
365
365
|
{ method: "POST", pattern: /^\/schedules\/tasks(?:\/[^/]+\/run)?$/, id: "schedules.create" },
|
|
366
366
|
{ method: "PATCH", pattern: /^\/schedules\/(tasks\/[^/]+|runs\/[^/]+\/read)$/, id: "schedules.update" },
|
|
@@ -368,6 +368,20 @@ var routes = [
|
|
|
368
368
|
{ method: "GET", pattern: /^\/(health|capabilities)$/, id: "protocol.read" },
|
|
369
369
|
{ method: "GET", pattern: /^\/(models|agent-personas|skills)$/, id: "resources.read" },
|
|
370
370
|
{ method: "POST", pattern: /^\/skills\/install$/, id: "skills.install" },
|
|
371
|
+
{ method: "GET", pattern: /^\/skills\/marketplace$/, id: "skills.marketplace" },
|
|
372
|
+
{ method: "POST", pattern: /^\/skills\/marketplace\/install$/, id: "skills.marketplace" },
|
|
373
|
+
{ method: "DELETE", pattern: /^\/skills\/[^/]+$/, id: "skills.remove" },
|
|
374
|
+
{ method: "GET", pattern: /^\/plugins(?:\/icon|\/archive\/uploads\/operations\/[^/]+|\/marketplace\/(?:catalog|sources|operations\/[^/]+))?$/, id: "plugins.manage" },
|
|
375
|
+
{ method: "POST", pattern: /^\/plugins\/(?:reload|archive\/uploads(?:\/install)?|git\/(?:preview|install)|[^/]+\/(?:enable|disable)|marketplace\/(?:sources|preview|install|cancel))$/, id: "plugins.manage" },
|
|
376
|
+
{ method: "PATCH", pattern: /^\/plugins\/marketplace\/sources\/[^/]+$/, id: "plugins.manage" },
|
|
377
|
+
{ method: "DELETE", pattern: /^\/plugins\/(?:[^/]+|archive\/uploads\/[^/]+|marketplace\/sources\/[^/]+)$/, id: "plugins.manage" },
|
|
378
|
+
{ method: "GET", pattern: /^\/mcp\/config\/servers(?:\/config\/(?:entry|export|inventory))?$/, id: "mcp.config" },
|
|
379
|
+
{ method: "POST", pattern: /^\/mcp\/config\/servers$/, id: "mcp.config" },
|
|
380
|
+
{ method: "PUT", pattern: /^\/mcp\/config\/servers\/config\/entry(?:\/enabled)?$/, id: "mcp.config" },
|
|
381
|
+
{ method: "DELETE", pattern: /^\/mcp\/config\/servers\/config\/entry$/, id: "mcp.config" },
|
|
382
|
+
{ method: "POST", pattern: /^\/mcp\/oauth\/(?:login|logout)$/, id: "mcp.oauth" },
|
|
383
|
+
{ method: "GET", pattern: /^\/mcp\/oauth\/operations\/[^/]+(?:\/events)?$/, id: "mcp.oauth" },
|
|
384
|
+
{ method: "DELETE", pattern: /^\/mcp\/oauth\/operations\/[^/]+$/, id: "mcp.oauth" },
|
|
371
385
|
{ method: "POST", pattern: /^\/model-connections$/, id: "models.prepare" },
|
|
372
386
|
{ method: "GET", pattern: /^\/sessions\/[^/]+\/goal(?:\/requests\/[^/]+)?$/, id: "goals.read" },
|
|
373
387
|
{ method: "POST", pattern: /^\/sessions\/[^/]+\/goals$/, id: "goals.write" },
|
|
@@ -662,7 +676,7 @@ function createAppCommandsApi(rpc) {
|
|
|
662
676
|
rpc.requireFeature();
|
|
663
677
|
snapshot = structuredClone(snapshot);
|
|
664
678
|
const registrationId = crypto.randomUUID();
|
|
665
|
-
let
|
|
679
|
+
let revision = 0;
|
|
666
680
|
let disposed = false;
|
|
667
681
|
let remoteValid = true;
|
|
668
682
|
let disposal;
|
|
@@ -670,11 +684,11 @@ function createAppCommandsApi(rpc) {
|
|
|
670
684
|
let conflicts = [];
|
|
671
685
|
let queue = Promise.resolve();
|
|
672
686
|
const off = rpc.onInvoke((event) => {
|
|
673
|
-
if (!disposed && event.registrationId === registrationId && event.revision ===
|
|
687
|
+
if (!disposed && event.registrationId === registrationId && event.revision === revision && current.commands.some(
|
|
674
688
|
(c) => c.id === event.commandId && c.enabled !== false
|
|
675
689
|
)) {
|
|
676
690
|
void Promise.resolve().then(() => {
|
|
677
|
-
if (!disposed && event.revision ===
|
|
691
|
+
if (!disposed && event.revision === revision)
|
|
678
692
|
return invoke(event.commandId);
|
|
679
693
|
}).catch(() => {
|
|
680
694
|
});
|
|
@@ -694,14 +708,14 @@ function createAppCommandsApi(rpc) {
|
|
|
694
708
|
const call = async (method, next) => {
|
|
695
709
|
const params = {
|
|
696
710
|
registrationId,
|
|
697
|
-
revision
|
|
711
|
+
revision,
|
|
698
712
|
...next === void 0 ? {} : { snapshot: next }
|
|
699
713
|
};
|
|
700
714
|
const result = await rpc.request(
|
|
701
715
|
method,
|
|
702
716
|
params
|
|
703
717
|
);
|
|
704
|
-
if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !==
|
|
718
|
+
if (!validCommandReceipt(result) || result.registrationId !== registrationId || result.revision !== revision)
|
|
705
719
|
throw new AppHostError("host_unavailable");
|
|
706
720
|
conflicts = [...result.shortcutConflicts ?? []];
|
|
707
721
|
};
|
|
@@ -711,7 +725,7 @@ function createAppCommandsApi(rpc) {
|
|
|
711
725
|
try {
|
|
712
726
|
await rpc.request("commands.dispose", {
|
|
713
727
|
registrationId,
|
|
714
|
-
revision: ++
|
|
728
|
+
revision: ++revision
|
|
715
729
|
});
|
|
716
730
|
} catch {
|
|
717
731
|
}
|
|
@@ -735,7 +749,7 @@ function createAppCommandsApi(rpc) {
|
|
|
735
749
|
const task = queue.then(async () => {
|
|
736
750
|
if (disposed) throw new AppHostError("connection_revoked");
|
|
737
751
|
rpc.requireFeature();
|
|
738
|
-
|
|
752
|
+
revision++;
|
|
739
753
|
current = next;
|
|
740
754
|
try {
|
|
741
755
|
await call("commands.update", next);
|
|
@@ -753,7 +767,7 @@ function createAppCommandsApi(rpc) {
|
|
|
753
767
|
stop();
|
|
754
768
|
disposal = queue.then(async () => {
|
|
755
769
|
if (!remoteValid) return;
|
|
756
|
-
|
|
770
|
+
revision++;
|
|
757
771
|
try {
|
|
758
772
|
await call("commands.dispose");
|
|
759
773
|
} finally {
|
|
@@ -933,9 +947,9 @@ function validConversationPreparationResult(method, result) {
|
|
|
933
947
|
// src/client-connections.ts
|
|
934
948
|
var connections = /* @__PURE__ */ new WeakMap();
|
|
935
949
|
function createClientConnection(wire, streams) {
|
|
936
|
-
const { connectionId, baseUrl, cwd
|
|
950
|
+
const { connectionId, baseUrl, cwd, defaultTaskLocation } = wire;
|
|
937
951
|
const connection = {
|
|
938
|
-
...
|
|
952
|
+
...cwd === void 0 ? {} : { cwd },
|
|
939
953
|
...defaultTaskLocation === void 0 ? {} : { defaultTaskLocation },
|
|
940
954
|
clientOptions: { baseUrl, fetch: streams.fetchFor(connectionId, baseUrl) },
|
|
941
955
|
isClosed: () => streams.isClosed?.(connectionId) === true
|
|
@@ -945,7 +959,8 @@ function createClientConnection(wire, streams) {
|
|
|
945
959
|
}
|
|
946
960
|
function resolveClientConnection(connection, owner) {
|
|
947
961
|
const record2 = connections.get(connection);
|
|
948
|
-
if (!record2 || record2.owner !== owner
|
|
962
|
+
if (!record2 || record2.owner !== owner && record2.owner !== globalThis.window || connection.isClosed?.())
|
|
963
|
+
throw new AppHostError("connection_revoked");
|
|
949
964
|
return record2.id;
|
|
950
965
|
}
|
|
951
966
|
|
|
@@ -1110,7 +1125,7 @@ function createAppDesktopApi(rpc, owner, filesFeature = () => {
|
|
|
1110
1125
|
if (!validDesktopResultForInput(method, params, value)) throw new AppHostError("host_unavailable");
|
|
1111
1126
|
return value;
|
|
1112
1127
|
};
|
|
1113
|
-
const group = (
|
|
1128
|
+
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
1129
|
const getOperation = async (input, validate) => {
|
|
1115
1130
|
if (!validate(input)) throw new AppHostError("invalid_request");
|
|
1116
1131
|
return call("desktop.files.getOperation", input);
|
|
@@ -1233,67 +1248,6 @@ function createAppAuxiliarySessionsApi(rpc, streams) {
|
|
|
1233
1248
|
};
|
|
1234
1249
|
}
|
|
1235
1250
|
|
|
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
1251
|
// src/projects.ts
|
|
1298
1252
|
var id2 = text(256);
|
|
1299
1253
|
var scope = { dataScopeId: id2 };
|
|
@@ -1301,14 +1255,8 @@ var project = { ...scope, projectId: id2, workspaceId: id2 };
|
|
|
1301
1255
|
function validProjectRequest(value) {
|
|
1302
1256
|
const action2 = value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, "action")?.value : void 0;
|
|
1303
1257
|
switch (action2) {
|
|
1304
|
-
case "list":
|
|
1305
|
-
return object({ action: (v) => v === "list" })(value);
|
|
1306
1258
|
case "register":
|
|
1307
1259
|
return object({ action: (v) => v === "register", ...scope, workspaceId: id2 })(value);
|
|
1308
|
-
case "setDefaultShell":
|
|
1309
|
-
return object({ action: (v) => v === "setDefaultShell", ...project, shell: (v) => v === null || text(4096)(v) })(value);
|
|
1310
|
-
case "archive":
|
|
1311
|
-
return object({ action: (v) => v === "archive", ...project })(value);
|
|
1312
1260
|
case "rebind":
|
|
1313
1261
|
return object({ action: (v) => v === "rebind", ...project, previousWorkspaceId: id2, expectedPath: text(32768) })(value);
|
|
1314
1262
|
default:
|
|
@@ -1328,6 +1276,7 @@ var root2 = { rootPath: text(32768) };
|
|
|
1328
1276
|
var identity = { identity: object({ dev: text(32), ino: text(32) }) };
|
|
1329
1277
|
var file = { ...root2, path: text(32768) };
|
|
1330
1278
|
var write = { ...file, requestId: id, content: text(125e4, true), originalContent: text(125e4, true) };
|
|
1279
|
+
var gitRead = { ...identity, range: enumeration("uncommitted", "working", "staged"), ignoreWhitespace: bool };
|
|
1331
1280
|
var actionOf = (value) => value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, "action")?.value : void 0;
|
|
1332
1281
|
function validLocalWorkspaceRequest(value) {
|
|
1333
1282
|
const action2 = actionOf(value);
|
|
@@ -1340,6 +1289,10 @@ function validLocalWorkspaceRequest(value) {
|
|
|
1340
1289
|
return object({ ...field, ...root2 }, { ...identity, path: text(32768, true) })(value);
|
|
1341
1290
|
case "find":
|
|
1342
1291
|
return object({ ...field, ...root2, query: text(1024) }, identity)(value);
|
|
1292
|
+
case "gitChanges":
|
|
1293
|
+
return object({ ...field, ...root2 }, gitRead)(value);
|
|
1294
|
+
case "gitDiff":
|
|
1295
|
+
return object({ ...field, ...root2 }, { ...gitRead, path: text(32768), base: text(512), head: text(512) })(value);
|
|
1343
1296
|
case "write":
|
|
1344
1297
|
case "getWrite":
|
|
1345
1298
|
return object({ ...field, ...write }, identity)(value);
|
|
@@ -1381,7 +1334,7 @@ var found = object({ files: array(text(32768), 1e3), truncated: bool });
|
|
|
1381
1334
|
var picked = object({ ...root2, ...identity, workspaceId: id });
|
|
1382
1335
|
var url = object({ url: text(131072) });
|
|
1383
1336
|
var openers = (value) => validDesktopResult("desktop.files.listOpeners", value);
|
|
1384
|
-
var
|
|
1337
|
+
var empty = (value) => value === void 0;
|
|
1385
1338
|
var checks = {
|
|
1386
1339
|
pick: nullable(picked),
|
|
1387
1340
|
list: tree,
|
|
@@ -1389,87 +1342,18 @@ var checks = {
|
|
|
1389
1342
|
read: preview,
|
|
1390
1343
|
write: preview,
|
|
1391
1344
|
getWrite: nullable(preview),
|
|
1392
|
-
reveal:
|
|
1393
|
-
openWith:
|
|
1394
|
-
copyPath:
|
|
1345
|
+
reveal: empty,
|
|
1346
|
+
openWith: empty,
|
|
1347
|
+
copyPath: empty,
|
|
1395
1348
|
listOpeners: openers,
|
|
1396
|
-
webPreview: url
|
|
1349
|
+
webPreview: url,
|
|
1350
|
+
gitChanges: (value) => validDesktopResult("desktop.git.changes", value),
|
|
1351
|
+
gitDiff: (value) => validDesktopResult("desktop.git.diff", value)
|
|
1397
1352
|
};
|
|
1398
1353
|
function validLocalWorkspaceResult(value, action2) {
|
|
1399
1354
|
return action2 ? checks[action2](value) : Object.values(checks).some((check) => check(value));
|
|
1400
1355
|
}
|
|
1401
1356
|
|
|
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
1357
|
// src/system.ts
|
|
1474
1358
|
var SYSTEM_SETTINGS_SECTIONS = [
|
|
1475
1359
|
"general",
|
|
@@ -1507,34 +1391,9 @@ var SYSTEM_SHORTCUT_IDS = [
|
|
|
1507
1391
|
"resetZoom",
|
|
1508
1392
|
"showShortcuts"
|
|
1509
1393
|
];
|
|
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
1394
|
var SYSTEM_METHODS = [
|
|
1532
1395
|
"system.projects",
|
|
1533
1396
|
"system.workspace",
|
|
1534
|
-
"system.extensions",
|
|
1535
|
-
"system.modelProviders",
|
|
1536
|
-
"system.channelSettings",
|
|
1537
|
-
"system.providerDefaults",
|
|
1538
1397
|
"system.open",
|
|
1539
1398
|
"system.getPresentationPreferences",
|
|
1540
1399
|
"system.setTheme",
|
|
@@ -1609,7 +1468,11 @@ var validDesktopNavigationTarget = (v) => object(
|
|
|
1609
1468
|
scheduledRunId: text(256)
|
|
1610
1469
|
},
|
|
1611
1470
|
{ sessionId: text(256) }
|
|
1612
|
-
)(v)
|
|
1471
|
+
)(v) || object({
|
|
1472
|
+
id: text(256),
|
|
1473
|
+
dataScopeId: text(256),
|
|
1474
|
+
kind: enumeration("extensions")
|
|
1475
|
+
})(v);
|
|
1613
1476
|
function isSystemMethod(v) {
|
|
1614
1477
|
return SYSTEM_METHODS.includes(v);
|
|
1615
1478
|
}
|
|
@@ -1631,21 +1494,6 @@ function validSystemInput(method, value) {
|
|
|
1631
1494
|
return validProjectRequest(value);
|
|
1632
1495
|
case "system.workspace":
|
|
1633
1496
|
return validLocalWorkspaceRequest(value);
|
|
1634
|
-
case "system.extensions":
|
|
1635
|
-
return validExtensionRequest(value);
|
|
1636
|
-
case "system.modelProviders":
|
|
1637
|
-
return validModelProviderRequest(value);
|
|
1638
|
-
case "system.channelSettings": {
|
|
1639
|
-
const action2 = enumeration(...CHANNEL_SETTINGS_ACTIONS);
|
|
1640
|
-
if (object({ action: enumeration("allowRemove"), input: text() })(value)) return true;
|
|
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);
|
|
1649
1497
|
case "system.setTheme":
|
|
1650
1498
|
return object({ theme: themeMode })(value);
|
|
1651
1499
|
case "system.setWindowMaterial":
|
|
@@ -1659,9 +1507,6 @@ function validSystemInput(method, value) {
|
|
|
1659
1507
|
{ page: enumeration("scheduled") },
|
|
1660
1508
|
{ taskId: text(256), scheduledRunId: text(256) }
|
|
1661
1509
|
)(value) && (!Object.hasOwn(value, "scheduledRunId") || Object.hasOwn(value, "taskId")) || object(
|
|
1662
|
-
{ page: enumeration("extensions") },
|
|
1663
|
-
{ tab: enumeration("plugins", "skills", "mcp") }
|
|
1664
|
-
)(value) || object(
|
|
1665
1510
|
{ page: enumeration("settings") },
|
|
1666
1511
|
{ section: enumeration(...SYSTEM_SETTINGS_SECTIONS) }
|
|
1667
1512
|
)(value) || object({ page: enumeration("pet") })(value) || object(
|
|
@@ -1691,14 +1536,6 @@ function validSystemResult(method, value) {
|
|
|
1691
1536
|
return validProjectSnapshot(value);
|
|
1692
1537
|
case "system.workspace":
|
|
1693
1538
|
return validLocalWorkspaceResult(value);
|
|
1694
|
-
case "system.extensions":
|
|
1695
|
-
return validExtensionResult(value);
|
|
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);
|
|
1702
1539
|
case "system.open":
|
|
1703
1540
|
return object({ opened: enumeration(true) })(value);
|
|
1704
1541
|
case "system.getPresentationPreferences":
|
|
@@ -1738,14 +1575,6 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1738
1575
|
if (!validLocalWorkspaceResult(result, input.action)) throw new AppHostError("host_unavailable");
|
|
1739
1576
|
return result;
|
|
1740
1577
|
}),
|
|
1741
|
-
extensions: (input) => send("system.extensions", input),
|
|
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
|
-
}),
|
|
1749
1578
|
open: (input) => {
|
|
1750
1579
|
if (input.page !== "session-settings") return send("system.open", input);
|
|
1751
1580
|
const { target: target2 } = input;
|
|
@@ -1769,28 +1598,9 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1769
1598
|
navigationReady: () => send("system.navigationReady", {}),
|
|
1770
1599
|
completeNavigation: (input) => send("system.completeNavigation", input)
|
|
1771
1600
|
};
|
|
1772
|
-
Object.defineProperty(system, channelSettingsKey, {
|
|
1773
|
-
value: (input) => send("system.channelSettings", input)
|
|
1774
|
-
});
|
|
1775
1601
|
return system;
|
|
1776
1602
|
}
|
|
1777
1603
|
|
|
1778
|
-
// src/session-resources.ts
|
|
1779
|
-
function resourceFields(v, required, optional = []) {
|
|
1780
|
-
if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) return false;
|
|
1781
|
-
return required.every((k) => Object.hasOwn(v, k)) && Reflect.ownKeys(v).every((k) => {
|
|
1782
|
-
const d = Object.getOwnPropertyDescriptor(v, k);
|
|
1783
|
-
return typeof k === "string" && [...required, ...optional].includes(k) && d.enumerable && Object.hasOwn(d, "value");
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
var str2 = (v, max = 256) => typeof v === "string" && v.length > 0 && v.length <= max;
|
|
1787
|
-
function validSessionResourceInput(method, v) {
|
|
1788
|
-
return method === "getAuthorizedAgentConnection" && resourceFields(v, []);
|
|
1789
|
-
}
|
|
1790
|
-
function validSessionResourceResult(_method, v) {
|
|
1791
|
-
return resourceFields(v, ["connectionId", "baseUrl"], ["defaultTaskLocation"]) && (!Object.hasOwn(v, "defaultTaskLocation") || v.defaultTaskLocation === "current" || v.defaultTaskLocation === "worktree") && str2(v.connectionId) && /^[A-Za-z0-9-]+$/.test(v.connectionId) && v.baseUrl === `https://app-host.invalid/connections/${v.connectionId}`;
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
1604
|
// src/workbench-computer.ts
|
|
1795
1605
|
var WORKBENCH_COMPUTER_FEATURE = "workbench-computer-v1";
|
|
1796
1606
|
var workbenchComputerKey = /* @__PURE__ */ Symbol.for("nomi.workbench-computer");
|
|
@@ -1816,7 +1626,7 @@ function text2(value, limit = 256) {
|
|
|
1816
1626
|
return typeof value === "string" && value.length > 0 && value.length <= limit;
|
|
1817
1627
|
}
|
|
1818
1628
|
function keys(value, ...names) {
|
|
1819
|
-
return Object.keys(value).length === names.length && names.every((
|
|
1629
|
+
return Object.keys(value).length === names.length && names.every((name) => Object.hasOwn(value, name));
|
|
1820
1630
|
}
|
|
1821
1631
|
function isWorkbenchComputerMethod(method) {
|
|
1822
1632
|
return WORKBENCH_COMPUTER_METHODS.includes(method);
|
|
@@ -1905,7 +1715,6 @@ var APP_HOST_METHODS = [
|
|
|
1905
1715
|
"storage.get",
|
|
1906
1716
|
"storage.set",
|
|
1907
1717
|
"storage.delete",
|
|
1908
|
-
"getAuthorizedAgentConnection",
|
|
1909
1718
|
"service.getStatus",
|
|
1910
1719
|
"service.getConnection",
|
|
1911
1720
|
"service.listWork",
|
|
@@ -1949,7 +1758,6 @@ export {
|
|
|
1949
1758
|
BROWSER_CAPTURE_PREVIEW_MAX_BYTES,
|
|
1950
1759
|
COMMANDS_METHODS,
|
|
1951
1760
|
DESKTOP_METHODS,
|
|
1952
|
-
EXTENSION_INPUTS,
|
|
1953
1761
|
FETCH_CHUNK_BYTES,
|
|
1954
1762
|
FETCH_HEADERS_TIMEOUT_MS,
|
|
1955
1763
|
FETCH_IDLE_TIMEOUT_MS,
|
|
@@ -1988,6 +1796,7 @@ export {
|
|
|
1988
1796
|
isWorkbenchComputerMethod,
|
|
1989
1797
|
matchAgentApiRoute,
|
|
1990
1798
|
normalizeAgentApiPath,
|
|
1799
|
+
pageFetchHeadersTimeout,
|
|
1991
1800
|
pageFetchPath,
|
|
1992
1801
|
validAppCommandSnapshot,
|
|
1993
1802
|
validAppWindowState,
|
|
@@ -2007,16 +1816,12 @@ export {
|
|
|
2007
1816
|
validDesktopResult,
|
|
2008
1817
|
validDesktopResultForInput,
|
|
2009
1818
|
validDesktopTarget,
|
|
2010
|
-
validExtensionRequest,
|
|
2011
|
-
validExtensionResult,
|
|
2012
1819
|
validPresentationSnapshot,
|
|
2013
1820
|
validProjectRequest,
|
|
2014
1821
|
validProjectSnapshot,
|
|
2015
1822
|
validResourceCatalogInput,
|
|
2016
1823
|
validResourceCatalogResult,
|
|
2017
1824
|
validResourceChanged,
|
|
2018
|
-
validSessionResourceInput,
|
|
2019
|
-
validSessionResourceResult,
|
|
2020
1825
|
validSessionSettingsTarget,
|
|
2021
1826
|
validSystemEvent,
|
|
2022
1827
|
validSystemInput,
|
|
@@ -2030,7 +1835,6 @@ export {
|
|
|
2030
1835
|
validWorkspaceInput,
|
|
2031
1836
|
validWorkspaceOperation,
|
|
2032
1837
|
validWorkspaceResult,
|
|
2033
|
-
workbenchChannelSettings,
|
|
2034
1838
|
workbenchComputer,
|
|
2035
1839
|
workbenchComputerKey
|
|
2036
1840
|
};
|