@zhushanwen/subagent-engine-sdk 0.2.0 → 0.3.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.
Files changed (59) hide show
  1. package/dist/{chunk-A75XDJIC.js → chunk-AIG5LSGK.js} +3 -0
  2. package/dist/{chunk-ZXEAW25V.js → chunk-BBVZK5DL.js} +1 -4
  3. package/dist/chunk-EUSM6ZX4.js +10 -0
  4. package/dist/{chunk-LEOBWKRM.js → chunk-FJT23P7T.js} +1 -1
  5. package/dist/{chunk-N3RL6OVM.js → chunk-J4G2MXDS.js} +3 -1
  6. package/dist/{chunk-ZOFFJNJD.js → chunk-LKPVN3N6.js} +1 -1
  7. package/dist/{chunk-RULLX6C6.js → chunk-LQR73V67.js} +2 -0
  8. package/dist/{chunk-YFSN3D5N.js → chunk-TGDMOLZU.js} +25 -17
  9. package/dist/{chunk-PPEPBVCC.js → chunk-WS4WAZVR.js} +1 -1
  10. package/dist/cli-entry.cjs +3 -1
  11. package/dist/cli-entry.js +1 -1
  12. package/dist/{contract-types-sSlgppBC.d.cts → contract-types-ByIFoLrY.d.cts} +18 -34
  13. package/dist/{contract-types-sSlgppBC.d.ts → contract-types-ByIFoLrY.d.ts} +18 -34
  14. package/dist/env.cjs +1 -4
  15. package/dist/env.d.cts +4 -1
  16. package/dist/env.d.ts +4 -1
  17. package/dist/env.js +1 -1
  18. package/dist/{error-codes-Dhss2Kmk.d.ts → error-codes-BUx92qYi.d.ts} +5 -4
  19. package/dist/{error-codes-DHco5-i_.d.cts → error-codes-DCiilt_8.d.cts} +5 -4
  20. package/dist/index.cjs +45 -23
  21. package/dist/index.d.cts +5 -5
  22. package/dist/index.d.ts +5 -5
  23. package/dist/index.js +16 -11
  24. package/dist/journal-io.d.cts +1 -1
  25. package/dist/journal-io.d.ts +1 -1
  26. package/dist/journal-replay.cjs +3 -0
  27. package/dist/journal-replay.d.cts +1 -1
  28. package/dist/journal-replay.d.ts +1 -1
  29. package/dist/journal-replay.js +1 -1
  30. package/dist/kill-chain.d.cts +2 -2
  31. package/dist/kill-chain.d.ts +2 -2
  32. package/dist/kill-chain.js +2 -2
  33. package/dist/node-executor.js +2 -2
  34. package/dist/port-contract.cjs +3 -0
  35. package/dist/port-contract.d.cts +41 -8
  36. package/dist/port-contract.d.ts +41 -8
  37. package/dist/port-contract.js +3 -1
  38. package/dist/protocol/index.cjs +26 -18
  39. package/dist/protocol/index.d.cts +95 -96
  40. package/dist/protocol/index.d.ts +95 -96
  41. package/dist/protocol/index.js +4 -4
  42. package/dist/ui-types.cjs +16 -0
  43. package/dist/ui-types.d.cts +13 -6
  44. package/dist/ui-types.d.ts +13 -6
  45. package/dist/ui-types.js +7 -1
  46. package/package.json +1 -1
  47. package/src/cli-entry.ts +6 -1
  48. package/src/data-dir.ts +3 -2
  49. package/src/env.ts +4 -4
  50. package/src/journal-replay.ts +4 -0
  51. package/src/port-contract.ts +40 -8
  52. package/src/protocol/contract-types.ts +20 -23
  53. package/src/protocol/engine-protocol.ts +19 -9
  54. package/src/protocol/error-codes.ts +7 -6
  55. package/src/protocol/methods.ts +38 -28
  56. package/src/protocol/reverse-channels.ts +15 -103
  57. package/src/protocol/schema.ts +36 -0
  58. package/src/ui-types.ts +22 -5
  59. package/dist/chunk-2DIMPZCQ.js +0 -0
package/src/ui-types.ts CHANGED
@@ -28,11 +28,12 @@ export type UiMethod =
28
28
  | "set_editor_text"
29
29
  | (string & {});
30
30
 
31
- /** UI 请求(session-runner 构造后传给 handler)。
31
+ /** UI 请求(引擎侧构造后经 host/askUser 送达宿主 handler)。
32
32
  *
33
33
  * method 是判别字段,决定排队策略(dialog 排队)和业务路由(channel 分发)。
34
- * method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1,由 session-runner 从
35
- * ExtensionUiRequest 平铺构造)。channel/channelPayload 由 parseChannel 填充。
34
+ * method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1,由引擎侧
35
+ * ui-request-queue 从 ExtensionUiRequest 平铺构造)。channel/channelPayload 由
36
+ * parseChannel 填充。
36
37
  *
37
38
  * 契约来源:.fix-plans/00-master-summary.md §二 2.2。 */
38
39
  export interface UiRequest {
@@ -61,8 +62,10 @@ export interface UiRequest {
61
62
  /** channel 解析后的结构化 payload(已 JSON.parse)。
62
63
  * ask_user: {questions, allowCancel};gui_widget: {component};无 channel: undefined。 */
63
64
  channelPayload?: unknown;
64
- /** 内部元数据字段:发起该 UI 请求的子进程 pid(由 session-runner.handleUiRequest
65
- * child.pid 填入)。L2 队列据此关联 rejectChildDialogs(child close 时批量 reject)。
65
+ /** 内部元数据字段:发起该 UI 请求的子进程 pid(由引擎侧 ui-request-queue
66
+ * child.pid 填入——session-runner 已随协议化重构删除,填充点现住 pi 引擎包)。
67
+ * L2 队列据此关联 rejectChildDialogs(子进程退出时批量取消,见
68
+ * notifyChildProcessExited 的接线链)。
66
69
  * 下划线前缀表示内部字段,非 Pi 协议字段,不参与 stdin 回写。 */
67
70
  _childPid?: number;
68
71
  }
@@ -78,6 +81,20 @@ export type UiResponse =
78
81
  | { cancelled: true }
79
82
  | { ack: true };
80
83
 
84
+ /** UiResponse 载荷结构判定(四成员判别;形态对齐 reverse-channels 的
85
+ * isHostStreamDeltaParams 先例)。消费方:引擎侧应答落位前守卫,防宿主畸形帧
86
+ * 静默流入 UI 队列(S7:askUser 应答跨界无守卫)。 */
87
+ export function isUiResponse(value: unknown): value is UiResponse {
88
+ if (typeof value !== "object" || value === null) return false;
89
+ const v = value as Record<string, unknown>;
90
+ return (
91
+ typeof v.value === "string" ||
92
+ typeof v.confirmed === "boolean" ||
93
+ v.cancelled === true ||
94
+ v.ack === true
95
+ );
96
+ }
97
+
81
98
  /** UI 请求 handler 签名(单函数,按 req.method 内部路由)。
82
99
  * 实现方负责:channel 业务路由(ask_user → AskUserComponent)+ 默认转发(ctx.ui.*)。
83
100
  * 抛错由调用方(DialogGlobalQueue / session-runner)兜底为 {cancelled:true}。 */
File without changes