@zhushanwen/extension-protocol 0.17.0 → 0.18.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 +7 -1
- package/dist/index.d.ts +97 -105
- package/dist/index.js +34 -28
- package/package.json +1 -1
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
|
-
*
|
|
396
|
-
*
|
|
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 透传 /
|
|
402
|
-
*
|
|
401
|
+
* value 恒 raw string(session-manager raw 透传 / inflight ack 全等匹配,回包消费
|
|
402
|
+
* 是真差异,不进原语);
|
|
403
403
|
* - payload 调用方已序列化(原语不 stringify——各协议序列化形状各异:嵌套
|
|
404
|
-
* {action,params} /
|
|
405
|
-
* - mode
|
|
406
|
-
*
|
|
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 通道各协议(
|
|
430
|
+
/** 错误回包底层形状:select+marker 通道各协议(session-manager)
|
|
431
431
|
* runtime 侧异常折叠的共用单源(不裸 reject,error 闭环走同一回包通道)。
|
|
432
|
-
*
|
|
432
|
+
* SessionManagerErrorResult 是本形状的 alias(D8 单源化)。 */
|
|
433
433
|
interface ChannelErrorResult {
|
|
434
434
|
error: string;
|
|
435
435
|
hint?: string;
|
|
@@ -1429,8 +1429,7 @@ interface SubagentInFlightReport {
|
|
|
1429
1429
|
inFlight: number;
|
|
1430
1430
|
/**
|
|
1431
1431
|
* 上报所属 session(ctx.sessionManager.getSessionId())。pi 延迟写入窗口内可能取
|
|
1432
|
-
*
|
|
1433
|
-
* (不镜像),不视为协议错误。
|
|
1432
|
+
* 不到——缺席时消费方按无法归属丢弃整帧(不镜像),不视为协议错误。
|
|
1434
1433
|
*/
|
|
1435
1434
|
sessionId?: string;
|
|
1436
1435
|
/** 产生时点(ms epoch,pi 进程内取值)。诊断/乱序排查用,消费方不依赖其单调性。 */
|
|
@@ -1468,6 +1467,92 @@ declare function isInFlightReportAck(v: unknown): v is typeof INFLIGHT_REPORT_AC
|
|
|
1468
1467
|
*/
|
|
1469
1468
|
declare const SUBAGENT_INFLIGHT_MARKER = "\0TAIJI_SUBAGENT_INFLIGHT";
|
|
1470
1469
|
|
|
1470
|
+
/**
|
|
1471
|
+
* journal 事件推送的类型定义(event-push-channel 协议面)。
|
|
1472
|
+
*
|
|
1473
|
+
* 契约两端:
|
|
1474
|
+
* - 写侧(生产):@zhushanwen/pi-subagent-workflow 壳层(src/host/journal-reporter.ts)
|
|
1475
|
+
* 监听 subagent-core 的 journal 落盘出口回调(notifyJournalAppended),经 select
|
|
1476
|
+
* 通道带回执推送;
|
|
1477
|
+
* - 读侧(消费):taiji runtime event-adapter 的 marker 路由分支 → journal-report-router
|
|
1478
|
+
* → SessionEventProjection(applyJournalReport:seq 缺口判定 → 缺口触发本地补读 → fold)。
|
|
1479
|
+
*
|
|
1480
|
+
* 语义锚点(设计 §3.3):推送报告只携带事件本体(事件信封自带 seq),不另设水位协商
|
|
1481
|
+
* ——消费方 per 文件持两个水位(字节偏移 = 补读起点、已折叠最大 seq = 去重判据),
|
|
1482
|
+
* 重复投递由域 fold 的 seq 单调检查构造性幂等。确认回执 = runtime 同步 fold 应用后
|
|
1483
|
+
* resolve(回执 = 「已应用」而非「已接收」)。
|
|
1484
|
+
*/
|
|
1485
|
+
/** journal 两域(单 marker 载荷判别字段——设计 §3.4 D2:两域推送方/接收方/通道语义同构,不拆双 marker)。 */
|
|
1486
|
+
type SubagentJournalDomain = 'run' | 'record';
|
|
1487
|
+
/**
|
|
1488
|
+
* 单条 journal 事件(run 域 = run journal 行 / record 域 = record 事件行——域内
|
|
1489
|
+
* 词表校验归读侧与文件行同一解析器,本层只校验跨域共同信封)。
|
|
1490
|
+
*/
|
|
1491
|
+
interface SubagentJournalEvent {
|
|
1492
|
+
/** 事件类型(域词表成员资格由读侧按域校验)。 */
|
|
1493
|
+
type: string;
|
|
1494
|
+
/** 事件时点(ms epoch;信封必填)。 */
|
|
1495
|
+
ts: number;
|
|
1496
|
+
/**
|
|
1497
|
+
* journal 行序号(写入方 JsonlEventStream.append 统一分配)。缺省 = W1 前存量
|
|
1498
|
+
* 无 seq 行(设计 §3.3 兼容条款:无 seq 事件不参与缺口判定,fold 按状态机语义幂等)。
|
|
1499
|
+
*/
|
|
1500
|
+
seq?: number;
|
|
1501
|
+
/** 域内载荷字段原样透传(写侧 = 刚落盘的行对象,无二次塑形)。 */
|
|
1502
|
+
[key: string]: unknown;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* 单帧 journal 事件报告(pi 进程 → runtime,经 select 通道,title = SUBAGENT_JOURNAL_MARKER,
|
|
1506
|
+
* options = [JSON.stringify(本形状)])。单帧只覆盖一个文件(fileKey 单数——设计 §3.4:
|
|
1507
|
+
* fileKey = runId 或 sa-id;多文件积压由写侧按组逐帧发送)。
|
|
1508
|
+
*/
|
|
1509
|
+
interface SubagentJournalReport {
|
|
1510
|
+
/** 事件所属域(run / record 判别)。 */
|
|
1511
|
+
domain: SubagentJournalDomain;
|
|
1512
|
+
/** 文件键:run 域 = runId,record 域 = record id(sa-id)。 */
|
|
1513
|
+
fileKey: string;
|
|
1514
|
+
/** 本帧事件(写入序;写侧落盘提交点之后的增量批次)。 */
|
|
1515
|
+
events: SubagentJournalEvent[];
|
|
1516
|
+
/**
|
|
1517
|
+
* 上报所属 session(ctx.sessionManager.getSessionId())。pi 延迟写入窗口内可能取
|
|
1518
|
+
* 不到——缺席时消费方按无法归属丢弃整帧(不 fold 不 ack),不视为协议错误
|
|
1519
|
+
* (归属权威 = 连接的 sessionId,本字段只作在场性判据——inflight 同款先例)。
|
|
1520
|
+
*/
|
|
1521
|
+
sessionId?: string;
|
|
1522
|
+
/** 产生时点(ms epoch,pi 进程内取值)。诊断/乱序排查用,消费方不依赖其单调性。 */
|
|
1523
|
+
emittedAt: number;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* select 通道的确认回包(runtime event-adapter 处理完帧后 resolve 给 pi 侧的
|
|
1527
|
+
* JSON 字符串)。回执语义 = 「已应用」(runtime 同步完成 fold 应用后 resolve,
|
|
1528
|
+
* 设计 §3.4 D7 生效回执)——写侧非本字符串即未确认:首败 warn 留证 + 缓冲丢弃
|
|
1529
|
+
* 不重推(完整性由消费方 seq 缺口补读收敛,设计 §3.3 D5)。
|
|
1530
|
+
*/
|
|
1531
|
+
declare const JOURNAL_REPORT_ACK: "{\"ack\":true}";
|
|
1532
|
+
/**
|
|
1533
|
+
* SubagentJournalReport 形状守卫:domain 落两域词表、fileKey 非空串、events 逐条
|
|
1534
|
+
* 过信封守卫、sessionId 缺席或 string。event-adapter 路由分支消费;非法帧返回
|
|
1535
|
+
* false(调用方丢弃,不 fold 不 ack)。
|
|
1536
|
+
*/
|
|
1537
|
+
declare function isSubagentJournalReport(v: unknown): v is SubagentJournalReport;
|
|
1538
|
+
/** 确认回包形状守卫(pi 侧 reporter 消费——非本字符串即未确认)。 */
|
|
1539
|
+
declare function isJournalReportAck(v: unknown): v is typeof JOURNAL_REPORT_ACK;
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* journal 事件推送的 title marker。runtime event-adapter 检测此 marker 区分
|
|
1543
|
+
* journal 事件报告与普通 select;pi 侧壳层(@zhushanwen/pi-subagent-workflow 的
|
|
1544
|
+
* host/journal-reporter)经同一 marker 以带回执语义推送 SubagentJournalReport
|
|
1545
|
+
* 帧(单一来源,两端口径必然一致)。
|
|
1546
|
+
*
|
|
1547
|
+
* NUL 前缀确保不会与 extension 正常的 select title 冲突。
|
|
1548
|
+
* 与 SUBAGENT_INFLIGHT_MARKER / ASK_USER_MARKER / SESSION_MANAGER_MARKER 同理。
|
|
1549
|
+
*
|
|
1550
|
+
* 设计权威源:.tmp/tech-design/event-push-channel.md §3.1/§3.4(journal 写入方
|
|
1551
|
+
* subagent-core 在落盘提交点经本 marker 通道把新事件批量推给 runtime,通道数量
|
|
1552
|
+
* = 1 个,载荷内 domain 字段判别 run/record 两域)。
|
|
1553
|
+
*/
|
|
1554
|
+
declare const SUBAGENT_JOURNAL_MARKER = "\0TAIJI_SUBAGENT_JOURNAL";
|
|
1555
|
+
|
|
1471
1556
|
/**
|
|
1472
1557
|
* subagent-workflow 通知通道的 custom_message customType 词表(单源)。
|
|
1473
1558
|
*
|
|
@@ -1500,99 +1585,6 @@ declare const SUBAGENT_BG_NOTIFY_CUSTOM_TYPE: "subagent-bg-notify";
|
|
|
1500
1585
|
* 上下文 + renderer 定向气泡)。shared parseSubagentDirective / runtime display 覆写消费。 */
|
|
1501
1586
|
declare const SUBAGENT_DIRECTIVE_CUSTOM_TYPE: "subagent-directive";
|
|
1502
1587
|
|
|
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
1588
|
/**
|
|
1597
1589
|
* 子代理引擎契约(U7 引擎可发现性 + GUI 引擎选择)。
|
|
1598
1590
|
*
|
|
@@ -1705,4 +1697,4 @@ declare function collectActivePendingIds(entries: unknown[], opts?: CollectPendi
|
|
|
1705
1697
|
type MappedPendingStatus = 'completed' | 'failed' | 'cancelled' | 'expired' | 'time_limited' | 'aborted';
|
|
1706
1698
|
declare function mapReasonToStatus(reason: string): MappedPendingStatus;
|
|
1707
1699
|
|
|
1708
|
-
export { ASK_USER_MARKER, type AskUserAnswers, type AskUserOption, type AskUserQuestion,
|
|
1700
|
+
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, 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
|
@@ -752,35 +752,44 @@ function isInFlightReportAck(v) {
|
|
|
752
752
|
return v === INFLIGHT_REPORT_ACK;
|
|
753
753
|
}
|
|
754
754
|
|
|
755
|
-
// src/extensions/subagent-
|
|
756
|
-
var
|
|
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"];
|
|
755
|
+
// src/extensions/subagent-journal/marker.ts
|
|
756
|
+
var SUBAGENT_JOURNAL_MARKER = "\0TAIJI_SUBAGENT_JOURNAL";
|
|
763
757
|
|
|
764
|
-
// src/extensions/
|
|
758
|
+
// src/extensions/subagent-journal/types.ts
|
|
759
|
+
var JOURNAL_REPORT_ACK = '{"ack":true}';
|
|
765
760
|
function isRecord3(v) {
|
|
766
761
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
767
762
|
}
|
|
768
|
-
function
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
return
|
|
763
|
+
function isSubagentJournalEvent(v) {
|
|
764
|
+
if (!isRecord3(v)) return false;
|
|
765
|
+
if (typeof v.type !== "string" || v.type === "") return false;
|
|
766
|
+
if (typeof v.ts !== "number" || !Number.isFinite(v.ts)) return false;
|
|
767
|
+
if (v.seq !== void 0 && (typeof v.seq !== "number" || !Number.isSafeInteger(v.seq) || v.seq < 1)) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
return true;
|
|
776
771
|
}
|
|
777
|
-
function
|
|
778
|
-
|
|
772
|
+
function isSubagentJournalReport(v) {
|
|
773
|
+
if (!isRecord3(v)) return false;
|
|
774
|
+
if (v.domain !== "run" && v.domain !== "record") return false;
|
|
775
|
+
if (typeof v.fileKey !== "string" || v.fileKey === "") return false;
|
|
776
|
+
if (!Array.isArray(v.events)) return false;
|
|
777
|
+
for (const event of v.events) {
|
|
778
|
+
if (!isSubagentJournalEvent(event)) return false;
|
|
779
|
+
}
|
|
780
|
+
if (typeof v.emittedAt !== "number") return false;
|
|
781
|
+
if (v.sessionId !== void 0 && typeof v.sessionId !== "string") return false;
|
|
782
|
+
return true;
|
|
779
783
|
}
|
|
780
|
-
function
|
|
781
|
-
return
|
|
784
|
+
function isJournalReportAck(v) {
|
|
785
|
+
return v === JOURNAL_REPORT_ACK;
|
|
782
786
|
}
|
|
783
787
|
|
|
788
|
+
// src/extensions/subagent-notify/custom-types.ts
|
|
789
|
+
var WORKFLOW_RESULT_CUSTOM_TYPE = "workflow-result";
|
|
790
|
+
var SUBAGENT_BG_NOTIFY_CUSTOM_TYPE = "subagent-bg-notify";
|
|
791
|
+
var SUBAGENT_DIRECTIVE_CUSTOM_TYPE = "subagent-directive";
|
|
792
|
+
|
|
784
793
|
// src/extensions/subagent-engine/contract.ts
|
|
785
794
|
var SUBAGENTS_ENGINES_FILENAME = "engines.json";
|
|
786
795
|
|
|
@@ -849,11 +858,10 @@ export {
|
|
|
849
858
|
BACKGROUND_TASK_REGISTRY_FILENAME,
|
|
850
859
|
BACKGROUND_TASK_REGISTRY_VERSION,
|
|
851
860
|
BASE_TOOL_ENHANCE_DIRNAME,
|
|
852
|
-
BRIDGE_MARKER,
|
|
853
|
-
BRIDGE_METHODS,
|
|
854
861
|
GUI_WIDGET_MARKER,
|
|
855
862
|
HISTORY_LIMIT,
|
|
856
863
|
INFLIGHT_REPORT_ACK,
|
|
864
|
+
JOURNAL_REPORT_ACK,
|
|
857
865
|
MAX_TERMINAL_REGISTRY_ENTRIES,
|
|
858
866
|
MS_PER_DAY,
|
|
859
867
|
MS_PER_HOUR,
|
|
@@ -874,6 +882,7 @@ export {
|
|
|
874
882
|
SUBAGENT_BG_NOTIFY_CUSTOM_TYPE,
|
|
875
883
|
SUBAGENT_DIRECTIVE_CUSTOM_TYPE,
|
|
876
884
|
SUBAGENT_INFLIGHT_MARKER,
|
|
885
|
+
SUBAGENT_JOURNAL_MARKER,
|
|
877
886
|
TASK_ENTRY_TYPE,
|
|
878
887
|
UI_FORM_MARKER,
|
|
879
888
|
WORKFLOW_RESULT_CUSTOM_TYPE,
|
|
@@ -897,10 +906,6 @@ export {
|
|
|
897
906
|
isActiveBackgroundTaskState,
|
|
898
907
|
isAskUserQuestion,
|
|
899
908
|
isBackgroundTaskRegistryEntry,
|
|
900
|
-
isBridgeErrorResponse,
|
|
901
|
-
isBridgeInterceptResponse,
|
|
902
|
-
isBridgeSyncPayload,
|
|
903
|
-
isBridgeToolExecuteResponse,
|
|
904
909
|
isChannelErrorResult,
|
|
905
910
|
isFormAnswers,
|
|
906
911
|
isFormQuestion,
|
|
@@ -908,6 +913,7 @@ export {
|
|
|
908
913
|
isGuiComponent,
|
|
909
914
|
isGuiRenderResult,
|
|
910
915
|
isInFlightReportAck,
|
|
916
|
+
isJournalReportAck,
|
|
911
917
|
isPlanReviewRequest,
|
|
912
918
|
isPlanReviewResponse,
|
|
913
919
|
isScheduleDraft,
|
|
@@ -922,7 +928,7 @@ export {
|
|
|
922
928
|
isSessionManagerWatchParams,
|
|
923
929
|
isSessionManagerWatchRespondPayload,
|
|
924
930
|
isSubagentInFlightReport,
|
|
925
|
-
|
|
931
|
+
isSubagentJournalReport,
|
|
926
932
|
isTerminalBackgroundTaskState,
|
|
927
933
|
mapReasonToStatus,
|
|
928
934
|
onceCronToDate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/extension-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|