dal-code 1.0.25 → 1.0.27

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 (175) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/NOTICE +7 -0
  3. package/dal-docs/README.md +13 -0
  4. package/dal-docs/settings.md +18 -2
  5. package/dist/cli/args.d.ts +3 -0
  6. package/dist/cli/args.js +14 -14
  7. package/dist/core/agent-session-services.d.ts +2 -0
  8. package/dist/core/agent-session-services.js +1 -1
  9. package/dist/core/agent-session.d.ts +27 -1
  10. package/dist/core/agent-session.js +9 -8
  11. package/dist/core/background-processes.d.ts +73 -0
  12. package/dist/core/background-processes.js +7 -0
  13. package/dist/core/extensions/index.d.ts +1 -1
  14. package/dist/core/extensions/loader.js +1 -1
  15. package/dist/core/extensions/permission-surface.js +1 -1
  16. package/dist/core/extensions/runner.js +1 -1
  17. package/dist/core/extensions/types.d.ts +6 -0
  18. package/dist/core/host-capabilities.d.ts +50 -0
  19. package/dist/core/host-capabilities.js +2 -0
  20. package/dist/core/permissions/rules.d.ts +45 -0
  21. package/dist/core/permissions/rules.js +1 -0
  22. package/dist/core/permissions/shell-words.js +2 -0
  23. package/dist/core/permissions/tool-policy.d.ts +46 -0
  24. package/dist/core/permissions/tool-policy.js +1 -0
  25. package/dist/core/sandbox/availability.d.ts +14 -0
  26. package/dist/core/sandbox/availability.js +1 -0
  27. package/dist/core/sandbox/denial.d.ts +25 -0
  28. package/dist/core/sandbox/denial.js +3 -0
  29. package/dist/core/sandbox/index.d.ts +5 -0
  30. package/dist/core/sandbox/index.js +1 -0
  31. package/dist/core/sandbox/policy.d.ts +66 -0
  32. package/dist/core/sandbox/policy.js +1 -0
  33. package/dist/core/sandbox/runtime.d.ts +41 -0
  34. package/dist/core/sandbox/runtime.js +1 -0
  35. package/dist/core/sandbox/shell-sandbox.d.ts +125 -0
  36. package/dist/core/sandbox/shell-sandbox.js +5 -0
  37. package/dist/core/sandbox/windows.d.ts +122 -0
  38. package/dist/core/sandbox/windows.js +5 -0
  39. package/dist/core/sdk.d.ts +3 -0
  40. package/dist/core/sdk.js +1 -1
  41. package/dist/core/settings-manager.d.ts +20 -0
  42. package/dist/core/settings-manager.js +1 -1
  43. package/dist/core/tools/bash.d.ts +16 -1
  44. package/dist/core/tools/bash.js +16 -14
  45. package/dist/core/tools/find.js +11 -11
  46. package/dist/core/tools/grep.js +10 -10
  47. package/dist/core/tools/index.d.ts +1 -0
  48. package/dist/core/tools/index.js +1 -1
  49. package/dist/core/tools/ls.js +6 -6
  50. package/dist/core/tools/powershell.d.ts +1 -1
  51. package/dist/core/tools/powershell.js +2 -2
  52. package/dist/core/tools/process.d.ts +26 -0
  53. package/dist/core/tools/process.js +22 -0
  54. package/dist/core/tools/read.js +15 -15
  55. package/dist/dal/builtins.js +2 -2
  56. package/dist/dal/child-env.js +1 -1
  57. package/dist/dal/manifest.d.ts +32 -0
  58. package/dist/dal/manifest.js +1 -0
  59. package/dist/index.d.ts +8 -3
  60. package/dist/index.js +1 -1
  61. package/dist/main.js +4 -4
  62. package/dist/modes/index.d.ts +2 -2
  63. package/dist/modes/print-mode.js +6 -4
  64. package/dist/modes/rpc/environment-update.js +1 -0
  65. package/dist/modes/rpc/rpc-client.d.ts +38 -1
  66. package/dist/modes/rpc/rpc-client.js +4 -1
  67. package/dist/modes/rpc/rpc-mode.d.ts +1 -0
  68. package/dist/modes/rpc/rpc-mode.js +1 -1
  69. package/dist/modes/rpc/rpc-types.d.ts +95 -0
  70. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  71. package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
  72. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  73. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  74. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  75. package/dist/node_modules/@dalcode/dal-interactive/LICENSE +21 -0
  76. package/dist/node_modules/@dalcode/dal-interactive/package.json +33 -0
  77. package/dist/node_modules/@dalcode/dal-interactive/src/handoff.js +28 -0
  78. package/dist/node_modules/@dalcode/dal-interactive/src/index.js +1 -0
  79. package/dist/node_modules/@dalcode/dal-interactive/src/interactive-shell.js +1 -0
  80. package/dist/node_modules/@dalcode/dal-interactive/src/questionnaire.js +3 -0
  81. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  82. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  83. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  84. package/dist/node_modules/@dalcode/dal-mcp/src/add-wizard.js +1 -1
  85. package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +1 -1
  86. package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
  87. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +18 -18
  88. package/dist/node_modules/@dalcode/dal-mcp/src/proxy.js +6 -6
  89. package/dist/node_modules/@dalcode/dal-mcp/src/report.js +1 -1
  90. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +1 -1
  91. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  92. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  93. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  94. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
  95. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  96. package/dist/node_modules/@dalcode/dal-review/LICENSE +21 -0
  97. package/dist/node_modules/@dalcode/dal-review/package.json +34 -0
  98. package/dist/node_modules/@dalcode/dal-review/src/args.d.ts +13 -0
  99. package/dist/node_modules/@dalcode/dal-review/src/args.js +1 -0
  100. package/dist/node_modules/@dalcode/dal-review/src/core.d.ts +6 -0
  101. package/dist/node_modules/@dalcode/dal-review/src/core.js +1 -0
  102. package/dist/node_modules/@dalcode/dal-review/src/findings.d.ts +23 -0
  103. package/dist/node_modules/@dalcode/dal-review/src/findings.js +4 -0
  104. package/dist/node_modules/@dalcode/dal-review/src/index.js +1 -0
  105. package/dist/node_modules/@dalcode/dal-review/src/prompt.d.ts +3 -0
  106. package/dist/node_modules/@dalcode/dal-review/src/prompt.js +29 -0
  107. package/dist/node_modules/@dalcode/dal-review/src/runner.d.ts +91 -0
  108. package/dist/node_modules/@dalcode/dal-review/src/runner.js +2 -0
  109. package/dist/node_modules/@dalcode/dal-review/src/targets.d.ts +33 -0
  110. package/dist/node_modules/@dalcode/dal-review/src/targets.js +17 -0
  111. package/dist/node_modules/@dalcode/dal-review/src/types.d.ts +94 -0
  112. package/dist/node_modules/@dalcode/dal-review/src/types.js +1 -0
  113. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  114. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  115. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  116. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  117. package/dist/node_modules/@dalcode/dal-subagent/src/agents.js +2 -2
  118. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +12 -12
  119. package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
  120. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  121. package/dist/node_modules/@dalcode/dal-terminal/LICENSE +21 -0
  122. package/dist/node_modules/@dalcode/dal-terminal/package.json +33 -0
  123. package/dist/node_modules/@dalcode/dal-terminal/src/contract.d.ts +60 -0
  124. package/dist/node_modules/@dalcode/dal-terminal/src/contract.js +7 -0
  125. package/dist/node_modules/@dalcode/dal-terminal/src/index.js +6 -0
  126. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  127. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  128. package/dist/node_modules/@dalcode/dal-web/src/config.js +2 -2
  129. package/dist/node_modules/@dalcode/dal-web/src/index.js +4 -4
  130. package/dist/node_modules/@dalcode/dal-web/src/search.js +4 -4
  131. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  132. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  133. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
  134. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  135. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  136. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +4 -0
  137. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
  138. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  139. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  140. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  141. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  142. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  143. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  144. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  145. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  146. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  147. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  148. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  149. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  150. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  151. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  152. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  153. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  154. package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
  155. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
  156. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  157. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  158. package/dist/sdk/index.d.ts +6 -2
  159. package/dist/sdk/index.js +1 -1
  160. package/dist/sdk/review.d.ts +1 -0
  161. package/dist/sdk/review.js +1 -0
  162. package/dist/sdk/subagents.d.ts +8 -0
  163. package/dist/sdk/subagents.js +1 -0
  164. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  165. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  166. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  167. package/examples/extensions/gondolin/package-lock.json +2 -2
  168. package/examples/extensions/gondolin/package.json +1 -1
  169. package/examples/extensions/sandbox/index.ts +6 -0
  170. package/examples/extensions/sandbox/package-lock.json +2 -2
  171. package/examples/extensions/sandbox/package.json +1 -1
  172. package/examples/extensions/with-deps/package-lock.json +2 -2
  173. package/examples/extensions/with-deps/package.json +1 -1
  174. package/npm-shrinkwrap.json +83 -5
  175. package/package.json +14 -1
@@ -1,8 +1,11 @@
1
1
  import type { AgentMessage, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
2
  import type { ImageContent, Model } from "@earendil-works/pi-ai";
3
3
  import type { SessionStats } from "../../core/agent-session.ts";
4
+ import type { BackgroundProcessInfo } from "../../core/background-processes.ts";
4
5
  import type { BashResult } from "../../core/bash-executor.ts";
5
6
  import type { CompactionResult } from "../../core/compaction/index.ts";
7
+ import type { HostCapability } from "../../core/host-capabilities.ts";
8
+ import type { SandboxStatus } from "../../core/sandbox/shell-sandbox.ts";
6
9
  import type { SessionEntry, SessionTreeNode } from "../../core/session-manager.ts";
7
10
  import type { SourceInfo } from "../../core/source-info.ts";
8
11
  export type RpcCommand = {
@@ -86,6 +89,21 @@ export type RpcCommand = {
86
89
  } | {
87
90
  id?: string;
88
91
  type: "abort_bash";
92
+ } | {
93
+ id?: string;
94
+ type: "get_sandbox_status";
95
+ } | {
96
+ id?: string;
97
+ type: "list_background_processes";
98
+ } | {
99
+ id?: string;
100
+ type: "read_background_process";
101
+ processId: string;
102
+ tail?: number;
103
+ } | {
104
+ id?: string;
105
+ type: "stop_background_process";
106
+ processId: string;
89
107
  } | {
90
108
  id?: string;
91
109
  type: "get_session_stats";
@@ -127,6 +145,15 @@ export type RpcCommand = {
127
145
  } | {
128
146
  id?: string;
129
147
  type: "get_commands";
148
+ } | {
149
+ id?: string;
150
+ type: "set_host_capabilities";
151
+ capabilities: HostCapability[];
152
+ } | {
153
+ id?: string;
154
+ type: "set_environment";
155
+ set?: Record<string, string>;
156
+ unset?: string[];
130
157
  };
131
158
  export interface RpcSlashCommand {
132
159
  name: string;
@@ -278,6 +305,38 @@ export type RpcResponse = {
278
305
  type: "response";
279
306
  command: "abort_bash";
280
307
  success: true;
308
+ } | {
309
+ id?: string;
310
+ type: "response";
311
+ command: "get_sandbox_status";
312
+ success: true;
313
+ data: SandboxStatus | null;
314
+ } | {
315
+ id?: string;
316
+ type: "response";
317
+ command: "list_background_processes";
318
+ success: true;
319
+ data: {
320
+ processes: BackgroundProcessInfo[];
321
+ };
322
+ } | {
323
+ id?: string;
324
+ type: "response";
325
+ command: "read_background_process";
326
+ success: true;
327
+ data: {
328
+ text: string;
329
+ truncated: boolean;
330
+ process: BackgroundProcessInfo;
331
+ };
332
+ } | {
333
+ id?: string;
334
+ type: "response";
335
+ command: "stop_background_process";
336
+ success: true;
337
+ data: {
338
+ process: BackgroundProcessInfo;
339
+ };
281
340
  } | {
282
341
  id?: string;
283
342
  type: "response";
@@ -375,6 +434,22 @@ export type RpcResponse = {
375
434
  data: {
376
435
  commands: RpcSlashCommand[];
377
436
  };
437
+ } | {
438
+ id?: string;
439
+ type: "response";
440
+ command: "set_host_capabilities";
441
+ success: true;
442
+ data: {
443
+ capabilities: HostCapability[];
444
+ };
445
+ } | {
446
+ id?: string;
447
+ type: "response";
448
+ command: "set_environment";
449
+ success: true;
450
+ data: {
451
+ changed: string[];
452
+ };
378
453
  } | {
379
454
  id?: string;
380
455
  type: "response";
@@ -480,4 +555,24 @@ export type RpcExtensionUIResponse = {
480
555
  id: string;
481
556
  cancelled: true;
482
557
  };
558
+ export interface RpcHostRequest {
559
+ type: "host_request";
560
+ id: string;
561
+ capability: string;
562
+ method: string;
563
+ params: Record<string, unknown>;
564
+ }
565
+ export interface RpcHostRequestCancelled {
566
+ type: "host_request_cancelled";
567
+ id: string;
568
+ }
569
+ export type RpcHostResponse = {
570
+ type: "host_response";
571
+ id: string;
572
+ result: unknown;
573
+ } | {
574
+ type: "host_response";
575
+ id: string;
576
+ error: string;
577
+ };
483
578
  export type RpcCommandType = RpcCommand["type"];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-bridge",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.25",
21
+ "@dalcode/dal-pi-kit": "1.0.27",
22
22
  "typebox": "1.3.7"
23
23
  },
24
24
  "peerDependencies": {
@@ -1 +1 @@
1
- var y=Object.defineProperty;var c=(n,p)=>y(n,"name",{value:p,configurable:!0});var S=Object.defineProperty,d=c((n,p)=>S(n,"name",{value:p,configurable:!0}),"l");import{t as e}from"@dalcode/dal-pi-kit";import{Type as i}from"typebox";import{AskUserInputError as _,askUserSchema as x,buildAskUserRequest as I,describeAnswers as T,THUMBNAIL_CHANNEL as P}from"./ask-user.js";import{askUserTimeoutMs as N,BridgeClient as $,planTimeoutMs as M,readBridgeConfig as U,readSubagentAttribution as O}from"./client.js";const q=i.Object({goal:i.String({description:e("\u8FD9\u4E2A\u8BA1\u5212\u8981\u8FBE\u6210\u4EC0\u4E48\uFF0C\u4E00\u53E5\u8BDD\u8BF4\u660E")}),reasoning:i.Optional(i.String({description:e("\u4E3A\u4EC0\u4E48\u9009\u8FD9\u4E2A\u65B9\u6848")})),steps:i.Array(i.Object({title:i.String({description:e("\u8FD9\u4E00\u6B65\u505A\u4EC0\u4E48")}),description:i.Optional(i.String({description:e("\u8FD9\u4E00\u6B65\u7684\u7EC6\u8282")}))}),{description:e("\u6309\u987A\u5E8F\u6392\u5217\u7684\u6267\u884C\u6B65\u9AA4")})}),L=new Set(["read","grep","ripgrep","find","fd","ls","glob","todo_read","todo","lsp"]),j="submit_plan",f="ask_user";function g(n){const p=n.input;for(const D of["command","file_path","path","filePath"]){const F=p[D];if(typeof F=="string"&&F.length>0)return F}}c(g,"q"),d(g,"ruleContentFor");function k(n,p){const D=U();if(!D)return;const F=new $(D,p),a=O();function B(t){const u=t.sessionManager.getSessionId();return a?{sessionId:a.parentSessionId,subagent:{id:a.subagentId,sessionId:u,...a.parentTaskId?{parentTaskId:a.parentTaskId}:{},...a.parentSubagentId?{parentSubagentId:a.parentSubagentId}:{},...a.label?{label:a.label}:{}}}:{sessionId:u}}c(B,"b"),d(B,"caller");let s,m=0;function C(t){const u=t.model;return{provider:u?.provider??"unknown",model:u?.id??u?.name??"unknown"}}c(C,"x"),d(C,"describeModel"),n.on("tool_call",async(t,u)=>{if(L.has(t.toolName)||t.toolName===j||t.toolName===f)return;const o=await F.post("/api/internal/pi-bridge/permission",{...B(u),toolName:t.toolName,toolInput:t.input,ruleContent:g(t)});if(!o)return{block:!0,reason:e("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")};if(o.decision==="deny")return{block:!0,reason:o.message??e("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}}),n.on("after_provider_response",(t,u)=>{t.status>=400?s={...C(u),reason:`HTTP ${t.status}`}:(s=void 0,m=0)}),n.on("before_provider_request",async(t,u)=>{if(!s)return;const o=C(u);if(o.provider===s.provider&&o.model===s.model)return;m+=1;const l={provider:s.provider,model:s.model},A=s.reason;s=void 0,await F.post("/api/internal/pi-bridge/provider-fallback",{...B(u),from:l,to:o,reason:A,attempt:m,blocked:!0});const r=new Error(e("dal-bridge\uFF1A\u8BF7\u6C42\u5931\u8D25\u540E\u4E0D\u5141\u8BB8\u81EA\u52A8\u6362\u6A21\u578B\u3002")+` ${l.provider}/${l.model} \u2192 ${o.provider}/${o.model} (${A})`);throw r.name="ProviderSwapAborted",r}),n.registerTool({name:"submit_plan",label:e("\u63D0\u4EA4\u8BA1\u5212\u5F85\u5BA1\u6279"),description:e(e("\u5728\u52A8\u624B\u6539\u52A8\u4E4B\u524D\uFF0C\u628A\u8BA1\u5212\u63D0\u4EA4\u7ED9\u7528\u6237\u5BA1\u6279\u3002\u8FD4\u56DE\u662F\u5426\u7EE7\u7EED\u6267\u884C\uFF0C\u4EE5\u53CA\u7528\u6237\u7ED9\u51FA\u7684\u53CD\u9988\u3002")+e("\u5F53\u4EFB\u52A1\u662F\u591A\u6B65\u9AA4\u7684\u3001\u6216\u4F1A\u6539\u52A8\u591A\u4E2A\u6587\u4EF6\u65F6\u4F7F\u7528\u3002")),promptSnippet:e("submit_plan - \u591A\u6B65\u9AA4\u4EFB\u52A1\u52A8\u624B\u524D\u5148\u63D0\u4EA4\u8BA1\u5212\u5F85\u7528\u6237\u5BA1\u6279"),parameters:q,execute:d(async(t,u,o,l,A)=>{const r=await F.post("/api/internal/pi-bridge/plan",{...B(A),goal:u.goal,reasoning:u.reasoning,steps:u.steps},{timeoutMs:M()});return!r||r.decision==="cancel"?{content:[{type:"text",text:r?.feedback?`Plan not approved. User feedback: ${r.feedback}`:"Plan not approved. Stop and wait for further instructions."}],details:{approved:!1,...r?.feedback?{feedback:r.feedback}:{}}}:{content:[{type:"text",text:"Plan approved. Proceed with the steps."}],details:{approved:!0}}},"execute")});const v=d((t,u)=>{let o;return n.events.emit(P,{ref:t,...u!==void 0?{title:u}:{},reply:d(l=>{o=l},"reply")}),o},"resolveThumbnail");n.registerTool({name:f,label:e("\u8BE2\u95EE\u7528\u6237"),description:e("\u52A8\u624B\u505A PPT\u3001\u6587\u6863\u3001\u8868\u683C\u3001\u9875\u9762\u4E4B\u524D\uFF0C\u7528\u4E00\u5F20\u5361\u7247\u5411\u7528\u6237\u786E\u8BA4\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF09\u3002\u9898\u578B\uFF1Achoice \u9009\u9879\uFF08\u53EF\u5E26\u7F29\u7565\u56FE\uFF09\u3001swatch \u914D\u8272\u3001outline \u53EF\u6392\u5E8F\u5927\u7EB2\u3001slider \u6570\u503C\u3001text \u81EA\u7531\u6587\u672C\u3002\u6BCF\u9898\u90FD\u8981\u6709\u63A8\u8350\u9879\u3002"),promptSnippet:e("ask_user - \u5F00\u5DE5\u524D\u7528\u4E00\u5F20\u5361\u7247\u786E\u8BA4\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF0C\u6BCF\u9898\u6709\u63A8\u8350\u9879\uFF09"),promptGuidelines:[e("ask_user \u53EA\u5728\u5F00\u5DE5\u524D\u95EE\u4E00\u6B21\uFF0C\u4E00\u8F6E\u6700\u591A 3 \u9898\uFF1B\u540C\u4E00\u4EFB\u52A1\u4E4B\u540E\u4E0D\u518D\u8FFD\u95EE\uFF0C\u9664\u975E\u7528\u6237\u4E3B\u52A8\u8981\u6C42\u3002"),e("\u53EA\u95EE\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u51B3\u5B9A\uFF08\u53D7\u4F17/\u7528\u9014\u3001\u98CE\u683C\u6216\u4E3B\u9898\u3001\u7BC7\u5E45\u3001\u5927\u7EB2\u987A\u5E8F\uFF09\uFF1B\u80FD\u4ECE\u7528\u6237\u539F\u8BDD\u3001\u9644\u4EF6\u6216\u9879\u76EE\u6587\u4EF6\u63A8\u65AD\u51FA\u7684\u4E0D\u95EE\u3002"),e("\u7528\u6237\u8BF4\u4E86\u300C\u76F4\u63A5\u505A / \u4F60\u51B3\u5B9A / \u5FEB\u901F\u51FA\u4E00\u7248\u300D\uFF0C\u6216\u662F\u5728\u4FEE\u6539\u5DF2\u6709\u6587\u4EF6\uFF08\u5E26\u5B9A\u4F4D\u3001\u300C\u628A\u7B2C 3 \u9875\u6539\u6210\u2026\u300D\uFF09\u65F6\uFF0C\u4E0D\u8981\u8C03\u7528 ask_user\u3002"),e("\u6BCF\u9898\u90FD\u6807\u51FA\u63A8\u8350\u9879\uFF08recommended\uFF09\uFF1B\u98CE\u683C\u9898\u4F18\u5148\u7528 thumbnail \u7F29\u7565\u56FE\uFF08theme:\u2026 / page:\u2026 / doc:\u2026\uFF09\uFF0C\u914D\u8272\u7528 swatch\u3002"),e("\u7528\u6237\u8DF3\u8FC7\u65F6\u6309\u63A8\u8350\u9879\u7EE7\u7EED\uFF0C\u5E76\u5728\u56DE\u590D\u91CC\u7528\u4E00\u53E5\u8BDD\u8BF4\u660E\u7528\u4E86\u54EA\u4E9B\u63A8\u8350\u9879\u3002")],parameters:x,execute:d(async(t,u,o,l,A)=>{let r;try{r=I(u,A.cwd,v)}catch(b){throw b instanceof _?new Error(`ask_user: ${b.message}`):b}const E=await F.post("/api/internal/pi-bridge/ask-user",{...B(A),...r},{timeoutMs:N()});if(!E||E.cancelled)return{content:[{type:"text",text:"User did not answer. Stop and wait for further instructions."}],details:{answered:!1,request:r}};const{text:w,skipped:h}=T(r,E);return{content:[{type:"text",text:w}],details:{answered:!0,answers:E.answers??{},...E.structured?{structured:E.structured}:{},...E.summary?{summary:E.summary}:{},skipped:h,request:r}}},"execute")})}c(k,"F"),d(k,"default");export{k as default};
1
+ var M=Object.defineProperty;var D=(r,c)=>M(r,"name",{value:c,configurable:!0});var $=Object.defineProperty,i=D((r,c)=>$(r,"name",{value:c,configurable:!0}),"d");import{t}from"@dalcode/dal-pi-kit";import{registerPermissionAskHandler as H,registerSandboxEscalationHandler as R}from"@earendil-works/pi-coding-agent";import{Type as l}from"typebox";import{AskUserInputError as q,askUserSchema as j,buildAskUserRequest as V,describeAnswers as G,THUMBNAIL_CHANNEL as z}from"./ask-user.js";import{askUserTimeoutMs as J,BridgeClient as K,planTimeoutMs as Q,readBridgeConfig as W,readSubagentAttribution as X}from"./client.js";const Y=l.Object({goal:l.String({description:t("\u8FD9\u4E2A\u8BA1\u5212\u8981\u8FBE\u6210\u4EC0\u4E48\uFF0C\u4E00\u53E5\u8BDD\u8BF4\u660E")}),reasoning:l.Optional(l.String({description:t("\u4E3A\u4EC0\u4E48\u9009\u8FD9\u4E2A\u65B9\u6848")})),steps:l.Array(l.Object({title:l.String({description:t("\u8FD9\u4E00\u6B65\u505A\u4EC0\u4E48")}),description:l.Optional(l.String({description:t("\u8FD9\u4E00\u6B65\u7684\u7EC6\u8282")}))}),{description:t("\u6309\u987A\u5E8F\u6392\u5217\u7684\u6267\u884C\u6B65\u9AA4")})}),Z=new Set(["read","grep","ripgrep","find","fd","ls","glob","todo_read","todo","lsp","terminal_read","review_report"]),uu=new Set(["read","grep","ripgrep","find","fd","ls","glob","lsp"]),I="DALCODE_BRIDGE_EVALUATE_READ_TOOLS",eu="submit_plan",h="ask_user";function _(r){return r.scope==="session"?"session":"once"}D(_,"R"),i(_,"escalationScope");function k(r){const c=r.input;for(const C of["command","file_path","path","filePath"]){const F=c[C];if(typeof F=="string"&&F.length>0)return F}}D(k,"T"),i(k,"ruleContentFor");let B,x=!1,g,T=!1;function N(r,c){const C=W();if(!C)return;const F=new K(C,c),d=X();function A(u){const e=u.sessionManager.getSessionId();return d?{sessionId:d.parentSessionId,subagent:{id:d.subagentId,sessionId:e,...d.parentTaskId?{parentTaskId:d.parentTaskId}:{},...d.parentSubagentId?{parentSubagentId:d.parentSubagentId}:{},...d.label?{label:d.label}:{}}}:{sessionId:e}}D(A,"f"),i(A,"caller");let p,b=0;function f(u){const e=u.model;return{provider:e?.provider??"unknown",model:e?.id??e?.name??"unknown"}}D(f,"w"),i(f,"describeModel");const v=new Map,m=new Set,P=process.env[I]==="1";r.on("tool_call",async(u,e)=>{const o=uu.has(u.toolName);if((o?!P:Z.has(u.toolName))||u.toolName===eu||u.toolName===h)return;const s=u.input.sandbox_escalation,a=await F.post("/api/internal/pi-bridge/permission",{...A(e),toolName:u.toolName,toolInput:u.input,ruleContent:k(u),...s?{category:"sandbox_escalation"}:{},...o?{readOnly:!0}:{}});if(!a)return{block:!0,reason:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")};if(a.decision==="deny")return{block:!0,reason:a.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")};s&&v.set(u.toolCallId,_(a)),m.add(u.toolCallId),m.size>1e3&&m.delete(m.values().next().value)});const y=i(async(u,e)=>{if(m.delete(u.toolCallId))return{approved:!0};const o=await F.post("/api/internal/pi-bridge/permission",{...A(e),toolName:u.toolName,toolInput:u.input,ruleContent:k({input:u.input}),category:"permission_rule",rule:u.rule,ruleSource:u.source});return o?o.decision==="allow"?{approved:!0}:{approved:!1,message:o.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveRule");g=y,T||(H((u,e)=>g?.(u,e)),T=!0);const S=i(async(u,e)=>{const o=v.get(u.toolCallId);if(o)return v.delete(u.toolCallId),{approved:!0,scope:o};if(!e)return;const s=await F.post("/api/internal/pi-bridge/permission",{...A(e),toolName:u.toolName,toolInput:{command:u.command},ruleContent:u.command,category:"sandbox_escalation",sandboxEscalation:u});return s?s.decision==="allow"?{approved:!0,scope:_(s)}:{approved:!1,message:s.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveEscalation");B=S,x||(R((u,e)=>B?.(u,e)),x=!0),r.on("session_shutdown",()=>{B===S&&(B=void 0),g===y&&(g=void 0)}),r.on("after_provider_response",(u,e)=>{u.status>=400?p={...f(e),reason:`HTTP ${u.status}`}:(p=void 0,b=0)}),r.on("before_provider_request",async(u,e)=>{if(!p)return;const o=f(e);if(o.provider===p.provider&&o.model===p.model)return;b+=1;const s={provider:p.provider,model:p.model},a=p.reason;p=void 0,await F.post("/api/internal/pi-bridge/provider-fallback",{...A(e),from:s,to:o,reason:a,attempt:b,blocked:!0});const n=new Error(t("dal-bridge\uFF1A\u8BF7\u6C42\u5931\u8D25\u540E\u4E0D\u5141\u8BB8\u81EA\u52A8\u6362\u6A21\u578B\u3002")+` ${s.provider}/${s.model} \u2192 ${o.provider}/${o.model} (${a})`);throw n.name="ProviderSwapAborted",n}),r.registerTool({name:"submit_plan",label:t("\u63D0\u4EA4\u8BA1\u5212\u5F85\u5BA1\u6279"),description:t(t("\u5728\u52A8\u624B\u6539\u52A8\u4E4B\u524D\uFF0C\u628A\u8BA1\u5212\u63D0\u4EA4\u7ED9\u7528\u6237\u5BA1\u6279\u3002\u8FD4\u56DE\u662F\u5426\u7EE7\u7EED\u6267\u884C\uFF0C\u4EE5\u53CA\u7528\u6237\u7ED9\u51FA\u7684\u53CD\u9988\u3002")+t("\u5F53\u4EFB\u52A1\u662F\u591A\u6B65\u9AA4\u7684\u3001\u6216\u4F1A\u6539\u52A8\u591A\u4E2A\u6587\u4EF6\u65F6\u4F7F\u7528\u3002")),promptSnippet:t("submit_plan - \u591A\u6B65\u9AA4\u4EFB\u52A1\u52A8\u624B\u524D\u5148\u63D0\u4EA4\u8BA1\u5212\u5F85\u7528\u6237\u5BA1\u6279"),parameters:Y,execute:i(async(u,e,o,s,a)=>{const n=await F.post("/api/internal/pi-bridge/plan",{...A(a),goal:e.goal,reasoning:e.reasoning,steps:e.steps},{timeoutMs:Q()});return!n||n.decision==="cancel"?{content:[{type:"text",text:n?.feedback?`Plan not approved. User feedback: ${n.feedback}`:"Plan not approved. Stop and wait for further instructions."}],details:{approved:!1,...n?.feedback?{feedback:n.feedback}:{}}}:{content:[{type:"text",text:"Plan approved. Proceed with the steps."}],details:{approved:!0}}},"execute")});const L=i((u,e)=>{let o;return r.events.emit(z,{ref:u,...e!==void 0?{title:e}:{},reply:i(s=>{o=s},"reply")}),o},"resolveThumbnail");r.registerTool({name:h,label:t("\u8BE2\u95EE\u7528\u6237"),description:t("\u52A8\u624B\u505A PPT\u3001\u6587\u6863\u3001\u8868\u683C\u3001\u9875\u9762\u4E4B\u524D\uFF0C\u7528\u4E00\u5F20\u5361\u7247\u5411\u7528\u6237\u786E\u8BA4\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF09\u3002\u9898\u578B\uFF1Achoice \u9009\u9879\uFF08\u53EF\u5E26\u7F29\u7565\u56FE\uFF09\u3001swatch \u914D\u8272\u3001outline \u53EF\u6392\u5E8F\u5927\u7EB2\u3001slider \u6570\u503C\u3001text \u81EA\u7531\u6587\u672C\u3002\u6BCF\u9898\u90FD\u8981\u6709\u63A8\u8350\u9879\u3002"),promptSnippet:t("ask_user - \u5F00\u5DE5\u524D\u7528\u4E00\u5F20\u5361\u7247\u786E\u8BA4\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF0C\u6BCF\u9898\u6709\u63A8\u8350\u9879\uFF09"),promptGuidelines:[t("ask_user \u53EA\u5728\u5F00\u5DE5\u524D\u95EE\u4E00\u6B21\uFF0C\u4E00\u8F6E\u6700\u591A 3 \u9898\uFF1B\u540C\u4E00\u4EFB\u52A1\u4E4B\u540E\u4E0D\u518D\u8FFD\u95EE\uFF0C\u9664\u975E\u7528\u6237\u4E3B\u52A8\u8981\u6C42\u3002"),t("\u53EA\u95EE\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u51B3\u5B9A\uFF08\u53D7\u4F17/\u7528\u9014\u3001\u98CE\u683C\u6216\u4E3B\u9898\u3001\u7BC7\u5E45\u3001\u5927\u7EB2\u987A\u5E8F\uFF09\uFF1B\u80FD\u4ECE\u7528\u6237\u539F\u8BDD\u3001\u9644\u4EF6\u6216\u9879\u76EE\u6587\u4EF6\u63A8\u65AD\u51FA\u7684\u4E0D\u95EE\u3002"),t("\u7528\u6237\u8BF4\u4E86\u300C\u76F4\u63A5\u505A / \u4F60\u51B3\u5B9A / \u5FEB\u901F\u51FA\u4E00\u7248\u300D\uFF0C\u6216\u662F\u5728\u4FEE\u6539\u5DF2\u6709\u6587\u4EF6\uFF08\u5E26\u5B9A\u4F4D\u3001\u300C\u628A\u7B2C 3 \u9875\u6539\u6210\u2026\u300D\uFF09\u65F6\uFF0C\u4E0D\u8981\u8C03\u7528 ask_user\u3002"),t("\u6BCF\u9898\u90FD\u6807\u51FA\u63A8\u8350\u9879\uFF08recommended\uFF09\uFF1B\u98CE\u683C\u9898\u4F18\u5148\u7528 thumbnail \u7F29\u7565\u56FE\uFF08theme:\u2026 / page:\u2026 / doc:\u2026\uFF09\uFF0C\u914D\u8272\u7528 swatch\u3002"),t("\u7528\u6237\u8DF3\u8FC7\u65F6\u6309\u63A8\u8350\u9879\u7EE7\u7EED\uFF0C\u5E76\u5728\u56DE\u590D\u91CC\u7528\u4E00\u53E5\u8BDD\u8BF4\u660E\u7528\u4E86\u54EA\u4E9B\u63A8\u8350\u9879\u3002")],parameters:j,execute:i(async(u,e,o,s,a)=>{let n;try{n=V(e,a.cwd,L)}catch(w){throw w instanceof q?new Error(`ask_user: ${w.message}`):w}const E=await F.post("/api/internal/pi-bridge/ask-user",{...A(a),...n},{timeoutMs:J()});if(!E||E.cancelled)return{content:[{type:"text",text:"User did not answer. Stop and wait for further instructions."}],details:{answered:!1,request:n}};const{text:O,skipped:U}=G(n,E);return{content:[{type:"text",text:O}],details:{answered:!0,answers:E.answers??{},...E.structured?{structured:E.structured}:{},...E.summary?{summary:E.summary}:{},skipped:U,request:n}}},"execute")})}D(N,"q"),i(N,"default");export{I as EVALUATE_READS_ENV,N as default};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-gateway",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/deepailab": "1.0.25"
20
+ "@dalcode/deepailab": "1.0.27"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-guard",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,9 +18,9 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.25",
22
- "@dalcode/dal-bridge": "1.0.25",
23
- "@dalcode/dal-halo": "1.0.25"
21
+ "@dalcode/dal-pi-kit": "1.0.27",
22
+ "@dalcode/dal-bridge": "1.0.27",
23
+ "@dalcode/dal-halo": "1.0.27"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-halo",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mario Zechner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@dalcode/dal-interactive",
3
+ "version": "1.0.27",
4
+ "private": true,
5
+ "description": "Terminal-UI conveniences adopted from pi's example extensions: the questionnaire tool (the model asks you questions), /handoff (carry context into a new session) and interactive ! commands (vim, git rebase -i, htop). Active only in the TUI; stands down under DAL Code.",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./src/index.js",
9
+ "exports": {
10
+ ".": "./src/index.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "src"
15
+ ],
16
+ "pi": {
17
+ "extensions": [
18
+ "./src/index.js"
19
+ ]
20
+ },
21
+ "dependencies": {
22
+ "@dalcode/dal-pi-kit": "1.0.27",
23
+ "typebox": "1.3.7"
24
+ },
25
+ "peerDependencies": {
26
+ "@earendil-works/pi-coding-agent": "^1.0.9"
27
+ },
28
+ "peerDependenciesMeta": {
29
+ "@earendil-works/pi-coding-agent": {
30
+ "optional": false
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,28 @@
1
+ var w=Object.defineProperty;var a=(e,o)=>w(e,"name",{value:o,configurable:!0});var x=Object.defineProperty,r=a((e,o)=>x(e,"name",{value:o,configurable:!0}),"i");import{t as n}from"@dalcode/dal-pi-kit";import{uuidv7 as C}from"@earendil-works/pi-ai";import{BorderedLoader as b,convertToLlm as k,serializeConversation as S}from"@earendil-works/pi-coding-agent";const T=`You are a context transfer assistant. Given a conversation history and the user's goal for a new thread, generate a focused prompt that:
2
+
3
+ 1. Summarizes relevant context from the conversation (decisions made, approaches taken, key findings)
4
+ 2. Lists any relevant files that were discussed or modified
5
+ 3. Clearly states the next task based on the user's goal
6
+ 4. Is self-contained - the new thread should be able to proceed without the old conversation
7
+
8
+ Format your response as a prompt the user can send to start the new thread. Be concise but include all necessary context. Do not include any preamble like "Here's the prompt" - just output the prompt itself.
9
+
10
+ Example output format:
11
+ ## Context
12
+ We've been working on X. Key decisions:
13
+ - Decision 1
14
+ - Decision 2
15
+
16
+ Files involved:
17
+ - path/to/file1.ts
18
+ - path/to/file2.ts
19
+
20
+ ## Task
21
+ [Clear description of what to do next based on user's goal]`;function m(e){if(e.type==="message")return e.message;if(e.type==="compaction")return{role:"compactionSummary",summary:e.summary,tokensBefore:e.tokensBefore,timestamp:new Date(e.timestamp).getTime()}}a(m,"h"),r(m,"entryToMessage");function p(e){let o=-1;for(let u=e.length-1;u>=0;u--)if(e[u].type==="compaction"){o=u;break}if(o<0)return e.map(m).filter(u=>u!==void 0);const s=e[o],t=s.type==="compaction"?e.findIndex(u=>u.id===s.firstKeptEntryId):-1;return[s,...t>=0?e.slice(t,o):[],...e.slice(o+1)].map(m).filter(u=>u!==void 0)}a(p,"B"),r(p,"getHandoffMessages");function g(e,o){e.registerCommand("handoff",{description:n("\u628A\u5F53\u524D\u8FDB\u5C55\u4EA4\u63A5\u5230\u4E00\u4E2A\u65B0\u4F1A\u8BDD\uFF1A\u751F\u6210\u53EF\u7F16\u8F91\u7684\u4EA4\u63A5\u63D0\u793A"),handler:r(async(s,t)=>{if(t.mode!=="tui"){t.ui.notify(n("/handoff \u53EA\u80FD\u5728\u7EC8\u7AEF\u754C\u9762\u4E2D\u4F7F\u7528"),"error");return}if(!t.model){t.ui.notify(n("\u8FD8\u6CA1\u6709\u9009\u62E9\u6A21\u578B"),"error");return}const u=s.trim();if(!u){t.ui.notify(n("\u7528\u6CD5\uFF1A/handoff <\u65B0\u4F1A\u8BDD\u8981\u505A\u7684\u4E8B>"),"error");return}const A=p(t.sessionManager.getBranch());if(A.length===0){t.ui.notify(n("\u8FD8\u6CA1\u6709\u53EF\u4EA4\u63A5\u7684\u5BF9\u8BDD"),"error");return}const E=k(A),F=S(E),v=t.sessionManager.getSessionFile(),h=await t.ui.custom((f,B,H,l)=>{const c=new b(f,B,n("\u6B63\u5728\u751F\u6210\u4EA4\u63A5\u63D0\u793A\u2026"));return c.onAbort=()=>l(null),r(async()=>{if(o)return o(F,u,c.signal);const i={role:"user",content:[{type:"text",text:`## Conversation History
22
+
23
+ ${F}
24
+
25
+ ## User's Goal for New Thread
26
+
27
+ ${u}`}],timestamp:Date.now()},D=await t.modelRegistry.complete(t.model,{systemPrompt:T,messages:[i]},{signal:c.signal,cacheRetention:"none",sessionId:C()});return D.stopReason==="aborted"?null:D.content.filter(d=>d.type==="text").map(d=>d.text).join(`
28
+ `)},"doGenerate")().then(l).catch(i=>{t.ui.notify(`${n("\u751F\u6210\u4EA4\u63A5\u63D0\u793A\u5931\u8D25\uFF1A")}${i instanceof Error?i.message:String(i)}`,"error"),l(null)}),c});if(h===null){t.ui.notify(n("\u5DF2\u53D6\u6D88"),"info");return}const y=await t.ui.editor(n("\u7F16\u8F91\u4EA4\u63A5\u63D0\u793A"),h);if(y===void 0){t.ui.notify(n("\u5DF2\u53D6\u6D88"),"info");return}(await t.newSession({parentSession:v,withSession:r(async f=>{f.ui.setEditorText(y),f.ui.notify(n("\u4EA4\u63A5\u63D0\u793A\u5DF2\u653E\u8FDB\u8F93\u5165\u6846\uFF0C\u786E\u8BA4\u540E\u53D1\u9001\u3002"),"info")},"withSession")})).cancelled&&t.ui.notify(n("\u6CA1\u6709\u65B0\u5EFA\u4F1A\u8BDD"),"info")},"handler")})}a(g,"D"),r(g,"registerHandoff");export{p as getHandoffMessages,g as registerHandoff};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});var l=Object.defineProperty,a=t((e,r)=>l(e,"name",{value:r,configurable:!0}),"t");import{registerHandoff as d}from"./handoff.js";import{registerInteractiveShell as g}from"./interactive-shell.js";import{QUESTIONNAIRE_TOOL as i,registerQuestionnaire as I}from"./questionnaire.js";import{getHandoffMessages as u,registerHandoff as O}from"./handoff.js";import{isInteractiveCommand as v,registerInteractiveShell as p}from"./interactive-shell.js";import{QUESTIONNAIRE_TOOL as E,registerQuestionnaire as T}from"./questionnaire.js";function o(e=process.env){return!!(e.DALCODE_BRIDGE_URL&&e.DALCODE_BRIDGE_TOKEN)}t(o,"l"),a(o,"underDalCodeDesktop");function n(e){o()||(I(e),d(e),g(e),e.on("session_start",async(r,f)=>{if(f.mode==="tui")return;const s=e.getActiveTools();s.includes(i)&&e.setActiveTools(s.filter(m=>m!==i))}))}t(n,"m"),a(n,"dalInteractive");export{E as QUESTIONNAIRE_TOOL,n as default,u as getHandoffMessages,v as isInteractiveCommand,O as registerHandoff,p as registerInteractiveShell,T as registerQuestionnaire};
@@ -0,0 +1 @@
1
+ var F=Object.defineProperty;var n=(i,t)=>F(i,"name",{value:t,configurable:!0});var f=Object.defineProperty,c=n((i,t)=>f(i,"name",{value:t,configurable:!0}),"n");import{spawnSync as E}from"node:child_process";import{t as a}from"@dalcode/dal-pi-kit";import{getShellEnv as v}from"@earendil-works/pi-coding-agent";const C=["vim","nvim","vi","nano","emacs","pico","micro","helix","hx","kak","less","more","most","git commit","git rebase","git merge","git cherry-pick","git revert","git add -p","git add --patch","git add -i","git add --interactive","git stash -p","git stash --patch","git reset -p","git reset --patch","git checkout -p","git checkout --patch","git difftool","git mergetool","htop","top","btop","glances","ranger","nnn","lf","mc","vifm","tig","lazygit","gitui","fzf","sk","ssh","telnet","mosh","psql","mysql","sqlite3","mongosh","redis-cli","kubectl edit","kubectl exec -it","docker exec -it","docker run -it","tmux","screen","ncdu"];function m(){const i=process.env.INTERACTIVE_COMMANDS?.split(",").map(e=>e.trim()).filter(Boolean)??[],t=new Set(process.env.INTERACTIVE_EXCLUDE?.split(",").map(e=>e.trim().toLowerCase())??[]);return[...C,...i].filter(e=>!t.has(e.toLowerCase()))}n(m,"v"),c(m,"getInteractiveCommands");function l(i){const t=i.trim().toLowerCase(),e=m();for(const r of e){const s=r.toLowerCase();if(t===s||t.startsWith(`${s} `)||t.startsWith(`${s} `))return!0;const u=t.lastIndexOf("|");if(u!==-1){const o=t.slice(u+1).trim();if(o===s||o.startsWith(`${s} `))return!0}}return!1}n(l,"I"),c(l,"isInteractiveCommand");function d(i){i.on("user_bash",async(t,e)=>{let r=t.command,s=!1;if((r.startsWith("i ")||r.startsWith("i "))&&(s=!0,r=r.slice(2).trim()),!(s||l(r)))return;if(e.mode!=="tui")return{result:{output:a("\uFF08\u4EA4\u4E92\u5F0F\u547D\u4EE4\u53EA\u80FD\u5728\u7EC8\u7AEF\u754C\u9762\u4E2D\u8FD0\u884C\uFF09"),exitCode:1,cancelled:!1,truncated:!1}};const u=await e.ui.custom((o,x,A,p)=>{o.stop(),process.stdout.write("\x1B[2J\x1B[H");const g=process.env.SHELL||"/bin/sh",h=E(g,["-c",r],{stdio:"inherit",cwd:e.cwd,env:v()});return o.start(),o.requestRender(!0),p(h.status),{render:c(()=>[],"render"),invalidate:c(()=>{},"invalidate")}});return{result:{output:u===0?a("\uFF08\u4EA4\u4E92\u5F0F\u547D\u4EE4\u5DF2\u5B8C\u6210\uFF09"):a("\uFF08\u4EA4\u4E92\u5F0F\u547D\u4EE4\u9000\u51FA\uFF0C\u9000\u51FA\u7801 {code}\uFF09").replace("{code}",String(u)),exitCode:u??1,cancelled:!1,truncated:!1}}})}n(d,"A"),c(d,"registerInteractiveShell");export{l as isInteractiveCommand,d as registerInteractiveShell};
@@ -0,0 +1,3 @@
1
+ var ae=Object.defineProperty;var l=(T,h)=>ae(T,"name",{value:h,configurable:!0});var ce=Object.defineProperty,s=l((T,h)=>ce(T,"name",{value:h,configurable:!0}),"s");import{t as a}from"@dalcode/dal-pi-kit";import{Editor as fe,Key as b,matchesKey as E,Text as R,visibleWidth as de,wrapTextWithAnsi as ee}from"@earendil-works/pi-tui";import{Type as c}from"typebox";const pe=c.Object({value:c.String({description:"The value returned when selected"}),label:c.String({description:"Display label for the option"}),description:c.Optional(c.String({description:"Optional description shown below label"}))}),ge=c.Object({id:c.String({description:"Unique identifier for this question"}),label:c.Optional(c.String({description:"Short contextual label for tab bar, e.g. 'Scope', 'Priority' (defaults to Q1, Q2)"})),prompt:c.String({description:"The full question text to display"}),options:c.Array(pe,{description:"Available options to choose from"}),allowOther:c.Optional(c.Boolean({description:"Allow 'Type something' option (default: true)"}))}),he=c.Object({questions:c.Array(ge,{description:"Questions to ask the user"})});function z(T,h=[]){return{content:[{type:"text",text:T}],details:{questions:h,answers:[],cancelled:!0}}}l(z,"V"),s(z,"errorResult");const te="questionnaire";function ne(T){T.registerTool({name:te,label:a("\u95EE\u5377"),description:"Ask the user one or more questions. Use for clarifying requirements, getting preferences, or confirming decisions. For single questions, shows a simple option list. For multiple questions, shows a tab-based interface.",promptSnippet:"questionnaire - ask the user multiple-choice questions when a decision is theirs to make",promptGuidelines:["Use questionnaire only for decisions you cannot infer from the request or the code; give 2-5 concrete options per question."],parameters:he,async execute(h,v,O,Q,q){if(q.mode!=="tui")return z("Error: UI not available (running in non-interactive mode)");if(v.questions.length===0)return z("Error: No questions provided");const r=v.questions.map((f,t)=>({...f,label:f.label||`Q${t+1}`,allowOther:f.allowOther!==!1})),u=r.length>1,D=r.length+1,U=await q.ui.custom((f,t,H,ie)=>{let p=0,$=0,y=!1,S=null,C;const j=new Map,re={borderColor:s(e=>t.fg("accent",e),"borderColor"),selectList:{selectedPrefix:s(e=>t.fg("accent",e),"selectedPrefix"),selectedText:s(e=>t.fg("accent",e),"selectedText"),description:s(e=>t.fg("muted",e),"description"),scrollInfo:s(e=>t.fg("dim",e),"scrollInfo"),noMatch:s(e=>t.fg("warning",e),"noMatch")}},B=new fe(f,re);function F(){C=void 0,f.requestRender()}l(F,"A"),s(F,"refresh");function M(e){ie({questions:r,answers:Array.from(j.values()),cancelled:e})}l(M,"P"),s(M,"submit");function P(){return r[p]}l(P,"k"),s(P,"currentQuestion");function _(){const e=P();if(!e)return[];const n=[...e.options];return e.allowOther&&n.push({value:"__other__",label:a("\u81EA\u5DF1\u8F93\u5165\u2026"),isOther:!0}),n}l(_,"F"),s(_,"currentOptions");function W(){return r.every(e=>j.has(e.id))}l(W,"L"),s(W,"allAnswered");function N(){if(!u){M(!1);return}p<r.length-1?p++:p=r.length,$=0,F()}l(N,"K"),s(N,"advanceAfterAnswer");function K(e,n,m,x,k){j.set(e,{id:e,value:n,label:m,wasCustom:x,index:k})}l(K,"D"),s(K,"saveAnswer"),B.onSubmit=e=>{if(!S)return;const n=e.trim()||a("\uFF08\u672A\u4F5C\u7B54\uFF09");K(S,n,n,!0),y=!1,S=null,B.setText(""),N()};function J(e){if(y){if(E(e,b.escape)){y=!1,S=null,B.setText(""),F();return}B.handleInput(e),F();return}const n=P(),m=_();if(u){if(E(e,b.tab)||E(e,b.right)){p=(p+1)%D,$=0,F();return}if(E(e,b.shift("tab"))||E(e,b.left)){p=(p-1+D)%D,$=0,F();return}}if(p===r.length){E(e,b.enter)&&W()?M(!1):E(e,b.escape)&&M(!0);return}if(E(e,b.up)){$=Math.max(0,$-1),F();return}if(E(e,b.down)){$=Math.min(m.length-1,$+1),F();return}if(E(e,b.enter)&&n){const x=m[$];if(x.isOther){y=!0,S=n.id,B.setText(""),F();return}K(n.id,x.value,x.label,!1,$+1),N();return}E(e,b.escape)&&M(!0)}l(J,"Z"),s(J,"handleInput");function V(e){if(C)return C;const n=[],m=Math.max(1,e),x=P(),k=_();function Y(i){n.push(...ee(i,m))}l(Y,"te"),s(Y,"addWrapped");function d(i,o){const w=de(i);if(w>=m){Y(i+o);return}const A=ee(o,m-w),I=" ".repeat(w);for(let g=0;g<A.length;g++)n.push(`${g===0?i:I}${A[g]}`)}if(l(d,"d"),s(d,"addWrappedWithPrefix"),n.push(t.fg("accent","\u2500".repeat(m))),u){const i=["\u2190 "];for(let g=0;g<r.length;g++){const G=g===p,Z=j.has(r[g].id),se=r[g].label,ue=Z?"\u25A0":"\u25A1",oe=Z?"success":"muted",X=` ${ue} ${se} `,le=G?t.bg("selectedBg",t.fg("text",X)):t.fg(oe,X);i.push(`${le} `)}const o=W(),w=p===r.length,A=` \u2713 ${a("\u63D0\u4EA4")} `,I=w?t.bg("selectedBg",t.fg("text",A)):t.fg(o?"success":"dim",A);i.push(`${I} \u2192`),d(" ",i.join("")),n.push("")}function L(){for(let i=0;i<k.length;i++){const o=k[i],w=i===$,A=o.isOther===!0,I=w?t.fg("accent","> "):" ",g=`${i+1}. ${o.label}${A&&y?" \u270E":""}`,G=w||A&&y?"accent":"text";d(I,t.fg(G,g)),o.description&&d(" ",t.fg("muted",o.description))}}if(l(L,"G"),s(L,"renderOptions"),y&&x){d(" ",t.fg("text",x.prompt)),n.push(""),L(),n.push(""),d(" ",t.fg("muted",a("\u4F60\u7684\u56DE\u7B54\uFF1A")));for(const i of B.render(Math.max(1,m-2)))n.push(` ${i}`);n.push(""),d(" ",t.fg("dim",a("Enter \u63D0\u4EA4 \u2022 Esc \u53D6\u6D88")))}else if(p===r.length){d(" ",t.fg("accent",t.bold(a("\u53EF\u4EE5\u63D0\u4EA4\u4E86")))),n.push("");for(const i of r){const o=j.get(i.id);if(o){const w=o.wasCustom?a("\uFF08\u81EA\u586B\uFF09"):"",A=`${t.fg("muted",`${i.label}: `)}${t.fg("text",w+o.label)}`;d(" ",A)}}if(n.push(""),W())d(" ",t.fg("success",a("\u6309 Enter \u63D0\u4EA4")));else{const i=r.filter(o=>!j.has(o.id)).map(o=>o.label).join(", ");d(" ",t.fg("warning",`${a("\u8FD8\u6CA1\u56DE\u7B54\uFF1A")}${i}`))}}else x&&(d(" ",t.fg("text",x.prompt)),n.push(""),L());if(n.push(""),!y){const i=u?a("Tab/\u2190\u2192 \u5207\u6362\u95EE\u9898 \u2022 \u2191\u2193 \u9009\u62E9 \u2022 Enter \u786E\u8BA4 \u2022 Esc \u53D6\u6D88"):a("\u2191\u2193 \u9009\u62E9 \u2022 Enter \u786E\u8BA4 \u2022 Esc \u53D6\u6D88");d(" ",t.fg("dim",i))}return n.push(t.fg("accent","\u2500".repeat(m))),C=n,n}return l(V,"ee"),s(V,"render"),{render:V,invalidate:s(()=>{C=void 0},"invalidate"),handleInput:J}});return U.cancelled?{content:[{type:"text",text:"User cancelled the questionnaire"}],details:U}:{content:[{type:"text",text:U.answers.map(f=>{const t=r.find(H=>H.id===f.id)?.label||f.id;return f.wasCustom?`${t}: user wrote: ${f.label}`:`${t}: user selected: ${f.index}. ${f.label}`}).join(`
2
+ `)}],details:U}},renderCall(h,v,O){const Q=h.questions||[],q=Q.length,r=Q.map(D=>D.label||D.id).join(", ");let u=v.fg("toolTitle",v.bold(`${a("\u95EE\u5377")} `));return u+=v.fg("muted",`${q} ${a("\u4E2A\u95EE\u9898")}`),r&&(u+=v.fg("dim",` (${r})`)),new R(u,0,0)},renderResult(h,v,O,Q){const q=h.details;if(!q){const u=h.content[0];return new R(u?.type==="text"?u.text:"",0,0)}if(q.cancelled)return new R(O.fg("warning",a("\u5DF2\u53D6\u6D88")),0,0);const r=q.answers.map(u=>{if(u.wasCustom)return`${O.fg("success","\u2713 ")}${O.fg("accent",u.id)}: ${O.fg("muted",a("\uFF08\u81EA\u586B\uFF09"))}${u.label}`;const D=u.index?`${u.index}. ${u.label}`:u.label;return`${O.fg("success","\u2713 ")}${O.fg("accent",u.id)}: ${D}`});return new R(r.join(`
3
+ `),0,0)}})}l(ne,"xe"),s(ne,"registerQuestionnaire");export{te as QUESTIONNAIRE_TOOL,ne as registerQuestionnaire};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lang",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,8 +17,8 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.25",
21
- "@dalcode/dal-bridge": "1.0.25"
20
+ "@dalcode/dal-pi-kit": "1.0.27",
21
+ "@dalcode/dal-bridge": "1.0.27"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lsp",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -19,8 +19,8 @@
19
19
  ]
20
20
  },
21
21
  "dependencies": {
22
- "@dalcode/dal-bridge": "1.0.25",
23
- "@dalcode/dal-pi-kit": "1.0.25",
22
+ "@dalcode/dal-bridge": "1.0.27",
23
+ "@dalcode/dal-pi-kit": "1.0.27",
24
24
  "cross-spawn": "7.0.6",
25
25
  "typebox": "1.3.7"
26
26
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-mcp",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -26,10 +26,10 @@
26
26
  ]
27
27
  },
28
28
  "dependencies": {
29
- "@dalcode/dal-bridge": "1.0.25",
30
- "@dalcode/dal-guard": "1.0.25",
31
- "@dalcode/dal-pi-kit": "1.0.25",
32
- "@dalcode/deepailab": "1.0.25",
29
+ "@dalcode/dal-bridge": "1.0.27",
30
+ "@dalcode/dal-guard": "1.0.27",
31
+ "@dalcode/dal-pi-kit": "1.0.27",
32
+ "@dalcode/deepailab": "1.0.27",
33
33
  "cross-spawn": "7.0.6"
34
34
  },
35
35
  "peerDependencies": {
@@ -1,2 +1,2 @@
1
- var w=Object.defineProperty;var c=(u,n)=>w(u,"name",{value:n,configurable:!0});var L=Object.defineProperty,E=c((u,n)=>L(u,"name",{value:n,configurable:!0}),"u");import{t as r}from"@dalcode/dal-pi-kit";import{assertValidName as j,tokenizeCommandArgs as v}from"./command-parser.js";const U=r("stdio\uFF08\u672C\u5730\u547D\u4EE4\uFF09"),C=r("http\uFF08\u8FDC\u7A0B URL\uFF09"),O=r("\u7528\u6237\u7EA7 ~/.dal/agent/mcp.json\uFF08\u672C\u673A\u6240\u6709\u9879\u76EE\u53EF\u7528\uFF09"),D=r("\u9879\u76EE\u7EA7 .dal/mcp.json\uFF08\u4EC5\u5F53\u524D\u9879\u76EE\uFF0C\u9700\u5DF2\u4FE1\u4EFB\uFF09");async function m(u,n,i){for(;;){const t=await u.input(n);if(t===void 0)return;const F=i(t);if(F===void 0)return t;u.notify(F,"error")}}c(m,"m"),E(m,"askValid");function y(u){const n={};for(const i of u.split(/[,,]/)){const t=i.trim();if(!t)continue;const F=t.indexOf("=");if(F===-1||!t.slice(0,F).trim())return{ok:!1,error:`${r("\u65E0\u6548\u7684\u73AF\u5883\u53D8\u91CF\u683C\u5F0F\uFF08KEY=VALUE\uFF09\uFF1A")}${t}`};n[t.slice(0,F).trim()]=t.slice(F+1).trim()}return{ok:!0,value:n}}c(y,"U"),E(y,"parseEnvList");function B(u){const n={};for(const i of u.split(/[,,]/)){const t=i.trim();if(!t)continue;const F=t.indexOf(":");if(F===-1||!t.slice(0,F).trim())return{ok:!1,error:`${r("\u65E0\u6548\u7684\u8BF7\u6C42\u5934\u683C\u5F0F\uFF08Key: Value\uFF09\uFF1A")}${t}`};n[t.slice(0,F).trim()]=t.slice(F+1).trim()}return{ok:!0,value:n}}c(B,"$"),E(B,"parseHeaderList");async function g(u,n){const i=await u.select(r("\u8981\u6DFB\u52A0\u7684 MCP \u670D\u52A1\u5668\u7C7B\u578B\uFF1A"),[U,C]);if(i===void 0)return;const t=i===C,F=await m(u,r("\u670D\u52A1\u5668\u540D\u79F0\uFF08\u4EC5\u5B57\u6BCD\u3001\u6570\u5B57\u3001-\u3001_\uFF09\uFF1A"),s=>{try{j(s.trim());return}catch(o){return o instanceof Error?o.message:String(o)}});if(F===void 0)return;let l;if(t){const s=await m(u,r("\u670D\u52A1\u5668 URL\uFF08http(s)://\u2026\uFF09\uFF1A"),e=>{let f;try{f=new URL(e.trim())}catch{return`${r("URL \u65E0\u6548\uFF1A")}${e.trim()}`}if(f.protocol!=="http:"&&f.protocol!=="https:")return`${r("URL \u4EC5\u652F\u6301 http(s)\uFF1A")}${e.trim()}`});if(s===void 0)return;const o=await u.input(r("\u8BF7\u6C42\u5934\uFF08\u53EF\u9009\uFF0C\u9017\u53F7\u5206\u9694 Key: Value\uFF09\uFF1A"));if(o===void 0)return;const a=B(o);if(!a.ok){u.notify(a.error,"error");return}l={url:s.trim(),...Object.keys(a.value).length>0?{headers:a.value}:{}}}else{const s=await m(u,r("\u542F\u52A8\u547D\u4EE4\uFF08\u542B\u53C2\u6570\uFF0C\u5982 npx -y chrome-devtools-mcp@latest\uFF09\uFF1A"),k=>v(k).length>0?void 0:r("\u547D\u4EE4\u4E0D\u80FD\u4E3A\u7A7A\u3002"));if(s===void 0)return;const o=v(s),a=await u.input(r("\u73AF\u5883\u53D8\u91CF\uFF08\u53EF\u9009\uFF0C\u9017\u53F7\u5206\u9694 KEY=VALUE\uFF09\uFF1A"));if(a===void 0)return;const e=y(a);if(!e.ok){u.notify(e.error,"error");return}const[f,...p]=o;l={command:f,...p.length>0?{args:p}:{},...Object.keys(e.value).length>0?{env:e.value}:{}}}const h=[O,D],A=await u.select(r("\u4FDD\u5B58\u4F4D\u7F6E\uFF1A"),h);if(A===void 0)return;const d=A===D?"project":"user",$=d==="user"?"~/.dal/agent/mcp.json":`${n}/.dal/mcp.json`;if(await u.confirm(r("\u786E\u8BA4\u4FDD\u5B58\u8BE5 MCP \u670D\u52A1\u5668\uFF1F"),`${F.trim()} \u2192 ${$}
1
+ var w=Object.defineProperty;var c=(u,n)=>w(u,"name",{value:n,configurable:!0});var L=Object.defineProperty,E=c((u,n)=>L(u,"name",{value:n,configurable:!0}),"u");import{t as r}from"@dalcode/dal-pi-kit";import{assertValidName as j,tokenizeCommandArgs as C}from"./command-parser.js";const U=r("stdio\uFF08\u672C\u5730\u547D\u4EE4\uFF09"),v=r("http\uFF08\u8FDC\u7A0B URL\uFF09"),O=r("\u7528\u6237\u7EA7 ~/.dal/agent/mcp.json\uFF08\u672C\u673A\u6240\u6709\u9879\u76EE\u53EF\u7528\uFF09"),D=r("\u9879\u76EE\u7EA7 .dal/mcp.json\uFF08\u4EC5\u5F53\u524D\u9879\u76EE\uFF0C\u9700\u5DF2\u4FE1\u4EFB\uFF09");async function m(u,n,i){for(;;){const t=await u.input(n);if(t===void 0)return;const F=i(t);if(F===void 0)return t;u.notify(F,"error")}}c(m,"m"),E(m,"askValid");function y(u){const n={};for(const i of u.split(/[,,]/)){const t=i.trim();if(!t)continue;const F=t.indexOf("=");if(F===-1||!t.slice(0,F).trim())return{ok:!1,error:`${r("\u65E0\u6548\u7684\u73AF\u5883\u53D8\u91CF\u683C\u5F0F\uFF08KEY=VALUE\uFF09\uFF1A")}${t}`};n[t.slice(0,F).trim()]=t.slice(F+1).trim()}return{ok:!0,value:n}}c(y,"U"),E(y,"parseEnvList");function B(u){const n={};for(const i of u.split(/[,,]/)){const t=i.trim();if(!t)continue;const F=t.indexOf(":");if(F===-1||!t.slice(0,F).trim())return{ok:!1,error:`${r("\u65E0\u6548\u7684\u8BF7\u6C42\u5934\u683C\u5F0F\uFF08Key: Value\uFF09\uFF1A")}${t}`};n[t.slice(0,F).trim()]=t.slice(F+1).trim()}return{ok:!0,value:n}}c(B,"$"),E(B,"parseHeaderList");async function g(u,n){const i=await u.select(r("\u8981\u6DFB\u52A0\u7684 MCP \u670D\u52A1\u5668\u7C7B\u578B\uFF1A"),[U,v]);if(i===void 0)return;const t=i===v,F=await m(u,r("\u670D\u52A1\u5668\u540D\u79F0\uFF08\u4EC5\u5B57\u6BCD\u3001\u6570\u5B57\u3001-\u3001_\uFF09\uFF1A"),s=>{try{j(s.trim());return}catch(o){return o instanceof Error?o.message:String(o)}});if(F===void 0)return;let l;if(t){const s=await m(u,r("\u670D\u52A1\u5668 URL\uFF08http(s)://\u2026\uFF09\uFF1A"),e=>{let f;try{f=new URL(e.trim())}catch{return`${r("URL \u65E0\u6548\uFF1A")}${e.trim()}`}if(f.protocol!=="http:"&&f.protocol!=="https:")return`${r("URL \u4EC5\u652F\u6301 http(s)\uFF1A")}${e.trim()}`});if(s===void 0)return;const o=await u.input(r("\u8BF7\u6C42\u5934\uFF08\u53EF\u9009\uFF0C\u9017\u53F7\u5206\u9694 Key: Value\uFF09\uFF1A"));if(o===void 0)return;const a=B(o);if(!a.ok){u.notify(a.error,"error");return}l={url:s.trim(),...Object.keys(a.value).length>0?{headers:a.value}:{}}}else{const s=await m(u,r("\u542F\u52A8\u547D\u4EE4\uFF08\u542B\u53C2\u6570\uFF0C\u5199\u660E\u7248\u672C\u53F7\uFF0C\u5982 npx -y some-mcp-server@1.2.3\uFF09\uFF1A"),k=>C(k).length>0?void 0:r("\u547D\u4EE4\u4E0D\u80FD\u4E3A\u7A7A\u3002"));if(s===void 0)return;const o=C(s),a=await u.input(r("\u73AF\u5883\u53D8\u91CF\uFF08\u53EF\u9009\uFF0C\u9017\u53F7\u5206\u9694 KEY=VALUE\uFF09\uFF1A"));if(a===void 0)return;const e=y(a);if(!e.ok){u.notify(e.error,"error");return}const[f,...p]=o;l={command:f,...p.length>0?{args:p}:{},...Object.keys(e.value).length>0?{env:e.value}:{}}}const h=[O,D],A=await u.select(r("\u4FDD\u5B58\u4F4D\u7F6E\uFF1A"),h);if(A===void 0)return;const d=A===D?"project":"user",$=d==="user"?"~/.dal/agent/mcp.json":`${n}/.dal/mcp.json`;if(await u.confirm(r("\u786E\u8BA4\u4FDD\u5B58\u8BE5 MCP \u670D\u52A1\u5668\uFF1F"),`${F.trim()} \u2192 ${$}
2
2
  ${JSON.stringify(l,null,2)}`))return{name:F.trim(),scope:d,config:l}}c(g,"j"),E(g,"runAddWizard");export{g as runAddWizard};
@@ -4,6 +4,6 @@ export interface LoadMcpServerConfigsOptions {
4
4
  projectTrusted?: boolean;
5
5
  accountServers?: Record<string, McpServerConfig>;
6
6
  }
7
- export declare const DEFAULT_MCP_SERVERS: Record<string, McpServerConfig>;
7
+ export declare const DEFAULT_MCP_SERVERS: Readonly<Record<string, McpServerConfig>>;
8
8
  export declare function takeMcpConfigProblems(): string[];
9
9
  export declare function loadMcpServerConfigs(cwd: string, opts?: LoadMcpServerConfigsOptions): Record<string, McpServerConfig>;
@@ -1 +1 @@
1
- var A=Object.defineProperty;var s=(r,e)=>A(r,"name",{value:e,configurable:!0});var D=Object.defineProperty,t=s((r,e)=>D(r,"name",{value:e,configurable:!0}),"o");import{existsSync as h,readFileSync as j}from"node:fs";import{join as m}from"node:path";import{CONFIG_DIR_NAME as C,getAgentDir as F}from"@earendil-works/pi-coding-agent";const p={"chrome-devtools":{command:"npx",args:["-y","chrome-devtools-mcp@latest","--headless"]}};function i(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(e=>typeof e=="string")}s(i,"d"),t(i,"isStringRecord");function y(r){return!r||typeof r!="object"||Array.isArray(r)?!1:r.disabled===!0}s(y,"C"),t(y,"isDisabled");function g(r){if(!r||typeof r!="object"||Array.isArray(r))return;const e=r;if(typeof e.url=="string"&&e.url.length>0)return{url:e.url,...i(e.headers)?{headers:e.headers}:{}};if(typeof e.command=="string"&&e.command.length>0)return{command:e.command,...Array.isArray(e.args)&&e.args.every(n=>typeof n=="string")?{args:e.args}:{},...i(e.env)?{env:e.env}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{}}}s(g,"M"),t(g,"parseServer");function a(){return{servers:{},names:new Set,disabled:new Set}}s(a,"i"),t(a,"emptyLayer");function u(r){if(!h(r))return a();try{const e=JSON.parse(j(r,"utf8")),n=a();for(const[o,f]of Object.entries(e.mcpServers??{})){if(y(f)){n.names.add(o),n.disabled.add(o);continue}const l=g(f);if(!l){c.push(`${r}: \u670D\u52A1\u5668 "${o}" \u7F3A\u5C11 command \u6216 url\uFF0C\u5DF2\u5FFD\u7565`);continue}n.names.add(o),n.servers[o]=l}return n}catch(e){return c.push(`${r}: ${e instanceof Error?e.message:String(e)}`),a()}}s(u,"g"),t(u,"readServersFile");const c=[];function v(){return c.splice(0,c.length)}s(v,"w"),t(v,"takeMcpConfigProblems");function b(r){return r?.includeDefaults!==void 0?r.includeDefaults:!!process.env.DALCODE_BRIDGE_URL}s(b,"b"),t(b,"shouldIncludeDefaults");function d(r,e){for(const n of e.names)delete r[n];Object.assign(r,e.servers);for(const n of e.disabled)delete r[n]}s(d,"u"),t(d,"applyLayer");function S(r,e){const n={};return b(e)&&Object.assign(n,p),e?.accountServers&&Object.assign(n,e.accountServers),d(n,u(m(F(),"mcp.json"))),e?.projectTrusted&&d(n,u(m(r,C,"mcp.json"))),n}s(S,"D"),t(S,"loadMcpServerConfigs");export{p as DEFAULT_MCP_SERVERS,S as loadMcpServerConfigs,v as takeMcpConfigProblems};
1
+ var j=Object.defineProperty;var t=(r,e)=>j(r,"name",{value:e,configurable:!0});var A=Object.defineProperty,s=t((r,e)=>A(r,"name",{value:e,configurable:!0}),"o");import{existsSync as D,readFileSync as O}from"node:fs";import{join as p}from"node:path";import{CONFIG_DIR_NAME as h,getAgentDir as C}from"@earendil-works/pi-coding-agent";const m=Object.freeze({});function i(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(e=>typeof e=="string")}t(i,"d"),s(i,"isStringRecord");function y(r){return!r||typeof r!="object"||Array.isArray(r)?!1:r.disabled===!0}t(y,"C"),s(y,"isDisabled");function g(r){if(!r||typeof r!="object"||Array.isArray(r))return;const e=r;if(typeof e.url=="string"&&e.url.length>0)return{url:e.url,...i(e.headers)?{headers:e.headers}:{}};if(typeof e.command=="string"&&e.command.length>0)return{command:e.command,...Array.isArray(e.args)&&e.args.every(n=>typeof n=="string")?{args:e.args}:{},...i(e.env)?{env:e.env}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{}}}t(g,"b"),s(g,"parseServer");function a(){return{servers:{},names:new Set,disabled:new Set}}t(a,"i"),s(a,"emptyLayer");function u(r){if(!D(r))return a();try{const e=JSON.parse(O(r,"utf8")),n=a();for(const[o,d]of Object.entries(e.mcpServers??{})){if(y(d)){n.names.add(o),n.disabled.add(o);continue}const l=g(d);if(!l){c.push(`${r}: \u670D\u52A1\u5668 "${o}" \u7F3A\u5C11 command \u6216 url\uFF0C\u5DF2\u5FFD\u7565`);continue}n.names.add(o),n.servers[o]=l}return n}catch(e){return c.push(`${r}: ${e instanceof Error?e.message:String(e)}`),a()}}t(u,"g"),s(u,"readServersFile");const c=[];function v(){return c.splice(0,c.length)}t(v,"O"),s(v,"takeMcpConfigProblems");function f(r,e){for(const n of e.names)delete r[n];Object.assign(r,e.servers);for(const n of e.disabled)delete r[n]}t(f,"u"),s(f,"applyLayer");function b(r){return r?.includeDefaults!==void 0?r.includeDefaults:!!process.env.DALCODE_BRIDGE_URL}t(b,"M"),s(b,"shouldIncludeDefaults");function S(r,e){const n={};return b(e)&&Object.assign(n,m),e?.accountServers&&Object.assign(n,e.accountServers),f(n,u(p(C(),"mcp.json"))),e?.projectTrusted&&f(n,u(p(r,h,"mcp.json"))),n}t(S,"w"),s(S,"loadMcpServerConfigs");export{m as DEFAULT_MCP_SERVERS,S as loadMcpServerConfigs,v as takeMcpConfigProblems};