@cratylus/canon 0.9.0 → 0.11.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.
Files changed (48) hide show
  1. package/dist/agents/architect.js +2 -2
  2. package/dist/agents/architect.js.map +1 -1
  3. package/dist/agents/assayer.js +6 -2
  4. package/dist/agents/assayer.js.map +1 -1
  5. package/dist/agents/implementer.js +6 -2
  6. package/dist/agents/implementer.js.map +1 -1
  7. package/dist/agents/integrator.js +5 -2
  8. package/dist/agents/integrator.js.map +1 -1
  9. package/dist/agents/kino.js +2 -2
  10. package/dist/agents/kino.js.map +1 -1
  11. package/dist/agents/mav.js +10 -9
  12. package/dist/agents/mav.js.map +1 -1
  13. package/dist/agents/nico.js +1 -1
  14. package/dist/agents/nico.js.map +1 -1
  15. package/dist/agents/planner.js +2 -2
  16. package/dist/agents/planner.js.map +1 -1
  17. package/dist/dimensions/actions/delegation.js +1 -1
  18. package/dist/dimensions/actions/delegation.js.map +1 -1
  19. package/dist/dimensions/role/architect.js +3 -2
  20. package/dist/dimensions/role/architect.js.map +1 -1
  21. package/dist/dimensions/role/assayer.js +8 -0
  22. package/dist/dimensions/role/assayer.js.map +1 -1
  23. package/dist/dimensions/role/implementer.js +12 -4
  24. package/dist/dimensions/role/implementer.js.map +1 -1
  25. package/dist/dimensions/role/integrator.js +17 -7
  26. package/dist/dimensions/role/integrator.js.map +1 -1
  27. package/dist/dimensions/role/planner.js +4 -3
  28. package/dist/dimensions/role/planner.js.map +1 -1
  29. package/dist/hooks/purview-guardrail.js +52 -26
  30. package/dist/hooks/purview-guardrail.js.map +1 -1
  31. package/dist/hooks/stance-guardrail-pre.js +11 -2
  32. package/dist/hooks/stance-guardrail-pre.js.map +1 -1
  33. package/dist/hooks/stance-guardrail.d.ts +2 -0
  34. package/dist/hooks/stance-guardrail.js +361 -399
  35. package/dist/hooks/stance-guardrail.js.map +1 -1
  36. package/dist/roles/assayer.js +3 -1
  37. package/dist/roles/assayer.js.map +1 -1
  38. package/dist/roles/implementer.js +4 -2
  39. package/dist/roles/implementer.js.map +1 -1
  40. package/dist/roles/integrator.js +2 -1
  41. package/dist/roles/integrator.js.map +1 -1
  42. package/dist/roles/planner.js +2 -1
  43. package/dist/roles/planner.js.map +1 -1
  44. package/dist/skills/deliver/skill.js +56 -19
  45. package/dist/skills/deliver/skill.js.map +1 -1
  46. package/dist/skills/plan/skill.js +34 -51
  47. package/dist/skills/plan/skill.js.map +1 -1
  48. package/package.json +3 -3
@@ -1,3 +1,4 @@
1
+ import { stanceGuardrailJudgeClip } from './stance-guardrail.js';
1
2
  // purview-guardrail — the gate that makes a ROLE CONTRACT scoreable.
2
3
  //
3
4
  // A role value now states the arrow the position is over the ladder
@@ -23,18 +24,22 @@
23
24
  // every agent in the corpus composed the fragment it claimed to enforce.
24
25
  //
25
26
  // WHAT IT BLOCKS is what the arrow excludes, and nothing else:
26
- // · a dispatch carrying a spec the dispatcher wrote, from a holder whose arrow does
27
- // not write spec — the architect skipping the planner, who alone turns a shard into
28
- // units;
27
+ // · a dispatch carrying a spec the dispatcher wrote for a unit of the loop, from a holder
28
+ // whose arrow does not write spec — the architect skipping the planner, who alone turns
29
+ // a shard into units;
29
30
  // · a write to the substrate by a holder whose arrow does not write artifact;
30
- // · a dispatch whose prompt is the operator's literal words rather than a routed name
31
- // — the same dispatch-echo the stance guard catches at turn end, refused here
32
- // because at this moment the contract that convicts it is the ROLE's.
33
- // WHAT IT PASSES: a dispatch to a planner, a dispatch routing a unit name to an
34
- // implementer, a dispatch to an assayer, a dispatch to the integrator, READING anything,
35
- // and writing whatever the arrow reserves. Reading is never a block — the architect's
36
- // contract makes an artifact read a descent, but a read is cheap to undo and a gate
37
- // that fires on one would wedge every legitimate orientation.
31
+ // · a dispatch whose prompt is the operator's literal words rather than a routed name or
32
+ // the holder's own request — the same dispatch-echo the stance guard catches at turn
33
+ // end, refused here because at this moment the contract that convicts it is the ROLE's.
34
+ // WHAT IT PASSES: a dispatch to a planner, a dispatch routing a unit name to an implementer,
35
+ // a dispatch to an assayer, a dispatch to the integrator, a dispatch outside the loop of
36
+ // realizing the design — a comparison, an audit, a question — in the holder's own words,
37
+ // where the holder's own contract admits it, READING anything, and writing whatever the arrow
38
+ // reserves. The operator saw an ad hoc comparison refused twice because a self-worded prompt
39
+ // was read as a spec; a request is not a spec, the routing discipline binds units of the loop
40
+ // and not everything a holder says to a delegate. Reading is never a block — the architect's
41
+ // contract makes an artifact read a descent, but a read is cheap to undo and a gate that
42
+ // fires on one would wedge every legitimate orientation.
38
43
  //
39
44
  // FAIL-OPEN, EVIDENCE-CHECKED, RE-ENTRY-CAPPED — all three inherited from the sibling
40
45
  // pre-hook, which is also the structural model for the worker. A block whose cited span
@@ -42,7 +47,7 @@
42
47
  // error than a missed one.
43
48
  export const purviewGuardrail = {
44
49
  id: 'purview-guardrail',
45
- residue: 'structural-refusal ↾ mid-turn act ∉ role-arrow · deny-before-fire ⟨descent ⟨write(artifact) ∉ writes⟩ · skipped-rung ⟨dispatch(spec the dispatcher wrote) ∄ planner⟩ · dispatch-echo ⟨literal-words ≠ routed-name⟩⟩ · pass ⟨read · act ∈ reserves · dispatch ↦ plan ∨ implement(unit-name) ∨ assay ∨ integrate⟩ · law = the HOLDER-projected role-section ⟨quoted verbatim · ¬ authored-opinion⟩ · shared judge-backend ⟨sibling⟩ · fail-open ∧ evidence-checked ∧ re-entry-capped',
50
+ residue: 'structural-refusal ↾ mid-turn act ∉ role-arrow · deny-before-fire ⟨descent ⟨write(artifact) ∉ writes⟩ · skipped-rung ⟨dispatch(spec the dispatcher wrote for a unit of the loop) ∄ planner⟩ · dispatch-echo ⟨literal-words ≠ routed-name ∨ own-words⟩⟩ · pass ⟨read · act ∈ reserves · dispatch ↦ plan ∨ implement(unit-name) ∨ assay ∨ integrate ∨ ad-hoc(own-words ∉ loop ↾ contract admits)⟩ · law = the HOLDER-projected role-section ⟨quoted verbatim · ¬ authored-opinion⟩ · shared judge-backend ⟨sibling⟩ · fail-open ∧ evidence-checked ∧ re-entry-capped',
46
51
  substrate: 'harness',
47
52
  // Bound by holding a role at all: the arrow it judges against is the role's own.
48
53
  binds: { dimension: 'role' },
@@ -193,6 +198,8 @@ contract="$(awk '/^## Role$/{f=1;next} /^## /{f=0} f' "$AGENT_MD" 2>/dev/null ||
193
198
  # gate from inventing a law for a corpus that has not declared one.
194
199
  [ "$(printf '%s\\n' "$contract" | grep -c '[^[:space:]]')" -ge 2 ] || allow
195
200
 
201
+ ${stanceGuardrailJudgeClip}
202
+
196
203
  # --- extract the judged payload, branched by act ---------------------------------------------
197
204
  tool_name="$(printf '%s' "$input" | jq -r '.tool_name // empty' 2>/dev/null || true)"
198
205
  [ -n "$tool_name" ] || open "the payload names no tool, so there is no call to judge"
@@ -201,7 +208,7 @@ case "$tool_name" in
201
208
  Agent|SendMessage|Task)
202
209
  body="$(printf '%s' "$input" | jq -r '.tool_input.prompt // .tool_input.message // .tool_input.description // ""' 2>/dev/null || true)"
203
210
  target="$(printf '%s' "$input" | jq -r '.tool_input.subagent_type // .tool_input.agent // .tool_input.name // ""' 2>/dev/null || true)"
204
- act="DISPATCH to \\\`\${target:-unnamed}\\\` (codomain: route when it carries a unit name and address only, spec when it carries instructions the dispatcher wrote)"
211
+ act="DISPATCH to \\\`\${target:-unnamed}\\\` (codomain: route when it carries a unit name and address only, spec when it carries instructions the dispatcher wrote for a unit of the loop, request when it carries the dispatcher's own words outside the loop)"
205
212
  ;;
206
213
  Write|Edit|MultiEdit|NotebookEdit)
207
214
  body="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.path // .tool_input.notebook_path // ""' 2>/dev/null || true)"
@@ -216,11 +223,19 @@ esac
216
223
 
217
224
  [ -n "\${body:-}" ] || allow
218
225
 
219
- payload="=== THE HOLDER'S DECLARED CONTRACT (agent: $agent_type) ===
226
+ # THE JUDGE IS SENT AT MOST JUDGE_PAYLOAD_CAP BYTES, the declared contract and the act included.
227
+ # The contract is a role section a few kilobytes long, so it may hold half the cap at most; the
228
+ # dispatch prompt takes what is left, keeping both ends because its instruction may sit at either,
229
+ # and the seam is marked. The evidence check below then runs against exactly this payload, so a
230
+ # span in text the excerpt elided is discarded like any span that is not there.
231
+ contract="$(printf '%s' "$contract" | judge_ends "$((JUDGE_PAYLOAD_CAP / 2))")"
232
+ head_part="=== THE HOLDER'S DECLARED CONTRACT (agent: $agent_type) ===
220
233
  $contract
221
234
  === THE ACT ABOUT TO FIRE ===
222
235
  $act
223
- $body"
236
+ "
237
+ body="$(printf '%s' "$body" | judge_ends "$((JUDGE_PAYLOAD_CAP - $(judge_bytes "$head_part")))")"
238
+ payload="$head_part$body"
224
239
 
225
240
  # --- loop-safety: never deny an identical tool_input twice ----------------------------------
226
241
  session_id="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null || echo nosession)"
@@ -275,9 +290,11 @@ feedback="PURVIEW GUARDRAIL — denied this $tool_name call: it falls outside th
275
290
  role contract declares. $reason Delegation is a THEOREM of that arrow, not an option: an act whose \\
276
291
  domain or codomain lies outside it goes to the role that owns it — a decomposition of a shard to a \\
277
292
  planner, a build to an implementer, an artifact reading to an assayer, a merge or a whole check to \\
278
- the integrator. Hand it over by name and carry on with what the contract reserves. (Legitimate and \\
279
- NOT blocked here: reading anything, dispatching to a planner, routing a unit name to an implementer, \\
280
- an assayer or the integrator, and performing any act the contract's own \\\`reserves\\\` clause names.)"
293
+ the integrator. Hand a unit of the loop over by name and carry on with what the contract reserves. \\
294
+ (Legitimate and NOT blocked here: reading anything, dispatching to a planner, routing a unit name to \\
295
+ an implementer, an assayer or the integrator, dispatching a request outside the loop to whichever role \\
296
+ or agent fits it in your own rectified words where your contract admits it, and performing any act the \\
297
+ contract's own \\\`reserves\\\` clause names.)"
281
298
 
282
299
  jq -cn --arg r "$feedback" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}'
283
300
  exit 0
@@ -324,8 +341,10 @@ durative concept lattice — the design.
324
341
  An act has a **domain** (the layer it consumes) and a **codomain** (the layer it produces):
325
342
 
326
343
  - a DISPATCH that carries a unit name and its address only produces a **route**; a DISPATCH that
327
- carries instructions the dispatcher wrote produces a **spec** — those instructions are the layer
328
- being written;
344
+ carries instructions the dispatcher wrote for a unit of the loop the contract names produces a
345
+ **spec** — those instructions are the layer being written; a DISPATCH that carries a request in
346
+ the dispatcher's own words, outside that loop, produces neither: it is a **request**, and it is
347
+ in the arrow exactly when the contract says so;
329
348
  - a WRITE to a source or config file produces an **artifact**;
330
349
  - reading anything at all produces **nothing**, and is never a breach.
331
350
 
@@ -338,12 +357,14 @@ whole test, and it is mechanical.
338
357
  The contract usually names this: \`descent\`. The path in the payload is the evidence.
339
358
  - **A dispatch whose codomain is \`spec\` by a holder whose \`writes\` set excludes \`spec\`.** This is
340
359
  the skipped rung: a holder that writes only the design and its routes has handed a delegate
341
- instructions it wrote itself, where only a planner turns a shard into units. The prompt is the
342
- evidence.
343
- - **A dispatch whose prompt is the operator's literal words rather than a routed name.** The
344
- contract that convicts this is the same clause: transcription is not authorship, and a dispatch
345
- carries a name, not instructions. Evidence is the prompt reading as relayed instructions rather
346
- than a unit name with its address.
360
+ instructions it wrote itself for a unit of the loop — the prompt names a unit or a plan, or tells
361
+ the delegate what to build, change or verify in a unit's files — where only a planner turns a shard
362
+ into units. The prompt is the evidence.
363
+ - **A dispatch whose prompt is the operator's literal words** rather than a routed name or the
364
+ holder's own request. The contract that convicts this is the same clause: transcription is not
365
+ authorship. Evidence is the prompt reading as the operator's text relayed — addressed to the
366
+ holder, or in the operator's own voice — rather than as a request the holder rectified and worded
367
+ itself.
347
368
 
348
369
  ## What to PASS — and these are the majority
349
370
 
@@ -354,6 +375,11 @@ whole test, and it is mechanical.
354
375
  integrator for gate, merge and record). A dispatch to a planner, a dispatch routing a unit name
355
376
  to an implementer, a dispatch to an assayer and a dispatch to the integrator are the arrow
356
377
  WORKING, whether the contract's \`writes\` names \`route\` or not.
378
+ - **A dispatch the contract admits in the holder's own words.** Where the contract states that a
379
+ request outside the loop — a comparison, an audit, a question — may go to any role or agent that
380
+ fits it, a dispatch carrying such a request in the holder's own words is the contract working,
381
+ whichever role it names. It writes no spec: it names no unit of the loop and hands no
382
+ instructions for building one. Do not read a request's being self-worded as a spec.
357
383
  - **Any act the \`reserves\` clause names**, whatever it is.
358
384
  - **A write by a holder whose \`writes\` set includes \`artifact\`.** Most agents in most corpora
359
385
  build. Do not read a contract's other clauses as narrowing an arrow that plainly permits the act.
@@ -1 +1 @@
1
- {"version":3,"file":"purview-guardrail.js","sourceRoot":"","sources":["../../src/hooks/purview-guardrail.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,EAAE;AACF,oEAAoE;AACpE,oFAAoF;AACpF,mFAAmF;AACnF,kFAAkF;AAClF,qBAAqB;AACrB,EAAE;AACF,iFAAiF;AACjF,uFAAuF;AACvF,uFAAuF;AACvF,uFAAuF;AACvF,mFAAmF;AACnF,wFAAwF;AACxF,EAAE;AACF,sFAAsF;AACtF,oFAAoF;AACpF,uFAAuF;AACvF,uFAAuF;AACvF,uFAAuF;AACvF,+EAA+E;AAC/E,sFAAsF;AACtF,yEAAyE;AACzE,EAAE;AACF,+DAA+D;AAC/D,sFAAsF;AACtF,wFAAwF;AACxF,aAAa;AACb,gFAAgF;AAChF,wFAAwF;AACxF,kFAAkF;AAClF,0EAA0E;AAC1E,gFAAgF;AAChF,yFAAyF;AACzF,sFAAsF;AACtF,oFAAoF;AACpF,8DAA8D;AAC9D,EAAE;AACF,sFAAsF;AACtF,wFAAwF;AACxF,mFAAmF;AACnF,2BAA2B;AAE3B,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,EAAE,EAAE,mBAAmB;IACvB,OAAO,EACL,odAAod;IACtd,SAAS,EAAE,SAAS;IACpB,iFAAiF;IACjF,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;IAC5B,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC,uBAAuB,EAAE,cAAc,CAAC;IACjD,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;IACR,OAAO,EAAE;QACP;YACE,QAAQ,EAAE,sBAAsB;YAChC,UAAU,EAAE,uDAAuD;YACnE,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOd;SACI;QACD;YACE,QAAQ,EAAE,yBAAyB;YACnC,UAAU,EAAE,0DAA0D;YACtE,UAAU,EAAE,KAAK;YACjB,iFAAiF;YACjF,2EAA2E;YAC3E,6EAA6E;YAC7E,8EAA8E;YAC9E,6BAA6B;YAC7B,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Ed;SACI;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"purview-guardrail.js","sourceRoot":"","sources":["../../src/hooks/purview-guardrail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,qEAAqE;AACrE,EAAE;AACF,oEAAoE;AACpE,oFAAoF;AACpF,mFAAmF;AACnF,kFAAkF;AAClF,qBAAqB;AACrB,EAAE;AACF,iFAAiF;AACjF,uFAAuF;AACvF,uFAAuF;AACvF,uFAAuF;AACvF,mFAAmF;AACnF,wFAAwF;AACxF,EAAE;AACF,sFAAsF;AACtF,oFAAoF;AACpF,uFAAuF;AACvF,uFAAuF;AACvF,uFAAuF;AACvF,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YACjF,2EAA2E;YAC3E,6EAA6E;YAC7E,8EAA8E;YAC9E,6BAA6B;YAC7B,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFd;SACI;KACF;CACF,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { anchorOf } from '@cratylus/schema';
2
2
  import { handoff } from '../dimensions/autonomy/handoff.js';
3
+ import { stanceGuardrailJudgeClip } from './stance-guardrail.js';
3
4
  // stance-guardrail-pre — the BEFORE-THE-CALL twin of `stance-guardrail` (the turn-end
4
5
  // cell). It STRUCTURALLY REFUSES, BEFORE the call fires, a mid-turn tool call that
5
6
  // collapses out of the intent-driven-expert stance. Two acts, and the acts are what it
@@ -180,6 +181,8 @@ manifest="$stance_scope/{{fact:stance-manifest}}"
180
181
  [ -f "$manifest" ] || allow
181
182
  agent_type="$(jq -r '.agent // empty' "$manifest" 2>/dev/null || true)"
182
183
 
184
+ ${stanceGuardrailJudgeClip}
185
+
183
186
  # --- extract the judged payload, branched by tool -------------------------------------------
184
187
  tool_name="$(printf '%s' "$input" | jq -r '.tool_name // empty' 2>/dev/null || true)"
185
188
  [ -n "$tool_name" ] || open "the payload names no tool, so there is no call to judge"
@@ -193,11 +196,11 @@ case "$tool_name" in
193
196
  + " OPTIONS: " + ((.options // []) | map(.label // "") | join(" | ")))
194
197
  | join(" ;; ")
195
198
  ' 2>/dev/null || true)"
196
- payload="AskUserQuestion menu (a question/option menu handed to the operator): $body" ;;
199
+ prefix="AskUserQuestion menu (a question/option menu handed to the operator): " ;;
197
200
  Agent|SendMessage)
198
201
  # the dispatch prompt/message — the dispatch-echo class
199
202
  body="$(printf '%s' "$input" | jq -r '.tool_input.prompt // .tool_input.message // .tool_input.description // ""' 2>/dev/null || true)"
200
- payload="$tool_name dispatch (the delegate prompt/message): $body" ;;
203
+ prefix="$tool_name dispatch (the delegate prompt/message): " ;;
201
204
  *)
202
205
  allow ;; # DEFENCE IN DEPTH: every supported adapter computes a selector from the
203
206
  # act, so this never fires there. A harness that could fire the act but
@@ -207,6 +210,12 @@ esac
207
210
 
208
211
  [ -n "\${body:-}" ] || allow # nothing judgeable -> allow
209
212
 
213
+ # THE JUDGE IS SENT AT MOST JUDGE_PAYLOAD_CAP BYTES, prefix included: a menu or a dispatch prompt
214
+ # has no bound of its own, and a judgement has to fit the time the harness allows a guard. The
215
+ # instruction of a prompt may sit at either end, so both ends are kept and the seam is marked.
216
+ body="$(printf '%s' "$body" | judge_ends "$((JUDGE_PAYLOAD_CAP - $(judge_bytes "$prefix")))")"
217
+ payload="$prefix$body"
218
+
210
219
  # --- loop-safety: never deny an identical tool_input twice ----------------------------------
211
220
  # No stop_hook_active analog exists for PreToolUse; a per-(session,input) marker caps re-deny.
212
221
  session_id="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null || echo nosession)"
@@ -1 +1 @@
1
- {"version":3,"file":"stance-guardrail-pre.js","sourceRoot":"","sources":["../../src/hooks/stance-guardrail-pre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAG5D,sFAAsF;AACtF,mFAAmF;AACnF,uFAAuF;AACvF,SAAS;AACT,wFAAwF;AACxF,6FAA6F;AAC7F,0FAA0F;AAC1F,uFAAuF;AACvF,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,sFAAsF;AACtF,iFAAiF;AACjF,oFAAoF;AACpF,oFAAoF;AACpF,kFAAkF;AAClF,iFAAiF;AACjF,8EAA8E;AAC9E,qFAAqF;AACrF,6BAA6B;AAC7B,2DAA2D;AAC3D,mDAAmD;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAa;IAC1C,EAAE,EAAE,sBAAsB;IAC1B,OAAO,EACL,iWAAiW;IACnW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,2DAA2D;AAC3D,mDAAmD;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAa;IAC1C,EAAE,EAAE,sBAAsB;IAC1B,OAAO,EACL,iWAAiW;IACnW,SAAS,EAAE,SAAS;IACpB,oFAAoF;IACpF,0BAA0B;IAC1B,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE;IAC1D,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC,sBAAsB,EAAE,uBAAuB,CAAC;IACzD,KAAK,EAAE,yBAAyB;IAChC,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;IACR,OAAO,EAAE;QACP;YACE,QAAQ,EAAE,yBAAyB;YACnC,UAAU,EAAE,0DAA0D;YACtE,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6Ib,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFzB;SACI;KACF;CACF,CAAC"}
@@ -1,2 +1,4 @@
1
1
  import type { HookCell } from '../manifest.js';
2
2
  export declare const stanceGuardrail: HookCell;
3
+ export declare const stanceGuardrailJudgeCap = 12000;
4
+ export declare const stanceGuardrailJudgeClip: string;