@systemfsoftware/omp-agent-discipline 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Match-COXzoyjd.js +1 -0
- package/dist/dispatch-doctrine.executor-DxH6nyYK.js +9 -0
- package/dist/dispatch-doctrine.kernel-DONLJscd.js +1 -0
- package/dist/{dist-DIH94u3_.js → dist-Cu2Bufzb.js} +1 -1
- package/dist/{helpers-BDT6qmPQ.js → helpers-CWrsZEwX.js} +1 -1
- package/dist/index.js +5 -3
- package/dist/no-skill-delegation.executor-BGERu8rH.js +2 -0
- package/dist/runtime-CjkNu9Ct.js +1 -0
- package/package.json +10 -4
- package/dist/no-skill-delegation.executor-DSGbU60f.js +0 -2
- package/dist/runtime-Dydy4g09.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ks as e,Qs as t,Sc as n,Us as r,vl as i}from"./core-CwsVf2Ey.js";const a={[Symbol.for(`@effect/matcher/Matcher`)]:{_input:i,_filters:i,_remaining:i,_result:i,_provided:i,_return:i},_tag:`ValueMatcher`,add(e){return this.value._tag===`Right`?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?o(this.provided,t(e.evaluate(this.provided))):this},pipe(){return n(this,arguments)}};function o(e,t){let n=Object.create(a);return n.provided=e,n.value=t,n}const s=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),c=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(c),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,c(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},l=t=>o(t,e(t)),u=(e,t)=>n=>n.add(s(c(e),t)),d=(e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(s(i,n))})(`_tag`),f=e=>t=>{let n=p(t);return r(n)?n._tag===`Right`?n.right:e(n.left):t=>{let r=n(t);return r._tag===`Right`?r.right:e(r.left)}},p=n=>{if(n._tag===`ValueMatcher`)return n.value;let r=n.cases.length;if(r===1){let r=n.cases[0];return n=>r._tag===`When`&&r.guard(n)===!0||r._tag===`Not`&&r.guard(n)===!1?t(r.evaluate(n)):e(n)}return i=>{for(let e=0;e<r;e++){let r=n.cases[e];if(r._tag===`When`&&r.guard(i)===!0||r._tag===`Not`&&r.guard(i)===!1)return t(r.evaluate(i))}return e(i)}},m=`effect/Match/exhaustive: absurd`,h=e=>{let t=p(e);if(r(t)){if(t._tag===`Right`)return t.right;throw Error(m)}return e=>{let n=t(e);if(n._tag===`Right`)return n.right;throw Error(m)}},g=l,_=u,v=d,y=f,b=h;export{_ as a,g as i,y as n,v as r,b as t};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{n as e}from"./dispatch-doctrine.kernel-DONLJscd.js";import{D as t}from"./Effect-BcYkmFCx.js";import{C as n,t as r,v as i,w as a,x as o}from"./dist-Cu2Bufzb.js";import{a as s,i as c,r as l,t as u}from"./Match-COXzoyjd.js";const d=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDispatchCommand`);var f=class extends n()(`CheckDispatchCommand`,{toolName:o,doctrineLoaded:i,gateEnabled:i}){[d]=d};const p=Symbol.for(`@systemfsoftware/omp-agent-discipline/DispatchDoctrineVerdict`);var m=class extends n()(`Allow`,{}){[p]=p},h=class extends n()(`DeliverDoctrine`,{reason:o}){[p]=p};a(m,h);const g=t=>t.gateEnabled&&e(t.toolName)&&!t.doctrineLoaded,_=e=>c(g(e)).pipe(s(!0,()=>new h({reason:`Refuse monolithic dispatches: size the unit, specify it completely, then dispatch — or do the work inline.
|
|
2
|
+
|
|
3
|
+
rules:
|
|
4
|
+
- GATE: decomposition is mandatory when ANY hold — multi-subsystem; exceeds one focused session for the worker's model class; irreversible side effects; verification longer than the work; incompatible reasoning modes. Dispatching monolithically anyway is an invalid dispatch: split, or do it yourself.
|
|
5
|
+
- SPEC: every dispatched unit carries objective, write_scope, verify_commands, acceptance, size_estimate, context_paths, rollback, dependencies — written before work starts. Missing any field is undispatchable.
|
|
6
|
+
- CHECK: verifier is not the maker. Run each unit's verify commands fresh in your own context; never accept a worker's reported output or completeness claims. A verify failure rejects the unit: record the failure, re-dispatch with the evidence.
|
|
7
|
+
- FENCE: parallel units need disjoint write scopes, confirmed by comparing write_scope declarations literally — never inferred from topic. Overlap forces serialization.
|
|
8
|
+
|
|
9
|
+
Full doctrine: skill://task-decomposition — sizing calibration, the dispatch contract, rejection rules, repair-retry. Refuse monolithic dispatches: size, specify, then dispatch or refuse.`})),s(!1,()=>new m),u);function v(e){return t(function*(){return(yield*(yield*r).load(e)).dispatch_doctrine_skills??[]})}const y=e=>c(e).pipe(l(`DeliverDoctrine`,e=>({block:!0,reason:e.reason})),l(`Allow`,()=>void 0),u);function b(e,n,r){return t(function*(){let t=new f({toolName:n,doctrineLoaded:r,gateEnabled:(yield*v(e)).length>0});return y(_(t))})}export{v as runDispatchDoctrineConfig,b as runDispatchDoctrineGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={task:!0,agent:!0},t=t=>e[t.trim().toLowerCase()]===!0,n=e=>{let t=e.slice(8);if(t.length===0)return null;let n=t.search(/[:/]/);return n===-1?t:t.slice(0,n)},r=e=>e.split(`\\`).join(`/`),i=(e,t)=>{let n=`/skills/`+t+`/SKILL.md`;return e.endsWith(n)},a=(e,t)=>{if(e.startsWith(`skill://`)){let r=n(e);return r!==null&&t.includes(r)}let a=r(e);for(let e of t)if(i(a,e))return!0;return!1},o={hasObjective:/\bobjective\b/i,hasWriteScope:/\bwrite_scope\b/i,hasVerifyCommands:/\bverify_commands\b/i},s=e=>({hasObjective:o.hasObjective.test(e),hasWriteScope:o.hasWriteScope.test(e),hasVerifyCommands:o.hasVerifyCommands.test(e)});export{t as n,a as r,s as t};
|
|
@@ -13,4 +13,4 @@ import{$c as e,$o as t,$s as n,Ao as r,As as i,Bc as a,Bs as o,Cc as s,Cr as c,D
|
|
|
13
13
|
`?e.next():e.startsWith(`\r
|
|
14
14
|
`)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),Q(t.join(``))}const Fv=/(?:true|false)\b/y;function Iv(e){e.skipWhitespaces();let t=e.match(Fv);if(!t)return $();let n=t[0];return e.next(n.length),Q(n===`true`)}const Lv=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),Rv=/[+-]?inf\b/y;function zv(e){e.skipWhitespaces();let t=e.match(Rv);if(!t)return $();let n=t[0];return e.next(n.length),Q(Lv.get(n))}const Bv=/[+-]?nan\b/y;function Vv(e){e.skipWhitespaces();let t=e.match(Bv);if(!t)return $();let n=t[0];return e.next(n.length),Q(NaN)}const Hv=Sv(bv([kv,jv,Mv]),`.`),Uv=/0b[01]+(?:_[01]+)*\b/y;function Wv(e){e.skipWhitespaces();let t=e.match(Uv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?$():Q(r)}const Gv=/0o[0-7]+(?:_[0-7]+)*\b/y;function Kv(e){e.skipWhitespaces();let t=e.match(Gv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?$():Q(r)}const qv=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function Jv(e){e.skipWhitespaces();let t=e.match(qv)?.[0];if(!t)return $();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?$():Q(r)}const Yv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function Xv(e){e.skipWhitespaces();let t=e.match(Yv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``);return Q(parseInt(n,10))}const Zv=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function Qv(e){e.skipWhitespaces();let t=e.match(Zv)?.[0];if(!t)return $();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?$():Q(r)}const $v=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function ey(e){e.skipWhitespaces();let t=e.match($v);if(!t)return $();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!fv(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return Q(i)}const ty=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function ny(e){e.skipWhitespaces();let t=e.match(ty)?.[0];return t?(e.next(t.length),Q(t)):$()}function ry(e){if(e.skipWhitespaces(),e.char()!==`[`)return $();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=ay(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),Q(t)}function iy(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),Q({__proto__:null});let t=Ev(`{`,xv(oy,`,`),`}`)(e);if(!t.ok)return $();let n={__proto__:null};for(let e of t.body)n=av(n,e);return Q(n)}const ay=bv([Nv,Pv,jv,Mv,Iv,zv,Vv,ey,ny,Wv,Kv,Jv,Qv,Xv,ry,iy]),oy=Cv(Hv,`=`,ay);function sy(e){e.nextUntilChar();let t=wv(Tv(oy))(e);return t.ok?Q({type:`Block`,value:t.body}):$()}const cy=Ev(`[`,Hv,`]`);function ly(e){e.nextUntilChar();let t=cy(e);if(!t.ok)return $();e.nextUntilChar();let n=sy(e);return Q({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const uy=Ev(`[[`,Hv,`]]`);function dy(e){e.nextUntilChar();let t=uy(e);if(!t.ok)return $();e.nextUntilChar();let n=sy(e);return Q({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function fy(e){let t=Tv(bv([sy,dy,ly]))(e);return t.ok?Q(t.body.reduce(yv,{__proto__:null})):Q({__proto__:null})}function py(e,t){let n=e.source.slice(0,e.position).split(`
|
|
15
15
|
`);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function my(e){return t=>{let n=new pv(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(py(n,r))}catch(e){throw e instanceof Error?SyntaxError(py(n,e.message)):SyntaxError(py(n,`Invalid error type caught`))}}}function hy(e){return my(fy)(e)}const gy=Symbol.for(`@effect/platform/Error`),_y=Nm(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var vy=class extends F_(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:_y,method:K,description:gh(K),cause:gh(q_)}){[gy]=gy;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const yy=Nm(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var by=class extends F_(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:yy,module:_y,method:K,description:gh(K),syscall:gh(K),pathOrDescriptor:gh(Jm(K,q)),cause:gh(q_)}){[gy]=gy;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const xy=Lt(`@effect/platform/FileSystem`),Sy=e=>typeof e==`bigint`?e:BigInt(e),Cy=BigInt(1024);Cy*Cy*Cy*Cy*Cy;const wy=e=>xy.of({...e,exists:t=>C(e.access(t),wr(!0),tr(`SystemError`,e=>e.reason===`NotFound`?M(!1):Gn(e))),readFileString:(t,n)=>Er(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new vy({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>C(e.open(t,{flag:`r`}),n?.offset?pr(e=>e.seek(n.offset,`start`)):S,E(e=>Ty(e,n)),rv),sink:(t,n)=>C(e.open(t,{flag:`w`,...n}),E(e=>Z_(t=>e.writeAll(t))),Q_),writeFileString:(t,n,r)=>D(er({try:()=>new TextEncoder().encode(n),catch:e=>new vy({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),Ty=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=Sy(64*1024)}={})=>{let i=n===void 0?void 0:Sy(n),a=Sy(r);function o(t){if(i!==void 0&&i<=t)return Hf;let n=i!==void 0&&i-t<a?i-t:a;return Vf(e.readAlloc(n),_({onNone:()=>Hf,onSome:e=>Vf(Uf(ye(e)),n=>o(t+BigInt(e.length)))}))}return ev(tv(o(BigInt(0))),{capacity:t})},Ey=Sy,Dy=xy,Oy=wy,ky=Symbol.for(`@effect/platform/FileSystem/File`),Ay=Nc(),jy=Ti(`Create`),My=Ti(`Update`),Ny=Ti(`Remove`);var Py=class extends Ze(`@effect/platform/FileSystem/WatchBackend`)(){};const Fy=Symbol.for(`@effect/platform/Path`),Iy=Lt(`@effect/platform/Path`);function Ly(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function Ry(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function zy(e){if(e.protocol!==`file:`)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return Gn(new vy({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return M(decodeURIComponent(t))}const By=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=Ly(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function Vy(e){let t=new URL(`file://`),n=By(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=qy(n),M(t)}const Hy=/%/g,Uy=/\\/g,Wy=/\n/g,Gy=/\r/g,Ky=/\t/g;function qy(e){return e.includes(`%`)&&(e=e.replace(Hy,`%25`)),e.includes(`\\`)&&(e=e.replace(Uy,`%5C`)),e.includes(`
|
|
16
|
-
`)&&(e=e.replace(Wy,`%0A`)),e.includes(`\r`)&&(e=e.replace(Gy,`%0D`)),e.includes(` `)&&(e=e.replace(Ky,`%09`)),e}const Jy=Iy.of({[Fy]:Fy,resolve:By,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Ly(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:Jy.normalize(e)},relative(e,t){if(e===t||(e=Jy.resolve(e),t=Jy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Ry(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:zy,toFileUrl:Vy,toNamespacedPath:S}),Yy=Ic(Iy,Jy),Xy=Iy,Zy=Yy,Qy=wh({key:K,value:nh(K)}).pipe(Eh(`TomlConfig`)),$y=X(K,Om(Qy),{strict:!0,decode:e=>_p({try:()=>hy(e),catch:e=>new cp(e,`TOML parse error`)}).pipe(bp(e=>Mp(Qy)(e))),encode:(e,t,n)=>gp(new fp(n,e,`TomlConfigFromText is decode-only`))}),eb=e=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]=r;return t},tb=`systemfsoftware.toml`,nb=Pp(Qy)({}),rb=(e,t,n)=>e.exists(n).pipe(D(t=>t?e.readFileString(n).pipe(D(km($y)),vr(()=>M(nb))):M(nb)));var ib=class extends Ze(`TomlLoader`)(){};const ab=(e=>Pc(ib,un(function*(){let t=yield*sr(nr()),n=yield*Dy,r=yield*Xy,i=r.join(e,`.omp`,tb);return ib.of({load:Nn(`TomlLoader.load`)(function*(e){let a=ar(yield*lr(t),e);if(bt(a))return a.value;let o=r.join(e,tb),s=r.join(e,`systemfsoftware.local.toml`),c=yield*rb(n,r,i),l=yield*rb(n,r,o),u=yield*rb(n,r,s),d=Pp(Qy)(eb([c,l,u]));return yield*Yr(t,t=>(Or(t,e,d),t)),d})})})))(Ci.homedir());Ip(nh(J({old_text:gh(Hm),new_text:gh(Hm)}).pipe(Y(e=>`old_text`in e||`new_text`in e))).pipe(o_(1))),Ip(nh(J({old_string:gh(Hm),new_string:gh(Hm)}).pipe(Y(e=>`old_string`in e||`new_string`in e)))),jp(wh({key:K,value:Hm}));export{
|
|
16
|
+
`)&&(e=e.replace(Wy,`%0A`)),e.includes(`\r`)&&(e=e.replace(Gy,`%0D`)),e.includes(` `)&&(e=e.replace(Ky,`%09`)),e}const Jy=Iy.of({[Fy]:Fy,resolve:By,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Ly(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:Jy.normalize(e)},relative(e,t){if(e===t||(e=Jy.resolve(e),t=Jy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Ry(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:zy,toFileUrl:Vy,toNamespacedPath:S}),Yy=Ic(Iy,Jy),Xy=Iy,Zy=Yy,Qy=wh({key:K,value:nh(K)}).pipe(Eh(`TomlConfig`)),$y=X(K,Om(Qy),{strict:!0,decode:e=>_p({try:()=>hy(e),catch:e=>new cp(e,`TOML parse error`)}).pipe(bp(e=>Mp(Qy)(e))),encode:(e,t,n)=>gp(new fp(n,e,`TomlConfigFromText is decode-only`))}),eb=e=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]=r;return t},tb=`systemfsoftware.toml`,nb=Pp(Qy)({}),rb=(e,t,n)=>e.exists(n).pipe(D(t=>t?e.readFileString(n).pipe(D(km($y)),vr(()=>M(nb))):M(nb)));var ib=class extends Ze(`TomlLoader`)(){};const ab=(e=>Pc(ib,un(function*(){let t=yield*sr(nr()),n=yield*Dy,r=yield*Xy,i=r.join(e,`.omp`,tb);return ib.of({load:Nn(`TomlLoader.load`)(function*(e){let a=ar(yield*lr(t),e);if(bt(a))return a.value;let o=r.join(e,tb),s=r.join(e,`systemfsoftware.local.toml`),c=yield*rb(n,r,i),l=yield*rb(n,r,o),u=yield*rb(n,r,s),d=Pp(Qy)(eb([c,l,u]));return yield*Yr(t,t=>(Or(t,e,d),t)),d})})})))(Ci.homedir());Ip(nh(J({old_text:gh(Hm),new_text:gh(Hm)}).pipe(Y(e=>`old_text`in e||`new_text`in e))).pipe(o_(1))),Ip(nh(J({old_string:gh(Hm),new_string:gh(Hm)}).pipe(Y(e=>`old_string`in e||`new_string`in e)))),jp(wh({key:K,value:Hm}));export{P_ as C,Fc as D,Pc as E,Lc as O,J as S,Bh as T,nh as _,Dy as a,wh as b,Py as c,My as d,Oy as f,nv as g,$_ as h,Ay as i,jy as l,by as m,ab as n,ky as o,vy as p,Zy as r,Ey as s,ib as t,Ny as u,Gm as v,Jm as w,K as x,Nm as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime-
|
|
1
|
+
const e=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime-CjkNu9Ct.js`).then(e=>e.default),import(`./Cause-CTmrUQgG.js`).then(e=>e.t),import(`./Effect-BcYkmFCx.js`).then(e=>e.t),import(`./Exit-Dq5mS6lc.js`).then(e=>e.t)]),a=e.pipe(r.exit),o=await t.runPromise(a);if(i.isFailure(o))throw n.squash(o.cause);return o.value};export{e as runSafe};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
`)
|
|
3
|
-
|
|
1
|
+
import{r as e,t}from"./dispatch-doctrine.kernel-DONLJscd.js";const n=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)},r=new Map,i=new Map,a=new Map,o=new Map,s=e=>{let t=e.sessionManager.getSessionId();return typeof t==`string`?t:``},c=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},l=(e,...t)=>{for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``},u=(e,t)=>{if(e!==``){if(r.has(e)){r.set(e,!0);return}if(r.size<50){r.set(e,!0);return}for(let n of r.keys())if(n!==t){r.delete(n),r.set(e,!0);return}r.set(e,!0)}},d=(e,t)=>{if(i.size>=200){let e=i.keys().next().value;typeof e==`string`&&i.delete(e)}i.set(e,t)},f=e=>{let t=Promise.all([import(`./helpers-CWrsZEwX.js`),import(`./dispatch-doctrine.executor-DxH6nyYK.js`)]).then(([{runSafe:t},{runDispatchDoctrineConfig:n}])=>t(n(e))).then(t=>{a.set(e,t)}).catch(()=>{a.set(e,[])}).finally(()=>{o.get(e)===t&&o.delete(e)});return o.set(e,t),t},p=(e,t,n)=>{if(e!==void 0)try{let r=e.info;typeof r==`function`&&r.call(e,t,n)}catch{}},m=e=>e===null?1:e.length,h=e=>{let t=l(e,`task`,`description`,`prompt`),n=e.tasks;if(!Array.isArray(n))return t;let r=n.map(e=>typeof e==`string`?e:l(c(e),`task`,`description`,`prompt`)).filter(e=>e.length>0).join(`
|
|
2
|
+
`);return t.length===0?r:t+`
|
|
3
|
+
`+r},g=e=>{let t=e.tasks;return Array.isArray(t)?t:null},_=n=>{n.on(`tool_call`,async(e,i)=>{let{runSafe:o}=await import(`./helpers-CWrsZEwX.js`),{runDispatchDoctrineConfig:l,runDispatchDoctrineGate:d}=await import(`./dispatch-doctrine.executor-DxH6nyYK.js`),f=s(i),_=c(e.input),v=f===``?!1:r.get(f)??!1,y=await o(l(i.cwd));a.set(i.cwd,y);let b=await o(d(i.cwd,e.toolName,v)),x=m(g(_)),S=t(h(_));if(b!==void 0)return u(f,f),p(n.logger,`agent_discipline.dispatch.blocked`,{plugin:`agent_discipline`,session_id:f,tool:e.toolName,reason:`kernel_delivered`,batch_size:x,has_objective:S.hasObjective,has_write_scope:S.hasWriteScope,has_verify_commands:S.hasVerifyCommands}),{block:!0,reason:b.reason};p(n.logger,`agent_discipline.dispatch.observed`,{plugin:`agent_discipline`,session_id:f,tool:e.toolName,batch_size:x,has_objective:S.hasObjective,has_write_scope:S.hasWriteScope,has_verify_commands:S.hasVerifyCommands})}),n.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`read`)return;let n=e.toolCallId;if(typeof n!=`string`||n.length===0)return;let r=c(e.args).path;typeof r==`string`&&(d(n,r),a.has(t.cwd)||f(t.cwd))}),n.on(`tool_execution_end`,async(t,r)=>{if(t.toolName!==`read`)return;let c=t.toolCallId;if(typeof c!=`string`||c.length===0)return;let l=i.get(c);if(i.delete(c),l===void 0||t.isError)return;let d=o.get(r.cwd);d!==void 0&&await d;let f=a.get(r.cwd);if(f===void 0||!e(l,f))return;let m=s(r);m!==``&&(u(m,m),p(n.logger,`agent_discipline.doctrine.loaded`,{plugin:`agent_discipline`,session_id:m,tool:t.toolName}))}),n.on(`session_start`,(e,t)=>{f(t.cwd)})};function v(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``}function y(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}const b=e=>{e.on(`tool_call`,async(e,t)=>{let{runSafe:n}=await import(`./helpers-CWrsZEwX.js`),{runNoSkillDelegation:r}=await import(`./no-skill-delegation.executor-BGERu8rH.js`),{Effect:i}=await import(`./esm-CHBBXVaA.js`).then(e=>e.t);return n(i.gen(function*(){let n=y(e.input),i=v(n,`subagent_type`,`agent`),a=v(n,`prompt`,`task`,`description`);return yield*r(t.cwd,e.toolName,i,a)}))})},x=/Tool ([A-Za-z0-9_:-]+) not found/i,S=new Map;function C(e){return typeof e==`object`&&!!e&&`text`in e&&typeof e.text==`string`}function w(e){if(typeof e!=`object`||!e||!(`content`in e))return``;let t=e.content;return Array.isArray(t)?t.filter(C).map(e=>e.text).join(`
|
|
4
|
+
`):``}function T(e){return[``,`---`,`### ⚠️ Unresolved Tool Calls`,``,"The following xd:// tools were not found but have NOT yet been retried via `write` to `xd://`:",``,...e.map((e,t)=>`${t+1}. **\`${e.tool}\`** — failed ${e.failures} time${e.failures>1?`s`:``}. Your first attempt to use \`${e.tool}\` returned \`Tool not found\`. Write to \`xd://${e.tool}\` (JSON args) to retry — do NOT concede the tool is unavailable.`),``,"Each unresolved entry will repeat here until you retry by writing to the `xd://` device.",`---`].join(`
|
|
5
|
+
`)}const E=e=>{e.on(`tool_execution_end`,(e,t)=>{if(!e.isError)return;let n=x.exec(w(e.result));if(!n)return;let r=n[1];if(r===void 0)return;let i=S.get(r);if(i)i.failures+=1;else{if(S.size>=50){let e=S.keys().next().value;e!==void 0&&S.delete(e)}S.set(r,{tool:r,failures:1,remindedAtFailure:0})}}),e.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`write`||typeof e.args!=`object`||e.args===null||!(`path`in e.args))return;let n=e.args.path;if(typeof n!=`string`||!n.startsWith(`xd://`))return;let r=n.slice(5).split(/[/?#]/)[0];r!==void 0&&r.length!==0&&S.delete(r)}),e.on(`context`,e=>{if(S.size===0)return;let t=[...S.values()].filter(e=>e.failures>e.remindedAtFailure);if(t.length===0)return;let n=T(t);for(let e of t)e.remindedAtFailure=e.failures;return{messages:[...e.messages,{role:`user`,content:[{type:`text`,text:n}],timestamp:Date.now()}]}})};function D(e){_(e),b(e),E(e),n(t=>e.on(`session_start`,(e,n)=>t(n)),()=>import(`./runtime-CjkNu9Ct.js`))}export{D as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Cs as e,Ms as t,Ps as n}from"./core-CwsVf2Ey.js";import{D as r}from"./Effect-BcYkmFCx.js";import{C as i,S as a,T as o,_ as s,b as c,t as l,w as u,x as d,y as f}from"./dist-Cu2Bufzb.js";import{a as p,i as m,n as h,r as g,t as _}from"./Match-COXzoyjd.js";const v=f(`subagent_type`,`prompt`),y=Symbol.for(`@systemfsoftware/omp-agent-discipline/DelegationVerdict`);var b=class extends i()(`Allow`,{}){[y]=y},x=class extends i()(`Block`,{reason:d,how:v,skill:d}){[y]=y};u(b,x);const S=a({protectedSkills:s(d),delegationVerbs:s(d),referenceVerbs:s(d),mentionPatterns:c({key:d,value:d})}).pipe(o({arbitrary:()=>e=>e.constant({protectedSkills:[`ce-work`],delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?ce-work\\b","\\buse\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bcall\\s+(?:the\\s+)?[`/]?ce-work\\b","\\brun\\s+(?:the\\s+)?[`/]?ce-work\\b"],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bread\\s+(?:the\\s+)?[`/]?ce-work\\b"],mentionPatterns:{"ce-work":'(?:^|[\\s/.`"])ce-work(?=$|[\\s/.`"]|\\b)'}})})),C=u(S,f(null)),w=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDelegationCommand`);var T=class extends i()(`CheckDelegationCommand`,{toolName:d,subagentType:d,prompt:d,guard:C}){[w]=w};const E=Symbol.for(`@systemfsoftware/omp-agent-discipline/ClassifiedInput`);var D=class extends i()(`NoGuard`,{}){[E]=E},O=class extends i()(`NonDelegatedTool`,{}){[E]=E},k=class extends i()(`ProtectedSubagent`,{skill:d}){[E]=E},A=class extends i()(`EmptyPrompt`,{}){[E]=E},j=class extends i()(`Prompted`,{guard:S,prompt:d}){[E]=E};u(D,O,k,A,j);const M=Symbol.for(`@systemfsoftware/omp-agent-discipline/PromptAnalysis`);var N=class extends i()(`Delegated`,{skill:d,excerpt:d}){[M]=M},P=class extends i()(`Referenced`,{}){[M]=M},F=class extends i()(`NoDelegation`,{}){[M]=M};u(N,P,F);function I(e,t,n){return[`⛔ BLOCKED: "`+e+`" must not be delegated to a subagent.`,`Detected in `+t+`: `+n,``,`REQUIRED: invoke `+e+` directly in THIS session via the host Skill / Tool call,`,`then pass its return envelope to the next step. Do NOT wrap it in a task / Agent dispatch.`,``,`WHY: a subagent reproduces the shape but loses the skill protocol — plan-path gate,`,`headless review contract, and pipeline-vs-chat mode. The contract does not survive the hop.`,``,`RULE: root AGENTS.md §"Skill invocations" (SK1/SK2).`].join(`
|
|
2
|
+
`)}function L(e,t){return new RegExp(e,`i`).test(t)}function R(e,t){return e.map(e=>new RegExp(e,`i`).exec(t)).find(e=>e!==null)??null}const z=e=>t(e=>e!==``)(e),B=(e,t)=>m(z(e.prompt)).pipe(g(`Some`,({value:e})=>new j({guard:t,prompt:e})),g(`None`,()=>new A),_),V=(e,n)=>t(e=>e!==``&&n.protectedSkills.includes(e))(e.subagentType),H=(e,t)=>m(V(e,t)).pipe(g(`Some`,({value:e})=>new k({skill:e})),g(`None`,()=>B(e,t)),_),U=t=>e(t.guard),W=(e,r)=>t(e=>e===`task`||e===`agent`)(e.toolName.toLowerCase()).pipe(n(()=>H(e,r))),G=e=>m(U(e)).pipe(g(`None`,()=>new D),g(`Some`,({value:t})=>m(W(e,t)).pipe(g(`None`,()=>new O),g(`Some`,({value:e})=>e),_)),_),K=(e,n)=>{let r=Object.entries(e.mentionPatterns).filter(([,e])=>L(e,n)).map(([e])=>e);return t(e=>e.length>0)(r)},q=(e,t)=>m(K(e,t)).pipe(g(`None`,()=>new F),g(`Some`,({value:n})=>{let r=n[0];return m({hasReference:e.referenceVerbs.some(e=>L(e,t)),hasDelegation:e.delegationVerbs.some(e=>L(e,t))}).pipe(p({hasReference:!0},()=>new P),p({hasDelegation:!1},()=>new F),h(()=>{let n=R(e.delegationVerbs,t),i=n===null?t.slice(0,120):n[0];return new N({skill:r,excerpt:i})}))}),_),J=e=>m(G(e)).pipe(g(`NoGuard`,()=>new b),g(`NonDelegatedTool`,()=>new b),g(`ProtectedSubagent`,({skill:e})=>new x({reason:I(e,`subagent_type`,e),how:`subagent_type`,skill:e})),g(`EmptyPrompt`,()=>new b),g(`Prompted`,({guard:e,prompt:t})=>m(q(e,t)).pipe(g(`Delegated`,({skill:e,excerpt:t})=>new x({reason:I(e,`prompt`,t),how:`prompt`,skill:e})),g(`Referenced`,()=>new b),g(`NoDelegation`,()=>new b),_)),_);function Y(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function X(e){if(e.length===0)return null;let t=`(?:`+e.map(Y).join(`|`)+`)`;return{protectedSkills:e.slice(),delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?"+t+`\\b`,"\\bwrap\\s+(?:the\\s+)?[`/]?"+t+`\\s+in\\s+(?:a\\s+)?(?:task|agent|subagent)\\b`,"\\bdelegate\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\brun\\s+(?:the\\s+)?[`/]?"+t+`\\s+(?:via|in)\\s+(?:a\\s+)?(?:subagent|task|agent)\\b`,"\\b(?:run|execute|launch)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bskill:\\s*[`/]?"+t+`\\b`,`\\bskill:\\/\\/`+t+`\\b`,`(?:^|\\W)/`+t+`(?=$|\\b|\\W)`,"\\buse\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bload\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcall\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bsend\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcreate\\s+(?:a\\s+)?(?:task|agent|subagent)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bstart\\s+(?:the\\s+)?[`/]?"+t+`\\b`],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bper\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bread\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\baccording\\s+to\\s+(?:the\\s+)?[`/]?"+t+`\\b`],mentionPatterns:Object.fromEntries(e.map(e=>[e,'(?:^|[\\s/.`"])'+Y(e)+'(?=$|[\\s/.`"]|\\b)']))}}function Z(e){return m(e).pipe(g(`Block`,e=>({block:!0,reason:e.reason,how:e.how,skill:e.skill})),g(`Allow`,()=>void 0),_)}function Q(e){return r(function*(){return X((yield*(yield*l).load(e)).no_delegate_skills??[])})}function $(e,t,n,i){return r(function*(){return Z(J(new T({toolName:t,subagentType:n,prompt:i,guard:yield*Q(e)})))})}export{$ as runNoSkillDelegation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as te,zs as f}from"./core-CwsVf2Ey.js";import{B as ne,Bt as re,Gt as ie,H as p,Ht as m,Jt as h,Kt as ae,Lt as oe,P as g,Q as se,Rt as ce,Sn as _,Ut as v,Vt as y,Wt as b,Xt as le,Yt as ue,_ as x,an as de,b as S,c as C,dt as fe,et as pe,f as me,it as he,mn as ge,mt as _e,n as w,nn as T,nt as E,on as ve,qt as ye,r as D,rt as O,st as k,tt as A,un as j,zt as M}from"./Effect-BcYkmFCx.js";import{D as N,E as P,O as F,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-Cu2Bufzb.js";import*as je from"node:os";import*as Me from"node:crypto";import*as B from"node:path";import*as V from"node:fs";function H(e,t){return l(e.runtimeEffect,e=>i(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,s(t,e.context))))}const Ne={..._,[T]:T,pipe(){return a(this,arguments)},commit(){return this.runtimeEffect}},Pe=(e,n)=>{n??=ce();let i=h(j()),a,o=u(()=>{if(!a){let r=new ge;a=y(t(ve(oe(e,n),i),e=>{s.cachedRuntime=e}),{scope:i,scheduler:r}),r.flush()}return te(a.await)}),s=Object.assign(Object.create(Ne),{memoMap:n,scope:i,runtimeEffect:o,cachedRuntime:void 0,runtime(){return s.cachedRuntime===void 0?b(s.runtimeEffect):Promise.resolve(s.cachedRuntime)},dispose(){return b(s.disposeEffect)},disposeEffect:u(()=>(s.runtimeEffect=c(`ManagedRuntime disposed`),s.cachedRuntime=void 0,de(s.scope,r))),runFork(e,t){return s.cachedRuntime===void 0?y(H(s,e),t):re(s.cachedRuntime)(e,t)},runSyncExit(e){return s.cachedRuntime===void 0?le(H(s,e)):ue(s.cachedRuntime)(e)},runSync(e){return s.cachedRuntime===void 0?h(H(s,e)):ye(s.cachedRuntime)(e)},runPromiseExit(e,t){return s.cachedRuntime===void 0?ae(H(s,e),t):ie(s.cachedRuntime)(e,t)},runCallback(e,t){return s.cachedRuntime===void 0?m(M)(H(s,e),t):m(s.cachedRuntime)(e,t)},runPromise(e,t){return s.cachedRuntime===void 0?b(H(s,e),t):v(s.cachedRuntime)(e,t)}});return s},U=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},W=(e,t,n)=>(...r)=>C(i=>{try{e(...r,(e,n)=>{i(e?x(t?t(e,r):e):A(n))})}catch(e){i(n?x(n(e,r)):me(e))}}),G=e=>t=>new ke({module:`FileSystem`,method:e,cause:t}),Fe=(()=>{let e=W(V.access,U(`FileSystem`,`access`),G(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ie=(()=>{let e=W(V.cp,U(`FileSystem`,`copy`),G(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Le=(()=>{let e=W(V.copyFile,U(`FileSystem`,`copyFile`),G(`copyFile`));return(t,n)=>e(t,n)})(),Re=(()=>{let e=W(V.chmod,U(`FileSystem`,`chmod`),G(`chmod`));return(t,n)=>e(t,n)})(),ze=(()=>{let e=W(V.chown,U(`FileSystem`,`chown`),G(`chown`));return(t,n,r)=>e(t,n,r)})(),Be=(()=>{let e=W(V.link,U(`FileSystem`,`link`),G(`link`));return(t,n)=>e(t,n)})(),Ve=(()=>{let e=W(V.mkdir,U(`FileSystem`,`makeDirectory`),G(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),K=e=>{let t=W(V.mkdtemp,U(`FileSystem`,e),G(e));return e=>E(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):je.tmpdir();return t(n?B.join(r,n):r+`/`)})},He=K(`makeTempDirectory`),q=e=>{let t=W(V.rm,U(`FileSystem`,e),G(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Ue=q(`remove`),We=(()=>{let e=K(`makeTempDirectoryScoped`),t=q(`makeTempDirectoryScoped`);return n=>D(e(n),e=>p(t(e,{recursive:!0})))})(),J=e=>{let t=W(V.open,U(`FileSystem`,e),G(e)),n=W(V.close,U(`FileSystem`,e),G(e));return(e,r)=>d(D(t(e,r?.flag??`r`,r?.mode),e=>p(n(e))),g(e=>Ke(Ee(e),r?.flag?.startsWith(`a`)??!1)))},Ge=J(`open`),Ke=(()=>{let e=e=>W(V.read,U(`FileSystem`,e),G(e)),t=e(`read`),r=e(`readAlloc`),i=W(V.fstat,U(`FileSystem`,`stat`),G(`stat`)),a=W(V.ftruncate,U(`FileSystem`,`truncate`),G(`truncate`)),o=W(V.fsync,U(`FileSystem`,`sync`),G(`sync`)),s=e=>W(V.write,U(`FileSystem`,e),G(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[L];semaphore=fe(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[L]=L}get stat(){return g(i(this.fd),Z)}get sync(){return o(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(O(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(g(E(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(S(O(()=>Buffer.allocUnsafeSlow(t)),e=>g(r(this.fd,{buffer:e,position:this.position}),r=>{if(r===0)return n();if(this.position+=BigInt(r),r===t)return f(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),f(i)})))}truncate(e){return this.semaphore.withPermits(1)(g(a(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(g(E(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return S(E(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?x(new I({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):w))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),Y=e=>{let t=K(e),n=J(e),r=e=>O(()=>Me.randomBytes(e).toString(`hex`));return e=>d(_e(t(e),r(6)),g(([t,n])=>B.join(t,n+(e?.suffix??``))),he(e=>se(n(e,{flag:`w+`}))))},qe=Y(`makeTempFile`),Je=(()=>{let e=Y(`makeTempFileScoped`),t=q(`makeTempFileScoped`);return n=>D(e(n),e=>p(t(B.dirname(e),{recursive:!0})))})(),Ye=(e,t)=>k({try:()=>V.promises.readdir(e,t),catch:t=>U(`FileSystem`,`readDirectory`)(t,[e])}),Xe=e=>C((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?x(U(`FileSystem`,`readFile`)(n,[e])):A(r))})}catch(e){t(x(G(`readFile`)(e)))}}),Ze=(()=>{let e=W(V.readlink,U(`FileSystem`,`readLink`),G(`readLink`));return t=>e(t)})(),X=(()=>{let e=W(V.realpath,U(`FileSystem`,`realPath`),G(`realPath`));return t=>e(t)})(),Qe=(()=>{let e=W(V.rename,U(`FileSystem`,`rename`),G(`rename`));return(t,n)=>e(t,n)})(),Z=t=>({type:t.isFile()?`File`:t.isDirectory()?`Directory`:t.isSymbolicLink()?`SymbolicLink`:t.isBlockDevice()?`BlockDevice`:t.isCharacterDevice()?`CharacterDevice`:t.isFIFO()?`FIFO`:t.isSocket()?`Socket`:`Unknown`,mtime:e(t.mtime),atime:e(t.atime),birthtime:e(t.birthtime),dev:t.dev,rdev:e(t.rdev),ino:e(t.ino),mode:t.mode,nlink:e(t.nlink),uid:e(t.uid),gid:e(t.gid),size:z(t.size),blksize:e(z(t.blksize)),blocks:e(t.blocks)}),Q=(()=>{let e=W(V.stat,U(`FileSystem`,`stat`),G(`stat`));return t=>g(e(t),Z)})(),$e=(()=>{let e=W(V.symlink,U(`FileSystem`,`symlink`),G(`symlink`));return(t,n)=>e(t,n)})(),et=(()=>{let e=W(V.truncate,U(`FileSystem`,`truncate`),G(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),tt=(()=>{let e=W(V.utimes,U(`FileSystem`,`utime`),G(`utime`));return(t,n,r)=>e(t,n,r)})(),nt=(e,t)=>Te(n=>D(O(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(ne(Q(t),{onSuccess:e=>A(De({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?A(Ae({path:t})):x(e)}));return;case`change`:n.single(Se({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>O(()=>e.close()))),rt=(e,t,n)=>Q(t).pipe(g(r=>e.pipe(ee(e=>e.register(t,r,n)),o(()=>nt(t,n)))),we),it=(e,t,n)=>C((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?x(U(`FileSystem`,`writeFile`)(t,[e])):w)})}catch(e){r(x(G(`writeFile`)(e)))}}),$=P(be,g(pe(xe),e=>Ce({access:Fe,chmod:Re,chown:ze,copy:Ie,copyFile:Le,link:Be,makeDirectory:Ve,makeTempDirectory:He,makeTempDirectoryScoped:We,makeTempFile:qe,makeTempFileScoped:Je,open:Ge,readDirectory:Ye,readFile:Xe,readLink:Ze,realPath:X,remove:Ue,rename:Qe,stat:Q,symlink:$e,truncate:et,utimes:tt,watch(t,n){return rt(e,t,n)},writeFile:it}))),at=Pe(N($,R,Oe.pipe(F($),F(R))));export{at as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/omp-agent-discipline",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"description": "OMP agent discipline: mechanical enforcement of rules prose can't hold (xd:// retry guard, ...)",
|
|
7
7
|
"type": "module",
|
|
@@ -24,17 +24,21 @@
|
|
|
24
24
|
"@effect/platform-node": "^0.97.0",
|
|
25
25
|
"@effect/vitest": "0.30.0",
|
|
26
26
|
"@oh-my-pi/pi-coding-agent": "^17.0.5",
|
|
27
|
+
"@stryker-mutator/vitest-runner": "^9.6.1",
|
|
27
28
|
"@types/node": "^24",
|
|
28
29
|
"effect": "^3.22.0",
|
|
29
30
|
"rimraf": "^6.1.3",
|
|
30
31
|
"tsdown": "^0.22.9",
|
|
31
32
|
"typescript": "^7",
|
|
32
33
|
"vitest": "^4",
|
|
34
|
+
"@systemfsoftware/effect-memfs": "^1.0.8",
|
|
33
35
|
"@systemfsoftware/effect-gherkin-spec": "^0.4.1",
|
|
36
|
+
"@systemfsoftware/stryker-js-core": "^1.1.6",
|
|
34
37
|
"@systemfsoftware/oxlint-config": "^0.1.0",
|
|
38
|
+
"@systemfsoftware/omp-utils": "^0.0.0",
|
|
39
|
+
"@systemfsoftware/stryker-js-typescript-checker": "^1.1.6",
|
|
35
40
|
"@systemfsoftware/tsconfig": "^1.2.6",
|
|
36
|
-
"@systemfsoftware/
|
|
37
|
-
"@systemfsoftware/omp-utils": "^0.0.0"
|
|
41
|
+
"@systemfsoftware/stryker-plugins": "^0.9.0"
|
|
38
42
|
},
|
|
39
43
|
"omp": {
|
|
40
44
|
"extensions": [
|
|
@@ -62,6 +66,8 @@
|
|
|
62
66
|
"clean": "rimraf dist",
|
|
63
67
|
"typecheck": "tsc --noEmit --incremental",
|
|
64
68
|
"test": "vitest run",
|
|
65
|
-
"lint": "oxlint . ${AGENT:+--format=unix --quiet}"
|
|
69
|
+
"lint": "oxlint . ${AGENT:+--format=unix --quiet}",
|
|
70
|
+
"mutation": "stryker run --incremental",
|
|
71
|
+
"mutation:full": "stryker run"
|
|
66
72
|
}
|
|
67
73
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Cs as e,Ks as t,Ms as n,Ps as r,Qs as i,Sc as a,Us as o,vl as s}from"./core-CwsVf2Ey.js";import{D as c}from"./Effect-BcYkmFCx.js";import{C as l,S as u,_ as d,b as f,t as p,v as m,w as h,x as g,y as _}from"./dist-DIH94u3_.js";const ee={[Symbol.for(`@effect/matcher/Matcher`)]:{_input:s,_filters:s,_remaining:s,_result:s,_provided:s,_return:s},_tag:`ValueMatcher`,add(e){return this.value._tag===`Right`?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?v(this.provided,i(e.evaluate(this.provided))):this},pipe(){return a(this,arguments)}};function v(e,t){let n=Object.create(ee);return n.provided=e,n.value=t,n}const y=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),b=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(b),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,b(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},x=e=>v(e,t(e)),S=(e,t)=>n=>n.add(y(b(e),t)),C=(e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(y(i,n))})(`_tag`),w=e=>t=>{let n=T(t);return o(n)?n._tag===`Right`?n.right:e(n.left):t=>{let r=n(t);return r._tag===`Right`?r.right:e(r.left)}},T=e=>{if(e._tag===`ValueMatcher`)return e.value;let n=e.cases.length;if(n===1){let n=e.cases[0];return e=>n._tag===`When`&&n.guard(e)===!0||n._tag===`Not`&&n.guard(e)===!1?i(n.evaluate(e)):t(e)}return r=>{for(let t=0;t<n;t++){let n=e.cases[t];if(n._tag===`When`&&n.guard(r)===!0||n._tag===`Not`&&n.guard(r)===!1)return i(n.evaluate(r))}return t(r)}},E=`effect/Match/exhaustive: absurd`,D=e=>{let t=T(e);if(o(t)){if(t._tag===`Right`)return t.right;throw Error(E)}return e=>{let n=t(e);if(n._tag===`Right`)return n.right;throw Error(E)}},O=x,k=S,A=C,j=w,M=D,N=m(`subagent_type`,`prompt`),P=Symbol.for(`@systemfsoftware/omp-agent-discipline/DelegationVerdict`);var F=class extends u()(`Allow`,{}){[P]=P},I=class extends u()(`Block`,{reason:f,how:N,skill:f}){[P]=P};l(F,I);const L=g({protectedSkills:d(f),delegationVerbs:d(f),referenceVerbs:d(f),mentionPatterns:_({key:f,value:f})}).pipe(h({arbitrary:()=>e=>e.constant({protectedSkills:[`ce-work`],delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?ce-work\\b","\\buse\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bcall\\s+(?:the\\s+)?[`/]?ce-work\\b","\\brun\\s+(?:the\\s+)?[`/]?ce-work\\b"],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bread\\s+(?:the\\s+)?[`/]?ce-work\\b"],mentionPatterns:{"ce-work":'(?:^|[\\s/.`"])ce-work(?=$|[\\s/.`"]|\\b)'}})})),R=l(L,m(null)),z=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDelegationCommand`);var te=class extends u()(`CheckDelegationCommand`,{toolName:f,subagentType:f,prompt:f,guard:R}){[z]=z};const B=Symbol.for(`@systemfsoftware/omp-agent-discipline/ClassifiedInput`);var V=class extends u()(`NoGuard`,{}){[B]=B},H=class extends u()(`NonDelegatedTool`,{}){[B]=B},U=class extends u()(`ProtectedSubagent`,{skill:f}){[B]=B},W=class extends u()(`EmptyPrompt`,{}){[B]=B},G=class extends u()(`Prompted`,{guard:L,prompt:f}){[B]=B};l(V,H,U,W,G);const K=Symbol.for(`@systemfsoftware/omp-agent-discipline/PromptAnalysis`);var q=class extends u()(`Delegated`,{skill:f,excerpt:f}){[K]=K},J=class extends u()(`Referenced`,{}){[K]=K},Y=class extends u()(`NoDelegation`,{}){[K]=K};l(q,J,Y);function X(e,t,n){return[`⛔ BLOCKED: "`+e+`" must not be delegated to a subagent.`,`Detected in `+t+`: `+n,``,`REQUIRED: invoke `+e+` directly in THIS session via the host Skill / Tool call,`,`then pass its return envelope to the next step. Do NOT wrap it in a task / Agent dispatch.`,``,`WHY: a subagent reproduces the shape but loses the skill protocol — plan-path gate,`,`headless review contract, and pipeline-vs-chat mode. The contract does not survive the hop.`,``,`RULE: root AGENTS.md §"Skill invocations" (SK1/SK2).`].join(`
|
|
2
|
-
`)}function Z(e,t){return new RegExp(e,`i`).test(t)}function ne(e,t){return e.map(e=>new RegExp(e,`i`).exec(t)).find(e=>e!==null)??null}const re=e=>n(e=>e!==``)(e),ie=(e,t)=>O(re(e.prompt)).pipe(A(`Some`,({value:e})=>new G({guard:t,prompt:e})),A(`None`,()=>new W),M),ae=(e,t)=>n(e=>e!==``&&t.protectedSkills.includes(e))(e.subagentType),oe=(e,t)=>O(ae(e,t)).pipe(A(`Some`,({value:e})=>new U({skill:e})),A(`None`,()=>ie(e,t)),M),se=t=>e(t.guard),Q=(e,t)=>n(e=>e===`task`||e===`agent`)(e.toolName.toLowerCase()).pipe(r(()=>oe(e,t))),ce=e=>O(se(e)).pipe(A(`None`,()=>new V),A(`Some`,({value:t})=>O(Q(e,t)).pipe(A(`None`,()=>new H),A(`Some`,({value:e})=>e),M)),M),le=(e,t)=>{let r=Object.entries(e.mentionPatterns).filter(([,e])=>Z(e,t)).map(([e])=>e);return n(e=>e.length>0)(r)},ue=(e,t)=>O(le(e,t)).pipe(A(`None`,()=>new Y),A(`Some`,({value:n})=>{let r=n[0],i=e.referenceVerbs.some(e=>Z(e,t)),a=e.delegationVerbs.some(e=>Z(e,t));return O({hasReference:i,hasDelegation:a}).pipe(k({hasReference:!0},()=>new J),k({hasDelegation:!1},()=>new Y),j(()=>{let n=ne(e.delegationVerbs,t),i=n===null?t.slice(0,120):n[0];return new q({skill:r,excerpt:i})}))}),M),de=e=>O(ce(e)).pipe(A(`NoGuard`,()=>new F),A(`NonDelegatedTool`,()=>new F),A(`ProtectedSubagent`,({skill:e})=>new I({reason:X(e,`subagent_type`,e),how:`subagent_type`,skill:e})),A(`EmptyPrompt`,()=>new F),A(`Prompted`,({guard:e,prompt:t})=>O(ue(e,t)).pipe(A(`Delegated`,({skill:e,excerpt:t})=>new I({reason:X(e,`prompt`,t),how:`prompt`,skill:e})),A(`Referenced`,()=>new F),A(`NoDelegation`,()=>new F),M)),M);function $(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fe(e){if(e.length===0)return null;let t=`(?:`+e.map($).join(`|`)+`)`;return{protectedSkills:e.slice(),delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?"+t+`\\b`,"\\bwrap\\s+(?:the\\s+)?[`/]?"+t+`\\s+in\\s+(?:a\\s+)?(?:task|agent|subagent)\\b`,"\\bdelegate\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\brun\\s+(?:the\\s+)?[`/]?"+t+`\\s+(?:via|in)\\s+(?:a\\s+)?(?:subagent|task|agent)\\b`,"\\b(?:run|execute|launch)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bskill:\\s*[`/]?"+t+`\\b`,`\\bskill:\\/\\/`+t+`\\b`,`(?:^|\\W)/`+t+`(?=$|\\b|\\W)`,"\\buse\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bload\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcall\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bsend\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcreate\\s+(?:a\\s+)?(?:task|agent|subagent)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bstart\\s+(?:the\\s+)?[`/]?"+t+`\\b`],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bper\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bread\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\baccording\\s+to\\s+(?:the\\s+)?[`/]?"+t+`\\b`],mentionPatterns:Object.fromEntries(e.map(e=>[e,'(?:^|[\\s/.`"])'+$(e)+'(?=$|[\\s/.`"]|\\b)']))}}function pe(e){return O(e).pipe(A(`Block`,e=>({block:!0,reason:e.reason,how:e.how,skill:e.skill})),A(`Allow`,()=>void 0),M)}function me(e){return c(function*(){return fe((yield*(yield*p).load(e)).no_delegate_skills??[])})}function he(e,t,n,r){return c(function*(){return pe(de(new te({toolName:t,subagentType:n,prompt:r,guard:yield*me(e)})))})}export{he as runNoSkillDelegation};
|
package/dist/runtime-Dydy4g09.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as te,zs as f}from"./core-CwsVf2Ey.js";import{B as ne,Bt as re,Gt as p,H as m,Ht as h,Jt as g,Kt as ie,Lt as ae,P as _,Q as oe,Rt as se,Sn as v,Ut as y,Vt as b,Wt as x,Xt as ce,Yt as le,_ as S,an as ue,b as C,c as w,dt as de,et as fe,f as pe,it as me,mn as he,mt as ge,n as T,nn as E,nt as D,on as _e,qt as ve,r as O,rt as k,st as A,tt as j,un as M,zt as N}from"./Effect-BcYkmFCx.js";import{D as P,E as F,T as ye,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-DIH94u3_.js";import*as je from"node:os";import*as Me from"node:crypto";import*as B from"node:path";import*as V from"node:fs";function H(e,t){return l(e.runtimeEffect,e=>i(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,s(t,e.context))))}const Ne={...v,[E]:E,pipe(){return a(this,arguments)},commit(){return this.runtimeEffect}},Pe=(e,n)=>{n??=se();let i=g(M()),a,o=u(()=>{if(!a){let r=new he;a=b(t(_e(ae(e,n),i),e=>{s.cachedRuntime=e}),{scope:i,scheduler:r}),r.flush()}return te(a.await)}),s=Object.assign(Object.create(Ne),{memoMap:n,scope:i,runtimeEffect:o,cachedRuntime:void 0,runtime(){return s.cachedRuntime===void 0?x(s.runtimeEffect):Promise.resolve(s.cachedRuntime)},dispose(){return x(s.disposeEffect)},disposeEffect:u(()=>(s.runtimeEffect=c(`ManagedRuntime disposed`),s.cachedRuntime=void 0,ue(s.scope,r))),runFork(e,t){return s.cachedRuntime===void 0?b(H(s,e),t):re(s.cachedRuntime)(e,t)},runSyncExit(e){return s.cachedRuntime===void 0?ce(H(s,e)):le(s.cachedRuntime)(e)},runSync(e){return s.cachedRuntime===void 0?g(H(s,e)):ve(s.cachedRuntime)(e)},runPromiseExit(e,t){return s.cachedRuntime===void 0?ie(H(s,e),t):p(s.cachedRuntime)(e,t)},runCallback(e,t){return s.cachedRuntime===void 0?h(N)(H(s,e),t):h(s.cachedRuntime)(e,t)},runPromise(e,t){return s.cachedRuntime===void 0?x(H(s,e),t):y(s.cachedRuntime)(e,t)}});return s},U=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},W=(e,t,n)=>(...r)=>w(i=>{try{e(...r,(e,n)=>{i(e?S(t?t(e,r):e):j(n))})}catch(e){i(n?S(n(e,r)):pe(e))}}),G=e=>t=>new ke({module:`FileSystem`,method:e,cause:t}),Fe=(()=>{let e=W(V.access,U(`FileSystem`,`access`),G(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ie=(()=>{let e=W(V.cp,U(`FileSystem`,`copy`),G(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Le=(()=>{let e=W(V.copyFile,U(`FileSystem`,`copyFile`),G(`copyFile`));return(t,n)=>e(t,n)})(),Re=(()=>{let e=W(V.chmod,U(`FileSystem`,`chmod`),G(`chmod`));return(t,n)=>e(t,n)})(),ze=(()=>{let e=W(V.chown,U(`FileSystem`,`chown`),G(`chown`));return(t,n,r)=>e(t,n,r)})(),Be=(()=>{let e=W(V.link,U(`FileSystem`,`link`),G(`link`));return(t,n)=>e(t,n)})(),Ve=(()=>{let e=W(V.mkdir,U(`FileSystem`,`makeDirectory`),G(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),K=e=>{let t=W(V.mkdtemp,U(`FileSystem`,e),G(e));return e=>D(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):je.tmpdir();return t(n?B.join(r,n):r+`/`)})},He=K(`makeTempDirectory`),q=e=>{let t=W(V.rm,U(`FileSystem`,e),G(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Ue=q(`remove`),We=(()=>{let e=K(`makeTempDirectoryScoped`),t=q(`makeTempDirectoryScoped`);return n=>O(e(n),e=>m(t(e,{recursive:!0})))})(),J=e=>{let t=W(V.open,U(`FileSystem`,e),G(e)),n=W(V.close,U(`FileSystem`,e),G(e));return(e,r)=>d(O(t(e,r?.flag??`r`,r?.mode),e=>m(n(e))),_(e=>Ke(Ee(e),r?.flag?.startsWith(`a`)??!1)))},Ge=J(`open`),Ke=(()=>{let e=e=>W(V.read,U(`FileSystem`,e),G(e)),t=e(`read`),r=e(`readAlloc`),i=W(V.fstat,U(`FileSystem`,`stat`),G(`stat`)),a=W(V.ftruncate,U(`FileSystem`,`truncate`),G(`truncate`)),o=W(V.fsync,U(`FileSystem`,`sync`),G(`sync`)),s=e=>W(V.write,U(`FileSystem`,e),G(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[L];semaphore=de(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[L]=L}get stat(){return _(i(this.fd),Z)}get sync(){return o(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(k(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(_(D(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(C(k(()=>Buffer.allocUnsafeSlow(t)),e=>_(r(this.fd,{buffer:e,position:this.position}),r=>{if(r===0)return n();if(this.position+=BigInt(r),r===t)return f(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),f(i)})))}truncate(e){return this.semaphore.withPermits(1)(_(a(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(_(D(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return C(D(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?S(new I({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):T))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),Y=e=>{let t=K(e),n=J(e),r=e=>k(()=>Me.randomBytes(e).toString(`hex`));return e=>d(ge(t(e),r(6)),_(([t,n])=>B.join(t,n+(e?.suffix??``))),me(e=>oe(n(e,{flag:`w+`}))))},qe=Y(`makeTempFile`),Je=(()=>{let e=Y(`makeTempFileScoped`),t=q(`makeTempFileScoped`);return n=>O(e(n),e=>m(t(B.dirname(e),{recursive:!0})))})(),Ye=(e,t)=>A({try:()=>V.promises.readdir(e,t),catch:t=>U(`FileSystem`,`readDirectory`)(t,[e])}),Xe=e=>w((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?S(U(`FileSystem`,`readFile`)(n,[e])):j(r))})}catch(e){t(S(G(`readFile`)(e)))}}),Ze=(()=>{let e=W(V.readlink,U(`FileSystem`,`readLink`),G(`readLink`));return t=>e(t)})(),X=(()=>{let e=W(V.realpath,U(`FileSystem`,`realPath`),G(`realPath`));return t=>e(t)})(),Qe=(()=>{let e=W(V.rename,U(`FileSystem`,`rename`),G(`rename`));return(t,n)=>e(t,n)})(),Z=t=>({type:t.isFile()?`File`:t.isDirectory()?`Directory`:t.isSymbolicLink()?`SymbolicLink`:t.isBlockDevice()?`BlockDevice`:t.isCharacterDevice()?`CharacterDevice`:t.isFIFO()?`FIFO`:t.isSocket()?`Socket`:`Unknown`,mtime:e(t.mtime),atime:e(t.atime),birthtime:e(t.birthtime),dev:t.dev,rdev:e(t.rdev),ino:e(t.ino),mode:t.mode,nlink:e(t.nlink),uid:e(t.uid),gid:e(t.gid),size:z(t.size),blksize:e(z(t.blksize)),blocks:e(t.blocks)}),Q=(()=>{let e=W(V.stat,U(`FileSystem`,`stat`),G(`stat`));return t=>_(e(t),Z)})(),$e=(()=>{let e=W(V.symlink,U(`FileSystem`,`symlink`),G(`symlink`));return(t,n)=>e(t,n)})(),et=(()=>{let e=W(V.truncate,U(`FileSystem`,`truncate`),G(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),tt=(()=>{let e=W(V.utimes,U(`FileSystem`,`utime`),G(`utime`));return(t,n,r)=>e(t,n,r)})(),nt=(e,t)=>Te(n=>O(k(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(ne(Q(t),{onSuccess:e=>j(De({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?j(Ae({path:t})):S(e)}));return;case`change`:n.single(Se({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>k(()=>e.close()))),rt=(e,t,n)=>Q(t).pipe(_(r=>e.pipe(ee(e=>e.register(t,r,n)),o(()=>nt(t,n)))),we),it=(e,t,n)=>w((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?S(U(`FileSystem`,`writeFile`)(t,[e])):T)})}catch(e){r(S(G(`writeFile`)(e)))}}),$=ye(be,_(fe(xe),e=>Ce({access:Fe,chmod:Re,chown:ze,copy:Ie,copyFile:Le,link:Be,makeDirectory:Ve,makeTempDirectory:He,makeTempDirectoryScoped:We,makeTempFile:qe,makeTempFileScoped:Je,open:Ge,readDirectory:Ye,readFile:Xe,readLink:Ze,realPath:X,remove:Ue,rename:Qe,stat:Q,symlink:$e,truncate:et,utimes:tt,watch(t,n){return rt(e,t,n)},writeFile:it}))),at=Pe(F($,R,Oe.pipe(P($),P(R))));export{at as default};
|