@bobannomi/app-host 0.1.0-next.1 → 0.1.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 +3 -3
- package/dist/index.d.ts +111 -131
- package/dist/index.js +477 -242
- package/dist/index.js.map +3 -3
- package/dist/node/service-host.d.ts +114 -336
- package/dist/node/service-host.js +88 -153
- package/dist/node/service-host.js.map +3 -3
- package/dist/protocol.d.ts +492 -513
- package/dist/protocol.js +220 -140
- package/dist/protocol.js.map +3 -3
- package/package.json +3 -3
package/dist/protocol.js
CHANGED
|
@@ -61,6 +61,18 @@ function appHostErrorMessage(code, details) {
|
|
|
61
61
|
return "The desktop host could not reconnect services for this page.";
|
|
62
62
|
case "host_access_check_failed":
|
|
63
63
|
return "The desktop host could not verify access for this page.";
|
|
64
|
+
case "skill_marketplace_unavailable":
|
|
65
|
+
return "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B98\u65B9\u6280\u80FD\u5E02\u573A\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
66
|
+
case "skill_marketplace_install_failed":
|
|
67
|
+
return "\u6280\u80FD\u5B89\u88C5\u6216\u66F4\u65B0\u672A\u5B8C\u6210\uFF0C\u8BF7\u5237\u65B0\u5DF2\u5B89\u88C5\u6280\u80FD\u540E\u91CD\u8BD5\u3002";
|
|
68
|
+
case "skill_marketplace_busy":
|
|
69
|
+
return "\u540E\u53F0\u6B63\u5728\u8FD0\u884C\u4EFB\u52A1\u6216\u5904\u7406\u6280\u80FD\u53D8\u66F4\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
70
|
+
case "skill_marketplace_local_conflict":
|
|
71
|
+
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";
|
|
72
|
+
case "skill_marketplace_selection_changed":
|
|
73
|
+
return "\u6240\u9009\u6280\u80FD\u6216\u7248\u672C\u5DF2\u53D8\u5316\uFF0C\u8BF7\u5237\u65B0\u6280\u80FD\u5E02\u573A\u540E\u91CD\u8BD5\u3002";
|
|
74
|
+
case "skill_marketplace_project_unavailable":
|
|
75
|
+
return "\u5F53\u524D\u9879\u76EE\u65E0\u6CD5\u5B89\u88C5\u6280\u80FD\uFF0C\u8BF7\u9009\u62E9\u5DF2\u767B\u8BB0\u7684\u9879\u76EE\u3002";
|
|
64
76
|
default:
|
|
65
77
|
return "The desktop host could not complete the operation.";
|
|
66
78
|
}
|
|
@@ -187,7 +199,7 @@ function rows(value, check) {
|
|
|
187
199
|
}
|
|
188
200
|
function validAgentInput(method, value) {
|
|
189
201
|
if (!json(value)) return false;
|
|
190
|
-
if (method === "agent.listModels"
|
|
202
|
+
if (method === "agent.listModels") return fields(value, []);
|
|
191
203
|
if (method === "agent.resolveSkills") return fields(value, ["skillIds"]) && Array.isArray(value.skillIds) && value.skillIds.length <= 128 && value.skillIds.every((v) => text(256)(v)) && new Set(value.skillIds).size === value.skillIds.length;
|
|
192
204
|
if (method !== "agent.getConnection" || !fields(value, [], ["workspaceId", "executionRoot", "privateSessionId"])) return false;
|
|
193
205
|
return (!Object.hasOwn(value, "workspaceId") || workspaceId(value.workspaceId)) && (!Object.hasOwn(value, "privateSessionId") || workspaceId(value.privateSessionId) && !Object.hasOwn(value, "workspaceId") && !Object.hasOwn(value, "executionRoot")) && (!Object.hasOwn(value, "executionRoot") || workspaceId(value.executionRoot) && Object.hasOwn(value, "workspaceId"));
|
|
@@ -202,104 +214,12 @@ function validAgentResult(method, value) {
|
|
|
202
214
|
value,
|
|
203
215
|
(row) => fields(row, ["id", "name"], ["reasoning", "reasoningEfforts", "vision", "contextWindow", "outputLimit", "inputModalities", "toolCalling"]) && text2(row.id) && text2(row.name) && ["reasoning", "vision", "toolCalling"].every((key) => !Object.hasOwn(row, key) || typeof row[key] === "boolean") && ["contextWindow", "outputLimit"].every((key) => !Object.hasOwn(row, key) || Number.isSafeInteger(row[key]) && row[key] > 0) && ["reasoningEfforts", "inputModalities"].every((key) => !Object.hasOwn(row, key) || Array.isArray(row[key]) && row[key].length <= 32 && row[key].every((value2) => text(128)(value2)) && new Set(row[key]).size === row[key].length)
|
|
204
216
|
);
|
|
205
|
-
case "agent.listRoles":
|
|
206
|
-
return rows(
|
|
207
|
-
value,
|
|
208
|
-
(row) => fields(row, ["id", "name", "description"]) && text2(row.id) && text2(row.name) && typeof row.description === "string"
|
|
209
|
-
);
|
|
210
217
|
case "agent.resolveSkills":
|
|
211
218
|
return rows(
|
|
212
219
|
value,
|
|
213
220
|
(row) => fields(row, ["type", "name", "path"]) && row.type === "skill" && text2(row.name) && text2(row.path)
|
|
214
221
|
);
|
|
215
222
|
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// ../domain-contracts/src/app-host/workspace-conversations.ts
|
|
219
|
-
var validWorkspaceConversation = (value) => {
|
|
220
|
-
if (!object(
|
|
221
|
-
{ dataScopeId: text(), requestId: id, sessionId: id, taskLocation: enumeration("current", "worktree"), configuration: json },
|
|
222
|
-
{ workspaceId: id, outsideProject: (v) => v === true, preparationRevision: text() }
|
|
223
|
-
)(value)) return false;
|
|
224
|
-
const input = value;
|
|
225
|
-
return input.workspaceId !== void 0 ? input.outsideProject !== true : input.outsideProject === true && input.taskLocation === "current";
|
|
226
|
-
};
|
|
227
|
-
var sessionText = (value) => typeof value === "string";
|
|
228
|
-
var sessionRecord = object({
|
|
229
|
-
id,
|
|
230
|
-
cwd: sessionText,
|
|
231
|
-
title: sessionText,
|
|
232
|
-
model: sessionText,
|
|
233
|
-
status: enumeration("idle", "running", "closing", "archived", "error"),
|
|
234
|
-
metadata: jsonObject,
|
|
235
|
-
createdAt: count,
|
|
236
|
-
updatedAt: count
|
|
237
|
-
}, {
|
|
238
|
-
storage: enumeration("sqlite", "memory"),
|
|
239
|
-
parentId: sessionText,
|
|
240
|
-
projectId: sessionText,
|
|
241
|
-
cwdRelative: sessionText,
|
|
242
|
-
agent: sessionText,
|
|
243
|
-
archivedAt: count
|
|
244
|
-
});
|
|
245
|
-
var workspaceConversationResult = object({
|
|
246
|
-
dataScopeId: text(),
|
|
247
|
-
sessionId: id,
|
|
248
|
-
requestId: id,
|
|
249
|
-
action: (v) => v === "create-session",
|
|
250
|
-
state: enumeration("prepared", "completed", "unknown")
|
|
251
|
-
}, {
|
|
252
|
-
configuration: json,
|
|
253
|
-
revision: count,
|
|
254
|
-
session: sessionRecord,
|
|
255
|
-
operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
|
|
256
|
-
indexBindingPending: (v) => v === true,
|
|
257
|
-
workspaceId: id,
|
|
258
|
-
executionRoot: id,
|
|
259
|
-
privateSessionId: id,
|
|
260
|
-
worktree: json
|
|
261
|
-
});
|
|
262
|
-
var validWorkspaceConversationResult = (value) => {
|
|
263
|
-
if (!workspaceConversationResult(value)) return false;
|
|
264
|
-
const result = value;
|
|
265
|
-
return !result.session || result.state === "completed" && result.session.id === result.sessionId;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// ../domain-contracts/src/app-host/session-controls.ts
|
|
269
|
-
var option = object({ id: text(), name: text() });
|
|
270
|
-
var choices = array(option);
|
|
271
|
-
var effortChoices = array(object({ id: text(1024, true), name: text() }));
|
|
272
|
-
var receiptShape = object({ dataScopeId: text(), sessionId: text(), requestId: id, action: enumeration("fork", "configure", "compact"), state: enumeration("prepared", "created", "completed", "unknown") }, { revision: count, targetSessionId: text() });
|
|
273
|
-
var receipt = receiptShape;
|
|
274
|
-
function validSessionControlOriginal(value) {
|
|
275
|
-
if (!object({ action: text(), body: json })(value)) return false;
|
|
276
|
-
const v = value;
|
|
277
|
-
if (v.action === "compact") return object({ requestId: id, expectedRevision: count })(v.body);
|
|
278
|
-
return v.action === "fork" && object({ requestId: id, id: text() }, { copyHistory: bool, beforeMessageId: text(), afterMessageId: text(), storage: enumeration("sqlite") })(v.body);
|
|
279
|
-
}
|
|
280
|
-
function validSessionControlInput(method, value) {
|
|
281
|
-
if (!json(value)) return false;
|
|
282
|
-
if (method === "sessions.getDraftComposerOptions") {
|
|
283
|
-
if (!object({ source: enumeration("instance") }, { workspaceId: id, outsideProject: bool, roleId: (v2) => v2 === null || text(256)(v2) })(value)) return false;
|
|
284
|
-
const target2 = value;
|
|
285
|
-
return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
|
|
286
|
-
}
|
|
287
|
-
if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
|
|
288
|
-
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
|
|
289
|
-
if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
|
|
290
|
-
if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
|
|
291
|
-
const v = value;
|
|
292
|
-
return v.original.body.requestId === v.requestId && !!v.connectionId;
|
|
293
|
-
}
|
|
294
|
-
function validSessionControlResult(method, value) {
|
|
295
|
-
if (!json(value)) return false;
|
|
296
|
-
if (method === "sessions.getDraftComposerOptions") return object({ source: enumeration("instance"), optionsRevision: text(), skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") }), 128), plugins: array(object({ id: text(), name: text(), agents: array(option, 128) }), 128) })(value);
|
|
297
|
-
if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
|
|
298
|
-
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
|
|
299
|
-
return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
|
|
300
|
-
if (method === "sessions.getControls") return object({ dataScopeId: text(), sessionId: text(), source: enumeration("instance", "auxiliary", "im"), revision: count, optionsRevision: text(), actions: object(Object.fromEntries(["readContext", "configure", "compact", "edit", "fork", "resume", "goalRead", "goalWrite", "goalStop"].map((k) => [k, bool]))), models: choices, roles: choices, efforts: effortChoices, workModes: choices, skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") })), commands: choices, contexts: choices }, { permissionModes: array(option, 128), appServiceBindings: array(option, 128), plugins: array(object({ id: text(), name: text(), agents: choices })) })(value);
|
|
301
|
-
if (method === "sessions.getControlResult") return value === null || receipt(value);
|
|
302
|
-
if (!receipt(value)) return false;
|
|
303
223
|
return false;
|
|
304
224
|
}
|
|
305
225
|
|
|
@@ -382,7 +302,31 @@ function validServiceResult(method, value) {
|
|
|
382
302
|
}
|
|
383
303
|
|
|
384
304
|
// ../domain-contracts/src/app-host/fetch.ts
|
|
385
|
-
var APP_HOST_FEATURES = [
|
|
305
|
+
var APP_HOST_FEATURES = [
|
|
306
|
+
"fetch-v1",
|
|
307
|
+
"fetch-inline-body-v1",
|
|
308
|
+
"fetch-target-close-v1",
|
|
309
|
+
"service-v1",
|
|
310
|
+
"extended-errors-v1",
|
|
311
|
+
"workspace-v1",
|
|
312
|
+
"session-resources-v1",
|
|
313
|
+
"session-controls-v1",
|
|
314
|
+
"conversation-creation-session-v1",
|
|
315
|
+
"trusted-desktop-v1",
|
|
316
|
+
"attachments-v1",
|
|
317
|
+
"auxiliary-sessions-v1",
|
|
318
|
+
"system-ui-v1",
|
|
319
|
+
"lifecycle-v1",
|
|
320
|
+
"commands-v1",
|
|
321
|
+
"resource-catalog-v1",
|
|
322
|
+
"file-content-v1",
|
|
323
|
+
"window-chrome-v1",
|
|
324
|
+
"window-updates-v1",
|
|
325
|
+
"window-update-check-v1",
|
|
326
|
+
"embedded-browser-v1",
|
|
327
|
+
"browser-binding-invalidation-v1",
|
|
328
|
+
"browser-capture-preview-v1"
|
|
329
|
+
];
|
|
386
330
|
var FETCH_CHUNK_BYTES = 64 * 1024;
|
|
387
331
|
var FETCH_INLINE_BODY_BYTES = 8 * 1024;
|
|
388
332
|
var FETCH_WINDOW_CHUNKS = 4;
|
|
@@ -395,7 +339,10 @@ function isPageFetchFrame(value) {
|
|
|
395
339
|
const visit = (entry, depth, binary = false) => {
|
|
396
340
|
if (depth > 10) return false;
|
|
397
341
|
if (entry instanceof Uint8Array) {
|
|
398
|
-
if (!binary || Object.getPrototypeOf(entry) !== Uint8Array.prototype || ["buffer", "byteLength", "byteOffset", "length"].some(
|
|
342
|
+
if (!binary || Object.getPrototypeOf(entry) !== Uint8Array.prototype || ["buffer", "byteLength", "byteOffset", "length"].some(
|
|
343
|
+
(key) => Object.hasOwn(entry, key)
|
|
344
|
+
))
|
|
345
|
+
return false;
|
|
399
346
|
const buffer = entry.buffer;
|
|
400
347
|
return buffer instanceof ArrayBuffer && !Object.hasOwn(buffer, "byteLength") && buffer.byteLength <= FETCH_CHUNK_BYTES && entry.byteLength > 0 && entry.byteLength <= FETCH_CHUNK_BYTES;
|
|
401
348
|
}
|
|
@@ -409,9 +356,11 @@ function isPageFetchFrame(value) {
|
|
|
409
356
|
}
|
|
410
357
|
if (!entry || typeof entry !== "object") return false;
|
|
411
358
|
const array2 = Array.isArray(entry);
|
|
412
|
-
if (array2 ? Object.getPrototypeOf(entry) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
359
|
+
if (array2 ? Object.getPrototypeOf(entry) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
360
|
+
return false;
|
|
413
361
|
const keys = Reflect.ownKeys(entry);
|
|
414
|
-
if (keys.length > FETCH_METADATA_BYTES || array2 && keys.length !== entry.length + 1)
|
|
362
|
+
if (keys.length > FETCH_METADATA_BYTES || array2 && keys.length !== entry.length + 1)
|
|
363
|
+
return false;
|
|
415
364
|
return keys.every((key) => {
|
|
416
365
|
if (array2 && key === "length") return true;
|
|
417
366
|
const d = Object.getOwnPropertyDescriptor(entry, key);
|
|
@@ -419,7 +368,8 @@ function isPageFetchFrame(value) {
|
|
|
419
368
|
return typeof key === "string" && d.enumerable && Object.hasOwn(d, "value") && (!array2 || /^(0|[1-9][0-9]*)$/.test(key) && Number(key) < entry.length) && visit(d.value, depth + 1, depth === 0 && key === "bytes") && size <= FETCH_METADATA_BYTES;
|
|
420
369
|
});
|
|
421
370
|
};
|
|
422
|
-
if (!visit(value, 0) || !value || typeof value !== "object" || Array.isArray(value))
|
|
371
|
+
if (!visit(value, 0) || !value || typeof value !== "object" || Array.isArray(value))
|
|
372
|
+
return false;
|
|
423
373
|
const v = value;
|
|
424
374
|
if (v.protocol !== 2 || typeof v.type !== "string") return false;
|
|
425
375
|
const fields4 = {
|
|
@@ -435,19 +385,28 @@ function isPageFetchFrame(value) {
|
|
|
435
385
|
};
|
|
436
386
|
const required = fields4[v.type];
|
|
437
387
|
const inline = v.type === "fetch-open" && Object.hasOwn(v, "inlineBody");
|
|
438
|
-
if (!required || Object.keys(v).length !== required.length + 2 + Number(inline) || !required.every((k) => Object.hasOwn(v, k)))
|
|
439
|
-
|
|
388
|
+
if (!required || Object.keys(v).length !== required.length + 2 + Number(inline) || !required.every((k) => Object.hasOwn(v, k)))
|
|
389
|
+
return false;
|
|
390
|
+
if (inline && (v.hasBody !== true || typeof v.inlineBody !== "string" || new TextEncoder().encode(v.inlineBody).byteLength > FETCH_INLINE_BODY_BYTES))
|
|
391
|
+
return false;
|
|
440
392
|
const id3 = (x) => typeof x === "string" && x.length > 0 && x.length <= 128;
|
|
441
393
|
if (v.type === "fetch-close") return id3(v.connectionId);
|
|
442
394
|
if (!id3(v.id)) return false;
|
|
443
|
-
if (v.type === "fetch-consumed")
|
|
444
|
-
|
|
445
|
-
if (
|
|
395
|
+
if (v.type === "fetch-consumed")
|
|
396
|
+
return v.direction === "download" && Number.isSafeInteger(v.sequence) && v.sequence >= 0;
|
|
397
|
+
if (["fetch-chunk", "fetch-credit", "fetch-end"].includes(v.type) && (!["upload", "download"].includes(v.direction) || !Number.isSafeInteger(v.sequence) || v.sequence < 0))
|
|
398
|
+
return false;
|
|
399
|
+
if (v.type === "fetch-credit")
|
|
400
|
+
return Number.isInteger(v.chunks) && v.chunks > 0 && v.chunks <= FETCH_WINDOW_CHUNKS && v.bytes === v.chunks * FETCH_CHUNK_BYTES;
|
|
446
401
|
if (v.type === "fetch-chunk") return v.bytes instanceof Uint8Array;
|
|
447
402
|
if (v.type === "fetch-error") return isAppHostErrorInfo(v.error);
|
|
448
403
|
if (v.type === "fetch-open" || v.type === "fetch-headers") {
|
|
449
|
-
if (!Array.isArray(v.headers) || !v.headers.every(
|
|
450
|
-
|
|
404
|
+
if (!Array.isArray(v.headers) || !v.headers.every(
|
|
405
|
+
(h) => Array.isArray(h) && h.length === 2 && h.every((x) => typeof x === "string")
|
|
406
|
+
) || typeof v.hasBody !== "boolean")
|
|
407
|
+
return false;
|
|
408
|
+
if (v.type === "fetch-open")
|
|
409
|
+
return id3(v.connectionId) && typeof v.url === "string" && typeof v.method === "string" && /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(v.method);
|
|
451
410
|
return Number.isInteger(v.status) && v.status >= 200 && v.status <= 599 && typeof v.statusText === "string";
|
|
452
411
|
}
|
|
453
412
|
return true;
|
|
@@ -455,14 +414,16 @@ function isPageFetchFrame(value) {
|
|
|
455
414
|
function pageFetchPath(baseUrl, input) {
|
|
456
415
|
if (/[\\\s#]/.test(input)) throw new TypeError("Invalid fetch URL");
|
|
457
416
|
const rawPath = input.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]+/, "").split("?")[0];
|
|
458
|
-
if (rawPath.includes("//") || /%(?:2e|2f|5c|25)/i.test(rawPath) || rawPath.split("/").some((p) => p === "." || p === "..") || /[\u0000-\u001f\u007f]/.test(decodeURIComponent(rawPath)))
|
|
417
|
+
if (rawPath.includes("//") || /%(?:2e|2f|5c|25)/i.test(rawPath) || rawPath.split("/").some((p) => p === "." || p === "..") || /[\u0000-\u001f\u007f]/.test(decodeURIComponent(rawPath)))
|
|
418
|
+
throw new TypeError("Ambiguous fetch path");
|
|
459
419
|
const base = new URL(baseUrl), url = new URL(input);
|
|
460
|
-
if (base.protocol !== "https:" || base.hostname !== "app-host.invalid" || base.username || base.password || base.search || base.hash || url.origin !== base.origin || url.username || url.password || url.hash || url.pathname !== base.pathname && !url.pathname.startsWith(base.pathname + "/"))
|
|
420
|
+
if (base.protocol !== "https:" || base.hostname !== "app-host.invalid" || base.username || base.password || base.search || base.hash || url.origin !== base.origin || url.username || url.password || url.hash || url.pathname !== base.pathname && !url.pathname.startsWith(base.pathname + "/"))
|
|
421
|
+
throw new TypeError("Fetch target mismatch");
|
|
461
422
|
return (url.pathname.slice(base.pathname.length) || "/") + url.search;
|
|
462
423
|
}
|
|
463
424
|
|
|
464
425
|
// ../domain-contracts/src/app-host/service-host-protocol.ts
|
|
465
|
-
var SERVICE_HOST_METHODS = ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.
|
|
426
|
+
var SERVICE_HOST_METHODS = ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.getConnection", "agent.resolveSkills", "sessions.getConnection", "workspace.gitStatus", "workspace.createTaskWorktree", "workspace.getWorktree", "workspace.releaseExecutionRoot", "work.list", "work.get"];
|
|
466
427
|
var SERVICE_HOST_MAX_FRAME_BYTES = 512 * 1024;
|
|
467
428
|
var SERVICE_HOST_MAX_PENDING = 64;
|
|
468
429
|
var validServiceContext = (v) => json(v) && object({ protocolVersion: enumeration(1), registrationId: id, instanceId: id, dataScopeId: text(256), scope: object({ appId: text(256), installationId: id, contentDigest: digest }), installationRevision: count, phase: enumeration("starting", "ready") })(v);
|
|
@@ -471,7 +432,6 @@ var worktreeReceipt = object({ requestId: id, state: enumeration("accepted", "co
|
|
|
471
432
|
function validServiceHostInput(method, v) {
|
|
472
433
|
if (!json(v)) return false;
|
|
473
434
|
if (method.startsWith("agent.")) return validAgentInput(method, v);
|
|
474
|
-
if (["sessions.getControls", "sessions.getControlResult"].includes(method)) return validSessionControlInput(method, v) && (method !== "sessions.getControlResult" || object({ connectionId: text(256), requestId: id, sessionId: text(), original: () => true })(v));
|
|
475
435
|
switch (method) {
|
|
476
436
|
case "secrets.get":
|
|
477
437
|
case "secrets.delete":
|
|
@@ -502,7 +462,6 @@ function validServiceHostInput(method, v) {
|
|
|
502
462
|
function validServiceHostResult(method, v) {
|
|
503
463
|
if (!json(v)) return false;
|
|
504
464
|
if (method.startsWith("agent.")) return validAgentResult(method, v);
|
|
505
|
-
if (["sessions.getControls", "sessions.getControlResult"].includes(method)) return validSessionControlResult(method, v);
|
|
506
465
|
switch (method) {
|
|
507
466
|
case "secrets.get":
|
|
508
467
|
return v === null || text(16384)(v);
|
|
@@ -556,7 +515,7 @@ function isServiceHostFrame(v) {
|
|
|
556
515
|
|
|
557
516
|
// ../domain-contracts/src/app-host/agent-api-policy.ts
|
|
558
517
|
var routes = [
|
|
559
|
-
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+)?|runs)$/, id: "schedules.read" },
|
|
518
|
+
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+(?:\/run|\/runs\/[^/]+)?)?|runs)$/, id: "schedules.read" },
|
|
560
519
|
{ method: "POST", pattern: /^\/schedules\/tasks(?:\/[^/]+\/run)?$/, id: "schedules.create" },
|
|
561
520
|
{ method: "PATCH", pattern: /^\/schedules\/(tasks\/[^/]+|runs\/[^/]+\/read)$/, id: "schedules.update" },
|
|
562
521
|
{ method: "DELETE", pattern: /^\/schedules\/tasks\/[^/]+$/, id: "schedules.delete" },
|
|
@@ -624,6 +583,94 @@ function normalizeAgentApiPath(raw) {
|
|
|
624
583
|
return decoded;
|
|
625
584
|
}
|
|
626
585
|
|
|
586
|
+
// ../domain-contracts/src/app-host/workspace-conversations.ts
|
|
587
|
+
var validWorkspaceConversation = (value) => {
|
|
588
|
+
if (!object(
|
|
589
|
+
{ dataScopeId: text(), requestId: id, sessionId: id, taskLocation: enumeration("current", "worktree"), configuration: json },
|
|
590
|
+
{ workspaceId: id, outsideProject: (v) => v === true, preparationRevision: text() }
|
|
591
|
+
)(value)) return false;
|
|
592
|
+
const input = value;
|
|
593
|
+
return input.workspaceId !== void 0 ? input.outsideProject !== true : input.outsideProject === true && input.taskLocation === "current";
|
|
594
|
+
};
|
|
595
|
+
var sessionText = (value) => typeof value === "string";
|
|
596
|
+
var sessionRecord = object({
|
|
597
|
+
id,
|
|
598
|
+
cwd: sessionText,
|
|
599
|
+
title: sessionText,
|
|
600
|
+
model: sessionText,
|
|
601
|
+
status: enumeration("idle", "running", "closing", "archived", "error"),
|
|
602
|
+
metadata: jsonObject,
|
|
603
|
+
createdAt: count,
|
|
604
|
+
updatedAt: count
|
|
605
|
+
}, {
|
|
606
|
+
storage: enumeration("sqlite", "memory"),
|
|
607
|
+
parentId: sessionText,
|
|
608
|
+
projectId: sessionText,
|
|
609
|
+
cwdRelative: sessionText,
|
|
610
|
+
agent: sessionText,
|
|
611
|
+
archivedAt: count
|
|
612
|
+
});
|
|
613
|
+
var workspaceConversationResult = object({
|
|
614
|
+
dataScopeId: text(),
|
|
615
|
+
sessionId: id,
|
|
616
|
+
requestId: id,
|
|
617
|
+
action: (v) => v === "create-session",
|
|
618
|
+
state: enumeration("prepared", "completed", "unknown")
|
|
619
|
+
}, {
|
|
620
|
+
configuration: json,
|
|
621
|
+
revision: count,
|
|
622
|
+
session: sessionRecord,
|
|
623
|
+
operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
|
|
624
|
+
indexBindingPending: (v) => v === true,
|
|
625
|
+
workspaceId: id,
|
|
626
|
+
executionRoot: id,
|
|
627
|
+
privateSessionId: id,
|
|
628
|
+
worktree: json
|
|
629
|
+
});
|
|
630
|
+
var validWorkspaceConversationResult = (value) => {
|
|
631
|
+
if (!workspaceConversationResult(value)) return false;
|
|
632
|
+
const result = value;
|
|
633
|
+
return !result.session || result.state === "completed" && result.session.id === result.sessionId;
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
// ../domain-contracts/src/app-host/session-controls.ts
|
|
637
|
+
var option = object({ id: text(), name: text() });
|
|
638
|
+
var choices = array(option);
|
|
639
|
+
var effortChoices = array(object({ id: text(1024, true), name: text() }));
|
|
640
|
+
var receiptShape = object({ dataScopeId: text(), sessionId: text(), requestId: id, action: enumeration("fork", "configure", "compact"), state: enumeration("prepared", "created", "completed", "unknown") }, { revision: count, targetSessionId: text() });
|
|
641
|
+
var receipt = receiptShape;
|
|
642
|
+
function validSessionControlOriginal(value) {
|
|
643
|
+
if (!object({ action: text(), body: json })(value)) return false;
|
|
644
|
+
const v = value;
|
|
645
|
+
if (v.action === "compact") return object({ requestId: id, expectedRevision: count })(v.body);
|
|
646
|
+
return v.action === "fork" && object({ requestId: id, id: text() }, { copyHistory: bool, beforeMessageId: text(), afterMessageId: text(), storage: enumeration("sqlite") })(v.body);
|
|
647
|
+
}
|
|
648
|
+
function validSessionControlInput(method, value) {
|
|
649
|
+
if (!json(value)) return false;
|
|
650
|
+
if (method === "sessions.getDraftComposerOptions") {
|
|
651
|
+
if (!object({ source: enumeration("instance") }, { workspaceId: id, outsideProject: bool, roleId: (v2) => v2 === null || text(256)(v2) })(value)) return false;
|
|
652
|
+
const target2 = value;
|
|
653
|
+
return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
|
|
654
|
+
}
|
|
655
|
+
if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
|
|
656
|
+
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
|
|
657
|
+
if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
|
|
658
|
+
if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
|
|
659
|
+
const v = value;
|
|
660
|
+
return v.original.body.requestId === v.requestId && !!v.connectionId;
|
|
661
|
+
}
|
|
662
|
+
function validSessionControlResult(method, value) {
|
|
663
|
+
if (!json(value)) return false;
|
|
664
|
+
if (method === "sessions.getDraftComposerOptions") return object({ source: enumeration("instance"), optionsRevision: text(), skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") }), 128), plugins: array(object({ id: text(), name: text(), agents: array(option, 128) }), 128) })(value);
|
|
665
|
+
if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
|
|
666
|
+
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
|
|
667
|
+
return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
|
|
668
|
+
if (method === "sessions.getControls") return object({ dataScopeId: text(), sessionId: text(), source: enumeration("instance", "auxiliary", "im"), revision: count, optionsRevision: text(), actions: object(Object.fromEntries(["readContext", "configure", "compact", "edit", "fork", "resume", "goalRead", "goalWrite", "goalStop"].map((k) => [k, bool]))), models: choices, roles: choices, efforts: effortChoices, workModes: choices, skills: array(object({ id: text(), name: text(), path: text(4096, true) }, { source: enumeration("bundled", "user", "project", "plugin") })), commands: choices, contexts: choices }, { permissionModes: array(option, 128), appServiceBindings: array(option, 128), plugins: array(object({ id: text(), name: text(), agents: choices })) })(value);
|
|
669
|
+
if (method === "sessions.getControlResult") return value === null || receipt(value);
|
|
670
|
+
if (!receipt(value)) return false;
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
|
|
627
674
|
// ../domain-contracts/src/app-host/workspace.ts
|
|
628
675
|
function fields3(v, required, optional = []) {
|
|
629
676
|
if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) return false;
|
|
@@ -877,28 +924,56 @@ function createAppCommandsApi(rpc) {
|
|
|
877
924
|
}
|
|
878
925
|
|
|
879
926
|
// src/window.ts
|
|
880
|
-
var WINDOW_METHODS = [
|
|
927
|
+
var WINDOW_METHODS = [
|
|
928
|
+
"window.getState",
|
|
929
|
+
"window.checkForUpdates",
|
|
930
|
+
"window.minimize",
|
|
931
|
+
"window.toggleMaximize",
|
|
932
|
+
"window.requestClose",
|
|
933
|
+
"window.openHost",
|
|
934
|
+
"window.reportStartup"
|
|
935
|
+
];
|
|
881
936
|
var finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
882
937
|
var material = object({
|
|
883
938
|
preference: enumeration("glass", "opaque"),
|
|
884
939
|
active: enumeration("glass", "opaque"),
|
|
885
940
|
shell: enumeration("solid", "translucent", "transparent"),
|
|
886
|
-
unavailableReason: nullable(
|
|
941
|
+
unavailableReason: nullable(
|
|
942
|
+
enumeration(
|
|
943
|
+
"unsupported-platform",
|
|
944
|
+
"unsupported-system",
|
|
945
|
+
"reduced-transparency",
|
|
946
|
+
"material-error"
|
|
947
|
+
)
|
|
948
|
+
)
|
|
887
949
|
});
|
|
888
|
-
var
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
950
|
+
var validUpdateState = (value) => object({ status: enumeration("idle", "checking", "error") })(value) || object({
|
|
951
|
+
status: enumeration("available", "downloaded"),
|
|
952
|
+
version: text(128)
|
|
953
|
+
})(value) || object({
|
|
954
|
+
status: enumeration("downloading"),
|
|
955
|
+
version: text(128),
|
|
956
|
+
percent: (value2) => finite(value2) && value2 >= 0 && value2 <= 100
|
|
894
957
|
})(value);
|
|
958
|
+
var validAppWindowState = (value) => object(
|
|
959
|
+
{
|
|
960
|
+
platform: enumeration("win32", "darwin", "linux"),
|
|
961
|
+
maximized: bool,
|
|
962
|
+
titleBar: enumeration("host", "custom", "native"),
|
|
963
|
+
trafficLightInset: (value2) => finite(value2) && value2 >= 0,
|
|
964
|
+
material
|
|
965
|
+
},
|
|
966
|
+
{ update: validUpdateState }
|
|
967
|
+
)(value);
|
|
895
968
|
function isWindowMethod(value) {
|
|
896
969
|
return WINDOW_METHODS.includes(value);
|
|
897
970
|
}
|
|
898
971
|
function validWindowInput(method, value) {
|
|
899
972
|
switch (method) {
|
|
900
973
|
case "window.openHost":
|
|
901
|
-
return object({
|
|
974
|
+
return object({
|
|
975
|
+
page: enumeration("manage", "settings", "about", "recovery")
|
|
976
|
+
})(value);
|
|
902
977
|
case "window.reportStartup":
|
|
903
978
|
return object({ status: enumeration("ready") })(value) || object({ status: enumeration("failed"), message: text(2048) })(value);
|
|
904
979
|
default:
|
|
@@ -909,20 +984,29 @@ function validWindowResult(method, value) {
|
|
|
909
984
|
switch (method) {
|
|
910
985
|
case "window.getState":
|
|
911
986
|
return validAppWindowState(value);
|
|
987
|
+
case "window.checkForUpdates":
|
|
988
|
+
return validUpdateState(value) || object({ status: enumeration("unsupported") })(value);
|
|
912
989
|
default:
|
|
913
990
|
return value === void 0;
|
|
914
991
|
}
|
|
915
992
|
}
|
|
916
993
|
function validWindowEvent(value) {
|
|
917
|
-
return object({
|
|
994
|
+
return object({
|
|
995
|
+
type: enumeration("window-state-changed"),
|
|
996
|
+
state: validAppWindowState
|
|
997
|
+
})(value);
|
|
918
998
|
}
|
|
919
999
|
function createAppWindowApi(requester) {
|
|
920
1000
|
async function send(method, params) {
|
|
921
1001
|
requester.requireFeature();
|
|
922
|
-
if (
|
|
1002
|
+
if (method === "window.checkForUpdates")
|
|
1003
|
+
requester.requireFeature("window-update-check-v1");
|
|
1004
|
+
if (!validWindowInput(method, params))
|
|
1005
|
+
throw new AppHostError("invalid_request");
|
|
923
1006
|
return requester.request(method, params);
|
|
924
1007
|
}
|
|
925
1008
|
return {
|
|
1009
|
+
checkForUpdates: () => send("window.checkForUpdates", {}),
|
|
926
1010
|
getState: () => send("window.getState", {}),
|
|
927
1011
|
minimize: () => send("window.minimize", {}),
|
|
928
1012
|
toggleMaximize: () => send("window.toggleMaximize", {}),
|
|
@@ -931,7 +1015,8 @@ function createAppWindowApi(requester) {
|
|
|
931
1015
|
reportStartup: (input) => send("window.reportStartup", input),
|
|
932
1016
|
onStateChanged: (listener) => {
|
|
933
1017
|
requester.requireFeature();
|
|
934
|
-
if (typeof listener !== "function")
|
|
1018
|
+
if (typeof listener !== "function")
|
|
1019
|
+
throw new AppHostError("invalid_request");
|
|
935
1020
|
return requester.onEvent((event) => {
|
|
936
1021
|
if (event.type === "window-state-changed") listener(event.state);
|
|
937
1022
|
});
|
|
@@ -1081,7 +1166,6 @@ var rules = {
|
|
|
1081
1166
|
"desktop.browser.addAnnotation": { input: object({ ...page, selectionId: text(), comment: text(65536, true) }), result: validBrowserSnapshot },
|
|
1082
1167
|
"desktop.browser.focusAnnotation": { input: object({ ...page, annotationId: text() }), result: validBrowserSnapshot },
|
|
1083
1168
|
"desktop.browser.removeAnnotation": { input: object({ ...page, annotationId: text() }), result: validBrowserSnapshot },
|
|
1084
|
-
"desktop.browser.capture": { input: object(page), result: object({ assetId: text(), sha256: digest, mediaType: text(256), byteLength: count, width: positive, height: positive }) },
|
|
1085
1169
|
"desktop.browser.capturePreview": { input: object(page), result: object({ bytes: capturePreviewBytes, width: positive, height: positive }) },
|
|
1086
1170
|
"desktop.pluginApps.catalog": { input: object(target), result: object({ backends: array(object({ pluginId: text(), pluginVersion: text(), pluginDigest: text(), definitionDigest: text(), backendId: text(), backendKind: enumeration("native-tools", "mcp-server"), surfaces: array(object({ id: text(), title: text(), backend: text(), resourceUri: text(8192), availability: enumeration("session") })) })) }) },
|
|
1087
1171
|
"desktop.pluginApps.composerContext": { input: object({ ...target, contextIds: array(id, 8) }), result: array(object({ source, lease: object({ token: text(), backendGeneration: text() }), requestId: id, expectedRevision: count, text: text(8 * 1024 * 1024, true), data: json }), 8) },
|
|
@@ -1249,6 +1333,13 @@ var selection2 = object({ cwd: text(4096), selectionId: text(256) });
|
|
|
1249
1333
|
var cancel = object({ selectionId: text(256) });
|
|
1250
1334
|
var name = object({ name: text(256) });
|
|
1251
1335
|
var login = object({ loginId: text(256) });
|
|
1336
|
+
var skillSelection = { id: text(64), version: text(32), sha256: digest };
|
|
1337
|
+
var personalSkillInstall = object({ ...skillSelection, scope: enumeration("personal") });
|
|
1338
|
+
var projectSkillInstall = object({
|
|
1339
|
+
...skillSelection,
|
|
1340
|
+
scope: enumeration("project"),
|
|
1341
|
+
projectPath: (value) => typeof value === "string" && value.trim().length > 0 && text(4096)(value)
|
|
1342
|
+
});
|
|
1252
1343
|
var EXTENSION_INPUTS = {
|
|
1253
1344
|
context: empty,
|
|
1254
1345
|
"plugins.loadIcon": object({ src: text(8192) }),
|
|
@@ -1273,6 +1364,8 @@ var EXTENSION_INPUTS = {
|
|
|
1273
1364
|
"plugins.marketplaceOperation": object({ cwd: text(4096), operationId: text(256) }),
|
|
1274
1365
|
"skills.snapshot": object({ projectPath: text(4096) }),
|
|
1275
1366
|
"skills.remove": object({ id: text(4096), expectedContent: text(8 * 1024 * 1024, true), projectPath: text(4096) }),
|
|
1367
|
+
"skills.marketplaceCatalog": empty,
|
|
1368
|
+
"skills.marketplaceInstall": (value) => personalSkillInstall(value) || projectSkillInstall(value),
|
|
1276
1369
|
"mcp.snapshot": empty,
|
|
1277
1370
|
"mcp.exportConfig": empty,
|
|
1278
1371
|
"mcp.getConfig": name,
|
|
@@ -1336,7 +1429,7 @@ var customProvider = object({
|
|
|
1336
1429
|
models: array(object({ id: text(1024), displayName: text(1024) }, { imageInputSupport, ...limits }), 16384)
|
|
1337
1430
|
}, { apiKey: text(8192), headers, secretHeaders });
|
|
1338
1431
|
function validModelProviderRequest(value) {
|
|
1339
|
-
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"), 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);
|
|
1432
|
+
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);
|
|
1340
1433
|
}
|
|
1341
1434
|
var validModel = object({ id: text(1024), label: text(1024) }, { imageInputSupport, declaredLimits: object({}, limits) });
|
|
1342
1435
|
var validConnection2 = object({
|
|
@@ -1434,7 +1527,6 @@ var SYSTEM_METHODS = [
|
|
|
1434
1527
|
"system.setWindowMaterial",
|
|
1435
1528
|
"system.copyText",
|
|
1436
1529
|
"system.openExternal",
|
|
1437
|
-
"system.markSessionRead",
|
|
1438
1530
|
"system.navigationReady",
|
|
1439
1531
|
"system.completeNavigation"
|
|
1440
1532
|
];
|
|
@@ -1554,12 +1646,6 @@ function validSystemInput(method, value) {
|
|
|
1554
1646
|
page: enumeration("session-settings"),
|
|
1555
1647
|
target: validSessionSettingsTarget
|
|
1556
1648
|
})(value);
|
|
1557
|
-
case "system.markSessionRead":
|
|
1558
|
-
return object({
|
|
1559
|
-
connectionId: text(256),
|
|
1560
|
-
sessionId: text(256),
|
|
1561
|
-
throughSeq: count
|
|
1562
|
-
})(value);
|
|
1563
1649
|
case "system.completeNavigation":
|
|
1564
1650
|
return object({
|
|
1565
1651
|
id: text(256),
|
|
@@ -1646,11 +1732,6 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1646
1732
|
setWindowMaterial: (preference) => send("system.setWindowMaterial", { preference }),
|
|
1647
1733
|
copyText: (text3) => send("system.copyText", { text: text3 }),
|
|
1648
1734
|
openExternal: (url) => send("system.openExternal", { url }),
|
|
1649
|
-
markSessionRead: ({ connection, sessionId, throughSeq }) => send("system.markSessionRead", {
|
|
1650
|
-
connectionId: resolveClientConnection(connection, connectionOwner),
|
|
1651
|
-
sessionId,
|
|
1652
|
-
throughSeq
|
|
1653
|
-
}),
|
|
1654
1735
|
navigationReady: () => send("system.navigationReady", {}),
|
|
1655
1736
|
completeNavigation: (input) => send("system.completeNavigation", input)
|
|
1656
1737
|
};
|
|
@@ -1666,10 +1747,9 @@ function resourceFields(v, required, optional = []) {
|
|
|
1666
1747
|
}
|
|
1667
1748
|
var str2 = (v, max = 256) => typeof v === "string" && v.length > 0 && v.length <= max;
|
|
1668
1749
|
function validSessionResourceInput(method, v) {
|
|
1669
|
-
|
|
1670
|
-
return resourceFields(v, ["dataScopeId", "sessionId"]) && str2(v.dataScopeId) && str2(v.sessionId);
|
|
1750
|
+
return method === "sessions.getConnection" && resourceFields(v, []);
|
|
1671
1751
|
}
|
|
1672
|
-
function validSessionResourceResult(
|
|
1752
|
+
function validSessionResourceResult(_method, v) {
|
|
1673
1753
|
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}`;
|
|
1674
1754
|
}
|
|
1675
1755
|
|