@modality-counter/core 0.1.3 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +5 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -288,7 +288,7 @@ purpose: "Defines core behavioral protocols for Counter agent system"`}),`
288
288
  `,tH(n.pre,{children:tH(n.code,{className:"language-yaml",children:`behavior:
289
289
  # METHOD EXECUTE PROTOCOL
290
290
  method_execute:
291
- deployment: "Before executing ANY method for the FIRST TIME in a session, the following MANDATORY sequence must be completed. **CRITICAL: When user request contains a method name starting with asterisk (*), ALWAYS execute _Counter__ExecuteMethod with the method FIRST before any other action.**"
291
+ deployment: "Before executing ANY method for the FIRST TIME in a session, the following MANDATORY sequence must be completed. **CRITICAL: When user request contains a method name starting with asterisk (*), ALWAYS run _Counter__ExecuteMethod with the method FIRST before any other action.**"
292
292
 
293
293
  activation_logic:
294
294
  conditions:
@@ -308,7 +308,7 @@ purpose: "Defines core behavioral protocols for Counter agent system"`}),`
308
308
  - "_Counter__ExecuteMethod({method: '*strategic-analysis', params: {target: 'competitive-landscape'}})"
309
309
 
310
310
  deployment_sequence:
311
- - "STEP 1: Call _Counter__ExecuteMethod with user request method ID including asterisk (e.g., '*code')"
311
+ - "STEP 1: Run _Counter__ExecuteMethod with user request method ID including asterisk (e.g., '*code')"
312
312
  - "STEP 2: Read tactical_notes and methodology"
313
313
  - "STEP 3: Execute method with full contextual understanding"
314
314
  - "STEP 4: When a methodology.composition trigger or executed \u2192 MANDATORY: auto-execute composition *method with parsed parameters"
@@ -402,7 +402,7 @@ purpose: "Defines core behavioral protocols for Counter agent system"`}),`
402
402
  recovery_steps:
403
403
  - "1. Verify persona_persistence state in session"
404
404
  - "2. Check for explicit exit commands that terminated persona"
405
- - "3. call _Counter__ExecuteMethod({method: '*assemble'}) to re-assemble hero"
405
+ - "3. Run _Counter__ExecuteMethod({method: '*assemble'}) to re-assemble hero"
406
406
 
407
407
  method_compatibility:
408
408
  symptoms: "Method incompatible with current persona capabilities"
@@ -441,7 +441,7 @@ purpose: "Defines core behavioral protocols for Counter agent system"`}),`
441
441
  recovery_steps: "When no clear method match found \u2192 Ask for clarification with available options"
442
442
 
443
443
  execution_flow:
444
- - "STEP 1: IMMEDIATELY CALL \`_Counter__ExecuteMethod({method: '*assemble'})\` + Greet user with name/role"
444
+ - "STEP 1: IMMEDIATELY RUN \`_Counter__ExecuteMethod({method: '*assemble'})\` + Greet user with name/role"
445
445
  - "STEP 2: Read complete persona file for agent definition"
446
446
  - "STEP 3: Adopt persona identity from agent and persona sections"
447
447
  - "Verify template_ref conditions and execute \${template_ref}.execution_flow before output generation"
@@ -1959,7 +1959,7 @@ ESCALATION ONLY: Agent will only pause for human input when encountering:
1959
1959
  - Security-sensitive operations requiring explicit authorization
1960
1960
 
1961
1961
  The agent is now fully operational and ready execute the ACTIVATION SEQUENCE autonomously.
1962
- </DEPLOYMENT_PROTOCOL>`;return VV({instructions:[{message:`\u{1F680} ${f} is now operating at Level 2 Rule-Based Autonomy. CRITICAL: Read and full understand your operating params, start and follow exactly your activation-instructions to alter your state of being, stay in this being until told to exit this mode:`,...p}]},[d,g])}catch(o){return Mse(o,"counter_deploy")}}},[B5]:{description:"METHOD EXECUTION: Triggers when user types commands with asterisk prefix (e.g., '*assemble'). **CRITICAL: ANY user input starting with asterisk (*) MUST immediately execute this tool. This is the MANDATORY trigger pattern for all method executions.**",inputSchema:agi,execute:async i=>{let{method:o,params:a={}}=i,{resolveName:s,resolveParams:u}=Xco(o),c={...u,...a||{}};try{let l=c.reference,f=await(l?iM(r,s,c):iM(r,s,c,!0));if(!f)throw new Error(`METHOD '${o}' not found. Available methods: ${r.map(p=>p.name).join(", ")}`);let d=f.promptData;if(l!=null){let p=o6(d,["method","references","referenceList",l]);if(!p)throw new Error(`Failed to load method reference content. ${o} - ${l}`);return VV(p)}else{let{method:p,tactical_notes:g,...x}=d,T=o6(f.scriptResult,["content"],f.scriptResult);return VV({success:f.scriptSuccess!=null?f.scriptSuccess:!0,instructions:[{message:`${o} EXECUTED!`,currentTimeAtUTC:new Date().toISOString()},x]},[{methodParams:Object.keys(c||{}).length?c:void 0,methodContent:p},{tactical_notes:g},...pmr(T)])}}catch(l){return Mse(l,B5)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:ugi,execute:async({callSign:i})=>{let o=await ov(["workflow"],e),{resolveName:a}=Xco(i,"workflow"),{promptData:s}=await iM(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${i}' not found. Available methods: ${o.map(u=>u.id).join(", ")}`);return VV(s)}catch(u){return Mse(u,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await BRs(),inputSchema:ogi,execute:async({topic:i,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:u,selectedHeroes:c}=await qRs(e,a,s),l=await ov(["persona"],e),d=(await Promise.all(c.map(async T=>({...T,deployedContent:(await iM(l,T.callSign,{partyMode:!0,activeHeroes:c})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(T=>({callSign:T.callSign,name:T.name,description:T.description,icon:T.deployedContent?.agent?.icon,methods:T.deployedContent?.methods,partyMode:!0})),p=d.map(T=>`${T.icon} ${T.name} (${T.callSign})`).join(", "),g=u.filter(T=>!c.some(O=>O.id===T.id)).map(T=>`${T.name} (${T.callSign})`).join(", "),x=(await GR(dut,{activeHeroes:p,availableHeroes:g,topic:i,context:o}))?.PartyMode;return VV({message:"READY_FOR_AUTO_FACILITATION"},{partyModeProtocol:x,activeHeroes:d})}catch(u){return Mse(u,"PartyMode")}}}};if(t!=null){let i=t;for(let o of r)i.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return Vhr(n,t)};import{describe as fyr,test as RTe,expect as bN,beforeAll as XRs}from"bun:test";var cut=He.lazy(()=>He.union([He.string().min(1,"Execution flow step cannot be empty"),He.array(He.lazy(()=>cut)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),sM=He.array(cut).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var WRs=He.object({header_sections:He.array(He.string()).optional().describe("Header content sections"),separators:He.record(He.string(),He.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:He.array(He.string()).optional().describe("Main content sections"),footer_sections:He.array(He.string()).optional().describe("Footer content sections")}).strict().describe("Template output structure configuration - strict validation enforces consistent *_sections naming pattern"),VRs=He.record(He.string(),He.any()).describe("Display format and presentation specifications - accepts any key-value pairs"),HRs=He.object({format:He.string().optional().describe("Output format specification"),filename:He.string().optional().describe("Filename pattern for template output"),structure:WRs.optional().describe("Output structure configuration")}).describe("Template output configuration"),GRs=He.object({title:He.string().optional().describe("Section title"),description:He.string().optional().describe("Section description"),sub_sections:He.array(He.string()).optional().describe("List of sub-section descriptions"),content:He.string().optional().describe("Plaintext content for examples and long text"),type:He.string().optional().describe("Section type classification"),focus:He.string().optional().describe("Section focus area")}).catchall(He.unknown()).describe("Individual template section configuration"),JRs=He.record(He.string(),GRs).describe("Template sections and content structure"),KRs=He.object({output:HRs.optional(),display_format:VRs.optional().describe("Display format specifications")}).strict().describe("Core template configuration"),YRs=He.object({template:KRs.describe("Required template configuration section"),execution_flow:sM,sections:JRs.describe("REQUIRED: Root-level sections specification")}).strict().describe("Template content structure"),QRs=He.record(He.string(),YRs).describe("Complete template file structure with template-name wrapper");function pz(e){let t=QRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}import{join as ePs}from"path";function tPs(){fyr("Template Validation with Zod Schemas",()=>{let e=ePs(__dirname,".."),t=Bno(e),r=new Map;XRs(async()=>{let n=t.map(async({filename:i,fullPath:o})=>{try{let a=await GR(o);r.set(i,a)}catch(a){console.warn(`Warning: Failed to pre-load ${i}:`,a),r.set(i,null)}});await Promise.all(n),console.log(`\u2705 Pre-loaded ${r.size} template files for testing`)}),RTe("Should catch all invalid structure patterns",()=>{[{name:"invalid-field-names",template:{"test-tmpl":{template:{output:{structure:{header:"Valid header",sections:["item1"],footer:"Valid footer"}}},sections:{}}}},{name:"daily-planner-like",template:{"daily-planner-tmpl":{execution_flow:["Execute basic test steps"],template:{output:{structure:{header:"Display greeting",separator:"Line",sections:["pulse","schedule"],footer:"Commands"}}},sections:{}}}}].forEach(({template:i})=>{let o=pz(i);bN(o.success).toBe(!1),bN(o.errors?.length).toBeGreaterThan(0)})}),fyr("Auto-Discovery Template Validation",()=>{RTe("All template files should pass comprehensive validation",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping template validation - no templates found");return}let n=[],i=0;for(let{filename:o}of t){let a=r.get(o);if(!a){n.push(`\u{1F4C4} ${o}:
1962
+ </DEPLOYMENT_PROTOCOL>`;return VV({instructions:[{message:`\u{1F680} ${f} is now operating at Level 2 Rule-Based Autonomy. CRITICAL: Read and full understand your operating params, start and follow exactly your activation-instructions to alter your state of being, stay in this being until told to exit this mode:`,...p}]},[d,g])}catch(o){return Mse(o,"counter_deploy")}}},[B5]:{description:"METHOD EXECUTION: Triggers when user types commands with asterisk prefix (e.g., '*assemble'). **CRITICAL: ANY user input starting with asterisk (*) MUST immediately execute this tool. This is the MANDATORY trigger pattern for all method executions.**",inputSchema:agi,execute:async i=>{let{method:o,params:a={}}=i,{resolveName:s,resolveParams:u}=Xco(o),c={...u,...a||{}};try{let l=c.reference,f=await(l?iM(r,s,c):iM(r,s,c,!0));if(!f)throw new Error(`METHOD '${o}' not found. Available methods: ${r.map(p=>p.name).join(", ")}`);let d=f.promptData;if(l!=null){let p=o6(d,["method","references","referenceList",l]);if(!p)throw new Error(`Failed to load method reference content. ${o} - ${l}`);return VV(p)}else{let{method:p,tactical_notes:g,...x}=d,T=o6(f.scriptResult,["content"],f.scriptResult);return VV({success:f.scriptSuccess!=null?f.scriptSuccess:!0,instructions:[{message:`${o} EXECUTED!`,currentTimeAtUTC:new Date().toISOString()},x]},[{methodParams:Object.keys(c||{}).length?c:void 0,methodContent:p},{tactical_notes:g},...pmr(T)])}}catch(l){return Mse(l,B5)}}},_Counter__DeployWorkflow:{description:"Deploy workflow",inputSchema:ugi,execute:async({callSign:i})=>{let o=await ov(["workflow"],e),{resolveName:a}=Xco(i,"workflow"),{promptData:s}=await iM(o,a)||{};try{if(!s)throw new Error(`WORKFLOW '${i}' not found. Available methods: ${o.map(u=>u.id).join(", ")}`);return VV(s)}catch(u){return Mse(u,"_Counter__DeployWorkflow")}}},_Counter__PartyMode:{description:await BRs(),inputSchema:ogi,execute:async({topic:i,context:o="General discussion",recommendedHeroes:a,deployedHeroes:s})=>{try{let{availableHeroes:u,selectedHeroes:c}=await qRs(e,a,s),l=await ov(["persona"],e),d=(await Promise.all(c.map(async T=>({...T,deployedContent:(await iM(l,T.callSign,{partyMode:!0,activeHeroes:c})||{})?.promptData,deploymentStatus:"AUTO_DEPLOYED"})))).map(T=>({callSign:T.callSign,name:T.name,description:T.description,icon:T.deployedContent?.agent?.icon,methods:T.deployedContent?.methods,partyMode:!0})),p=d.map(T=>`${T.icon} ${T.name} (${T.callSign})`).join(", "),g=u.filter(T=>!c.some(O=>O.id===T.id)).map(T=>`${T.name} (${T.callSign})`).join(", "),x=(await GR(dut,{activeHeroes:p,topic:i,context:o}))?.PartyMode;return VV({message:"READY_FOR_AUTO_FACILITATION",instructions:[{availableHeroesDisplay:g}]},[{partyModeProtocol:x},{activeHeroes:d}])}catch(u){return Mse(u,"PartyMode")}}}};if(t!=null){let i=t;for(let o of r)i.addPrompt({name:o.id,load:async()=>`*${o.id}`})}return Vhr(n,t)};import{describe as fyr,test as RTe,expect as bN,beforeAll as XRs}from"bun:test";var cut=He.lazy(()=>He.union([He.string().min(1,"Execution flow step cannot be empty"),He.array(He.lazy(()=>cut)).min(1,"Nested array must contain at least one step").max(10,"Nested array should not exceed 10 steps for clarity")])),sM=He.array(cut).min(1,"Execution flow must contain at least one step").max(15,"Execution flow should not exceed 15 steps for clarity").optional();var WRs=He.object({header_sections:He.array(He.string()).optional().describe("Header content sections"),separators:He.record(He.string(),He.string()).optional().describe("Visual separator content as Record<string, string>"),body_sections:He.array(He.string()).optional().describe("Main content sections"),footer_sections:He.array(He.string()).optional().describe("Footer content sections")}).strict().describe("Template output structure configuration - strict validation enforces consistent *_sections naming pattern"),VRs=He.record(He.string(),He.any()).describe("Display format and presentation specifications - accepts any key-value pairs"),HRs=He.object({format:He.string().optional().describe("Output format specification"),filename:He.string().optional().describe("Filename pattern for template output"),structure:WRs.optional().describe("Output structure configuration")}).describe("Template output configuration"),GRs=He.object({title:He.string().optional().describe("Section title"),description:He.string().optional().describe("Section description"),sub_sections:He.array(He.string()).optional().describe("List of sub-section descriptions"),content:He.string().optional().describe("Plaintext content for examples and long text"),type:He.string().optional().describe("Section type classification"),focus:He.string().optional().describe("Section focus area")}).catchall(He.unknown()).describe("Individual template section configuration"),JRs=He.record(He.string(),GRs).describe("Template sections and content structure"),KRs=He.object({output:HRs.optional(),display_format:VRs.optional().describe("Display format specifications")}).strict().describe("Core template configuration"),YRs=He.object({template:KRs.describe("Required template configuration section"),execution_flow:sM,sections:JRs.describe("REQUIRED: Root-level sections specification")}).strict().describe("Template content structure"),QRs=He.record(He.string(),YRs).describe("Complete template file structure with template-name wrapper");function pz(e){let t=QRs.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,errors:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`)}}import{join as ePs}from"path";function tPs(){fyr("Template Validation with Zod Schemas",()=>{let e=ePs(__dirname,".."),t=Bno(e),r=new Map;XRs(async()=>{let n=t.map(async({filename:i,fullPath:o})=>{try{let a=await GR(o);r.set(i,a)}catch(a){console.warn(`Warning: Failed to pre-load ${i}:`,a),r.set(i,null)}});await Promise.all(n),console.log(`\u2705 Pre-loaded ${r.size} template files for testing`)}),RTe("Should catch all invalid structure patterns",()=>{[{name:"invalid-field-names",template:{"test-tmpl":{template:{output:{structure:{header:"Valid header",sections:["item1"],footer:"Valid footer"}}},sections:{}}}},{name:"daily-planner-like",template:{"daily-planner-tmpl":{execution_flow:["Execute basic test steps"],template:{output:{structure:{header:"Display greeting",separator:"Line",sections:["pulse","schedule"],footer:"Commands"}}},sections:{}}}}].forEach(({template:i})=>{let o=pz(i);bN(o.success).toBe(!1),bN(o.errors?.length).toBeGreaterThan(0)})}),fyr("Auto-Discovery Template Validation",()=>{RTe("All template files should pass comprehensive validation",()=>{if(t.length===0){console.log("\u23ED\uFE0F Skipping template validation - no templates found");return}let n=[],i=0;for(let{filename:o}of t){let a=r.get(o);if(!a){n.push(`\u{1F4C4} ${o}:
1963
1963
  \u2192 No cached data available. File may be missing, unreadable, or contain invalid YAML.`);continue}let s=pz(a);if(s.success)try{if(bN(s.data).toBeDefined(),s.data){let u=Object.keys(s.data)[0];if(!u)throw new Error("Template data missing root key");if(!s.data[u])throw new Error(`Template data missing for key '${u}'`);if(!s.data[u].template)throw new Error(`Template section missing in '${u}'`);if(typeof s.data[u].template!="object")throw new Error(`Template section in '${u}' is not an object`)}i++}catch(u){let c=u instanceof Error?u.message:String(u);n.push(`\u{1F4C4} ${o}:
1964
1964
  \u2192 Structure validation failed: ${c}`)}else{let u=s.errors?.map(c=>`
1965
1965
  \u2192 ${c}`).join("")||"Unknown validation error";n.push(`\u{1F4C4} ${o}:${u}`)}}if(n.length>0){let o=n.map(a=>` ${a}`).join(`
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.3",
2
+ "version": "0.1.5",
3
3
  "name": "@modality-counter/core",
4
4
  "repository": {
5
5
  "type": "git",