@zhushanwen/extension-protocol 0.17.0 → 0.19.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 CHANGED
@@ -7,9 +7,15 @@ pi extension 跨层契约包:类型 + helper 函数 + 共享行为原语,零
7
7
  - `core/` —— 通用协议层(所有 extension 共用:`GuiComponent` + 布局原语 + 传输编码 + 双模 widget helper)
8
8
  - `extensions/` —— 有运行时定制逻辑的 extension(marker + helper)
9
9
  - `ask-user/` —— 富交互(select 通道 + marker)
10
+ - `plan/` —— plan 生命周期状态机 + 审阅回传值域契约 + 旧 entry legacy 读取(纯函数零 pi 依赖,扩展 / runtime / renderer 三层共用)
11
+ - `scheduler/` —— scheduler 任务条目契约 + entry 重放折叠(replayFoldEntries)+ 时间格式化(纯契约与纯函数,零 pi/node 依赖)
12
+ - `scheduler-create/` —— scheduler 创建确认共享资产(ScheduleDraft / ScheduleFormResult 类型 + 形状与时间折叠守卫 + marker)
10
13
  - `session-manager/` —— agent-managed session 嵌套 `{action, params}` 契约(select 通道 + marker)
11
- - `plugin-bridge/` —— plugin system bridge(插件工具/事件/拦截经 select 通道 + marker 桥接)
12
14
  - `subagent-engine/` —— 引擎可发现性(`engines.json` 状态文件 + 引擎配置视图)
15
+ - `subagent-inflight/` —— subagent 在途聚合上报(绝对计数报告 + marker,select 通道)
16
+ - `subagent-notify/` —— subagent-workflow 通知通道 customType 常量唯一来源(workflow 结果 / 后台通知 / subagent 指令三类)
17
+ - `ui-form/` —— 统一提问表单协议(ask-user / scheduler / plan 三方提问统一入口:类型 + marker + 交互 helper + 守卫)
18
+ - 完整子协议清单以 `src/index.ts` 导出为准
13
19
  - `pending-entries` —— pending 事件流差集核心(register 去重 + unregister 抵消,纯算法)
14
20
  - `background-task` —— base-tool-enhance 后台任务 `registry.json` 文件契约
15
21
  - 子出口 `@zhushanwen/extension-protocol/background-task` —— 后台任务行为原语(进程处置 / registry 文件 IO / output tail,含 node 内建依赖,不进 index 桶出口)
package/dist/index.d.ts CHANGED
@@ -392,18 +392,18 @@ declare function firstContentText(result: {
392
392
  /**
393
393
  * select+marker 通道 RPC 原语(D8)。
394
394
  *
395
- * 三消费方(plugin-bridge / session-manager / subagent-workflow inflight-reporter)
396
- * 此前各自手写「ctx.ui.select(marker, [payload], opts) + 失败折叠 + JSON 检测」传输核,
395
+ * 消费方(session-manager / subagent-workflow inflight-reporter)各自手写过
396
+ * 「ctx.ui.select(marker, [payload], opts) + 失败折叠 + JSON 检测」传输核,
397
397
  * 形态同构、留痕/超时策略各异。本原语只收敛传输核与失败折叠契约,真差异留在调用方:
398
398
  *
399
399
  * - 判别结果而非抛错(调用方统一按 reason 折叠 isError / 重试);
400
400
  * - 回包只做 JSON 合法性检测(`non-json` 判别 + 留痕),parsed 结果的消费留调用方——
401
- * value 恒 raw string(session-manager raw 透传 / plugin-bridge 各形状守卫 / inflight
402
- * ack 全等匹配,三态回包消费是真差异,不进原语);
401
+ * value 恒 raw string(session-manager raw 透传 / inflight ack 全等匹配,回包消费
402
+ * 是真差异,不进原语);
403
403
  * - payload 调用方已序列化(原语不 stringify——各协议序列化形状各异:嵌套
404
- * {action,params} / BridgeRequest / 快照帧,不引入内部 stringify 异常面);
405
- * - mode 门控留调用方(三方现状各异:plugin-bridge 在 callBridge 内 / inflight 在
406
- * attachSession 处 / session-manager 无门控——四态 reason 无 non-rpc 语义);
404
+ * {action,params} / 快照帧,不引入内部 stringify 异常面);
405
+ * - mode 门控留调用方(inflight 在 attachSession 处 / session-manager 无门控——
406
+ * 四态 reason 无 non-rpc 语义);
407
407
  * - `ui.select` 缺席(非 GUI ctx)由调用方前置判定(沿 ask-user askUserInteract 的
408
408
  * `isGuiCapable(ctx) && ctx.ui?.select` 先例);误用即 throw 明确错误。
409
409
  *
@@ -427,9 +427,9 @@ interface MarkerRpcOptions {
427
427
  * 日志策略(级别 / 前缀 / 防刷屏)归调用方——真差异保留。 */
428
428
  log?: (msg: string, detail?: object) => void;
429
429
  }
430
- /** 错误回包底层形状:select+marker 通道各协议(plugin-bridge / session-manager)
430
+ /** 错误回包底层形状:select+marker 通道各协议(session-manager)
431
431
  * runtime 侧异常折叠的共用单源(不裸 reject,error 闭环走同一回包通道)。
432
- * BridgeErrorResponse / SessionManagerErrorResult 是本形状的 alias(D8 单源化)。 */
432
+ * SessionManagerErrorResult 是本形状的 alias(D8 单源化)。 */
433
433
  interface ChannelErrorResult {
434
434
  error: string;
435
435
  hint?: string;
@@ -648,6 +648,13 @@ type SchedulerEntryOp = {
648
648
  * 避免恢复出的运行时 task 与快照共享数组/元素引用(task 后续被 mutate 时不污染快照)。
649
649
  */
650
650
  declare function snapshotToTask(snapshot: TaskSnapshot): ScheduledTask;
651
+ /**
652
+ * scheduler-manager 插件推树的 overlay 定时任务 tab ViewHost 分区键(历史命名
653
+ * modal-<pluginId>-<modalId>,modal 链退役后原值保留):插件 views.update 推树与
654
+ * taiji renderer ViewHost 消费跨包共用本单源——双端各持字面量时任一端漂移即
655
+ * ViewHost per-session 分区静默 miss(tab 空白无报错),收敛到本文件单点导出。
656
+ */
657
+ declare const SCHEDULER_MODAL_VIEW_ID = "modal-scheduler-manager-scheduler-manager.panel";
651
658
 
652
659
  /**
653
660
  * 折叠期降级日志注入点:包内不持有任何 logger 依赖(零 pi 依赖收敛),由调用方注入。
@@ -1429,8 +1436,7 @@ interface SubagentInFlightReport {
1429
1436
  inFlight: number;
1430
1437
  /**
1431
1438
  * 上报所属 session(ctx.sessionManager.getSessionId())。pi 延迟写入窗口内可能取
1432
- * 不到(plugin-bridge getSessionId 同款防御)——缺席时消费方按无法归属丢弃整帧
1433
- * (不镜像),不视为协议错误。
1439
+ * 不到——缺席时消费方按无法归属丢弃整帧(不镜像),不视为协议错误。
1434
1440
  */
1435
1441
  sessionId?: string;
1436
1442
  /** 产生时点(ms epoch,pi 进程内取值)。诊断/乱序排查用,消费方不依赖其单调性。 */
@@ -1468,6 +1474,92 @@ declare function isInFlightReportAck(v: unknown): v is typeof INFLIGHT_REPORT_AC
1468
1474
  */
1469
1475
  declare const SUBAGENT_INFLIGHT_MARKER = "\0TAIJI_SUBAGENT_INFLIGHT";
1470
1476
 
1477
+ /**
1478
+ * journal 事件推送的类型定义(event-push-channel 协议面)。
1479
+ *
1480
+ * 契约两端:
1481
+ * - 写侧(生产):@zhushanwen/pi-subagent-workflow 壳层(src/host/journal-reporter.ts)
1482
+ * 监听 subagent-core 的 journal 落盘出口回调(notifyJournalAppended),经 select
1483
+ * 通道带回执推送;
1484
+ * - 读侧(消费):taiji runtime event-adapter 的 marker 路由分支 → journal-report-router
1485
+ * → SessionEventProjection(applyJournalReport:seq 缺口判定 → 缺口触发本地补读 → fold)。
1486
+ *
1487
+ * 语义锚点(设计 §3.3):推送报告只携带事件本体(事件信封自带 seq),不另设水位协商
1488
+ * ——消费方 per 文件持两个水位(字节偏移 = 补读起点、已折叠最大 seq = 去重判据),
1489
+ * 重复投递由域 fold 的 seq 单调检查构造性幂等。确认回执 = runtime 同步 fold 应用后
1490
+ * resolve(回执 = 「已应用」而非「已接收」)。
1491
+ */
1492
+ /** journal 两域(单 marker 载荷判别字段——设计 §3.4 D2:两域推送方/接收方/通道语义同构,不拆双 marker)。 */
1493
+ type SubagentJournalDomain = 'run' | 'record';
1494
+ /**
1495
+ * 单条 journal 事件(run 域 = run journal 行 / record 域 = record 事件行——域内
1496
+ * 词表校验归读侧与文件行同一解析器,本层只校验跨域共同信封)。
1497
+ */
1498
+ interface SubagentJournalEvent {
1499
+ /** 事件类型(域词表成员资格由读侧按域校验)。 */
1500
+ type: string;
1501
+ /** 事件时点(ms epoch;信封必填)。 */
1502
+ ts: number;
1503
+ /**
1504
+ * journal 行序号(写入方 JsonlEventStream.append 统一分配)。缺省 = W1 前存量
1505
+ * 无 seq 行(设计 §3.3 兼容条款:无 seq 事件不参与缺口判定,fold 按状态机语义幂等)。
1506
+ */
1507
+ seq?: number;
1508
+ /** 域内载荷字段原样透传(写侧 = 刚落盘的行对象,无二次塑形)。 */
1509
+ [key: string]: unknown;
1510
+ }
1511
+ /**
1512
+ * 单帧 journal 事件报告(pi 进程 → runtime,经 select 通道,title = SUBAGENT_JOURNAL_MARKER,
1513
+ * options = [JSON.stringify(本形状)])。单帧只覆盖一个文件(fileKey 单数——设计 §3.4:
1514
+ * fileKey = runId 或 sa-id;多文件积压由写侧按组逐帧发送)。
1515
+ */
1516
+ interface SubagentJournalReport {
1517
+ /** 事件所属域(run / record 判别)。 */
1518
+ domain: SubagentJournalDomain;
1519
+ /** 文件键:run 域 = runId,record 域 = record id(sa-id)。 */
1520
+ fileKey: string;
1521
+ /** 本帧事件(写入序;写侧落盘提交点之后的增量批次)。 */
1522
+ events: SubagentJournalEvent[];
1523
+ /**
1524
+ * 上报所属 session(ctx.sessionManager.getSessionId())。pi 延迟写入窗口内可能取
1525
+ * 不到——缺席时消费方按无法归属丢弃整帧(不 fold 不 ack),不视为协议错误
1526
+ * (归属权威 = 连接的 sessionId,本字段只作在场性判据——inflight 同款先例)。
1527
+ */
1528
+ sessionId?: string;
1529
+ /** 产生时点(ms epoch,pi 进程内取值)。诊断/乱序排查用,消费方不依赖其单调性。 */
1530
+ emittedAt: number;
1531
+ }
1532
+ /**
1533
+ * select 通道的确认回包(runtime event-adapter 处理完帧后 resolve 给 pi 侧的
1534
+ * JSON 字符串)。回执语义 = 「已应用」(runtime 同步完成 fold 应用后 resolve,
1535
+ * 设计 §3.4 D7 生效回执)——写侧非本字符串即未确认:首败 warn 留证 + 缓冲丢弃
1536
+ * 不重推(完整性由消费方 seq 缺口补读收敛,设计 §3.3 D5)。
1537
+ */
1538
+ declare const JOURNAL_REPORT_ACK: "{\"ack\":true}";
1539
+ /**
1540
+ * SubagentJournalReport 形状守卫:domain 落两域词表、fileKey 非空串、events 逐条
1541
+ * 过信封守卫、sessionId 缺席或 string。event-adapter 路由分支消费;非法帧返回
1542
+ * false(调用方丢弃,不 fold 不 ack)。
1543
+ */
1544
+ declare function isSubagentJournalReport(v: unknown): v is SubagentJournalReport;
1545
+ /** 确认回包形状守卫(pi 侧 reporter 消费——非本字符串即未确认)。 */
1546
+ declare function isJournalReportAck(v: unknown): v is typeof JOURNAL_REPORT_ACK;
1547
+
1548
+ /**
1549
+ * journal 事件推送的 title marker。runtime event-adapter 检测此 marker 区分
1550
+ * journal 事件报告与普通 select;pi 侧壳层(@zhushanwen/pi-subagent-workflow 的
1551
+ * host/journal-reporter)经同一 marker 以带回执语义推送 SubagentJournalReport
1552
+ * 帧(单一来源,两端口径必然一致)。
1553
+ *
1554
+ * NUL 前缀确保不会与 extension 正常的 select title 冲突。
1555
+ * 与 SUBAGENT_INFLIGHT_MARKER / ASK_USER_MARKER / SESSION_MANAGER_MARKER 同理。
1556
+ *
1557
+ * 设计权威源:.tmp/tech-design/event-push-channel.md §3.1/§3.4(journal 写入方
1558
+ * subagent-core 在落盘提交点经本 marker 通道把新事件批量推给 runtime,通道数量
1559
+ * = 1 个,载荷内 domain 字段判别 run/record 两域)。
1560
+ */
1561
+ declare const SUBAGENT_JOURNAL_MARKER = "\0TAIJI_SUBAGENT_JOURNAL";
1562
+
1471
1563
  /**
1472
1564
  * subagent-workflow 通知通道的 custom_message customType 词表(单源)。
1473
1565
  *
@@ -1500,99 +1592,6 @@ declare const SUBAGENT_BG_NOTIFY_CUSTOM_TYPE: "subagent-bg-notify";
1500
1592
  * 上下文 + renderer 定向气泡)。shared parseSubagentDirective / runtime display 覆写消费。 */
1501
1593
  declare const SUBAGENT_DIRECTIVE_CUSTOM_TYPE: "subagent-directive";
1502
1594
 
1503
- /**
1504
- * plugin-bridge 请求的 title marker。runtime event-adapter 和 pi 侧
1505
- * bridge extension(@zhushanwen/pi-plugin-bridge)双端消费此 marker,
1506
- * 在 select 通道上区分 bridge 帧与普通 select(单一来源,两端口径必然一致)。
1507
- *
1508
- * NUL 前缀确保不会与 extension 正常的 select title 冲突。
1509
- * 与 ASK_USER_MARKER / SESSION_MANAGER_MARKER / GUI_WIDGET_MARKER 同理。
1510
- */
1511
- declare const BRIDGE_MARKER = "\0TAIJI_BRIDGE";
1512
- /**
1513
- * 协议 v2 的 4 个 method 运行时集合(与 BridgeMethod 类型同源——types.ts 从此派生)。
1514
- * event-adapter 用它校验 marker 帧的 method 合法性,
1515
- * 非法值折叠为 'bridge:malformed' 哨兵(handler 回 malformed 错误,不静默丢弃)。
1516
- */
1517
- declare const BRIDGE_METHODS: readonly ["bridge:sync", "bridge:tool_execute", "bridge:event", "bridge:intercept"];
1518
-
1519
- /**
1520
- * plugin-bridge 协议 v2 的类型定义。
1521
- *
1522
- * select + BRIDGE_MARKER 通道上的请求/回包形状,pi 侧 bridge extension
1523
- * (序列化发送方)与 runtime bridge-handler(解析与回包方)共用。
1524
- * 向后不兼容旧 bridge:* method 承载(旧链路本来就不通,改名无收益)。
1525
- * marker 检测后按 method 分发到对应 handler 分支。
1526
- */
1527
-
1528
- /** 协议 v2 的 4 个 method(从 BRIDGE_METHODS 集合派生,值与类型同源) */
1529
- type BridgeMethod = (typeof BRIDGE_METHODS)[number];
1530
- /** bridge 请求的统一形状(pi bridge extension → runtime via select 通道) */
1531
- interface BridgeRequest {
1532
- method: BridgeMethod;
1533
- /** tool_execute 专属:工具名 */
1534
- toolName?: string;
1535
- /** tool_execute 专属:工具调用 id */
1536
- toolCallId?: string;
1537
- /** tool_execute 专属:工具入参 */
1538
- params?: Record<string, unknown>;
1539
- /** 发起请求的 session(tool_execute/event/intercept 携带,供 runtime 按 session 路由
1540
- * 防跨 session 串台;bridge:sync 全局快照请求不带) */
1541
- sessionId?: string;
1542
- /** event / intercept 专属:pi 原生事件名 */
1543
- eventName?: string;
1544
- /** event / intercept 专属:事件负载 */
1545
- data?: unknown;
1546
- }
1547
- /** tool_execute 回包:插件工具执行结果 */
1548
- interface BridgeToolExecuteResponse {
1549
- content: string;
1550
- isError?: boolean;
1551
- }
1552
- /** sync 回包:工具清单快照(pi 侧命令发现不走本协议,另走 getCommands 通路) */
1553
- interface BridgeSyncPayload {
1554
- tools: Array<{
1555
- name: string;
1556
- description: string;
1557
- parameters: Record<string, unknown>;
1558
- }>;
1559
- success: true;
1560
- }
1561
- /** intercept 回包:before_agent_start 拦截决策(bridge 侧把 injectedMessages 映射为单条 CustomMessage) */
1562
- interface BridgeInterceptResponse {
1563
- blocked?: boolean;
1564
- reason?: string;
1565
- injectedMessages: unknown[];
1566
- }
1567
- /** 错误回包:runtime 侧异常折叠(不裸 reject;bridge 侧解析后以 isError 返回)。
1568
- * D8 单源化:底层形状 alias 到 core 的 ChannelErrorResult(导出名与文件位置不变,
1569
- * public API 零破坏)。 */
1570
- type BridgeErrorResponse = ChannelErrorResult;
1571
-
1572
- /**
1573
- * plugin-bridge 回包形状守卫族(D11 自 extensions/taiji/plugin-bridge index.ts 零改动迁入)。
1574
- *
1575
- * 「marker + types + 守卫」同住惯例(session-manager / subagent-inflight 先例):
1576
- * 回包形状的运行时检测与类型定义同源维护。当前唯一消费方 = pi 侧 bridge
1577
- * extension;runtime bridge-handler 的 5 处 `as string` 断言是后续批次的第二
1578
- * 消费方(换校验的铺路,设计 D11 登记项)。
1579
- *
1580
- * isRecord 为模块内私有副本(排数组严版——与 subagent-inflight / session-manager
1581
- * 副本同款同义):protocol 不依赖 extensions 层的 ext-guards(分层边界裁决,D3
1582
- * 明确排除),包内三份私有副本并存是裁决下的既有惯例,语义必须一致。
1583
- *
1584
- * 设计权威源:docs/architecture/ext-simplify-17-shared-extraction.md §3.3 D11。
1585
- */
1586
-
1587
- /** runtime 错误闭环形状 {error, hint?}(设计 §3.3-D1:不裸 reject)——检测逻辑单源于
1588
- * core 的 isChannelErrorResult(D8),本名保留为守卫族整体成员(D11 迁移) */
1589
- declare function isBridgeErrorResponse(v: unknown): v is BridgeErrorResponse;
1590
- declare function isBridgeToolExecuteResponse(v: unknown): v is BridgeToolExecuteResponse;
1591
- declare function isBridgeSyncPayload(v: unknown): v is BridgeSyncPayload;
1592
- declare function isBridgeInterceptResponse(v: unknown): v is BridgeInterceptResponse;
1593
- /** sync 清单里的单个工具条目(parameters 顶层必须 type:'object'——OpenAI 兼容红线) */
1594
- declare function isSyncedTool(v: unknown): v is BridgeSyncPayload['tools'][number];
1595
-
1596
1595
  /**
1597
1596
  * 子代理引擎契约(U7 引擎可发现性 + GUI 引擎选择)。
1598
1597
  *
@@ -1705,4 +1704,4 @@ declare function collectActivePendingIds(entries: unknown[], opts?: CollectPendi
1705
1704
  type MappedPendingStatus = 'completed' | 'failed' | 'cancelled' | 'expired' | 'time_limited' | 'aborted';
1706
1705
  declare function mapReasonToStatus(reason: string): MappedPendingStatus;
1707
1706
 
1708
- export { ASK_USER_MARKER, type AskUserAnswers, type AskUserOption, type AskUserQuestion, BRIDGE_MARKER, BRIDGE_METHODS, type BridgeErrorResponse, type BridgeInterceptResponse, type BridgeMethod, type BridgeRequest, type BridgeSyncPayload, type BridgeToolExecuteResponse, type ChannelErrorResult, type ChoiceQuestion, type CollectPendingIdsOptions, type DualWidgetContent, type ExecutionRecord, type FormAnswers, type FormOption, type FormQuestion, GUI_WIDGET_MARKER, type GuiComponent, type GuiComponentProps, type GuiComponentType, type GuiContext, type GuiRenderResult, HISTORY_LIMIT, INFLIGHT_REPORT_ACK, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, type MappedPendingStatus, type MarkerRpcOptions, type MarkerRpcResult, PENDING_REGISTER_ENTRY_TYPE, PENDING_UNREGISTER_ENTRY_TYPE, PLAN_LIFECYCLE_EVENTS, PLAN_LIFECYCLE_STATES, PLAN_REVIEW_MARKER, PLAN_SELF_REVIEW_MAX_BYTES, PLAN_STATE_CUSTOM_TYPE, PROTOCOL_VERSION, type PendingEntriesScan, type PlanDocMeta, type PlanLifecycleEvent, type PlanLifecycleState, type PlanPhase, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, type PlanReviewResponseEnvelope, type PlanTransitionResult, type ReplayFoldOptions, SCHEDULE_CREATE_MARKER, SESSION_MANAGER_ACTIONS, SESSION_MANAGER_MARKER, SUBAGENTS_ENGINES_FILENAME, SUBAGENT_BG_NOTIFY_CUSTOM_TYPE, SUBAGENT_DIRECTIVE_CUSTOM_TYPE, SUBAGENT_INFLIGHT_MARKER, type ScheduleDraft, type ScheduleFormResult, type ScheduleKind, type ScheduleQuestion, type ScheduleSpec, type ScheduledTask, type SchedulerEntryLike, type SchedulerEntryOp, type SessionManagerAbortParams, type SessionManagerAbortResult, type SessionManagerAction, type SessionManagerCreateParams, type SessionManagerCreateResult, type SessionManagerErrorResult, type SessionManagerHistoryParams, type SessionManagerHistoryResult, type SessionManagerListParams, type SessionManagerListResult, type SessionManagerParams, type SessionManagerSendParams, type SessionManagerSendResult, type SessionManagerSessionSummary, type SessionManagerStatusParams, type SessionManagerStatusResult, type SessionManagerWatchParams, type SessionManagerWatchReason, type SessionManagerWatchRespondPayload, type StatItem, type SubagentEngineConfigView, type SubagentEnginesFile, type SubagentInFlightReport, TASK_ENTRY_TYPE, type TaskKind, type TaskSnapshot, type TaskStatus, type TextQuestion, type TreeItem, type TreeItemIcon, UI_FORM_MARKER, type UiFormInteractOptions, type UiFormInteractResult, WORKFLOW_RESULT_CUSTOM_TYPE, type WidgetIconPathsRejection, type WidgetIconPathsValidation, type WidgetMeta, appendExecutionRecord, applyPendingDiff, callMarkerRpc, collectActivePendingIds, dateToOnceCron, derivePhase, extractGui, firstContentText, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isBridgeErrorResponse, isBridgeInterceptResponse, isBridgeSyncPayload, isBridgeToolExecuteResponse, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isPlanReviewRequest, isPlanReviewResponse, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerCreateParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerNotifyId, isSessionManagerSendParams, isSessionManagerStatusParams, isSessionManagerWatchParams, isSessionManagerWatchRespondPayload, isSubagentInFlightReport, isSyncedTool, mapReasonToStatus, onceCronToDate, parsePlanReviewResponse, readLifecycleState, readResumeHint, replayFoldEntries, scanPendingEntries, setWidgetDual, snapshotToTask, transition, truncateSelfReview, uiFormInteract, validateWidgetIconPaths };
1707
+ export { ASK_USER_MARKER, type AskUserAnswers, type AskUserOption, type AskUserQuestion, type ChannelErrorResult, type ChoiceQuestion, type CollectPendingIdsOptions, type DualWidgetContent, type ExecutionRecord, type FormAnswers, type FormOption, type FormQuestion, GUI_WIDGET_MARKER, type GuiComponent, type GuiComponentProps, type GuiComponentType, type GuiContext, type GuiRenderResult, HISTORY_LIMIT, INFLIGHT_REPORT_ACK, JOURNAL_REPORT_ACK, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, type MappedPendingStatus, type MarkerRpcOptions, type MarkerRpcResult, PENDING_REGISTER_ENTRY_TYPE, PENDING_UNREGISTER_ENTRY_TYPE, PLAN_LIFECYCLE_EVENTS, PLAN_LIFECYCLE_STATES, PLAN_REVIEW_MARKER, PLAN_SELF_REVIEW_MAX_BYTES, PLAN_STATE_CUSTOM_TYPE, PROTOCOL_VERSION, type PendingEntriesScan, type PlanDocMeta, type PlanLifecycleEvent, type PlanLifecycleState, type PlanPhase, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, type PlanReviewResponseEnvelope, type PlanTransitionResult, type ReplayFoldOptions, SCHEDULER_MODAL_VIEW_ID, SCHEDULE_CREATE_MARKER, SESSION_MANAGER_ACTIONS, SESSION_MANAGER_MARKER, SUBAGENTS_ENGINES_FILENAME, SUBAGENT_BG_NOTIFY_CUSTOM_TYPE, SUBAGENT_DIRECTIVE_CUSTOM_TYPE, SUBAGENT_INFLIGHT_MARKER, SUBAGENT_JOURNAL_MARKER, type ScheduleDraft, type ScheduleFormResult, type ScheduleKind, type ScheduleQuestion, type ScheduleSpec, type ScheduledTask, type SchedulerEntryLike, type SchedulerEntryOp, type SessionManagerAbortParams, type SessionManagerAbortResult, type SessionManagerAction, type SessionManagerCreateParams, type SessionManagerCreateResult, type SessionManagerErrorResult, type SessionManagerHistoryParams, type SessionManagerHistoryResult, type SessionManagerListParams, type SessionManagerListResult, type SessionManagerParams, type SessionManagerSendParams, type SessionManagerSendResult, type SessionManagerSessionSummary, type SessionManagerStatusParams, type SessionManagerStatusResult, type SessionManagerWatchParams, type SessionManagerWatchReason, type SessionManagerWatchRespondPayload, type StatItem, type SubagentEngineConfigView, type SubagentEnginesFile, type SubagentInFlightReport, type SubagentJournalDomain, type SubagentJournalEvent, type SubagentJournalReport, TASK_ENTRY_TYPE, type TaskKind, type TaskSnapshot, type TaskStatus, type TextQuestion, type TreeItem, type TreeItemIcon, UI_FORM_MARKER, type UiFormInteractOptions, type UiFormInteractResult, WORKFLOW_RESULT_CUSTOM_TYPE, type WidgetIconPathsRejection, type WidgetIconPathsValidation, type WidgetMeta, appendExecutionRecord, applyPendingDiff, callMarkerRpc, collectActivePendingIds, dateToOnceCron, derivePhase, extractGui, firstContentText, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isJournalReportAck, isPlanReviewRequest, isPlanReviewResponse, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerCreateParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerNotifyId, isSessionManagerSendParams, isSessionManagerStatusParams, isSessionManagerWatchParams, isSessionManagerWatchRespondPayload, isSubagentInFlightReport, isSubagentJournalReport, mapReasonToStatus, onceCronToDate, parsePlanReviewResponse, readLifecycleState, readResumeHint, replayFoldEntries, scanPendingEntries, setWidgetDual, snapshotToTask, transition, truncateSelfReview, uiFormInteract, validateWidgetIconPaths };
package/dist/index.js CHANGED
@@ -211,6 +211,7 @@ function snapshotToTask(snapshot) {
211
211
  history: snapshot.history.map((h) => ({ ...h }))
212
212
  };
213
213
  }
214
+ var SCHEDULER_MODAL_VIEW_ID = "modal-scheduler-manager-scheduler-manager.panel";
214
215
 
215
216
  // src/extensions/scheduler/replay.ts
216
217
  function toErrorMessage(e) {
@@ -752,35 +753,44 @@ function isInFlightReportAck(v) {
752
753
  return v === INFLIGHT_REPORT_ACK;
753
754
  }
754
755
 
755
- // src/extensions/subagent-notify/custom-types.ts
756
- var WORKFLOW_RESULT_CUSTOM_TYPE = "workflow-result";
757
- var SUBAGENT_BG_NOTIFY_CUSTOM_TYPE = "subagent-bg-notify";
758
- var SUBAGENT_DIRECTIVE_CUSTOM_TYPE = "subagent-directive";
759
-
760
- // src/extensions/plugin-bridge/marker.ts
761
- var BRIDGE_MARKER = "\0TAIJI_BRIDGE";
762
- var BRIDGE_METHODS = ["bridge:sync", "bridge:tool_execute", "bridge:event", "bridge:intercept"];
756
+ // src/extensions/subagent-journal/marker.ts
757
+ var SUBAGENT_JOURNAL_MARKER = "\0TAIJI_SUBAGENT_JOURNAL";
763
758
 
764
- // src/extensions/plugin-bridge/guards.ts
759
+ // src/extensions/subagent-journal/types.ts
760
+ var JOURNAL_REPORT_ACK = '{"ack":true}';
765
761
  function isRecord3(v) {
766
762
  return typeof v === "object" && v !== null && !Array.isArray(v);
767
763
  }
768
- function isBridgeErrorResponse(v) {
769
- return isChannelErrorResult(v);
770
- }
771
- function isBridgeToolExecuteResponse(v) {
772
- return isRecord3(v) && typeof v.content === "string" && (v.isError === void 0 || typeof v.isError === "boolean");
773
- }
774
- function isBridgeSyncPayload(v) {
775
- return isRecord3(v) && v.success === true && Array.isArray(v.tools);
764
+ function isSubagentJournalEvent(v) {
765
+ if (!isRecord3(v)) return false;
766
+ if (typeof v.type !== "string" || v.type === "") return false;
767
+ if (typeof v.ts !== "number" || !Number.isFinite(v.ts)) return false;
768
+ if (v.seq !== void 0 && (typeof v.seq !== "number" || !Number.isSafeInteger(v.seq) || v.seq < 1)) {
769
+ return false;
770
+ }
771
+ return true;
776
772
  }
777
- function isBridgeInterceptResponse(v) {
778
- return isRecord3(v) && Array.isArray(v.injectedMessages);
773
+ function isSubagentJournalReport(v) {
774
+ if (!isRecord3(v)) return false;
775
+ if (v.domain !== "run" && v.domain !== "record") return false;
776
+ if (typeof v.fileKey !== "string" || v.fileKey === "") return false;
777
+ if (!Array.isArray(v.events)) return false;
778
+ for (const event of v.events) {
779
+ if (!isSubagentJournalEvent(event)) return false;
780
+ }
781
+ if (typeof v.emittedAt !== "number") return false;
782
+ if (v.sessionId !== void 0 && typeof v.sessionId !== "string") return false;
783
+ return true;
779
784
  }
780
- function isSyncedTool(v) {
781
- return isRecord3(v) && typeof v.name === "string" && typeof v.description === "string" && isRecord3(v.parameters) && v.parameters.type === "object";
785
+ function isJournalReportAck(v) {
786
+ return v === JOURNAL_REPORT_ACK;
782
787
  }
783
788
 
789
+ // src/extensions/subagent-notify/custom-types.ts
790
+ var WORKFLOW_RESULT_CUSTOM_TYPE = "workflow-result";
791
+ var SUBAGENT_BG_NOTIFY_CUSTOM_TYPE = "subagent-bg-notify";
792
+ var SUBAGENT_DIRECTIVE_CUSTOM_TYPE = "subagent-directive";
793
+
784
794
  // src/extensions/subagent-engine/contract.ts
785
795
  var SUBAGENTS_ENGINES_FILENAME = "engines.json";
786
796
 
@@ -849,11 +859,10 @@ export {
849
859
  BACKGROUND_TASK_REGISTRY_FILENAME,
850
860
  BACKGROUND_TASK_REGISTRY_VERSION,
851
861
  BASE_TOOL_ENHANCE_DIRNAME,
852
- BRIDGE_MARKER,
853
- BRIDGE_METHODS,
854
862
  GUI_WIDGET_MARKER,
855
863
  HISTORY_LIMIT,
856
864
  INFLIGHT_REPORT_ACK,
865
+ JOURNAL_REPORT_ACK,
857
866
  MAX_TERMINAL_REGISTRY_ENTRIES,
858
867
  MS_PER_DAY,
859
868
  MS_PER_HOUR,
@@ -867,6 +876,7 @@ export {
867
876
  PLAN_SELF_REVIEW_MAX_BYTES,
868
877
  PLAN_STATE_CUSTOM_TYPE,
869
878
  PROTOCOL_VERSION,
879
+ SCHEDULER_MODAL_VIEW_ID,
870
880
  SCHEDULE_CREATE_MARKER,
871
881
  SESSION_MANAGER_ACTIONS,
872
882
  SESSION_MANAGER_MARKER,
@@ -874,6 +884,7 @@ export {
874
884
  SUBAGENT_BG_NOTIFY_CUSTOM_TYPE,
875
885
  SUBAGENT_DIRECTIVE_CUSTOM_TYPE,
876
886
  SUBAGENT_INFLIGHT_MARKER,
887
+ SUBAGENT_JOURNAL_MARKER,
877
888
  TASK_ENTRY_TYPE,
878
889
  UI_FORM_MARKER,
879
890
  WORKFLOW_RESULT_CUSTOM_TYPE,
@@ -897,10 +908,6 @@ export {
897
908
  isActiveBackgroundTaskState,
898
909
  isAskUserQuestion,
899
910
  isBackgroundTaskRegistryEntry,
900
- isBridgeErrorResponse,
901
- isBridgeInterceptResponse,
902
- isBridgeSyncPayload,
903
- isBridgeToolExecuteResponse,
904
911
  isChannelErrorResult,
905
912
  isFormAnswers,
906
913
  isFormQuestion,
@@ -908,6 +915,7 @@ export {
908
915
  isGuiComponent,
909
916
  isGuiRenderResult,
910
917
  isInFlightReportAck,
918
+ isJournalReportAck,
911
919
  isPlanReviewRequest,
912
920
  isPlanReviewResponse,
913
921
  isScheduleDraft,
@@ -922,7 +930,7 @@ export {
922
930
  isSessionManagerWatchParams,
923
931
  isSessionManagerWatchRespondPayload,
924
932
  isSubagentInFlightReport,
925
- isSyncedTool,
933
+ isSubagentJournalReport,
926
934
  isTerminalBackgroundTaskState,
927
935
  mapReasonToStatus,
928
936
  onceCronToDate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/extension-protocol",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Cross-layer pi extension contract package: dual-mode (TUI/GUI) rendering helpers, session/background-task/pending-entries protocols, and shared behavior primitives",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",