@bobannomi/app-host 0.1.0-next.1 → 0.1.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 +3 -3
- package/dist/index.d.ts +79 -92
- package/dist/index.js +97 -104
- package/dist/index.js.map +3 -3
- package/dist/node/service-host.d.ts +61 -312
- package/dist/node/service-host.js +46 -140
- package/dist/node/service-host.js.map +3 -3
- package/dist/protocol.d.ts +371 -385
- package/dist/protocol.js +92 -100
- package/dist/protocol.js.map +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ JSON 方法使用非空键,文件方法使用宿主签发的文件 ID;页面
|
|
|
27
27
|
|
|
28
28
|
`pnpm --filter @bobannomi/app-host test`、`check-types`、`build` 分别运行测试、浏览器类型检查和 ESM/d.ts 构建。包只发布 dist 与本说明;Desktop 的 main/preload 只能从精确 `@bobannomi/app-host/protocol` 导入共享消息协议。新增公开页面方法须同时补充协议、严格验证和行为测试,不能从根入口导出 Electron 内部 API。
|
|
29
29
|
|
|
30
|
-
构建分别合并浏览器根入口、宿主 `/protocol` 和 Node `/node` 的 JS 与类型声明,内部工作区包只作为构建输入;类型检查分别使用浏览器 `tsconfig.json` 和 Node `tsconfig.node.json`。`verify:pack` 在独立临时项目检查真实 TGZ 的运行、类型与浏览器消费。仅 `@bobannomi/app-host/node` 会加载 `node:process`。Node 服务通过 `connectServiceHost()` 使用自己实际 IPC 的 owner 握手;`context.whenReady()` 等待同一实例的 ready,随后才启动调度计时器,不会创建 Agent
|
|
30
|
+
构建分别合并浏览器根入口、宿主 `/protocol` 和 Node `/node` 的 JS 与类型声明,内部工作区包只作为构建输入;类型检查分别使用浏览器 `tsconfig.json` 和 Node `tsconfig.node.json`。`verify:pack` 在独立临时项目检查真实 TGZ 的运行、类型与浏览器消费。仅 `@bobannomi/app-host/node` 会加载 `node:process`。Node 服务通过 `connectServiceHost()` 使用自己实际 IPC 的 owner 握手;`context.whenReady()` 等待同一实例的 ready,随后才启动调度计时器,不会创建 Agent。服务用 `host.sessions.getConnection({ dataScopeId, sessionId })` 核对已有会话及数据范围,再把 `AgentConnection.clientOptions` 交给普通 Client SDK。控制选项、原动作回执和角色目录分别由 `client.sessions.getControls()`、`client.sessions.getControlResult()` 和 `client.runtime.listAgentPersonas()` 读取。后台凭据始终由宿主管理。
|
|
31
31
|
|
|
32
32
|
`commands-v1` 提供 `host.commands.register(snapshot, invoke)`,回调保存在当前文档内。更新/注销使用 registration UUID 和递增 revision;旧 registration、旧 revision、禁用命令和关闭连接不会分发回调。命令、菜单、快捷键和工具栏都是有限数据,未知写入回执不会自动重放命令。
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ JSON 方法使用非空键,文件方法使用宿主签发的文件 ID;页面
|
|
|
39
39
|
|
|
40
40
|
协商 `browser-binding-invalidation-v1` 后,`browser-changed` 的 `snapshot` 可直接更新匹配目标和标签的批注界面。`invalidated: true` 表示原绑定已失效,此时快照仅供兼容,页面应重新核对原绑定。旧宿主和旧 SDK 继续使用不带标记的 `browser-changed` 触发读取。
|
|
41
41
|
|
|
42
|
-
协商 `browser-capture-preview-v1` 后,`host.desktop.browser.capturePreview({ targetId, tabId, pageRevision })` 返回当前网页的 PNG 字节与宽高。字节上限为 8 MiB
|
|
42
|
+
协商 `browser-capture-preview-v1` 后,`host.desktop.browser.capturePreview({ targetId, tabId, pageRevision })` 返回当前网页的 PNG 字节与宽高。字节上限为 8 MiB,应用可直接用它们显示预览或下载。
|
|
43
43
|
|
|
44
44
|
支持 `window-chrome-v1` 的宿主提供 `host.window`:getState() 读取平台、最大化、标题栏模式、macOS 控件避让宽度与实际材质,onStateChanged(listener) 返回取消监听函数;minimize()、toggleMaximize()、requestClose() 操作当前所属窗口。openHost({page}) 只打开 manage、settings、about、recovery。调用与监听都需先协商,旧宿主返回 incompatible。应用新接入时使用 `hostApi: "^0.1.1"`;关闭前保存由宿主沿 lifecycle 流程安排,SDK 不直接销毁窗口。
|
|
45
45
|
|
|
@@ -63,7 +63,7 @@ SDK 兼容只有 `code` 和 `message` 的错误回复。每次连接都核对版
|
|
|
63
63
|
|
|
64
64
|
根入口提供 `parsePluginAppComposerContexts`,校验插件输入框上下文。历史交互和 MCP 工具结果从各自的合同包读取。
|
|
65
65
|
|
|
66
|
-
`host.sessions.getConnection()`
|
|
66
|
+
`host.sessions.getConnection()` 只接受无参调用,为当前应用页面提供一条可复用的会话连接。将返回的 `clientOptions` 交给标准 Client SDK,按会话 ID 读取历史、订阅事件,或继续有执行权限的用户会话。Daemon 按每次访问的会话及操作核对授权。附件、辅助会话和原生文件工具沿各自入口指定目标。执行目录是创建请求的业务参数。
|
|
67
67
|
|
|
68
68
|
`host.desktop` fixes an explicit target (scope, draft revision, optional actual root and session), then exposes typed files, Git, terminal, window, browser annotation/capture and MCP App operations. `host.attachments.getConnection` also supports a draft-only target. `host.sessions` exposes auxiliary options/open/query/close using the original standard connection. See `src/desktop.ts`, `src/attachments.ts`, `src/auxiliary.ts`; each wire method validates both request and reply. Connections are recorded in a per-document WeakMap; a fabricated or foreign document connection cannot be bound. The three negotiated features are only available when their actual host services are assembled; they add no installation capability or Agent grant. Recovery methods query original request receipts and do not replay mutations.
|
|
69
69
|
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,81 @@ declare class AppHostError extends Error {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
interface ServiceStatus {
|
|
49
|
+
state: "absent" | "unauthorized" | "stopped" | "starting" | "recovering" | "ready" | "failed";
|
|
50
|
+
reason?: "dependency_missing" | "service_start_failed" | "service_unavailable" | "result_unknown" | "incompatible" | "revoked";
|
|
51
|
+
instanceId?: string;
|
|
52
|
+
apiVersion?: string;
|
|
53
|
+
}
|
|
54
|
+
interface ServiceWork {
|
|
55
|
+
requestId: string;
|
|
56
|
+
state: ServiceWorkState;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
result?: JsonValue$1;
|
|
59
|
+
error?: JsonValue$1;
|
|
60
|
+
}
|
|
61
|
+
interface ServiceConnectionDescriptor {
|
|
62
|
+
connectionId: string;
|
|
63
|
+
baseUrl: string;
|
|
64
|
+
apiVersion: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare const APP_HOST_FEATURES: readonly ["fetch-v2", "fetch-inline-body-v1", "fetch-target-close-v1", "service-v1", "extended-errors-v1", "workspace-v1", "session-resources-v1", "session-controls-v1", "conversation-creation-session-v1", "trusted-desktop-v1", "attachments-v1", "auxiliary-sessions-v1", "system-ui-v1", "lifecycle-v1", "commands-v1", "resource-catalog-v1", "file-content-v1", "window-chrome-v1", "embedded-browser-v1", "browser-binding-invalidation-v1", "browser-capture-preview-v1"];
|
|
68
|
+
type AppHostFeature = typeof APP_HOST_FEATURES[number];
|
|
69
|
+
type FetchDirection = "upload" | "download";
|
|
70
|
+
type PageFetchFrame = {
|
|
71
|
+
protocol: 2;
|
|
72
|
+
} & ({
|
|
73
|
+
type: "fetch-open";
|
|
74
|
+
id: string;
|
|
75
|
+
connectionId: string;
|
|
76
|
+
url: string;
|
|
77
|
+
method: string;
|
|
78
|
+
headers: [string, string][];
|
|
79
|
+
hasBody: boolean;
|
|
80
|
+
inlineBody?: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: "fetch-headers";
|
|
83
|
+
id: string;
|
|
84
|
+
status: number;
|
|
85
|
+
statusText: string;
|
|
86
|
+
headers: [string, string][];
|
|
87
|
+
hasBody: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
type: "fetch-credit";
|
|
90
|
+
id: string;
|
|
91
|
+
direction: FetchDirection;
|
|
92
|
+
sequence: number;
|
|
93
|
+
chunks: number;
|
|
94
|
+
bytes: number;
|
|
95
|
+
} | {
|
|
96
|
+
type: "fetch-chunk";
|
|
97
|
+
id: string;
|
|
98
|
+
direction: FetchDirection;
|
|
99
|
+
sequence: number;
|
|
100
|
+
bytes: Uint8Array;
|
|
101
|
+
} | {
|
|
102
|
+
type: "fetch-end";
|
|
103
|
+
id: string;
|
|
104
|
+
direction: FetchDirection;
|
|
105
|
+
sequence: number;
|
|
106
|
+
} | {
|
|
107
|
+
type: "fetch-consumed";
|
|
108
|
+
id: string;
|
|
109
|
+
direction: "download";
|
|
110
|
+
sequence: number;
|
|
111
|
+
} | {
|
|
112
|
+
type: "fetch-cancel";
|
|
113
|
+
id: string;
|
|
114
|
+
} | {
|
|
115
|
+
type: "fetch-error";
|
|
116
|
+
id: string;
|
|
117
|
+
error: AppHostErrorInfo;
|
|
118
|
+
} | {
|
|
119
|
+
type: "fetch-close";
|
|
120
|
+
connectionId: string;
|
|
121
|
+
});
|
|
122
|
+
|
|
48
123
|
/** How an agent explains findings and delivers results, independently of update timing. */
|
|
49
124
|
type ReplyStyle = "collaborative" | "direct" | "explanatory";
|
|
50
125
|
|
|
@@ -240,81 +315,6 @@ type SessionControlOriginal = {
|
|
|
240
315
|
};
|
|
241
316
|
};
|
|
242
317
|
|
|
243
|
-
interface ServiceStatus {
|
|
244
|
-
state: "absent" | "unauthorized" | "stopped" | "starting" | "recovering" | "ready" | "failed";
|
|
245
|
-
reason?: "dependency_missing" | "service_start_failed" | "service_unavailable" | "result_unknown" | "incompatible" | "revoked";
|
|
246
|
-
instanceId?: string;
|
|
247
|
-
apiVersion?: string;
|
|
248
|
-
}
|
|
249
|
-
interface ServiceWork {
|
|
250
|
-
requestId: string;
|
|
251
|
-
state: ServiceWorkState;
|
|
252
|
-
updatedAt: string;
|
|
253
|
-
result?: JsonValue$1;
|
|
254
|
-
error?: JsonValue$1;
|
|
255
|
-
}
|
|
256
|
-
interface ServiceConnectionDescriptor {
|
|
257
|
-
connectionId: string;
|
|
258
|
-
baseUrl: string;
|
|
259
|
-
apiVersion: string;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
declare const APP_HOST_FEATURES: readonly ["fetch-v2", "fetch-inline-body-v1", "fetch-target-close-v1", "service-v1", "extended-errors-v1", "workspace-v1", "session-resources-v1", "session-controls-v1", "conversation-creation-session-v1", "trusted-desktop-v1", "attachments-v1", "auxiliary-sessions-v1", "system-ui-v1", "lifecycle-v1", "commands-v1", "resource-catalog-v1", "file-content-v1", "window-chrome-v1", "embedded-browser-v1", "browser-binding-invalidation-v1", "browser-capture-preview-v1"];
|
|
263
|
-
type AppHostFeature = typeof APP_HOST_FEATURES[number];
|
|
264
|
-
type FetchDirection = "upload" | "download";
|
|
265
|
-
type PageFetchFrame = {
|
|
266
|
-
protocol: 2;
|
|
267
|
-
} & ({
|
|
268
|
-
type: "fetch-open";
|
|
269
|
-
id: string;
|
|
270
|
-
connectionId: string;
|
|
271
|
-
url: string;
|
|
272
|
-
method: string;
|
|
273
|
-
headers: [string, string][];
|
|
274
|
-
hasBody: boolean;
|
|
275
|
-
inlineBody?: string;
|
|
276
|
-
} | {
|
|
277
|
-
type: "fetch-headers";
|
|
278
|
-
id: string;
|
|
279
|
-
status: number;
|
|
280
|
-
statusText: string;
|
|
281
|
-
headers: [string, string][];
|
|
282
|
-
hasBody: boolean;
|
|
283
|
-
} | {
|
|
284
|
-
type: "fetch-credit";
|
|
285
|
-
id: string;
|
|
286
|
-
direction: FetchDirection;
|
|
287
|
-
sequence: number;
|
|
288
|
-
chunks: number;
|
|
289
|
-
bytes: number;
|
|
290
|
-
} | {
|
|
291
|
-
type: "fetch-chunk";
|
|
292
|
-
id: string;
|
|
293
|
-
direction: FetchDirection;
|
|
294
|
-
sequence: number;
|
|
295
|
-
bytes: Uint8Array;
|
|
296
|
-
} | {
|
|
297
|
-
type: "fetch-end";
|
|
298
|
-
id: string;
|
|
299
|
-
direction: FetchDirection;
|
|
300
|
-
sequence: number;
|
|
301
|
-
} | {
|
|
302
|
-
type: "fetch-consumed";
|
|
303
|
-
id: string;
|
|
304
|
-
direction: "download";
|
|
305
|
-
sequence: number;
|
|
306
|
-
} | {
|
|
307
|
-
type: "fetch-cancel";
|
|
308
|
-
id: string;
|
|
309
|
-
} | {
|
|
310
|
-
type: "fetch-error";
|
|
311
|
-
id: string;
|
|
312
|
-
error: AppHostErrorInfo;
|
|
313
|
-
} | {
|
|
314
|
-
type: "fetch-close";
|
|
315
|
-
connectionId: string;
|
|
316
|
-
});
|
|
317
|
-
|
|
318
318
|
interface WorkspaceRef {
|
|
319
319
|
id: string;
|
|
320
320
|
displayName: string;
|
|
@@ -981,14 +981,6 @@ interface DesktopMethodMap {
|
|
|
981
981
|
"desktop.browser.removeAnnotation": Entry<BrowserPage & {
|
|
982
982
|
annotationId: string;
|
|
983
983
|
}, BrowserAnnotationSnapshot>;
|
|
984
|
-
"desktop.browser.capture": Entry<BrowserPage, {
|
|
985
|
-
assetId: string;
|
|
986
|
-
sha256: string;
|
|
987
|
-
mediaType: string;
|
|
988
|
-
byteLength: number;
|
|
989
|
-
width: number;
|
|
990
|
-
height: number;
|
|
991
|
-
}>;
|
|
992
984
|
"desktop.browser.capturePreview": Entry<BrowserPage, {
|
|
993
985
|
bytes: Uint8Array<ArrayBuffer>;
|
|
994
986
|
width: number;
|
|
@@ -1792,15 +1784,10 @@ declare function createAppAuxiliarySessionsApi(rpc: {
|
|
|
1792
1784
|
request<M extends AuxiliaryMethod>(method: M, params: AuxiliaryMethodMap[M]["params"]): Promise<AuxiliaryMethodMap[M]["result"]>;
|
|
1793
1785
|
}, streams: ConnectionStreams): AppHostAuxiliarySessions;
|
|
1794
1786
|
|
|
1795
|
-
interface SessionTarget {
|
|
1796
|
-
dataScopeId: string;
|
|
1797
|
-
sessionId: string;
|
|
1798
|
-
}
|
|
1799
|
-
type SessionConnectionTarget = SessionTarget | Record<string, never>;
|
|
1800
1787
|
interface AppHostSessions {
|
|
1801
|
-
/**
|
|
1802
|
-
*
|
|
1803
|
-
getConnection(
|
|
1788
|
+
/** Handles share the page's connection. Closing any handle ends the
|
|
1789
|
+
* connection and all its in-flight requests. */
|
|
1790
|
+
getConnection(): Promise<AgentConnection>;
|
|
1804
1791
|
}
|
|
1805
1792
|
|
|
1806
1793
|
interface ServiceConnection {
|
|
@@ -2038,4 +2025,4 @@ interface PluginAppConversationInput {
|
|
|
2038
2025
|
declare function parsePluginAppComposerContexts(value: unknown): PluginAppConversationInput[];
|
|
2039
2026
|
|
|
2040
2027
|
export { ATTACHMENTS_METHODS, AUXILIARY_METHODS, AppHostError, BROWSER_CAPTURE_PREVIEW_MAX_BYTES, COMMANDS_METHODS, DESKTOP_METHODS, EXTENSION_INPUTS, RESOURCE_CATALOG_METHODS, SYSTEM_METHODS, SYSTEM_SETTINGS_SECTIONS, SYSTEM_SHORTCUT_IDS, WINDOW_METHODS, canonicalDesktopRequest, connectAppHost, createAppAttachmentsApi, createAppAuxiliarySessionsApi, createAppCommandsApi, createAppDesktopApi, createAppSystemApi, createAppWindowApi, createPageFetchClient, createResourceCatalogApi, isAuxiliaryMethod, isCommandsMethod, isDesktopMethod, isResourceCatalogMethod, isSystemMethod, isWindowMethod, parsePluginAppComposerContexts, validAppCommandSnapshot, validAppWindowState, validAttachmentsInput, validAttachmentsResult, validAuxiliaryInput, validAuxiliaryResult, validBrowserSnapshot, validCommandInvocation, validCommandReceipt, validCommandsInput, validDesktopEvent, validDesktopInput, validDesktopNavigationTarget, validDesktopResult, validDesktopResultForInput, validDesktopTarget, validExtensionRequest, validExtensionResult, validPresentationSnapshot, validProjectRequest, validProjectSnapshot, validResourceCatalogInput, validResourceCatalogResult, validResourceChanged, validSessionSettingsTarget, validSystemEvent, validSystemInput, validSystemResult, validWindowEvent, validWindowInput, validWindowResult, validWorkspaceOperation };
|
|
2041
|
-
export type { AgentConnection, AnnotationMode, AnnotationRect, AnnotationTarget, AppCommandRegistration, AppCommandSnapshot, AppContext, AppHost, AppHostAttachments, AppHostAuxiliarySessions, AppHostCommands, AppHostDesktop, AppHostErrorCode, AppHostErrorInfo, AppHostEvent, AppHostLifecycle, AppHostRetry, AppHostService, AppHostSessions, AppHostStorage, AppHostSystem, AppHostWindow, AppHostWorkspace, AppUnloadHandler, AppUnloadReason, AppUnloadRequest, AppWindowMaterialState, AppWindowOpenHostInput, AppWindowStartupResult, AppWindowState, AppearancePreferences, AttachmentsMethod, AttachmentsMethodMap, AuxiliaryMethod, AuxiliaryMethodMap, AuxiliaryOptions, AuxiliaryReceipt, AuxiliaryRequest, AuxiliarySelection, AuxiliaryWireRequest, BindDesktopTarget, BrowserAnnotationRecord, BrowserAnnotationSnapshot, BrowserPage, ClientConnection, CommandInvocation, CommandReceipt, CommandsMethod, CommandsMethodMap, ConnectParams, ConversationPreparation, DesktopGitChange, DesktopMethod, DesktopMethodMap, DesktopNavigationTarget, DesktopOpener, DesktopRoot, DesktopSearch, DesktopTarget, DesktopTerminal, DesktopTerminalInfo, DesktopTerminalRequestOriginal, DesktopTerminalRequestReceipt, DesktopTerminalSnapshot, DesktopText, DesktopToolEvent, DesktopWindow, ExtensionOperation, ExtensionRequest, JsonValue$1 as JsonValue, LoginResult, ModelProviderConnection, ModelProviderRequest, NavigationCompletionStatus, PluginAppActionReceipt, PluginAppActionResponse, PluginAppCatalog, PluginAppComposerContext, PluginAppHostState, PluginAppModelContext, PluginAppMount, PluginAppPreparedMessage, PluginAppPreparedTool, PluginAppRecord, PluginAppSource$1 as PluginAppSource, PluginAppSubmissionReceipt, PluginAppToolPolicy, PresentationSnapshot, ProjectRequest, ProjectSnapshot, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, ResourceCatalogMethod, ResourceCatalogMethodMap, ResourceChanged, ServiceConnection, ServiceConnectionDescriptor, ServiceStatus, ServiceWork, ServiceWorkState, SessionSettingsTarget, SessionSettingsWireTarget,
|
|
2028
|
+
export type { AgentConnection, AnnotationMode, AnnotationRect, AnnotationTarget, AppCommandRegistration, AppCommandSnapshot, AppContext, AppHost, AppHostAttachments, AppHostAuxiliarySessions, AppHostCommands, AppHostDesktop, AppHostErrorCode, AppHostErrorInfo, AppHostEvent, AppHostLifecycle, AppHostRetry, AppHostService, AppHostSessions, AppHostStorage, AppHostSystem, AppHostWindow, AppHostWorkspace, AppUnloadHandler, AppUnloadReason, AppUnloadRequest, AppWindowMaterialState, AppWindowOpenHostInput, AppWindowStartupResult, AppWindowState, AppearancePreferences, AttachmentsMethod, AttachmentsMethodMap, AuxiliaryMethod, AuxiliaryMethodMap, AuxiliaryOptions, AuxiliaryReceipt, AuxiliaryRequest, AuxiliarySelection, AuxiliaryWireRequest, BindDesktopTarget, BrowserAnnotationRecord, BrowserAnnotationSnapshot, BrowserPage, ClientConnection, CommandInvocation, CommandReceipt, CommandsMethod, CommandsMethodMap, ConnectParams, ConversationPreparation, DesktopGitChange, DesktopMethod, DesktopMethodMap, DesktopNavigationTarget, DesktopOpener, DesktopRoot, DesktopSearch, DesktopTarget, DesktopTerminal, DesktopTerminalInfo, DesktopTerminalRequestOriginal, DesktopTerminalRequestReceipt, DesktopTerminalSnapshot, DesktopText, DesktopToolEvent, DesktopWindow, ExtensionOperation, ExtensionRequest, JsonValue$1 as JsonValue, LoginResult, ModelProviderConnection, ModelProviderRequest, NavigationCompletionStatus, PluginAppActionReceipt, PluginAppActionResponse, PluginAppCatalog, PluginAppComposerContext, PluginAppHostState, PluginAppModelContext, PluginAppMount, PluginAppPreparedMessage, PluginAppPreparedTool, PluginAppRecord, PluginAppSource$1 as PluginAppSource, PluginAppSubmissionReceipt, PluginAppToolPolicy, PresentationSnapshot, ProjectRequest, ProjectSnapshot, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, ResourceCatalogMethod, ResourceCatalogMethodMap, ResourceChanged, ServiceConnection, ServiceConnectionDescriptor, ServiceStatus, ServiceWork, ServiceWorkState, SessionSettingsTarget, SessionSettingsWireTarget, StorageGetResult, StoredFile, SystemEvent, SystemMethod, SystemMethodMap, SystemOpenInput, SystemOpenWireInput, SystemProject, SystemRequester, SystemShortcutId, WindowMethod, WindowMethodMap, WindowRequester, WindowStateChanged, WorkspaceConversationCreation, WorkspaceConversationResult, WorkspaceDirectoryPage, WorkspaceFilePage, WorkspaceOperation, WorkspaceOperationKind, WorkspaceOperationOriginal, WorkspaceRef, WorkspaceSelection, WorkspaceText };
|
package/dist/index.js
CHANGED
|
@@ -171,94 +171,6 @@ function validConnection(v) {
|
|
|
171
171
|
return wireConnection(v) && /^[A-Za-z0-9-]+$/.test(v.connectionId) && v.baseUrl === `https://app-host.invalid/connections/${v.connectionId}`;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// ../domain-contracts/src/app-host/workspace-conversations.ts
|
|
175
|
-
var validWorkspaceConversation = (value) => {
|
|
176
|
-
if (!object(
|
|
177
|
-
{ dataScopeId: text(), requestId: id, sessionId: id, taskLocation: enumeration("current", "worktree"), configuration: json },
|
|
178
|
-
{ workspaceId: id, outsideProject: (v) => v === true, preparationRevision: text() }
|
|
179
|
-
)(value)) return false;
|
|
180
|
-
const input = value;
|
|
181
|
-
return input.workspaceId !== void 0 ? input.outsideProject !== true : input.outsideProject === true && input.taskLocation === "current";
|
|
182
|
-
};
|
|
183
|
-
var sessionText = (value) => typeof value === "string";
|
|
184
|
-
var sessionRecord = object({
|
|
185
|
-
id,
|
|
186
|
-
cwd: sessionText,
|
|
187
|
-
title: sessionText,
|
|
188
|
-
model: sessionText,
|
|
189
|
-
status: enumeration("idle", "running", "closing", "archived", "error"),
|
|
190
|
-
metadata: jsonObject,
|
|
191
|
-
createdAt: count,
|
|
192
|
-
updatedAt: count
|
|
193
|
-
}, {
|
|
194
|
-
storage: enumeration("sqlite", "memory"),
|
|
195
|
-
parentId: sessionText,
|
|
196
|
-
projectId: sessionText,
|
|
197
|
-
cwdRelative: sessionText,
|
|
198
|
-
agent: sessionText,
|
|
199
|
-
archivedAt: count
|
|
200
|
-
});
|
|
201
|
-
var workspaceConversationResult = object({
|
|
202
|
-
dataScopeId: text(),
|
|
203
|
-
sessionId: id,
|
|
204
|
-
requestId: id,
|
|
205
|
-
action: (v) => v === "create-session",
|
|
206
|
-
state: enumeration("prepared", "completed", "unknown")
|
|
207
|
-
}, {
|
|
208
|
-
configuration: json,
|
|
209
|
-
revision: count,
|
|
210
|
-
session: sessionRecord,
|
|
211
|
-
operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
|
|
212
|
-
indexBindingPending: (v) => v === true,
|
|
213
|
-
workspaceId: id,
|
|
214
|
-
executionRoot: id,
|
|
215
|
-
privateSessionId: id,
|
|
216
|
-
worktree: json
|
|
217
|
-
});
|
|
218
|
-
var validWorkspaceConversationResult = (value) => {
|
|
219
|
-
if (!workspaceConversationResult(value)) return false;
|
|
220
|
-
const result = value;
|
|
221
|
-
return !result.session || result.state === "completed" && result.session.id === result.sessionId;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// ../domain-contracts/src/app-host/session-controls.ts
|
|
225
|
-
var option = object({ id: text(), name: text() });
|
|
226
|
-
var choices = array(option);
|
|
227
|
-
var effortChoices = array(object({ id: text(1024, true), name: text() }));
|
|
228
|
-
var receiptShape = object({ dataScopeId: text(), sessionId: text(), requestId: id, action: enumeration("fork", "configure", "compact"), state: enumeration("prepared", "created", "completed", "unknown") }, { revision: count, targetSessionId: text() });
|
|
229
|
-
var receipt = receiptShape;
|
|
230
|
-
function validSessionControlOriginal(value) {
|
|
231
|
-
if (!object({ action: text(), body: json })(value)) return false;
|
|
232
|
-
const v = value;
|
|
233
|
-
if (v.action === "compact") return object({ requestId: id, expectedRevision: count })(v.body);
|
|
234
|
-
return v.action === "fork" && object({ requestId: id, id: text() }, { copyHistory: bool, beforeMessageId: text(), afterMessageId: text(), storage: enumeration("sqlite") })(v.body);
|
|
235
|
-
}
|
|
236
|
-
function validSessionControlInput(method, value) {
|
|
237
|
-
if (!json(value)) return false;
|
|
238
|
-
if (method === "sessions.getDraftComposerOptions") {
|
|
239
|
-
if (!object({ source: enumeration("instance") }, { workspaceId: id, outsideProject: bool, roleId: (v2) => v2 === null || text(256)(v2) })(value)) return false;
|
|
240
|
-
const target2 = value;
|
|
241
|
-
return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
|
|
242
|
-
}
|
|
243
|
-
if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
|
|
244
|
-
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
|
|
245
|
-
if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
|
|
246
|
-
if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
|
|
247
|
-
const v = value;
|
|
248
|
-
return v.original.body.requestId === v.requestId && !!v.connectionId;
|
|
249
|
-
}
|
|
250
|
-
function validSessionControlResult(method, value) {
|
|
251
|
-
if (!json(value)) return false;
|
|
252
|
-
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);
|
|
253
|
-
if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
|
|
254
|
-
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
|
|
255
|
-
return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
|
|
256
|
-
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);
|
|
257
|
-
if (method === "sessions.getControlResult") return value === null || receipt(value);
|
|
258
|
-
if (!receipt(value)) return false;
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
174
|
// ../domain-contracts/src/app-host/service.ts
|
|
263
175
|
function fields(value, required, optional = []) {
|
|
264
176
|
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
@@ -425,6 +337,94 @@ var SERVICE_HOST_MAX_FRAME_BYTES = 512 * 1024;
|
|
|
425
337
|
var worktreeBody = { workspaceId: id, expectedHead: text(256), branch: text(1024) };
|
|
426
338
|
var worktreeReceipt = object({ requestId: id, state: enumeration("accepted", "completed", "failed", "unknown") }, { result: object({ executionRoot: id, workspaceId: id, branch: text(1024), sourceHead: text(256) }) });
|
|
427
339
|
|
|
340
|
+
// ../domain-contracts/src/app-host/workspace-conversations.ts
|
|
341
|
+
var validWorkspaceConversation = (value) => {
|
|
342
|
+
if (!object(
|
|
343
|
+
{ dataScopeId: text(), requestId: id, sessionId: id, taskLocation: enumeration("current", "worktree"), configuration: json },
|
|
344
|
+
{ workspaceId: id, outsideProject: (v) => v === true, preparationRevision: text() }
|
|
345
|
+
)(value)) return false;
|
|
346
|
+
const input = value;
|
|
347
|
+
return input.workspaceId !== void 0 ? input.outsideProject !== true : input.outsideProject === true && input.taskLocation === "current";
|
|
348
|
+
};
|
|
349
|
+
var sessionText = (value) => typeof value === "string";
|
|
350
|
+
var sessionRecord = object({
|
|
351
|
+
id,
|
|
352
|
+
cwd: sessionText,
|
|
353
|
+
title: sessionText,
|
|
354
|
+
model: sessionText,
|
|
355
|
+
status: enumeration("idle", "running", "closing", "archived", "error"),
|
|
356
|
+
metadata: jsonObject,
|
|
357
|
+
createdAt: count,
|
|
358
|
+
updatedAt: count
|
|
359
|
+
}, {
|
|
360
|
+
storage: enumeration("sqlite", "memory"),
|
|
361
|
+
parentId: sessionText,
|
|
362
|
+
projectId: sessionText,
|
|
363
|
+
cwdRelative: sessionText,
|
|
364
|
+
agent: sessionText,
|
|
365
|
+
archivedAt: count
|
|
366
|
+
});
|
|
367
|
+
var workspaceConversationResult = object({
|
|
368
|
+
dataScopeId: text(),
|
|
369
|
+
sessionId: id,
|
|
370
|
+
requestId: id,
|
|
371
|
+
action: (v) => v === "create-session",
|
|
372
|
+
state: enumeration("prepared", "completed", "unknown")
|
|
373
|
+
}, {
|
|
374
|
+
configuration: json,
|
|
375
|
+
revision: count,
|
|
376
|
+
session: sessionRecord,
|
|
377
|
+
operationState: enumeration("prepared", "running", "completed", "failed", "unknown"),
|
|
378
|
+
indexBindingPending: (v) => v === true,
|
|
379
|
+
workspaceId: id,
|
|
380
|
+
executionRoot: id,
|
|
381
|
+
privateSessionId: id,
|
|
382
|
+
worktree: json
|
|
383
|
+
});
|
|
384
|
+
var validWorkspaceConversationResult = (value) => {
|
|
385
|
+
if (!workspaceConversationResult(value)) return false;
|
|
386
|
+
const result = value;
|
|
387
|
+
return !result.session || result.state === "completed" && result.session.id === result.sessionId;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// ../domain-contracts/src/app-host/session-controls.ts
|
|
391
|
+
var option = object({ id: text(), name: text() });
|
|
392
|
+
var choices = array(option);
|
|
393
|
+
var effortChoices = array(object({ id: text(1024, true), name: text() }));
|
|
394
|
+
var receiptShape = object({ dataScopeId: text(), sessionId: text(), requestId: id, action: enumeration("fork", "configure", "compact"), state: enumeration("prepared", "created", "completed", "unknown") }, { revision: count, targetSessionId: text() });
|
|
395
|
+
var receipt = receiptShape;
|
|
396
|
+
function validSessionControlOriginal(value) {
|
|
397
|
+
if (!object({ action: text(), body: json })(value)) return false;
|
|
398
|
+
const v = value;
|
|
399
|
+
if (v.action === "compact") return object({ requestId: id, expectedRevision: count })(v.body);
|
|
400
|
+
return v.action === "fork" && object({ requestId: id, id: text() }, { copyHistory: bool, beforeMessageId: text(), afterMessageId: text(), storage: enumeration("sqlite") })(v.body);
|
|
401
|
+
}
|
|
402
|
+
function validSessionControlInput(method, value) {
|
|
403
|
+
if (!json(value)) return false;
|
|
404
|
+
if (method === "sessions.getDraftComposerOptions") {
|
|
405
|
+
if (!object({ source: enumeration("instance") }, { workspaceId: id, outsideProject: bool, roleId: (v2) => v2 === null || text(256)(v2) })(value)) return false;
|
|
406
|
+
const target2 = value;
|
|
407
|
+
return target2.workspaceId !== void 0 ? target2.outsideProject !== true : target2.outsideProject === true;
|
|
408
|
+
}
|
|
409
|
+
if (method === "sessions.bindConversationIndex") return object({ original: validWorkspaceConversation, dataScopeId: text() })(value);
|
|
410
|
+
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult") return validWorkspaceConversation(value);
|
|
411
|
+
if (method === "sessions.getControls") return object({ connectionId: text(), sessionId: text() })(value);
|
|
412
|
+
if (!object({ requestId: id, sessionId: text(), original: validSessionControlOriginal }, { connectionId: text() })(value)) return false;
|
|
413
|
+
const v = value;
|
|
414
|
+
return v.original.body.requestId === v.requestId && !!v.connectionId;
|
|
415
|
+
}
|
|
416
|
+
function validSessionControlResult(method, value) {
|
|
417
|
+
if (!json(value)) return false;
|
|
418
|
+
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);
|
|
419
|
+
if (method === "sessions.bindConversationIndex") return validWorkspaceConversationResult(value);
|
|
420
|
+
if (method === "sessions.createConversation" || method === "sessions.getConversationCreationResult")
|
|
421
|
+
return method === "sessions.getConversationCreationResult" && value === null || validWorkspaceConversationResult(value);
|
|
422
|
+
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);
|
|
423
|
+
if (method === "sessions.getControlResult") return value === null || receipt(value);
|
|
424
|
+
if (!receipt(value)) return false;
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
428
|
// ../domain-contracts/src/app-host/workspace.ts
|
|
429
429
|
function fields2(v, required, optional = []) {
|
|
430
430
|
if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) return false;
|
|
@@ -827,7 +827,6 @@ var rules = {
|
|
|
827
827
|
"desktop.browser.addAnnotation": { input: object({ ...page, selectionId: text(), comment: text(65536, true) }), result: validBrowserSnapshot },
|
|
828
828
|
"desktop.browser.focusAnnotation": { input: object({ ...page, annotationId: text() }), result: validBrowserSnapshot },
|
|
829
829
|
"desktop.browser.removeAnnotation": { input: object({ ...page, annotationId: text() }), result: validBrowserSnapshot },
|
|
830
|
-
"desktop.browser.capture": { input: object(page), result: object({ assetId: text(), sha256: digest, mediaType: text(256), byteLength: count, width: positive, height: positive }) },
|
|
831
830
|
"desktop.browser.capturePreview": { input: object(page), result: object({ bytes: capturePreviewBytes, width: positive, height: positive }) },
|
|
832
831
|
"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") })) })) }) },
|
|
833
832
|
"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) },
|
|
@@ -1486,25 +1485,19 @@ function resourceFields(v, required, optional = []) {
|
|
|
1486
1485
|
});
|
|
1487
1486
|
}
|
|
1488
1487
|
var str2 = (v, max = 256) => typeof v === "string" && v.length > 0 && v.length <= max;
|
|
1489
|
-
function
|
|
1490
|
-
if (method === "sessions.getConnection" && resourceFields(v, [])) return true;
|
|
1491
|
-
return resourceFields(v, ["dataScopeId", "sessionId"]) && str2(v.dataScopeId) && str2(v.sessionId);
|
|
1492
|
-
}
|
|
1493
|
-
function validSessionResourceResult(method, v) {
|
|
1488
|
+
function validSessionResourceResult(_method, v) {
|
|
1494
1489
|
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}`;
|
|
1495
1490
|
}
|
|
1496
1491
|
function createAppSessionsApi(input, streams) {
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1492
|
+
return {
|
|
1493
|
+
async getConnection(...args) {
|
|
1494
|
+
if (args.length !== 0) throw new AppHostError("invalid_request");
|
|
1495
|
+
input.requireFeature();
|
|
1496
|
+
const wire = await input.request("sessions.getConnection", {});
|
|
1497
|
+
if (!validSessionResourceResult("sessions.getConnection", wire)) throw new AppHostError("host_unavailable");
|
|
1498
|
+
return createClientConnection(wire, streams);
|
|
1499
|
+
}
|
|
1503
1500
|
};
|
|
1504
|
-
return { async getConnection(params = {}) {
|
|
1505
|
-
const wire = await call("sessions.getConnection", params);
|
|
1506
|
-
return createClientConnection(wire, streams);
|
|
1507
|
-
} };
|
|
1508
1501
|
}
|
|
1509
1502
|
|
|
1510
1503
|
// src/service.ts
|