@kuafucloud/developer 0.0.0-stage → 0.1.9-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/admin/extension.zip +0 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +2 -0
- package/dist/admin/meta/admin.json +59 -0
- package/dist/admin/meta/extension-manifest.json +794 -0
- package/dist/facade/index.d.ts +241 -0
- package/dist/facade/index.js +11 -0
- package/dist/monitor/runtime-services/app/index.js +660 -0
- package/dist/monitor/runtime-services/app/service-module.config.json +16 -0
- package/dist/monitor/runtime-services/app-simulator/index.js +648 -0
- package/dist/monitor/runtime-services/app-simulator/service-module.config.json +12 -0
- package/dist/monitor/runtime-services/mini-program/index.js +653 -0
- package/dist/monitor/runtime-services/mini-program/service-module.config.json +12 -0
- package/dist/monitor/runtime-services/mini-program-simulator/index.js +648 -0
- package/dist/monitor/runtime-services/mini-program-simulator/service-module.config.json +12 -0
- package/dist/monitor/runtime-services/site/index.js +648 -0
- package/dist/monitor/runtime-services/site/service-module.config.json +12 -0
- package/dist/public/monitor/index.js +6 -0
- package/dist/public/monitor/runtime-services/core/index.js +552 -0
- package/dist/public/realtime/host/index.js +4550 -0
- package/dist/public/realtime/index.js +3180 -0
- package/dist/public/realtime/native-preview-http/index.js +148 -0
- package/dist/simulation/artifact/meta/database.json +43 -0
- package/dist/simulation/artifact/meta/manifest.json +170 -0
- package/dist/simulation/artifact/meta/runtime-meta.json +28 -0
- package/dist/simulation/artifact/meta/schema.json +41 -0
- package/dist/simulation/artifact/server/worker/index.js +39 -0
- package/dist/simulation/artifact/server/worker/monitoring-contract.json +7 -0
- package/dist/simulation/index.d.ts +1 -0
- package/dist/simulation/index.js +1 -0
- package/dist/types/monitor/client/index.d.ts +4 -0
- package/dist/types/monitor/runtime-services/app/index.d.ts +4 -0
- package/dist/types/monitor/runtime-services/app-simulator/index.d.ts +4 -0
- package/dist/types/monitor/runtime-services/core/index.d.ts +1 -0
- package/dist/types/monitor/runtime-services/core/monitor-browser-service.d.ts +25 -0
- package/dist/types/monitor/runtime-services/core/monitor-mini-program-service.d.ts +25 -0
- package/dist/types/monitor/runtime-services/core/monitor-native-service.d.ts +25 -0
- package/dist/types/monitor/runtime-services/core/monitor-service.d.ts +35 -0
- package/dist/types/monitor/runtime-services/mini-program/index.d.ts +4 -0
- package/dist/types/monitor/runtime-services/mini-program-simulator/index.d.ts +4 -0
- package/dist/types/monitor/runtime-services/site/index.d.ts +4 -0
- package/dist/types/realtime/agent-chat-model.d.ts +216 -0
- package/dist/types/realtime/agent-question.d.ts +24 -0
- package/dist/types/realtime/developer-realtime.d.ts +158 -0
- package/dist/types/realtime/host/index.d.ts +28 -0
- package/dist/types/realtime/host-channels.d.ts +52 -0
- package/dist/types/realtime/host-connection.d.ts +131 -0
- package/dist/types/realtime/native-preview-http/index.d.ts +6 -0
- package/dist/types/realtime/native-source-codec.d.ts +21 -0
- package/dist/types/realtime/payload-fragments.d.ts +21 -0
- package/dist/types/realtime/preview-device.d.ts +9 -0
- package/dist/types/realtime/product-preview-cache.d.ts +69 -0
- package/dist/types/realtime/product-preview-clients.d.ts +7 -0
- package/dist/types/realtime/product-preview-host.d.ts +50 -0
- package/dist/types/realtime/product-preview-http-runtime.d.ts +9 -0
- package/dist/types/realtime/product-preview-protocol.d.ts +167 -0
- package/dist/types/realtime/product-preview-socket-source.d.ts +24 -0
- package/dist/types/realtime/product-preview-viewer-http.d.ts +41 -0
- package/dist/types/realtime/product-preview-viewer.d.ts +44 -0
- package/dist/types/realtime/project-workspaces.d.ts +43 -0
- package/dist/types/realtime/viewer/index.d.ts +22 -0
- package/dist/types/realtime/websocket-transport.d.ts +12 -0
- package/dist/types/realtime/workspace-agent-history.d.ts +46 -0
- package/dist/types/realtime/workspace-agent-input.d.ts +38 -0
- package/dist/types/realtime/workspace-agent-member.d.ts +15 -0
- package/dist/types/realtime/workspace-agent-view.d.ts +22 -0
- package/dist/types/realtime/workspace-cache-store.d.ts +38 -0
- package/dist/types/realtime/workspace-cache.d.ts +72 -0
- package/dist/types/realtime/workspace-chat-stream.d.ts +6 -0
- package/dist/types/realtime/workspace-file-view.d.ts +9 -0
- package/dist/types/realtime/workspace-status-view.d.ts +8 -0
- package/dist/types/realtime/workspace-viewer.d.ts +100 -0
- package/extension-manifest.json +457 -0
- package/package.json +112 -4
- package/README.md +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DeveloperSocketTicket, type DeveloperViewerSocket, type DeveloperViewerSocketEvents } from "./workspace-viewer.js";
|
|
2
|
+
import type { DeveloperWorkspaceBinding } from "./workspace-viewer.js";
|
|
3
|
+
export type DeveloperPlatformWebSocket = Pick<WebSocket, "send" | "close" | "readyState" | "bufferedAmount" | "protocol" | "addEventListener" | "removeEventListener"> & {
|
|
4
|
+
/** 仅由已确认支持RFC控制帧的适配器提供;不能猜测平台同名ping的语义。 */
|
|
5
|
+
sendControlPing?(): void;
|
|
6
|
+
};
|
|
7
|
+
/** 工作区只读连接直接携带定位参数;不申请票据,不传账号凭据。 */
|
|
8
|
+
export declare function openWorkspaceReadWebSocket(socketUrl: string, binding: DeveloperWorkspaceBinding, events: DeveloperViewerSocketEvents, signal: AbortSignal, create?: (url: string, protocols: string[]) => DeveloperPlatformWebSocket): Promise<DeveloperViewerSocket>;
|
|
9
|
+
/** Browser/RN共用标准WSS;账号凭据留在API客户端,专用票据只进子协议。 */
|
|
10
|
+
export declare function openDeveloperWebSocket(ticket: DeveloperSocketTicket, events: DeveloperViewerSocketEvents, signal: AbortSignal, create?: (url: string, protocols: string[]) => DeveloperPlatformWebSocket): Promise<DeveloperViewerSocket>;
|
|
11
|
+
/** 产品观看只提交冻结目标;不能用此子协议订阅Agent或提交写命令。 */
|
|
12
|
+
export declare function openProductPreviewWebSocket(socketUrl: string, events: DeveloperViewerSocketEvents, signal: AbortSignal, create?: (url: string, protocols: string[]) => DeveloperPlatformWebSocket): Promise<DeveloperViewerSocket>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type DeveloperCachedAgent, type DeveloperCacheScope, type DeveloperWorkspaceCache } from "./workspace-cache.js";
|
|
2
|
+
import type { DeveloperWorkspaceViewer } from "./workspace-viewer.js";
|
|
3
|
+
export type DeveloperAgentHistoryState = {
|
|
4
|
+
content: DeveloperCachedAgent | null;
|
|
5
|
+
syncing: boolean;
|
|
6
|
+
loadingHistory: boolean;
|
|
7
|
+
hasMore: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
};
|
|
10
|
+
type Viewer = Pick<DeveloperWorkspaceViewer, "subscribe" | "getSnapshot" | "request">;
|
|
11
|
+
/** 本地首屏、有限校准与连续事件的唯一 owner;页面不再自行拼接历史。 */
|
|
12
|
+
export declare class DeveloperAgentHistory {
|
|
13
|
+
private readonly cache;
|
|
14
|
+
private readonly conversationId;
|
|
15
|
+
private readonly membershipEpoch;
|
|
16
|
+
private state;
|
|
17
|
+
private readonly listeners;
|
|
18
|
+
private all;
|
|
19
|
+
private restored?;
|
|
20
|
+
private visible;
|
|
21
|
+
private cursor;
|
|
22
|
+
private viewer?;
|
|
23
|
+
private live?;
|
|
24
|
+
private scope?;
|
|
25
|
+
private streamKey?;
|
|
26
|
+
private abort?;
|
|
27
|
+
private detach?;
|
|
28
|
+
private releaseCache?;
|
|
29
|
+
private closed;
|
|
30
|
+
private initializing;
|
|
31
|
+
private startGeneration;
|
|
32
|
+
constructor(cache: DeveloperWorkspaceCache, conversationId: string, membershipEpoch: string);
|
|
33
|
+
getSnapshot: () => DeveloperAgentHistoryState;
|
|
34
|
+
subscribe: (listener: () => void) => (() => void);
|
|
35
|
+
start(): void;
|
|
36
|
+
attach(viewer: Viewer, scope: DeveloperCacheScope): () => void;
|
|
37
|
+
close(): void;
|
|
38
|
+
private restore;
|
|
39
|
+
private receive;
|
|
40
|
+
private reconcile;
|
|
41
|
+
loadOlder: () => Promise<void>;
|
|
42
|
+
private persist;
|
|
43
|
+
private replace;
|
|
44
|
+
private publish;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type LocalWorkspaceQuestionReply, type LocalWorkspaceChatMessageReceipt, type LocalWorkspaceChatScope } from "@kuafucloud/product-runtime-protocol";
|
|
2
|
+
import type { TimelineMessage } from "./agent-chat-model.js";
|
|
3
|
+
type Attempt = LocalWorkspaceChatScope & {
|
|
4
|
+
clientMessageId: string;
|
|
5
|
+
text: string;
|
|
6
|
+
reply?: LocalWorkspaceQuestionReply;
|
|
7
|
+
};
|
|
8
|
+
export type DeveloperAgentInputState = {
|
|
9
|
+
text: string;
|
|
10
|
+
phase: "draft" | "sending" | "unknown";
|
|
11
|
+
attempt: Readonly<Attempt> | null;
|
|
12
|
+
error: string | null;
|
|
13
|
+
};
|
|
14
|
+
export type DeveloperAgentRequest = (operation: "send" | "receipt", input: unknown) => Promise<unknown>;
|
|
15
|
+
/** 当前聊天详情持有输入意图,切Tab不丢;传输重连不触发发送。 */
|
|
16
|
+
export declare class DeveloperAgentInput {
|
|
17
|
+
private readonly newId;
|
|
18
|
+
private state;
|
|
19
|
+
private listeners;
|
|
20
|
+
private lastAccepted;
|
|
21
|
+
private readonly outbox;
|
|
22
|
+
get accepted(): boolean;
|
|
23
|
+
private questions;
|
|
24
|
+
forQuestion(key: string): DeveloperAgentInput;
|
|
25
|
+
constructor(newId: () => string);
|
|
26
|
+
getSnapshot: () => DeveloperAgentInputState;
|
|
27
|
+
subscribe: (listener: () => void) => (() => void);
|
|
28
|
+
/** 本地发送展示与源端复用 clientMessageId;只投影当前会话,不写入历史缓存。 */
|
|
29
|
+
projectMessages(messages: readonly TimelineMessage[], scope: LocalWorkspaceChatScope, actorSubject: string | null): readonly TimelineMessage[];
|
|
30
|
+
acknowledge(messages: readonly TimelineMessage[], scope: LocalWorkspaceChatScope): void;
|
|
31
|
+
edit(text: string): void;
|
|
32
|
+
submit(scope: LocalWorkspaceChatScope, request: DeveloperAgentRequest, reply?: LocalWorkspaceQuestionReply): Promise<void>;
|
|
33
|
+
private update;
|
|
34
|
+
}
|
|
35
|
+
export declare function readDeveloperAgentReceipt(value: unknown, expected: LocalWorkspaceChatScope & {
|
|
36
|
+
clientMessageId: string;
|
|
37
|
+
}): LocalWorkspaceChatMessageReceipt;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AgentMessageMember } from "./agent-chat-model.js";
|
|
2
|
+
/** 平台工作区群的虚拟成员展示;不修改通用IM目录,也不授予任何操作权限。 */
|
|
3
|
+
type WorkspaceConversation = {
|
|
4
|
+
kind: string;
|
|
5
|
+
title: string;
|
|
6
|
+
tags?: readonly string[];
|
|
7
|
+
memberSubjects: readonly string[];
|
|
8
|
+
};
|
|
9
|
+
export declare function workspaceAgentMember(conversation: WorkspaceConversation, subject: string): AgentMessageMember | undefined;
|
|
10
|
+
/** 资料明确使用 ID 回退时,平台页面才可使用当前工作区的本地名称。 */
|
|
11
|
+
export declare function workspaceSenderName(conversation: WorkspaceConversation, subject: string, ...profiles: readonly ({
|
|
12
|
+
displayName: string;
|
|
13
|
+
nameSource?: "profile" | "id";
|
|
14
|
+
} | undefined)[]): string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LocalWorkspaceChatSnapshot } from "@kuafucloud/product-runtime-protocol";
|
|
2
|
+
import type { TimelineMessage } from "./agent-chat-model.js";
|
|
3
|
+
export type DeveloperHistoryCursor = {
|
|
4
|
+
hasMore: boolean;
|
|
5
|
+
nextBefore: number | null;
|
|
6
|
+
beforeMessageId?: string;
|
|
7
|
+
};
|
|
8
|
+
export type DeveloperAgentView = {
|
|
9
|
+
snapshot: LocalWorkspaceChatSnapshot;
|
|
10
|
+
history: DeveloperHistoryCursor;
|
|
11
|
+
stream: TimelineMessage[];
|
|
12
|
+
messages: TimelineMessage[];
|
|
13
|
+
};
|
|
14
|
+
/** 远端首帧必须携带真实最近页边界;不得把缺少历史信息误判为没有更早消息。 */
|
|
15
|
+
export declare function readDeveloperAgentView(workspaceId: string, input: unknown): DeveloperAgentView;
|
|
16
|
+
/** Socket的物理帧顺序由Viewer核验,此处只核验业务会话并复用本地消息归并。 */
|
|
17
|
+
export declare function applyDeveloperAgentEvent(view: DeveloperAgentView, input: unknown): DeveloperAgentView;
|
|
18
|
+
/** 同一观察流的新最近页不丢已加载历史;会话变化必须从新的首帧开始。 */
|
|
19
|
+
export declare function refreshDeveloperAgentView(next: DeveloperAgentView, previous?: DeveloperAgentView): DeveloperAgentView;
|
|
20
|
+
export declare function mergeDeveloperAgentHistory(view: DeveloperAgentView, value: unknown, beforeSeq: number, beforeMessageId?: string): DeveloperAgentView;
|
|
21
|
+
/** 新快照或最近页提供权威顺序;只在前面保留其窗口之外的已读历史。 */
|
|
22
|
+
export declare function mergeAgentHistoryWindow(older: readonly TimelineMessage[], latest: readonly TimelineMessage[]): TimelineMessage[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DeveloperProductsSnapshot } from "./developer-realtime.js";
|
|
2
|
+
import { type DeveloperCachedAgent, type DeveloperCachedHistory, type DeveloperCacheScope } from "./workspace-cache.js";
|
|
3
|
+
/** 分区由宿主的账号/产品 Authority 决定;记录中不接受调用方自报账号或文件路径。 */
|
|
4
|
+
export type DeveloperCacheRecord = {
|
|
5
|
+
scope: DeveloperCacheScope;
|
|
6
|
+
agent?: DeveloperCachedAgent;
|
|
7
|
+
history?: DeveloperCachedHistory;
|
|
8
|
+
products?: DeveloperProductsSnapshot;
|
|
9
|
+
workspaceMissing?: true;
|
|
10
|
+
};
|
|
11
|
+
export interface DeveloperCacheStore {
|
|
12
|
+
read(conversationId: string): Promise<DeveloperCacheRecord | null>;
|
|
13
|
+
readMissing(): Promise<readonly DeveloperCacheScope[]>;
|
|
14
|
+
write(record: DeveloperCacheRecord): Promise<void>;
|
|
15
|
+
remove(conversationId: string): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export type DeveloperCacheTransaction = (statements: readonly {
|
|
19
|
+
sql: string;
|
|
20
|
+
parameters?: readonly (string | number | null)[];
|
|
21
|
+
}[]) => Promise<readonly {
|
|
22
|
+
rows: readonly Readonly<Record<string, unknown>>[];
|
|
23
|
+
}[]>;
|
|
24
|
+
/** 两端使用同一 SQL 合同。正文按消息存储,元数据和裁剪在同一个事务提交。 */
|
|
25
|
+
export declare class SqliteDeveloperCacheStore implements DeveloperCacheStore {
|
|
26
|
+
private readonly transaction;
|
|
27
|
+
private readonly release;
|
|
28
|
+
private initialized?;
|
|
29
|
+
constructor(transaction: DeveloperCacheTransaction, release?: () => Promise<void>);
|
|
30
|
+
private initialize;
|
|
31
|
+
read(conversationId: string): Promise<DeveloperCacheRecord | null>;
|
|
32
|
+
/** 会话列表只读轻量标记,不为显示标题加载每个群的千条历史。 */
|
|
33
|
+
readMissing(): Promise<readonly DeveloperCacheScope[]>;
|
|
34
|
+
write(record: DeveloperCacheRecord): Promise<void>;
|
|
35
|
+
remove(conversationId: string): Promise<void>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare function assertDeveloperCacheRecord(value: unknown): asserts value is DeveloperCacheRecord;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DeveloperProductsSnapshot } from "./developer-realtime.js";
|
|
2
|
+
import type { DeveloperAgentView } from "./workspace-agent-view.js";
|
|
3
|
+
import type { DeveloperCacheStore } from "./workspace-cache-store.js";
|
|
4
|
+
export declare const DEVELOPER_AGENT_CACHE_MESSAGES = 1000;
|
|
5
|
+
/** 缓存实例由当前Runtime/Host服务会话独占,环境、Project、账号切换必须换实例。 */
|
|
6
|
+
export type DeveloperCacheScope = {
|
|
7
|
+
conversationId: string;
|
|
8
|
+
membershipEpoch: string;
|
|
9
|
+
hostDeviceId: string;
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
};
|
|
12
|
+
/** 仅用于首屏展示。没有连接水位和历史游标,不能直接用于发送或分页。 */
|
|
13
|
+
export type DeveloperCachedAgent = {
|
|
14
|
+
snapshot: Pick<DeveloperAgentView["snapshot"], "workspaceId" | "sessionId" | "status" | "updatedAt">;
|
|
15
|
+
messages: DeveloperAgentView["messages"];
|
|
16
|
+
};
|
|
17
|
+
export type DeveloperCachedHistory = {
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
beforeMessageId?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare class DeveloperWorkspaceCache {
|
|
22
|
+
private readonly store?;
|
|
23
|
+
private readonly bindings;
|
|
24
|
+
private readonly listeners;
|
|
25
|
+
private readonly pending;
|
|
26
|
+
private readonly hydrating;
|
|
27
|
+
private readonly loaded;
|
|
28
|
+
private timer?;
|
|
29
|
+
private writes;
|
|
30
|
+
private revision;
|
|
31
|
+
private generation;
|
|
32
|
+
private storageError;
|
|
33
|
+
private missingRevision;
|
|
34
|
+
private missingLoad?;
|
|
35
|
+
private readonly invalidated;
|
|
36
|
+
private readonly confirmedPresent;
|
|
37
|
+
constructor(store?: DeveloperCacheStore | undefined);
|
|
38
|
+
subscribe: (listener: () => void) => (() => void);
|
|
39
|
+
getRevision: () => number;
|
|
40
|
+
getMissingRevision: () => number;
|
|
41
|
+
isMissing(conversationId: string, membershipEpoch: string): boolean;
|
|
42
|
+
/** 账号分区中的已确认事实;普通断线不调用此入口,也不创建Host删除记录。 */
|
|
43
|
+
restoreMissing(): Promise<void>;
|
|
44
|
+
getStorageError: () => string | null;
|
|
45
|
+
hasHydrated(conversationId: string, membershipEpoch: string): boolean;
|
|
46
|
+
private notify;
|
|
47
|
+
/** 读取本地绑定与历史,不依赖远端 resolve;迟到读取不能覆盖新连接已写入的数据。 */
|
|
48
|
+
hydrate(conversationId: string, membershipEpoch: string): Promise<void>;
|
|
49
|
+
/** 合并短时片段写入;关闭时 flush,持久化失败保持可观察错误,不伪称保存成功。 */
|
|
50
|
+
flush(): Promise<void>;
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
private persist;
|
|
53
|
+
/** 只接受resolve返回且与IM成员代际一致的绑定。 */
|
|
54
|
+
bind(scope: DeveloperCacheScope): void;
|
|
55
|
+
resolve(conversationId: string, membershipEpoch: string): DeveloperCacheScope | null;
|
|
56
|
+
private readonly entries;
|
|
57
|
+
readAgent(scope: DeveloperCacheScope): DeveloperCachedAgent | null;
|
|
58
|
+
readProducts(scope: DeveloperCacheScope): DeveloperProductsSnapshot | null;
|
|
59
|
+
/** 仅在新首帧证实同会话且有重叠时保留更早缓存;分页由Host重新解析消息身份。 */
|
|
60
|
+
restoreAgent(scope: DeveloperCacheScope, next: DeveloperAgentView): DeveloperAgentView;
|
|
61
|
+
saveAgent(scope: DeveloperCacheScope, view: DeveloperAgentView): void;
|
|
62
|
+
saveProducts(scope: DeveloperCacheScope, products: DeveloperProductsSnapshot): void;
|
|
63
|
+
/** 明确不存在只清空产品入口,保留群对应的本地Agent历史。 */
|
|
64
|
+
removeProducts(scope: DeveloperCacheScope): void;
|
|
65
|
+
markMissing(scope: DeveloperCacheScope): void;
|
|
66
|
+
private confirmPresent;
|
|
67
|
+
readHistory(scope: DeveloperCacheScope): DeveloperCachedHistory | null;
|
|
68
|
+
invalidate(scope: DeveloperCacheScope): void;
|
|
69
|
+
/** 只释放内存;清理磁盘必须显式 invalidate,页面卸载不删除持久历史。 */
|
|
70
|
+
clear(): void;
|
|
71
|
+
private entry;
|
|
72
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LocalWorkspaceAgentDelta, LocalWorkspaceChatSnapshot } from "@kuafucloud/product-runtime-protocol";
|
|
2
|
+
import { type TimelineMessage } from "./agent-chat-model.js";
|
|
3
|
+
/** 本地研发页和远端观看端共用;seq属于消息,不是片段去重键。 */
|
|
4
|
+
export declare function applyWorkspaceChatStream(snapshot: LocalWorkspaceChatSnapshot, stream: readonly TimelineMessage[], delta: LocalWorkspaceAgentDelta): TimelineMessage[];
|
|
5
|
+
export declare function restoreWorkspaceChatStream(snapshot: LocalWorkspaceChatSnapshot): TimelineMessage[];
|
|
6
|
+
export declare function workspaceChatTimeline(snapshot: LocalWorkspaceChatSnapshot, stream?: TimelineMessage[], agentLabel?: string): TimelineMessage[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DeveloperWorkspaceViewer } from "./workspace-viewer.js";
|
|
2
|
+
export type DeveloperFilePreview = {
|
|
3
|
+
path: string;
|
|
4
|
+
kind: "text" | "image";
|
|
5
|
+
content: string;
|
|
6
|
+
truncated?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** 只读文件与聊天复用同一Viewer,返回值必须来自原绑定工作区。 */
|
|
9
|
+
export declare function readDeveloperWorkspaceFile(viewer: DeveloperWorkspaceViewer, workspaceId: string, path: string, mode: "read" | "image", signal: AbortSignal): Promise<DeveloperFilePreview>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type WorkspaceStatusView = Readonly<{
|
|
2
|
+
workspaceId: string;
|
|
3
|
+
state: "running" | "waiting" | "idle" | "offline" | "unknown";
|
|
4
|
+
confirmation: "current" | "cached";
|
|
5
|
+
observedAt: number;
|
|
6
|
+
}>;
|
|
7
|
+
/** 只投影受信IM当前值;不观察Host、不按采样年龄让长任务过期,也不借消息projectionFresh判断在线。 */
|
|
8
|
+
export declare function workspaceStatusView(conversation: unknown, imStatus: string): WorkspaceStatusView | null;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type DeveloperObserveKind, type DeveloperRelayFrame, type DeveloperWorkspaceViewState, type DeveloperProductItem } from "./developer-realtime.js";
|
|
2
|
+
import { DeveloperPayloadAssembly } from "./payload-fragments.js";
|
|
3
|
+
export type DeveloperWorkspaceBinding = {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
conversationId: string;
|
|
6
|
+
hostDeviceId: string;
|
|
7
|
+
};
|
|
8
|
+
export type DeveloperSocketTicket = {
|
|
9
|
+
socketUrl: string;
|
|
10
|
+
ticket: string;
|
|
11
|
+
expiresAt: number;
|
|
12
|
+
};
|
|
13
|
+
export type DeveloperViewerSocket = {
|
|
14
|
+
send(text: string): void;
|
|
15
|
+
sendBinary?(bytes: ArrayBuffer, signal: AbortSignal): Promise<void>;
|
|
16
|
+
close(code?: number, reason?: string): void;
|
|
17
|
+
};
|
|
18
|
+
export type DeveloperViewerSocketEvents = {
|
|
19
|
+
message(data: unknown): void;
|
|
20
|
+
closed(): void;
|
|
21
|
+
failed(): void;
|
|
22
|
+
};
|
|
23
|
+
export type DeveloperWorkspaceViewerPorts = ({
|
|
24
|
+
authorize(binding: DeveloperWorkspaceBinding, signal: AbortSignal): Promise<DeveloperSocketTicket>;
|
|
25
|
+
open(ticket: DeveloperSocketTicket, events: DeveloperViewerSocketEvents, signal: AbortSignal): DeveloperViewerSocket | Promise<DeveloperViewerSocket>;
|
|
26
|
+
} | {
|
|
27
|
+
/** 本机已核验工作区直接建立IPC,不签发或伪造远端票据。 */
|
|
28
|
+
connect(events: DeveloperViewerSocketEvents, signal: AbortSignal): DeveloperViewerSocket | Promise<DeveloperViewerSocket>;
|
|
29
|
+
}) & {
|
|
30
|
+
snapshot(kind: DeveloperObserveKind, payload: unknown, previous?: unknown): unknown;
|
|
31
|
+
event(kind: DeveloperObserveKind, content: unknown, payload: unknown): unknown;
|
|
32
|
+
newId(): string;
|
|
33
|
+
diagnostic?(code: string): void;
|
|
34
|
+
/** 仅send/receipt使用;读取和重连不触发账号身份获取。 */
|
|
35
|
+
authorizeInput?(binding: DeveloperWorkspaceBinding, signal: AbortSignal): Promise<string>;
|
|
36
|
+
preview?: DeveloperProductItem["preview"];
|
|
37
|
+
};
|
|
38
|
+
export declare class DeveloperRealtimeClientError extends Error {
|
|
39
|
+
readonly code: string;
|
|
40
|
+
readonly outcome?: "unknown" | undefined;
|
|
41
|
+
readonly details?: unknown | undefined;
|
|
42
|
+
constructor(code: string, outcome?: "unknown" | undefined, details?: unknown | undefined);
|
|
43
|
+
}
|
|
44
|
+
type Pending = {
|
|
45
|
+
operation: "history" | "send" | "receipt" | "file";
|
|
46
|
+
resolve(value: unknown): void;
|
|
47
|
+
reject(error: Error): void;
|
|
48
|
+
cleanup(): void;
|
|
49
|
+
assembly: DeveloperPayloadAssembly;
|
|
50
|
+
};
|
|
51
|
+
/** 聊天页持有轻量连接状态;仅可见研发Tab订阅内容,IM常驻owner独立。 */
|
|
52
|
+
export declare class DeveloperWorkspaceViewer {
|
|
53
|
+
private readonly binding;
|
|
54
|
+
private readonly ports;
|
|
55
|
+
private readonly views;
|
|
56
|
+
private readonly connectionListeners;
|
|
57
|
+
private connectionState;
|
|
58
|
+
getConnectionSnapshot: () => {
|
|
59
|
+
connecting: boolean;
|
|
60
|
+
hostOffline: boolean;
|
|
61
|
+
};
|
|
62
|
+
subscribeConnection: (listener: () => void) => (() => void);
|
|
63
|
+
private setConnectionState;
|
|
64
|
+
private readonly pending;
|
|
65
|
+
private connection?;
|
|
66
|
+
private retryTimer?;
|
|
67
|
+
private attempt;
|
|
68
|
+
private serial;
|
|
69
|
+
private closed;
|
|
70
|
+
private missing;
|
|
71
|
+
constructor(binding: DeveloperWorkspaceBinding, ports: DeveloperWorkspaceViewerPorts);
|
|
72
|
+
getSnapshot(kind: DeveloperObserveKind): Readonly<DeveloperWorkspaceViewState>;
|
|
73
|
+
/** 分页响应只可归并到发起时的连接流;其间新增实时事件由归并器保留。 */
|
|
74
|
+
updateContent(kind: DeveloperObserveKind, expected: Pick<DeveloperWorkspaceViewState, "generation" | "streamId">, update: (content: unknown) => unknown): boolean;
|
|
75
|
+
subscribe(kind: DeveloperObserveKind, listener: () => void): () => void;
|
|
76
|
+
/** 输入从不自动重放;结果未知时调用方只能按原业务clientMessageId查询receipt。 */
|
|
77
|
+
request(operation: Pending["operation"], input: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
78
|
+
retry(): void;
|
|
79
|
+
close(): void;
|
|
80
|
+
private connect;
|
|
81
|
+
private receive;
|
|
82
|
+
private apply;
|
|
83
|
+
private subscribeView;
|
|
84
|
+
private send;
|
|
85
|
+
private failed;
|
|
86
|
+
private disconnect;
|
|
87
|
+
private reset;
|
|
88
|
+
private notify;
|
|
89
|
+
private finishRequest;
|
|
90
|
+
private failRequests;
|
|
91
|
+
private requestError;
|
|
92
|
+
private observed;
|
|
93
|
+
private current;
|
|
94
|
+
private clearRetry;
|
|
95
|
+
private kinds;
|
|
96
|
+
private nextId;
|
|
97
|
+
}
|
|
98
|
+
/** Viewer只接收该角色帧,二期二进制/资源协议不能混入一期内容。 */
|
|
99
|
+
export declare function decodeDeveloperViewerFrame(raw: unknown): DeveloperRelayFrame;
|
|
100
|
+
export {};
|