werkmeister 0.24.0 → 0.24.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/lib/agent_state.js +4 -4
- package/dist/main.js +277 -277
- package/dist/mcp.js +1 -1
- package/dist/sandbox-workspaces.vsix +0 -0
- package/package.json +2 -2
package/dist/lib/agent_state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
var b=Object.defineProperty;var i=(e,t)=>b(e,"name",{value:t,configurable:!0});import*as
|
|
4
|
-
`);for(let o
|
|
5
|
-
`)}return null}i(
|
|
6
|
-
`),
|
|
3
|
+
var b=Object.defineProperty;var i=(e,t)=>b(e,"name",{value:t,configurable:!0});import*as r from"node:fs";import*as x from"node:path";import*as g from"node:fs";import*as l from"node:path";var y=[".werkmeister",".sandbox"];function d(e){let t=y.find(n=>g.existsSync(l.join(e,n)));return l.join(e,t??y[0])}i(d,"dotDir");import*as m from"node:fs";import*as p from"node:path";function S(e){let t=p.resolve(e);for(;;){if(m.existsSync(p.join(d(t),"workspace.yml")))return t;let n=p.dirname(t);if(n===t)return null;t=n}}i(S,"findRecordRoot");var q=new Set(["working","needs-you","done","idle"]),R=new Set(["AskUserQuestion","ExitPlanMode"]),_="mcp__ccd_turn__wrap_up",v=new Set(["permission_prompt","elicitation_dialog"]),w=i(e=>x.join(d(e),"agent-state.json"),"stateFile");function A(e){try{let t=JSON.parse(r.readFileSync(w(e),"utf8"));if(!q.has(t?.state)||typeof t.at!="string")return null;let n={state:t.state,at:t.at};return typeof t.question=="string"&&(n.question=t.question),t.via==="wrap_up"&&(n.via="wrap_up"),n}catch{return null}}i(A,"readAgentState");function T(e){return/\?[\s*_`'")\]]*$/.test(e)}i(T,"asksQuestion");function P(e){let t=e.trim().split(/\n\s*\n/);return t[t.length-1].trim().slice(0,200)}i(P,"questionOf");function $(e){let t=r.openSync(e,"r"),n;try{let s=r.fstatSync(t).size,a=Math.min(s,65536),c=Buffer.alloc(a);r.readSync(t,c,0,a,s-a),n=c.toString("utf8")}finally{r.closeSync(t)}let o=n.split(`
|
|
4
|
+
`);for(let s=o.length-1;s>=0;s--){let a;try{a=JSON.parse(o[s])}catch{continue}if(a.type!=="assistant")continue;let c=a.message?.content;if(typeof c=="string")return c;if(!Array.isArray(c))continue;let u=c.filter(f=>f?.type==="text"&&typeof f.text=="string");if(u.length)return u.map(f=>f.text).join(`
|
|
5
|
+
`)}return null}i($,"lastAssistantText");function O(e,t){switch(e.hook_event_name){case"UserPromptSubmit":return{state:"working"};case"PostToolUse":return e.tool_name===_&&t?.via==="wrap_up"?null:{state:"working"};case"PreToolUse":{let n=String(e.tool_name??""),o=e.tool_input?.ask;if(n===_&&typeof o=="string"&&o.trim())return{state:"needs-you",question:o.trim(),via:"wrap_up"};if(!R.has(n))return{state:"working"};let s=e.tool_input?.questions?.[0]?.question;return{state:"needs-you",question:typeof s=="string"?s:"Approve the plan?"}}case"Notification":{let n=e.notification_type,o=String(e.message??"");return!(typeof n=="string"?v.has(n):!/waiting for your input/i.test(o))||t?.state==="needs-you"&&t.question?null:{state:"needs-you",question:o||void 0}}case"Stop":{let n=null;return typeof e.last_assistant_message=="string"?n=e.last_assistant_message:typeof e.transcript_path=="string"&&(n=$(e.transcript_path)),n&&T(n)?{state:"needs-you",question:P(n)}:t?.via==="wrap_up"?null:{state:"done"}}case"SessionEnd":return t?.state==="working"?{state:"idle"}:null;default:return null}}i(O,"nextState");function D(e,t=new Date){let n=S(String(e.cwd||process.cwd()));if(!n)return null;let o=A(n),s=O(e,o);if(!s||o&&o.state===s.state&&o.question===s.question&&o.via===s.via)return null;let a={state:s.state,at:t.toISOString()};s.question&&(a.question=s.question),s.via&&(a.via=s.via);let c=w(n),u=`${c}.${process.pid}.tmp`;return r.writeFileSync(u,`${JSON.stringify(a)}
|
|
6
|
+
`),r.renameSync(u,c),c}i(D,"record");function k(){try{let e=process.stdin.isTTY?"":r.readFileSync(0,"utf8"),t=e.trim()?JSON.parse(e):{};typeof t=="object"&&t!==null&&!Array.isArray(t)&&D(t)}catch{}}i(k,"main");k();
|
|
7
7
|
//# sourceMappingURL=agent_state.js.map
|