@zhushanwen/extension-protocol 0.23.0 → 0.25.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 +119 -16
- package/dist/index.js +100 -17
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -100,6 +100,23 @@ interface GuiComponentProps {
|
|
|
100
100
|
args?: Record<string, string | number | boolean>;
|
|
101
101
|
}[];
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* 文本输入——GuiComponent 协议输入原语(provider-plugin-access D8:粘贴 PAT、
|
|
105
|
+
* 填回调地址)。值变更即经 plugin.uiEvent 回传({ viewId, componentId: id,
|
|
106
|
+
* event, value },插件侧始终持有最新值);确认动作复用 action-bar 按钮点击——
|
|
107
|
+
* 「输入 + 确认」两者组合完成,无表单聚合原语(single-select / form 砍除)。
|
|
108
|
+
* 宿主只做形状校验(value 标量、深度 ≤ 2),业务校验归插件。渲染端缺
|
|
109
|
+
* uiEvent 出口时输入框禁用 + warn(TabBar 降级出声范式)。
|
|
110
|
+
*/
|
|
111
|
+
'text-input': {
|
|
112
|
+
/** 组件 id(uiEvent 回传的 componentId,插件定位输入项的键) */
|
|
113
|
+
id: string;
|
|
114
|
+
label?: string;
|
|
115
|
+
placeholder?: string;
|
|
116
|
+
/** 当前值(插件推树携带,宿主受控渲染——单值权威在插件侧) */
|
|
117
|
+
value?: string;
|
|
118
|
+
multiline?: boolean;
|
|
119
|
+
};
|
|
103
120
|
/** 自定义组件——逃生口(仅限内置 extension 编译期注册) */
|
|
104
121
|
'custom': {
|
|
105
122
|
component: string;
|
|
@@ -242,6 +259,18 @@ declare const GUI_WIDGET_MARKER = "\0TAIJI_GUI_WIDGET:";
|
|
|
242
259
|
* 与 GUI_WIDGET_MARKER / ASK_USER_MARKER 同族(select 通道 marker)。
|
|
243
260
|
*/
|
|
244
261
|
declare const PLAN_REVIEW_MARKER = "\0TAIJI_PLAN_REVIEW:";
|
|
262
|
+
/**
|
|
263
|
+
* permission 审批 select 的 title 首行判定键。pi-permission 扩展的 RPC 审批 select
|
|
264
|
+
* (extensions/universal/permission approval.ts buildApprovalFieldSet 单点构造,
|
|
265
|
+
* title 可多行、首行恒为此串)与 runtime event-adapter 判定(isPermissionApprovalSelect
|
|
266
|
+
* 按首行精确匹配,命中后广播帧附加 permission: true 键)双端共用本常量——
|
|
267
|
+
* 与 PLAN_REVIEW_MARKER 的 planReview: true 键同构分流(select 通道标记)。
|
|
268
|
+
*
|
|
269
|
+
* 与上方 NUL marker 家族的形态区别:这是用户可见文案(审批对话框标题),
|
|
270
|
+
* 无控制符前缀;单源价值同族——双端各自手抄字面量时,生产端改文案 → 消费端
|
|
271
|
+
* 静默不命中 → 侧栏 permission 等待可见性失效,零报错信号。
|
|
272
|
+
*/
|
|
273
|
+
declare const PERMISSION_APPROVAL_TITLE = "[pi-permission] Approval required";
|
|
245
274
|
|
|
246
275
|
/**
|
|
247
276
|
* helpers 需要的 ctx 最小接口。
|
|
@@ -388,6 +417,22 @@ declare function firstContentText(result: {
|
|
|
388
417
|
text?: string;
|
|
389
418
|
}>;
|
|
390
419
|
}): string;
|
|
420
|
+
/**
|
|
421
|
+
* 从 pi toolResult(unknown 入参)安全读取 details.summary(一行摘要读侧单点)。
|
|
422
|
+
* result / details 非对象形态、summary 非字符串或空串一律 undefined——调用方以
|
|
423
|
+
* `?? 回退文本` 表达降级。读侧检查单点化:extension 的 renderResult 不再各自
|
|
424
|
+
* 手抄取值函数(历史 8 处手抄 + 2 处 as 断言已收编)。
|
|
425
|
+
*/
|
|
426
|
+
declare function readDetailsSummary(result: unknown): string | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* pi toolResult 通用形状提取的 unknown 检查式版(firstContentText 的宽入参形态):
|
|
429
|
+
* content 数组缺失或 content[0] 非 text 块时兜底空串。renderResult 入参是 unknown
|
|
430
|
+
* (容错历史持久化 entry),无法直接满足 firstContentText 的强类型入参——本函数
|
|
431
|
+
* 内化取值检查,调用方不再各自包装 contentText。
|
|
432
|
+
*/
|
|
433
|
+
declare function resultContentText(result: unknown): string;
|
|
434
|
+
/** 文本首行(按首个换行切分;无换行返回原文)。折叠态一行摘要形态的共用切分。 */
|
|
435
|
+
declare function firstLine(text: string): string;
|
|
391
436
|
|
|
392
437
|
/**
|
|
393
438
|
* select+marker 通道 RPC 原语(D8)。
|
|
@@ -1491,7 +1536,8 @@ type SessionManagerErrorResult = ChannelErrorResult & {
|
|
|
1491
1536
|
interface SubagentInFlightReport {
|
|
1492
1537
|
/**
|
|
1493
1538
|
* 绝对计数:该 pi 进程当前「非 idle 句柄数」(hasLiveProcessHandle && !hasIdleTimer
|
|
1494
|
-
*
|
|
1539
|
+
* 双谓词过滤;原「与 notify-host.ts hasRunningBackground 同源」的表述随该谓词
|
|
1540
|
+
* 退役删除——subagent-observability §3.3.7③)。非增量——消费方整帧
|
|
1495
1541
|
* 覆盖镜像,不做加减。
|
|
1496
1542
|
*/
|
|
1497
1543
|
inFlight: number;
|
|
@@ -1900,6 +1946,13 @@ interface ReviewReport {
|
|
|
1900
1946
|
round: number;
|
|
1901
1947
|
maxRounds: number;
|
|
1902
1948
|
entries: ReviewEntry[];
|
|
1949
|
+
/**
|
|
1950
|
+
* 最近一次报告写回(review-append)的轮次。零发现轮的完成事实:空 entries 也是
|
|
1951
|
+
* 审查结论,条目存在性判不了「本轮 run 已完成」——轮次推进与 maxRounds 预算的
|
|
1952
|
+
* 完成判定以本字段为准(有条目轮两条判据皆成立)。optional = 尚无任何写回 /
|
|
1953
|
+
* 旧快照兼容(缺省按无写回处理,不阻碍既有数据重放)。
|
|
1954
|
+
*/
|
|
1955
|
+
lastRunRound?: number;
|
|
1903
1956
|
/** 非 converged 终态的停回说明(聚合 2 不变量 2:max-rounds / escalated / stuck 必附)。 */
|
|
1904
1957
|
stopNote?: string;
|
|
1905
1958
|
/** 恢复动作建议(停回说明的配套:升级裁决后可再发起)。 */
|
|
@@ -2425,6 +2478,14 @@ interface PendingEntriesScan {
|
|
|
2425
2478
|
* 末次合法值(后条非法不抹除前条合法值)。
|
|
2426
2479
|
*/
|
|
2427
2480
|
unregisterStatuses: Map<string, MappedPendingStatus>;
|
|
2481
|
+
/**
|
|
2482
|
+
* 注销条目结清视图(subagent-observability §3.3.6 债权结清新权威通道):id →
|
|
2483
|
+
* 结清枚举(封闭五值 + 词表外解析缺省 unknown)。读注销 entry 的 reason 事实经
|
|
2484
|
+
* resolveSettlementReason 解析(不经 mapReasonToStatus 旧映射);string reason
|
|
2485
|
+
* 一律解析(fail-visible 值照常入视图),非 string reason 视为畸形不入视图;
|
|
2486
|
+
* 同 id 多条注销取末次带 string reason 的值(后条畸形不抹除前值)。
|
|
2487
|
+
*/
|
|
2488
|
+
unregisterSettlements: Map<string, ResolvedSettlementReason>;
|
|
2428
2489
|
}
|
|
2429
2490
|
/**
|
|
2430
2491
|
* 单趟扫描 entries 按 customType 分流(容错对齐 pending 侧 S-10:null/非对象
|
|
@@ -2436,16 +2497,18 @@ interface PendingEntriesScan {
|
|
|
2436
2497
|
* 收敛——消费方禁止本地复制映射段)。
|
|
2437
2498
|
*/
|
|
2438
2499
|
declare function scanPendingEntries(entries: readonly unknown[]): PendingEntriesScan;
|
|
2439
|
-
/** scanPendingFields 的结果:collect 链路消费的字段映射投影(首见 type + 注销 status
|
|
2500
|
+
/** scanPendingFields 的结果:collect 链路消费的字段映射投影(首见 type + 注销 status 视图 + 注销结清视图)。 */
|
|
2440
2501
|
interface PendingFieldsScan {
|
|
2441
2502
|
registerTypes: Map<string, string>;
|
|
2442
2503
|
unregisterStatuses: Map<string, MappedPendingStatus>;
|
|
2504
|
+
/** 注销结清视图(§3.3.6 权威通道,见 {@link PendingEntriesScan.unregisterSettlements})。 */
|
|
2505
|
+
unregisterSettlements: Map<string, ResolvedSettlementReason>;
|
|
2443
2506
|
}
|
|
2444
2507
|
/**
|
|
2445
2508
|
* collect 终局回填的字段视图(MF-2-1 单点入口):scanPendingEntries 产物中
|
|
2446
|
-
* register 首见 type + 全部注销 status 的 MAPPED
|
|
2447
|
-
* 快照基线 / pending-notifications consume
|
|
2448
|
-
*
|
|
2509
|
+
* register 首见 type + 全部注销 status 的 MAPPED 成员投影 + 注销 reason 事实的
|
|
2510
|
+
* 结清解析投影。消费方(delivery-port 快照基线 / pending-notifications consume 后
|
|
2511
|
+
* 回填)按 id 查表补 type/outcome,查无保持 undefined(诚实缺省,不虚构终态)。
|
|
2449
2512
|
*/
|
|
2450
2513
|
declare function scanPendingFields(entries: readonly unknown[]): PendingFieldsScan;
|
|
2451
2514
|
/**
|
|
@@ -2475,19 +2538,27 @@ declare function collectActivePendingIds(entries: unknown[], opts?: CollectPendi
|
|
|
2475
2538
|
*
|
|
2476
2539
|
* [notify-once D3 族映射] session-manager watch 应答的 4 个新 reason 同族接入:
|
|
2477
2540
|
* stopped→aborted(用户 UI 掐断含债权轮)、exited/deleted/orphaned→cancelled
|
|
2478
|
-
* (终局死亡/删除/orphan
|
|
2479
|
-
*
|
|
2480
|
-
*
|
|
2481
|
-
*
|
|
2541
|
+
* (终局死亡/删除/orphan 吸收态)。
|
|
2542
|
+
*
|
|
2543
|
+
* [subagent-observability §3.3.6/§3.3.11④] 本通道保留为**历史 reason 解析兼容通道**
|
|
2544
|
+
* (解析词表纪律:旧值保留解析);债权结清的新权威通道 = resolveSettlementReason
|
|
2545
|
+
* (下方 SettlementReason 封闭五值),双通道以新写入方为权威。缺省方向废除
|
|
2546
|
+
* fail-open:词表外 reason → unknown(不再产假成功)。
|
|
2482
2547
|
*
|
|
2483
2548
|
* 返回值 MappedPendingStatus(本文件封闭字面量联合):PendingStatus 枚举留在
|
|
2484
|
-
* pending-notifications(本包不引 extension
|
|
2485
|
-
*
|
|
2549
|
+
* pending-notifications(本包不引 extension 侧类型),本联合是其终态子集+解析缺省
|
|
2550
|
+
* unknown——消费方免 as 收窄直接赋值。
|
|
2486
2551
|
*/
|
|
2487
|
-
/**
|
|
2488
|
-
*
|
|
2489
|
-
*
|
|
2490
|
-
|
|
2552
|
+
/**
|
|
2553
|
+
* mapReasonToStatus 的封闭返回值域:pending-notifications PendingStatus 的终态子集
|
|
2554
|
+
* (不含初始态 active)+ 解析缺省 unknown。protocol 不引 extension 侧类型(分层裁决
|
|
2555
|
+
* 不变),以自有字面量联合锁定值域,switch 分支编译期受限。
|
|
2556
|
+
*
|
|
2557
|
+
* [subagent-observability §3.3.6/§3.3.11④ fail-open 废除] 第七成员 unknown = 词表外
|
|
2558
|
+
* reason 的解析缺省(fail-visible——解析词表纪律的缺省方向与旧 fail-open=completed
|
|
2559
|
+
* 相反:不可判读时如实标注,不产假成功)。
|
|
2560
|
+
*/
|
|
2561
|
+
type MappedPendingStatus = 'completed' | 'failed' | 'cancelled' | 'expired' | 'time_limited' | 'aborted' | 'unknown';
|
|
2491
2562
|
declare function mapReasonToStatus(reason: string): MappedPendingStatus;
|
|
2492
2563
|
/**
|
|
2493
2564
|
* MappedPendingStatus 的值集(MF-1-5 词表单源):由 REASON_STATUS_MAP 派生——映射表
|
|
@@ -2496,7 +2567,39 @@ declare function mapReasonToStatus(reason: string): MappedPendingStatus;
|
|
|
2496
2567
|
* import 本常量,禁止本地复制六值 Set(曾两包各持一份本地拷贝注释自认「同步维护」)。
|
|
2497
2568
|
* Set 成员与 MappedPendingStatus 联合的相等性由 pending-entries.test.ts 断言锁定。
|
|
2498
2569
|
* string 元素类型是消费面要求(对任意落盘 status 做成员判定,窄化前的原始值)。
|
|
2570
|
+
*
|
|
2571
|
+
* [subagent-observability §3.3.11④] 值集含解析缺省 unknown(fail-visible)——词表外
|
|
2572
|
+
* 落盘 status 由成员判定放行进入字段视图(不再静默丢弃),消费方按「不可判读」呈现。
|
|
2499
2573
|
*/
|
|
2500
2574
|
declare const MAPPED_PENDING_STATUSES: ReadonlySet<string>;
|
|
2575
|
+
/**
|
|
2576
|
+
* 债权结清词表(封闭五值;值域语义与 subagent-core run-vocabulary ALL_SETTLEMENT_REASONS
|
|
2577
|
+
* 同源——「债权」= pending-notifications 的 collect 挂起债,结清 = 该债以何种事实形态
|
|
2578
|
+
* 兑现或消灭):
|
|
2579
|
+
* completed — 轮正常收尾兑现;
|
|
2580
|
+
* failed — 轮失败结清(含预算/超时轮失败);
|
|
2581
|
+
* cancelled — 轮中止、run 取消、编排性收尾打断(interrupted 族宿主侧打断);
|
|
2582
|
+
* lost — 失联清点(宿主重启代际 + pid 探活事实,§3.3.4 合并清点产物);
|
|
2583
|
+
* no_result — 无果:退出无 settle 无结果、清理扫描无事实可依、或轮被扩展接管
|
|
2584
|
+
* (细因经轮收条 promptDisposition 披露;与 lost 的边界 = 有无
|
|
2585
|
+
* 「宿主重启」事实)。
|
|
2586
|
+
*
|
|
2587
|
+
* 依赖方向:core → 本包(权威写侧产值在 core run-vocabulary;本包按协议单点纪律
|
|
2588
|
+
* 自持同值字面量,双包字面量一致性由各自枚举完整性测试 + core 侧对账测试锁定)。
|
|
2589
|
+
*/
|
|
2590
|
+
declare const SETTLEMENT_REASONS: readonly ["completed", "failed", "cancelled", "lost", "no_result"];
|
|
2591
|
+
/** 债权结清词表(封闭五值;值域语义见 {@link SETTLEMENT_REASONS})。 */
|
|
2592
|
+
type SettlementReason = (typeof SETTLEMENT_REASONS)[number];
|
|
2593
|
+
/**
|
|
2594
|
+
* 结清解析产出类型:词表外 reason 解析缺省 `unknown`(fail-visible——不可判读时
|
|
2595
|
+
* 如实标注,不产假成功;缺省方向与旧 fail-open=completed 相反)。
|
|
2596
|
+
*/
|
|
2597
|
+
type ResolvedSettlementReason = SettlementReason | 'unknown';
|
|
2598
|
+
/**
|
|
2599
|
+
* pending 注销 reason → 债权结清枚举解析(新权威通道;双通道以新写入方为权威——
|
|
2600
|
+
* 新写入方直接产 SettlementReason 字面量,本函数服务历史 reason 与防御性解析)。
|
|
2601
|
+
* mapReasonToStatus(六值+unknown 历史通道)保留并行,两表键集一致性由测试锁定。
|
|
2602
|
+
*/
|
|
2603
|
+
declare function resolveSettlementReason(reason: string): ResolvedSettlementReason;
|
|
2501
2604
|
|
|
2502
|
-
export { ACTION_EVENT_MAP, ASK_USER_MARKER, type ArgumentMateriality, type ArgumentPolarity, type AskUserAnswers, type AskUserOption, type AskUserQuestion, CANVAS_ACTIONS, CANVAS_ACTOR_MATRIX, CANVAS_ERROR_CODES, CANVAS_ERROR_RECOVERY, CANVAS_EVENT_TYPES, CANVAS_MARKER, CANVAS_MARKER_ACTIONS, CANVAS_TOOL_NAMES, type CanvasAction, type CanvasActionParams, type CanvasActor, type CanvasComment, type CanvasCommentParams, type CanvasCommentRespondParams, type CanvasConvergeCheckParams, type CanvasCreateParams, type CanvasDecideDirectionParams, type CanvasDirectionDecision, type CanvasDispatchParams, type CanvasEdge, type CanvasEdgeType, type CanvasEnterParams, type CanvasError, type CanvasErrorCode, type CanvasEventType, type CanvasExportParams, type CanvasExportTarget, type CanvasGrowItem, type CanvasGrowParams, type CanvasListEntry, type CanvasListParams, type CanvasListReply, type CanvasMarkerAction, type CanvasMarkerParams, type CanvasMarkerRequest, type CanvasMutateReply, type CanvasMutateRequest, type CanvasNode, type CanvasNodeLifecycle, type CanvasNodeType, type CanvasPatchParams, type CanvasReadParams, type CanvasReadReply, type CanvasReviewAppendParams, type CanvasReviewEntryInput, type CanvasReviewRequestParams, type CanvasReviewResolveParams, type CanvasSelectParams, type CanvasState, type CanvasToolName, type CanvasTransitionParams, 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, MAPPED_PENDING_STATUSES, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, type MappedPendingStatus, type MarkerRpcOptions, type MarkerRpcResult, NON_TOOL_ACTIONS, 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 PendingFieldsScan, type PlanDocMeta, type PlanLifecycleEvent, type PlanLifecycleState, type PlanPhase, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, type PlanReviewResponseEnvelope, type PlanTransitionResult, type ReplayFoldOptions, type ReviewDimension, type ReviewEntry, type ReviewReport, type ReviewReportStatus, type ReviewResolutionDisposition, type ReviewSeverity, 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 SessionManagerArchiveParams, type SessionManagerArchiveResult, type SessionManagerCreateParams, type SessionManagerCreateResult, type SessionManagerDeleteParams, type SessionManagerDeleteResult, 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 SubagentEngineModelInfo, type SubagentEnginesFile, type SubagentInFlightReport, type SubagentJournalDomain, type SubagentJournalEvent, type SubagentJournalReport, type SupportRating, TASK_ENTRY_TYPE, TOOL_ACTION_MAP, 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, allCanvasActions, allToolActions, appendExecutionRecord, applyPendingDiff, callMarkerRpc, canvasError, collectActivePendingIds, dateToOnceCron, derivePhase, extractGui, firstContentText, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isActionAllowed, isArgumentMateriality, isArgumentPolarity, isAskUserQuestion, isCanvasCommentParams, isCanvasCommentRespondParams, isCanvasConvergeCheckParams, isCanvasCreateParams, isCanvasDecideDirectionParams, isCanvasDispatchParams, isCanvasEnterParams, isCanvasExportParams, isCanvasGrowParams, isCanvasListParams, isCanvasMarkerRequest, isCanvasPatchParams, isCanvasReadParams, isCanvasReviewAppendParams, isCanvasReviewRequestParams, isCanvasReviewResolveParams, isCanvasSelectParams, isCanvasTransitionParams, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isJournalReportAck, isPlanReviewRequest, isPlanReviewResponse, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerArchiveParams, isSessionManagerCreateParams, isSessionManagerDeleteParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerNotifyId, isSessionManagerSendParams, isSessionManagerStatusParams, isSessionManagerWatchParams, isSessionManagerWatchRespondPayload, isSubagentInFlightReport, isSubagentJournalReport, mapReasonToStatus, onceCronToDate, parsePlanReviewResponse, readLifecycleState, readResumeHint, replayFoldEntries, scanPendingEntries, scanPendingFields, setWidgetDual, snapshotToTask, toolOfAction, transition, truncateSelfReview, uiFormInteract, validateWidgetIconPaths };
|
|
2605
|
+
export { ACTION_EVENT_MAP, ASK_USER_MARKER, type ArgumentMateriality, type ArgumentPolarity, type AskUserAnswers, type AskUserOption, type AskUserQuestion, CANVAS_ACTIONS, CANVAS_ACTOR_MATRIX, CANVAS_ERROR_CODES, CANVAS_ERROR_RECOVERY, CANVAS_EVENT_TYPES, CANVAS_MARKER, CANVAS_MARKER_ACTIONS, CANVAS_TOOL_NAMES, type CanvasAction, type CanvasActionParams, type CanvasActor, type CanvasComment, type CanvasCommentParams, type CanvasCommentRespondParams, type CanvasConvergeCheckParams, type CanvasCreateParams, type CanvasDecideDirectionParams, type CanvasDirectionDecision, type CanvasDispatchParams, type CanvasEdge, type CanvasEdgeType, type CanvasEnterParams, type CanvasError, type CanvasErrorCode, type CanvasEventType, type CanvasExportParams, type CanvasExportTarget, type CanvasGrowItem, type CanvasGrowParams, type CanvasListEntry, type CanvasListParams, type CanvasListReply, type CanvasMarkerAction, type CanvasMarkerParams, type CanvasMarkerRequest, type CanvasMutateReply, type CanvasMutateRequest, type CanvasNode, type CanvasNodeLifecycle, type CanvasNodeType, type CanvasPatchParams, type CanvasReadParams, type CanvasReadReply, type CanvasReviewAppendParams, type CanvasReviewEntryInput, type CanvasReviewRequestParams, type CanvasReviewResolveParams, type CanvasSelectParams, type CanvasState, type CanvasToolName, type CanvasTransitionParams, 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, MAPPED_PENDING_STATUSES, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, type MappedPendingStatus, type MarkerRpcOptions, type MarkerRpcResult, NON_TOOL_ACTIONS, PENDING_REGISTER_ENTRY_TYPE, PENDING_UNREGISTER_ENTRY_TYPE, PERMISSION_APPROVAL_TITLE, PLAN_LIFECYCLE_EVENTS, PLAN_LIFECYCLE_STATES, PLAN_REVIEW_MARKER, PLAN_SELF_REVIEW_MAX_BYTES, PLAN_STATE_CUSTOM_TYPE, PROTOCOL_VERSION, type PendingEntriesScan, type PendingFieldsScan, type PlanDocMeta, type PlanLifecycleEvent, type PlanLifecycleState, type PlanPhase, type PlanReviewComment, type PlanReviewDecision, type PlanReviewRequest, type PlanReviewResponse, type PlanReviewResponseEnvelope, type PlanTransitionResult, type ReplayFoldOptions, type ResolvedSettlementReason, type ReviewDimension, type ReviewEntry, type ReviewReport, type ReviewReportStatus, type ReviewResolutionDisposition, type ReviewSeverity, SCHEDULER_MODAL_VIEW_ID, SCHEDULE_CREATE_MARKER, SESSION_MANAGER_ACTIONS, SESSION_MANAGER_MARKER, SETTLEMENT_REASONS, 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 SessionManagerArchiveParams, type SessionManagerArchiveResult, type SessionManagerCreateParams, type SessionManagerCreateResult, type SessionManagerDeleteParams, type SessionManagerDeleteResult, 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 SettlementReason, type StatItem, type SubagentEngineConfigView, type SubagentEngineModelInfo, type SubagentEnginesFile, type SubagentInFlightReport, type SubagentJournalDomain, type SubagentJournalEvent, type SubagentJournalReport, type SupportRating, TASK_ENTRY_TYPE, TOOL_ACTION_MAP, 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, allCanvasActions, allToolActions, appendExecutionRecord, applyPendingDiff, callMarkerRpc, canvasError, collectActivePendingIds, dateToOnceCron, derivePhase, extractGui, firstContentText, firstLine, formatChannelErrorText, formatDuration, formatRelativeTime, formatSchedule, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isActionAllowed, isArgumentMateriality, isArgumentPolarity, isAskUserQuestion, isCanvasCommentParams, isCanvasCommentRespondParams, isCanvasConvergeCheckParams, isCanvasCreateParams, isCanvasDecideDirectionParams, isCanvasDispatchParams, isCanvasEnterParams, isCanvasExportParams, isCanvasGrowParams, isCanvasListParams, isCanvasMarkerRequest, isCanvasPatchParams, isCanvasReadParams, isCanvasReviewAppendParams, isCanvasReviewRequestParams, isCanvasReviewResolveParams, isCanvasSelectParams, isCanvasTransitionParams, isChannelErrorResult, isFormAnswers, isFormQuestion, isGuiCapable, isGuiComponent, isGuiRenderResult, isInFlightReportAck, isJournalReportAck, isPlanReviewRequest, isPlanReviewResponse, isScheduleDraft, isScheduleFormResult, isSessionManagerAbortParams, isSessionManagerArchiveParams, isSessionManagerCreateParams, isSessionManagerDeleteParams, isSessionManagerHistoryParams, isSessionManagerListParams, isSessionManagerNotifyId, isSessionManagerSendParams, isSessionManagerStatusParams, isSessionManagerWatchParams, isSessionManagerWatchRespondPayload, isSubagentInFlightReport, isSubagentJournalReport, mapReasonToStatus, onceCronToDate, parsePlanReviewResponse, readDetailsSummary, readLifecycleState, readResumeHint, replayFoldEntries, resolveSettlementReason, resultContentText, scanPendingEntries, scanPendingFields, setWidgetDual, snapshotToTask, toolOfAction, transition, truncateSelfReview, uiFormInteract, validateWidgetIconPaths };
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var PROTOCOL_VERSION = 1;
|
|
|
15
15
|
// src/core/markers.ts
|
|
16
16
|
var GUI_WIDGET_MARKER = "\0TAIJI_GUI_WIDGET:";
|
|
17
17
|
var PLAN_REVIEW_MARKER = "\0TAIJI_PLAN_REVIEW:";
|
|
18
|
+
var PERMISSION_APPROVAL_TITLE = "[pi-permission] Approval required";
|
|
18
19
|
|
|
19
20
|
// src/core/helpers.ts
|
|
20
21
|
function isGuiCapable(ctx) {
|
|
@@ -94,6 +95,23 @@ function firstContentText(result) {
|
|
|
94
95
|
const first = result.content[0];
|
|
95
96
|
return first?.type === "text" ? first.text ?? "" : "";
|
|
96
97
|
}
|
|
98
|
+
function readDetailsSummary(result) {
|
|
99
|
+
if (result === null || typeof result !== "object") return void 0;
|
|
100
|
+
const details = result.details;
|
|
101
|
+
if (details === null || typeof details !== "object") return void 0;
|
|
102
|
+
const summary = details.summary;
|
|
103
|
+
return typeof summary === "string" && summary !== "" ? summary : void 0;
|
|
104
|
+
}
|
|
105
|
+
function resultContentText(result) {
|
|
106
|
+
if (result === null || typeof result !== "object") return "";
|
|
107
|
+
const content = result.content;
|
|
108
|
+
if (!Array.isArray(content)) return "";
|
|
109
|
+
return firstContentText({ content });
|
|
110
|
+
}
|
|
111
|
+
function firstLine(text) {
|
|
112
|
+
const idx = text.indexOf("\n");
|
|
113
|
+
return idx === -1 ? text : text.slice(0, idx);
|
|
114
|
+
}
|
|
97
115
|
function stripUndefined(obj) {
|
|
98
116
|
if (obj === null || obj === void 0) return obj;
|
|
99
117
|
if (typeof obj !== "object") return obj;
|
|
@@ -1150,7 +1168,8 @@ function scanPendingEntries(entries) {
|
|
|
1150
1168
|
registerEntries: [],
|
|
1151
1169
|
unregisteredIds: /* @__PURE__ */ new Set(),
|
|
1152
1170
|
registerTypes: /* @__PURE__ */ new Map(),
|
|
1153
|
-
unregisterStatuses: /* @__PURE__ */ new Map()
|
|
1171
|
+
unregisterStatuses: /* @__PURE__ */ new Map(),
|
|
1172
|
+
unregisterSettlements: /* @__PURE__ */ new Map()
|
|
1154
1173
|
};
|
|
1155
1174
|
const seenRegisterIds = /* @__PURE__ */ new Set();
|
|
1156
1175
|
for (const raw of entries) {
|
|
@@ -1158,26 +1177,36 @@ function scanPendingEntries(entries) {
|
|
|
1158
1177
|
const entry = raw;
|
|
1159
1178
|
const data = entry.data ?? {};
|
|
1160
1179
|
if (entry.customType === PENDING_REGISTER_ENTRY_TYPE) {
|
|
1161
|
-
scan
|
|
1162
|
-
if (typeof data.id === "string" && data.id !== "" && !seenRegisterIds.has(data.id)) {
|
|
1163
|
-
seenRegisterIds.add(data.id);
|
|
1164
|
-
if (typeof data.type === "string") scan.registerTypes.set(data.id, data.type);
|
|
1165
|
-
}
|
|
1180
|
+
absorbRegisterEntry(scan, data, seenRegisterIds);
|
|
1166
1181
|
} else if (entry.customType === PENDING_UNREGISTER_ENTRY_TYPE) {
|
|
1167
|
-
|
|
1168
|
-
scan.unregisteredIds.add(data.id);
|
|
1169
|
-
const status = data.status;
|
|
1170
|
-
if (data.id !== "" && typeof status === "string" && MAPPED_PENDING_STATUSES.has(status)) {
|
|
1171
|
-
scan.unregisterStatuses.set(data.id, status);
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1182
|
+
absorbUnregisterEntry(scan, data);
|
|
1174
1183
|
}
|
|
1175
1184
|
}
|
|
1176
1185
|
return scan;
|
|
1177
1186
|
}
|
|
1187
|
+
function absorbRegisterEntry(scan, data, seenRegisterIds) {
|
|
1188
|
+
scan.registerEntries.push({ data });
|
|
1189
|
+
if (typeof data.id === "string" && data.id !== "" && !seenRegisterIds.has(data.id)) {
|
|
1190
|
+
seenRegisterIds.add(data.id);
|
|
1191
|
+
if (typeof data.type === "string") scan.registerTypes.set(data.id, data.type);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
function absorbUnregisterEntry(scan, data) {
|
|
1195
|
+
if (typeof data.id !== "string") return;
|
|
1196
|
+
scan.unregisteredIds.add(data.id);
|
|
1197
|
+
if (data.id === "") return;
|
|
1198
|
+
const status = data.status;
|
|
1199
|
+
if (typeof status === "string" && MAPPED_PENDING_STATUSES.has(status)) {
|
|
1200
|
+
scan.unregisterStatuses.set(data.id, status);
|
|
1201
|
+
}
|
|
1202
|
+
const reason = data.reason;
|
|
1203
|
+
if (typeof reason === "string") {
|
|
1204
|
+
scan.unregisterSettlements.set(data.id, resolveSettlementReason(reason));
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1178
1207
|
function scanPendingFields(entries) {
|
|
1179
|
-
const { registerTypes, unregisterStatuses } = scanPendingEntries(entries);
|
|
1180
|
-
return { registerTypes, unregisterStatuses };
|
|
1208
|
+
const { registerTypes, unregisterStatuses, unregisterSettlements } = scanPendingEntries(entries);
|
|
1209
|
+
return { registerTypes, unregisterStatuses, unregisterSettlements };
|
|
1181
1210
|
}
|
|
1182
1211
|
function applyPendingDiff(scan) {
|
|
1183
1212
|
const active = [];
|
|
@@ -1216,12 +1245,60 @@ var REASON_STATUS_MAP = {
|
|
|
1216
1245
|
stopped: "aborted",
|
|
1217
1246
|
exited: "cancelled",
|
|
1218
1247
|
deleted: "cancelled",
|
|
1219
|
-
orphaned: "cancelled"
|
|
1248
|
+
orphaned: "cancelled",
|
|
1249
|
+
// ── [subagent-observability §3.3.6] 三组词表外字面量显式映射(原直落 default)──
|
|
1250
|
+
running: "completed",
|
|
1251
|
+
closed: "cancelled",
|
|
1252
|
+
"parent-shutdown": "aborted",
|
|
1253
|
+
"parent-fork": "aborted",
|
|
1254
|
+
"parent-new": "aborted",
|
|
1255
|
+
"user-close": "cancelled",
|
|
1256
|
+
disconnected: "aborted",
|
|
1257
|
+
gc: "unknown"
|
|
1220
1258
|
};
|
|
1221
1259
|
function mapReasonToStatus(reason) {
|
|
1222
|
-
return REASON_STATUS_MAP[reason] ?? "
|
|
1260
|
+
return REASON_STATUS_MAP[reason] ?? "unknown";
|
|
1223
1261
|
}
|
|
1262
|
+
var MAPPED_REASON_KEYS = new Set(Object.keys(REASON_STATUS_MAP));
|
|
1224
1263
|
var MAPPED_PENDING_STATUSES = new Set(Object.values(REASON_STATUS_MAP));
|
|
1264
|
+
var SETTLEMENT_REASONS = [
|
|
1265
|
+
"completed",
|
|
1266
|
+
"failed",
|
|
1267
|
+
"cancelled",
|
|
1268
|
+
"lost",
|
|
1269
|
+
"no_result"
|
|
1270
|
+
];
|
|
1271
|
+
var SETTLEMENT_REASON_MAP = {
|
|
1272
|
+
completed: "completed",
|
|
1273
|
+
failed: "failed",
|
|
1274
|
+
cancelled: "cancelled",
|
|
1275
|
+
lost: "lost",
|
|
1276
|
+
no_result: "no_result",
|
|
1277
|
+
expired: "no_result",
|
|
1278
|
+
time_limited: "failed",
|
|
1279
|
+
budget_limited: "failed",
|
|
1280
|
+
aborted: "cancelled",
|
|
1281
|
+
interrupted: "cancelled",
|
|
1282
|
+
"interrupted-by-restart": "cancelled",
|
|
1283
|
+
"interrupted-by-parent": "cancelled",
|
|
1284
|
+
stopped: "cancelled",
|
|
1285
|
+
exited: "cancelled",
|
|
1286
|
+
deleted: "cancelled",
|
|
1287
|
+
orphaned: "cancelled",
|
|
1288
|
+
reopened: "completed",
|
|
1289
|
+
running: "no_result",
|
|
1290
|
+
closed: "cancelled",
|
|
1291
|
+
"parent-shutdown": "cancelled",
|
|
1292
|
+
"parent-fork": "cancelled",
|
|
1293
|
+
"parent-new": "cancelled",
|
|
1294
|
+
"user-close": "cancelled",
|
|
1295
|
+
disconnected: "no_result",
|
|
1296
|
+
gc: "no_result"
|
|
1297
|
+
};
|
|
1298
|
+
function resolveSettlementReason(reason) {
|
|
1299
|
+
return SETTLEMENT_REASON_MAP[reason] ?? "unknown";
|
|
1300
|
+
}
|
|
1301
|
+
var SETTLEMENT_REASON_KEYS = new Set(Object.keys(SETTLEMENT_REASON_MAP));
|
|
1225
1302
|
export {
|
|
1226
1303
|
ACTION_EVENT_MAP,
|
|
1227
1304
|
ASK_USER_MARKER,
|
|
@@ -1250,6 +1327,7 @@ export {
|
|
|
1250
1327
|
NON_TOOL_ACTIONS,
|
|
1251
1328
|
PENDING_REGISTER_ENTRY_TYPE,
|
|
1252
1329
|
PENDING_UNREGISTER_ENTRY_TYPE,
|
|
1330
|
+
PERMISSION_APPROVAL_TITLE,
|
|
1253
1331
|
PLAN_LIFECYCLE_EVENTS,
|
|
1254
1332
|
PLAN_LIFECYCLE_STATES,
|
|
1255
1333
|
PLAN_REVIEW_MARKER,
|
|
@@ -1260,6 +1338,7 @@ export {
|
|
|
1260
1338
|
SCHEDULE_CREATE_MARKER,
|
|
1261
1339
|
SESSION_MANAGER_ACTIONS,
|
|
1262
1340
|
SESSION_MANAGER_MARKER,
|
|
1341
|
+
SETTLEMENT_REASONS,
|
|
1263
1342
|
SUBAGENTS_ENGINES_FILENAME,
|
|
1264
1343
|
SUBAGENT_BG_NOTIFY_CUSTOM_TYPE,
|
|
1265
1344
|
SUBAGENT_DIRECTIVE_CUSTOM_TYPE,
|
|
@@ -1280,6 +1359,7 @@ export {
|
|
|
1280
1359
|
derivePhase,
|
|
1281
1360
|
extractGui,
|
|
1282
1361
|
firstContentText,
|
|
1362
|
+
firstLine,
|
|
1283
1363
|
formatChannelErrorText,
|
|
1284
1364
|
formatDuration,
|
|
1285
1365
|
formatRelativeTime,
|
|
@@ -1342,9 +1422,12 @@ export {
|
|
|
1342
1422
|
mapReasonToStatus,
|
|
1343
1423
|
onceCronToDate,
|
|
1344
1424
|
parsePlanReviewResponse,
|
|
1425
|
+
readDetailsSummary,
|
|
1345
1426
|
readLifecycleState,
|
|
1346
1427
|
readResumeHint,
|
|
1347
1428
|
replayFoldEntries,
|
|
1429
|
+
resolveSettlementReason,
|
|
1430
|
+
resultContentText,
|
|
1348
1431
|
scanPendingEntries,
|
|
1349
1432
|
scanPendingFields,
|
|
1350
1433
|
setWidgetDual,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/extension-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsup",
|
|
35
35
|
"typecheck": "tsc --noEmit",
|
|
36
|
-
"test": "vitest run"
|
|
36
|
+
"test": "vitest run --pool=threads"
|
|
37
37
|
}
|
|
38
38
|
}
|