@wudao-org/server 0.0.0-stage → 0.4.20

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.
@@ -0,0 +1,364 @@
1
+ import type { RecoveryStatusRow } from "./recovery.js";
2
+ export type { RecoveryJournalEntry, RecoveryJournalFold, FoldSessionState, RecoveryObservation, RecoveryClassification, RecoverySettle, RecoveryPort, RecoveryStatusRow, RecoveryCoordinatorOptions, RecoveryCoordinator, } from "./recovery.js";
3
+ export { createRecoveryJournal, foldRecoveryLines, classifyRecovery, createRecoveryCoordinator, RECOVERY_INTERVAL_MS, RECOVERY_CONCURRENCY, RECOVERY_ROTATION_BOUND, } from "./recovery.js";
4
+ /** Loopback hostnames the Host header may carry (DNS-rebinding guard)。*/
5
+ /** Close codes (documented in PROTOCOL.md)。*/
6
+ /** ω99-225: the resume verdict relayed verbatim — a structural mirror of the
7
+ * CLI's ResumeOutcome (this package never imports the CLI; the shapes are
8
+ * kept identical by the twin tests in each package). `occupied` carries the
9
+ * live lease holder's pid so the web can tell a busy session from a missing
10
+ * one instead of guessing off the old bare boolean. */
11
+ export type ResumeOutcome = {
12
+ readonly ok: true;
13
+ } | {
14
+ readonly ok: false;
15
+ readonly reason: "not_found";
16
+ } | {
17
+ readonly ok: false;
18
+ readonly reason: "occupied";
19
+ readonly holderPid: number;
20
+ };
21
+ /** The driver surface this server speaks to (structural — no CLI import).
22
+ * Payloads are JSON-serializable values the server relays verbatim. */
23
+ export interface UiDriverPort {
24
+ subscribe(cb: () => void): () => void;
25
+ getStatus(): unknown;
26
+ getHistory(): readonly unknown[];
27
+ onHistory(cb: (entries: readonly unknown[], reset: boolean) => void): () => void;
28
+ onLoopEvent(cb: (event: unknown) => void): () => void;
29
+ submit(text: string, opts?: {
30
+ readonly plan?: boolean;
31
+ readonly expand?: boolean;
32
+ readonly images?: readonly unknown[];
33
+ readonly files?: readonly unknown[];
34
+ }): unknown;
35
+ interrupt(): void;
36
+ /** 0.4.0 集成缝:车道工厂打开后恢复到该会话(主 driver 的同形方法)。 */
37
+ resume(id: string): Promise<{
38
+ ok: boolean;
39
+ not_found?: boolean;
40
+ occupied?: {
41
+ pid: number;
42
+ };
43
+ }>;
44
+ setMode(mode: string): void;
45
+ answerPermission(allow: boolean, reason?: string, scope?: "session" | "always"): boolean;
46
+ /** 借鉴弧 α2(CC 2.1.269 思想)— recall ONE still-queued steering message
47
+ * (CAS: index+text from the same status frame; consumed entries → false).
48
+ * User lane only. OPTIONAL like searchSessions: the ui host's ask-lane
49
+ * wrapper mounts it; a driver without it cleanly refuses (server op). */
50
+ recallSteer?(index: number, text: string): boolean;
51
+ /** 借鉴弧 α1(Codex 0.154 思想)— answer the parked ask_user clarification
52
+ * card (an absent/empty answer = dismiss → the tool's error result tells
53
+ * the model to decide itself). Returns false when nothing is parked.
54
+ * OPTIONAL — mounted by the same ask-lane wrapper. */
55
+ answerAskUser?(answer?: string): boolean;
56
+ /** 借鉴弧 δ(penguin 367ab084 思想)— move ONE in-flight tool call to the
57
+ * background (its result stops blocking the turn; the run closes at the
58
+ * turn boundary; the landed result merges later). callId from the status
59
+ * frame's busyTools rows; absent = the first detachable row. Typed
60
+ * refusals: {kind:"refused", reason:"not_detachable"|"not_in_flight"}.
61
+ * OPTIONAL like recallSteer — mounted by the settings-ops wrapper. */
62
+ detachToolCall?(callId?: string): unknown;
63
+ listSlashCommands(): readonly unknown[];
64
+ sessions(): Promise<readonly unknown[]>;
65
+ searchSessions?(q: string): Promise<readonly unknown[]>;
66
+ deleteSession?(id: string): Promise<unknown>;
67
+ trashSessions?(): Promise<readonly unknown[]>;
68
+ restoreSession?(id: string): Promise<unknown>;
69
+ continueSession?(id: string): Promise<unknown>;
70
+ forkSession?(id: string): Promise<unknown>;
71
+ schedulesList?(): Promise<unknown>;
72
+ schedulesSetEnabled?(id: string, enabled: boolean): Promise<unknown>;
73
+ schedulesRemove?(id: string): Promise<unknown>;
74
+ schedulesRunNow?(id: string, opts?: {
75
+ readonly resetBreaker?: boolean;
76
+ }): Promise<unknown>;
77
+ resume(id: string): Promise<ResumeOutcome>;
78
+ rewind(target: number | "last" | "list"): Promise<string>;
79
+ /** M53 §1: /edit arming — returns the original text (null when out of
80
+ * range or a run is in flight) so the web input can present it. */
81
+ beginEdit(n: number): string | undefined;
82
+ /** M53 §1: /tree //switch notice text. */
83
+ tree(): Promise<string>;
84
+ switchBranch(n?: number): Promise<string>;
85
+ /** ω99-258: the structured branch leaf table (PROTOCOL "branchLeaves") —
86
+ * tree()'s data twin for the web branch panel: rows of {n, leafKey,
87
+ * forkPreview, messageCount, isCurrent}. OPTIONAL like the settings ops —
88
+ * a driver without it gets a clean "unsupported" error (old-server
89
+ * degradation is the CLIENT's chip-hidden branch). Read-only, never
90
+ * vaulted. */
91
+ branchLeaves?(): Promise<unknown>;
92
+ /** ω99-258: void a pending /edit arm (the web banner's 取消 — edit op with
93
+ * n:0). OPTIONAL for the same reason; absent → the op refuses. */
94
+ disarmEdit?(): boolean;
95
+ /** ω99-260: the full memory ledger (PROTOCOL "memoryList") — the store's
96
+ * load() table passed through structured (file order, active + pending)
97
+ * for the web memory faces. OPTIONAL like branchLeaves — a driver without
98
+ * it gets a clean "unsupported" error (old-server degradation is the
99
+ * CLIENT's hidden face). Read-only, never vaulted. */
100
+ memoryList?(): Promise<unknown>;
101
+ /** ω99-260: decide one pending memory (PROTOCOL "memoryDecide") — ok
102
+ * (confirm, pending→active) or del (remove the line); store.confirm/
103
+ * remove are the single source. VAULTED: the decision is a side effect
104
+ * that must survive a mid-flap replay exactly once, and ok/del converge
105
+ * (a replayed second ok answers ok:false, never breaks). */
106
+ memoryDecide?(id: string, action: "ok" | "del"): Promise<unknown>;
107
+ /** ω99-264: #2 — rewrite one memory entry's content (PROTOCOL "memoryEdit") —
108
+ * update + a conditional confirm (status-preserving: active stays active,
109
+ * pending stays pending; tags/hits ride verbatim). VAULTED like the
110
+ * decision, but the convergence lives in the DRIVER: a bare update is
111
+ * NOT idempotent (v+1 per call), so the driver short-circuits a
112
+ * content-equal replay (ok:true, zero writes) — a mid-flap replay lands
113
+ * exactly once. */
114
+ memoryEdit?(id: string, content: string): Promise<unknown>;
115
+ improvementFace?(action: "list" | "consent" | "ignore" | "activate" | "reject" | "undo", id?: string): Promise<unknown>;
116
+ /** The provider matrix + credentials count + settings values (no secrets). */
117
+ settingsStatus?(): Promise<unknown>;
118
+ /** Persist one provider key to the credentials file (cli-side write). */
119
+ settingsSaveKey?(provider: string, key: string): Promise<unknown>;
120
+ /** One minimal request through the target provider; human failure states. */
121
+ settingsTestConnection?(provider: string, opts?: {
122
+ readonly key?: string;
123
+ readonly model?: string;
124
+ }): Promise<unknown>;
125
+ /** Write one allowlisted settings key — the 13 writable keys (ω99-237: #2 —
126
+ * see settingsSet's unknown-key error in driver/settings-ops.ts, the
127
+ * single source of truth; this mirror once drifted to "8" when the
128
+ * language pair landed uncounted; ω99-287: #5 bumps 12→13 with
129
+ * desktop.backgroundOnClose, doc-only). */
130
+ settingsSet?(key: string, value: unknown): Promise<unknown>;
131
+ /** Register/update one provider (custom or builtin overlay) in the
132
+ * machine registry; the reply is status-only. */
133
+ settingsSaveProvider?(id: string, config: unknown): Promise<unknown>;
134
+ /** Remove one registry entry (customs only); a stored defaultModel
135
+ * pointing at the deleted id falls back. Idempotent. */
136
+ settingsDeleteProvider?(id: string): Promise<unknown>;
137
+ /** Probe GET ${endpoint}/models through the target provider (the
138
+ * testConnection key ladder + failure states); the request key never
139
+ * echoes back. */
140
+ settingsListModels?(provider: string, opts?: {
141
+ readonly key?: string;
142
+ }): Promise<unknown>;
143
+ /** M75-ux1 §2: the workspace switcher's recents (PROTOCOL "recentWorkspaces")
144
+ * — read the list, or (with `add`) unshift + persist + read. No separate
145
+ * write op: the switch click adds through the same handler. */
146
+ recentWorkspaces?(add?: string): Promise<unknown>;
147
+ /** M77-workspace §1: same-window switch — starts a new UI session for the
148
+ * target directory and returns its URL; the client navigates there. */
149
+ switchWorkspace?(path: string): Promise<unknown>;
150
+ /** One directory level: dirs first alphabetically, then files; dotfiles
151
+ * and the hidden list carry hidden:true (the CLIENT filters). */
152
+ fileTree?(path: string): Promise<unknown>;
153
+ /** One file's UTF-8 content (1MB limit / 100KB prefix, binary sniff);
154
+ * sensitive paths (.git, .ssh, .env*, credentials*) reject. */
155
+ fileRead?(path: string): Promise<unknown>;
156
+ /** 高亮/编辑 spec §3: the viewer's save — user-hand edit, no permission
157
+ * pipeline; the driver enforces the read-side guards + the base
158
+ * compare-and-swap + the atomic write. */
159
+ fileWrite?(path: string, content: string, base: string): Promise<unknown>;
160
+ /** ω99-314: 文件级时光机——把指定文件恢复到指定快照(改动面板「恢复到
161
+ * 这里」的引擎)。写面 op:VAULTED(isVaultedMutation),一次重放绝不
162
+ * 双写。守卫序与判决联合见 driver 的 fileRevert(busy/evicted/bad-path/
163
+ * no-store 拒;ok:true 带 stale 事实)。OPTIONAL like fileWrite — 无该
164
+ * 方法的 driver 干净拒答(老 server 降级=面板恢复钮隐藏)。 */
165
+ fileRevert?(path: string, sha: string): Promise<unknown>;
166
+ /** workspace-ux B1: switch the file panel's VIEW root (PROTOCOL
167
+ * "panelRootSet") — exists-and-directory validated driver-side; the
168
+ * reply carries the new root. Deliberately NOT the agent root: the
169
+ * session and its tool boundary never move (that is agentRootSwitch's
170
+ * job, B2). */
171
+ panelRootSet?(path: string): Promise<unknown>;
172
+ /** workspace-ux B1: the dual-root snapshot (PROTOCOL "agentRootStatus") —
173
+ * panelRoot (the view) vs agentRoot (the session's workspace root) and
174
+ * whether they still agree. */
175
+ agentRootStatus?(): Promise<unknown>;
176
+ /** workspace-ux B2: switch the agent's workspace root (PROTOCOL
177
+ * "agentRootSwitch") — idle applies now ({applied:true}); busy parks until
178
+ * the run's settle seam ({queued:true}). Moves the builtin file tools'
179
+ * boundary, shell's cwd, the FileChanged watchers, and the hook
180
+ * payload root — NEVER the system prompt, the session id, or any .wudao
181
+ * anchor. */
182
+ agentRootSwitch?(path: string): Promise<unknown>;
183
+ /** M76-ux2 §8: the ctx hover's breakdown (PROTOCOL "ctxInfo") — the
184
+ * serialized prompt's per-section token estimates + the free remainder
185
+ * (the StatusBar ctx segment's tooltip data). Read-only over driver
186
+ * state; the relay below is a pass-through. */
187
+ ctxInfo?(): Promise<unknown>;
188
+ /** 140(监控要看全): the session's full anatomy — system prompt text +
189
+ * the persisted message chain (user prompts, assistant content/reasoning,
190
+ * tool calls/results). Optional like ctxInfo (absent → the op refuses). */
191
+ sessionAnatomy?(): Promise<unknown>;
192
+ /** The away recap (PROTOCOL "recap"): stats counted from the
193
+ * session's structured history since the viewer's mark, plus an optional
194
+ * narrative from one tiny background model call. The reply is the payload
195
+ * or undefined (a legitimate "no recap", not an error). Session identity,
196
+ * the mark, and the ≥3-new-messages gate live in the driver handler
197
+ * (agent-driver.ts) — the relay stays shape-validation only. */
198
+ recap?(sessionId: string, sinceMark: number, sinceTs?: number): Promise<unknown>;
199
+ /** ω99-316 — /btw 侧问 (PROTOCOL "sideQuestion"): ask the session's
200
+ * side lane a question without interrupting the main run — a detached
201
+ * loop over a sanitized clone of the request-time projection (frozen
202
+ * tool table, maxTurns=3), answering {answer, rounds}. Read-only over
203
+ * the session (never writes JSONL/store — a replay just re-asks, never
204
+ * vaulted). Session identity and the empty-text gate live in the driver
205
+ * handler; the relay stays shape-validation only. */
206
+ sideQuestion?(sessionId: string, text: string): Promise<unknown>;
207
+ /** Admit a base64 image batch → durable refs (limits live in the driver's
208
+ * AttachmentStore: fail-closed admission BEFORE any write). */
209
+ attachmentSave?(inputs: readonly {
210
+ data: string;
211
+ mediaType: string;
212
+ }[]): Promise<unknown>;
213
+ /** One stored image back as base64 (for rendering history images). */
214
+ attachmentGet?(ref: {
215
+ attachmentId: string;
216
+ mediaType: string;
217
+ byteLength: number;
218
+ }): Promise<unknown>;
219
+ /** Admit a base64 generic-file batch → content-addressed FileBlocks
220
+ * (fail-closed admission BEFORE any write; equal bytes dedup). */
221
+ fileSave?(inputs: readonly {
222
+ data: string;
223
+ name: string;
224
+ }[]): Promise<unknown>;
225
+ /** The install registry + enable state (the settings page's 已装 list). */
226
+ pluginList?(): Promise<unknown>;
227
+ /** MCP visibility (settings page's MCP tab): every configured server
228
+ * across the three tiers with runtime status. */
229
+ mcpList?(): Promise<unknown>;
230
+ /** Every registered market + its discover entries (with install-preview
231
+ * counts for local-dir sources; null for git-location sources). */
232
+ pluginMarketList?(): Promise<unknown>;
233
+ /** Add a market from a source (owner/repo · git URL#ref · 本地目录 ·
234
+ * marketplace.json 路径); `name` overrides the manifest's own. */
235
+ pluginMarketAdd?(source: string, name?: string): Promise<unknown>;
236
+ /** Re-pull / re-copy one registered market. */
237
+ pluginMarketUpdate?(name: string): Promise<unknown>;
238
+ /** Unregister + delete a market, cascading the uninstall of the plugins
239
+ * it installed (busy → refusal error, nothing touched). */
240
+ pluginMarketRemove?(name: string): Promise<unknown>;
241
+ /** Install a market's plugin into a scope root (reply carries the loader
242
+ * dry-run's InstallDetail). */
243
+ pluginInstall?(name: string, market: string, scope: "user" | "project"): Promise<unknown>;
244
+ /** 引导安装(guided-install 弧):spec 三形态(本地路径/GitHub 简写/git URL)+ 可选预览。 */
245
+ pluginInstallSpec?(spec: string, preview?: boolean): Promise<unknown>;
246
+ /** 长期记忆(M-Memory):列表 + tombstone 删除。 */
247
+ longtermMemoryList?(): Promise<unknown>;
248
+ longtermMemoryForget?(id: string): Promise<unknown>;
249
+ /** Delete the install dir + registry record + enable key (busy → refusal). */
250
+ pluginUninstall?(id: string): Promise<unknown>;
251
+ /** Re-enable a disabled plugin (deletes the enabledPlugins key). */
252
+ pluginEnable?(id: string): Promise<unknown>;
253
+ /** Hide a plugin from discovery's mapping (registry record kept). */
254
+ pluginDisable?(id: string): Promise<unknown>;
255
+ /** Every registered persona (builtin + global + workspace) with its tier
256
+ * source, layers label, and edit gate (global only). */
257
+ personaList?(): Promise<unknown>;
258
+ /** One persona's full definition (unknown id rejects). */
259
+ personaGet?(id: string): Promise<unknown>;
260
+ /** Create/update one GLOBAL persona (~/.wudao/personas/<id>.json). */
261
+ personaSave?(definition: unknown): Promise<unknown>;
262
+ /** Delete one global persona; the reference inventory when bound. */
263
+ personaDelete?(id: string, unbind?: boolean): Promise<unknown>;
264
+ }
265
+ /** ω99-235: #1 — the pet lane's server surface (this file's whole lane: the
266
+ * narrow port below, the optional UiServerOptions.petDriver mount, the three
267
+ * pet ops (#3), the dual-lane state frames (#4/#5), the sessions lane mark
268
+ * (#6), and the vaulted-set join (#2)). The desktop sprite's own session —
269
+ * a SECOND driver the same host process mounts beside the main one. The
270
+ * five-method slice is all the pet ops and the state frame's `pet` field
271
+ * consume — history/loop-events/settings/plugin surfaces stay main-lane-only
272
+ * (no /commands, no resume).
273
+ * ω99-271: #2 — the "Bubble is a pure send face: no history replay" premise
274
+ * is RETIRED (user report 09-10: 「很多消息没有展示完全,也看不到完整的会话
275
+ * 信息」): the lane driver HAS the full pet.jsonl history (ui.ts resumes it
276
+ * into getHistory at boot) — the window just had no way to ask. The port
277
+ * gains ONE read; the send-face discipline (no commands, no resume, no
278
+ * loop-event relay) stands. */
279
+ export interface UiPetDriverPort {
280
+ subscribe(cb: () => void): () => void;
281
+ getStatus(): unknown;
282
+ submit(text: string): unknown;
283
+ interrupt(): void;
284
+ answerPermission(allow: boolean, reason?: string, scope?: "session" | "always"): boolean;
285
+ /** ω99-271 — the lane's own session history (pet.jsonl, already
286
+ * branch-walked at boot). Structurally minimal read: `text` optional so
287
+ * the driver's HistoryEntry union (tool/edit/board entries lack text)
288
+ * assigns without a cli-side type dependency. */
289
+ getHistory(): readonly {
290
+ kind: string;
291
+ text?: string;
292
+ }[];
293
+ }
294
+ /** 多 driver 并发弧 B —— sid 寻址车道的驱动面:UiDriverPort 的交互切片
295
+ * (状态/历史两个中继道 + submit/interrupt/setMode/answerPermission 四个
296
+ * 必选写面 + recallSteer/answerAskUser/detachToolCall 三个可选写面)。
297
+ * 结构化注入如 UiDriverPort:本包不 import cli,真实副车道由宿主的车道
298
+ * 管理器装配传入(参照 pet 车道的降配清单)。完整 UiDriverPort 天然满足
299
+ * 本接口(必需面全在场)——主车道就是 opts.driver 原样入表(key "main")。
300
+ * 会话寻址面(resume/sessions/settings/file/plugin/persona/…)刻意不在
301
+ * 本接口:v1 车道弧只车道化「交互写面 + 两个中继道」(见 PROTOCOL.md
302
+ * Lanes 节)。 */
303
+ export interface LaneDriverPort {
304
+ /** 状态帧订阅:任何车道的 emit 都触发一次全表重读合并推送。 */
305
+ subscribe(cb: () => void): () => void;
306
+ /** 车道状态快照(推送时重读——永不携带陈旧车道态)。 */
307
+ getStatus(): unknown;
308
+ /** 车道当前史(auth 重放面 + petHistory 式拉取的数据源)。 */
309
+ getHistory(): readonly unknown[];
310
+ /** 史推送道:副车道帧由 server 侧统一标注 sid,driver 自身零感知。 */
311
+ onHistory(cb: (entries: readonly unknown[], reset: boolean) => void): () => void;
312
+ submit(text: string, opts?: {
313
+ readonly plan?: boolean;
314
+ readonly expand?: boolean;
315
+ readonly images?: readonly unknown[];
316
+ readonly files?: readonly unknown[];
317
+ }): unknown;
318
+ interrupt(): void;
319
+ /** 0.4.0 集成缝:车道工厂打开后恢复到该会话(主 driver 的同形方法)。 */
320
+ resume(id: string): Promise<{
321
+ ok: boolean;
322
+ not_found?: boolean;
323
+ occupied?: {
324
+ pid: number;
325
+ };
326
+ }>;
327
+ setMode(mode: string): void;
328
+ answerPermission(allow: boolean, reason?: string, scope?: "session" | "always"): boolean;
329
+ /** 以下三面 OPTIONAL——与 UiDriverPort 的同款可选面同形,server op 层
330
+ * 沿用「not supported by this driver」干净拒答族。 */
331
+ recallSteer?(index: number, text: string): boolean;
332
+ answerAskUser?(answer?: string): boolean;
333
+ detachToolCall?(callId?: string): unknown;
334
+ }
335
+ /** ω99-242: #3 — the crash-recovery coordinator's server-facing slice (the
336
+ * petDriver mounting precedent: a host process owns the coordinator and
337
+ * mounts it here; the server relays its status and forwards the ONE
338
+ * invalidation seam). All three members are OPTIONAL-mounted: absent → the
339
+ * recoveryStatus op answers a clean "not supported" and the submit op's
340
+ * invalidation call is skipped — today's byte-identical behavior.
341
+ * M24 声明(§二.10):恢复注入发生在 resume 边界=冷转预期(cold turn
342
+ * expected)——详见 recovery.ts 头注与弧报告。 */
343
+ export interface UiRecoveryPort {
344
+ /** A manual client submit landed on the driver's CURRENT session — cancel
345
+ * that session's pending recovery (invariant 7; permission replies ride
346
+ * answerPermission and deliberately never reach this seam). */
347
+ noteUserInput(): void;
348
+ /** Structured per-session rows (the web reconciliation line's X/Y). */
349
+ status(): readonly RecoveryStatusRow[];
350
+ /** Graceful-shutdown checkpoint — freeze the in-flight session before the
351
+ * engine dies (the orphan self-exit path calls this before exit(0)). */
352
+ stop(): Promise<void>;
353
+ }
354
+ /** ω99-235 — the pet lane's fixed session id, as a SERVER-SIDE LITERAL: this
355
+ * package never imports the CLI (the workspace graph stays acyclic), so the
356
+ * twin of cli/src/ui.ts's exported PET_SESSION_ID lives here — the pet-ops
357
+ * tests pin both sides to the same bytes ("pet"). */
358
+ export declare const PET_LANE_SESSION_ID = "pet";
359
+ export interface PetHistoryTurnWire {
360
+ readonly q: string;
361
+ readonly a: string;
362
+ }
363
+ /** Pair the lane driver's session history into chat turns for the pet window. */
364
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eA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,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzC,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3C;AAED;;;;;;;wCAOwC;AACxC,MAAM,WAAW,cAAc;IAC7B;;oEAEgE;IAChE,aAAa,IAAI,IAAI,CAAC;IACtB,uEAAuE;IACvE,MAAM,IAAI,SAAS,iBAAiB,EAAE,CAAC;IACvC;6EACyE;IACzE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;sDAGsD;AACtD,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAUzC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iFAAiF"}
package/dist/ports.js ADDED
@@ -0,0 +1,8 @@
1
+ export { createRecoveryJournal, foldRecoveryLines, classifyRecovery, createRecoveryCoordinator, RECOVERY_INTERVAL_MS, RECOVERY_CONCURRENCY, RECOVERY_ROTATION_BOUND, } from "./recovery.js";
2
+ /** ω99-235 — the pet lane's fixed session id, as a SERVER-SIDE LITERAL: this
3
+ * package never imports the CLI (the workspace graph stays acyclic), so the
4
+ * twin of cli/src/ui.ts's exported PET_SESSION_ID lives here — the pet-ops
5
+ * tests pin both sides to the same bytes ("pet"). */
6
+ export const PET_LANE_SESSION_ID = "pet";
7
+ /** Pair the lane driver's session history into chat turns for the pet window. */
8
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAqZvB;;;sDAGsD;AACtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAezC,iFAAiF"}
@@ -0,0 +1,39 @@
1
+ /** 探针类别(PB-1 的 cat 域,单一来源)。 */
2
+ export declare const PROBE_CATS: readonly ["model", "tool", "ui", "system", "agent"];
3
+ export type ProbeCat = (typeof PROBE_CATS)[number];
4
+ /** 一条探针事件(PB-1 ProbeEvent 的 wire 镜像——结构端口,不 import core)。
5
+ * `data` 是探针自带的自由负载(JSON 可序列化),server 原样中继。 */
6
+ export interface ProbeEventWire {
7
+ readonly ts: number;
8
+ readonly cat: ProbeCat;
9
+ readonly name: string;
10
+ readonly sessionId?: string;
11
+ readonly lane?: string;
12
+ readonly data: Record<string, unknown>;
13
+ readonly dur?: number;
14
+ }
15
+ /** 宿主挂载的探针 bus 面(PB-1 ProbeBus 的结构镜像;stats 按 name 计数——
16
+ * {count, lastTs},与探针名一对一)。 */
17
+ export interface UiProbeBusPort {
18
+ emit(e: ProbeEventWire): void;
19
+ subscribe(cat: ProbeCat | "*", cb: (e: ProbeEventWire) => void): () => void;
20
+ recent(cat?: string, limit?: number): readonly ProbeEventWire[];
21
+ stats(): Record<string, {
22
+ count: number;
23
+ lastTs: number;
24
+ }>;
25
+ }
26
+ /** probeRecent 的 limit 帽(环形缓冲同量级;防一帧拉 O(∞) 的形状门)。 */
27
+ export declare const PROBE_RECENT_LIMIT_CAP = 1000;
28
+ export interface ProbeRelay {
29
+ /** 三个 probe op 的统一入口(index.ts 的 switch case 直递;未知 op 名不
30
+ * 进来——dispatch 已按 case 名收敛)。 */
31
+ handleOp(o: Record<string, unknown>, reply: (ok: unknown, err?: string) => void): void;
32
+ /** 退订(server.close 时调用;未挂 bus 为 no-op)。 */
33
+ close(): void;
34
+ }
35
+ export declare function createProbeRelay(opts: {
36
+ readonly bus: UiProbeBusPort | undefined;
37
+ readonly send: (frame: unknown) => void;
38
+ }): ProbeRelay;
39
+ //# sourceMappingURL=probe.d.ts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AAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;IACvF,2CAA2C;IAC3C,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,GAAG,UAAU,CA0Eb"}
package/dist/probe.js ADDED
@@ -0,0 +1,96 @@
1
+ // PB-2(探针基础设施弧)— server 侧探针遥测车道:宿主 ProbeBus 的 WS 中继。
2
+ // 结构化注入如 petDriver/recovery(本包不 import core,工作区图保持无环——
3
+ // PB-1 落地 core 的 ProbeBus 天然满足 UiProbeBusPort,形状由本包孪生测试钉)。
4
+ // 三个读面 op(全部 never vaulted——不进 vault 不重放,ω99-260 memoryList 读表
5
+ // 先例):
6
+ // probeStream {cat?} 订阅:其后每条匹配事件转发一帧 {t:"probe",event}
7
+ // (139:cat:"off" 退订——仪表盘关页停流)
8
+ // probeEnable {on} 139:运行时翻转探针总闸(WUDAO_PROBE)
9
+ // probeRecent {cat?,limit?} 拉环形缓冲(recent 同形直通)
10
+ // probeStats {} 拉统计面(stats 原样回)
11
+ // 缺省纪律(缺省零变化):未挂 bus → 三 op 干净拒答(optional-ops 既有文案族)、
12
+ // 零 probe 帧、零订阅副作用;挂了 bus 但客户端未 probeStream → 同样零帧(订阅
13
+ // 门在 relay 内,emit 永不主动上链)。UI 主车道消费:probe 帧走既有单连接(单
14
+ // 连接车道寻址先例),绝不另开 WS。
15
+ /** 探针类别(PB-1 的 cat 域,单一来源)。 */
16
+ export const PROBE_CATS = ["model", "tool", "ui", "system", "agent"];
17
+ /** probeRecent 的 limit 帽(环形缓冲同量级;防一帧拉 O(∞) 的形状门)。 */
18
+ export const PROBE_RECENT_LIMIT_CAP = 1000;
19
+ export function createProbeRelay(opts) {
20
+ const { bus, send } = opts;
21
+ // 订阅门:null=未订阅(零帧);cat=undefined=订阅全部类别;其余=单类别过滤。
22
+ // v1-A 单客户端:一个过滤槽足够;重发 probeStream 即换槽(幂等语义,最后
23
+ // 一次为准)。断线重连不重置——send 已按已认证槽位门控,无槽=零帧落地。
24
+ let filter = null;
25
+ const unsubscribe = bus?.subscribe("*", (event) => {
26
+ if (filter !== null && (filter.cat === undefined || filter.cat === event.cat)) {
27
+ send({ t: "probe", event });
28
+ }
29
+ });
30
+ const isCat = (v) => PROBE_CATS.includes(v);
31
+ return {
32
+ handleOp(o, reply) {
33
+ if (bus === undefined) {
34
+ reply(undefined, "probe not supported by this server");
35
+ return;
36
+ }
37
+ switch (o.op) {
38
+ case "probeStream": {
39
+ // cat 缺省=全部;"*" 同义(subscribe 域);"off" 退订(139 仪表盘
40
+ // 关页即停流——单过滤槽无独立 unsubscribe,语义走换槽);其余串拒。
41
+ if (o.cat !== undefined && o.cat !== "*" && o.cat !== "off" && (typeof o.cat !== "string" || !isCat(o.cat))) {
42
+ reply(undefined, `probeStream cat must be one of ${PROBE_CATS.join("|")}|*|off when present`);
43
+ return;
44
+ }
45
+ if (o.cat === "off") {
46
+ filter = null;
47
+ reply(true);
48
+ return;
49
+ }
50
+ const cat = typeof o.cat === "string" && o.cat !== "*" ? o.cat : undefined;
51
+ filter = { cat };
52
+ reply(true);
53
+ return;
54
+ }
55
+ case "probeEnable": {
56
+ // 139(用户令:默认仪表盘实时采集探针):运行时翻转探针总闸——
57
+ // probeEnabled() 逐调用读环境(probe.ts §3),翻 process.env 即全
58
+ // 部挂载点即时生效。loop 挂载(agent.* 与 tool.*)按 run 重裹,下一
59
+ // run 起可见;model.call 的包装在 provider 工厂构造时一次成形,
60
+ // 运行时开闸对它不追溯(回执字段说明,前端照实提示)。
61
+ if (typeof o.on !== "boolean") {
62
+ reply(undefined, "probeEnable on must be a boolean");
63
+ return;
64
+ }
65
+ if (o.on)
66
+ process.env.WUDAO_PROBE = "on";
67
+ else
68
+ delete process.env.WUDAO_PROBE;
69
+ reply({ enabled: o.on, modelCallNeedsRestart: true });
70
+ return;
71
+ }
72
+ case "probeRecent": {
73
+ if (o.cat !== undefined && o.cat !== "*" && (typeof o.cat !== "string" || !isCat(o.cat))) {
74
+ reply(undefined, `probeRecent cat must be one of ${PROBE_CATS.join("|")}|* when present`);
75
+ return;
76
+ }
77
+ if (o.limit !== undefined &&
78
+ (typeof o.limit !== "number" || !Number.isInteger(o.limit) || o.limit < 1 || o.limit > PROBE_RECENT_LIMIT_CAP)) {
79
+ reply(undefined, `probeRecent limit must be an integer 1..${PROBE_RECENT_LIMIT_CAP} when present`);
80
+ return;
81
+ }
82
+ const cat = typeof o.cat === "string" && o.cat !== "*" ? o.cat : undefined;
83
+ reply(bus.recent(cat, typeof o.limit === "number" ? o.limit : undefined));
84
+ return;
85
+ }
86
+ case "probeStats":
87
+ reply(bus.stats());
88
+ return;
89
+ default:
90
+ reply(undefined, `unknown op: ${String(o.op)}`);
91
+ }
92
+ },
93
+ close: () => unsubscribe?.(),
94
+ };
95
+ }
96
+ //# sourceMappingURL=probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.js","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,uDAAuD;AACvD,2DAA2D;AAC3D,+DAA+D;AAC/D,OAAO;AACP,iEAAiE;AACjE,2DAA2D;AAC3D,0DAA0D;AAC1D,kDAAkD;AAClD,+CAA+C;AAC/C,sDAAsD;AACtD,sDAAsD;AACtD,mDAAmD;AACnD,qBAAqB;AAErB,+BAA+B;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAwB9E,qDAAqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAU3C,MAAM,UAAU,gBAAgB,CAA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