@zhushanwen/extension-protocol 0.15.0 → 0.16.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/dist/index.d.ts +125 -7
- package/dist/index.js +63 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -981,20 +981,25 @@ declare function isFormAnswers(value: unknown): value is FormAnswers;
|
|
|
981
981
|
*/
|
|
982
982
|
declare const SESSION_MANAGER_MARKER = "\0TAIJI_SESSION_MANAGER";
|
|
983
983
|
/**
|
|
984
|
-
*
|
|
984
|
+
* 7 个 action 的运行时集合(与 SessionManagerAction 类型同源——types.ts 从此派生)。
|
|
985
985
|
* event-adapter 用它把 JSON 解析出的 action 字符串收窄为联合类型,
|
|
986
986
|
* 非法值折叠为 '__malformed__' 哨兵(与 handler default 分支同走 cancelled)。
|
|
987
|
+
*
|
|
988
|
+
* 'watch'(notify-once D6):通知债权的纯应答通道——单键 params={notifyId} 寻址、
|
|
989
|
+
* 不传 timeout、fire-and-forget 长挂 select;必须在本集合内,否则 event-adapter
|
|
990
|
+
* 把它折叠成 '__malformed__'(旧 runtime 兼容象限的静默降级形态),watch 永远到不了
|
|
991
|
+
* handler 路由。
|
|
987
992
|
*/
|
|
988
|
-
declare const SESSION_MANAGER_ACTIONS: readonly ["create", "send", "history", "status", "list", "abort"];
|
|
993
|
+
declare const SESSION_MANAGER_ACTIONS: readonly ["create", "send", "history", "status", "list", "abort", "watch"];
|
|
989
994
|
|
|
990
995
|
/**
|
|
991
996
|
* session-manager extension 的类型定义。
|
|
992
997
|
*
|
|
993
|
-
*
|
|
998
|
+
* 7 个 action 的请求 params 和结果类型,供 handler 和 extension 共用。
|
|
994
999
|
* marker 检测后按 action 分发到对应 handler 分支。
|
|
995
1000
|
*/
|
|
996
1001
|
|
|
997
|
-
/** session-manager 支持的
|
|
1002
|
+
/** session-manager 支持的 7 个 action(从 SESSION_MANAGER_ACTIONS 集合派生,值与类型同源) */
|
|
998
1003
|
type SessionManagerAction = (typeof SESSION_MANAGER_ACTIONS)[number];
|
|
999
1004
|
/** 各 action 的请求参数映射 */
|
|
1000
1005
|
interface SessionManagerParams {
|
|
@@ -1004,6 +1009,7 @@ interface SessionManagerParams {
|
|
|
1004
1009
|
status: SessionManagerStatusParams;
|
|
1005
1010
|
list: SessionManagerListParams;
|
|
1006
1011
|
abort: SessionManagerAbortParams;
|
|
1012
|
+
watch: SessionManagerWatchParams;
|
|
1007
1013
|
}
|
|
1008
1014
|
/** create action 参数 */
|
|
1009
1015
|
interface SessionManagerCreateParams {
|
|
@@ -1013,11 +1019,21 @@ interface SessionManagerCreateParams {
|
|
|
1013
1019
|
label?: string;
|
|
1014
1020
|
/** 初始 prompt(可选;提供时 create 后立即注入——设计文档 §5.2 原子性决策) */
|
|
1015
1021
|
prompt?: string;
|
|
1022
|
+
/**
|
|
1023
|
+
* 完成通知债权的幂等键(optional,notify-once D2/D6):extension 侧
|
|
1024
|
+
* `crypto.randomUUID()` 前缀 `sm-` 生成。缺省/畸形 → runtime 不 arm、
|
|
1025
|
+
* `willNotify:false`、零完成通知——兼容判据从版本二分改为字段有无。
|
|
1026
|
+
* 形态判定不在 params 守卫(畸形不构成 params 错误、动作照常执行),
|
|
1027
|
+
* 由 runtime 受理点消费 `isSessionManagerNotifyId` 作 arm 判据。
|
|
1028
|
+
*/
|
|
1029
|
+
notifyId?: string;
|
|
1016
1030
|
}
|
|
1017
1031
|
/** send action 参数 */
|
|
1018
1032
|
interface SessionManagerSendParams {
|
|
1019
1033
|
sessionId: string;
|
|
1020
1034
|
prompt: string;
|
|
1035
|
+
/** 完成通知债权的幂等键(optional,语义同 create:缺省/畸形 → 不 arm + willNotify:false) */
|
|
1036
|
+
notifyId?: string;
|
|
1021
1037
|
}
|
|
1022
1038
|
/** history action 参数 */
|
|
1023
1039
|
interface SessionManagerHistoryParams {
|
|
@@ -1035,9 +1051,20 @@ type SessionManagerListParams = Record<string, never>;
|
|
|
1035
1051
|
interface SessionManagerAbortParams {
|
|
1036
1052
|
sessionId: string;
|
|
1037
1053
|
}
|
|
1038
|
-
/**
|
|
1054
|
+
/**
|
|
1055
|
+
* watch action 参数(notify-once D2/D6):通知债权的纯应答通道,**单键寻址**——
|
|
1056
|
+
* runtime 按 `(调用方 parentSid, notifyId)` 反查 claim,parentSid 取自调用方连接身份、
|
|
1057
|
+
* **协议面不定义不携带**(可推导字段免传,多余字段被守卫拒绝)。不传 timeout、
|
|
1058
|
+
* fire-and-forget 长挂 select;每 claim 单 watch 槽(新覆盖旧,runtime 只 respond 最新)。
|
|
1059
|
+
*/
|
|
1060
|
+
interface SessionManagerWatchParams {
|
|
1061
|
+
/** 目标 claim/lifetime 的幂等键(`sm-` 前缀 UUID,形态自检见 isSessionManagerNotifyId) */
|
|
1062
|
+
notifyId: string;
|
|
1063
|
+
}
|
|
1064
|
+
declare function isSessionManagerNotifyId(v: unknown): v is string;
|
|
1065
|
+
/** create:字段可选 string + optional notifyId(类型面,sm- 形态判定归 arm 判据) */
|
|
1039
1066
|
declare function isSessionManagerCreateParams(v: unknown): v is SessionManagerCreateParams;
|
|
1040
|
-
/** send:sessionId + prompt
|
|
1067
|
+
/** send:sessionId + prompt 必填,notifyId optional(类型面校验同 create) */
|
|
1041
1068
|
declare function isSessionManagerSendParams(v: unknown): v is SessionManagerSendParams;
|
|
1042
1069
|
/** history:sessionId 必填、tailTurns 可选 number */
|
|
1043
1070
|
declare function isSessionManagerHistoryParams(v: unknown): v is SessionManagerHistoryParams;
|
|
@@ -1046,11 +1073,31 @@ declare function isSessionManagerStatusParams(v: unknown): v is SessionManagerSt
|
|
|
1046
1073
|
declare function isSessionManagerAbortParams(v: unknown): v is SessionManagerAbortParams;
|
|
1047
1074
|
/** list:无参数(过滤由 handler 固化,params 不携带任何过滤字段) */
|
|
1048
1075
|
declare function isSessionManagerListParams(v: unknown): v is SessionManagerListParams;
|
|
1076
|
+
/**
|
|
1077
|
+
* watch:**封闭单键** `{notifyId}` 守卫(notify-once D2 形态入站自检)——
|
|
1078
|
+
* 空载荷 / 缺字段 / 夹带任何额外字段(如 parentSid:归属由 runtime 取连接身份,
|
|
1079
|
+
* 协议面不定义)/ notifyId 非 string / 形态不符(缺 `sm-` 前缀、非 UUID 体、超长)
|
|
1080
|
+
* → false → handler dispatch 抛错走 respond({error}) 错误闭环(error envelope)。
|
|
1081
|
+
* 形态函数与 lifetimeNotifyId 同一实现(防自检拒掉 runtime 生成的 lifetime watch)。
|
|
1082
|
+
*/
|
|
1083
|
+
declare function isSessionManagerWatchParams(v: unknown): v is SessionManagerWatchParams;
|
|
1049
1084
|
/** create 结果 */
|
|
1050
1085
|
interface SessionManagerCreateResult {
|
|
1051
1086
|
sessionId: string;
|
|
1052
1087
|
status: 'created';
|
|
1053
1088
|
modelId?: string;
|
|
1089
|
+
/**
|
|
1090
|
+
* 完成通知债权是否已 arm(notify-once D6,LLM 契约面显式化):create 无 prompt /
|
|
1091
|
+
* notifyId 缺省或畸形 → false(零完成通知);true 时首次完成恰回一条通知。
|
|
1092
|
+
* 注意与 lifetimeNotifyId 正交——后者恒存在(死亡通知与债权无关)。
|
|
1093
|
+
*/
|
|
1094
|
+
willNotify: boolean;
|
|
1095
|
+
/**
|
|
1096
|
+
* runtime 在 handleCreate 自动 arm 的 lifetime(死亡)通知幂等键(notify-once D2/D5):
|
|
1097
|
+
* create 成恒返回、`sm-` 同形态同校验;与 params.notifyId(claim 键)双键独立,
|
|
1098
|
+
* 杜绝撞幂等键。extension 据此注册 pending(register id = 本键)并开终身 watch。
|
|
1099
|
+
*/
|
|
1100
|
+
lifetimeNotifyId: string;
|
|
1054
1101
|
}
|
|
1055
1102
|
/**
|
|
1056
1103
|
* send 结果(sd-u5 起):消息已入队/已投递——目标 busy 时在下一 turn 边界注入。
|
|
@@ -1058,6 +1105,8 @@ interface SessionManagerCreateResult {
|
|
|
1058
1105
|
*/
|
|
1059
1106
|
interface SessionManagerSendResult {
|
|
1060
1107
|
queued: true;
|
|
1108
|
+
/** 完成通知债权是否已 arm(notify-once D6):notifyId 缺省/畸形 → false(零完成通知) */
|
|
1109
|
+
willNotify: boolean;
|
|
1061
1110
|
}
|
|
1062
1111
|
/** history 结果 */
|
|
1063
1112
|
interface SessionManagerHistoryResult {
|
|
@@ -1068,10 +1117,18 @@ interface SessionManagerHistoryResult {
|
|
|
1068
1117
|
interface SessionManagerStatusResult {
|
|
1069
1118
|
status: string;
|
|
1070
1119
|
modelId?: string;
|
|
1120
|
+
/**
|
|
1121
|
+
* 「未送达结果」事实计数(notify-once D6/D7,非警示布尔):orphaned 与
|
|
1122
|
+
* fulfilled-no-watch(TTL 清扫转入)两态的在册总数。天然无清除语义问题、无
|
|
1123
|
+
* cry-wolf;持久化二期补投时递减自洽。ownership 校验同其余按 sessionId 寻址的 action。
|
|
1124
|
+
*/
|
|
1125
|
+
undeliveredResults: number;
|
|
1071
1126
|
}
|
|
1072
1127
|
/** list 结果 */
|
|
1073
1128
|
interface SessionManagerListResult {
|
|
1074
1129
|
sessions: SessionManagerSessionSummary[];
|
|
1130
|
+
/** 「未送达结果」事实计数(语义同 status:发起方名下全量在册数) */
|
|
1131
|
+
undeliveredResults: number;
|
|
1075
1132
|
}
|
|
1076
1133
|
/** list 返回的 session 摘要(精简版) */
|
|
1077
1134
|
interface SessionManagerSessionSummary {
|
|
@@ -1086,6 +1143,60 @@ interface SessionManagerSessionSummary {
|
|
|
1086
1143
|
interface SessionManagerAbortResult {
|
|
1087
1144
|
success: boolean;
|
|
1088
1145
|
}
|
|
1146
|
+
/**
|
|
1147
|
+
* watch 应答 reason 词表(封闭 7 值)——与 pending-entries `mapReasonToStatus` 的
|
|
1148
|
+
* 4 个新 case 同词形(stopped→aborted、exited/deleted/orphaned→cancelled),
|
|
1149
|
+
* **不扩共享词表**:精确状态由通知正文与 `get_session_status` 承载。
|
|
1150
|
+
*/
|
|
1151
|
+
type SessionManagerWatchReason =
|
|
1152
|
+
/** settle 兑现 / catch-up 快照(outcome 映射 completed/failed/stopped) */
|
|
1153
|
+
'completed' | 'failed' | 'stopped'
|
|
1154
|
+
/** 终局死亡(delete/forceQuit/不可恢复 crash;respawn 链静默不发声) */
|
|
1155
|
+
| 'exited' | 'deleted'
|
|
1156
|
+
/** 静默折叠(主 abort / 二次校验归属失效 / fail-closed 查无 claim / 旧 runtime 兼容象限) */
|
|
1157
|
+
| 'cancelled'
|
|
1158
|
+
/** orphan 吸收态(父 pi 死亡批量转移 / TTL 清扫 / respond 失败) */
|
|
1159
|
+
| 'orphaned';
|
|
1160
|
+
/**
|
|
1161
|
+
* watch respond payload(notify-once D6,全 additive)——extension 侧 watch 响应的
|
|
1162
|
+
* 唯一权威形状。旧 runtime 象限 respond `null`(不识 watch action),由 extension
|
|
1163
|
+
* 折叠 cancelled——null 不在本类型内,消费方须同时处理。
|
|
1164
|
+
*/
|
|
1165
|
+
interface SessionManagerWatchRespondPayload {
|
|
1166
|
+
/** 分拣键 (sessionId, reason) 的 reason 腿(D3 两层模型:cancelled/orphaned → 仅
|
|
1167
|
+
* unregister;exited/deleted → 死亡新闻槽;completed/failed/stopped → 结果新闻) */
|
|
1168
|
+
reason: SessionManagerWatchReason;
|
|
1169
|
+
/**
|
|
1170
|
+
* claim 所属子会话 id 回带——D3 槽键 (sessionId, deathSeq) / 分拣键 (sessionId,
|
|
1171
|
+
* reason) / D9 文案 `<sid>` 的唯一数据源(收口腿闭包仅有父 sid,缺此字段则同父
|
|
1172
|
+
* 多子 deathSeq 跨 child 碰撞)。claim 命中路径(settle/death/orphaned/二次校验)
|
|
1173
|
+
* 恒带;fail-closed(查无 claim)无 claim 可回带 → 缺席——该路径 reason 恒
|
|
1174
|
+
* 'cancelled',extension 静默收口不消费 sessionId。
|
|
1175
|
+
*/
|
|
1176
|
+
sessionId?: string;
|
|
1177
|
+
/** death 批身份(per session 递增;同一死亡事件循环 respond 时 runtime 直供) */
|
|
1178
|
+
deathSeq?: number;
|
|
1179
|
+
/** settle 批身份(per session 递增;批身份 = settleSeq/deathSeq——同批身份才合一条 record) */
|
|
1180
|
+
settleSeq?: number;
|
|
1181
|
+
/** 本批兑现总笔数(同批每条应答携带同值);death 侧 = 同 deathSeq 的 claim 数(D3 合批口径,runtime 直供,死亡/结果新闻正文消费 fulfills N) */
|
|
1182
|
+
fulfillsN?: number;
|
|
1183
|
+
/** death 应答携带:exit 腿诊断数据通路复刻(400 字截尾沿用现值),extension 文案构造消费 */
|
|
1184
|
+
exitCode?: number | null;
|
|
1185
|
+
stderrTail?: string;
|
|
1186
|
+
/**
|
|
1187
|
+
* 会话文件绝对路径(additive optional,notify-once D9):通知正文 `Full transcript:`
|
|
1188
|
+
* 指针行的唯一数据源(`~/.taiji/agent/sessions/.../<sid>.jsonl` 形态)。死亡/settle
|
|
1189
|
+
* 应答携带(正文构造消费);fail-closed 等无 claim 应答不携(该路径静默无文案)。
|
|
1190
|
+
*/
|
|
1191
|
+
sessionFilePath?: string;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* watch respond payload 运行时守卫(extension 读侧不信任外部格式——AGENTS 关键规则 5):
|
|
1195
|
+
* null(旧 runtime 象限)/ 非 record / reason 缺失、非 string 或词表外 / 可选 meta
|
|
1196
|
+
* 类型不符 → false(可选字段缺席一律放行——含 sessionFilePath)。消费方对 false 与
|
|
1197
|
+
* null 同路折叠静默 unregister(fail-safe:未知 reason 不得落 default 误标)。
|
|
1198
|
+
*/
|
|
1199
|
+
declare function isSessionManagerWatchRespondPayload(v: unknown): v is SessionManagerWatchRespondPayload;
|
|
1089
1200
|
/** 错误响应形状(send 同步失败时 = { error, hint };create 已成功时另附 sessionId)。
|
|
1090
1201
|
* D8 单源化:交集扩展 alias——error/hint 单源于 core 的 ChannelErrorResult,sessionId
|
|
1091
1202
|
* 为本协议独有扩展(runtime session-manager-handler 活构造:create 已成功但后续步骤
|
|
@@ -1382,6 +1493,13 @@ declare function collectActivePendingIds(entries: unknown[], opts?: CollectPendi
|
|
|
1382
1493
|
* reopened → completed)——防新词落 default 被记为 completed 的误标(cancelled 同族
|
|
1383
1494
|
* 事故先例:新枚举值漏映射静默落兜底)。
|
|
1384
1495
|
*
|
|
1496
|
+
* [notify-once D3 族映射] session-manager watch 应答的 4 个新 reason 同族接入:
|
|
1497
|
+
* stopped→aborted(用户 UI 掐断含债权轮)、exited/deleted/orphaned→cancelled
|
|
1498
|
+
* (终局死亡/删除/orphan 吸收态)。**不扩 MappedPendingStatus/PendingStatus 词表**——
|
|
1499
|
+
* 四个新 reason 全仓零读方按 status 分流(countActiveFromEntries 只用 register−unregister
|
|
1500
|
+
* 差集、notify-summary outcome 读 details 不读 entry.status),精确状态由通知正文与
|
|
1501
|
+
* get_session_status 承载,高于 G2 感知线。
|
|
1502
|
+
*
|
|
1385
1503
|
* 返回值 MappedPendingStatus(本文件封闭字面量联合):PendingStatus 枚举留在
|
|
1386
1504
|
* pending-notifications(本包不引 extension 侧类型),本联合是其终态子集——消费方
|
|
1387
1505
|
* 免 as 收窄直接赋值。
|
|
@@ -1392,4 +1510,4 @@ declare function collectActivePendingIds(entries: unknown[], opts?: CollectPendi
|
|
|
1392
1510
|
type MappedPendingStatus = 'completed' | 'failed' | 'cancelled' | 'expired' | 'time_limited' | 'aborted';
|
|
1393
1511
|
declare function mapReasonToStatus(reason: string): MappedPendingStatus;
|
|
1394
1512
|
|
|
1395
|
-
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_REVIEW_MARKER, PROTOCOL_VERSION, type PendingEntriesScan, type PlanDocMeta, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, 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 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, extractGui, firstContentText, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isBridgeErrorResponse, isBridgeInterceptResponse, isBridgeSyncPayload, isBridgeToolExecuteResponse, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerCreateParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerSendParams, isSessionManagerStatusParams, isSubagentInFlightReport, isSyncedTool, mapReasonToStatus, onceCronToDate, replayFoldEntries, scanPendingEntries, setWidgetDual, snapshotToTask, uiFormInteract, validateWidgetIconPaths };
|
|
1513
|
+
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_REVIEW_MARKER, PROTOCOL_VERSION, type PendingEntriesScan, type PlanDocMeta, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, 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, extractGui, firstContentText, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isBridgeErrorResponse, isBridgeInterceptResponse, isBridgeSyncPayload, isBridgeToolExecuteResponse, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerCreateParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerNotifyId, isSessionManagerSendParams, isSessionManagerStatusParams, isSessionManagerWatchParams, isSessionManagerWatchRespondPayload, isSubagentInFlightReport, isSyncedTool, mapReasonToStatus, onceCronToDate, replayFoldEntries, scanPendingEntries, setWidgetDual, snapshotToTask, uiFormInteract, validateWidgetIconPaths };
|
package/dist/index.js
CHANGED
|
@@ -517,14 +517,27 @@ function isRecord(v) {
|
|
|
517
517
|
function isOptionalString2(v) {
|
|
518
518
|
return v === void 0 || typeof v === "string";
|
|
519
519
|
}
|
|
520
|
+
function isOptionalNumber(v) {
|
|
521
|
+
return v === void 0 || typeof v === "number";
|
|
522
|
+
}
|
|
523
|
+
function isOptionalNumberOrNull(v) {
|
|
524
|
+
return v === void 0 || v === null || typeof v === "number";
|
|
525
|
+
}
|
|
526
|
+
var NOTIFY_ID_PATTERN = /^sm-[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
527
|
+
function isSessionManagerNotifyId(v) {
|
|
528
|
+
return typeof v === "string" && NOTIFY_ID_PATTERN.test(v);
|
|
529
|
+
}
|
|
530
|
+
function isOptionalNotifyId(v) {
|
|
531
|
+
return v === void 0 || typeof v === "string";
|
|
532
|
+
}
|
|
520
533
|
function isSessionIdParams(v) {
|
|
521
534
|
return isRecord(v) && typeof v.sessionId === "string";
|
|
522
535
|
}
|
|
523
536
|
function isSessionManagerCreateParams(v) {
|
|
524
|
-
return isRecord(v) && isOptionalString2(v.cwd) && isOptionalString2(v.label) && isOptionalString2(v.prompt);
|
|
537
|
+
return isRecord(v) && isOptionalString2(v.cwd) && isOptionalString2(v.label) && isOptionalString2(v.prompt) && isOptionalNotifyId(v.notifyId);
|
|
525
538
|
}
|
|
526
539
|
function isSessionManagerSendParams(v) {
|
|
527
|
-
return isRecord(v) && typeof v.sessionId === "string" && typeof v.prompt === "string";
|
|
540
|
+
return isRecord(v) && typeof v.sessionId === "string" && typeof v.prompt === "string" && isOptionalNotifyId(v.notifyId);
|
|
528
541
|
}
|
|
529
542
|
function isSessionManagerHistoryParams(v) {
|
|
530
543
|
return isRecord(v) && typeof v.sessionId === "string" && (v.tailTurns === void 0 || typeof v.tailTurns === "number");
|
|
@@ -538,10 +551,36 @@ function isSessionManagerAbortParams(v) {
|
|
|
538
551
|
function isSessionManagerListParams(v) {
|
|
539
552
|
return isRecord(v);
|
|
540
553
|
}
|
|
554
|
+
function isSessionManagerWatchParams(v) {
|
|
555
|
+
if (!isRecord(v)) return false;
|
|
556
|
+
const keys = Object.keys(v);
|
|
557
|
+
return keys.length === 1 && keys[0] === "notifyId" && isSessionManagerNotifyId(v.notifyId);
|
|
558
|
+
}
|
|
559
|
+
var WATCH_REASON_SET = /* @__PURE__ */ new Set([
|
|
560
|
+
"completed",
|
|
561
|
+
"failed",
|
|
562
|
+
"stopped",
|
|
563
|
+
"exited",
|
|
564
|
+
"deleted",
|
|
565
|
+
"cancelled",
|
|
566
|
+
"orphaned"
|
|
567
|
+
]);
|
|
568
|
+
function isSessionManagerWatchRespondPayload(v) {
|
|
569
|
+
if (!isRecord(v)) return false;
|
|
570
|
+
if (typeof v.reason !== "string" || !WATCH_REASON_SET.has(v.reason)) return false;
|
|
571
|
+
if (!isOptionalString2(v.sessionId)) return false;
|
|
572
|
+
if (!isOptionalNumber(v.deathSeq)) return false;
|
|
573
|
+
if (!isOptionalNumber(v.settleSeq)) return false;
|
|
574
|
+
if (!isOptionalNumber(v.fulfillsN)) return false;
|
|
575
|
+
if (!isOptionalNumberOrNull(v.exitCode)) return false;
|
|
576
|
+
if (!isOptionalString2(v.stderrTail)) return false;
|
|
577
|
+
if (!isOptionalString2(v.sessionFilePath)) return false;
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
541
580
|
|
|
542
581
|
// src/extensions/session-manager/marker.ts
|
|
543
582
|
var SESSION_MANAGER_MARKER = "\0TAIJI_SESSION_MANAGER";
|
|
544
|
-
var SESSION_MANAGER_ACTIONS = ["create", "send", "history", "status", "list", "abort"];
|
|
583
|
+
var SESSION_MANAGER_ACTIONS = ["create", "send", "history", "status", "list", "abort", "watch"];
|
|
545
584
|
|
|
546
585
|
// src/extensions/subagent-inflight/marker.ts
|
|
547
586
|
var SUBAGENT_INFLIGHT_MARKER = "\0TAIJI_SUBAGENT_INFLIGHT";
|
|
@@ -633,31 +672,25 @@ function collectActivePendingIds(entries, opts) {
|
|
|
633
672
|
}
|
|
634
673
|
return ids;
|
|
635
674
|
}
|
|
675
|
+
var REASON_STATUS_MAP = {
|
|
676
|
+
completed: "completed",
|
|
677
|
+
failed: "failed",
|
|
678
|
+
cancelled: "cancelled",
|
|
679
|
+
expired: "expired",
|
|
680
|
+
time_limited: "time_limited",
|
|
681
|
+
budget_limited: "failed",
|
|
682
|
+
aborted: "aborted",
|
|
683
|
+
interrupted: "aborted",
|
|
684
|
+
"interrupted-by-restart": "aborted",
|
|
685
|
+
"interrupted-by-parent": "aborted",
|
|
686
|
+
reopened: "completed",
|
|
687
|
+
stopped: "aborted",
|
|
688
|
+
exited: "cancelled",
|
|
689
|
+
deleted: "cancelled",
|
|
690
|
+
orphaned: "cancelled"
|
|
691
|
+
};
|
|
636
692
|
function mapReasonToStatus(reason) {
|
|
637
|
-
|
|
638
|
-
case "completed":
|
|
639
|
-
return "completed";
|
|
640
|
-
case "failed":
|
|
641
|
-
return "failed";
|
|
642
|
-
case "cancelled":
|
|
643
|
-
return "cancelled";
|
|
644
|
-
case "expired":
|
|
645
|
-
return "expired";
|
|
646
|
-
case "time_limited":
|
|
647
|
-
return "time_limited";
|
|
648
|
-
case "budget_limited":
|
|
649
|
-
return "failed";
|
|
650
|
-
case "aborted":
|
|
651
|
-
return "aborted";
|
|
652
|
-
case "interrupted":
|
|
653
|
-
case "interrupted-by-restart":
|
|
654
|
-
case "interrupted-by-parent":
|
|
655
|
-
return "aborted";
|
|
656
|
-
case "reopened":
|
|
657
|
-
return "completed";
|
|
658
|
-
default:
|
|
659
|
-
return "completed";
|
|
660
|
-
}
|
|
693
|
+
return REASON_STATUS_MAP[reason] ?? "completed";
|
|
661
694
|
}
|
|
662
695
|
export {
|
|
663
696
|
ASK_USER_MARKER,
|
|
@@ -725,8 +758,11 @@ export {
|
|
|
725
758
|
isSessionManagerCreateParams,
|
|
726
759
|
isSessionManagerHistoryParams,
|
|
727
760
|
isSessionManagerListParams,
|
|
761
|
+
isSessionManagerNotifyId,
|
|
728
762
|
isSessionManagerSendParams,
|
|
729
763
|
isSessionManagerStatusParams,
|
|
764
|
+
isSessionManagerWatchParams,
|
|
765
|
+
isSessionManagerWatchRespondPayload,
|
|
730
766
|
isSubagentInFlightReport,
|
|
731
767
|
isSyncedTool,
|
|
732
768
|
isTerminalBackgroundTaskState,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/extension-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|