@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.
Files changed (75) hide show
  1. package/dist/admin/admin/extension.zip +0 -0
  2. package/dist/admin/index.d.ts +2 -0
  3. package/dist/admin/index.js +2 -0
  4. package/dist/admin/meta/admin.json +59 -0
  5. package/dist/admin/meta/extension-manifest.json +794 -0
  6. package/dist/facade/index.d.ts +241 -0
  7. package/dist/facade/index.js +11 -0
  8. package/dist/monitor/runtime-services/app/index.js +660 -0
  9. package/dist/monitor/runtime-services/app/service-module.config.json +16 -0
  10. package/dist/monitor/runtime-services/app-simulator/index.js +648 -0
  11. package/dist/monitor/runtime-services/app-simulator/service-module.config.json +12 -0
  12. package/dist/monitor/runtime-services/mini-program/index.js +653 -0
  13. package/dist/monitor/runtime-services/mini-program/service-module.config.json +12 -0
  14. package/dist/monitor/runtime-services/mini-program-simulator/index.js +648 -0
  15. package/dist/monitor/runtime-services/mini-program-simulator/service-module.config.json +12 -0
  16. package/dist/monitor/runtime-services/site/index.js +648 -0
  17. package/dist/monitor/runtime-services/site/service-module.config.json +12 -0
  18. package/dist/public/monitor/index.js +6 -0
  19. package/dist/public/monitor/runtime-services/core/index.js +552 -0
  20. package/dist/public/realtime/host/index.js +4550 -0
  21. package/dist/public/realtime/index.js +3180 -0
  22. package/dist/public/realtime/native-preview-http/index.js +148 -0
  23. package/dist/simulation/artifact/meta/database.json +43 -0
  24. package/dist/simulation/artifact/meta/manifest.json +170 -0
  25. package/dist/simulation/artifact/meta/runtime-meta.json +28 -0
  26. package/dist/simulation/artifact/meta/schema.json +41 -0
  27. package/dist/simulation/artifact/server/worker/index.js +39 -0
  28. package/dist/simulation/artifact/server/worker/monitoring-contract.json +7 -0
  29. package/dist/simulation/index.d.ts +1 -0
  30. package/dist/simulation/index.js +1 -0
  31. package/dist/types/monitor/client/index.d.ts +4 -0
  32. package/dist/types/monitor/runtime-services/app/index.d.ts +4 -0
  33. package/dist/types/monitor/runtime-services/app-simulator/index.d.ts +4 -0
  34. package/dist/types/monitor/runtime-services/core/index.d.ts +1 -0
  35. package/dist/types/monitor/runtime-services/core/monitor-browser-service.d.ts +25 -0
  36. package/dist/types/monitor/runtime-services/core/monitor-mini-program-service.d.ts +25 -0
  37. package/dist/types/monitor/runtime-services/core/monitor-native-service.d.ts +25 -0
  38. package/dist/types/monitor/runtime-services/core/monitor-service.d.ts +35 -0
  39. package/dist/types/monitor/runtime-services/mini-program/index.d.ts +4 -0
  40. package/dist/types/monitor/runtime-services/mini-program-simulator/index.d.ts +4 -0
  41. package/dist/types/monitor/runtime-services/site/index.d.ts +4 -0
  42. package/dist/types/realtime/agent-chat-model.d.ts +216 -0
  43. package/dist/types/realtime/agent-question.d.ts +24 -0
  44. package/dist/types/realtime/developer-realtime.d.ts +158 -0
  45. package/dist/types/realtime/host/index.d.ts +28 -0
  46. package/dist/types/realtime/host-channels.d.ts +52 -0
  47. package/dist/types/realtime/host-connection.d.ts +131 -0
  48. package/dist/types/realtime/native-preview-http/index.d.ts +6 -0
  49. package/dist/types/realtime/native-source-codec.d.ts +21 -0
  50. package/dist/types/realtime/payload-fragments.d.ts +21 -0
  51. package/dist/types/realtime/preview-device.d.ts +9 -0
  52. package/dist/types/realtime/product-preview-cache.d.ts +69 -0
  53. package/dist/types/realtime/product-preview-clients.d.ts +7 -0
  54. package/dist/types/realtime/product-preview-host.d.ts +50 -0
  55. package/dist/types/realtime/product-preview-http-runtime.d.ts +9 -0
  56. package/dist/types/realtime/product-preview-protocol.d.ts +167 -0
  57. package/dist/types/realtime/product-preview-socket-source.d.ts +24 -0
  58. package/dist/types/realtime/product-preview-viewer-http.d.ts +41 -0
  59. package/dist/types/realtime/product-preview-viewer.d.ts +44 -0
  60. package/dist/types/realtime/project-workspaces.d.ts +43 -0
  61. package/dist/types/realtime/viewer/index.d.ts +22 -0
  62. package/dist/types/realtime/websocket-transport.d.ts +12 -0
  63. package/dist/types/realtime/workspace-agent-history.d.ts +46 -0
  64. package/dist/types/realtime/workspace-agent-input.d.ts +38 -0
  65. package/dist/types/realtime/workspace-agent-member.d.ts +15 -0
  66. package/dist/types/realtime/workspace-agent-view.d.ts +22 -0
  67. package/dist/types/realtime/workspace-cache-store.d.ts +38 -0
  68. package/dist/types/realtime/workspace-cache.d.ts +72 -0
  69. package/dist/types/realtime/workspace-chat-stream.d.ts +6 -0
  70. package/dist/types/realtime/workspace-file-view.d.ts +9 -0
  71. package/dist/types/realtime/workspace-status-view.d.ts +8 -0
  72. package/dist/types/realtime/workspace-viewer.d.ts +100 -0
  73. package/extension-manifest.json +457 -0
  74. package/package.json +112 -4
  75. package/README.md +0 -3
@@ -0,0 +1,7 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "consolePolicy": "runtime-bootstrap-v1",
4
+ "scriptDigest": "sha256:3f310cf6728dd1b2a15233e2fe63f03a3430a8ee3eaa3eee3ca3d432f64c0634",
5
+ "extensionId": "developer",
6
+ "releaseSource": "PLATFORM_EXTENSION_RELEASE"
7
+ }
@@ -0,0 +1 @@
1
+ export declare const artifactRoot: URL;
@@ -0,0 +1 @@
1
+ export const artifactRoot = new URL("./artifact/", import.meta.url);
@@ -0,0 +1,4 @@
1
+ import type { MonitorApi } from "@kuafucloud/product-runtime-protocol";
2
+ export type { ClientCallOptions, MonitorApi, MonitorCaptureReceipt, MonitorErrorCode, MonitorEventContext, MonitorFlushOutcome, MonitorFlushResult, MonitorSpanContext, MonitorSpanOptions, } from "@kuafucloud/product-runtime-protocol";
3
+ /** Product 通过当前实例的 services.get(Monitor) 访问,不暴露 SDK、DSN 或传输凭据。 */
4
+ export declare const Monitor: import("@kuafucloud/product-runtime-protocol").ServiceKey<MonitorApi>;
@@ -0,0 +1,4 @@
1
+ import type { MonitorBackendV1 } from "@kuafucloud/product-runtime-protocol";
2
+ import { type MonitorApi } from "@kuafucloud/developer/monitor";
3
+ declare const _default: import("@kuafucloud/product-runtime-protocol").ServiceModuleDefinition<MonitorApi, MonitorBackendV1>;
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { MonitorBackendV1 } from "@kuafucloud/product-runtime-protocol";
2
+ import { type MonitorApi } from "@kuafucloud/developer/monitor";
3
+ declare const _default: import("@kuafucloud/product-runtime-protocol").ServiceModuleDefinition<MonitorApi, MonitorBackendV1>;
4
+ export default _default;
@@ -0,0 +1 @@
1
+ export { createMonitorService } from "./monitor-service.js";
@@ -0,0 +1,25 @@
1
+ import { createMonitorService } from "./monitor-service.js";
2
+ type Context = Parameters<typeof createMonitorService>[0];
3
+ /** 仅供网页 Runtime 的正式 Module 使用;不向业务暴露全局观察器。 */
4
+ export declare function createBrowserMonitorService(context: Context): {
5
+ start(input: {
6
+ signal: AbortSignal;
7
+ }): Promise<void>;
8
+ stop(input?: {
9
+ signal: AbortSignal;
10
+ }): Promise<void>;
11
+ api: import("@kuafucloud/product-runtime-protocol").MonitorApi;
12
+ wake: () => void;
13
+ captureAutomatic: (error: unknown, mechanism?: "unhandled" | "resource", correlation?: object) => Promise<{
14
+ readonly ok: true;
15
+ readonly data: import("@kuafucloud/product-runtime-protocol").MonitorCaptureReceipt;
16
+ } | {
17
+ readonly ok: false;
18
+ readonly error: import("@kuafucloud/product-runtime-protocol").KuafuClientError<import("@kuafucloud/product-runtime-protocol").MonitorErrorCode>;
19
+ }>;
20
+ drain: (input: {
21
+ deadline: number;
22
+ signal: AbortSignal;
23
+ }) => Promise<void>;
24
+ };
25
+ export {};
@@ -0,0 +1,25 @@
1
+ import { createMonitorService } from "./monitor-service.js";
2
+ type Context = Parameters<typeof createMonitorService>[0];
3
+ /** 微信只使用平台公开回调,不替换 App 定义或吞掉业务错误处理。 */
4
+ export declare function createMiniProgramMonitorService(context: Context): {
5
+ start(input: {
6
+ signal: AbortSignal;
7
+ }): Promise<void>;
8
+ stop(input?: {
9
+ signal: AbortSignal;
10
+ }): Promise<void>;
11
+ api: import("@kuafucloud/product-runtime-protocol").MonitorApi;
12
+ wake: () => void;
13
+ captureAutomatic: (error: unknown, mechanism?: "unhandled" | "resource", correlation?: object) => Promise<{
14
+ readonly ok: true;
15
+ readonly data: import("@kuafucloud/product-runtime-protocol").MonitorCaptureReceipt;
16
+ } | {
17
+ readonly ok: false;
18
+ readonly error: import("@kuafucloud/product-runtime-protocol").KuafuClientError<import("@kuafucloud/product-runtime-protocol").MonitorErrorCode>;
19
+ }>;
20
+ drain: (input: {
21
+ deadline: number;
22
+ signal: AbortSignal;
23
+ }) => Promise<void>;
24
+ };
25
+ export {};
@@ -0,0 +1,25 @@
1
+ import { createMonitorService } from "./monitor-service.js";
2
+ type Context = Parameters<typeof createMonitorService>[0];
3
+ /** 只观察 React Native 已建立的 JS 错误边界,不替换其异常展示和终止行为。 */
4
+ export declare function createNativeMonitorService(context: Context): {
5
+ start(input: {
6
+ signal: AbortSignal;
7
+ }): Promise<void>;
8
+ stop(input?: {
9
+ signal: AbortSignal;
10
+ }): Promise<void>;
11
+ api: import("@kuafucloud/product-runtime-protocol").MonitorApi;
12
+ wake: () => void;
13
+ captureAutomatic: (error: unknown, mechanism?: "unhandled" | "resource", correlation?: object) => Promise<{
14
+ readonly ok: true;
15
+ readonly data: import("@kuafucloud/product-runtime-protocol").MonitorCaptureReceipt;
16
+ } | {
17
+ readonly ok: false;
18
+ readonly error: import("@kuafucloud/product-runtime-protocol").KuafuClientError<import("@kuafucloud/product-runtime-protocol").MonitorErrorCode>;
19
+ }>;
20
+ drain: (input: {
21
+ deadline: number;
22
+ signal: AbortSignal;
23
+ }) => Promise<void>;
24
+ };
25
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { KuafuResult, MonitorApi, MonitorBackendV1, MonitorCaptureReceipt, MonitorErrorCode } from "@kuafucloud/product-runtime-protocol";
2
+ type Store = {
3
+ get<T>(key: string): Promise<T | null>;
4
+ set<T>(key: string, value: T): Promise<void>;
5
+ };
6
+ type CaptureResult = KuafuResult<MonitorCaptureReceipt, MonitorErrorCode>;
7
+ /** 私有共享核心;存储、发生证据及传输均由正式 Runtime/Module 组合根提供。 */
8
+ export declare function createMonitorService(context: {
9
+ readonly backend: MonitorBackendV1;
10
+ readonly storage: {
11
+ durable(namespace: string): Store;
12
+ };
13
+ readonly diagnostics: {
14
+ write(input: {
15
+ code: string;
16
+ }): void;
17
+ };
18
+ }): {
19
+ api: MonitorApi;
20
+ start: (input: {
21
+ signal: AbortSignal;
22
+ }) => Promise<void>;
23
+ /** 生命周期和连通性只唤醒既有 Outbox,不给业务暴露传输配置。 */
24
+ wake: () => void;
25
+ /** Runtime 自动适配入口,不作为业务 API 导出。 */
26
+ captureAutomatic: (error: unknown, mechanism?: "unhandled" | "resource", correlation?: object) => Promise<CaptureResult>;
27
+ drain: (input: {
28
+ deadline: number;
29
+ signal: AbortSignal;
30
+ }) => Promise<void>;
31
+ stop: (_input?: {
32
+ signal: AbortSignal;
33
+ }) => Promise<void>;
34
+ };
35
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MonitorBackendV1 } from "@kuafucloud/product-runtime-protocol";
2
+ import { type MonitorApi } from "@kuafucloud/developer/monitor";
3
+ declare const _default: import("@kuafucloud/product-runtime-protocol").ServiceModuleDefinition<MonitorApi, MonitorBackendV1>;
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { MonitorBackendV1 } from "@kuafucloud/product-runtime-protocol";
2
+ import { type MonitorApi } from "@kuafucloud/developer/monitor";
3
+ declare const _default: import("@kuafucloud/product-runtime-protocol").ServiceModuleDefinition<MonitorApi, MonitorBackendV1>;
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { MonitorBackendV1 } from "@kuafucloud/product-runtime-protocol";
2
+ import { type MonitorApi } from "@kuafucloud/developer/monitor";
3
+ declare const _default: import("@kuafucloud/product-runtime-protocol").ServiceModuleDefinition<MonitorApi, MonitorBackendV1>;
4
+ export default _default;
@@ -0,0 +1,216 @@
1
+ import { type AgentQuestionPart } from "./agent-question.js";
2
+ import { type LocalWorkspaceAttachment } from "@kuafucloud/product-runtime-protocol";
3
+ /** Host与App共用的Agent消息语义归并;不含组件、账号API或本机访问。 */
4
+ export type WorkspaceAgentRole = "user" | "assistant" | "system";
5
+ export type WorkspaceAgentMessage = {
6
+ actorSubject?: string;
7
+ messageId?: string;
8
+ role: WorkspaceAgentRole;
9
+ content: string;
10
+ createdAt: string;
11
+ kind?: "message" | "thinking" | "tool" | "interactive" | "permission" | "error" | "task";
12
+ status?: "streaming" | "final" | "error";
13
+ payload?: unknown;
14
+ model?: string;
15
+ };
16
+ export type ContentPart = AgentQuestionPart | {
17
+ type: "text";
18
+ text: string;
19
+ runId?: string;
20
+ agentId?: string;
21
+ parentRunId?: string;
22
+ } | {
23
+ type: "system.message";
24
+ text: string;
25
+ runId?: string;
26
+ agentId?: string;
27
+ parentRunId?: string;
28
+ } | {
29
+ type: "reasoning";
30
+ text: string;
31
+ runId?: string;
32
+ agentId?: string;
33
+ parentRunId?: string;
34
+ } | {
35
+ type: "tool-call";
36
+ toolCallId: string;
37
+ toolName: string;
38
+ args: unknown;
39
+ result?: unknown;
40
+ status?: "pending" | "running" | "completed" | "error";
41
+ runId?: string;
42
+ agentId?: string;
43
+ parentRunId?: string;
44
+ } | {
45
+ type: "agent-run";
46
+ runId: string;
47
+ parentRunId?: string | null;
48
+ agentId: string;
49
+ agentNickname?: string;
50
+ agentName?: string;
51
+ status: "queued" | "running" | "waiting" | "done" | "failed" | "cancelled";
52
+ model?: string;
53
+ summary?: string;
54
+ startedAt?: string;
55
+ completedAt?: string;
56
+ recentToolName?: string;
57
+ } | {
58
+ type: "agent.activity";
59
+ activityId: string;
60
+ status: "running" | "completed" | "error";
61
+ title: string;
62
+ icon: "read" | "search" | "command" | "edit" | "tool" | "mixed";
63
+ counts?: Partial<Record<"read" | "search" | "command" | "edit" | "tool", number>>;
64
+ runId?: string;
65
+ agentId?: string;
66
+ startedAt?: string;
67
+ completedAt?: string;
68
+ } | {
69
+ type: "file";
70
+ fileName: string;
71
+ attachment?: LocalWorkspaceAttachment;
72
+ path?: string;
73
+ url?: string;
74
+ mime?: string;
75
+ source?: string;
76
+ kind?: "image" | "file";
77
+ size?: number;
78
+ width?: number;
79
+ height?: number;
80
+ runId?: string;
81
+ agentId?: string;
82
+ } | {
83
+ type: "step";
84
+ status: "started" | "finished";
85
+ label?: string;
86
+ runId?: string;
87
+ agentId?: string;
88
+ } | {
89
+ type: "snapshot";
90
+ label?: string;
91
+ summary?: string;
92
+ runId?: string;
93
+ agentId?: string;
94
+ } | {
95
+ type: "patch";
96
+ summary?: string;
97
+ files?: Array<string | PatchContentFile>;
98
+ hash?: string;
99
+ turnId?: string;
100
+ snapshotRef?: string;
101
+ snapshotId?: string;
102
+ delivery?: {
103
+ deliveryId: string;
104
+ taskKey: string;
105
+ revision: string;
106
+ };
107
+ versionLabel?: string;
108
+ createdAt?: string;
109
+ runId?: string;
110
+ agentId?: string;
111
+ } | {
112
+ type: "retry";
113
+ attempt: number;
114
+ error?: string;
115
+ runId?: string;
116
+ agentId?: string;
117
+ } | {
118
+ type: "compaction";
119
+ summary?: string;
120
+ runId?: string;
121
+ agentId?: string;
122
+ } | {
123
+ type: "todo";
124
+ items: Array<{
125
+ id?: string;
126
+ text: string;
127
+ status?: string;
128
+ }>;
129
+ runId?: string;
130
+ agentId?: string;
131
+ } | {
132
+ type: "command";
133
+ command: string;
134
+ args?: unknown;
135
+ status?: string;
136
+ runId?: string;
137
+ agentId?: string;
138
+ };
139
+ type PatchContentFile = {
140
+ path: string;
141
+ status?: "added" | "modified" | "removed" | "renamed";
142
+ diff?: string;
143
+ binary?: boolean;
144
+ additions?: number;
145
+ deletions?: number;
146
+ };
147
+ export type TimelineMessage = {
148
+ actorSubject?: string;
149
+ id: string;
150
+ role: "user" | "assistant";
151
+ content: ContentPart[];
152
+ status: "in_progress" | "awaiting_dispatch" | "dispatching" | "queued_for_agent" | "complete" | "error";
153
+ createdAt: string;
154
+ };
155
+ export declare function normalizeWorkspaceAgentServerMessage(input: unknown): {
156
+ type: "message.delta";
157
+ id: string;
158
+ seq: number;
159
+ role: "assistant" | "system";
160
+ delta: ContentPart[];
161
+ runId: string | undefined;
162
+ agentId: string | undefined;
163
+ parentRunId: string | null;
164
+ status?: undefined;
165
+ } | {
166
+ type: "message.commit";
167
+ id: string;
168
+ seq: number;
169
+ status: "error" | "complete";
170
+ runId: string | undefined;
171
+ agentId: string | undefined;
172
+ parentRunId: string | null;
173
+ role?: undefined;
174
+ delta?: undefined;
175
+ } | null;
176
+ /**
177
+ * 将 delta content parts 合并到现有 streaming message。
178
+ * 如果 id 不存在则创建新消息;如果存在则追加 text delta 到最后一个 text part。
179
+ */
180
+ export declare function applyDelta(current: readonly TimelineMessage[], event: {
181
+ id: string;
182
+ seq: number;
183
+ role: "assistant" | "system";
184
+ delta: ContentPart[];
185
+ }): TimelineMessage[];
186
+ /**
187
+ * 标记 streaming message 为完成/错误。
188
+ */
189
+ export declare function applyCommit(current: readonly TimelineMessage[], event: {
190
+ id: string;
191
+ status: "complete" | "error";
192
+ }): TimelineMessage[];
193
+ export declare function mapAgentMessagesToTimeline(messages: readonly WorkspaceAgentMessage[], options?: {
194
+ idPrefix?: string;
195
+ preserveMessageIds?: boolean;
196
+ groupReasoning?: boolean;
197
+ agentLabel?: string;
198
+ hideOwnCompletion?: boolean;
199
+ workspaceLabels?: ReadonlyMap<string, string>;
200
+ }): TimelineMessage[];
201
+ export declare function normalizePatchDelivery(value: unknown): {
202
+ deliveryId: string;
203
+ taskKey: string;
204
+ revision: string;
205
+ } | undefined;
206
+ /** 只有可信发送者与当前账号相同的用户消息放右侧;未知身份不冒充自己。 */
207
+ export declare function isOwnAgentMessage(message: Pick<TimelineMessage, "role" | "actorSubject">, currentSubject: string | null): boolean;
208
+ export type AgentMessageMember = {
209
+ readonly subject: string;
210
+ readonly displayName: string;
211
+ readonly avatarUrl?: string;
212
+ };
213
+ /** 名称和头像来自已授权 IM 目录,消息本身保存稳定账号身份。 */
214
+ export declare function agentMessageMember(message: Pick<TimelineMessage, "actorSubject">, members: readonly AgentMessageMember[]): AgentMessageMember | undefined;
215
+ export declare function agentMemberInitial(name: string): string;
216
+ export {};
@@ -0,0 +1,24 @@
1
+ import { type LocalWorkspaceQuestionReply } from "@kuafucloud/product-runtime-protocol";
2
+ export type AgentQuestion = {
3
+ id: string;
4
+ header: string;
5
+ question: string;
6
+ isOther: boolean;
7
+ options: Array<{
8
+ label: string;
9
+ description: string;
10
+ }>;
11
+ };
12
+ export type AgentQuestionPart = {
13
+ type: "agent.question";
14
+ questionMessageId: string;
15
+ sessionId: string | null;
16
+ state: "waiting" | "answered" | "resolved";
17
+ approval?: true;
18
+ questions: AgentQuestion[];
19
+ answers?: Record<string, string[]>;
20
+ };
21
+ /** 只接收已归一化的公开问题;原始引擎RPC身份不传到UI。 */
22
+ export declare function readAgentQuestion(value: unknown): AgentQuestionPart | null;
23
+ export declare function canAnswerAgentQuestion(question: AgentQuestionPart, sessionId: string | null): boolean;
24
+ export declare function createAgentQuestionReply(question: AgentQuestionPart, sessionId: string | null, values: Record<string, string>): LocalWorkspaceQuestionReply;
@@ -0,0 +1,158 @@
1
+ import type { DeveloperPayloadFragment } from "./payload-fragments.js";
2
+ import type { DeveloperChannelGrant } from "./host-channels.js";
3
+ import type { DeveloperProductPreviewTarget } from "./product-preview-protocol.js";
4
+ /** Developer/Host 内部实时协议;IM 不解释这些帧或工作区身份。 */
5
+ export declare const DEVELOPER_REALTIME_VERSION: 1;
6
+ export declare const DEVELOPER_REALTIME_LIMITS: {
7
+ readonly frameBytes: number;
8
+ readonly subscriptionsPerViewer: 8;
9
+ readonly viewersPerHost: 32;
10
+ readonly requestsPerViewer: 4;
11
+ readonly requestTimeoutMs: 30000;
12
+ readonly socketBufferedBytes: number;
13
+ readonly productsPerWorkspace: 256;
14
+ };
15
+ export type DeveloperRealtimeScope = {
16
+ projectId: string;
17
+ environmentKey: string;
18
+ hostDeviceId: string;
19
+ };
20
+ export type DeveloperWorkspaceGrant = {
21
+ workspaceId: string;
22
+ conversationId: string;
23
+ canSend: boolean;
24
+ };
25
+ /** 权威由 Worker 握手校验后提供,不能从 socket 帧中取得。 */
26
+ export type DeveloperRealtimeAuthority = DeveloperRealtimeScope & {
27
+ subject: string;
28
+ } & ({
29
+ role: "host";
30
+ } | ({
31
+ role: "channel";
32
+ } & DeveloperChannelGrant) | {
33
+ role: "viewer";
34
+ workspaces: readonly DeveloperWorkspaceGrant[];
35
+ } | {
36
+ role: "preview";
37
+ target: DeveloperProductPreviewTarget;
38
+ });
39
+ export type DeveloperObserveKind = "agent" | "products";
40
+ export type DeveloperProductItem = {
41
+ repositoryId: string;
42
+ codebasePath: string;
43
+ productId: string;
44
+ name: string;
45
+ kind: string;
46
+ state: "unprepared" | "preparing" | "ready" | "running" | "failed" | "unknown";
47
+ /** 产品列表现有连接提供路由;打开预览无需再次解析群或申请观看许可。 */
48
+ preview?: {
49
+ origin: string;
50
+ projectId: string;
51
+ hostDeviceId: string;
52
+ workspaceId: string;
53
+ };
54
+ };
55
+ export type DeveloperProductsSnapshot = {
56
+ revision: number;
57
+ products: readonly DeveloperProductItem[];
58
+ };
59
+ export type DeveloperViewerFrame = {
60
+ type: "ack";
61
+ generation: string;
62
+ streamId: string;
63
+ subscriptionId: string;
64
+ sequence: number;
65
+ } | {
66
+ type: "subscribe";
67
+ subscriptionId: string;
68
+ workspaceId: string;
69
+ kind: DeveloperObserveKind;
70
+ } | {
71
+ type: "unsubscribe";
72
+ subscriptionId: string;
73
+ } | {
74
+ type: "request";
75
+ requestId: string;
76
+ workspaceId: string;
77
+ operation: "history" | "send" | "receipt" | "file";
78
+ input: unknown;
79
+ inputTicket?: string;
80
+ };
81
+ export type DeveloperHostFrame = {
82
+ type: "snapshot" | "event";
83
+ generation: string;
84
+ streamId: string;
85
+ sequence: number;
86
+ payload: unknown;
87
+ fragment?: DeveloperPayloadFragment;
88
+ } | {
89
+ type: "result";
90
+ generation: string;
91
+ requestId: string;
92
+ ok: boolean;
93
+ payload: unknown;
94
+ fragment?: DeveloperPayloadFragment;
95
+ };
96
+ export type DeveloperRelayFrame = {
97
+ type: "fragment-ack";
98
+ generation: string;
99
+ id: string;
100
+ index: number;
101
+ } | {
102
+ type: "ready";
103
+ version: 1;
104
+ generation: string | null;
105
+ } | {
106
+ type: "host-state";
107
+ generation: string | null;
108
+ state: "online" | "offline";
109
+ } | {
110
+ type: "subscribe";
111
+ generation: string;
112
+ streamId: string;
113
+ workspaceId: string;
114
+ kind: DeveloperObserveKind;
115
+ } | {
116
+ type: "unsubscribe";
117
+ generation: string;
118
+ streamId: string;
119
+ } | {
120
+ type: "request";
121
+ generation: string;
122
+ requestId: string;
123
+ subject: string;
124
+ workspaceId: string;
125
+ operation: "history" | "send" | "receipt" | "file";
126
+ input: unknown;
127
+ } | {
128
+ type: "snapshot" | "event";
129
+ generation: string;
130
+ streamId: string;
131
+ subscriptionId: string;
132
+ sequence: number;
133
+ payload: unknown;
134
+ fragment?: DeveloperPayloadFragment;
135
+ } | {
136
+ type: "result";
137
+ requestId: string;
138
+ ok: boolean;
139
+ payload: unknown;
140
+ fragment?: DeveloperPayloadFragment;
141
+ } | {
142
+ type: "error";
143
+ code: string;
144
+ subscriptionId?: string;
145
+ requestId?: string;
146
+ };
147
+ /** 两端共同的可见性规则;离线/重连/撤权立即丢弃旧内容,首帧后才展示。 */
148
+ export type DeveloperWorkspaceViewState = {
149
+ phase: "offline" | "connecting" | "ready" | "forbidden" | "failed" | "missing";
150
+ generation: string | null;
151
+ streamId: string | null;
152
+ sequence: number;
153
+ content: unknown;
154
+ errorCode?: string;
155
+ };
156
+ export declare function emptyDeveloperWorkspaceView(phase?: DeveloperWorkspaceViewState["phase"], generation?: string | null): DeveloperWorkspaceViewState;
157
+ export declare function developerWorkspaceUnavailable(state: DeveloperWorkspaceViewState): boolean;
158
+ export declare function reduceDeveloperWorkspaceView(state: DeveloperWorkspaceViewState, subscriptionId: string, frame: DeveloperRelayFrame, applyEvent: (content: unknown, event: unknown) => unknown): DeveloperWorkspaceViewState;
@@ -0,0 +1,28 @@
1
+ export * from "../developer-realtime.js";
2
+ export * from "../host-channels.js";
3
+ export * from "../product-preview-protocol.js";
4
+ export * from "../product-preview-host.js";
5
+ export { validServiceSocketText } from "../product-preview-socket-source.js";
6
+ export * from "../product-preview-viewer.js";
7
+ export * from "../product-preview-viewer-http.js";
8
+ export * from "../product-preview-cache.js";
9
+ export * from "../product-preview-http-runtime.js";
10
+ export * from "../native-source-codec.js";
11
+ export * from "../workspace-viewer.js";
12
+ export * from "../websocket-transport.js";
13
+ export * from "../host-connection.js";
14
+ export * from "../agent-chat-model.js";
15
+ export * from "../payload-fragments.js";
16
+ export * from "../workspace-chat-stream.js";
17
+ export * from "../workspace-agent-view.js";
18
+ export * from "../workspace-agent-input.js";
19
+ export * from "../agent-question.js";
20
+ export * from "../workspace-cache.js";
21
+ export * from "../workspace-cache-store.js";
22
+ export * from "../workspace-agent-history.js";
23
+ export * from "../workspace-file-view.js";
24
+ export * from "../workspace-agent-member.js";
25
+ export * from "../workspace-status-view.js";
26
+ export * from "../project-workspaces.js";
27
+ export { readProductPreviewClient, type ProductPreviewClient } from "../product-preview-clients.js";
28
+ export * from "../preview-device.js";
@@ -0,0 +1,52 @@
1
+ import { type DeveloperProductPreviewTarget } from "./product-preview-protocol.js";
2
+ /** Main跨所有Source作用域共享,不能由每条业务Socket重复获得完整额度。 */
3
+ export declare const DEVELOPER_CHANNEL_LIMITS: {
4
+ readonly businessChannels: 16;
5
+ readonly streams: 16;
6
+ readonly queuedBytes: number;
7
+ readonly handshakeMs: 15000;
8
+ readonly idleMs: 30000;
9
+ };
10
+ export type DeveloperChannelTarget = {
11
+ kind: "workspace-events";
12
+ workspaceId: string;
13
+ } | {
14
+ kind: "product-preview";
15
+ product: DeveloperProductPreviewTarget;
16
+ };
17
+ export type DeveloperChannelGrant = {
18
+ controlEpoch: string;
19
+ channelId: string;
20
+ nonce: string;
21
+ target: DeveloperChannelTarget;
22
+ };
23
+ export type DeveloperChannelOpen = DeveloperChannelGrant & {
24
+ type: "channel.open";
25
+ ticket: string;
26
+ expiresAt: number;
27
+ };
28
+ export type DeveloperChannelClose = {
29
+ type: "channel.close";
30
+ controlEpoch: string;
31
+ channelId: string;
32
+ code: string;
33
+ };
34
+ export declare function readDeveloperChannelTarget(raw: unknown): DeveloperChannelTarget;
35
+ export declare function developerChannelKey(target: DeveloperChannelTarget): string;
36
+ export declare function developerChannelWorkspace(target: DeveloperChannelTarget): string;
37
+ export declare function readDeveloperChannelGrant(raw: unknown): DeveloperChannelGrant;
38
+ /** 预算先取得后启动资源;每张许可只释放一次,异步迟到结果也归原owner。 */
39
+ export declare class DeveloperHostBudget {
40
+ private channels;
41
+ private streams;
42
+ private bytes;
43
+ acquireChannel(): () => void;
44
+ acquireStream(): () => void;
45
+ acquireBytes(bytes: number): () => void;
46
+ snapshot(): {
47
+ channels: number;
48
+ streams: number;
49
+ bytes: number;
50
+ };
51
+ private take;
52
+ }