@bobannomi/app-host 0.1.0 → 0.2.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/README.md +16 -11
- package/dist/index.d.ts +314 -206
- package/dist/index.js +689 -282
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +297 -357
- package/dist/protocol.js +328 -315
- package/dist/protocol.js.map +3 -3
- package/package.json +4 -9
- package/dist/node/service-host.d.ts +0 -1418
- package/dist/node/service-host.js +0 -1379
- package/dist/node/service-host.js.map +0 -6
package/dist/protocol.js
CHANGED
|
@@ -19,7 +19,9 @@ var APP_HOST_ERROR_RETRY = {
|
|
|
19
19
|
root_changed: "never",
|
|
20
20
|
resource_revision_conflict: "query",
|
|
21
21
|
request_conflict: "never",
|
|
22
|
-
cursor_stale: "query"
|
|
22
|
+
cursor_stale: "query",
|
|
23
|
+
model_provider_not_configured: "never",
|
|
24
|
+
model_not_configured: "never"
|
|
23
25
|
};
|
|
24
26
|
var HOST_REQUEST_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
25
27
|
function isSafeErrorDetails(value, depth = 0) {
|
|
@@ -45,6 +47,8 @@ function isAppHostErrorInfo(value) {
|
|
|
45
47
|
}
|
|
46
48
|
function appHostErrorMessage(code, details) {
|
|
47
49
|
const reason = details && typeof details === "object" && !Array.isArray(details) ? details.reason : void 0;
|
|
50
|
+
if (code === "model_provider_not_configured") return "\u8BF7\u5148\u914D\u7F6E\u6240\u9009\u4F9B\u5E94\u5546\u7684\u8FDE\u63A5\u3002";
|
|
51
|
+
if (code === "model_not_configured") return "\u8BF7\u5728\u4F9B\u5E94\u5546\u914D\u7F6E\u4E2D\u4FDD\u5B58\u6240\u9009\u6A21\u578B\u3002";
|
|
48
52
|
if (code === "host_unavailable") {
|
|
49
53
|
switch (reason) {
|
|
50
54
|
case "host_port_timeout":
|
|
@@ -61,6 +65,18 @@ function appHostErrorMessage(code, details) {
|
|
|
61
65
|
return "The desktop host could not reconnect services for this page.";
|
|
62
66
|
case "host_access_check_failed":
|
|
63
67
|
return "The desktop host could not verify access for this page.";
|
|
68
|
+
case "skill_marketplace_unavailable":
|
|
69
|
+
return "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B98\u65B9\u6280\u80FD\u5E02\u573A\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
70
|
+
case "skill_marketplace_install_failed":
|
|
71
|
+
return "\u6280\u80FD\u5B89\u88C5\u6216\u66F4\u65B0\u672A\u5B8C\u6210\uFF0C\u8BF7\u5237\u65B0\u5DF2\u5B89\u88C5\u6280\u80FD\u540E\u91CD\u8BD5\u3002";
|
|
72
|
+
case "skill_marketplace_busy":
|
|
73
|
+
return "\u540E\u53F0\u6B63\u5728\u8FD0\u884C\u4EFB\u52A1\u6216\u5904\u7406\u6280\u80FD\u53D8\u66F4\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
|
|
74
|
+
case "skill_marketplace_local_conflict":
|
|
75
|
+
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";
|
|
76
|
+
case "skill_marketplace_selection_changed":
|
|
77
|
+
return "\u6240\u9009\u6280\u80FD\u6216\u7248\u672C\u5DF2\u53D8\u5316\uFF0C\u8BF7\u5237\u65B0\u6280\u80FD\u5E02\u573A\u540E\u91CD\u8BD5\u3002";
|
|
78
|
+
case "skill_marketplace_project_unavailable":
|
|
79
|
+
return "\u5F53\u524D\u9879\u76EE\u65E0\u6CD5\u5B89\u88C5\u6280\u80FD\uFF0C\u8BF7\u9009\u62E9\u5DF2\u767B\u8BB0\u7684\u9879\u76EE\u3002";
|
|
64
80
|
default:
|
|
65
81
|
return "The desktop host could not complete the operation.";
|
|
66
82
|
}
|
|
@@ -102,7 +118,7 @@ var AppHostError = class extends Error {
|
|
|
102
118
|
};
|
|
103
119
|
|
|
104
120
|
// ../domain-contracts/src/app-host/wire-validation.ts
|
|
105
|
-
var text = (max = 1024,
|
|
121
|
+
var text = (max = 1024, empty3 = false) => (v) => typeof v === "string" && (empty3 || v.length > 0) && new TextEncoder().encode(v).byteLength <= max;
|
|
106
122
|
var id = (v) => typeof v === "string" && HOST_REQUEST_ID.test(v);
|
|
107
123
|
var count = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
|
|
108
124
|
var bool = (v) => typeof v === "boolean";
|
|
@@ -171,126 +187,32 @@ function validConnection(v) {
|
|
|
171
187
|
return wireConnection(v) && /^[A-Za-z0-9-]+$/.test(v.connectionId) && v.baseUrl === `https://app-host.invalid/connections/${v.connectionId}`;
|
|
172
188
|
}
|
|
173
189
|
|
|
174
|
-
// ../domain-contracts/src/app-host/agent.ts
|
|
175
|
-
function fields(value, required, optional = []) {
|
|
176
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
177
|
-
return false;
|
|
178
|
-
return required.every((key) => Object.hasOwn(value, key)) && Reflect.ownKeys(value).every((key) => {
|
|
179
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
180
|
-
return typeof key === "string" && [...required, ...optional].includes(key) && descriptor.enumerable && Object.hasOwn(descriptor, "value");
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
var text2 = (value) => typeof value === "string" && value.trim().length > 0;
|
|
184
|
-
var workspaceId = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
185
|
-
function rows(value, check) {
|
|
186
|
-
return Array.isArray(value) && value.length <= 1024 && value.every(check);
|
|
187
|
-
}
|
|
188
|
-
function validAgentInput(method, value) {
|
|
189
|
-
if (!json(value)) return false;
|
|
190
|
-
if (method === "agent.listModels") return fields(value, []);
|
|
191
|
-
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
|
-
if (method !== "agent.getConnection" || !fields(value, [], ["workspaceId", "executionRoot", "privateSessionId"])) return false;
|
|
193
|
-
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"));
|
|
194
|
-
}
|
|
195
|
-
function validAgentResult(method, value) {
|
|
196
|
-
if (!json(value)) return false;
|
|
197
|
-
switch (method) {
|
|
198
|
-
case "agent.getConnection":
|
|
199
|
-
return fields(value, ["connectionId", "baseUrl"], ["cwd", "defaultTaskLocation"]) && (!Object.hasOwn(value, "defaultTaskLocation") || value.defaultTaskLocation === "current" || value.defaultTaskLocation === "worktree") && (!Object.hasOwn(value, "cwd") || text2(value.cwd)) && text2(value.connectionId) && value.baseUrl === `https://app-host.invalid/connections/${value.connectionId}` && /^[A-Za-z0-9-]+$/.test(value.connectionId);
|
|
200
|
-
case "agent.listModels":
|
|
201
|
-
return rows(
|
|
202
|
-
value,
|
|
203
|
-
(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
|
-
);
|
|
205
|
-
case "agent.resolveSkills":
|
|
206
|
-
return rows(
|
|
207
|
-
value,
|
|
208
|
-
(row) => fields(row, ["type", "name", "path"]) && row.type === "skill" && text2(row.name) && text2(row.path)
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// ../domain-contracts/src/app-host/service.ts
|
|
215
|
-
function fields2(value, required, optional = []) {
|
|
216
|
-
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
217
|
-
return false;
|
|
218
|
-
return required.every((k) => Object.hasOwn(value, k)) && Reflect.ownKeys(value).every((k) => {
|
|
219
|
-
const d = Object.getOwnPropertyDescriptor(value, k);
|
|
220
|
-
return typeof k === "string" && [...required, ...optional].includes(k) && d.enumerable && Object.hasOwn(d, "value");
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
var version = (v) => typeof v === "string" && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/.test(
|
|
224
|
-
v
|
|
225
|
-
);
|
|
226
|
-
function json2(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
|
|
227
|
-
if (depth > 100) return false;
|
|
228
|
-
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
229
|
-
return true;
|
|
230
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
231
|
-
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
232
|
-
const array2 = Array.isArray(value);
|
|
233
|
-
if (array2 ? Object.getPrototypeOf(value) !== Array.prototype || Reflect.ownKeys(value).length !== value.length + 1 : ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
234
|
-
return false;
|
|
235
|
-
ancestors.add(value);
|
|
236
|
-
const result = Reflect.ownKeys(value).every((k) => {
|
|
237
|
-
if (array2 && k === "length") return true;
|
|
238
|
-
const d = Object.getOwnPropertyDescriptor(value, k);
|
|
239
|
-
return typeof k === "string" && (!array2 || /^(0|[1-9]\d*)$/.test(k) && Number(k) < value.length) && d.enumerable && Object.hasOwn(d, "value") && json2(d.value, ancestors, depth + 1);
|
|
240
|
-
});
|
|
241
|
-
ancestors.delete(value);
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
function validServiceStatus(value) {
|
|
245
|
-
return fields2(value, ["state"], ["reason", "instanceId", "apiVersion"]) && [
|
|
246
|
-
"absent",
|
|
247
|
-
"unauthorized",
|
|
248
|
-
"stopped",
|
|
249
|
-
"starting",
|
|
250
|
-
"recovering",
|
|
251
|
-
"ready",
|
|
252
|
-
"failed"
|
|
253
|
-
].includes(value.state) && (!Object.hasOwn(value, "reason") || [
|
|
254
|
-
"dependency_missing",
|
|
255
|
-
"service_start_failed",
|
|
256
|
-
"service_unavailable",
|
|
257
|
-
"result_unknown",
|
|
258
|
-
"incompatible",
|
|
259
|
-
"revoked"
|
|
260
|
-
].includes(value.reason)) && (!Object.hasOwn(value, "instanceId") || typeof value.instanceId === "string" && HOST_REQUEST_ID.test(value.instanceId)) && (!Object.hasOwn(value, "apiVersion") || version(value.apiVersion)) && (value.state !== "ready" || Object.hasOwn(value, "instanceId") && Object.hasOwn(value, "apiVersion"));
|
|
261
|
-
}
|
|
262
|
-
function validWork(value) {
|
|
263
|
-
return fields2(value, ["requestId", "state", "updatedAt"], ["result", "error"]) && typeof value.requestId === "string" && HOST_REQUEST_ID.test(value.requestId) && [
|
|
264
|
-
"not_accepted",
|
|
265
|
-
"accepted",
|
|
266
|
-
"running",
|
|
267
|
-
"completed",
|
|
268
|
-
"failed",
|
|
269
|
-
"interrupted",
|
|
270
|
-
"unknown"
|
|
271
|
-
].includes(value.state) && typeof value.updatedAt === "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/.test(
|
|
272
|
-
value.updatedAt
|
|
273
|
-
) && Number.isFinite(Date.parse(value.updatedAt)) && ["result", "error"].every(
|
|
274
|
-
(k) => !Object.hasOwn(value, k) || json2(value[k]) && new TextEncoder().encode(JSON.stringify(value[k])).length <= 16384
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
function validServiceResult(method, value) {
|
|
278
|
-
switch (method) {
|
|
279
|
-
case "service.getStatus":
|
|
280
|
-
return validServiceStatus(value);
|
|
281
|
-
case "service.getConnection":
|
|
282
|
-
return fields2(value, ["connectionId", "baseUrl", "apiVersion"]) && typeof value.connectionId === "string" && /^[A-Za-z0-9-]+$/.test(value.connectionId) && value.baseUrl === `https://app-host.invalid/connections/${value.connectionId}` && version(value.apiVersion);
|
|
283
|
-
case "service.getWork":
|
|
284
|
-
return validWork(value);
|
|
285
|
-
case "service.listWork":
|
|
286
|
-
return Array.isArray(value) && value.length <= 5120 && value.every(validWork) && new Set(value.map((w) => w.requestId)).size === value.length;
|
|
287
|
-
case "service.interruptWork":
|
|
288
|
-
return fields2(value, ["requested"]) && typeof value.requested === "boolean";
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
190
|
// ../domain-contracts/src/app-host/fetch.ts
|
|
293
|
-
var APP_HOST_FEATURES = [
|
|
191
|
+
var APP_HOST_FEATURES = [
|
|
192
|
+
"fetch-v1",
|
|
193
|
+
"fetch-inline-body-v1",
|
|
194
|
+
"fetch-target-close-v1",
|
|
195
|
+
"service-v1",
|
|
196
|
+
"extended-errors-v1",
|
|
197
|
+
"workspace-v1",
|
|
198
|
+
"session-resources-v1",
|
|
199
|
+
"session-controls-v1",
|
|
200
|
+
"conversation-creation-session-v1",
|
|
201
|
+
"trusted-desktop-v1",
|
|
202
|
+
"attachments-v1",
|
|
203
|
+
"auxiliary-sessions-v1",
|
|
204
|
+
"system-ui-v1",
|
|
205
|
+
"lifecycle-v1",
|
|
206
|
+
"commands-v1",
|
|
207
|
+
"resource-catalog-v1",
|
|
208
|
+
"file-content-v1",
|
|
209
|
+
"window-chrome-v1",
|
|
210
|
+
"window-updates-v1",
|
|
211
|
+
"window-update-check-v1",
|
|
212
|
+
"embedded-browser-v1",
|
|
213
|
+
"browser-binding-invalidation-v1",
|
|
214
|
+
"browser-capture-preview-v1"
|
|
215
|
+
];
|
|
294
216
|
var FETCH_CHUNK_BYTES = 64 * 1024;
|
|
295
217
|
var FETCH_INLINE_BODY_BYTES = 8 * 1024;
|
|
296
218
|
var FETCH_WINDOW_CHUNKS = 4;
|
|
@@ -303,7 +225,10 @@ function isPageFetchFrame(value) {
|
|
|
303
225
|
const visit = (entry, depth, binary = false) => {
|
|
304
226
|
if (depth > 10) return false;
|
|
305
227
|
if (entry instanceof Uint8Array) {
|
|
306
|
-
if (!binary || Object.getPrototypeOf(entry) !== Uint8Array.prototype || ["buffer", "byteLength", "byteOffset", "length"].some(
|
|
228
|
+
if (!binary || Object.getPrototypeOf(entry) !== Uint8Array.prototype || ["buffer", "byteLength", "byteOffset", "length"].some(
|
|
229
|
+
(key) => Object.hasOwn(entry, key)
|
|
230
|
+
))
|
|
231
|
+
return false;
|
|
307
232
|
const buffer = entry.buffer;
|
|
308
233
|
return buffer instanceof ArrayBuffer && !Object.hasOwn(buffer, "byteLength") && buffer.byteLength <= FETCH_CHUNK_BYTES && entry.byteLength > 0 && entry.byteLength <= FETCH_CHUNK_BYTES;
|
|
309
234
|
}
|
|
@@ -317,9 +242,11 @@ function isPageFetchFrame(value) {
|
|
|
317
242
|
}
|
|
318
243
|
if (!entry || typeof entry !== "object") return false;
|
|
319
244
|
const array2 = Array.isArray(entry);
|
|
320
|
-
if (array2 ? Object.getPrototypeOf(entry) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
245
|
+
if (array2 ? Object.getPrototypeOf(entry) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
246
|
+
return false;
|
|
321
247
|
const keys = Reflect.ownKeys(entry);
|
|
322
|
-
if (keys.length > FETCH_METADATA_BYTES || array2 && keys.length !== entry.length + 1)
|
|
248
|
+
if (keys.length > FETCH_METADATA_BYTES || array2 && keys.length !== entry.length + 1)
|
|
249
|
+
return false;
|
|
323
250
|
return keys.every((key) => {
|
|
324
251
|
if (array2 && key === "length") return true;
|
|
325
252
|
const d = Object.getOwnPropertyDescriptor(entry, key);
|
|
@@ -327,10 +254,11 @@ function isPageFetchFrame(value) {
|
|
|
327
254
|
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;
|
|
328
255
|
});
|
|
329
256
|
};
|
|
330
|
-
if (!visit(value, 0) || !value || typeof value !== "object" || Array.isArray(value))
|
|
257
|
+
if (!visit(value, 0) || !value || typeof value !== "object" || Array.isArray(value))
|
|
258
|
+
return false;
|
|
331
259
|
const v = value;
|
|
332
260
|
if (v.protocol !== 2 || typeof v.type !== "string") return false;
|
|
333
|
-
const
|
|
261
|
+
const fields2 = {
|
|
334
262
|
"fetch-open": ["id", "connectionId", "url", "method", "headers", "hasBody"],
|
|
335
263
|
"fetch-headers": ["id", "status", "statusText", "headers", "hasBody"],
|
|
336
264
|
"fetch-credit": ["id", "direction", "sequence", "chunks", "bytes"],
|
|
@@ -341,21 +269,30 @@ function isPageFetchFrame(value) {
|
|
|
341
269
|
"fetch-error": ["id", "error"],
|
|
342
270
|
"fetch-close": ["connectionId"]
|
|
343
271
|
};
|
|
344
|
-
const required =
|
|
272
|
+
const required = fields2[v.type];
|
|
345
273
|
const inline = v.type === "fetch-open" && Object.hasOwn(v, "inlineBody");
|
|
346
|
-
if (!required || Object.keys(v).length !== required.length + 2 + Number(inline) || !required.every((k) => Object.hasOwn(v, k)))
|
|
347
|
-
|
|
274
|
+
if (!required || Object.keys(v).length !== required.length + 2 + Number(inline) || !required.every((k) => Object.hasOwn(v, k)))
|
|
275
|
+
return false;
|
|
276
|
+
if (inline && (v.hasBody !== true || typeof v.inlineBody !== "string" || new TextEncoder().encode(v.inlineBody).byteLength > FETCH_INLINE_BODY_BYTES))
|
|
277
|
+
return false;
|
|
348
278
|
const id3 = (x) => typeof x === "string" && x.length > 0 && x.length <= 128;
|
|
349
279
|
if (v.type === "fetch-close") return id3(v.connectionId);
|
|
350
280
|
if (!id3(v.id)) return false;
|
|
351
|
-
if (v.type === "fetch-consumed")
|
|
352
|
-
|
|
353
|
-
if (
|
|
281
|
+
if (v.type === "fetch-consumed")
|
|
282
|
+
return v.direction === "download" && Number.isSafeInteger(v.sequence) && v.sequence >= 0;
|
|
283
|
+
if (["fetch-chunk", "fetch-credit", "fetch-end"].includes(v.type) && (!["upload", "download"].includes(v.direction) || !Number.isSafeInteger(v.sequence) || v.sequence < 0))
|
|
284
|
+
return false;
|
|
285
|
+
if (v.type === "fetch-credit")
|
|
286
|
+
return Number.isInteger(v.chunks) && v.chunks > 0 && v.chunks <= FETCH_WINDOW_CHUNKS && v.bytes === v.chunks * FETCH_CHUNK_BYTES;
|
|
354
287
|
if (v.type === "fetch-chunk") return v.bytes instanceof Uint8Array;
|
|
355
288
|
if (v.type === "fetch-error") return isAppHostErrorInfo(v.error);
|
|
356
289
|
if (v.type === "fetch-open" || v.type === "fetch-headers") {
|
|
357
|
-
if (!Array.isArray(v.headers) || !v.headers.every(
|
|
358
|
-
|
|
290
|
+
if (!Array.isArray(v.headers) || !v.headers.every(
|
|
291
|
+
(h) => Array.isArray(h) && h.length === 2 && h.every((x) => typeof x === "string")
|
|
292
|
+
) || typeof v.hasBody !== "boolean")
|
|
293
|
+
return false;
|
|
294
|
+
if (v.type === "fetch-open")
|
|
295
|
+
return id3(v.connectionId) && typeof v.url === "string" && typeof v.method === "string" && /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(v.method);
|
|
359
296
|
return Number.isInteger(v.status) && v.status >= 200 && v.status <= 599 && typeof v.statusText === "string";
|
|
360
297
|
}
|
|
361
298
|
return true;
|
|
@@ -363,106 +300,17 @@ function isPageFetchFrame(value) {
|
|
|
363
300
|
function pageFetchPath(baseUrl, input) {
|
|
364
301
|
if (/[\\\s#]/.test(input)) throw new TypeError("Invalid fetch URL");
|
|
365
302
|
const rawPath = input.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]+/, "").split("?")[0];
|
|
366
|
-
if (rawPath.includes("//") || /%(?:2e|2f|5c|25)/i.test(rawPath) || rawPath.split("/").some((p) => p === "." || p === "..") || /[\u0000-\u001f\u007f]/.test(decodeURIComponent(rawPath)))
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
// ../domain-contracts/src/app-host/service-host-protocol.ts
|
|
373
|
-
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"];
|
|
374
|
-
var SERVICE_HOST_MAX_FRAME_BYTES = 512 * 1024;
|
|
375
|
-
var SERVICE_HOST_MAX_PENDING = 64;
|
|
376
|
-
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);
|
|
377
|
-
var worktreeBody = { workspaceId: id, expectedHead: text(256), branch: text(1024) };
|
|
378
|
-
var worktreeReceipt = object({ requestId: id, state: enumeration("accepted", "completed", "failed", "unknown") }, { result: object({ executionRoot: id, workspaceId: id, branch: text(1024), sourceHead: text(256) }) });
|
|
379
|
-
function validServiceHostInput(method, v) {
|
|
380
|
-
if (!json(v)) return false;
|
|
381
|
-
if (method.startsWith("agent.")) return validAgentInput(method, v);
|
|
382
|
-
switch (method) {
|
|
383
|
-
case "secrets.get":
|
|
384
|
-
case "secrets.delete":
|
|
385
|
-
return object({ key: (x) => typeof x === "string" && /^[a-zA-Z0-9._:-]{1,128}$/.test(x) })(v);
|
|
386
|
-
case "secrets.set":
|
|
387
|
-
return object({ key: (x) => typeof x === "string" && /^[a-zA-Z0-9._:-]{1,128}$/.test(x), value: text(16384) })(v);
|
|
388
|
-
case "context.get":
|
|
389
|
-
case "work.list":
|
|
390
|
-
return object({})(v);
|
|
391
|
-
case "context.resolveInvocation":
|
|
392
|
-
return object({ ticket: text(8192) })(v);
|
|
393
|
-
case "sessions.getConnection":
|
|
394
|
-
return object({ dataScopeId: text(256), sessionId: text(256) })(v);
|
|
395
|
-
case "workspace.gitStatus":
|
|
396
|
-
return object({ workspaceId: id })(v);
|
|
397
|
-
case "workspace.createTaskWorktree":
|
|
398
|
-
return object({ requestId: id, ...worktreeBody })(v);
|
|
399
|
-
case "workspace.getWorktree":
|
|
400
|
-
return object({ requestId: id, original: object(worktreeBody) })(v);
|
|
401
|
-
case "workspace.releaseExecutionRoot":
|
|
402
|
-
return object({ requestId: id, workspaceId: id, executionRoot: id })(v);
|
|
403
|
-
case "work.get":
|
|
404
|
-
return object({ requestId: id })(v);
|
|
405
|
-
default:
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
function validServiceHostResult(method, v) {
|
|
410
|
-
if (!json(v)) return false;
|
|
411
|
-
if (method.startsWith("agent.")) return validAgentResult(method, v);
|
|
412
|
-
switch (method) {
|
|
413
|
-
case "secrets.get":
|
|
414
|
-
return v === null || text(16384)(v);
|
|
415
|
-
case "secrets.set":
|
|
416
|
-
return object({ stored: enumeration(true) })(v);
|
|
417
|
-
case "secrets.delete":
|
|
418
|
-
return object({ deleted: enumeration(true) })(v);
|
|
419
|
-
case "context.get":
|
|
420
|
-
return validServiceContext(v);
|
|
421
|
-
case "context.resolveInvocation":
|
|
422
|
-
return object({ invocationId: id, dataScopeId: text(256), sessionId: text(256), runId: text(256) }, { inputId: text(256), workspaceId: id, executionRoot: id, privateSessionId: id })(v);
|
|
423
|
-
case "sessions.getConnection":
|
|
424
|
-
return validAgentResult("agent.getConnection", v);
|
|
425
|
-
case "workspace.gitStatus":
|
|
426
|
-
return object({ root: text(32768), commonDir: text(32768), head: text(256), branch: text(1024, true), changes: array(text(32768), 1e4) })(v);
|
|
427
|
-
case "workspace.createTaskWorktree":
|
|
428
|
-
return worktreeReceipt(v);
|
|
429
|
-
case "workspace.getWorktree":
|
|
430
|
-
return v === null || worktreeReceipt(v);
|
|
431
|
-
case "workspace.releaseExecutionRoot":
|
|
432
|
-
return object({ requestId: id, executionRoot: id, state: enumeration("released", "retained-dirty", "in-use", "unknown") })(v);
|
|
433
|
-
case "work.list":
|
|
434
|
-
return validServiceResult("service.listWork", v);
|
|
435
|
-
case "work.get":
|
|
436
|
-
return v === null || validServiceResult("service.getWork", v);
|
|
437
|
-
default:
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
function isServiceHostFrame(v) {
|
|
442
|
-
if (isPageFetchFrame(v)) return true;
|
|
443
|
-
if (!json(v) || new TextEncoder().encode(JSON.stringify(v)).byteLength > SERVICE_HOST_MAX_FRAME_BYTES || !object({ protocol: enumeration(1), type: text(64) }, { id, context: validServiceContext, method: enumeration(...SERVICE_HOST_METHODS), params: json, ok: enumeration(true, false), value: json, error: isAppHostErrorInfo })(v)) return false;
|
|
444
|
-
const frame = v;
|
|
445
|
-
switch (frame.type) {
|
|
446
|
-
case "service-host-connect":
|
|
447
|
-
return object({ protocol: enumeration(1), type: enumeration(frame.type), id })(v);
|
|
448
|
-
case "service-host-ready":
|
|
449
|
-
return object({ protocol: enumeration(1), type: enumeration(frame.type), id, context: validServiceContext })(v);
|
|
450
|
-
case "service-host-context":
|
|
451
|
-
return object({ protocol: enumeration(1), type: enumeration(frame.type), context: validServiceContext })(v);
|
|
452
|
-
case "service-host-close":
|
|
453
|
-
return object({ protocol: enumeration(1), type: enumeration(frame.type) })(v);
|
|
454
|
-
case "service-host-request":
|
|
455
|
-
return object({ protocol: enumeration(1), type: enumeration(frame.type), id, method: enumeration(...SERVICE_HOST_METHODS), params: (x) => validServiceHostInput(frame.method, x) })(v);
|
|
456
|
-
case "service-host-response":
|
|
457
|
-
return frame.ok ? object({ protocol: enumeration(1), type: enumeration(frame.type), id, ok: enumeration(true), value: json })(v) : object({ protocol: enumeration(1), type: enumeration(frame.type), id, ok: enumeration(false), error: isAppHostErrorInfo })(v);
|
|
458
|
-
default:
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
303
|
+
if (rawPath.includes("//") || /%(?:2e|2f|5c|25)/i.test(rawPath) || rawPath.split("/").some((p) => p === "." || p === "..") || /[\u0000-\u001f\u007f]/.test(decodeURIComponent(rawPath)))
|
|
304
|
+
throw new TypeError("Ambiguous fetch path");
|
|
305
|
+
const base = new URL(baseUrl), url2 = new URL(input);
|
|
306
|
+
if (base.protocol !== "https:" || base.hostname !== "app-host.invalid" || base.username || base.password || base.search || base.hash || url2.origin !== base.origin || url2.username || url2.password || url2.hash || url2.pathname !== base.pathname && !url2.pathname.startsWith(base.pathname + "/"))
|
|
307
|
+
throw new TypeError("Fetch target mismatch");
|
|
308
|
+
return (url2.pathname.slice(base.pathname.length) || "/") + url2.search;
|
|
461
309
|
}
|
|
462
310
|
|
|
463
311
|
// ../domain-contracts/src/app-host/agent-api-policy.ts
|
|
464
312
|
var routes = [
|
|
465
|
-
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+)?|runs)$/, id: "schedules.read" },
|
|
313
|
+
{ method: "GET", pattern: /^\/schedules\/(status|tasks(?:\/[^/]+(?:\/run|\/runs\/[^/]+)?)?|runs)$/, id: "schedules.read" },
|
|
466
314
|
{ method: "POST", pattern: /^\/schedules\/tasks(?:\/[^/]+\/run)?$/, id: "schedules.create" },
|
|
467
315
|
{ method: "PATCH", pattern: /^\/schedules\/(tasks\/[^/]+|runs\/[^/]+\/read)$/, id: "schedules.update" },
|
|
468
316
|
{ method: "DELETE", pattern: /^\/schedules\/tasks\/[^/]+$/, id: "schedules.delete" },
|
|
@@ -512,6 +360,7 @@ var routes = [
|
|
|
512
360
|
{ method: "POST", pattern: /^\/jobs\/[^/]+\/cancel$/, id: "jobs.cancel" }
|
|
513
361
|
];
|
|
514
362
|
function matchAgentApiRoute(method, path) {
|
|
363
|
+
if (path === "/attachments/storage") return void 0;
|
|
515
364
|
return routes.find((route) => route.method === method && route.pattern.test(path));
|
|
516
365
|
}
|
|
517
366
|
function normalizeAgentApiPath(raw) {
|
|
@@ -568,7 +417,6 @@ var workspaceConversationResult = object({
|
|
|
568
417
|
revision: count,
|
|
569
418
|
session: sessionRecord,
|
|
570
419
|
operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
|
|
571
|
-
indexBindingPending: (v) => v === true,
|
|
572
420
|
workspaceId: id,
|
|
573
421
|
executionRoot: id,
|
|
574
422
|
privateSessionId: id,
|
|
@@ -599,7 +447,6 @@ function validSessionControlInput(method, value) {
|
|
|
599
447
|
const target2 = value;
|
|
600
448
|
return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
|
|
601
449
|
}
|
|
602
|
-
if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
|
|
603
450
|
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
|
|
604
451
|
if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
|
|
605
452
|
if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
|
|
@@ -609,17 +456,16 @@ function validSessionControlInput(method, value) {
|
|
|
609
456
|
function validSessionControlResult(method, value) {
|
|
610
457
|
if (!json(value)) return false;
|
|
611
458
|
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);
|
|
612
|
-
if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
|
|
613
459
|
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
|
|
614
460
|
return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
|
|
615
|
-
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),
|
|
461
|
+
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), plugins: array(object({ id: text(), name: text(), agents: choices })) })(value);
|
|
616
462
|
if (method === "sessions.getControlResult") return value === null || receipt(value);
|
|
617
463
|
if (!receipt(value)) return false;
|
|
618
464
|
return false;
|
|
619
465
|
}
|
|
620
466
|
|
|
621
467
|
// ../domain-contracts/src/app-host/workspace.ts
|
|
622
|
-
function
|
|
468
|
+
function fields(v, required, optional = []) {
|
|
623
469
|
if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) return false;
|
|
624
470
|
return required.every((k) => Object.hasOwn(v, k)) && Reflect.ownKeys(v).every((k) => {
|
|
625
471
|
const d = Object.getOwnPropertyDescriptor(v, k);
|
|
@@ -628,7 +474,7 @@ function fields3(v, required, optional = []) {
|
|
|
628
474
|
}
|
|
629
475
|
var uuid = (v) => typeof v === "string" && HOST_REQUEST_ID.test(v);
|
|
630
476
|
var str = (v) => typeof v === "string";
|
|
631
|
-
function
|
|
477
|
+
function rows(v, check) {
|
|
632
478
|
if (!Array.isArray(v) || Object.getPrototypeOf(v) !== Array.prototype || v.length > 200 || Reflect.ownKeys(v).length !== v.length + 1) return false;
|
|
633
479
|
for (let i = 0; i < v.length; i++) {
|
|
634
480
|
const d = Object.getOwnPropertyDescriptor(v, String(i));
|
|
@@ -636,18 +482,18 @@ function rows2(v, check) {
|
|
|
636
482
|
}
|
|
637
483
|
return true;
|
|
638
484
|
}
|
|
639
|
-
var ref = (v) =>
|
|
485
|
+
var ref = (v) => fields(v, ["id", "displayName"]) && uuid(v.id) && str(v.displayName) && v.displayName.length > 0;
|
|
640
486
|
function validWorkspaceInput(method, v) {
|
|
641
487
|
switch (method) {
|
|
642
488
|
case "workspace.select":
|
|
643
489
|
case "workspace.getSelection":
|
|
644
|
-
return
|
|
490
|
+
return fields(v, ["requestId"]) && uuid(v.requestId);
|
|
645
491
|
case "workspace.get":
|
|
646
|
-
return
|
|
492
|
+
return fields(v, ["workspaceId"]) && uuid(v.workspaceId);
|
|
647
493
|
case "workspace.listFiles":
|
|
648
|
-
return
|
|
494
|
+
return fields(v, ["workspaceId", "directory"], ["cursor"]) && uuid(v.workspaceId) && str(v.directory) && (!Object.hasOwn(v, "cursor") || uuid(v.cursor));
|
|
649
495
|
case "workspace.readText":
|
|
650
|
-
return
|
|
496
|
+
return fields(v, ["workspaceId", "path"]) && uuid(v.workspaceId) && str(v.path) && v.path.length > 0;
|
|
651
497
|
}
|
|
652
498
|
}
|
|
653
499
|
function validWorkspaceResult(method, v) {
|
|
@@ -657,13 +503,13 @@ function validWorkspaceResult(method, v) {
|
|
|
657
503
|
case "workspace.get":
|
|
658
504
|
return ref(v);
|
|
659
505
|
case "workspace.getSelection":
|
|
660
|
-
if (!
|
|
661
|
-
if (v.status === "completed") return
|
|
662
|
-
return
|
|
506
|
+
if (!fields(v, ["requestId", "status"], ["workspace", "unavailable"]) || !uuid(v.requestId)) return false;
|
|
507
|
+
if (v.status === "completed") return fields(v, ["requestId", "status", "workspace"]) && ref(v.workspace) || fields(v, ["requestId", "status", "unavailable"]) && v.unavailable === true;
|
|
508
|
+
return fields(v, ["requestId", "status"]) && ["pending", "cancelled", "expired", "failed", "unknown"].includes(v.status);
|
|
663
509
|
case "workspace.listFiles":
|
|
664
|
-
return
|
|
510
|
+
return fields(v, ["entries"], ["nextCursor"]) && rows(v.entries, (e) => fields(e, ["path", "name", "kind"]) && str(e.path) && str(e.name) && (e.kind === "file" || e.kind === "directory")) && (!Object.hasOwn(v, "nextCursor") || uuid(v.nextCursor));
|
|
665
511
|
case "workspace.readText":
|
|
666
|
-
return
|
|
512
|
+
return fields(v, ["path", "text", "revision"]) && str(v.path) && v.path.length > 0 && str(v.text) && typeof v.revision === "string" && /^[a-f0-9]{64}$/.test(v.revision);
|
|
667
513
|
}
|
|
668
514
|
}
|
|
669
515
|
|
|
@@ -871,28 +717,56 @@ function createAppCommandsApi(rpc) {
|
|
|
871
717
|
}
|
|
872
718
|
|
|
873
719
|
// src/window.ts
|
|
874
|
-
var WINDOW_METHODS = [
|
|
720
|
+
var WINDOW_METHODS = [
|
|
721
|
+
"window.getState",
|
|
722
|
+
"window.checkForUpdates",
|
|
723
|
+
"window.minimize",
|
|
724
|
+
"window.toggleMaximize",
|
|
725
|
+
"window.requestClose",
|
|
726
|
+
"window.openHost",
|
|
727
|
+
"window.reportStartup"
|
|
728
|
+
];
|
|
875
729
|
var finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
876
730
|
var material = object({
|
|
877
731
|
preference: enumeration("glass", "opaque"),
|
|
878
732
|
active: enumeration("glass", "opaque"),
|
|
879
733
|
shell: enumeration("solid", "translucent", "transparent"),
|
|
880
|
-
unavailableReason: nullable(
|
|
734
|
+
unavailableReason: nullable(
|
|
735
|
+
enumeration(
|
|
736
|
+
"unsupported-platform",
|
|
737
|
+
"unsupported-system",
|
|
738
|
+
"reduced-transparency",
|
|
739
|
+
"material-error"
|
|
740
|
+
)
|
|
741
|
+
)
|
|
881
742
|
});
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
743
|
+
var validUpdateState = (value) => object({ status: enumeration("idle", "checking", "error") })(value) || object({
|
|
744
|
+
status: enumeration("available", "downloaded"),
|
|
745
|
+
version: text(128)
|
|
746
|
+
})(value) || object({
|
|
747
|
+
status: enumeration("downloading"),
|
|
748
|
+
version: text(128),
|
|
749
|
+
percent: (value2) => finite(value2) && value2 >= 0 && value2 <= 100
|
|
888
750
|
})(value);
|
|
751
|
+
var validAppWindowState = (value) => object(
|
|
752
|
+
{
|
|
753
|
+
platform: enumeration("win32", "darwin", "linux"),
|
|
754
|
+
maximized: bool,
|
|
755
|
+
titleBar: enumeration("host", "custom", "native"),
|
|
756
|
+
trafficLightInset: (value2) => finite(value2) && value2 >= 0,
|
|
757
|
+
material
|
|
758
|
+
},
|
|
759
|
+
{ update: validUpdateState }
|
|
760
|
+
)(value);
|
|
889
761
|
function isWindowMethod(value) {
|
|
890
762
|
return WINDOW_METHODS.includes(value);
|
|
891
763
|
}
|
|
892
764
|
function validWindowInput(method, value) {
|
|
893
765
|
switch (method) {
|
|
894
766
|
case "window.openHost":
|
|
895
|
-
return object({
|
|
767
|
+
return object({
|
|
768
|
+
page: enumeration("manage", "settings", "about", "recovery")
|
|
769
|
+
})(value);
|
|
896
770
|
case "window.reportStartup":
|
|
897
771
|
return object({ status: enumeration("ready") })(value) || object({ status: enumeration("failed"), message: text(2048) })(value);
|
|
898
772
|
default:
|
|
@@ -903,20 +777,29 @@ function validWindowResult(method, value) {
|
|
|
903
777
|
switch (method) {
|
|
904
778
|
case "window.getState":
|
|
905
779
|
return validAppWindowState(value);
|
|
780
|
+
case "window.checkForUpdates":
|
|
781
|
+
return validUpdateState(value) || object({ status: enumeration("unsupported") })(value);
|
|
906
782
|
default:
|
|
907
783
|
return value === void 0;
|
|
908
784
|
}
|
|
909
785
|
}
|
|
910
786
|
function validWindowEvent(value) {
|
|
911
|
-
return object({
|
|
787
|
+
return object({
|
|
788
|
+
type: enumeration("window-state-changed"),
|
|
789
|
+
state: validAppWindowState
|
|
790
|
+
})(value);
|
|
912
791
|
}
|
|
913
792
|
function createAppWindowApi(requester) {
|
|
914
793
|
async function send(method, params) {
|
|
915
794
|
requester.requireFeature();
|
|
916
|
-
if (
|
|
795
|
+
if (method === "window.checkForUpdates")
|
|
796
|
+
requester.requireFeature("window-update-check-v1");
|
|
797
|
+
if (!validWindowInput(method, params))
|
|
798
|
+
throw new AppHostError("invalid_request");
|
|
917
799
|
return requester.request(method, params);
|
|
918
800
|
}
|
|
919
801
|
return {
|
|
802
|
+
checkForUpdates: () => send("window.checkForUpdates", {}),
|
|
920
803
|
getState: () => send("window.getState", {}),
|
|
921
804
|
minimize: () => send("window.minimize", {}),
|
|
922
805
|
toggleMaximize: () => send("window.toggleMaximize", {}),
|
|
@@ -925,7 +808,8 @@ function createAppWindowApi(requester) {
|
|
|
925
808
|
reportStartup: (input) => send("window.reportStartup", input),
|
|
926
809
|
onStateChanged: (listener) => {
|
|
927
810
|
requester.requireFeature();
|
|
928
|
-
if (typeof listener !== "function")
|
|
811
|
+
if (typeof listener !== "function")
|
|
812
|
+
throw new AppHostError("invalid_request");
|
|
929
813
|
return requester.onEvent((event) => {
|
|
930
814
|
if (event.type === "window-state-changed") listener(event.state);
|
|
931
815
|
});
|
|
@@ -960,8 +844,7 @@ function createResourceCatalogApi(rpc) {
|
|
|
960
844
|
// src/session-controls.ts
|
|
961
845
|
var CONVERSATION_PREPARATION_METHODS = [
|
|
962
846
|
"sessions.createConversation",
|
|
963
|
-
"sessions.getConversationCreationResult"
|
|
964
|
-
"sessions.bindConversationIndex"
|
|
847
|
+
"sessions.getConversationCreationResult"
|
|
965
848
|
];
|
|
966
849
|
function isConversationPreparationMethod(method) {
|
|
967
850
|
return CONVERSATION_PREPARATION_METHODS.includes(method);
|
|
@@ -996,10 +879,23 @@ function resolveClientConnection(connection, owner) {
|
|
|
996
879
|
|
|
997
880
|
// src/desktop.ts
|
|
998
881
|
var BROWSER_CAPTURE_PREVIEW_MAX_BYTES = 8 * 1024 * 1024;
|
|
882
|
+
var DESKTOP_ADAPTED_METHODS = ["desktop.files.openRead", "desktop.files.getOperation"];
|
|
999
883
|
var target = { targetId: text(256) };
|
|
1000
884
|
var mount = { ...target, mountId: text(256) };
|
|
1001
885
|
var source = object({ sessionId: text(), appId: text() });
|
|
1002
886
|
var action = { ...mount, source, requestId: id, expectedRevision: count };
|
|
887
|
+
var fileWriteBody = { path: text(32768), expectedSha256: digest, text: text(8 * 1024 * 1024, true) };
|
|
888
|
+
var gitBranchBody = { expectedHead: text(), branch: text() };
|
|
889
|
+
var validFileOperationQuery = object({
|
|
890
|
+
...target,
|
|
891
|
+
requestId: id,
|
|
892
|
+
original: object({ kind: enumeration("files.writeText"), body: object(fileWriteBody) })
|
|
893
|
+
});
|
|
894
|
+
var validGitOperationQuery = object({
|
|
895
|
+
...target,
|
|
896
|
+
requestId: id,
|
|
897
|
+
original: object({ kind: enumeration("git.switchBranch", "git.createBranch"), body: object(gitBranchBody) })
|
|
898
|
+
});
|
|
1003
899
|
var page = { ...target, tabId: text(256), pageRevision: count };
|
|
1004
900
|
var mode = enumeration("off", "pick", "review");
|
|
1005
901
|
var voidResult = (v) => v === void 0;
|
|
@@ -1009,7 +905,7 @@ var annotationFields = { target: text(8192), selector: text(8192), locatorKind:
|
|
|
1009
905
|
var validBrowserSnapshot = object({ pageUrl: text(16384, true), pageRevision: count, ready: bool, mode, interactionVersion: count, eventSequence: count, selection: nullable(object({ selectionId: text(), target: object(annotationFields), rect })), focusedAnnotationId: nullable(text()), viewport: nullable(object({ width: finite2, height: finite2 })), annotations: array(object({ record: object({ ...annotationFields, id: text(), pageUrl: text(16384, true), comment: text(65536, true) }), status: enumeration("visible", "offscreen", "missing"), rect: nullable(rect) }), 4096) });
|
|
1010
906
|
var root = object({ path: text(32768), identity: object({ dev: text(), ino: text() }) }, { workspaceId: text() });
|
|
1011
907
|
var validDesktopTarget = object({ id: text(), dataScopeId: text(), draftId: text(), draftRevision: count }, { root, sessionId: text() });
|
|
1012
|
-
var kind = enumeration("files.writeText", "git.switchBranch", "git.createBranch"
|
|
908
|
+
var kind = enumeration("files.writeText", "git.switchBranch", "git.createBranch");
|
|
1013
909
|
var validWorkspaceOperation = object({ requestId: id, kind, state: enumeration("prepared", "running", "completed", "failed", "unknown"), createdAt: count, updatedAt: count }, { result: json, error: object({ code: text(128) }) });
|
|
1014
910
|
var origin = (v) => object({ kind: enumeration("surface"), surfaceId: text() })(v) || object({ kind: enumeration("tool-result"), sourcePartId: text() })(v);
|
|
1015
911
|
var appRecord = object({ id: text(), sessionId: text(), pluginId: text(), pluginVersion: text(), pluginDigest: text(), definitionDigest: text(), backendId: text(), backendKind: enumeration("native-tools", "mcp-server"), resourceUri: text(8192), origin, logicalKey: text(8192), status: enumeration("open", "closed", "revoked"), controlRevision: count, createdAt: count, updatedAt: count }, { activeActionRunId: text(), lastActionRunId: text() });
|
|
@@ -1032,7 +928,7 @@ var rules = {
|
|
|
1032
928
|
"desktop.files.search": { input: object({ ...target, query: text(4096, true) }, { directory: text(32768, true), limit: positive }), result: object({ matches: array(object({ path: text(32768), line: count, text: text(65536, true) }), 1e4), truncated: bool }) },
|
|
1033
929
|
"desktop.files.openRead": { input: object({ ...target, path: text(32768) }), result: validConnection },
|
|
1034
930
|
"desktop.files.readText": { input: object({ ...target, path: text(32768) }), result: object({ path: text(32768), text: text(8 * 1024 * 1024, true), sha256: digest, byteLength: count, encoding: enumeration("utf-8"), truncated: bool }) },
|
|
1035
|
-
"desktop.files.writeText": { input: object({ ...target, requestId: id,
|
|
931
|
+
"desktop.files.writeText": { input: object({ ...target, requestId: id, ...fileWriteBody }), result: validWorkspaceOperation },
|
|
1036
932
|
"desktop.files.getOperation": { input: object({ ...target, requestId: id, original: object({ kind, body: json }) }), result: nullable(validWorkspaceOperation) },
|
|
1037
933
|
"desktop.files.revealPath": { input: object({ ...target, path: text(32768) }), result: voidResult },
|
|
1038
934
|
"desktop.files.listOpeners": { input: object(target), result: array(object({ id: text(256), label: text(1024), kind: enumeration("editor", "folder", "terminal"), iconDataUrl: nullable(text(1024 * 1024)) }, { isDefault: bool }), 256) },
|
|
@@ -1048,9 +944,8 @@ var rules = {
|
|
|
1048
944
|
"desktop.git.listBranches": { input: object(target), result: object({ branches: array(text(1024), 1e4) }) },
|
|
1049
945
|
"desktop.git.changes": { input: object(target, { range: enumeration("uncommitted", "working", "staged"), ignoreWhitespace: bool }), result: object({ files: array(object({ path: text(32768), status: enumeration("added", "modified", "deleted", "renamed", "copied", "untracked"), additions: nullable(count), deletions: nullable(count), binary: bool }, { oldPath: text(32768) }), 1e4), totalAdditions: count, totalDeletions: count }) },
|
|
1050
946
|
"desktop.git.diff": { input: object(target, { path: text(32768), base: text(), head: text(), range: enumeration("uncommitted", "working", "staged"), ignoreWhitespace: bool }), result: object({ text: text(8 * 1024 * 1024, true), truncated: bool }) },
|
|
1051
|
-
"desktop.git.switchBranch": { input: object({ ...target, requestId: id,
|
|
1052
|
-
"desktop.git.createBranch": { input: object({ ...target, requestId: id,
|
|
1053
|
-
"desktop.git.createTaskWorktree": { input: object({ ...target, requestId: id, expectedHead: text(), branch: text() }), result: validWorkspaceOperation },
|
|
947
|
+
"desktop.git.switchBranch": { input: object({ ...target, requestId: id, ...gitBranchBody }), result: validWorkspaceOperation },
|
|
948
|
+
"desktop.git.createBranch": { input: object({ ...target, requestId: id, ...gitBranchBody }), result: validWorkspaceOperation },
|
|
1054
949
|
"desktop.terminals.create": { input: object({ ...target, requestId: id, cols: positive, rows: positive }, { name: text(256) }), result: object({ resourceId: text(), terminalId: text(), cwd: text(32768), status: enumeration("running", "exited") }) },
|
|
1055
950
|
"desktop.terminals.list": { input: object(target), result: array(object({ id: text(), name: text(1024, true), scope: (v) => object({ kind: enumeration("session"), sessionId: text() })(v) || object({ kind: enumeration("project"), projectId: text() })(v), runtime: enumeration("local", "environment"), source: enumeration("user", "agent"), status: enumeration("running", "stopping", "completed", "killed", "failed"), cwd: text(32768), shell: text(32768, true), cols: positive, rows: positive, createdAt: text() }, { projectId: text(), sessionId: text(), environmentKind: enumeration("native", "wsl"), distribution: text(), command: text(65536, true), exitedAt: text(), exitCode: nullable(finite2) }), 1e4) },
|
|
1056
951
|
"desktop.terminals.restart": { input: object({ ...target, terminalId: text(), requestId: id }), result: object({ resourceId: text(), terminalId: text(), cwd: text(32768), status: enumeration("running", "exited") }) },
|
|
@@ -1143,24 +1038,48 @@ function createAppDesktopApi(rpc, owner, filesFeature = () => {
|
|
|
1143
1038
|
if (!validDesktopResultForInput(method, params, value)) throw new AppHostError("host_unavailable");
|
|
1144
1039
|
return value;
|
|
1145
1040
|
};
|
|
1146
|
-
const group = (name2) => Object.fromEntries(DESKTOP_METHODS.filter((
|
|
1147
|
-
|
|
1148
|
-
if (!
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1041
|
+
const group = (name2) => Object.fromEntries(DESKTOP_METHODS.filter((method) => !DESKTOP_ADAPTED_METHODS.includes(method) && method.startsWith(`desktop.${name2}.`)).map((method) => [method.split(".")[2], (params) => call(method, params)]));
|
|
1042
|
+
const getOperation = async (input, validate) => {
|
|
1043
|
+
if (!validate(input)) throw new AppHostError("invalid_request");
|
|
1044
|
+
return call("desktop.files.getOperation", input);
|
|
1045
|
+
};
|
|
1046
|
+
return {
|
|
1047
|
+
bindTarget(input) {
|
|
1048
|
+
if (!object({ draftId: text(), draftRevision: count }, { directory: text(32768), workspaceId: text(), connection: (v) => !!v && typeof v === "object", sessionId: text() })(input)) throw new AppHostError("invalid_request");
|
|
1049
|
+
const { connection, ...rest } = input;
|
|
1050
|
+
return call("desktop.bindTarget", { ...rest, ...connection === void 0 ? {} : { connectionId: resolveClientConnection(connection, owner) } });
|
|
1051
|
+
},
|
|
1052
|
+
releaseTarget: (input) => call("desktop.releaseTarget", input),
|
|
1053
|
+
files: {
|
|
1054
|
+
...group("files"),
|
|
1055
|
+
getOperation: (input) => getOperation(input, validFileOperationQuery),
|
|
1056
|
+
async readFile(input, options = {}) {
|
|
1057
|
+
if (!object({ ...target, path: text(32768) }, { range: object({ start: count }, { end: count }) })(input) || input.range?.end !== void 0 && input.range.end < input.range.start) throw new AppHostError("invalid_request");
|
|
1058
|
+
filesFeature();
|
|
1059
|
+
const { range: range2, ...params } = input;
|
|
1060
|
+
const wire = await call("desktop.files.openRead", params);
|
|
1061
|
+
const fetchFile = owner.fetchFor(wire.connectionId, wire.baseUrl);
|
|
1062
|
+
try {
|
|
1063
|
+
return await fetchFile(wire.baseUrl + "/", {
|
|
1064
|
+
...options.signal ? { signal: options.signal } : {},
|
|
1065
|
+
...range2 ? { headers: { Range: `bytes=${range2.start}-${range2.end ?? ""}` } } : {}
|
|
1066
|
+
});
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
owner.close(wire.connectionId);
|
|
1069
|
+
throw error;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
clipboard: group("clipboard"),
|
|
1074
|
+
git: {
|
|
1075
|
+
...group("git"),
|
|
1076
|
+
getOperation: (input) => getOperation(input, validGitOperationQuery)
|
|
1077
|
+
},
|
|
1078
|
+
terminals: group("terminals"),
|
|
1079
|
+
windows: group("windows"),
|
|
1080
|
+
browser: group("browser"),
|
|
1081
|
+
pluginApps: group("pluginApps")
|
|
1082
|
+
};
|
|
1164
1083
|
}
|
|
1165
1084
|
function canonicalDesktopRequest(value) {
|
|
1166
1085
|
if (!json(value)) throw new AppHostError("invalid_request");
|
|
@@ -1228,10 +1147,18 @@ function createAppAuxiliarySessionsApi(rpc, streams) {
|
|
|
1228
1147
|
const { connection, ...rest } = input;
|
|
1229
1148
|
return { ...rest, connectionId: resolveClientConnection(connection, streams) };
|
|
1230
1149
|
};
|
|
1231
|
-
return {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1150
|
+
return {
|
|
1151
|
+
getOptions: (input) => request("sessions.getAuxiliaryOptions", {
|
|
1152
|
+
sessionId: input.sessionId,
|
|
1153
|
+
connectionId: resolveClientConnection(input.connection, streams)
|
|
1154
|
+
}),
|
|
1155
|
+
async open(input) {
|
|
1156
|
+
const wire = await request("sessions.openAuxiliary", resolve(input));
|
|
1157
|
+
return { leaseId: wire.receipt.leaseId, sessionId: wire.receipt.sessionId, connection: createClientConnection(wire, streams) };
|
|
1158
|
+
},
|
|
1159
|
+
get: (input) => request("sessions.getAuxiliary", resolve(input)),
|
|
1160
|
+
close: (input) => request("sessions.closeAuxiliary", resolve(input))
|
|
1161
|
+
};
|
|
1235
1162
|
}
|
|
1236
1163
|
|
|
1237
1164
|
// src/extensions.ts
|
|
@@ -1242,6 +1169,13 @@ var selection2 = object({ cwd: text(4096), selectionId: text(256) });
|
|
|
1242
1169
|
var cancel = object({ selectionId: text(256) });
|
|
1243
1170
|
var name = object({ name: text(256) });
|
|
1244
1171
|
var login = object({ loginId: text(256) });
|
|
1172
|
+
var skillSelection = { id: text(64), version: text(32), sha256: digest };
|
|
1173
|
+
var personalSkillInstall = object({ ...skillSelection, scope: enumeration("personal") });
|
|
1174
|
+
var projectSkillInstall = object({
|
|
1175
|
+
...skillSelection,
|
|
1176
|
+
scope: enumeration("project"),
|
|
1177
|
+
projectPath: (value) => typeof value === "string" && value.trim().length > 0 && text(4096)(value)
|
|
1178
|
+
});
|
|
1245
1179
|
var EXTENSION_INPUTS = {
|
|
1246
1180
|
context: empty,
|
|
1247
1181
|
"plugins.loadIcon": object({ src: text(8192) }),
|
|
@@ -1266,6 +1200,8 @@ var EXTENSION_INPUTS = {
|
|
|
1266
1200
|
"plugins.marketplaceOperation": object({ cwd: text(4096), operationId: text(256) }),
|
|
1267
1201
|
"skills.snapshot": object({ projectPath: text(4096) }),
|
|
1268
1202
|
"skills.remove": object({ id: text(4096), expectedContent: text(8 * 1024 * 1024, true), projectPath: text(4096) }),
|
|
1203
|
+
"skills.marketplaceCatalog": empty,
|
|
1204
|
+
"skills.marketplaceInstall": (value) => personalSkillInstall(value) || projectSkillInstall(value),
|
|
1269
1205
|
"mcp.snapshot": empty,
|
|
1270
1206
|
"mcp.exportConfig": empty,
|
|
1271
1207
|
"mcp.getConfig": name,
|
|
@@ -1301,12 +1237,94 @@ function validProjectRequest(value) {
|
|
|
1301
1237
|
case "archive":
|
|
1302
1238
|
return object({ action: (v) => v === "archive", ...project })(value);
|
|
1303
1239
|
case "rebind":
|
|
1304
|
-
return object({ action: (v) => v === "rebind", ...
|
|
1240
|
+
return object({ action: (v) => v === "rebind", ...project, previousWorkspaceId: id2, expectedPath: text(32768) })(value);
|
|
1305
1241
|
default:
|
|
1306
1242
|
return false;
|
|
1307
1243
|
}
|
|
1308
1244
|
}
|
|
1309
|
-
var validProjectSnapshot = (value) => object({
|
|
1245
|
+
var validProjectSnapshot = (value) => object({
|
|
1246
|
+
dataScopeId: id2,
|
|
1247
|
+
projects: array(object({ workspaceId: id2, projectId: id2, name: text(1024), path: text(32768), available: bool, lastOpenedAt: count }, {
|
|
1248
|
+
defaultShell: text(4096),
|
|
1249
|
+
rootIdentity: object({ dev: text(32), ino: text(32) })
|
|
1250
|
+
}), 1e4)
|
|
1251
|
+
}, { selectedWorkspaceId: id2 })(value);
|
|
1252
|
+
|
|
1253
|
+
// src/local-workspace.ts
|
|
1254
|
+
var root2 = { rootPath: text(32768) };
|
|
1255
|
+
var identity = { identity: object({ dev: text(32), ino: text(32) }) };
|
|
1256
|
+
var file = { ...root2, path: text(32768) };
|
|
1257
|
+
var write = { ...file, requestId: id, content: text(125e4, true), originalContent: text(125e4, true) };
|
|
1258
|
+
var actionOf = (value) => value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, "action")?.value : void 0;
|
|
1259
|
+
function validLocalWorkspaceRequest(value) {
|
|
1260
|
+
const action2 = actionOf(value);
|
|
1261
|
+
const field = { action: enumeration(action2) };
|
|
1262
|
+
switch (action2) {
|
|
1263
|
+
case "pick":
|
|
1264
|
+
case "listOpeners":
|
|
1265
|
+
return object(field)(value);
|
|
1266
|
+
case "list":
|
|
1267
|
+
return object({ ...field, ...root2 }, { ...identity, path: text(32768, true) })(value);
|
|
1268
|
+
case "find":
|
|
1269
|
+
return object({ ...field, ...root2, query: text(1024) }, identity)(value);
|
|
1270
|
+
case "write":
|
|
1271
|
+
case "getWrite":
|
|
1272
|
+
return object({ ...field, ...write }, identity)(value);
|
|
1273
|
+
case "openWith":
|
|
1274
|
+
return object({ ...field, ...file, openerId: text(256) }, identity)(value);
|
|
1275
|
+
case "copyPath":
|
|
1276
|
+
return object({ ...field, ...file }, { ...identity, absolute: bool })(value);
|
|
1277
|
+
case "read":
|
|
1278
|
+
case "reveal":
|
|
1279
|
+
case "webPreview":
|
|
1280
|
+
return object({ ...field, ...file }, identity)(value);
|
|
1281
|
+
default:
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
var bytes = (limit) => (value) => value instanceof ArrayBuffer && value.byteLength <= limit;
|
|
1286
|
+
var preview = object({
|
|
1287
|
+
path: text(32768),
|
|
1288
|
+
name: text(32768),
|
|
1289
|
+
language: text(4096),
|
|
1290
|
+
size: count,
|
|
1291
|
+
binary: bool,
|
|
1292
|
+
content: nullable(text(125e4, true)),
|
|
1293
|
+
scope: enumeration("project", "extra-root"),
|
|
1294
|
+
relativePath: text(32768),
|
|
1295
|
+
rootLabel: text(32768),
|
|
1296
|
+
previewBytes: nullable(bytes(50 * 1024 * 1024)),
|
|
1297
|
+
mediaType: enumeration(null, "image/avif", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/webp"),
|
|
1298
|
+
imagePreviewError: enumeration(null, "image_too_large", "image_unsupported")
|
|
1299
|
+
}, {
|
|
1300
|
+
rootIdentity: identity.identity,
|
|
1301
|
+
documentPreview: object({ format: enumeration("pdf", "epub", "docx", "xlsx", "pptx"), bytes: bytes(64 * 1024 * 1024) })
|
|
1302
|
+
});
|
|
1303
|
+
var tree = object({
|
|
1304
|
+
...root2,
|
|
1305
|
+
entries: array(object({ path: text(32768), type: enumeration("file", "directory") }, { size: count }), 1e4)
|
|
1306
|
+
}, { truncated: bool });
|
|
1307
|
+
var found = object({ files: array(text(32768), 1e3), truncated: bool });
|
|
1308
|
+
var picked = object({ ...root2, ...identity, workspaceId: id });
|
|
1309
|
+
var url = object({ url: text(131072) });
|
|
1310
|
+
var openers = (value) => validDesktopResult("desktop.files.listOpeners", value);
|
|
1311
|
+
var empty2 = (value) => value === void 0;
|
|
1312
|
+
var checks = {
|
|
1313
|
+
pick: nullable(picked),
|
|
1314
|
+
list: tree,
|
|
1315
|
+
find: found,
|
|
1316
|
+
read: preview,
|
|
1317
|
+
write: preview,
|
|
1318
|
+
getWrite: nullable(preview),
|
|
1319
|
+
reveal: empty2,
|
|
1320
|
+
openWith: empty2,
|
|
1321
|
+
copyPath: empty2,
|
|
1322
|
+
listOpeners: openers,
|
|
1323
|
+
webPreview: url
|
|
1324
|
+
};
|
|
1325
|
+
function validLocalWorkspaceResult(value, action2) {
|
|
1326
|
+
return action2 ? checks[action2](value) : Object.values(checks).some((check) => check(value));
|
|
1327
|
+
}
|
|
1310
1328
|
|
|
1311
1329
|
// ../domain-contracts/src/app-host/model-providers.ts
|
|
1312
1330
|
var provider = text(256);
|
|
@@ -1329,7 +1347,7 @@ var customProvider = object({
|
|
|
1329
1347
|
models: array(object({ id: text(1024), displayName: text(1024) }, { imageInputSupport, ...limits }), 16384)
|
|
1330
1348
|
}, { apiKey: text(8192), headers, secretHeaders });
|
|
1331
1349
|
function validModelProviderRequest(value) {
|
|
1332
|
-
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);
|
|
1350
|
+
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);
|
|
1333
1351
|
}
|
|
1334
1352
|
var validModel = object({ id: text(1024), label: text(1024) }, { imageInputSupport, declaredLimits: object({}, limits) });
|
|
1335
1353
|
var validConnection2 = object({
|
|
@@ -1346,8 +1364,9 @@ function validModelProviderConnections(value) {
|
|
|
1346
1364
|
var modelId = text(1024);
|
|
1347
1365
|
var effort = nullable(text(256));
|
|
1348
1366
|
var revision = text(8192);
|
|
1367
|
+
var accountGatewayProof = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
1349
1368
|
function validProviderDefaultsRequest(value) {
|
|
1350
|
-
return object({ action: enumeration("snapshot") })(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);
|
|
1369
|
+
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);
|
|
1351
1370
|
}
|
|
1352
1371
|
var verifiedProvider = object({ model: modelId, checkedAt: count });
|
|
1353
1372
|
var verified = (value) => {
|
|
@@ -1371,7 +1390,7 @@ var validProviderDefaultsSnapshot = object({
|
|
|
1371
1390
|
verified,
|
|
1372
1391
|
fastModeAvailable: enumeration(false),
|
|
1373
1392
|
fastModeReason: text(1024)
|
|
1374
|
-
});
|
|
1393
|
+
}, { accountGatewayMatches: bool });
|
|
1375
1394
|
var validProviderConnectionTestResult = object({
|
|
1376
1395
|
status: enumeration("verified", "failed"),
|
|
1377
1396
|
detail: text(8192),
|
|
@@ -1418,6 +1437,7 @@ var SYSTEM_SHORTCUT_IDS = [
|
|
|
1418
1437
|
];
|
|
1419
1438
|
var SYSTEM_METHODS = [
|
|
1420
1439
|
"system.projects",
|
|
1440
|
+
"system.workspace",
|
|
1421
1441
|
"system.extensions",
|
|
1422
1442
|
"system.modelProviders",
|
|
1423
1443
|
"system.providerDefaults",
|
|
@@ -1427,7 +1447,6 @@ var SYSTEM_METHODS = [
|
|
|
1427
1447
|
"system.setWindowMaterial",
|
|
1428
1448
|
"system.copyText",
|
|
1429
1449
|
"system.openExternal",
|
|
1430
|
-
"system.markSessionRead",
|
|
1431
1450
|
"system.navigationReady",
|
|
1432
1451
|
"system.completeNavigation"
|
|
1433
1452
|
];
|
|
@@ -1516,6 +1535,8 @@ function validSystemInput(method, value) {
|
|
|
1516
1535
|
switch (method) {
|
|
1517
1536
|
case "system.projects":
|
|
1518
1537
|
return validProjectRequest(value);
|
|
1538
|
+
case "system.workspace":
|
|
1539
|
+
return validLocalWorkspaceRequest(value);
|
|
1519
1540
|
case "system.extensions":
|
|
1520
1541
|
return validExtensionRequest(value);
|
|
1521
1542
|
case "system.modelProviders":
|
|
@@ -1547,12 +1568,6 @@ function validSystemInput(method, value) {
|
|
|
1547
1568
|
page: enumeration("session-settings"),
|
|
1548
1569
|
target: validSessionSettingsTarget
|
|
1549
1570
|
})(value);
|
|
1550
|
-
case "system.markSessionRead":
|
|
1551
|
-
return object({
|
|
1552
|
-
connectionId: text(256),
|
|
1553
|
-
sessionId: text(256),
|
|
1554
|
-
throughSeq: count
|
|
1555
|
-
})(value);
|
|
1556
1571
|
case "system.completeNavigation":
|
|
1557
1572
|
return object({
|
|
1558
1573
|
id: text(256),
|
|
@@ -1571,6 +1586,8 @@ function validSystemResult(method, value) {
|
|
|
1571
1586
|
switch (method) {
|
|
1572
1587
|
case "system.projects":
|
|
1573
1588
|
return validProjectSnapshot(value);
|
|
1589
|
+
case "system.workspace":
|
|
1590
|
+
return validLocalWorkspaceResult(value);
|
|
1574
1591
|
case "system.extensions":
|
|
1575
1592
|
return validExtensionResult(value);
|
|
1576
1593
|
case "system.modelProviders":
|
|
@@ -1611,6 +1628,11 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1611
1628
|
}
|
|
1612
1629
|
return {
|
|
1613
1630
|
projects: (input) => send("system.projects", input),
|
|
1631
|
+
workspace: (async (input) => {
|
|
1632
|
+
const result = await send("system.workspace", input);
|
|
1633
|
+
if (!validLocalWorkspaceResult(result, input.action)) throw new AppHostError("host_unavailable");
|
|
1634
|
+
return result;
|
|
1635
|
+
}),
|
|
1614
1636
|
extensions: (input) => send("system.extensions", input),
|
|
1615
1637
|
modelProviders: (input) => send("system.modelProviders", input),
|
|
1616
1638
|
providerDefaults: (async (input) => {
|
|
@@ -1637,13 +1659,8 @@ function createAppSystemApi(requester, connectionOwner) {
|
|
|
1637
1659
|
getPresentationPreferences: () => send("system.getPresentationPreferences", {}),
|
|
1638
1660
|
setTheme: (theme) => send("system.setTheme", { theme }),
|
|
1639
1661
|
setWindowMaterial: (preference) => send("system.setWindowMaterial", { preference }),
|
|
1640
|
-
copyText: (
|
|
1641
|
-
openExternal: (
|
|
1642
|
-
markSessionRead: ({ connection, sessionId, throughSeq }) => send("system.markSessionRead", {
|
|
1643
|
-
connectionId: resolveClientConnection(connection, connectionOwner),
|
|
1644
|
-
sessionId,
|
|
1645
|
-
throughSeq
|
|
1646
|
-
}),
|
|
1662
|
+
copyText: (text2) => send("system.copyText", { text: text2 }),
|
|
1663
|
+
openExternal: (url2) => send("system.openExternal", { url: url2 }),
|
|
1647
1664
|
navigationReady: () => send("system.navigationReady", {}),
|
|
1648
1665
|
completeNavigation: (input) => send("system.completeNavigation", input)
|
|
1649
1666
|
};
|
|
@@ -1671,11 +1688,14 @@ function isAppLifecycleFrame(value) {
|
|
|
1671
1688
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
1672
1689
|
if (Reflect.ownKeys(descriptors).some((key) => typeof key !== "string" || !descriptors[key].enumerable || !Object.hasOwn(descriptors[key], "value"))) return false;
|
|
1673
1690
|
const frame = value;
|
|
1674
|
-
const
|
|
1675
|
-
if (!
|
|
1691
|
+
const fields2 = frame.type === "lifecycle-prepare" ? ["protocol", "type", "id", "reason"] : frame.type === "lifecycle-cancel" ? ["protocol", "type", "id"] : frame.type === "lifecycle-result" ? ["protocol", "type", "id", "ready"] : void 0;
|
|
1692
|
+
if (!fields2 || Reflect.ownKeys(value).length !== fields2.length || !fields2.every((key) => Object.hasOwn(value, key)) || frame.protocol !== 1 || typeof frame.id !== "string" || !HOST_REQUEST_ID.test(frame.id)) return false;
|
|
1676
1693
|
return frame.type === "lifecycle-prepare" ? ["switch", "reload", "disable", "quit"].includes(frame.reason) : frame.type === "lifecycle-result" ? typeof frame.ready === "boolean" : true;
|
|
1677
1694
|
}
|
|
1678
1695
|
|
|
1696
|
+
// src/workspace.ts
|
|
1697
|
+
var validPickOptions = object({}, { requestId: (value) => value === void 0 || id(value) });
|
|
1698
|
+
|
|
1679
1699
|
// src/protocol.ts
|
|
1680
1700
|
var APP_HOST_PROTOCOL = 1;
|
|
1681
1701
|
var APP_HOST_READY = "nomi.app-host.ready";
|
|
@@ -1746,9 +1766,6 @@ export {
|
|
|
1746
1766
|
FETCH_WINDOW_CHUNKS,
|
|
1747
1767
|
HOST_REQUEST_ID,
|
|
1748
1768
|
RESOURCE_CATALOG_METHODS,
|
|
1749
|
-
SERVICE_HOST_MAX_FRAME_BYTES,
|
|
1750
|
-
SERVICE_HOST_MAX_PENDING,
|
|
1751
|
-
SERVICE_HOST_METHODS,
|
|
1752
1769
|
SYSTEM_METHODS,
|
|
1753
1770
|
SYSTEM_SETTINGS_SECTIONS,
|
|
1754
1771
|
SYSTEM_SHORTCUT_IDS,
|
|
@@ -1771,7 +1788,6 @@ export {
|
|
|
1771
1788
|
isPageFetchFrame,
|
|
1772
1789
|
isResourceCatalogMethod,
|
|
1773
1790
|
isSafeErrorDetails,
|
|
1774
|
-
isServiceHostFrame,
|
|
1775
1791
|
isSystemMethod,
|
|
1776
1792
|
isWindowMethod,
|
|
1777
1793
|
matchAgentApiRoute,
|
|
@@ -1803,9 +1819,6 @@ export {
|
|
|
1803
1819
|
validResourceCatalogInput,
|
|
1804
1820
|
validResourceCatalogResult,
|
|
1805
1821
|
validResourceChanged,
|
|
1806
|
-
validServiceContext,
|
|
1807
|
-
validServiceHostInput,
|
|
1808
|
-
validServiceHostResult,
|
|
1809
1822
|
validSessionResourceInput,
|
|
1810
1823
|
validSessionResourceResult,
|
|
1811
1824
|
validSessionSettingsTarget,
|