dal-code 1.0.52 → 1.0.54
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/CHANGELOG.md +9 -0
- package/dist/bundle/chunks/{anthropic-messages-NK5NGKAI.js → anthropic-messages-UHE6F2IE.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-VEASENYL.js → azure-openai-responses-EK4W2MKL.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-XDBGA662.js → chunk-2C7JTP5O.js} +1 -1
- package/dist/bundle/chunks/{chunk-HEFI7NO7.js → chunk-33MCYYJ3.js} +1 -1
- package/dist/bundle/chunks/{chunk-DLKRCASW.js → chunk-356BFRU3.js} +1 -1
- package/dist/bundle/chunks/{chunk-UVKMBM5X.js → chunk-3ZHZINH3.js} +2 -2
- package/dist/bundle/chunks/{chunk-OQWPBJCS.js → chunk-4DMD6C65.js} +1 -1
- package/dist/bundle/chunks/{chunk-ANL2BCIQ.js → chunk-B5GJW7C2.js} +1 -1
- package/dist/bundle/chunks/{chunk-WIZGOHKY.js → chunk-CSZTBJOE.js} +1 -1
- package/dist/bundle/chunks/{chunk-6EEJ4MZH.js → chunk-FE533CCR.js} +1 -1
- package/dist/bundle/chunks/{chunk-AAQZXQA7.js → chunk-IDZ3QKHZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-TK2WJTRC.js → chunk-K4B5ABCQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-KJW3E2CB.js → chunk-L3RBW36Y.js} +1 -1
- package/dist/bundle/chunks/{chunk-CS4T4O5O.js → chunk-O7G23ELK.js} +1 -1
- package/dist/bundle/chunks/{chunk-ON7ZX67F.js → chunk-R7FBN5UP.js} +2 -2
- package/dist/bundle/chunks/{chunk-XAS5HHBW.js → chunk-RKLUP6JT.js} +10 -12
- package/dist/bundle/chunks/{chunk-4VJJ6NXH.js → chunk-SCYK4XNE.js} +1 -1
- package/dist/bundle/chunks/{chunk-A5CI3CVQ.js → chunk-VIS5PYQO.js} +1 -1
- package/dist/bundle/chunks/{chunk-YWNDPXVM.js → chunk-XRF4A4KI.js} +1 -1
- package/dist/bundle/chunks/{cli-YPE3BB5X.js → cli-XOLEGZVC.js} +1 -1
- package/dist/bundle/chunks/{cli-GXB5WYKG.js → cli-YJV3WN2N.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-B7WOBGWO.js → cloudflare-workers-ai-system-one-KNGB64NR.js} +1 -1
- package/dist/bundle/chunks/{execute-27QCJECT.js → execute-6PNQ63VS.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-MBMRBHSZ.js → google-generative-ai-YJN7TGWU.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-S2ZFBDPP.js → google-vertex-3BVJFMMZ.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-S4LVGNNY.js → llama-cpp-classify-JVUWNG3E.js} +1 -1
- package/dist/bundle/chunks/{mcp-6LJKGKJQ.js → mcp-PC3Y3FBI.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-C7LUXIEY.js → mistral-conversations-O6YIQAS5.js} +1 -1
- package/dist/bundle/chunks/{office-5OWKTZOA.js → office-AXLGVCMO.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-YQQXJ24E.js → openai-codex-responses-YQ5NNPTG.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-7CMH2FKD.js → openai-completions-R4I3PKBD.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-AOGZTREY.js → openai-decisions-IUHMKKHZ.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-ZSOGZ3MK.js → openai-responses-E2PHOQF4.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-AHXST2TH.js → openrouter-images-NCMLTKZW.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-QERJLMZ6.js → pi-messages-GLTSGLSO.js} +1 -1
- package/dist/bundle/chunks/{review-5G56KIWY.js → review-KXWT7T3V.js} +1 -1
- package/dist/bundle/chunks/{router-776Z7G7G.js → router-26PXJ7YH.js} +1 -1
- package/dist/bundle/chunks/{runtime-NKPT25KD.js → runtime-LJBCO7CX.js} +1 -1
- package/dist/bundle/chunks/{sdk-TVC4GDUX.js → sdk-6GP346VB.js} +1 -1
- package/dist/bundle/chunks/{sync-JBDC3YBK.js → sync-ONQZCAYG.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-MMNGGQ46.js → typesafe-system-one-GQFHU7SQ.js} +1 -1
- package/dist/bundle/chunks/{usage-BDCIALHO.js → usage-MY7HTXQB.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-25RQ6XTV.js → virtual-modules-BEBLHRXC.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/tools/bash.js +14 -14
- package/dist/core/tools/renderers/bash.js +8 -8
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +3 -3
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +14 -14
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/core/tools/bash.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as
|
|
2
|
-
Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",
|
|
3
|
-
${E.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const
|
|
1
|
+
var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as V,truncateToWidth as ve}from"@earendil-works/pi-tui";import{spawn as Ie}from"child_process";import{Type as l}from"typebox";import{fill as Y,t as A}from"../../dal/i18n.js";import{keyHint as Ae}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as ke}from"../../modes/interactive/components/visual-truncate.js";import{theme as E}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as Me}from"../../utils/child-process.js";import{writeOutputFile as Fe}from"../../utils/output-files.js";import{getShellConfig as ce,getShellEnv as me,killProcessTree as pe,trackDetachedChildPid as Ne,untrackDetachedChildPid as Be}from"../../utils/shell.js";import{missingManagedToolHint as Re}from"../../utils/tools-manager.js";import{describeDenialForModel as Ue}from"../sandbox/denial.js";import{getProcessShellSandbox as Ge}from"../sandbox/shell-sandbox.js";import{toolDenial as He,withToolDenial as je}from"../tool-denial.js";import{isReadOnlyBashCommand as We}from"./bash-read-only.js";import{OutputAccumulator as Ve}from"./output-accumulator.js";import{condenseShellOutput as Ye,outputCondenseDisabled as Xe}from"./output-condense.js";import{countOutputLines as Ke,formatCollapsedSummary as qe,getTextOutput as fe,invalidArgText as ze,str as he,truncateDisplay as Je}from"./render-utils.js";import{wrapToolDefinition as Qe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Ze,formatSize as et,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as tt}from"./truncate.js";const we=2147483647,Se=1024*1024,nt=8*1024*1024,ot=we/1e3,te=12e4,ne=30;function it(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>we)throw new Error(`Invalid timeout: maximum is ${ot} seconds`);return e}s(it,"resolveTimeoutMs");const xe=l.Object({command:l.String({description:"Shell command to execute"}),description:l.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:l.Optional(l.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),st=l.Optional(l.Object({mode:l.Union([l.Literal("allow"),l.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:l.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:l.Optional(l.Array(l.String(),{description:"e.g. registry.npmjs.org"})),allow_write:l.Optional(l.Array(l.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),rt=l.Object({...xe.properties,sandbox_escalation:st}),be={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},at=l.Object({output:l.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:l.Boolean(),full_output_path:l.Optional(l.String({description:"Full output, when truncated"})),exit_code:l.Number({description:"-1 while the command runs in the background"}),background_id:l.Optional(l.String({description:"Background process id, when it is still running"})),wall_time_seconds:l.Number()});class Ee extends Error{static{s(this,"ShellTimeoutError")}shellExit;constructor(e,n){super(`timeout:${e}`),this.shellExit=n}}function dt(t,e){return{exec:s(async(n,o,{onData:u,signal:i,timeout:L,env:w,yieldTo:c})=>{const $=it(L);if(i?.aborted)throw new Error("aborted");const S=e();try{await Ce(o,Te.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
|
|
2
|
+
Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",r=Ie(S.shell,x?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??me(),stdio:[x?"pipe":"ignore","pipe","pipe"],windowsHide:!0});x&&(r.stdin?.on("error",()=>{}),r.stdin?.end(n)),r.pid&&Ne(r.pid);const a=performance.now();let p;r.once("exit",()=>{p=performance.now()-a});let h=!1,m=!1,f;const T=new Promise(U=>{f=s(()=>U("yielded"),"onYielded")});let R,D;const k=s(()=>{r.pid&&pe(r.pid)},"onAbort");try{$!==void 0&&(D=setTimeout(()=>{if(c&&r.exitCode===null&&r.signalCode===null&&c(r)){m=!0,f?.();return}h=!0,R=p,r.pid&&pe(r.pid)},$)),r.stdout?.on("data",u),r.stderr?.on("data",u),i&&(i.aborted?k():i.addEventListener("abort",k,{once:!0}));const U=Me(r),C=await Promise.race([U,T]);if(C==="yielded")return U.catch(()=>{}),{exitCode:null,yielded:!0};const O=C;if(i?.aborted)throw new Error("aborted");const g=r.signalCode,M=O??(g?128+(Pe.signals[g]??0):1);if(h)throw new Ee(($??te)/1e3,R!==void 0?{exitCode:M,afterSeconds:Math.round(R/100)/10}:void 0);return{exitCode:M}}finally{r.pid&&!m&&Be(r.pid),D&&clearTimeout(D),i&&i.removeEventListener("abort",k)}},"exec")}}s(dt,"createLocalShellOperations");function lt(t){return dt("bash",()=>ce(t?.shellPath))}s(lt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Kt(t){return se.add(t),()=>{se.delete(t)}}s(Kt,"registerShellExecutionGuard");async function ut(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}s(ut,"shellExecutionRefusal");const ct=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function mt(t,e,n,o,u){const i={...me()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&u){const w=u.model;i.PI_SESSION_ID=u.sessionManager.getSessionId();const c=u.sessionManager.getSessionFile();c&&(i.PI_SESSION_FILE=c),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),u.thinkingLevel&&(i.PI_REASONING_LEVEL=u.thinkingLevel)}for(const w of ct){delete i[`DAL_${w}`];const c=i[`PI_${w}`];c!==void 0&&(i[`DAL_${w}`]=c)}const L={command:t,cwd:e,env:i};return n?n(L):L}s(mt,"resolveSpawnContext");const pt=5,ft=100;class ht extends De{static{s(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function wt(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),u=n%60;return o<60?`${o}m ${u}s`:`${Math.floor(o/60)}h ${o%60}m ${u}s`}s(wt,"formatDuration");function St(t,e,n=!1){const o=he(t?.command),u=he(t?.description)?.trim(),i="";if(u){const w=E.fg("toolTitle",E.bold(u))+i;return!n||!o?w:`${w}
|
|
3
|
+
${E.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const L=o===null?ze(E):o?E.fg("dim",Je(o.replace(/\s+/g," ").trim(),42)):E.fg("dim","\u2026");return`${E.fg("toolTitle",E.bold(e))} ${L}${i}`}s(St,"formatShellCall");function xt(t,e,n,o,u,i,L,w){const c=t.state;t.clear();const $=bt(n,u,i,w);if(!n.expanded&&!L){const a=fe(e,o),p=Ke(a),h=[];p>0&&h.push(Y(A("{count} \u884C"),{count:p})),$&&h.push($);const m=qe(E,h);m&&t.addChild(new V(m,0,0));return}let S=fe(e,o).trim();const x=e.details?.truncation,r=e.details?.fullOutputPath;if(!n.isPartial&&x?.truncated&&r&&S.endsWith("]")){const a=S.lastIndexOf(`
|
|
4
4
|
|
|
5
|
-
[`);
|
|
5
|
+
[`);a!==-1&&S.slice(a).includes(r)&&(S=S.slice(0,a).trimEnd())}if(S){const a=S.split(`
|
|
6
6
|
`).map(p=>E.fg("toolOutput",p)).join(`
|
|
7
|
-
`);n.expanded?t.addChild(new
|
|
8
|
-
${
|
|
9
|
-
${E.fg("warning",`[${
|
|
10
|
-
${E.fg("muted"
|
|
11
|
-
${T}`:T,C=mt(U,f?.cwd||t
|
|
7
|
+
`);n.expanded?t.addChild(new V(`
|
|
8
|
+
${a}`,0,0)):t.addChild({render:s(p=>{if(c.cachedLines===void 0||c.cachedWidth!==p){const h=ke(a,pt,p);c.cachedLines=h.visualLines,c.cachedSkipped=h.skippedCount,c.cachedWidth=p}if(c.cachedSkipped&&c.cachedSkipped>0){const h=E.fg("muted",Y(A("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:c.cachedSkipped}))+` ${Ae("app.tools.expand",A("\u5373\u53EF\u5C55\u5F00"))}${E.fg("muted",")")}`;return["",ve(h,p,"..."),...c.cachedLines??[]]}return["",...c.cachedLines??[]]},"render"),invalidate:s(()=>{c.cachedWidth=void 0,c.cachedLines=void 0,c.cachedSkipped=void 0},"invalidate")})}if(x?.truncated||r){const a=[];r&&a.push(Y(A("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:r})),x?.truncated&&(x.truncatedBy==="lines"?a.push(Y(A("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:x.outputLines,total:x.totalLines})):a.push(Y(A("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:x.outputLines,limit:et(x.maxBytes??Ze)}))),t.addChild(new V(`
|
|
9
|
+
${E.fg("warning",`[${a.join(". ")}]`)}`,0,0))}$&&t.addChild(new V(`
|
|
10
|
+
${E.fg("muted",$)}`,0,0))}s(xt,"rebuildBashResultRenderComponent");function bt(t,e,n,o){let u;if(!t.isPartial&&o!==void 0)u=o;else if(e!==void 0)u=(n??Date.now())-e;else return;if(!(!t.isPartial&&u<100))return`${t.isPartial?A("\u5DF2\u8FD0\u884C"):A("\u8017\u65F6")} ${wt(u)}`}s(bt,"bashTimingLabel");function Et(t,e,n){const o=n?.operations??e.defaultOperations?.()??lt({shellPath:n?.shellPath}),u=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,L=n?.spawnHook,w=n?.sandbox,c=n?.operations===void 0,$=w?.describeForModel(),S=n?.background;let x=!1;const r=s(a=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${a?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${$?` ${$}`:""}`,"describe");return{name:e.name,label:e.label,description:r(!1),prepareLoadout:S&&c?a=>(x=a.declared.some(p=>p.name==="process"),x?{descriptions:{[e.name]:r(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!u?a=>e.readOnlyCommand?.(a?.command)?"parallel":void 0:void 0,parameters:w?.active?rt:xe,outputSchema:at,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(a,p,h,m,f){const{command:T,timeout:R}=p;m&&m({content:[],details:void 0});const D=w??(c?Ge():void 0),k=await ut({toolName:e.name,command:T,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile(),...D?.active?{tempDir:D.scratchDir()}:{}});if(k!==void 0)throw new ue(k,je(void 0,He("dangerous-command",k)));const U=u?`${u}
|
|
11
|
+
${T}`:T,C=mt(U,f?.cwd||t,L,i,f);let O;if(D?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${D.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);O=await D.prepare({command:C.command,cwd:C.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:C.env,toolCallId:a,toolName:e.name,escalation:p.sandbox_escalation,ctx:f,signal:h})}const g=new Ve({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let M=!0,W,K=!1,re=0;const q=s(()=>{if(!m||!K)return;K=!1,re=Date.now();const d=g.snapshot({persistIfTruncated:!0});m({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),z=s(()=>{W&&(clearTimeout(W),W=void 0)},"clearUpdateTimer"),_e=s(()=>{if(!m)return;K=!0;const d=ft-(Date.now()-re);if(d<=0){z(),q();return}W??=setTimeout(()=>{W=void 0,q()},d)},"scheduleOutputUpdate"),Oe=s(d=>{M&&(g.append(d),_e())},"handleData"),ge=s(async()=>{M=!1,g.finish(),z(),q();const d=g.snapshot({persistIfTruncated:!0});return await g.closeTempFile(),d},"finishOutput"),J=s(async(d="(no output)")=>{const y=await ge(),F=await g.readFullOutput(nt),P=Xe()?void 0:Ye(F.content),_=tt(P?.text??F.content,ee);let I=y.fullOutputPath;(_.truncated||P)&&!I&&(I=await Fe(e.tempFilePrefix,".log",F.content));let N=_.content||d,H;const j=y.truncation.totalLines;return _.truncated?(H={truncation:{content:_.content,truncated:!0,truncatedBy:"bytes",totalLines:j,totalBytes:y.truncation.totalBytes,outputLines:_.headLines+_.tailLines,outputBytes:Buffer.byteLength(_.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:j,maxBytes:ee},fullOutputPath:I},N+=`
|
|
12
12
|
|
|
13
|
-
[Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${
|
|
13
|
+
[Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${I}]`):P&&(H={fullOutputPath:I},N+=`
|
|
14
14
|
|
|
15
|
-
[Condensed: ${P.summary}. Full output: ${
|
|
15
|
+
[Condensed: ${P.summary}. Full output: ${I}]`),{text:N,details:H,snapshot:y}},"modelOutput"),G=s((d,y)=>`${d?`${d}
|
|
16
16
|
|
|
17
|
-
`:""}${y}`,"appendStatus"),ae=performance.now();let
|
|
17
|
+
`:""}${y}`,"appendStatus"),ae=performance.now();let v;const Q=S&&c&&x?d=>{M=!1;try{return v=S.adopt({child:d,command:T,cwd:C.cwd,...O?{prepared:O}:{},...g.handOff()}),!0}catch{return M=!0,!1}}:void 0;try{let d;try{const b=await o.exec(O?.command??C.command,C.cwd,{onData:Oe,signal:h,timeout:R??(Q?ne:void 0),env:C.env,...Q?{yieldTo:Q}:{}});if(b.yielded&&v){const{text:B,details:de}=await J(""),X=R??ne,ye=v.urls.length>0?` It printed ${v.urls.join(" ")}.`:"",$e=`[Still running after ${X}s, now in the background as ${v.id}.${ye} For new output and the exit code call process with action "poll" and id "${v.id}"; "kill" stops it.]`,le=await g.readFullOutput(Se);return{content:[{type:"text",text:G(B,$e)}],details:{...de,background:v},structuredContent:{output:le.content,truncated:le.truncated,exit_code:-1,background_id:v.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}d=b.exitCode}catch(b){const{text:B}=await J("");if(await O?.finish(null,""),b instanceof Error&&b.message==="aborted")throw new Error(G(B,"Command aborted"));if(b instanceof Error&&b.message.startsWith("timeout:")){let X=`Command timed out after ${b.message.split(":")[1]} seconds`;throw b instanceof Ee&&b.shellExit&&(X+=`. The shell exited with code ${b.shellExit.exitCode} after ${b.shellExit.afterSeconds} seconds, but background processes it started kept writing output until the timeout.`),new Error(G(B,X))}throw b}const{text:y,details:F,snapshot:P}=await J(),_=await O?.finish(d,P.content||"");if(_&&O)throw new ue(`${G(y,`Command exited with code ${d??"(none)"}`)}
|
|
18
18
|
|
|
19
|
-
${Ue(_)}`,{...F,sandbox:O.details});if(
|
|
20
|
-
${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(
|
|
19
|
+
${Ue(_)}`,{...F,sandbox:O.details});if(d===null)throw new Error(G(y,"Command terminated without an exit code"));const I=Math.round((performance.now()-ae)/100)/10,N=await g.readFullOutput(Se),H={output:N.content,truncated:N.truncated,...N.truncated&&P.fullOutputPath?{full_output_path:P.fullOutputPath}:{},exit_code:d,wall_time_seconds:I},j=O?.details.escalation?O.details:void 0,Z=j?{...F,sandbox:j}:F;if(d!==0){const b=d===127?await Re(y):void 0,B=G(y,`Command exited with code ${d}`);return{content:[{type:"text",text:b?`${B}
|
|
20
|
+
${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(a,p,h){const m=h.state;h.executionStarted&&m.startedAt===void 0&&(m.startedAt=Date.now(),m.endedAt=void 0);const f=h.lastComponent??new V("",0,0);return f.setText(St(a,e.prompt,h.expanded===!0)),f},renderResult(a,p,h,m){const f=m.state;f.startedAt!==void 0&&p.isPartial&&!f.interval&&(f.interval=setInterval(()=>m.invalidate(),1e3)),(!p.isPartial||m.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const T=m.lastComponent??new ht;return xt(T,a,p,m.showImages,f.startedAt,f.endedAt,m.isError,m.durationMs),T.invalidate(),T}}}s(Et,"createShellToolDefinition");const _t={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:We,sandboxShell:s(t=>ce(t).shell,"sandboxShell")};function Ot(t,e){return Et(t,_t,e)}s(Ot,"createBashToolDefinition");function qt(t,e){const n=Ot(t,e),o=Qe(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}s(qt,"createBashTool");export{be as bashToolSystemPromptContribution,qt as createBashTool,Ot as createBashToolDefinition,lt as createLocalBashOperations,dt as createLocalShellOperations,Et as createShellToolDefinition,Kt as registerShellExecutionGuard,st as sandboxEscalationSchema,ut as shellExecutionRefusal};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var S=Object.defineProperty;var c=(
|
|
2
|
-
${d.fg("muted",` \u23BF ${i} ${
|
|
1
|
+
var S=Object.defineProperty;var c=(n,i)=>S(n,"name",{value:i,configurable:!0});import{Container as A,Spacer as C,Text as p}from"@earendil-works/pi-tui";import{fill as $,t as f}from"../../../dal/i18n.js";import{keyHint as v}from"../../../modes/interactive/components/keybinding-hints.js";import{VisualLinePreview as P}from"../../../modes/interactive/components/visual-truncate.js";import{theme as d}from"../../../modes/interactive/theme/theme.js";import{getTextOutput as E,invalidArgText as x,str as w}from"../render-utils.js";import{DEFAULT_MAX_BYTES as _,formatSize as L}from"../truncate.js";const O=5,k=100;function g(n){const i=n/1e3;if(i<60)return`${i.toFixed(1)}s`;const r=Math.floor(i),e=Math.floor(r/60),t=r%60;return e<60?`${e}m ${t}s`:`${Math.floor(e/60)}h ${e%60}m ${t}s`}c(g,"formatDuration");function D(n,i,r){const e=w(n?.command),t=w(n?.description)?.trim(),a="",l=e===null?x(d):e||d.fg("toolOutput","...");if(!t)return d.fg("toolTitle",d.bold(`${i} ${l}`))+a;const o=d.fg("toolTitle",d.bold(t))+a;return r?`${o}
|
|
2
|
+
${d.fg("muted",` \u23BF ${i} ${e??""}`.trimEnd())}`:o}c(D,"formatShellCall");function B(n,i,r,e,t,a,l){n.clear();let o=E(i,e).trim();const u=i.details?.truncation,h=i.details?.fullOutputPath;if(!r.isPartial&&u?.truncated&&h&&o.endsWith("]")){const s=o.lastIndexOf(`
|
|
3
3
|
|
|
4
|
-
[`);s!==-1&&
|
|
4
|
+
[`);s!==-1&&o.slice(s).includes(h)&&(o=o.slice(0,s).trimEnd())}if(o){const s=o.split(`
|
|
5
5
|
`).map(m=>d.fg("toolOutput",m)).join(`
|
|
6
|
-
`);r.expanded?
|
|
7
|
-
${s}`,0,0)):(
|
|
8
|
-
${d.fg("warning",`[${s.join(". ")}]`)}`,0,0))}if(!r.isPartial&&l!==void 0)l>=100&&
|
|
9
|
-
${d.fg("muted",`${f("\u8017\u65F6")} ${g(l)}`)}`,0,0));else if(t!==void 0){const m=(a??Date.now())-t;if(r.isPartial||m>=100){const T=r.isPartial?f("\u5DF2\u8FD0\u884C"):f("\u8017\u65F6");
|
|
10
|
-
${d.fg("muted",`${T} ${g(m)}`)}`,0,0))}}}c(B,"rebuildBashResultRenderComponent");function F(
|
|
6
|
+
`);r.expanded?n.addChild(new p(`
|
|
7
|
+
${s}`,0,0)):(n.addChild(new C(1)),n.addChild(new P({text:s,maxVisualLines:O,keep:"end",formatHint:c(m=>d.fg("muted",$(f("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:m}))+` ${v("app.tools.expand",f("\u5373\u53EF\u5C55\u5F00"))}${d.fg("muted",")")}`,"formatHint")})))}if(u?.truncated||h){const s=[];h&&s.push($(f("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:h})),u?.truncated&&(u.truncatedBy==="lines"?s.push($(f("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:u.outputLines,total:u.totalLines})):s.push($(f("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:u.outputLines,limit:L(u.maxBytes??_)}))),n.addChild(new p(`
|
|
8
|
+
${d.fg("warning",`[${s.join(". ")}]`)}`,0,0))}if(!r.isPartial&&l!==void 0)l>=100&&n.addChild(new p(`
|
|
9
|
+
${d.fg("muted",`${f("\u8017\u65F6")} ${g(l)}`)}`,0,0));else if(t!==void 0){const m=(a??Date.now())-t;if(r.isPartial||m>=100){const T=r.isPartial?f("\u5DF2\u8FD0\u884C"):f("\u8017\u65F6");n.addChild(new p(`
|
|
10
|
+
${d.fg("muted",`${T} ${g(m)}`)}`,0,0))}}}c(B,"rebuildBashResultRenderComponent");function F(n){return{renderCall(i,r,e){const t=e.state;e.executionStarted&&t.startedAt===void 0&&(t.startedAt=Date.now(),t.endedAt=void 0);const a=i,l=e.lastComponent??new p("",0,0);return l.setText(D(a,n,e.expanded===!0)),l},renderResult(i,r,e,t){const a=t.state;a.startedAt!==void 0&&r.isPartial&&!a.interval&&(a.interval=setInterval(()=>t.invalidate(),1e3)),(!r.isPartial||t.isError)&&(a.endedAt??=Date.now(),a.interval&&(clearInterval(a.interval),a.interval=void 0));const l=t.lastComponent??new A;return B(l,i,r,t.showImages,a.startedAt,a.endedAt,t.durationMs),l.invalidate(),l}}}c(F,"createShellRenderers");export{k as BASH_UPDATE_THROTTLE_MS,F as createShellRenderers};
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`,r=x("summary",()=>!1,this.markdownTransformers,this.messageId,this.timestamp);e.addChild(new g(this.message.summary,0,0,this.markdownTheme,{color:o(s=>m.fg("customMessageText",s),"color")},{transform:o((s,l)=>t+r(s,l),"transform")}))}else e.addChild(new h(`${n} ${m.fg("customMessageText",p(d("\u5DF2\u538B\u7F29 {count} \u4E2A token"),{count:a}))}`,0,0));this.addChild(new k(e,t=>{if(!(t.type!=="click"||t.button!=="left"))return this.setExpanded(!this.expanded),{handled:!0}}))}}export{D as CompactionSummaryMessageComponent};
|
|
1
|
+
var h=Object.defineProperty;var d=(i,e)=>h(i,"name",{value:e,configurable:!0});import{Box as p,Container as l,Markdown as u,MouseRegion as f,Text as m}from"@earendil-works/pi-tui";import{t as c}from"../../../dal/i18n.js";import{getMarkdownTheme as w,theme as o}from"../theme/theme.js";import{createMarkdownTransform as g}from"./markdown-transform.js";class M extends p{static{d(this,"CompactionSummaryMessageComponent")}markdownTransformers=[];messageId;timestamp;expanded=!1;message;markdownTheme;constructor(e,a=w(),s=0,r=[],t,n){super(s,0),this.markdownTransformers=r,this.messageId=t,this.timestamp=n,this.message=e,this.markdownTheme=a,this.updateDisplay()}setExpanded(e){this.expanded=e,this.updateDisplay()}setOutputPad(e){this.setPaddingX(e)}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){this.clear();const e=new l,a=o.fg("muted",c("\u8F83\u65E9\u7684\u5BF9\u8BDD\u5DF2\u6574\u7406\u4E3A\u6458\u8981"));if(this.expanded){e.addChild(new m(a,0,0));const s="",r=g("summary",()=>!1,this.markdownTransformers,this.messageId,this.timestamp);e.addChild(new u(this.message.summary,0,0,this.markdownTheme,{color:d(t=>o.fg("customMessageText",t),"color")},{transform:d((t,n)=>s+r(t,n),"transform")}))}else e.addChild(new m(a,0,0));this.addChild(new f(e,s=>{if(!(s.type!=="click"||s.button!=="left"))return this.setExpanded(!this.expanded),{handled:!0}}))}}export{M as CompactionSummaryMessageComponent};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-advisor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "advisor: the model asks another strong model to review its current plan and point out risks. Adapted from @juicesharp/rpiv-advisor 2.13.8 (MIT).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
24
|
-
"@dalcode/dal-router": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
24
|
+
"@dalcode/dal-router": "1.0.54",
|
|
25
25
|
"typebox": "1.3.27"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-awake",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Keeps the computer from going to sleep while a long agent run is in progress, and lets it sleep again when the run ends. Adapted from @narumitw/pi-caffeinate (MIT).",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.54"
|
|
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-bridge",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
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.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
22
22
|
"typebox": "1.3.7"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-capabilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Capability center for DAL: switches on the reviewed MCP connectors, skills and engine packages a task needs (installed automatically from the signed DAL market), with /capabilities to list, disable and enable them.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dalcode/dal-mcp": "1.0.
|
|
27
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
28
|
-
"@dalcode/deepailab": "1.0.
|
|
26
|
+
"@dalcode/dal-mcp": "1.0.54",
|
|
27
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
28
|
+
"@dalcode/deepailab": "1.0.54"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-codeindex",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Code index: a persistent local symbol and reference index (tree-sitter WebAssembly grammars) the model queries to find definitions, callers, file outlines and related files without repeated grep.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
22
22
|
"@vscode/tree-sitter-wasm": "0.3.1",
|
|
23
23
|
"ignore": "7.0.8",
|
|
24
24
|
"typebox": "1.3.27"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-compat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Claude Code compatibility: the user's and project's .claude/rules/ and .claude/CLAUDE.md apply in DAL. Grown from the claude-rules extension example.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
21
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
22
22
|
"minimatch": "11.0.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-dap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Debugger for DAL: breakpoints, stepping, call stacks and variables in Node.js and Python programs over the Debug Adapter Protocol, installing the adapter on first use. The DAP client is adapted from oh-my-pi's src/dap (MIT).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
27
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
28
28
|
"typebox": "1.3.27"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-gateway",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
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.
|
|
20
|
+
"@dalcode/deepailab": "1.0.54"
|
|
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-goal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Goal mode for DAL: /goal keeps the agent working on one objective until it is verified complete, with token and continuation limits. Adapted from @narumitw/pi-goal 0.54.11 (MIT, narumiruna); the independent completion check adapts pi-goal-x 0.32.3 (MIT, Lucas).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
-
"@dalcode/dal-subagent": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
25
|
+
"@dalcode/dal-subagent": "1.0.54",
|
|
26
26
|
"typebox": "1.3.27"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-guard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
25
|
-
"@dalcode/dal-bridge": "1.0.
|
|
26
|
-
"@dalcode/dal-halo": "1.0.
|
|
24
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
25
|
+
"@dalcode/dal-bridge": "1.0.54",
|
|
26
|
+
"@dalcode/dal-halo": "1.0.54"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-interactive",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
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
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
23
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
24
24
|
"typebox": "1.3.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dalcode/dal-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
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.
|
|
21
|
-
"@dalcode/dal-bridge": "1.0.
|
|
20
|
+
"@dalcode/dal-pi-kit": "1.0.54",
|
|
21
|
+
"@dalcode/dal-bridge": "1.0.54"
|
|
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-learn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Self-evolution for DAL: lessons learned from earlier sessions (project and personal), a project map of verified commands and locations, effect tracking, and skill proposals for recurring procedures (/lessons).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dalcode/dal-pi-kit": "1.0.
|
|
33
|
+
"@dalcode/dal-pi-kit": "1.0.54"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@earendil-works/pi-coding-agent": "^1.0.9"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var oe=Object.defineProperty;var k=(f,e)=>oe(f,"name",{value:e,configurable:!0});var re=Object.defineProperty,j=k((f,e)=>re(f,"name",{value:e,configurable:!0}),"y");import{existsSync as ie,readdirSync as ne,readFileSync as ae,realpathSync as ce}from"node:fs";import{join as x}from"node:path";import{t as y}from"@dalcode/dal-pi-kit";import{buildExtractPrompt as de,buildInducePrompt as ue,buildReflectPrompt as le,draftFromFix as pe,EXTRACT_SYSTEM_PROMPT as fe,INDUCE_SYSTEM_PROMPT as he,normalizeCommand as R,parseExtractAnswer as me,parseInduceAnswer as ke,parseReflectAnswer as ye,REFLECT_SYSTEM_PROMPT as ge,taskNoteSignature as U}from"./extract.js";import{applyFeedback as je,proposeLesson as Fe,readLessons as m,recordInjection as we,renderLessonsSection as xe,retireLessons as De,updateLessons as D}from"./lessons.js";import{desktopProjectsRoot as Ce,importDesktopRules as be}from"./migrate.js";import{procedureOf as Ee,proceduresPath as Ie,recordProcedure as Ae,updateProcedures as $}from"./procedures.js";import{identifyProject as Se}from"./project.js";import{learnFromRun as ve,readMap as Pe,renderMapSection as Re,updateMap as $e,viewMap as Me}from"./project-map.js";import{rejectLesson as Y,riskOf as M}from"./safety.js";import{analyzeRun as T,buildExcerpt as L,longSuccess as Te,needsModel as Le,needsReflection as _e,protectedChanges as q,runsChecks as X,verifiedOutcome as Be}from"./signals.js";import{applyPatches as z,decideScope as
|
|
2
|
-
`),evidence:n,risk:M(P)}}else{const w=z(l,[K],{marker:!v,projectKey:t.key}).text;d={...s,name:c.name,content:"",kind:"improve",scope:se,scopeReason:`${W}\uFF1B${a.reason}`,target:O,patch:K,diff:b(l,w,c.name),evidence:n,risk:M(u.text)}}}}return $(e,u=>({...u,procedures:u.procedures.map(c=>c.fingerprint===o.fingerprint&&!d&&p?{...c,coveredBy:E(p.ref)}:c),drafts:d?u.drafts.map(c=>c.id===s.id?d:c):u.drafts.filter(c=>c.id!==s.id)})),d}seenInAnotherTask(e,t,o){const s=U(t.content);let r=!1;try{G(x(e,"task-notes.json"),i=>({signatures:i?.signatures&&typeof i.signatures=="object"&&!Array.isArray(i.signatures)?i.signatures:{}}),i=>{const n=Array.isArray(i.signatures[s])?i.signatures[s]:[];if(r=n.some(d=>d!==o),n.includes(o))return;const a=Object.entries({...i.signatures,[s]:[...n,o].slice(-4)});return{signatures:Object.fromEntries(a.slice(-200))}})}catch{return!1}return r}propose(e,t,o,s,r){const i=t.scope==="user"?this.userDir():e;try{D(i,n=>{const a=Fe(n,t,o,s);if(a.outcome.kind!=="suppressed"){if(a.outcome.kind==="created"&&r.proposed.push(a.outcome.lesson),a.transition){const d=a.transition.to;d==="active"&&r.notices.push({kind:"activated",lesson:a.transition.lesson}),d==="awaiting_user"&&r.notices.push({kind:"awaiting_user",lesson:a.transition.lesson})}return a.doc}})}catch{}}applyFeedback(e,t,o,s){let r=0;for(const i of[e,this.userDir()])D(i,n=>{const a=je(n,t,o,s);return r+=a.changed,a.changed>0?a.doc:void 0});return r}commandFeedback(e,t,o){if(t.injected.length===0)return[];const s=new Set(t.injected),r=[...m(o).lessons,...m(this.userDir()).lessons].filter(n=>s.has(n.id)&&n.fix),i=[];for(const n of r){const a=n.fix?.good;if(a)for(const d of e.steps){if(!d.command)continue;const p=R(d.cdDir?`cd ${d.cdDir} && ${d.command}`:d.command);if(!d.isError&&!d.unverifiedPass&&X(p,a)){i.push({id:n.id,tag:"helpful",why:`\`${a}\` passed`});break}if(d.isError&&X(p,a,!0)){i.push({id:n.id,tag:"harmful",why:`\`${a}\` failed`});break}}}return i}async draftWithModel(e,t,o,s,r){if(!t.complete){r.modelCall="unavailable";return}if(!this.claimCall(s,"draft")){r.modelCall="capped";return}const i={id:S(s),kind:"draft",createdAt:s,attempts:1,projectKey:o.key,projectRoot:o.root,sessionId:t.sessionId,excerpt:L(e,e.corrected?t.previousAssistant:void 0),reason:{corrected:e.corrected,detour:e.detour,denials:e.denials.length,fixes:e.fixes.length}};await this.draftFromExcerpt(i,t.complete,s,r)}async reflectWithModel(e,t,o,s,r,i){if(!o.complete){i.reflection="unavailable";return}if(!this.claimCall(r,"reflect")){i.reflection="capped";return}const n={id:S(r),kind:"reflect",injected:[...t],outcome:Be(e.steps)??"passed",...q(e.steps).length?{touched:q(e.steps)}:{},createdAt:r,attempts:1,projectKey:s.key,projectRoot:s.root,sessionId:o.sessionId,excerpt:L(e),reason:{corrected:!1,detour:!1,denials:0,fixes:e.fixes.length}};await this.draftFromExcerpt(n,o.complete,r,i)}async induceWithModel(e,t,o,s,r){if(!t.complete){r.induction="unavailable";return}if(!this.claimCall(s,"draft")){r.induction="capped";return}const i={id:S(s),kind:"induce",...t.injected.length>0?{injected:[...t.injected]}:{},createdAt:s,attempts:1,projectKey:o.key,projectRoot:o.root,sessionId:t.sessionId,excerpt:L(e),reason:{corrected:!1,detour:!1,denials:0,fixes:e.fixes.length}};await this.draftFromExcerpt(i,t.complete,s,r)}claimCall(e,t){try{return
|
|
1
|
+
var oe=Object.defineProperty;var k=(f,e)=>oe(f,"name",{value:e,configurable:!0});var re=Object.defineProperty,j=k((f,e)=>re(f,"name",{value:e,configurable:!0}),"y");import{existsSync as ie,readdirSync as ne,readFileSync as ae,realpathSync as ce}from"node:fs";import{join as x}from"node:path";import{t as y}from"@dalcode/dal-pi-kit";import{buildExtractPrompt as de,buildInducePrompt as ue,buildReflectPrompt as le,draftFromFix as pe,EXTRACT_SYSTEM_PROMPT as fe,INDUCE_SYSTEM_PROMPT as he,normalizeCommand as R,parseExtractAnswer as me,parseInduceAnswer as ke,parseReflectAnswer as ye,REFLECT_SYSTEM_PROMPT as ge,taskNoteSignature as U}from"./extract.js";import{applyFeedback as je,proposeLesson as Fe,readLessons as m,recordInjection as we,renderLessonsSection as xe,retireLessons as De,updateLessons as D}from"./lessons.js";import{desktopProjectsRoot as Ce,importDesktopRules as be}from"./migrate.js";import{procedureOf as Ee,proceduresPath as Ie,recordProcedure as Ae,updateProcedures as $}from"./procedures.js";import{identifyProject as Se}from"./project.js";import{learnFromRun as ve,readMap as Pe,renderMapSection as Re,updateMap as $e,viewMap as Me}from"./project-map.js";import{rejectLesson as Y,riskOf as M}from"./safety.js";import{analyzeRun as T,buildExcerpt as L,longSuccess as Te,needsModel as Le,needsReflection as _e,protectedChanges as q,runsChecks as X,verifiedOutcome as Be}from"./signals.js";import{acceptProposal as Ke}from"./skill-actions.js";import{applyPatches as z,decideScope as Oe,improvementFor as We,isEditable as Ne,lineDiff as b,MAX_SKILL_CHARS as Ue,matchSkill as Ye,restoreBefore as H,runOutcome as qe,skillKey as E,skillsLoaded as Xe,trackUse as ze}from"./skill-evolution.js";import{claimExtraction as He,claimPending as Ge,learnedRoot as Je,listPending as Qe,MAX_PENDING_ATTEMPTS as Ve,pendingDir as Ze,projectDir as I,recordExtractionTokens as et,removePending as tt,updateDoc as G,userDir as st,writePending as _}from"./store.js";const J=6,Q=4;function B(f,e){return e?.length?f.map(t=>t.tag==="helpful"?{...t,tag:"neutral",why:`${t.why} [not credited: the run changed ${e.join(", ")}]`.slice(0,200)}:t):f}k(B,"Je"),j(B,"capProtectedCredit");function A(f){return{signals:f,notices:[],proposed:[],taskNotes:[],feedback:0,modelCall:"none",reflection:"none",induction:"none"}}k(A,"_"),j(A,"emptyReport");function V(f,e){const t=[...f.list()],o=[...new Set((e.evidence??[]).flatMap(r=>r.skills))],s=[e.steps.join(" "),...o];for(const r of s)for(const i of f.search?.(r)??[])t.some(n=>n.name===i.name)||t.push(i);return t}k(V,"Qe"),j(V,"candidateSkills");class ot{static{k(this,"gt")}static{j(this,"Learner")}root;desktopRoot;dailyCap;reflectCap;autoAdoptInto;clock;inFlight=new Set;constructor(e={}){this.root=Je(e.root),this.desktopRoot=e.desktopRoot??Ce(),this.dailyCap=e.dailyCap??J,this.reflectCap=e.reflectCap??Math.min(Q,this.dailyCap),this.clock=e.now??Date.now,this.autoAdoptInto=e.autoAdoptInto}now(){return this.clock()}project(e){return Se(e)}projectDir(e){return I(this.root,e.key)}userDir(){return st(this.root)}recordProjectIdentity(e){const t=x(this.projectDir(e),"project.json");G(t,o=>({root:typeof o?.root=="string"?o.root:"",remote:o?.remote,roots:o?.roots}),o=>{const s=Array.isArray(o.roots)?o.roots:[];if(!(o.root===e.root&&s.includes(e.root)))return{root:e.root,remote:e.remote,roots:[...new Set([...s,e.root])].slice(-20)}})}startSession(e,t={}){const o=this.now(),s=this.project(e),r=this.projectDir(s);let i=0;const n=[];try{this.recordProjectIdentity(s)}catch{}try{D(r,l=>{const u=be(l,[s.root,e],this.desktopRoot,o);if(u)return i=u.added.length,u.doc})}catch{i=0}for(const l of[r,this.userDir()])try{D(l,u=>{const c=De(u,o);return n.push(...c.transitions),c.transitions.length>0?c.doc:void 0})}catch{}const a=this.render(s,o,t);for(const l of[r,this.userDir()])try{D(l,u=>{const c=we(u,a.lessonIds,a.eligible,o);return n.push(...c.transitions),c.doc===u?void 0:c.doc})}catch{}const{eligible:d,...p}=a;return{...p,imported:i,retired:n}}preview(e,t={}){const{eligible:o,...s}=this.render(this.project(e),this.now(),t);return{...s,imported:0,retired:[]}}render(e,t,o){const s=this.projectDir(e),r=m(s).lessons.filter(c=>!(o.hostHasLearnedSection&&c.origin?.kind==="desktop")),i=m(this.userDir()).lessons,n=Pe(s),a=xe([{label:"Your habits (every project)",lessons:i},{label:"This project",lessons:r}],{...o.request?{request:o.request}:{},paths:[...n.hotFiles.map(c=>c.path),...n.locations.map(c=>c.path)]}),d=new Set(a.ids),p=[...i,...r].filter(c=>d.has(c.id)&&c.fix),l=Me(n,e.root,t);l.pitfalls=l.pitfalls.filter(c=>!p.some(h=>h.fix?.bad.endsWith(c.bad)&&h.fix.good.endsWith(c.good)));const u=Re(l);return{project:e,...a.text?{lessons:a.text}:{},lessonIds:a.ids,eligible:a.eligible,lessonTokens:a.tokens,...u.text?{map:u.text}:{},mapTokens:u.tokens}}async onRunEnd(e,t){const o=this.now(),s=T(e,t.previousAssistant),r=A(s);let i;try{i=this.project(t.cwd)}catch{return r}const n=this.projectDir(i);let a=[];try{a=this.commandFeedback(s,t,n),a.length>0&&(r.feedback+=this.applyFeedback(n,a,t.sessionId,o))}catch{}try{$e(n,l=>ve(l,{root:i.root,cwd:te(t.cwd),sessionId:t.sessionId,steps:s.steps,fixes:s.fixes.filter(u=>u.proven),now:o}))}catch{}for(const l of s.fixes){let u=pe(l);Y({content:u.content})&&(u={...u,content:u.content.replace(/([^)]*)|\s\([^)]*\)/u,""),rootCause:""},Y({content:u.content}))||this.propose(n,u,t.sessionId,o,r)}const d=[...new Set([...Xe(s),...t.loadedSkills??[]])],p=qe(s);try{const l=p==="correction"?[...new Set([...d,...t.earlierSkills??[]])]:d;this.trackSkills(n,l,p,t,o,r)}catch{}try{const l=Ee(s.steps);if(l){let u;const c=s.fixes.map(h=>({bad:R(h.bad),good:R(h.good),reason:h.reason}));if($(n,h=>{const g=Ae(h,l,t.sessionId,o,{skills:d,fixes:c,outcome:p});return g.draft&&(u={draft:g.draft,procedure:g.procedure}),g.doc}),u){const h=await this.shapeProposal(n,i,u.procedure,u.draft,t,o);h&&r.notices.push(this.adoptOrPropose(n,i,h,o))}}}catch{}if(Le(s))await this.draftWithModel(s,t,i,o,r);else if(_e(s,t.injected)){const l=new Set(a.map(c=>c.id));for(const c of[...m(n).lessons,...m(this.userDir()).lessons])c.feedback.some(h=>h.sessionId===t.sessionId)&&l.add(c.id);const u=t.injected.filter(c=>!l.has(c));u.length>0&&await this.reflectWithModel(s,u,t,i,o,r)}return Te(s)&&await this.induceWithModel(s,t,i,o,r),r}adoptOrPropose(e,t,o,s){if(!this.autoAdoptInto||o.risk&&o.risk.length>0)return{kind:"skill_proposed",draft:o};const r=Ke({root:this.root,projectDir:e,projectKey:t.key,userSkillsDir:this.autoAdoptInto,id:o.id,now:s});return r.kind==="accepted"?{kind:"skill_adopted",draft:r.draft,paths:r.paths}:{kind:"skill_proposed",draft:o}}skillFeedback(e,t,o,s){const r=A(T([]));if(o.length===0)return[];try{const i=this.projectDir(this.project(e));this.trackSkills(i,o,"correction",{cwd:e,sessionId:t,injected:[],skills:s},this.now(),r)}catch{}return r.notices}trackSkills(e,t,o,s,r,i){if(t.length===0)return;const n=s.skills?.list()??[],a=t.flatMap(d=>{const p=n.filter(l=>l.name===d);return p.length>0?p.map(E):[E({origin:"cloud",name:d})]});for(const d of ze(this.root,a,s.sessionId,o,r)){if(H(this.root,d.key,d.proposalId,"revert",r).kind!=="restored")continue;let p;$(e,u=>{const c=u.drafts.findIndex(g=>g.id===d.proposalId);if(c<0)return;p={...u.drafts[c],status:"undone"};const h=[...u.drafts];return h[c]=p,{...u,drafts:h}});const l=p?.target;p?.kind==="split"&&l&&l.key!==d.key&&H(this.root,l.key,d.proposalId,"revert",r),i.notices.push({kind:"skill_reverted",skill:d.name,proposalId:d.proposalId,...p?{draft:p}:{},uses:{total:d.uses.length,bad:d.uses.filter(u=>u.outcome!=="success").length}})}}otherProjectsWith(e,t){let o=0,s=[];try{s=ne(x(this.root,"projects"))}catch{return 0}for(const r of s){const i=x(this.root,"projects",r);if(i!==t)try{ae(Ie(i),"utf8").includes(e)&&o++}catch{}}return o}async shapeProposal(e,t,o,s,r,i){const n=(o.evidence??[]).map(u=>({sessionId:u.sessionId,at:u.at,note:Z(u)})),a=Oe(o,t.root,this.otherProjectsWith(o.fingerprint,e));let d={...s,kind:"new",scope:a.scope,scopeReason:a.reason,diff:b("",s.content,`${s.name}/SKILL.md`),evidence:n,risk:M(s.content)};const p=r.skills?Ye(o,V(r.skills,o)):void 0,l=p?await r.skills?.text(p.ref).catch(()=>{}):void 0;if(p&&l!==void 0){const u=We(l,o,i,s.id),c=p.ref,h=E(c);if(!u)d=void 0;else{const g=c.origin==="learned-project"&&c.projectKey===t.key,C=a.scope==="project"&&!g,v=Ne(c)&&!C,K=C?{...u,projectKey:t.key}:u,O={key:h,name:c.name,origin:c.origin,editable:v,...c.filePath?{filePath:c.filePath}:{}},se=g||C||c.origin==="project"?"project":"user",W=p.why==="loaded"?F(y("\u8FD9\u4E9B\u4F1A\u8BDD\u91CC\u6709 {n} \u4E2A\u52A0\u8F7D\u8FC7\u6280\u80FD\u300C{name}\u300D"),{n:p.count,name:c.name}):F(y("\u6280\u80FD\u300C{name}\u300D\u7684\u540D\u79F0\u548C\u8BF4\u660E\u4E0E\u8FD9\u5957\u6B65\u9AA4\u76F8\u7B26"),{name:c.name});if(l.length+u.text.length>Ue){const w=`${c.name}-${s.name}`.slice(0,64).replace(/-+$/g,""),P=ee(w,c.name,o,u.text),N={id:`${s.id}p`,mode:"append",text:F(y("\u53E6\u89C1\u6280\u80FD\u300C{name}\u300D\uFF1A\u672C\u673A\u8865\u5145\u7684\u505A\u6CD5\u3002"),{name:w}),proposalId:s.id,created:u.created,...C?{projectKey:t.key}:{}};d={...s,name:w,content:P,kind:"split",scope:a.scope,scopeReason:`${W}\uFF1B${F(y("\u5B83\u5DF2\u7ECF\u5F88\u957F\uFF08{n} \u5B57\u7B26\uFF09\uFF0C\u8865\u5145\u53E6\u6210\u4E00\u4E2A\u6280\u80FD"),{n:l.length})}\uFF1B${a.reason}`,target:O,patch:N,diff:[b("",P,`${w}/SKILL.md`),b(l,z(l,[N],{marker:!v,projectKey:t.key}).text,`${c.name}`)].join(`
|
|
2
|
+
`),evidence:n,risk:M(P)}}else{const w=z(l,[K],{marker:!v,projectKey:t.key}).text;d={...s,name:c.name,content:"",kind:"improve",scope:se,scopeReason:`${W}\uFF1B${a.reason}`,target:O,patch:K,diff:b(l,w,c.name),evidence:n,risk:M(u.text)}}}}return $(e,u=>({...u,procedures:u.procedures.map(c=>c.fingerprint===o.fingerprint&&!d&&p?{...c,coveredBy:E(p.ref)}:c),drafts:d?u.drafts.map(c=>c.id===s.id?d:c):u.drafts.filter(c=>c.id!==s.id)})),d}seenInAnotherTask(e,t,o){const s=U(t.content);let r=!1;try{G(x(e,"task-notes.json"),i=>({signatures:i?.signatures&&typeof i.signatures=="object"&&!Array.isArray(i.signatures)?i.signatures:{}}),i=>{const n=Array.isArray(i.signatures[s])?i.signatures[s]:[];if(r=n.some(d=>d!==o),n.includes(o))return;const a=Object.entries({...i.signatures,[s]:[...n,o].slice(-4)});return{signatures:Object.fromEntries(a.slice(-200))}})}catch{return!1}return r}propose(e,t,o,s,r){const i=t.scope==="user"?this.userDir():e;try{D(i,n=>{const a=Fe(n,t,o,s);if(a.outcome.kind!=="suppressed"){if(a.outcome.kind==="created"&&r.proposed.push(a.outcome.lesson),a.transition){const d=a.transition.to;d==="active"&&r.notices.push({kind:"activated",lesson:a.transition.lesson}),d==="awaiting_user"&&r.notices.push({kind:"awaiting_user",lesson:a.transition.lesson})}return a.doc}})}catch{}}applyFeedback(e,t,o,s){let r=0;for(const i of[e,this.userDir()])D(i,n=>{const a=je(n,t,o,s);return r+=a.changed,a.changed>0?a.doc:void 0});return r}commandFeedback(e,t,o){if(t.injected.length===0)return[];const s=new Set(t.injected),r=[...m(o).lessons,...m(this.userDir()).lessons].filter(n=>s.has(n.id)&&n.fix),i=[];for(const n of r){const a=n.fix?.good;if(a)for(const d of e.steps){if(!d.command)continue;const p=R(d.cdDir?`cd ${d.cdDir} && ${d.command}`:d.command);if(!d.isError&&!d.unverifiedPass&&X(p,a)){i.push({id:n.id,tag:"helpful",why:`\`${a}\` passed`});break}if(d.isError&&X(p,a,!0)){i.push({id:n.id,tag:"harmful",why:`\`${a}\` failed`});break}}}return i}async draftWithModel(e,t,o,s,r){if(!t.complete){r.modelCall="unavailable";return}if(!this.claimCall(s,"draft")){r.modelCall="capped";return}const i={id:S(s),kind:"draft",createdAt:s,attempts:1,projectKey:o.key,projectRoot:o.root,sessionId:t.sessionId,excerpt:L(e,e.corrected?t.previousAssistant:void 0),reason:{corrected:e.corrected,detour:e.detour,denials:e.denials.length,fixes:e.fixes.length}};await this.draftFromExcerpt(i,t.complete,s,r)}async reflectWithModel(e,t,o,s,r,i){if(!o.complete){i.reflection="unavailable";return}if(!this.claimCall(r,"reflect")){i.reflection="capped";return}const n={id:S(r),kind:"reflect",injected:[...t],outcome:Be(e.steps)??"passed",...q(e.steps).length?{touched:q(e.steps)}:{},createdAt:r,attempts:1,projectKey:s.key,projectRoot:s.root,sessionId:o.sessionId,excerpt:L(e),reason:{corrected:!1,detour:!1,denials:0,fixes:e.fixes.length}};await this.draftFromExcerpt(n,o.complete,r,i)}async induceWithModel(e,t,o,s,r){if(!t.complete){r.induction="unavailable";return}if(!this.claimCall(s,"draft")){r.induction="capped";return}const i={id:S(s),kind:"induce",...t.injected.length>0?{injected:[...t.injected]}:{},createdAt:s,attempts:1,projectKey:o.key,projectRoot:o.root,sessionId:t.sessionId,excerpt:L(e),reason:{corrected:!1,detour:!1,denials:0,fixes:e.fixes.length}};await this.draftFromExcerpt(i,t.complete,s,r)}claimCall(e,t){try{return He(this.root,t==="reflect"?this.reflectCap:this.dailyCap,e,t)}catch{return!1}}async ask(e,t,o,s,r){const i={job:e,kept:!1,abort:new AbortController};this.inFlight.add(i);let n;try{n=await s(t,o,i.abort.signal)}catch{return{status:"failed"}}finally{this.inFlight.delete(i)}if(!n)return{status:"unavailable"};if(i.kept&&!tt(this.root,e.id))return{status:"none"};try{et(this.root,n.inputTokens??0,n.outputTokens??0,r)}catch{}return{status:"done",answer:n}}async draftFromExcerpt(e,t,o,s){if(e.kind==="reflect")return s.reflection=await this.reflectFromExcerpt(e,t,o,s),s.reflection;if(e.kind==="induce")return s.induction=await this.induceFromExcerpt(e,t,o,s),s.induction;const r=I(this.root,e.projectKey),i={corrected:e.reason.corrected,detour:e.reason.detour,denials:{length:e.reason.denials},fixes:{length:e.reason.fixes}},n=[...m(r).lessons,...m(this.userDir()).lessons],{status:a,answer:d}=await this.ask(e,fe,de(e.excerpt,i,n),t,o);if(s.modelCall=a,!d)return a;const p=me(d.text,i);for(const l of p.drafts)this.propose(r,l,e.sessionId,o,s);for(const l of p.taskNotes)s.taskNotes.push(l),this.seenInAnotherTask(r,l,e.sessionId)&&this.propose(r,{scope:"project",section:l.section,content:l.content,rootCause:l.rootCause,signal:l.signal,note:l.note,signature:`task:${U(l.content)}`},e.sessionId,o,s);return a}async induceFromExcerpt(e,t,o,s){const r=I(this.root,e.projectKey),i=[...m(r).lessons,...m(this.userDir()).lessons],{status:n,answer:a}=await this.ask(e,he,ue(e.excerpt,i,e.injected??[]),t,o);if(!a)return n;const d=/^\[user\] (.*)$/m.exec(e.excerpt)?.[1]??"";for(const p of ke(a.text,d).drafts)this.propose(r,p,e.sessionId,o,s);return n}async reflectFromExcerpt(e,t,o,s){const r=I(this.root,e.projectKey),i=new Set(e.injected??[]),n=[...m(r).lessons,...m(this.userDir()).lessons].filter(l=>i.has(l.id)&&l.status==="active");if(n.length===0)return"none";const{status:a,answer:d}=await this.ask(e,ge,le(e.excerpt,e.outcome??"passed",n),t,o);if(!d)return a;const p=B(ye(d.text,n.map(l=>l.id)),e.touched);if(p.length>0)try{s.feedback+=this.applyFeedback(r,p,e.sessionId,o)}catch{}return a}keepUnfinished(){let e=0;for(const t of this.inFlight)if(!t.kept){try{_(this.root,t.job),t.kept=!0,e++}catch{continue}t.abort.abort()}return e}async finishPending(e,t=2){const o=[];let s;try{s=Qe(this.root,this.now())}catch{return o}for(const r of s.slice(0,t)){const i=this.now(),n=Ge(this.root,r.id);if(!n)continue;if(!this.claimCall(i,n.kind==="reflect"?"reflect":"draft")){try{_(this.root,n)}catch{}continue}const a=A(T([])),d={...n,attempts:n.attempts+1},p=await this.draftFromExcerpt(d,e,i,a);if(p==="failed"||p==="unavailable")try{d.attempts<Ve&&!ie(x(Ze(this.root),`${n.id}.json`))&&_(this.root,d)}catch{}o.push({project:{key:n.projectKey,root:n.projectRoot},report:a})}return o}}function S(f){return`${f.toString(36)}-${Math.random().toString(36).slice(2,10)}`}k(S,"$"),j(S,"pendingId");function F(f,e){return f.replace(/\{(\w+)\}/g,(t,o)=>o in e?String(e[o]):t)}k(F,"S"),j(F,"fill");function Z(f){const e=[];f.outcome==="correction"&&e.push(y("\u4F60\u7EA0\u6B63\u4E86\u52A9\u624B")),f.outcome==="failure"&&e.push(y("\u68C0\u67E5\u5931\u8D25\u672A\u4FEE\u597D"));for(const t of f.fixes.slice(0,2))e.push(F(y("`{bad}` \u5931\u8D25\u540E\u6539\u7528 `{good}`"),t));return f.skills.length>0&&e.push(F(y("\u52A0\u8F7D\u4E86\u6280\u80FD {names}"),{names:f.skills.join("\u3001")})),e.length>0?e.join(y("\uFF1B")):y("\u987A\u5229\u5B8C\u6210")}k(Z,"Ve"),j(Z,"evidenceNote");function ee(f,e,t,o){const s=t.steps.join(" \u2192 "),r=F(y("\u300C{original}\u300D\u5728\u672C\u673A\u7684\u8865\u5145\u505A\u6CD5\uFF08{flow}\uFF09\u3002\u548C\u300C{original}\u300D\u4E00\u8D77\u4F7F\u7528\u3002"),{original:e,flow:s});return`---
|
|
3
3
|
name: ${f}
|
|
4
4
|
description: ${JSON.stringify(r)}
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
${o}
|
|
8
|
-
`}k(ee,"
|
|
8
|
+
`}k(ee,"Ze"),j(ee,"companionSkill");function te(f){try{return ce(f)}catch{return f}}k(te,"et"),j(te,"realCwd");export{J as DEFAULT_DAILY_CAP,Q as DEFAULT_REFLECT_CAP,ot as Learner,B as capProtectedCredit};
|