alchemylab 1.2.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/640.js +14 -0
- package/dist/cli.js +177 -90
- package/dist/http-server.js +619 -582
- package/dist/index.js +411 -374
- package/dist/mcp-direct.js +152 -115
- package/package.json +1 -1
package/dist/mcp-direct.js
CHANGED
|
@@ -701,41 +701,44 @@ return t},n(e)},function(e){if(e&&e.__esModule)return e
|
|
|
701
701
|
var t={}
|
|
702
702
|
if(null!=e)for(var r=n(e),i=0;i<r.length;i++)"default"!==r[i]&&o(t,e,r[i])
|
|
703
703
|
return s(t,e),t})
|
|
704
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.logSessionIdentity=void 0,exports.registerTools=function(e,
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
try{return await
|
|
708
|
-
|
|
704
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.logSessionIdentity=void 0,exports.registerTools=function(e,n,o,s,i,g,f){const y=s.child({component:"tools"})
|
|
705
|
+
y.info("Registering tools...")
|
|
706
|
+
const w=!!g,k=async()=>{if(!w)return!0
|
|
707
|
+
try{return await g.hasValidToken()}catch(e){return y.error("Error checking authentication status",{error:(0,l.getErrorMessage)(e)}),!1}},I=async()=>{const e=(0,c.areTestsRequiredForCompletion)(),t=await k()
|
|
708
|
+
y.info(`Generating tools list with testsRequired=${e}, authenticated=${t}`)
|
|
709
709
|
const r={testsRequired:e,authenticated:t}
|
|
710
710
|
return(0,m.generateVisibleToolsList)(r)}
|
|
711
|
-
let I
|
|
712
|
-
|
|
713
|
-
let
|
|
714
|
-
e.setRequestHandler(a.CallToolRequestSchema,(async e=>{try{const{name:
|
|
715
|
-
const
|
|
711
|
+
let b=I(),v=[]
|
|
712
|
+
b.then((e=>{v=e})).catch((e=>{y.error("Error generating initial tools list",{error:(0,l.getErrorMessage)(e)}),v=[]})),e.setRequestHandler(a.ListToolsRequestSchema,(async()=>{try{return v=await I(),{tools:v}}catch(e){return y.error("Error generating tools list",{error:(0,l.getErrorMessage)(e)}),{tools:[]}}}))
|
|
713
|
+
let C=!1
|
|
714
|
+
e.setRequestHandler(a.CallToolRequestSchema,(async e=>{try{const{name:a,arguments:c={},_meta:g}=e.params;(0,p.logSessionIdentity)(a,"_meta-debug",{has_meta:!!g,sessionId:g?.sessionId||null,messageId:g?.messageId||null,paramKeys:Object.keys(e.params)}),y.info("Tool call received: "+a,{tool:a}),i.incrementCounter("tool_calls_total",1,{tool:a})
|
|
715
|
+
const I=i.startTimer("tool_execution_time")
|
|
716
716
|
Date.now()
|
|
717
|
-
let
|
|
718
|
-
const
|
|
719
|
-
if(Date.now(),
|
|
720
|
-
if(Date.now(),!e)return
|
|
721
|
-
let
|
|
722
|
-
if(
|
|
723
|
-
if(
|
|
724
|
-
else{const
|
|
725
|
-
u.sessionIdentity.setIdentity({providerId:"opencode",sessionId:e,serverUrl:
|
|
726
|
-
u.sessionIdentity.setCurrentCallOrigin(
|
|
727
|
-
const E
|
|
728
|
-
if(
|
|
729
|
-
try{const e=await(0,d.getServerUrl)(
|
|
730
|
-
e&&
|
|
731
|
-
if(e?.sessionId&&t){const r=t.match(/^requests\/(.+)$/),
|
|
732
|
-
if(r&&!
|
|
733
|
-
|
|
734
|
-
try{const{sessionTag:r}=(0,h.getGlobalClientInfo)(),o
|
|
735
|
-
await Promise.all([i,a])}catch(e){
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
717
|
+
let b=Date.now()
|
|
718
|
+
const v=r(c)
|
|
719
|
+
if(Date.now(),b=Date.now(),w){const e=await k()
|
|
720
|
+
if(Date.now(),!e)return y.warn("Unauthenticated tool call attempt",{tool:a}),{content:[{type:"text",text:"Authentication required. Please run 'alchemylab setup' to authenticate and configure your project."}],isError:!0}}const _=(0,m.getToolByName)(a)
|
|
721
|
+
let E
|
|
722
|
+
if(b=Date.now(),o?(o.setOptions({createRecords:_?.createsRecords??!1}),y.info(`Setting record creation for tool ${a}: ${_?.createsRecords??!1}`)):y.debug(`No API client available for tool ${a} (minimal mode)`),Date.now(),Date.now(),b=Date.now(),g?.sessionId){const e=g.sessionId,t=g.messageId,r=u.sessionIdentity.getIdentity()
|
|
723
|
+
if(r)r.sessionId!==e&&((0,p.logSessionIdentity)(a,"_meta-session-switch",{prevSessionId:r.sessionId,prevAgentType:r.agentType,newSessionId:e}),u.sessionIdentity.setIdentity({providerId:"opencode",sessionId:e,serverUrl:r.serverUrl}),n?.workspaceManager?.resetCurrentContext?.(e))
|
|
724
|
+
else{const t=await(0,d.getServerUrl)(n,y)
|
|
725
|
+
u.sessionIdentity.setIdentity({providerId:"opencode",sessionId:e,serverUrl:t||""})}E={providerId:"opencode",sessionId:e,messageId:t,createdAt:(new Date).toISOString()},(0,p.logSessionIdentity)(a,"_meta",{sessionId:e,messageId:t})}else y.warn("No _meta.sessionId on tool call \u2014 session identity unavailable",{tool:a})
|
|
726
|
+
u.sessionIdentity.setCurrentCallOrigin(E)
|
|
727
|
+
const q=E?.sessionId||g?.sessionId
|
|
728
|
+
if(n?.workspaceManager){b=Date.now()
|
|
729
|
+
try{const e=await(0,d.getServerUrl)(n,y)
|
|
730
|
+
e&&o&&await n.workspaceManager.ensureReadonlyBranchIfNeeded(e,a,o,q)}catch(e){y.debug("Error during workspace check",{error:(0,l.getErrorMessage)(e)})}Date.now()}if(!C&&o){const e=u.sessionIdentity.getIdentity(),t=process.env.ALCHEMY_INITIAL_BRANCH
|
|
731
|
+
if(e?.sessionId&&t){const r=t.match(/^requests\/(.+)$/),n="1"===process.env.ALCHEMY_ALLOW_PARALLEL
|
|
732
|
+
if(r&&!n){const t=r[1]
|
|
733
|
+
C=!0
|
|
734
|
+
try{const{sessionTag:r}=(0,h.getGlobalClientInfo)(),n=o.getSessionTagMappingClient(),s=o.getRequestClient(),i=n?n.getMappingByOpencodeSessionId(e.sessionId).then((t=>{t?((0,h.setSessionTag)(t.sessionTag),y.info("Recovered session tag from mapping",{opencodeSessionId:e.sessionId,sessionTag:t.sessionTag})):(n.createOrUpdateMapping(r,e.sessionId).catch((()=>{})),y.info("Registered session tag mapping",{opencodeSessionId:e.sessionId,sessionTag:r}))}),(e=>y.debug("Mapping lookup failed",{error:(0,l.getErrorMessage)(e)}))):Promise.resolve(),a=s.lockRequest?s.lockRequest(t,r).then((e=>{e.locked?y.info("Acquired request lock",{requestId:t,sessionTag:r}):y.warn("Failed to acquire request lock",{requestId:t,sessionTag:r})}),(e=>y.warn("Lock acquisition failed",{error:(0,l.getErrorMessage)(e)}))):Promise.resolve()
|
|
735
|
+
await Promise.all([i,a])}catch(e){y.warn("Error in session tag mapping / lock acquisition",{error:(0,l.getErrorMessage)(e)})}}}}n&&(n.currentSessionId=q||"__unknown__")
|
|
736
|
+
const S=`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,T=e=>{const{getActionServerBaseUrl:r}=t(9414)
|
|
737
|
+
fetch(r()+"/api/mcp/tool-call-event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,callId:S}),signal:AbortSignal.timeout(500)}).catch((()=>{}))}
|
|
738
|
+
let x
|
|
739
|
+
T("start")
|
|
740
|
+
try{if(_){const e={context:n,apiClient:o,logger:s,metrics:i,mcpServer:f,cliOrigin:E}
|
|
741
|
+
x=await _.handler(v,e)}else y.info(`Tool ${a} not found, returning negative response`),x={content:[{type:"text",text:`The tool '${a}' does not exist.`}]}}finally{T("end")}return Date.now(),Date.now(),I({tool:a,success:!0}),x}catch(t){y.error("Error executing tool:",{error:t instanceof Error?t.stack:t+"",tool:e.params.name}),i.incrementCounter("tool_errors_total",1,{tool:e.params.name,error:t instanceof Error?t.name:"unknown"})
|
|
739
742
|
let r="Unknown error"
|
|
740
743
|
if(t instanceof Error)r=t.message
|
|
741
744
|
else if("string"==typeof t)r=t
|
|
@@ -748,7 +751,7 @@ else if(e.body&&"string"==typeof e.body)try{const t=JSON.parse(e.body)
|
|
|
748
751
|
r=t.error&&t.error.message?t.error.message:t.message?t.message:e.body.substring(0,200)}catch{r=e.body.substring(0,200)}else{const t=Object.keys(e).filter((t=>"string"==typeof e[t]&&e[t].length>0))
|
|
749
752
|
if(t.length>0){const n=t[0]
|
|
750
753
|
r=`${n}: ${e[n]}`}else r="Unknown error (no readable properties)"}}else r=t+""
|
|
751
|
-
return{content:[{type:"text",text:"Error: "+r}],isError:!0}}})),
|
|
754
|
+
return{content:[{type:"text",text:"Error: "+r}],isError:!0}}})),y.info("Tools registration complete")}
|
|
752
755
|
const a=t(9150),c=t(2478),l=t(8824),d=t(7617),u=t(6688),h=t(5172)
|
|
753
756
|
i(t(9896)),i(t(6928))
|
|
754
757
|
var g=t(7280)
|
|
@@ -1277,7 +1280,7 @@ case"list-sessions":const s={activeOnly:r.activeOnly,requestId:r.requestId,limit
|
|
|
1277
1280
|
m=await h(t,c,i,s)
|
|
1278
1281
|
break
|
|
1279
1282
|
default:throw new y.ValidationError("Unknown operation: "+p)}return l({success:!0}),s.incrementCounter(`subagent_operations_${p}_success`,1),m}catch(e){return c.error("Subagent operations failed",{error:e instanceof Error?e.stack:e+""}),l({success:!1}),s.incrementCounter("subagent_operations_errors",1),{content:[{type:"text",text:"Subagent operation failed: "+(0,_.getErrorMessage)(e)}],isError:!0}}}
|
|
1280
|
-
const y=t(9860),w=t(8035),k=t(7617),I=t(6688),b=t(7280),v=t(6183),C=f(t(5967)),_=t(8824),E=t(9896),q=t(6928),S=t(8955),T=
|
|
1283
|
+
const y=t(9860),w=t(8035),k=t(7617),I=t(6688),b=t(7280),v=t(6183),C=f(t(5967)),_=t(8824),E=t(9896),q=t(6928),S=t(8955),T=(0,t(9414).getActionServerPort)(),x=6e4,R=3e5},1791(e,exports,t){"use strict"
|
|
1281
1284
|
function r(e,t){return t.info("Creating project context middleware",{projectId:e}),(t,r,n)=>{"GET"===t.method&&(t.query.projectId=e),["POST","PATCH","PUT"].includes(t.method)&&t.body&&(t.body.projectId=e),n()}}var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
1282
1285
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProjectContext=void 0,exports.projectContextMiddleware=r
|
|
1283
1286
|
const o=n(t(9896)),s=n(t(6928)),i=t(4139),a=t(4055),c=t(8824)
|
|
@@ -1436,18 +1439,18 @@ try{const e=d(t.command,{cwd:h,timeout:1e3*t.timeout,encoding:"utf-8",stdio:["pi
|
|
|
1436
1439
|
p.push({name:t.name,command:t.command,exitCode:0,output:e.slice(-4e3),timedOut:!1})}catch(r){const n=!0===r.killed,o=((r.stdout||"")+"\n"+(r.stderr||"")).trim().slice(-4e3),s=r.status??1
|
|
1437
1440
|
if(p.push({name:t.name,command:t.command,exitCode:s,output:o,timedOut:n}),"setup"===e.commandName)break}}const m=p.every((e=>0===e.exitCode)),f=p.map((e=>{const t=e.timedOut?"\u23f1 TIMEOUT":0===e.exitCode?"\u2705 PASS":`\u274c FAIL (exit ${e.exitCode})`
|
|
1438
1441
|
return`### ${e.name}: ${t}\n\`\`\`\n$ ${e.command}\n${e.output}\n\`\`\``})).join("\n\n")
|
|
1439
|
-
return a({success:!0}),{content:[{type:"text",text:`## ${"setup"===e.commandName?"Setup":e.commandName} \u2014 ${m?"PASSED":"FAILED"}\n\n${f}`}]}}catch(e){return a({success:!1,error:"execution_error"}),{content:[{type:"text",text:"Failed to execute test command: "+(0,r.getErrorMessage)(e)}],isError:!0}}},exports.handleReportTestResults=async function(e,o,s,i,a){const
|
|
1440
|
-
try{const{sessionIdentity:
|
|
1441
|
-
if(!
|
|
1442
|
-
const
|
|
1443
|
-
if(!
|
|
1444
|
-
const m
|
|
1445
|
-
await s.proxyPatch(`/api/projects/${o.projectId}/test-runs/${
|
|
1446
|
-
const
|
|
1442
|
+
return a({success:!0}),{content:[{type:"text",text:`## ${"setup"===e.commandName?"Setup":e.commandName} \u2014 ${m?"PASSED":"FAILED"}\n\n${f}`}]}}catch(e){return a({success:!1,error:"execution_error"}),{content:[{type:"text",text:"Failed to execute test command: "+(0,r.getErrorMessage)(e)}],isError:!0}}},exports.handleReportTestResults=async function(e,o,s,i,a,c){const l=a.startTimer("tool_execution_time")
|
|
1443
|
+
try{const{sessionIdentity:d}=await Promise.resolve().then(t.bind(t,6688)),u=await d.getSessionRequestId(s,i,c?.sessionId)
|
|
1444
|
+
if(!u)return l({success:!1,error:"no_request_association"}),{content:[{type:"text",text:"Cannot report test results: this session is not associated with a request."}],isError:!0}
|
|
1445
|
+
const h=await s.proxyGet(`/api/projects/${o.projectId}/requests/${u}/test-runs`),g=h?.data||h||[],p=Array.isArray(g)?g:[],m=p.find((e=>"pending"===e.status||"running"===e.status))||p[0]
|
|
1446
|
+
if(!m)return l({success:!1,error:"no_test_run"}),{content:[{type:"text",text:`No test run found for request ${u}.`}],isError:!0}
|
|
1447
|
+
const f=m.id
|
|
1448
|
+
await s.proxyPatch(`/api/projects/${o.projectId}/test-runs/${f}`,{status:e.status,results:e.results})
|
|
1449
|
+
const y="passed"===e.status?"\u2705":"failed"===e.status?"\u274c":"\u26a0\ufe0f"
|
|
1447
1450
|
try{const t=s.getRequestClient()
|
|
1448
|
-
"passed"===e.status?(await t.updateRequest(
|
|
1449
|
-
try{const t=await(0,n.handleSessionMessageOperations)({operation:"send",type:"report",status:"passed"===e.status?"success":"failure",summary:
|
|
1450
|
-
return
|
|
1451
|
+
"passed"===e.status?(await t.updateRequest(u,{status:"ready_for_merge"}),i.info("Tests passed, set request to ready_for_merge",{requestId:u})):(await t.updateRequest(u,{status:"in_progress"}),i.info("Tests failed, set request back to in_progress",{requestId:u}))}catch(e){i.warn("Failed to update request status after test results",{requestId:u,error:(0,r.getErrorMessage)(e)})}const w="passed"===e.status?"\n\nAll tests passed \u2014 the coder can now call `merge` to merge this request.":"\n\nTests failed \u2014 the coder should fix the issues and call `complete` again.",k=`${y} Test run ${e.status} for request ${u}\n\n${e.results.summary}${w}`
|
|
1452
|
+
try{const t=await(0,n.handleSessionMessageOperations)({operation:"send",type:"report",status:"passed"===e.status?"success":"failure",summary:k,details:e.results.commands?.map((e=>`${"passed"===e.status?"\u2705":"\u274c"} ${e.name}: ${e.status}${e.diagnosis?" - "+e.diagnosis:""}`)).join("\n"),finish:!0},o,i,a,s,c),r=t?.content?.[0]?.text||"unknown",d=t?.isError
|
|
1453
|
+
return l({success:!0}),{content:[{type:"text",text:`Test run for request ${u} reported as **${e.status}**.${d?" Parent notification FAILED: "+r:" Parent session notified."}\n\n${e.results.summary}`}]}}catch(t){return l({success:!0}),{content:[{type:"text",text:`Test run for request ${u} reported as **${e.status}** but failed to notify parent: ${(0,r.getErrorMessage)(t)}\n\n${e.results.summary}`}]}}}catch(e){return l({success:!1,error:"api_error"}),{content:[{type:"text",text:"Failed to report test results: "+(0,r.getErrorMessage)(e)}],isError:!0}}},exports.handleTestingReference=async function(e,t,r,n,o){return o.startTimer("tool_execution_time")({success:!0}),{content:[{type:"text",text:'# Test Process Design Guide\n\n## Overview\n\nA test process defines how to verify code changes for a project. It consists of:\n- **Setup**: Commands to prepare the environment (install deps, link node_modules, etc.) \u2014 runs once per worktree\n- **Commands**: The actual test commands (build, lint, test, etc.) \u2014 the verification steps\n\n## Command Properties\n\n- **name**: Human-readable name (e.g., "Build", "Unit Tests")\n- **command**: Shell command to run (e.g., `npm test`)\n- **required** (default: true): If a required command fails, the request won\'t be merged\n- **timeout** (default: 300s): Maximum execution time. Exit code 0 = pass, non-zero = fail.\n\n## Scope (Monorepo Support)\n\nSet `scope` to a path prefix to limit when a process runs:\n- `scope: "packages/api/"` \u2192 only runs when files under packages/api/ change\n- `scope: null` \u2192 runs for all changes (global process)\n\nMultiple active processes per project are supported.\n\n## Common Patterns\n\n### Node.js / TypeScript\n```json\n{\n "setup": ["ln -s ../../node_modules node_modules"],\n "commands": [\n { "name": "Build", "command": "npm run build" },\n { "name": "Lint", "command": "npm run lint", "required": false },\n { "name": "Unit Tests", "command": "npm test" }\n ]\n}\n```\n\n### Python\n```json\n{\n "setup": ["pip install -e \'.[dev]\'"],\n "commands": [\n { "name": "Type Check", "command": "mypy src/" },\n { "name": "Lint", "command": "ruff check .", "required": false },\n { "name": "Tests", "command": "pytest" }\n ]\n}\n```\n\n### Go\n```json\n{\n "setup": ["go mod download"],\n "commands": [\n { "name": "Build", "command": "go build ./..." },\n { "name": "Vet", "command": "go vet ./...", "required": false },\n { "name": "Tests", "command": "go test ./..." }\n ]\n}\n```\n\n### Rust\n```json\n{\n "setup": ["cargo fetch"],\n "commands": [\n { "name": "Build", "command": "cargo build" },\n { "name": "Clippy", "command": "cargo clippy -- -D warnings", "required": false },\n { "name": "Tests", "command": "cargo test" }\n ]\n}\n```\n\n## Project Analysis Checklist\n\nWhen setting up testing for a new project, check for:\n1. **package.json** \u2192 Node.js/TypeScript (check "scripts" for test/build/lint commands)\n2. **Cargo.toml** \u2192 Rust\n3. **go.mod** \u2192 Go\n4. **pyproject.toml** / **requirements.txt** \u2192 Python\n5. **Makefile** \u2192 Custom build system (check for test/build targets)\n6. **.github/workflows/** \u2192 Existing CI configuration (great source of test commands)\n7. **.gitlab-ci.yml** \u2192 GitLab CI\n8. **tsconfig.json** \u2192 TypeScript type checking\n9. **.eslintrc** / **biome.json** \u2192 Linting configuration\n10. **vitest.config.ts** / **jest.config.ts** / **pytest.ini** \u2192 Test framework configuration'}]}}
|
|
1451
1454
|
const r=t(8824),n=t(9072)},2085(e,exports,t){"use strict"
|
|
1452
1455
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRequestTimelineForFile=async function(e,t,s,i){let a=`# File History: ${t}\n\n`
|
|
1453
1456
|
a+="**Context**: Main branch (request-level view)\n\n"
|
|
@@ -1475,7 +1478,29 @@ case"manage-files":return"\u{1f4c1} Manage Files"
|
|
|
1475
1478
|
default:return e}}(t.type)}\n`,s+=`**Time**: ${n.toLocaleString()}\n`,s+=`**Comment**: ${o}\n`,"write-file"===t.type&&(s+=`**Action**: File ${t.metadata?.append?"appended":"written"}\n`),"replace-in-files"===t.type&&t.metadata?.operations){const r=t.metadata.operations.find((t=>t.path===e))
|
|
1476
1479
|
r&&r.replacements&&(s+=`**Replacements**: ${r.replacements.length}\n`)}if("move-files"===t.type&&t.metadata?.successfulOperations){const r=t.metadata.successfulOperations.find((t=>t.source===e||t.destination===e))
|
|
1477
1480
|
r&&(s+=`**Move**: ${r.source} \u2192 ${r.destination}\n`)}t.metadata?.commitHash&&(s+=`**Commit**: ${t.metadata.commitHash.substring(0,8)}\n`),s+="\n---\n\n"}))}catch(e){n.error("Error getting operation detail",{error:e}),s+=`\n\u274c Error: ${(0,o.getErrorMessage)(e)}\n`}return s}
|
|
1478
|
-
const r=t(1181),n=t(2960),o=t(8824)},
|
|
1481
|
+
const r=t(1181),n=t(2960),o=t(8824)},2113(e,exports,t){"use strict"
|
|
1482
|
+
async function r(e,t){const r=await fetch(`${e}/session/${t}/message`,{signal:AbortSignal.timeout(5e3)})
|
|
1483
|
+
if(!r.ok)throw Error("status "+r.status)
|
|
1484
|
+
return await r.json()}Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleCommitToViewedSession=async function(e,t){const a=Math.random().toString(36).slice(2,8),c=Date.now()
|
|
1485
|
+
let l
|
|
1486
|
+
t.info("commit_to_viewed_session:enter",{callId:a,enteredAt:c})
|
|
1487
|
+
try{l=n.CommitToViewedSessionSchema.parse(e).message}catch(e){return t.warn("commit_to_viewed_session:schema-fail",{callId:a,error:(0,o.getErrorMessage)(e)}),{content:[{type:"text",text:"Invalid commit: "+(0,o.getErrorMessage)(e)}],isError:!0}}t.info("commit_to_viewed_session:parsed",{callId:a,messagePreview:l.slice(0,80),messageLength:l.length})
|
|
1488
|
+
const d=s.sessionIdentity.getIdentity(),u=d?.sessionId,h=d?.serverUrl
|
|
1489
|
+
if(!u||!h)return t.warn("commit_to_viewed_session: missing session identity",{hasHeraldId:!!u,hasServerUrl:!!h}),{content:[{type:"text",text:"Commit failed: herald session identity unavailable."}],isError:!0}
|
|
1490
|
+
let g
|
|
1491
|
+
try{g=await r(h,u)}catch(e){return t.warn("commit_to_viewed_session: could not fetch herald messages",{heraldId:u,error:(0,o.getErrorMessage)(e)}),{content:[{type:"text",text:`Commit failed: unable to read herald context (${(0,o.getErrorMessage)(e)}).`}],isError:!0}}const p=function(e){for(let t=e.length-1;t>=0;t--){const r=e[t]
|
|
1492
|
+
if("user"===r.info?.role)for(const e of r.parts??[]){if("text"!==e.type||!e.text)continue
|
|
1493
|
+
const t=e.text.match(/<viewed_session\s+id="([^"]+)"\s*\/?>/)
|
|
1494
|
+
if(t)return t[1]}}return null}(g)
|
|
1495
|
+
if(!p)return{content:[{type:"text",text:"Commit failed: no <viewed_session/> tag in herald context. The UI must embed one in each dictation envelope."}],isError:!0}
|
|
1496
|
+
let m
|
|
1497
|
+
try{m=function(e){for(let t=e.length-1;t>=0;t--){const r=e[t]
|
|
1498
|
+
if("assistant"===r.info?.role&&r.info.agent)return r.info.agent}}(await r(h,p)),m||t.warn("commit_to_viewed_session: no agent resolvable for viewed session; omitting agent",{viewedId:p})}catch(e){t.warn("commit_to_viewed_session: could not fetch viewed messages; omitting agent",{viewedId:p,error:(0,o.getErrorMessage)(e)})}const f={parts:[{type:"text",text:`${i}${l}`}]}
|
|
1499
|
+
m&&(f.agent=m),t.info("commit_to_viewed_session:posting",{callId:a,viewedId:p,heraldId:u,agent:m})
|
|
1500
|
+
try{const e=await fetch(`${h}/session/${p}/prompt_async`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f),signal:AbortSignal.timeout(1e4)})
|
|
1501
|
+
if(t.info("commit_to_viewed_session:posted",{callId:a,status:e.status}),!e.ok){const t=await e.text().catch((()=>""))
|
|
1502
|
+
return{content:[{type:"text",text:`Commit failed: prompt_async returned ${e.status}${t?` (${t.slice(0,120)})`:""}.`}],isError:!0}}}catch(e){return t.warn("commit_to_viewed_session:post-failed",{callId:a,error:(0,o.getErrorMessage)(e)}),{content:[{type:"text",text:"Commit failed: "+(0,o.getErrorMessage)(e)}],isError:!0}}return t.info("Translator forwarded message to viewed session",{callId:a,heraldId:u,viewedId:p,agent:m,messageLength:l.length,preview:l.slice(0,120),durationMs:Date.now()-c}),{content:[{type:"text",text:"Committed."}]}}
|
|
1503
|
+
const n=t(6183),o=t(8824),s=t(6688),i="\x3c!-- via-herald --\x3e"},2140(e,exports,t){"use strict"
|
|
1479
1504
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleSwitchToMainBranch=async function(e,t,i,a,c){const l=a.child({tool:"switch_to_main_branch"}),d=Date.now()
|
|
1480
1505
|
try{if(r.SwitchToMainBranchSchema.parse(e),l.info("Switching to main branch/repository"),!t.workspaceManager)throw(0,n.createServiceError)("WorkspaceManager not available",{phase:"workspace_manager_check"})
|
|
1481
1506
|
let a=null
|
|
@@ -1615,7 +1640,7 @@ Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
|
1615
1640
|
const r=t(6183),n=t(3707)
|
|
1616
1641
|
exports.def={name:"quick_manage",description:"Move, delete, or create directories. Wraps the change in a request/task workflow that auto-completes.\n\nProvide an array of operations, each with operationType and corresponding data:\n\u2022 create-directory: { createDirectory: { path } }\n\u2022 move-files: { moveFiles: { moves: [{ source, destination }] } }\n\u2022 delete-files: { deleteFiles: { targets: [{ path }] } }\n\nFor read-only operations like get-file-info, use manage_files instead.\n\nRequires: title, description, operations.",schema:r.QuickManageSchema,annotations:{title:"Quick Manage",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1},handler(e,t){return(0,n.handleQuickChange)(e,"manage",t.context,t.apiClient,t.logger,t.metrics,t.mcpServer)}}},2462(e,exports,t){"use strict"
|
|
1617
1642
|
Object.defineProperty(exports,"__esModule",{value:!0})
|
|
1618
|
-
const r=t(2245),n=t(9080),o=t(5692),s=t(9030),i=t(2903),a=t(4607),c=t(9499),l=t(6770),d=t(8045),u=t(9697),h=t(9196),g=t(5459),p=t(4805),m=t(260),f=t(2283),y=t(4165),w=t(7834),k=t(9373),I=t(6111),b=t(700),v=t(2783),C=t(2601),_=t(1722),E=t(7257),q=t(9230),S=t(6064),T=t(5216),x=t(6473),R=t(4921),P=t(8850),M=t(3556),j=t(1391),$=t(6315),O=t(7713),D=t(6252),A=t(213),F=t(7250),N=t(2425),L=t(1540),z=t(5767),B=t(4973),H=t(509),U=t(7613),G=t(
|
|
1643
|
+
const r=t(2245),n=t(9080),o=t(5692),s=t(9030),i=t(2903),a=t(4607),c=t(9499),l=t(6770),d=t(8045),u=t(9697),h=t(9196),g=t(5459),p=t(4805),m=t(260),f=t(2283),y=t(4165),w=t(7834),k=t(9373),I=t(6111),b=t(700),v=t(2783),C=t(2601),_=t(1722),E=t(7257),q=t(9230),S=t(6064),T=t(5216),x=t(6473),R=t(4921),P=t(8850),M=t(3556),j=t(1391),$=t(6315),O=t(7713),D=t(6252),A=t(213),F=t(7250),N=t(2425),L=t(1540),z=t(5767),B=t(4973),H=t(509),U=t(7613),G=t(8456),W=t(3322),V=t(5247),J=t(8849),K=t(542);(0,r.registerTool)(n.def),(0,r.registerTool)(o.def),(0,r.registerTool)(s.def),(0,r.registerTool)(i.def),(0,r.registerTool)(a.def),(0,r.registerTool)(c.def),(0,r.registerTool)(l.def),(0,r.registerTool)(d.def),(0,r.registerTool)(u.def),(0,r.registerTool)(h.def),(0,r.registerTool)(g.def),(0,r.registerTool)(p.def),(0,r.registerTool)(m.def),(0,r.registerTool)(f.def),(0,r.registerTool)(y.def),(0,r.registerTool)(w.def),(0,r.registerTool)(k.def),(0,r.registerTool)(I.def),(0,r.registerTool)(b.def),(0,r.registerTool)(v.def),(0,r.registerTool)(S.def),(0,r.registerTool)(C.def),(0,r.registerTool)(_.def),(0,r.registerTool)(E.def),(0,r.registerTool)(q.def),(0,r.registerTool)(T.def),(0,r.registerTool)(x.def),(0,r.registerTool)(R.def),(0,r.registerTool)(P.def),(0,r.registerTool)(M.def),(0,r.registerTool)(j.def),(0,r.registerTool)($.def),(0,r.registerTool)(O.def),(0,r.registerTool)(D.def),(0,r.registerTool)(A.def),(0,r.registerTool)(F.def),(0,r.registerTool)(N.def),(0,r.registerTool)(L.def),(0,r.registerTool)(z.def),(0,r.registerTool)(B.def),(0,r.registerTool)(H.def),(0,r.registerTool)(U.def),(0,r.registerTool)(G.def),(0,r.registerTools)(W.metaDefs),(0,r.registerTools)(V.testingDefs),(0,r.registerTools)(J.checkingDefs),(0,r.registerTools)(K.debugDefs),(0,t(2245).freezeRegistry)()},2478(e,exports){"use strict"
|
|
1619
1644
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.requestConfig=void 0,exports.areTestsRequiredForCompletion=function(){return exports.requestConfig.requireTestsForCompletion},exports.setTestsRequiredForCompletion=function(e){exports.requestConfig.requireTestsForCompletion=e},exports.getCompletionMode=function(e){return e&&["auto-merge","auto-test-then-merge","manual-review"].includes(e)?e:"auto-merge"},exports.getApprovalMode=function(e){return e&&["none","require-approval"].includes(e)?e:"none"},exports.requestConfig={requireTestsForCompletion:!1}},2537(e,exports,t){"use strict"
|
|
1620
1645
|
async function r(e,t,r){if(C.has(r)&&_>=t){if(0===t)return 0
|
|
1621
1646
|
try{return(await y.default.readFile(e,"utf-8")).split("\n").length}catch{return}}}function n(e,t,r){const n="depth"in e,o=n?e:r,s=n?e.isDirectory:e.isDirectory(),a=e.name,c=s?"[\u{1f4c1} DIR]":"[\u{1f4c4} FILE]"
|
|
@@ -2641,7 +2666,7 @@ try{const e=s?.sessionId||d.sessionIdentity.getIdentity()?.sessionId,t=o?.getSes
|
|
|
2641
2666
|
if(t&&e){const n=await d.sessionIdentity.getParentSessionId(e,o,h),s=r.description||r.prompt
|
|
2642
2667
|
await t.createQuestion({fromSessionId:e,toSessionId:n||void 0,questionType:"alternatives",question:"Planning requested: "+s,options:[{id:"auto",label:"Auto Plan",description:"Spawn an autonomous planner agent"},{id:"manual",label:"Manual Plan",description:"Open the interactive plan editor"},{id:"cancel",label:"Skip",description:"Dismiss this planning request"}],context:r.prompt,category:"action-required",priority:"high"}),h.info("planner-request: notification created",{fromSessionId:e})}else h.warn("planner-request: skipping notification",{hasClient:!!t,hasCallerSessionId:!!e})}catch(e){h.warn("planner-request: failed to create notification",{error:(0,l.getErrorMessage)(e)})}f={content:[{type:"text",text:"Planning request submitted. The user will choose the planning approach. This is non-blocking \u2014 continue with your other work.\nPLANNER_CHOICE_PENDING|"+JSON.stringify({prompt:r.prompt,description:r.description})}]}
|
|
2643
2668
|
break}const n="auto-planner"
|
|
2644
|
-
if(h.info("Spawning planner",{planningMode:e,agent:n}),f=await(0,u.handleSpawn)({agent:n,prompt:r.prompt,title:r.description},t,h,o),!f.isError&&f.content.length>0){const t=f.content[0].text
|
|
2669
|
+
if(h.info("Spawning planner",{planningMode:e,agent:n}),f=await(0,u.handleSpawn)({agent:n,prompt:r.prompt,title:r.description},t,h,o,s),!f.isError&&f.content.length>0){const t=f.content[0].text
|
|
2645
2670
|
f.content[0].text=`Planning mode: ${e} (agent: ${n}). Planning is running in the background \u2014 continue with your other work.\n${t}`}break}case"check-status":f=await(0,u.handleCheckStatus)(m,t,h,o)
|
|
2646
2671
|
break
|
|
2647
2672
|
case"list":const e=s?.sessionId||d.sessionIdentity.getIdentity()?.sessionId,[n,a]=await Promise.all([(0,u.handleListSessions)(t,h,o,{activeOnly:r.activeOnly,limit:r.limit,agentType:"auto-planner",parentSessionId:e}),(0,u.handleListSessions)(t,h,o,{activeOnly:r.activeOnly,limit:r.limit,agentType:"planner",parentSessionId:e})]),c=n.content[0]?.text??"",g=a.content[0]?.text??""
|
|
@@ -2984,7 +3009,7 @@ var t={}
|
|
|
2984
3009
|
if(null!=e)for(var s=r(e),i=0;i<s.length;i++)"default"!==s[i]&&n(t,e,s[i])
|
|
2985
3010
|
return o(t,e),t})
|
|
2986
3011
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.testingDefs=void 0
|
|
2987
|
-
const i=s(t(6183)),a=t(2052),c=e=>(t,r)=>e(t,r.context,r.apiClient,r.logger,r.metrics)
|
|
3012
|
+
const i=s(t(6183)),a=t(2052),c=e=>(t,r)=>e(t,r.context,r.apiClient,r.logger,r.metrics,r.cliOrigin)
|
|
2988
3013
|
exports.testingDefs=[{name:"testing_process_list",description:"List all test processes for this project. Shows active/inactive status, command count, and scope.",schema:i.TestingProcessListSchema,annotations:{title:"List Test Processes",readOnlyHint:!0},readOnly:!0,handler:c(a.handleTestingProcessList)},{name:"testing_process_get",description:"Get detailed configuration of a test process including setup and test commands.",schema:i.TestingProcessGetSchema,annotations:{title:"Get Test Process",readOnlyHint:!0},readOnly:!0,handler:c(a.handleTestingProcessGet)},{name:"testing_process_create",description:"Create a new test process with optional setup commands and one or more test commands. Each command has a name, shell command, required flag, and timeout.",schema:i.TestingProcessCreateSchema,annotations:{title:"Create Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessCreate)},{name:"testing_process_update",description:"Update an existing test process. Can modify name, description, scope, active status, and test configuration.",schema:i.TestingProcessUpdateSchema,annotations:{title:"Update Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessUpdate)},{name:"testing_reference",description:"Get the test process design guide with patterns for Node.js, Python, Go, Rust, and monorepo setups.",schema:i.TestingReferenceSchema,annotations:{title:"Testing Reference",readOnlyHint:!0},readOnly:!0,handler:c(a.handleTestingReference)},{name:"execute_test_command",description:'Execute a specific command from a configured test process. Use commandName="setup" to run all setup commands, or specify a test command name to run it. Only commands defined in the test process can be executed.',schema:i.ExecuteTestCommandSchema,annotations:{title:"Execute Test Command",readOnlyHint:!1},handler:c(a.handleExecuteTestCommand)},{name:"report_test_results",description:"Report the results of a test run. Call this after running all test commands to record pass/fail status and per-command results. The test run is auto-discovered from the current request context.",schema:i.ReportTestResultsSchema,annotations:{title:"Report Test Results",readOnlyHint:!1},handler:c(a.handleReportTestResults)}]},5278(e,exports,t){"use strict"
|
|
2989
3014
|
var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
|
|
2990
3015
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentFileManager=void 0
|
|
@@ -3312,7 +3337,7 @@ const n=await this.requestWithRetry("POST","/api/files/recover",t)
|
|
|
3312
3337
|
if(!(0,i.safeGetResponseData)(n,null))throw new r.ServiceError("Empty response when recovering file")
|
|
3313
3338
|
const o=(0,i.safeGetResponseData)(n,{success:!0,path:e.path,commitHash:e.commitHash,backupPath:void 0})
|
|
3314
3339
|
return this.logger.info("Successfully recovered file "+e.path,{path:o.path,commitHash:o.commitHash,backupPath:o.backupPath}),o}catch(t){throw this.logger.error("Failed to recover file "+e.path,{path:e.path,commitHash:e.commitHash,error:t instanceof Error?t.stack:t+""}),t}}}exports.FileOperationsClient=a},6183(e,exports,t){"use strict"
|
|
3315
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.SwitchToMainBranchSchema=exports.PlanWriteSchema=exports.PlanReadSchema=exports.DocumentOperationsSchema=exports.SearchDocumentsSchema=exports.CreateDocumentSchema=exports.ReplaceLinesSchema=exports.InsertLinesSchema=exports.SwitchToRequestBranchSchema=exports.PlannerOpsSchema=exports.SpecialistOpsSchema=exports.SubagentOperationsSchema=exports.TaskOperationsSchema=exports.CompleteTaskSchema=exports.GetTaskInformationSchema=exports.GetRequestInformationSchema=exports.ListRequestsSchema=exports.ListTasksSchema=exports.SearchSchema=exports.QueryHistorySchema=exports.FileRecoverSchema=exports.FileHistorySchema=exports.DeleteFilesSchema=exports.DeleteFileSchema=exports.ReplaceInFilesSchema=exports.ReplaceStringsSchema=exports.ReplaceStringSchema=exports.MoveFilesSchema=exports.CreateDirectorySchema=exports.GetFileInfoSchema=exports.ListDirectorySchema=exports.ReadFilesSchema=exports.ViewAssetSchema=exports.WriteFileSchema=exports.UpdateTaskStatusSchema=exports.CreateTaskSchema=exports.CreateRequestSchema=exports.CompleteRequestSchema=exports.ExecutedTestSchema=exports.TestVerificationSchema=exports.TestDefinitionSchema=exports.AcceptanceCriterionSchema=exports.RecordTypeEnum=exports.EvidenceTypeEnum=exports.CriterionStatusEnum=exports.RequestStatusEnum=exports.TaskStatusEnum=exports.RequestTypeEnum=exports.TestCoverageTypeEnum=exports.CompletionStatusEnum=void 0,exports.UpdateSpecializationSchema=exports.SessionMessageOperationsSchema=exports.ReportTestResultsSchema=exports.CommandsSchema=exports.ExecuteTestCommandSchema=exports.TestingReferenceSchema=exports.TestingProcessUpdateSchema=exports.TestingProcessCreateSchema=exports.TestingProcessGetSchema=exports.TestingProcessListSchema=exports.MetaReferenceSchema=exports.MetaAgentListSchema=exports.MetaWorkflowRemoveRecipeSchema=exports.MetaWorkflowAddRecipeSchema=exports.MetaHookCreateSchema=exports.MetaHookListSchema=exports.MetaRecipeRemoveHookSchema=exports.MetaRecipeAddHookSchema=exports.MetaRecipeCreateSchema=exports.MetaRecipeGetSchema=exports.MetaRecipeListSchema=exports.MetaWorkflowUpdateSchema=exports.MetaWorkflowCreateSchema=exports.MetaWorkflowGetSchema=exports.MetaWorkflowListSchema=exports.GenerateRequestJournalSchema=exports.QuickManageSchema=exports.QuickReplaceSchema=exports.QuickWriteSchema=exports.RequestOperationsSchema=exports.ManageFilesSchema=exports.ModifyFileSchema=exports.RevertRequestSchema=exports.SwitchToBranchSchema=void 0
|
|
3340
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.SwitchToMainBranchSchema=exports.PlanWriteSchema=exports.PlanReadSchema=exports.DocumentOperationsSchema=exports.SearchDocumentsSchema=exports.CreateDocumentSchema=exports.ReplaceLinesSchema=exports.InsertLinesSchema=exports.SwitchToRequestBranchSchema=exports.PlannerOpsSchema=exports.SpecialistOpsSchema=exports.SubagentOperationsSchema=exports.TaskOperationsSchema=exports.CompleteTaskSchema=exports.GetTaskInformationSchema=exports.GetRequestInformationSchema=exports.ListRequestsSchema=exports.ListTasksSchema=exports.SearchSchema=exports.QueryHistorySchema=exports.FileRecoverSchema=exports.FileHistorySchema=exports.DeleteFilesSchema=exports.DeleteFileSchema=exports.ReplaceInFilesSchema=exports.ReplaceStringsSchema=exports.ReplaceStringSchema=exports.MoveFilesSchema=exports.CreateDirectorySchema=exports.GetFileInfoSchema=exports.ListDirectorySchema=exports.ReadFilesSchema=exports.ViewAssetSchema=exports.WriteFileSchema=exports.UpdateTaskStatusSchema=exports.CreateTaskSchema=exports.CreateRequestSchema=exports.CompleteRequestSchema=exports.ExecutedTestSchema=exports.TestVerificationSchema=exports.TestDefinitionSchema=exports.AcceptanceCriterionSchema=exports.RecordTypeEnum=exports.EvidenceTypeEnum=exports.CriterionStatusEnum=exports.RequestStatusEnum=exports.TaskStatusEnum=exports.RequestTypeEnum=exports.TestCoverageTypeEnum=exports.CompletionStatusEnum=void 0,exports.CommitToViewedSessionSchema=exports.UpdateSpecializationSchema=exports.SessionMessageOperationsSchema=exports.ReportTestResultsSchema=exports.CommandsSchema=exports.ExecuteTestCommandSchema=exports.TestingReferenceSchema=exports.TestingProcessUpdateSchema=exports.TestingProcessCreateSchema=exports.TestingProcessGetSchema=exports.TestingProcessListSchema=exports.MetaReferenceSchema=exports.MetaAgentListSchema=exports.MetaWorkflowRemoveRecipeSchema=exports.MetaWorkflowAddRecipeSchema=exports.MetaHookCreateSchema=exports.MetaHookListSchema=exports.MetaRecipeRemoveHookSchema=exports.MetaRecipeAddHookSchema=exports.MetaRecipeCreateSchema=exports.MetaRecipeGetSchema=exports.MetaRecipeListSchema=exports.MetaWorkflowUpdateSchema=exports.MetaWorkflowCreateSchema=exports.MetaWorkflowGetSchema=exports.MetaWorkflowListSchema=exports.GenerateRequestJournalSchema=exports.QuickManageSchema=exports.QuickReplaceSchema=exports.QuickWriteSchema=exports.RequestOperationsSchema=exports.ManageFilesSchema=exports.ModifyFileSchema=exports.RevertRequestSchema=exports.SwitchToBranchSchema=void 0
|
|
3316
3341
|
const r=t(1569),n=t(8955),o=r.z.string().refine((e=>!(!e||!/^tas\d{6}$/.test(e)&&!/^req\d{6}#\d+$/.test(e))),{message:"Task ID must be req######+#NN (e.g. req000005#03) or tas###### format (e.g. tas000001)."}),s=r.z.string().refine((e=>!!e&&/^req\d{6}$/.test(e)),{message:"Request ID must match format: req###### (e.g. req000001)"}),i=r.z.string().refine((e=>!!e&&(/^doc_[0-9A-Z]{26}$/i.test(e)||/^(doc|plan|jour)\d{6}$/.test(e))),{message:"Document ID must match format: doc_[26 alphanumeric] (ULID) or doc######/plan######/jour###### (local ID)"})
|
|
3317
3342
|
exports.CompletionStatusEnum=r.z.enum(["complete","incomplete","partial"]),exports.TestCoverageTypeEnum=r.z.enum(["unit","e2e","integration","manual"]),exports.RequestTypeEnum=r.z.enum(["feature","bugfix","quick-edit"]),exports.TaskStatusEnum=r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]),exports.RequestStatusEnum=r.z.enum(["open","in_progress","ready_for_review","ready_for_merge","completed","canceled","reverted","conflicted"]),exports.CriterionStatusEnum=r.z.enum(["unverified","verified"]),exports.EvidenceTypeEnum=r.z.enum(["test","manual","other"]),exports.RecordTypeEnum=r.z.enum(["write","modify","blocker","resolution","discovery","test","delete"]),exports.AcceptanceCriterionSchema=r.z.object({description:r.z.string(),status:r.z.enum(["unverified","verified"]).default("unverified"),evidence:r.z.string().nullable().optional(),evidenceType:r.z.enum(["test","manual","other"]).nullable().optional(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.TestDefinitionSchema=r.z.object({id:r.z.string(),description:r.z.string(),status:exports.CompletionStatusEnum,coverageType:exports.TestCoverageTypeEnum,accepts:r.z.array(r.z.string())}),exports.TestVerificationSchema=r.z.object({criteria:r.z.array(r.z.string()),tests:r.z.array(r.z.string()),coverageType:exports.TestCoverageTypeEnum,coverageRatio:r.z.number(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.ExecutedTestSchema=r.z.object({id:r.z.string(),testId:r.z.string(),status:exports.CompletionStatusEnum,results:r.z.string(),coverage:r.z.array(r.z.string()),executedAt:r.z.string()}),exports.CompleteRequestSchema=r.z.object({status:exports.RequestStatusEnum,acceptanceCriteria:r.z.array(exports.AcceptanceCriterionSchema),testVerification:exports.TestVerificationSchema.optional(),completionSummary:r.z.string().optional()}),exports.CreateRequestSchema=r.z.object({title:r.z.string(),type:r.z.enum(["feature","bugfix"]),description:r.z.string(),acceptanceCriteria:r.z.array(r.z.string()),planDocumentId:r.z.string().optional()}),exports.CreateTaskSchema=r.z.object({requestId:s,title:r.z.string(),description:r.z.string()}),exports.UpdateTaskStatusSchema=r.z.object({taskId:o,status:exports.TaskStatusEnum,note:r.z.string()}),exports.WriteFileSchema=r.z.object({path:r.z.string().optional(),documentId:i.optional(),content:r.z.union([r.z.string(),r.z.record(r.z.any()),r.z.array(r.z.unknown())]),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional(),comment:r.z.string()}).refine((e=>e.path&&!e.documentId||!e.path&&e.documentId),{message:"path or documentId required"}),exports.ViewAssetSchema=r.z.object({filename:r.z.string().describe("The asset filename (e.g., 01JMXYZ.png)")}),exports.ReadFilesSchema=r.z.object({paths:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional(),lines:r.z.string().optional()}).refine((e=>e.path&&!e.documentId||!e.path&&e.documentId),{message:"path or documentId required"})),encoding:r.z.enum(["utf8","utf-8","ascii","binary"]).optional()}),exports.ListDirectorySchema=r.z.object({path:r.z.string(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}),exports.GetFileInfoSchema=r.z.object({path:r.z.string()}),exports.CreateDirectorySchema=r.z.object({path:r.z.string(),comment:r.z.string().optional()}),exports.MoveFilesSchema=r.z.object({operations:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()})),comment:r.z.string()}),exports.ReplaceStringSchema=r.z.object({path:r.z.string(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional(),comment:r.z.string()}),exports.ReplaceStringsSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional()}).refine((e=>e.path&&!e.documentId||!e.path&&e.documentId),{message:"path or documentId required"})),comment:r.z.string()}),exports.ReplaceInFilesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1,"old string cannot be empty"),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1,"At least one replacement required"),fuzzy_match:r.z.boolean().optional()}).refine((e=>e.path&&!e.documentId||!e.path&&e.documentId),{message:"Either path or documentId is required, but not both"})).min(1,"At least one operation required"),fuzzy_match:r.z.boolean().optional().default(!0),comment:r.z.string()}),exports.DeleteFileSchema=r.z.object({path:r.z.string(),comment:r.z.string()}),exports.DeleteFilesSchema=r.z.object({paths:r.z.array(r.z.string()).optional(),operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional()}).refine((e=>e.path&&!e.documentId||!e.path&&e.documentId),{message:"path or documentId required"})).optional(),comment:r.z.string()}).refine((e=>e.paths&&!e.operations||!e.paths&&e.operations),{message:"paths or operations required"}).refine((e=>e.paths?.length||e.operations?.length),{message:"path/operation required"}),exports.FileHistorySchema=r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}),exports.FileRecoverSchema=r.z.object({path:r.z.string(),commitHash:r.z.string(),createBackup:r.z.boolean().default(!0)}),exports.QueryHistorySchema=r.z.object({queryType:r.z.enum(["file-history","request-file-history","recover","blame"],{errorMap(){return{message:"Invalid queryType. Valid options: file-history, request-file-history, recover, blame"}}}),fileHistory:r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}).optional(),requestHistory:r.z.object({requestId:s,detailLevel:r.z.enum(["summary","detailed"]).default("summary"),taskId:o.optional(),showDiff:r.z.boolean().optional(),fileFilter:r.z.string().optional()}).optional(),recover:r.z.object({path:r.z.string(),commitHash:r.z.string().optional(),createBackup:r.z.boolean().default(!0)}).optional(),blame:r.z.object({path:r.z.string(),lines:r.z.string().optional(),branch:r.z.string().optional()}).optional()}).refine((e=>"file-history"===e.queryType?e.fileHistory&&!e.requestHistory&&!e.recover:"request-file-history"===e.queryType?e.requestHistory&&!e.fileHistory&&!e.recover:"recover"===e.queryType?e.recover&&!e.fileHistory&&!e.requestHistory&&!e.blame:"blame"===e.queryType&&e.blame&&!e.fileHistory&&!e.requestHistory&&!e.recover),{message:"Invalid query data"}),exports.SearchSchema=r.z.object({needle:r.z.string().optional(),directory:r.z.string().optional(),options:r.z.object({caseSensitive:r.z.boolean().optional(),fileExtension:r.z.string().optional(),maxResults:r.z.number().optional(),useRegex:r.z.boolean().optional(),searchIn:r.z.enum(["content","filename","both"]).default("content").optional(),contextLines:r.z.number().min(0).max(10).optional(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}).optional()}),exports.ListTasksSchema=r.z.object({requestId:s,filters:r.z.object({status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.ListRequestsSchema=r.z.object({filters:r.z.object({type:r.z.enum(["feature","bugfix"]).optional(),status:r.z.enum(["open","in_progress","ready_for_review","completed","canceled"]).optional(),planDocumentId:r.z.string().optional(),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.GetRequestInformationSchema=r.z.object({requestId:s}),exports.GetTaskInformationSchema=r.z.object({taskId:o}),exports.CompleteTaskSchema=r.z.object({taskId:o,summary:r.z.string()}),exports.TaskOperationsSchema=r.z.object({operation:r.z.enum(["create","complete","get-info","list"]),taskId:o.optional(),requestId:s.optional(),title:r.z.string().optional(),description:r.z.string().optional(),summary:r.z.string().optional(),status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).superRefine(((e,t)=>{"create"!==e.operation||e.requestId||t.addIssue({code:"custom",message:'requestId is required for create. Example: { "operation": "create", "requestId": "req000001", "title": "...", "description": "..." }'}),"create"!==e.operation||e.title||t.addIssue({code:"custom",message:"title is required for create."}),"create"!==e.operation||e.description||t.addIssue({code:"custom",message:"description is required for create."}),"complete"!==e.operation||e.taskId||t.addIssue({code:"custom",message:'taskId is required for complete. Example: { "operation": "complete", "taskId": "req000001#01", "summary": "..." }'}),"complete"!==e.operation||e.summary||t.addIssue({code:"custom",message:"summary is required for complete."}),"get-info"!==e.operation||e.taskId||t.addIssue({code:"custom",message:'taskId is required for get-info. Example: { "operation": "get-info", "taskId": "req000001#01" }'}),"list"!==e.operation||e.requestId||t.addIssue({code:"custom",message:'requestId is required for list. Example: { "operation": "list", "requestId": "req000001" }'})}))
|
|
3318
3343
|
const a=r.z.string().min(1).describe("OpenCode session ID")
|
|
@@ -3323,7 +3348,7 @@ exports.PlanReadSchema=r.z.object({operation:r.z.enum(["get","get-active","list"
|
|
|
3323
3348
|
const r=e.operation,n={complete:{field:"complete",hint:'Provide: { complete: { summary: "..." } }'},merge:{field:"merge",hint:'Provide: { merge: { verifications: [{key: "1a", evidence: "..."}] } }'},revert:{field:"revert",hint:'Provide: { revert: { reason: "..." } }'},search:{field:"search",hint:'Provide: { search: { query: "..." } }'}}[r]
|
|
3324
3349
|
n&&!e[n.field]&&t.addIssue({code:"custom",message:`'${r}' operation requires '${n.field}' data. ${n.hint}`})})),exports.QuickWriteSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),path:r.z.string().optional(),documentId:i.optional(),content:r.z.union([r.z.string(),r.z.record(r.z.any()),r.z.array(r.z.unknown())]),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional()}),exports.QuickReplaceSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1),fuzzy_match:r.z.boolean().optional()})).min(1),fuzzy_match:r.z.boolean().optional(),comment:r.z.string().min(1,"Comment describing the change is required")}),exports.QuickManageSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),operations:r.z.array(r.z.object({operationType:r.z.enum(["create-directory","move-files","delete-files"]),createDirectory:r.z.object({path:r.z.string()}).optional(),moveFiles:r.z.object({moves:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()}))}).optional(),deleteFiles:r.z.object({targets:r.z.array(r.z.object({path:r.z.string().optional(),documentId:i.optional()}))}).optional()})).min(1)}),exports.GenerateRequestJournalSchema=r.z.object({requestId:r.z.string().regex(/^req[_\d].+$/,"Invalid request ID format. Expected format: req_[26 chars] or req######")}),exports.MetaWorkflowListSchema=r.z.object({}),exports.MetaWorkflowGetSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to retrieve")}),exports.MetaWorkflowCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the workflow"),shortName:r.z.string().min(1).max(10).describe("Short display name (required, max 10 chars)"),description:r.z.string().optional().describe("Description of what the workflow does"),documentation:r.z.string().optional().describe("Detailed documentation"),defaultAgent:r.z.string().optional().describe("Default agent template to use"),completionMode:r.z.enum(["auto-merge","auto-test-then-merge","manual-review"]).optional().describe("Request completion behavior: auto-merge (default), auto-test-then-merge, or manual-review"),approvalMode:r.z.enum(["none","require-approval"]).optional().describe("Pre-work approval: none (default) or require-approval")}),exports.MetaWorkflowUpdateSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to update"),name:r.z.string().min(1).optional().describe("New name"),shortName:r.z.string().max(10).optional().describe("New short name (max 10 chars)"),description:r.z.string().optional().describe("New description"),documentation:r.z.string().optional().describe("New documentation"),defaultAgent:r.z.string().optional().describe("New default agent"),completionMode:r.z.enum(["auto-merge","auto-test-then-merge","manual-review"]).optional().describe("Request completion behavior"),approvalMode:r.z.enum(["none","require-approval"]).optional().describe("Pre-work approval: none (default) or require-approval")}),exports.MetaRecipeListSchema=r.z.object({}),exports.MetaRecipeGetSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to retrieve")}),exports.MetaRecipeCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the recipe"),description:r.z.string().optional().describe("Description of what the recipe does"),documentation:r.z.string().optional().describe("Detailed documentation")}),exports.MetaRecipeAddHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to add the hook to"),hookId:r.z.string().describe("Hook template ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the recipe (0-based, appended if omitted)")}),exports.MetaRecipeRemoveHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to remove the hook from"),hookId:r.z.string().describe("Hook template ID to remove")}),exports.MetaHookListSchema=r.z.object({}),exports.MetaHookCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the hook"),description:r.z.string().optional().describe("Description of what the hook does"),eventType:r.z.string().describe("Event type that triggers this hook (e.g., session_idle, request_completed, custom:plan_ready)"),category:r.z.enum(["alchemy","session","message","editing","reading","file_management","documents","history","tool"]).default("session").describe("Hook category"),agent:r.z.string().describe("Agent template to execute when hook fires"),promptTemplate:r.z.string().describe("Prompt template with {{variable}} substitution"),condition:r.z.record(r.z.any()).optional().describe("Condition object for filtering when hook fires"),executionMode:r.z.enum(["same_session","sub_agent","background","notification","direct_report"]).default("background").describe("How to execute the hook"),timing:r.z.enum(["before","after"]).default("after").describe("When to fire relative to the event"),maxIterations:r.z.number().int().min(1).optional().describe("Maximum times to fire per session"),emitEvent:r.z.string().optional().describe("Custom event to emit on completion"),emitEventOnCondition:r.z.union([r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}),r.z.array(r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}))]).optional().describe("Conditional event emission based on output")}),exports.MetaWorkflowAddRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to add the recipe to"),recipeId:r.z.string().describe("Recipe ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the workflow (0-based, appended if omitted)")}),exports.MetaWorkflowRemoveRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to remove the recipe from"),recipeId:r.z.string().describe("Recipe ID to remove")}),exports.MetaAgentListSchema=r.z.object({}),exports.MetaReferenceSchema=r.z.object({}),exports.TestingProcessListSchema=r.z.object({}),exports.TestingProcessGetSchema=r.z.object({processId:r.z.string().describe("Test process ID to retrieve")})
|
|
3325
3350
|
const l=r.z.object({name:r.z.string().min(1).describe('Command name (e.g., "Build", "Unit Tests")'),command:r.z.string().min(1).describe('Shell command to run (e.g., "npm test")'),required:r.z.boolean().default(!0).describe("If true, failure blocks the request (default: true)"),timeout:r.z.number().int().min(10).max(3600).default(300).describe("Max execution time in seconds (default: 300)")})
|
|
3326
|
-
exports.TestingProcessCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the test process"),description:r.z.string().optional().describe("Description of what this process verifies"),scope:r.z.string().optional().describe('Path prefix for monorepo scoping (e.g., "packages/api/"). Omit for global.'),setup:r.z.array(r.z.string()).optional().describe('Commands to prepare the environment (e.g., ["ln -s ../../node_modules node_modules"])'),commands:r.z.array(l).min(1).describe("Test commands to execute in order"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands")}),exports.TestingProcessUpdateSchema=r.z.object({processId:r.z.string().describe("Test process ID to update"),name:r.z.string().min(1).optional().describe("New name"),description:r.z.string().optional().describe("New description"),scope:r.z.string().nullable().optional().describe("New scope (null to remove)"),isActive:r.z.boolean().optional().describe("Enable or disable the process"),setup:r.z.array(r.z.string()).optional().describe("New setup commands (replaces existing)"),commands:r.z.array(l).optional().describe("New test commands (replaces existing)"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands")}),exports.TestingReferenceSchema=r.z.object({}),exports.ExecuteTestCommandSchema=r.z.object({processId:r.z.string().describe("Test process ID containing the command"),commandName:r.z.string().describe('Name of the test command to run, or "setup" to run all setup commands in sequence')}),exports.CommandsSchema=r.z.object({operation:r.z.enum(["run","list","add","remove"]).default("run").describe('"run" to execute a command, "list" to see available commands, "add" to register a new command, "remove" to delete one'),name:r.z.string().optional().describe('Command name (required for "run", "add", and "remove")'),args:r.z.string().optional().describe('Additional arguments appended to the base command (optional, for "run")'),grep:r.z.string().optional().describe('Filter output through grep (optional, for "run"). Pipes command output through grep -i with this pattern.'),command:r.z.string().optional().describe('Shell command to register (required for "add", e.g. "tsc --noEmit")'),description:r.z.string().optional().describe('What this command verifies (optional, for "add")'),timeout:r.z.number().optional().describe('Timeout in seconds (optional, for "add", default 60)')}),exports.ReportTestResultsSchema=r.z.object({status:r.z.enum(["passed","failed","error"]).describe("Overall result"),results:r.z.object({commands:r.z.array(r.z.object({name:r.z.string().describe("Command name"),status:r.z.enum(["passed","failed","skipped","error"]).describe("Command result"),output:r.z.string().optional().describe("Relevant output snippet"),diagnosis:r.z.string().optional().describe("Why it failed, if applicable")})).describe("Per-command results"),summary:r.z.string().describe("Brief overall summary"),acceptanceCriteria:r.z.array(r.z.object({criterion:r.z.string().describe("The acceptance criterion text"),status:r.z.enum(["verified","unverified","unclear"]),evidence:r.z.string().describe("How verified, or why not")})).optional().describe("AC verification results, if applicable")}).describe("Structured test results")}),exports.SessionMessageOperationsSchema=r.z.object({operation:r.z.enum(["send","reply","list","get","offer-handoff"]),type:r.z.enum(["question","report"]).optional().describe("Message type to send (required for send)"),toSessionId:r.z.string().optional().describe('Target session ID, or "parent" to auto-resolve to parent session (omit for broadcast questions)'),questionType:r.z.enum(["free-form","alternatives"]).optional().describe('Type of question (required for send type="question")'),questionContent:r.z.object({question:r.z.string().min(1).describe("The question text"),context:r.z.string().optional().describe("Additional context"),options:r.z.array(r.z.object({id:r.z.string(),label:r.z.string(),description:r.z.string().optional()})).optional().describe("Options for alternatives questions"),allowMultiple:r.z.boolean().optional().describe("Allow selecting multiple options")}).optional().describe('Question content (required for send type="question")'),priority:r.z.enum(["low","normal","high"]).optional().describe("Question priority"),expiresInHours:r.z.number().optional().describe("Question expiry in hours"),status:r.z.enum(["success","partial","failure","blocked"]).optional().describe('Report status (required for send type="report")'),summary:r.z.string().optional().describe('Report summary (required for send type="report")'),details:r.z.string().optional().describe("Report details"),finish:r.z.boolean().optional().describe("Release request associations after report"),messageCode:r.z.string().optional().describe("Message code (required for reply and get operations)"),respondedBySessionId:r.z.string().optional().describe("Session ID answering the question"),text:r.z.string().optional().describe("Text answer for free-form questions"),selectedOptions:r.z.array(r.z.string()).optional().describe("Selected option IDs for alternatives"),notes:r.z.string().optional().describe("Additional notes"),list:r.z.object({sessionId:r.z.string().optional().describe("Filter by session ID (auto-discovered if omitted)"),messageType:r.z.enum(["question","report","all"]).default("all").describe("Filter by message type"),direction:r.z.enum(["incoming","outgoing","all"]).default("all"),status:r.z.enum(["pending","answered","expired","success","partial","failure","blocked","all"]).default("all").describe("Filter by status"),readStatus:r.z.enum(["unread","read","acknowledged","all"]).default("all").describe("Filter by read status (reports only)"),limit:r.z.number().min(1).max(100).default(50),offset:r.z.number().min(0).default(0)}).optional().describe('List filters (operation: "list" only)'),offerHandoff:r.z.object({summary:r.z.string().describe("Summary of what was planned/created"),requestIds:r.z.array(r.z.string()).describe("Request IDs that were created from the plan")}).optional().describe('Handoff offer details (operation: "offer-handoff" only)')}).refine((e=>"send"===e.operation?!!e.type:"reply"===e.operation?!!e.messageCode:"list"===e.operation||("get"===e.operation?!!e.messageCode:"offer-handoff"===e.operation)),{message:"Invalid operation data: send requires type, reply requires messageCode, get requires messageCode"}),exports.UpdateSpecializationSchema=r.z.object({specialization:r.z.string().min(1).max(500).describe("Your updated specialization summary \u2014 a concise description of your accumulated domain expertise")})},6252(e,exports,t){"use strict"
|
|
3351
|
+
exports.TestingProcessCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the test process"),description:r.z.string().optional().describe("Description of what this process verifies"),scope:r.z.string().optional().describe('Path prefix for monorepo scoping (e.g., "packages/api/"). Omit for global.'),setup:r.z.array(r.z.string()).optional().describe('Commands to prepare the environment (e.g., ["ln -s ../../node_modules node_modules"])'),commands:r.z.array(l).min(1).describe("Test commands to execute in order"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands")}),exports.TestingProcessUpdateSchema=r.z.object({processId:r.z.string().describe("Test process ID to update"),name:r.z.string().min(1).optional().describe("New name"),description:r.z.string().optional().describe("New description"),scope:r.z.string().nullable().optional().describe("New scope (null to remove)"),isActive:r.z.boolean().optional().describe("Enable or disable the process"),setup:r.z.array(r.z.string()).optional().describe("New setup commands (replaces existing)"),commands:r.z.array(l).optional().describe("New test commands (replaces existing)"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands")}),exports.TestingReferenceSchema=r.z.object({}),exports.ExecuteTestCommandSchema=r.z.object({processId:r.z.string().describe("Test process ID containing the command"),commandName:r.z.string().describe('Name of the test command to run, or "setup" to run all setup commands in sequence')}),exports.CommandsSchema=r.z.object({operation:r.z.enum(["run","list","add","remove"]).default("run").describe('"run" to execute a command, "list" to see available commands, "add" to register a new command, "remove" to delete one'),name:r.z.string().optional().describe('Command name (required for "run", "add", and "remove")'),args:r.z.string().optional().describe('Additional arguments appended to the base command (optional, for "run")'),grep:r.z.string().optional().describe('Filter output through grep (optional, for "run"). Pipes command output through grep -i with this pattern.'),command:r.z.string().optional().describe('Shell command to register (required for "add", e.g. "tsc --noEmit")'),description:r.z.string().optional().describe('What this command verifies (optional, for "add")'),timeout:r.z.number().optional().describe('Timeout in seconds (optional, for "add", default 60)')}),exports.ReportTestResultsSchema=r.z.object({status:r.z.enum(["passed","failed","error"]).describe("Overall result"),results:r.z.object({commands:r.z.array(r.z.object({name:r.z.string().describe("Command name"),status:r.z.enum(["passed","failed","skipped","error"]).describe("Command result"),output:r.z.string().optional().describe("Relevant output snippet"),diagnosis:r.z.string().optional().describe("Why it failed, if applicable")})).describe("Per-command results"),summary:r.z.string().describe("Brief overall summary"),acceptanceCriteria:r.z.array(r.z.object({criterion:r.z.string().describe("The acceptance criterion text"),status:r.z.enum(["verified","unverified","unclear"]),evidence:r.z.string().describe("How verified, or why not")})).optional().describe("AC verification results, if applicable")}).describe("Structured test results")}),exports.SessionMessageOperationsSchema=r.z.object({operation:r.z.enum(["send","reply","list","get","offer-handoff"]),type:r.z.enum(["question","report"]).optional().describe("Message type to send (required for send)"),toSessionId:r.z.string().optional().describe('Target session ID, or "parent" to auto-resolve to parent session (omit for broadcast questions)'),questionType:r.z.enum(["free-form","alternatives"]).optional().describe('Type of question (required for send type="question")'),questionContent:r.z.object({question:r.z.string().min(1).describe("The question text"),context:r.z.string().optional().describe("Additional context"),options:r.z.array(r.z.object({id:r.z.string(),label:r.z.string(),description:r.z.string().optional()})).optional().describe("Options for alternatives questions"),allowMultiple:r.z.boolean().optional().describe("Allow selecting multiple options")}).optional().describe('Question content (required for send type="question")'),priority:r.z.enum(["low","normal","high"]).optional().describe("Question priority"),expiresInHours:r.z.number().optional().describe("Question expiry in hours"),status:r.z.enum(["success","partial","failure","blocked"]).optional().describe('Report status (required for send type="report")'),summary:r.z.string().optional().describe('Report summary (required for send type="report")'),details:r.z.string().optional().describe("Report details"),finish:r.z.boolean().optional().describe("Release request associations after report"),messageCode:r.z.string().optional().describe("Message code (required for reply and get operations)"),respondedBySessionId:r.z.string().optional().describe("Session ID answering the question"),text:r.z.string().optional().describe("Text answer for free-form questions"),selectedOptions:r.z.array(r.z.string()).optional().describe("Selected option IDs for alternatives"),notes:r.z.string().optional().describe("Additional notes"),list:r.z.object({sessionId:r.z.string().optional().describe("Filter by session ID (auto-discovered if omitted)"),messageType:r.z.enum(["question","report","all"]).default("all").describe("Filter by message type"),direction:r.z.enum(["incoming","outgoing","all"]).default("all"),status:r.z.enum(["pending","answered","expired","success","partial","failure","blocked","all"]).default("all").describe("Filter by status"),readStatus:r.z.enum(["unread","read","acknowledged","all"]).default("all").describe("Filter by read status (reports only)"),limit:r.z.number().min(1).max(100).default(50),offset:r.z.number().min(0).default(0)}).optional().describe('List filters (operation: "list" only)'),offerHandoff:r.z.object({summary:r.z.string().describe("Summary of what was planned/created"),requestIds:r.z.array(r.z.string()).describe("Request IDs that were created from the plan")}).optional().describe('Handoff offer details (operation: "offer-handoff" only)')}).refine((e=>"send"===e.operation?!!e.type:"reply"===e.operation?!!e.messageCode:"list"===e.operation||("get"===e.operation?!!e.messageCode:"offer-handoff"===e.operation)),{message:"Invalid operation data: send requires type, reply requires messageCode, get requires messageCode"}),exports.UpdateSpecializationSchema=r.z.object({specialization:r.z.string().min(1).max(500).describe("Your updated specialization summary \u2014 a concise description of your accumulated domain expertise")}),exports.CommitToViewedSessionSchema=r.z.object({message:r.z.coerce.string().min(1).describe("The cleaned-up user message to post to the viewed session. Fix obvious dictation errors, add punctuation, but preserve the user's intent exactly.")})},6252(e,exports,t){"use strict"
|
|
3327
3352
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
3328
3353
|
const r=t(6183),n=t(405)
|
|
3329
3354
|
exports.def={name:"plan_write",description:"Modify project plans.\n\nOperations:\n\u2022 update - Update plan content\n\u2022 append - Append content to an existing plan\n\u2022 replace - Find and replace text within a plan\n\u2022 create-snapshot - Create a version snapshot\n\u2022 restore - Restore to a previous version",schema:r.PlanWriteSchema,annotations:{title:"Plan Write",readOnlyHint:!1,destructiveHint:!1},handler(e,t){return(0,n.handlePlanWrite)(e,t.context,t.apiClient,t.logger,t.metrics,t.mcpServer,t.cliOrigin)}}},6261(module){"use strict"
|
|
@@ -3367,8 +3392,7 @@ if(c("session fetch status="+t.status),t.ok){const e=(await t.json()).filter((e=
|
|
|
3367
3392
|
c(`siblings=${e.length}: ${e.join(", ")}`)
|
|
3368
3393
|
const r=(0,d.pickSpecialistName)(e)
|
|
3369
3394
|
i=r,c("picked name: "+r)}}else c("no serverUrl")}catch(e){c("error: "+(e instanceof Error?e.message:e+""))}else c("no parentId")
|
|
3370
|
-
|
|
3371
|
-
k=await(0,u.handleSpawn)({agent:"specialist",prompt:y,title:i,specialization:n.specialization},r,m,s,p)
|
|
3395
|
+
k=await(0,u.handleSpawn)({agent:"specialist",prompt:n.prompt,title:i,specialization:n.specialization},r,m,s,p)
|
|
3372
3396
|
break}case"follow-up":{const e=await(0,h.getServerUrl)(r,m)
|
|
3373
3397
|
if(e)try{const t=await fetch(e.replace(/\/$/,"")+"/session/status")
|
|
3374
3398
|
if(t.ok){const e=await t.json(),r=e[w]?.type
|
|
@@ -3660,7 +3684,7 @@ if(k.error("Replace lines operation failed",{error:t instanceof Error?t.stack:t+
|
|
|
3660
3684
|
const c=a(t(1943)),l=t(6183),d=i(t(5967)),u=t(9860),h=t(5003),g=t(7478),p=t(9949),m=t(8824),f=t(3255),y=t(9470)},6688(e,exports,t){"use strict"
|
|
3661
3685
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.sessionIdentity=void 0
|
|
3662
3686
|
const r=t(9896),n=t(6928)
|
|
3663
|
-
exports.sessionIdentity=new class{constructor(){this.parentCache=new Map}setIdentity(e){const t=this.identity
|
|
3687
|
+
exports.sessionIdentity=new class{constructor(){this.parentCache=new Map,this.sessionRequestCache=new Map}setIdentity(e){const t=this.identity
|
|
3664
3688
|
this.identity=e,this.log("setIdentity",{sessionId:e.sessionId,serverUrl:e.serverUrl,agentType:e.agentType||null,prevSessionId:t?.sessionId||null,changed:t?.sessionId!==e.sessionId})}getIdentity(){return this.identity}updateIdentity(e){if(this.identity){const t={...this.identity}
|
|
3665
3689
|
this.identity={...this.identity,...e},this.log("updateIdentity",{sessionId:this.identity.sessionId,updates:Object.keys(e),agentTypeBefore:t.agentType||null,agentTypeAfter:this.identity.agentType||null})}}async getParentSessionId(e,t,r){if(this.parentCache.has(e)){const t=this.parentCache.get(e)
|
|
3666
3690
|
return this.log("getParentSessionId.cache-hit",{childExternalId:e,parentExternalId:t}),t}try{const n=t.getCLISessionClient()
|
|
@@ -3669,12 +3693,14 @@ const o=await n.getParent(e),s=o?.externalSessionId||null
|
|
|
3669
3693
|
return this.parentCache.set(e,s),this.log("getParentSessionId.resolved",{childExternalId:e,parentExternalId:s}),s||r.warn("Parent session not found",{sessionId:e}),s}catch(t){const n=t instanceof Error?t.message:t+""
|
|
3670
3694
|
return r.warn("Error getting parent session",{sessionId:e,error:n}),null}}setParentSessionId(e,t){this.parentCache.set(e,t)}async getSessionRequestId(e,t,r){const n=r||this.identity?.sessionId
|
|
3671
3695
|
if(!n)return t.warn("Cannot get session request: no session identity"),null
|
|
3696
|
+
const o=this.sessionRequestCache.get(n)
|
|
3697
|
+
if(o)return this.log("getSessionRequestId.cache-hit",{sessionId:n,requestId:o}),o
|
|
3672
3698
|
try{const r=e.getSessionRequestAssociationClient?.()
|
|
3673
3699
|
if(!r)return t.warn("Session request association client not available"),null
|
|
3674
3700
|
const o=await r.getActiveRequestsForSession(n)
|
|
3675
3701
|
if(o?.length>0){const e=o[0].requestLocalId||o[0].request_local_id
|
|
3676
|
-
return this.log("getSessionRequestId.resolved",{sessionId:n,requestId:e}),e||null}return this.log("getSessionRequestId.none",{sessionId:n}),null}catch(e){const r=e instanceof Error?e.message:e+""
|
|
3677
|
-
return t.warn("Error getting session request",{sessionId:n,error:r}),null}}buildCliOrigin(e){if(this.identity)return{providerId:this.identity.providerId,sessionId:this.identity.sessionId,messageId:e,createdAt:(new Date).toISOString()}}setCurrentCallOrigin(e){this.currentCallOrigin=e}getCurrentCallOrigin(){return this.currentCallOrigin||this.buildCliOrigin()}log(e,t){try{const o=process.env.ALCHEMY_PROJECT_PATH||process.cwd(),s=(0,n.join)(o,".alchemy_lab");(0,r.existsSync)(s)||(0,r.mkdirSync)(s,{recursive:!0})
|
|
3702
|
+
return e&&this.sessionRequestCache.set(n,e),this.log("getSessionRequestId.resolved",{sessionId:n,requestId:e}),e||null}return this.log("getSessionRequestId.none",{sessionId:n}),null}catch(e){const r=e instanceof Error?e.message:e+""
|
|
3703
|
+
return t.warn("Error getting session request",{sessionId:n,error:r}),null}}clearSessionRequestCache(e){e?this.sessionRequestCache.delete(e):this.sessionRequestCache.clear()}buildCliOrigin(e){if(this.identity)return{providerId:this.identity.providerId,sessionId:this.identity.sessionId,messageId:e,createdAt:(new Date).toISOString()}}setCurrentCallOrigin(e){this.currentCallOrigin=e}getCurrentCallOrigin(){return this.currentCallOrigin||this.buildCliOrigin()}log(e,t){try{const o=process.env.ALCHEMY_PROJECT_PATH||process.cwd(),s=(0,n.join)(o,".alchemy_lab");(0,r.existsSync)(s)||(0,r.mkdirSync)(s,{recursive:!0})
|
|
3678
3704
|
const i=(0,n.join)(s,"mcp-identity-debug.log"),a=(new Date).toISOString(),c=process.pid,l=t?" "+JSON.stringify(t):"";(0,r.appendFileSync)(i,`[${a}] [PID:${c}] identity.${e}${l}\n`)}catch{}}},exports.sessionIdentity.log("module-load",{ALCHEMY_SESSION_TAG:process.env.ALCHEMY_SESSION_TAG||null,ALCHEMY_INITIAL_BRANCH:process.env.ALCHEMY_INITIAL_BRANCH||null,ALCHEMY_ALLOW_PARALLEL:process.env.ALCHEMY_ALLOW_PARALLEL||null})},6756(e,exports){"use strict"
|
|
3679
3705
|
var t,r
|
|
3680
3706
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.TaskStatus=exports.RequestStatus=void 0,function(e){e.OPEN="open",e.IN_PROGRESS="in_progress",e.COMPLETED="completed",e.CONFLICTED="conflicted",e.READY_FOR_REVIEW="ready_for_review",e.PENDING_APPROVAL="pending_approval"}(t||(exports.RequestStatus=t={})),function(e){e.PENDING="pending",e.IN_PROGRESS="in_progress",e.READY_FOR_REVIEW="ready_for_review",e.COMPLETED="completed"}(r||(exports.TaskStatus=r={}))},6770(e,exports,t){"use strict"
|
|
@@ -4226,7 +4252,7 @@ return s.info("Plan updated",{planId:a}),{content:[{type:"text",text:`\u2705 **P
|
|
|
4226
4252
|
const r=t(8824)},7613(e,exports,t){"use strict"
|
|
4227
4253
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
4228
4254
|
const r=t(6183),n=t(9072)
|
|
4229
|
-
exports.def={name:"session_message_operations",description:'Inter-session messaging (questions and reports).\n\nOperations:\n\u2022 send - Send a message (type: "question" or "report")\n\u2022 reply - Reply to a message (answer a question or acknowledge a report). Type inferred from code prefix (Q-/R-).\n\u2022 list - List messages (filter by messageType, direction, status)\n\u2022 get - Get a message by its code\n\u2022 offer-handoff - Present the user with a choice to start building or keep planning\n\nMessage codes: Q-{id}-{seq} for questions, R-{id}-{seq} for reports.',schema:r.SessionMessageOperationsSchema,annotations:{title:"Session Message Operations",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler(e,t){return(0,n.handleSessionMessageOperations)(e,t.context,t.logger,t.metrics,t.apiClient??void 0)}}},7617(e,exports,t){"use strict"
|
|
4255
|
+
exports.def={name:"session_message_operations",description:'Inter-session messaging (questions and reports).\n\nOperations:\n\u2022 send - Send a message (type: "question" or "report")\n\u2022 reply - Reply to a message (answer a question or acknowledge a report). Type inferred from code prefix (Q-/R-).\n\u2022 list - List messages (filter by messageType, direction, status)\n\u2022 get - Get a message by its code\n\u2022 offer-handoff - Present the user with a choice to start building or keep planning\n\nMessage codes: Q-{id}-{seq} for questions, R-{id}-{seq} for reports.',schema:r.SessionMessageOperationsSchema,annotations:{title:"Session Message Operations",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler(e,t){return(0,n.handleSessionMessageOperations)(e,t.context,t.logger,t.metrics,t.apiClient??void 0,t.cliOrigin)}}},7617(e,exports,t){"use strict"
|
|
4230
4256
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.getServerUrl=async function(e,r){let n=process.env.OPENCODE_TUI_URL
|
|
4231
4257
|
if(!n)try{const{readFileSync:o}=await Promise.resolve().then(t.t.bind(t,9896,23)),{join:s}=await Promise.resolve().then(t.t.bind(t,6928,23)),i=o(s(e.basePath,".alchemy_lab","opencode.json"),"utf8"),a=JSON.parse(i)
|
|
4232
4258
|
a.port&&(n="http://127.0.0.1:"+a.port,r.debug("Discovered OpenCode server URL from .alchemy_lab/opencode.json",{serverUrl:n}))}catch(e){r.debug("Could not read .alchemy_lab/opencode.json",{error:e instanceof Error?e.message:e+""})}return n}},7621(e,exports,t){"use strict"
|
|
@@ -4717,7 +4743,10 @@ let u=`**${e} Operation Complete**\n\n`
|
|
|
4717
4743
|
return u+="**Summary:**\n",u+=`- **Files processed:** ${s+i}\n`,u+=`- **Successful operations:** ${s}\n`,u+=`- **Failed operations:** ${i}\n`,u+=`- **Total changes made:** ${a}\n\n`,r.success&&r.commitHash?(u+="**Git Commit:**\n",u+=`- **Commit Hash:** ${r.commitHash.substring(0,8)}\n`,u+=`- **Files Committed:** ${r.filesCommitted.length}\n`,r.previousCommitHash&&(u+=`- **Previous Commit:** ${r.previousCommitHash.substring(0,8)}\n`),u+="\n"):r.error&&(u+=`**Git Status:** Changes saved but commit failed - ${r.error}\n\n`),n?.lockAcquired&&n.lockedRequestId&&(u+=`\u{1f512} **Locked request:** ${n.lockedRequestId}\n\n`),l.length>0&&(u+="**\u2705 Successful Operations:**\n",l.slice(0,10).forEach((e=>{const t=o?e[o]||0:"completed",r=e.path||e.documentId||"unknown"
|
|
4718
4744
|
u+=`- \`${r}\`: ${t} changes\n`})),l.length>10&&(u+=`- ... and ${l.length-10} more files\n`),u+="\n"),d.length>0&&(u+="**\u274c Failed Operations:**\n",d.slice(0,5).forEach((e=>{const t=e.path||e.documentId||"unknown"
|
|
4719
4745
|
u+=`- \`${t}\`: ${e.error||"Unknown error"}\n`})),d.length>5&&(u+=`- ... and ${d.length-5} more failures\n`)),{content:[{type:"text",text:u}],isError:!c}}
|
|
4720
|
-
const r=t(8824)},
|
|
4746
|
+
const r=t(8824)},8456(e,exports,t){"use strict"
|
|
4747
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
4748
|
+
const r=t(6183),n=t(2113)
|
|
4749
|
+
exports.def={name:"commit_to_viewed_session",description:"Post a cleaned-up user message to the session the user is currently viewing. Translator-only. Call this when the dictation is clear and ready to forward.",schema:r.CommitToViewedSessionSchema,annotations:{title:"Commit to Viewed Session",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler(e,t){return(0,n.handleCommitToViewedSession)(e,t.logger)}}},8485(e,exports){"use strict"
|
|
4721
4750
|
function t(e,t){const r=e.match(/^([ \t]*)(.*?)\s*$/)
|
|
4722
4751
|
if(!r)return e
|
|
4723
4752
|
const[,n,s]=r
|
|
@@ -4982,47 +5011,47 @@ e.success&&e.agentType&&(s=e.agentType)}}catch(t){n.warn("Agent type lookup fail
|
|
|
4982
5011
|
if(e.ok){const t=await e.json()
|
|
4983
5012
|
if(t.data?.defaultModel){const[e,...r]=t.data.defaultModel.split("/")
|
|
4984
5013
|
i={providerID:e,modelID:r.join("/")}}}}catch{}const a=`${o.replace(/\/$/,"")}/session/${e}/prompt_async`,c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parts:[{type:"text",text:"\x3c!-- inserted-prompt --\x3e"+t}],...s?{agent:s}:{},...i?{model:i}:{}})})
|
|
4985
|
-
return c.ok?(n.info("Notified session",{sessionId:e}),!0):(n.warn("Failed to notify session",{sessionId:e,status:c.status}),!1)}catch(t){return n.warn("Error notifying session",{sessionId:e,error:(0,l.getErrorMessage)(t)}),!1}}function n(e,t,r){return u.sessionIdentity.getParentSessionId(e,t,r)}function o(e,t,r){const
|
|
4986
|
-
if(!
|
|
4987
|
-
return(0,h.logSessionIdentity)(""+r,"identity",{sessionId:
|
|
5014
|
+
return c.ok?(n.info("Notified session",{sessionId:e}),!0):(n.warn("Failed to notify session",{sessionId:e,status:c.status}),!1)}catch(t){return n.warn("Error notifying session",{sessionId:e,error:(0,l.getErrorMessage)(t)}),!1}}function n(e,t,r){return u.sessionIdentity.getParentSessionId(e,t,r)}function o(e,t,r,n,o){const s=o?.sessionId||u.sessionIdentity.getIdentity()?.sessionId
|
|
5015
|
+
if(!s)throw new c.ValidationError("No session identity available. Make sure you are running within an OpenCode session.")
|
|
5016
|
+
return(0,h.logSessionIdentity)(""+r,"identity",{sessionId:s,fromCliOrigin:!!o?.sessionId}),s}function s(e){const t=[],r=e.content||{}
|
|
4988
5017
|
if(t.push("**Message Code:** "+e.messageCode),t.push(`**Type:** question (${r.questionType})`),t.push("**Status:** "+e.status),t.push("**Priority:** "+e.priority),t.push("**From:** "+e.fromSessionId),t.push(e.toSessionId?"**To:** "+e.toSessionId:"**To:** (broadcast)"),t.push("**Created:** "+e.createdAt),t.push("**Expires:** "+e.expiresAt),t.push(""),t.push("**Question:** "+r.question),r.context&&t.push("**Context:** "+r.context),"alternatives"===r.questionType&&r.options){t.push(""),t.push("**Options:**")
|
|
4989
5018
|
for(const e of r.options)t.push(` - [${e.id}] ${e.label}${e.description?" - "+e.description:""}`)}return"responded"===e.status&&e.response&&(t.push(""),t.push("---"),t.push("**Answered by:** "+e.respondedBySessionId),t.push("**Answered at:** "+e.respondedAt),e.response.text&&t.push("**Answer:** "+e.response.text),e.response.selectedOptions&&t.push("**Selected:** "+e.response.selectedOptions.join(", ")),e.response.notes&&t.push("**Notes:** "+e.response.notes)),t.join("\n")}function i(e){const t=[],r=e.content||{}
|
|
4990
|
-
return t.push("**Status:** "+(r.reportStatus||"unknown")),t.push("**Summary:** "+(r.summary||"")),r.details&&(t.push(""),t.push("**Details:**"),t.push(r.details)),t.join("\n")}function a(e){return"question"===e.messageType?s(e):i(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleSessionMessageOperations=async function(e,t,d,p,m){const
|
|
5019
|
+
return t.push("**Status:** "+(r.reportStatus||"unknown")),t.push("**Summary:** "+(r.summary||"")),r.details&&(t.push(""),t.push("**Details:**"),t.push(r.details)),t.join("\n")}function a(e){return"question"===e.messageType?s(e):i(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleSessionMessageOperations=async function(e,t,d,p,m,f){const y=d.child({component:"session_message_operations"})
|
|
4991
5020
|
if(!m)throw new c.ValidationError("API client not available")
|
|
4992
|
-
const{operation:
|
|
4993
|
-
|
|
4994
|
-
try{switch(
|
|
4995
|
-
return await async function(e,t,a,l){const{type:
|
|
4996
|
-
if(!
|
|
4997
|
-
const
|
|
4998
|
-
if(!
|
|
4999
|
-
if("question"===
|
|
5000
|
-
if(!
|
|
5001
|
-
const
|
|
5021
|
+
const{operation:w}=e
|
|
5022
|
+
y.info("Session message operation",{operation:w}),p.incrementCounter("session_message_operations",1,{operation:w})
|
|
5023
|
+
try{switch(w){case"send":if(!e.type)throw new c.ValidationError('send operation requires type ("question" or "report")')
|
|
5024
|
+
return await async function(e,t,a,l,d){const{type:u}=e
|
|
5025
|
+
if(!u)throw new c.ValidationError('send operation requires type ("question" or "report")')
|
|
5026
|
+
const h=l.getSessionMessageClient()
|
|
5027
|
+
if(!h)throw new c.ValidationError("Session message client not available")
|
|
5028
|
+
if("question"===u)return await async function(e,t,i,a,l,d){const{toSessionId:u,questionType:h,questionContent:g,priority:p,expiresInHours:m}=e
|
|
5029
|
+
if(!h||!g?.question)throw new c.ValidationError("Question requires questionType and questionContent.question")
|
|
5030
|
+
const f=o(0,0,"session_message_operations",0,d),y=await async function(e,t,r,o){if("parent"===e){const e=await n(t,r,o)
|
|
5002
5031
|
if(!e)throw new c.ValidationError("Could not find parent session. Make sure this session was spawned as a subagent.")
|
|
5003
|
-
return o.info('Resolved toSessionId "parent" to actual ID',{parentId:e}),e}return e}(
|
|
5004
|
-
if(!("alternatives"!==
|
|
5005
|
-
i.info("Creating question",{fromSessionId:
|
|
5006
|
-
const
|
|
5007
|
-
let
|
|
5008
|
-
return
|
|
5032
|
+
return o.info('Resolved toSessionId "parent" to actual ID',{parentId:e}),e}return e}(u,f,a,i)
|
|
5033
|
+
if(!("alternatives"!==h||g.options&&Array.isArray(g.options)))throw new c.ValidationError("Alternatives questions require options array")
|
|
5034
|
+
i.info("Creating question",{fromSessionId:f,toSessionId:y,questionType:h})
|
|
5035
|
+
const w=await l.createQuestion({fromSessionId:f,toSessionId:y,questionType:h,question:g.question,options:g.options,context:g.context,allowMultiple:g.allowMultiple,priority:p,expiresInHours:m})
|
|
5036
|
+
let k=""
|
|
5037
|
+
return y&&(k=await r(y,function(e){const t=e.content||{},r=["\u{1f4e8} **You have a new question!**","","**Question Code:** "+e.messageCode,"**From:** "+e.fromSessionId,"**Priority:** "+e.priority,"","**Question:** "+t.question]
|
|
5009
5038
|
if(t.context&&r.push("**Context:** "+t.context),"alternatives"===t.questionType&&t.options){r.push(""),r.push("**Options:**")
|
|
5010
|
-
for(const e of t.options)r.push(` - [${e.id}] ${e.label}${e.description?" - "+e.description:""}`)}return r.push(""),r.push(`Use \`session_message_operations\` with \`reply\` operation and message code \`${e.messageCode}\` to respond.`),r.join("\n")}(
|
|
5011
|
-
if("report"===
|
|
5012
|
-
if(!
|
|
5013
|
-
const
|
|
5014
|
-
const t=await n(
|
|
5015
|
-
if(
|
|
5016
|
-
|
|
5017
|
-
s.info("Submitting report",{sessionId:
|
|
5018
|
-
const
|
|
5019
|
-
let
|
|
5020
|
-
try{const e=await fetch(`http://localhost:${g}/api/sessions/${encodeURIComponent(
|
|
5039
|
+
for(const e of t.options)r.push(` - [${e.id}] ${e.label}${e.description?" - "+e.description:""}`)}return r.push(""),r.push(`Use \`session_message_operations\` with \`reply\` operation and message code \`${e.messageCode}\` to respond.`),r.join("\n")}(w),t,i)?"\n\n\u{1f4ec} The target session has been notified.":"\n\n\u26a0\ufe0f Could not notify the target session (may be offline)."),{content:[{type:"text",text:`\u2705 Question created!${k}\n\n**Message Code: ${w.messageCode}**\n\nUse this code to check for answers or share with other sessions.\n\n${s(w)}`}]}}(e,t,a,l,h,d)
|
|
5040
|
+
if("report"===u)return await async function(e,t,s,a,l,d){const{status:u,summary:h,details:p,finish:m}=e
|
|
5041
|
+
if(!u||!h)throw new c.ValidationError("Report requires status and summary")
|
|
5042
|
+
const f=o(0,0,"session_message_operations",0,d),y=await(async()=>{if(e.toSessionId&&"parent"!==e.toSessionId)return s.info("Using explicit toSessionId for report",{parentSessionId:e.toSessionId}),e.toSessionId
|
|
5043
|
+
const t=await n(f,a,s)
|
|
5044
|
+
if(t)return s.info("Auto-resolved parent session",{parentSessionId:t}),t
|
|
5045
|
+
throw new c.ValidationError("Could not find parent session. Ensure this session was created with a parent link, or provide an explicit toSessionId.")})()
|
|
5046
|
+
s.info("Submitting report",{sessionId:f,parentSessionId:y,status:u})
|
|
5047
|
+
const w=await l.createReport({fromSessionId:f,toSessionId:y,status:u,summary:h,details:p})
|
|
5048
|
+
let k="agent"
|
|
5049
|
+
try{const e=await fetch(`http://localhost:${g}/api/sessions/${encodeURIComponent(f)}/agent-type`)
|
|
5021
5050
|
if(e.ok){const t=await e.json()
|
|
5022
|
-
t.success&&t.agentType&&(
|
|
5023
|
-
return r.details&&(n.push(""),n.push(r.details)),n.join("\n")}(
|
|
5024
|
-
return{content:[{type:"text",text:`\u2705 Report submitted.${
|
|
5025
|
-
throw new c.ValidationError(`Unknown message type: ${
|
|
5051
|
+
t.success&&t.agentType&&(k=t.agentType)}}catch{}const I=await r(y,function(e,t="agent"){const r=e.content||{},n=[`${{success:"\u2705",partial:"\u26a0\ufe0f",failure:"\u274c",blocked:"\u{1f6ab}"}[r.reportStatus]||"\u{1f4cb}"} **Report \u2014 ${r.reportStatus}**`,`from: ${t} (${e.fromSessionId})`,"",r.summary]
|
|
5052
|
+
return r.details&&(n.push(""),n.push(r.details)),n.join("\n")}(w,k),t,s)
|
|
5053
|
+
return{content:[{type:"text",text:`\u2705 Report submitted.${I?"\n\n\u{1f4ec} The parent session has been notified.":"\n\n\u26a0\ufe0f Could not notify the parent session (may be offline)."}\n\n${i(w)}`}]}}(e,t,a,l,h,d)
|
|
5054
|
+
throw new c.ValidationError(`Unknown message type: ${u}. Use "question" or "report".`)}(e,t,y,m,f)
|
|
5026
5055
|
case"reply":if(!e.messageCode)throw new c.ValidationError("reply operation requires messageCode")
|
|
5027
5056
|
return await async function(e,t,n,o){const{messageCode:a}=e
|
|
5028
5057
|
if(!a)throw new c.ValidationError("reply operation requires messageCode")
|
|
@@ -5033,24 +5062,24 @@ n.info("Answering question",{messageCode:a,respondedBySessionId:o})
|
|
|
5033
5062
|
const u=await l.answerQuestion(a,{respondedBySessionId:o,text:i,selectedOptions:c,notes:d})
|
|
5034
5063
|
return{content:[{type:"text",text:`\u2705 Question answered!${await r(u.fromSessionId,function(e){const t=e.content||{},r=e.response||{},n=["\u{1f4ec} **Your question has been answered!**","","**Question Code:** "+e.messageCode,"**Question:** "+t.question,"","---","**Answered by:** "+e.respondedBySessionId]
|
|
5035
5064
|
return r.text&&n.push("**Answer:** "+r.text),r.selectedOptions&&n.push("**Selected:** "+r.selectedOptions.join(", ")),r.notes&&n.push("**Notes:** "+r.notes),n.join("\n")}(u),t,n)?"\n\n\u{1f4ec} The asking session has been notified.":"\n\n\u26a0\ufe0f Could not notify the asking session (may be offline)."}\n\n${s(u)}`}]}}if(a.startsWith("R-"))return n.info("Acknowledging report",{messageCode:a}),{content:[{type:"text",text:"\u2705 Report acknowledged!\n\n"+i(await l.acknowledgeReport(a))}]}
|
|
5036
|
-
throw new c.ValidationError(`Cannot determine message type from code "${a}". Expected Q-xxx (question) or R-xxx (report).`)}(e,t,
|
|
5037
|
-
case"offer-handoff":{const t=e.offerHandoff||{summary:e.summary||"",requestIds:e.requestIds||[]}
|
|
5038
|
-
|
|
5039
|
-
try{
|
|
5040
|
-
if(e
|
|
5041
|
-
await e.createQuestion({fromSessionId:r,toSessionId:s||void 0,questionType:"alternatives",question:"Plan ready: "+(t.summary||"Plan complete"),options:[{id:"build",label:"Start Building",description:`Begin building ${n} request${1!==n?"s":""}`},{id:"plan",label:"Keep Planning",description:"Continue refining the plan"}],context:
|
|
5042
|
-
const
|
|
5043
|
-
if(!
|
|
5044
|
-
if(!
|
|
5045
|
-
if(!e
|
|
5046
|
-
|
|
5047
|
-
const
|
|
5048
|
-
|
|
5049
|
-
const
|
|
5050
|
-
if(0===
|
|
5051
|
-
const
|
|
5052
|
-
for(const e of
|
|
5053
|
-
return{content:[{type:"text",text:
|
|
5065
|
+
throw new c.ValidationError(`Cannot determine message type from code "${a}". Expected Q-xxx (question) or R-xxx (report).`)}(e,t,y,m)
|
|
5066
|
+
case"offer-handoff":{const t=e.offerHandoff||{summary:e.summary||"",requestIds:e.requestIds||[]},r=o(0,0,"session_message_operations",0,f),s=await n(r,m,y)
|
|
5067
|
+
s||y.warn("offer-handoff: no parent session found \u2014 notification will be global",{fromSessionId:r})
|
|
5068
|
+
try{const e=m.getSessionMessageClient()
|
|
5069
|
+
if(e){const n=t.requestIds?.length||0
|
|
5070
|
+
await e.createQuestion({fromSessionId:r,toSessionId:s||void 0,questionType:"alternatives",question:"Plan ready: "+(t.summary||"Plan complete"),options:[{id:"build",label:"Start Building",description:`Begin building ${n} request${1!==n?"s":""}`},{id:"plan",label:"Keep Planning",description:"Continue refining the plan"}],context:JSON.stringify({type:"plan-completion",plannerSessionId:r,parentSessionId:s,requestIds:t.requestIds,summary:t.summary}),category:"action-required",priority:"high"}),y.info("offer-handoff: notification question created",{fromSessionId:r,parentSessionId:s})}else y.warn("offer-handoff: skipping notification question \u2014 no message client")}catch(e){y.warn("offer-handoff: failed to create notification question",{error:(0,l.getErrorMessage)(e)})}return{content:[{type:"text",text:'Handoff offered to user. STOP here and wait \u2014 the user will choose "Start Building" or "Keep Planning". You will receive their choice as a new message. Do NOT generate any further output until then.\nPLAN_HANDOFF_PENDING|'+JSON.stringify({summary:t.summary,requestIds:t.requestIds,parentSessionId:s,fromSessionId:r})}],isError:!1}}case"list":return await async function(e,t,r,n,o){let{sessionId:s,messageType:i,direction:l,status:d,readStatus:g,reportStatus:p,limit:m,offset:f}=e
|
|
5071
|
+
const y=n.getSessionMessageClient()
|
|
5072
|
+
if(!y)throw new c.ValidationError("Session message client not available")
|
|
5073
|
+
if(!s){const e=o?.sessionId||u.sessionIdentity.getIdentity()?.sessionId
|
|
5074
|
+
if(!e)return r.warn("No session identity for list operation"),{content:[{type:"text",text:"\u26a0\ufe0f Could not determine current session ID. Unable to list messages without a session context."}]}
|
|
5075
|
+
s=e,(0,h.logSessionIdentity)("session_message_operations.list","identity",{sessionId:s,fromCliOrigin:!!o?.sessionId})}r.debug("Listing messages",{sessionId:s,messageType:i,direction:l,status:d,readStatus:g})
|
|
5076
|
+
const w={sessionId:s,direction:l,limit:m,offset:f}
|
|
5077
|
+
i&&"all"!==i&&(w.messageType=i),d&&"all"!==d&&("report"===i?w.reportStatus=d:w.status=d),g&&"all"!==g&&(w.readStatus=g),p&&"all"!==p&&(w.reportStatus=p)
|
|
5078
|
+
const k=await y.listMessages(w)
|
|
5079
|
+
if(0===k.length)return{content:[{type:"text",text:"No messages found matching the criteria."}]}
|
|
5080
|
+
const I=[`Found ${k.length} message(s):\n`]
|
|
5081
|
+
for(const e of k)I.push("---\n"),I.push(a(e)),I.push("")
|
|
5082
|
+
return{content:[{type:"text",text:I.join("\n")}]}}(e.list||{},0,y,m,f)
|
|
5054
5083
|
case"get":if(!e.messageCode)throw new c.ValidationError("get operation requires messageCode")
|
|
5055
5084
|
return await async function(e,t,r){const{messageCode:n}=e
|
|
5056
5085
|
if(!n)throw new c.ValidationError("get operation requires messageCode")
|
|
@@ -5058,9 +5087,9 @@ const o=r.getSessionMessageClient()
|
|
|
5058
5087
|
if(!o)throw new c.ValidationError("Session message client not available")
|
|
5059
5088
|
t.debug("Getting message",{messageCode:n})
|
|
5060
5089
|
const s=await o.getMessage(n)
|
|
5061
|
-
return s?{content:[{type:"text",text:a(s)}]}:{content:[{type:"text",text:`\u274c Message with code ${n} not found.`}],isError:!0}}(e,
|
|
5062
|
-
default:throw new c.ValidationError(`Unknown operation: ${
|
|
5063
|
-
const c=t(9860),l=t(8824),d=t(7617),u=t(6688),h=t(7280),g=
|
|
5090
|
+
return s?{content:[{type:"text",text:a(s)}]}:{content:[{type:"text",text:`\u274c Message with code ${n} not found.`}],isError:!0}}(e,y,m)
|
|
5091
|
+
default:throw new c.ValidationError(`Unknown operation: ${w}. Valid operations: send, reply, list, get`)}}catch(e){return y.error("Session message operation failed",{operation:w,error:(0,l.getErrorMessage)(e)}),{content:[{type:"text",text:"\u274c Error: "+(0,l.getErrorMessage)(e)}],isError:!0}}}
|
|
5092
|
+
const c=t(9860),l=t(8824),d=t(7617),u=t(6688),h=t(7280),g=(0,t(9414).getActionServerPort)()},9080(e,exports,t){"use strict"
|
|
5064
5093
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
5065
5094
|
const r=t(6183),n=t(1281)
|
|
5066
5095
|
exports.def={name:"search",description:"Search for text patterns in files on the currently active branch. Supports regex patterns and sorts results by file modification time (newest first).\n\nFile extensions: 'ts', '.ts', '*.ts' (all valid). Use '*' for any file type.\n\nCONTEXT LINES: Use contextLines option (0-10) to show surrounding lines before and after matches, reducing need for follow-up reads.\n\nLIST-ALL MODE: Omit 'needle' to list all files in a directory with tree structure (like ls/tree). Options: levels (1-4 depth), sortBy (name/modified/size/type).",schema:r.SearchSchema,annotations:{title:"Search Files",readOnlyHint:!0},readOnly:!0,handler(e,t){return(0,n.handleSearch)(e,t.context,t.apiClient,t.logger,t.metrics)}}},9089(e,exports){"use strict"
|
|
@@ -5125,7 +5154,15 @@ const r=t(6183),n=t(9863)
|
|
|
5125
5154
|
exports.def={name:"list_tasks",description:"List and filter tasks",schema:r.ListTasksSchema,annotations:{title:"List Tasks",readOnlyHint:!0},hidden:!0,readOnly:!0,handler(e,t){return(0,n.handleListTasks)(e,t.context,t.apiClient,t.logger,t.metrics)}}},9373(e,exports,t){"use strict"
|
|
5126
5155
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.def=void 0
|
|
5127
5156
|
const r=t(6183),n=t(6416)
|
|
5128
|
-
exports.def={name:"revert_request",description:"Cancel open/in-progress requests or revert completed requests.\n\nCancel (open/in-progress):\n\u2022 Status set to 'canceled', request becomes read-only\n\u2022 No git operations, branch preserved\n\nRevert (completed):\n\u2022 All file changes undone via git revert\n\u2022 Request/task status set to 'reverted'\n\u2022 Request branch deleted\n\u2022 Fails fast if conflicts detected\n\nPreserved: Documents, git history, tool records (for audit trail).",schema:r.RevertRequestSchema,annotations:{title:"Revert Request",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1},hidden:!0,handler(e,t){return(0,n.handleRevertRequest)(e,t.context,t.apiClient,t.logger,t.metrics)}}},
|
|
5157
|
+
exports.def={name:"revert_request",description:"Cancel open/in-progress requests or revert completed requests.\n\nCancel (open/in-progress):\n\u2022 Status set to 'canceled', request becomes read-only\n\u2022 No git operations, branch preserved\n\nRevert (completed):\n\u2022 All file changes undone via git revert\n\u2022 Request/task status set to 'reverted'\n\u2022 Request branch deleted\n\u2022 Fails fast if conflicts detected\n\nPreserved: Documents, git history, tool records (for audit trail).",schema:r.RevertRequestSchema,annotations:{title:"Revert Request",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1},hidden:!0,handler(e,t){return(0,n.handleRevertRequest)(e,t.context,t.apiClient,t.logger,t.metrics)}}},9414(e,exports,t){"use strict"
|
|
5158
|
+
function r(){const e=Date.now()
|
|
5159
|
+
if(null!==c&&d>e-l)return c
|
|
5160
|
+
const t=(0,o.join)(process.env.ALCHEMY_PROJECT_PATH||process.cwd(),i,a)
|
|
5161
|
+
if((0,n.existsSync)(t))try{const r=(0,n.readFileSync)(t,"utf-8"),o=JSON.parse(r)
|
|
5162
|
+
if("number"==typeof o.port&&o.port>0&&65536>o.port)return c=o.port,l=e,c}catch{}return c=s,l=e,c}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getActionServerPort=r,exports.getActionServerBaseUrl=function(){return"http://localhost:"+r()}
|
|
5163
|
+
const n=t(9896),o=t(6928),s=3456,i=".alchemy_lab",a="action-server.json"
|
|
5164
|
+
let c=null,l=0
|
|
5165
|
+
const d=5e3},9422(e,exports,t){"use strict"
|
|
5129
5166
|
Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleDebugRequestFileHistory=async function(e,t,n,o){const s=o.child({tool:"debug_request_file_history"})
|
|
5130
5167
|
try{const{requestId:n="req000046"}=e
|
|
5131
5168
|
if(!t.git)throw Error("Git integration not available")
|