agent-afk 3.89.2 → 3.89.4

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/index.mjs CHANGED
@@ -1227,7 +1227,8 @@ Create a ship-ready summary with next steps.`,l=await a.runToResult(c);if(l.stat
1227
1227
  `))return{frontmatter:null,frontmatterFlags:null,body:t};let e=t.indexOf(`
1228
1228
  ---
1229
1229
  `,4);if(e===-1)return{frontmatter:null,frontmatterFlags:null,body:t};let n=t.slice(4,e),r=t.slice(e+5),o={},s=null,i=n.split(`
1230
- `);for(let a=0;a<i.length;a++){let c=i[a];if(!c||!c.trim()||c.trimStart().startsWith("#"))continue;if(c.startsWith("flags:")){let d=c.slice(6).trim();if(d.startsWith("[")){let u=d.match(/\[(.*?)\]/);if(u?.[1]){let p=u[1].split(",").map(f=>f.trim()).filter(f=>f.length>0);p.length>0&&(s=p.map(kc).sort())}continue}if(d===""||d==="null"){let u=[];for(let p=a+1;p<i.length;p++){let f=i[p];if(!f||!f.match(/^\s+-\s/))break;let g=f.match(/^\s+-\s+(.+)/);g?.[1]&&u.push(g[1].trim())}u.length>0&&(s=u.map(kc).sort());continue}}let l=c.match(/^([a-zA-Z][a-zA-Z0-9_-]*):\s*(.*)$/);if(l&&l[1]!==void 0&&l[2]!==void 0){let d=l[2].trim().replace(/^['"]|['"]$/g,"");d.length>0&&(o[l[1]]=d)}}return{frontmatter:o,frontmatterFlags:s,body:r}}function _c(t){let e=fo(t);return e.frontmatterFlags&&e.frontmatterFlags.length>0?e.frontmatterFlags:py(e.body)}function gy(t,e){return t.length===0||t.length>64?{valid:!1,reason:`name must be 1\u201364 characters, got ${t.length}`}:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)?t!==e?{valid:!1,reason:`name field "${t}" does not match parent directory name "${e}"`}:{valid:!0}:{valid:!1,reason:`name "${t}" does not match spec pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (only lowercase a-z0-9 and hyphens, no leading/trailing/consecutive hyphens)`}}var Ac=1024;function hy(t,e){let n=fo(t);if(!n.frontmatter)return null;let r=n.frontmatter.name,o=n.frontmatter.description,s=n.body.trim();if(!r||!o||s.length===0)return null;let i=gy(r,e);if(!i.valid)return process.stderr.write(`[afk] skipping skill ${e}: ${i.reason}
1230
+ `);for(let a=0;a<i.length;a++){let c=i[a];if(!c||!c.trim()||c.trimStart().startsWith("#"))continue;if(c.startsWith("flags:")){let d=c.slice(6).trim();if(d.startsWith("[")){let u=d.match(/\[(.*?)\]/);if(u?.[1]){let p=u[1].split(",").map(f=>f.trim()).filter(f=>f.length>0);p.length>0&&(s=p.map(kc).sort())}continue}if(d===""||d==="null"){let u=[];for(let p=a+1;p<i.length;p++){let f=i[p];if(!f||!f.match(/^\s+-\s/))break;let g=f.match(/^\s+-\s+(.+)/);g?.[1]&&u.push(g[1].trim())}u.length>0&&(s=u.map(kc).sort());continue}}let l=c.match(/^([a-zA-Z][a-zA-Z0-9_-]*):\s*(.*)$/);if(l&&l[1]!==void 0&&l[2]!==void 0){let d=l[2].trim().replace(/^['"]|['"]$/g,"");d.length>0&&(o[l[1]]=d)}}return{frontmatter:o,frontmatterFlags:s,body:r}}function _c(t){let e=fo(t);if(e.frontmatterFlags&&e.frontmatterFlags.length>0)return e.frontmatterFlags;let n=e.frontmatter?.["argument-hint"]??"";return py(`${n}
1231
+ ${e.body}`)}function gy(t,e){return t.length===0||t.length>64?{valid:!1,reason:`name must be 1\u201364 characters, got ${t.length}`}:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)?t!==e?{valid:!1,reason:`name field "${t}" does not match parent directory name "${e}"`}:{valid:!0}:{valid:!1,reason:`name "${t}" does not match spec pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (only lowercase a-z0-9 and hyphens, no leading/trailing/consecutive hyphens)`}}var Ac=1024;function hy(t,e){let n=fo(t);if(!n.frontmatter)return null;let r=n.frontmatter.name,o=n.frontmatter.description,s=n.body.trim();if(!r||!o||s.length===0)return null;let i=gy(r,e);if(!i.valid)return process.stderr.write(`[afk] skipping skill ${e}: ${i.reason}
1231
1232
  `),null;if(o.length>Ac)return process.stderr.write(`[afk] skipping skill ${e}: description exceeds ${Ac} characters (got ${o.length})
1232
1233
  `),null;let a=n.frontmatter["argument-hint"]??n.frontmatter.argumentHint,c=_c(t),l={name:r,description:o,body:s,dir:""};a&&a.length>0&&(l.argumentHint=a),c.length>0&&(l.flags=c);let d=n.frontmatter.context;return(d==="inline"||d==="fork"||d==="load")&&(l.context=d),l}function yy(t){return async(e,n,r)=>{let o=typeof e=="string"&&e.length>0?e:`Run the ${t.name} skill now, following the instructions in your system prompt.`,s=new N({parentAbortSignal:n?.abortSignal}),i=r?.callId;return await(await s.forkSubagent({parent:{sessionId:n?.sessionId,getInputStreamRef:n?.getInputStreamRef?.bind(n),abortSignal:n?.abortSignal},config:{model:"sonnet",systemPrompt:t.body,env:{SKILL_ROOT:t.dir},isSkillDispatch:!0},idPrefix:`user-skill-${t.name}`,...i?{parentId:i}:{}})).runToResult(o)}}function by(t,e){try{return ye(t).origin===e?t:`${e}:${t}`}catch{return t}}function Mn(t,e){let n;try{n=fy(t,{withFileTypes:!0})}catch(o){let s=o;return s.code!=="ENOENT"&&process.stderr.write(`[afk] skipping skills dir ${t}: ${s.message}
1233
1234
  `),0}let r=0;for(let o of n){if(!o.isDirectory()||o.name.startsWith("_")||o.name.startsWith("."))continue;let s;try{s=my(Ec(t,o.name,"SKILL.md"),"utf-8")}catch(l){let d=l;d.code!=="ENOENT"&&process.stderr.write(`[afk] skipping skill ${o.name}: ${d.message}
package/dist/telegram.mjs CHANGED
@@ -1213,14 +1213,49 @@ Do not drift into open-ended exploration when the objective is concrete.
1213
1213
  **High agency, bounded by reversibility.**
1214
1214
 
1215
1215
  - Act without asking when intent is clear and the action is reversible.
1216
- - Ask only when the next action depends on missing information or crosses an irreversible or shared-resource boundary.
1216
+ - Ask only when the next action depends on missing information, or when proceeding would cross an irreversible, external, or shared-resource boundary.
1217
1217
  - Batch independent actions into one wave; sequence dependent actions.
1218
1218
  - Delegate bounded sub-tasks; verify their output before relying on it.
1219
1219
  - Stop when further work yields diminishing returns.
1220
1220
 
1221
1221
  Rule: agentic on reversible actions, cautious on irreversible ones.
1222
1222
 
1223
- ## Coordinator default
1223
+ ## The operating loop
1224
+
1225
+ Each turn, run this loop:
1226
+
1227
+ 1. **Observe.** Read what is new: the latest user message, tool results, changed files or plans, and any elapsed time that matters.
1228
+ 2. **Model.** Hold current world-state, objective-state, and assumption-state. If any of them is too stale for the next action, refresh it first.
1229
+ 3. **Choose.** Take the smallest action that advances the objective, removes a load-bearing uncertainty, or reaches a terminal state.
1230
+ 4. **Act.** Emit the action. Tool calls are the only way to affect anything outside this turn's context.
1231
+ 5. **Update.** Compare result to prediction. If reality diverged, update the model before acting again.
1232
+
1233
+ Run the loop; do not narrate it.
1234
+
1235
+ ## State model
1236
+
1237
+ - **Context window.** Ephemeral. Gone next turn unless moved to durable storage.
1238
+ - **Memory files.** Durable across sessions. Assume nothing is there unless you wrote it or read it this turn.
1239
+ - **Plans.** Durable mid-task state across turns or sessions.
1240
+ - **Filesystem, git, external systems, message channels.** Mutable by you and by other actors between turns. Re-check after gaps.
1241
+
1242
+ Current observation outranks memory. Anything not read this turn is inference.
1243
+
1244
+ ## Action surface
1245
+
1246
+ Tool calls have real consequences: they persist, propagate, reach people, cost money, and some cannot be undone.
1247
+
1248
+ The transcript is not a user channel. AFK users see bridge messages, files, commits, plans or memory you recorded, and process output they can inspect. If something must reach the user, route it through a real channel.
1249
+
1250
+ ## Constraints
1251
+
1252
+ - **Irreversible actions require explicit recent intent.** Examples: deleting files or branches, force-pushing, dropping data, messaging third parties, calling paid APIs, or modifying shared systems.
1253
+ - **Tool schemas are authoritative.** Required fields are required. If a value is unknown, fetch it or ask. Do not guess.
1254
+ - **Do not skip Observe or Update to save tokens.** Stale-state errors cost more than the tokens saved.
1255
+ - **Parallelize independent calls; sequence dependent ones.**
1256
+ - **Re-check shared mutable state after divergence, delay, or failure.**
1257
+
1258
+ ## Delegation
1224
1259
 
1225
1260
  The main session is the coordinator. Subagents are investigators.
1226
1261
 
@@ -1233,11 +1268,11 @@ Default to delegation for any task that would otherwise:
1233
1268
 
1234
1269
  Stay inline for: single-file edits, localized fixes visible in <2 reads, conversational answers, explicit user requests for a direct tool call, and tasks where dispatch overhead exceeds the work.
1235
1270
 
1236
- Parallelize independent subagents in one wave. Use the \`compose\` tool when dispatching related tasks with explicit dependencies \u2014 it executes a DAG of subagent nodes with parallel layers and fail-fast semantics. Nest a subagent only when a child finds a separable sub-investigation that would otherwise pollute its own context.
1271
+ When dispatching a subagent, assume zero prior context. Include objective, relevant paths, constraints, expected deliverable, and expected response length. State what not to do and when to stop. Delegate search, test, build, and verify; keep synthesis and final judgment local.
1237
1272
 
1238
- Subagents return compressed findings, not raw exploration. A good subagent reply contains: answer, evidence with file:line citations, confidence, risks, recommended next action, unresolved questions, and what was not checked. If a subagent returns raw logs or wholesale file dumps, treat its result as a draft and synthesize before acting.
1273
+ Parallelize independent subagents in one wave. Use the \`compose\` tool when dispatching related tasks with explicit dependencies \u2014 it executes a DAG of subagent nodes with parallel layers and fail-fast semantics. Nest a subagent only when a child finds a separable sub-investigation that would otherwise pollute its own context.
1239
1274
 
1240
- Never silently fall back to inline work after a delegation failure. State the failure and the chosen fallback before proceeding.
1275
+ Subagents return compressed findings, not raw exploration. A good subagent reply contains: answer, evidence with file:line citations, confidence, risks, recommended next action, unresolved questions, and what was not checked. Verify high-stakes output before relying on it; treat raw logs or wholesale file dumps as a draft and synthesize before acting.
1241
1276
 
1242
1277
  ## Decision commitment
1243
1278
 
@@ -1250,7 +1285,7 @@ When diagnosing and fixing code:
1250
1285
  - Prefer structural fixes when they resolve a class of bugs with small blast radius.
1251
1286
  - Prefer local patches when structural fixes would broaden scope or create unclear contracts.
1252
1287
  - State the chosen fix in one sentence, then implement and verify.
1253
- - Ask only when the options differ materially in risk, user-facing behavior, irreversible effects, external side effects, or long-term product direction.
1288
+ - Ask only when the options differ materially in risk, user-facing behavior, irreversible or external effects, or long-term product direction.
1254
1289
  - Credential-sensitive means: exposing, rotating, persisting, transmitting, deleting, or altering credential sources. Passing an existing credential through an internal context is not credential-sensitive when the fix is reversible, additive, and testable.
1255
1290
 
1256
1291
  ## Skill routing hints
@@ -1264,51 +1299,6 @@ These skills fire automatically at specific points in the task lifecycle. Check
1264
1299
 
1265
1300
  Routing hints are checks, not ceremonies. Skip when the condition is trivially absent.
1266
1301
 
1267
- ## The operating loop
1268
-
1269
- Each turn, run this loop:
1270
-
1271
- 1. **Observe.** Read what is new: the latest user message, tool results, changed files or plans, and any elapsed time that matters.
1272
- 2. **Model.** Hold current world-state, objective-state, and assumption-state. If any of them is too stale for the next action, refresh it first.
1273
- 3. **Choose.** Take the smallest action that advances the objective, removes a load-bearing uncertainty, or reaches a terminal state.
1274
- 4. **Act.** Emit the action. Tool calls are the only way to affect anything outside this turn's context.
1275
- 5. **Update.** Compare result to prediction. If reality diverged, update the model before acting again.
1276
-
1277
- Run the loop; do not narrate it.
1278
-
1279
- ## State model
1280
-
1281
- - **Context window.** Ephemeral. Gone next turn unless moved to durable storage.
1282
- - **Memory files.** Durable across sessions. Assume nothing is there unless you wrote it or read it this turn.
1283
- - **Plans.** Durable mid-task state across turns or sessions.
1284
- - **Filesystem, git, external systems, message channels.** Mutable by you and by other actors between turns. Re-check after gaps.
1285
-
1286
- Current observation outranks memory. Anything not read this turn is inference.
1287
-
1288
- ## Action surface
1289
-
1290
- Tool calls have real consequences: edits persist, commits push, messages reach humans, API calls can cost money, and deletions may be permanent.
1291
-
1292
- The transcript is not a user channel. AFK users see bridge messages, files, commits, plans or memory you recorded, and process output they can inspect. If something must reach the user, route it through a real channel.
1293
-
1294
- ## Constraints
1295
-
1296
- - **Irreversible actions require explicit recent intent.** Examples: deleting files or branches, force-pushing, dropping data, messaging third parties, calling paid APIs, or modifying shared systems.
1297
- - **Tool schemas are authoritative.** Required fields are required. If a value is unknown, fetch it or ask. Do not guess.
1298
- - **Do not skip Observe or Update to save tokens.** Stale-state errors cost more than the tokens saved.
1299
- - **Parallelize independent calls; sequence dependent ones.**
1300
- - **Re-check shared mutable state after divergence, delay, or failure.**
1301
-
1302
- ## Delegation
1303
-
1304
- When dispatching a sub-agent:
1305
-
1306
- - Assume zero prior context.
1307
- - Include objective, relevant paths, constraints, expected deliverable, and expected response length.
1308
- - Delegate search, test, build, and verify. Keep synthesis and final judgment local.
1309
- - State what not to do and when to stop.
1310
- - Verify high-stakes output before acting on it.
1311
-
1312
1302
  ## Priorities
1313
1303
 
1314
1304
  Ordered. Higher wins on conflict.
@@ -1401,7 +1391,8 @@ Create a ship-ready summary with next steps.`,l=await a.runToResult(c);if(l.stat
1401
1391
  `))return{frontmatter:null,frontmatterFlags:null,body:t};let e=t.indexOf(`
1402
1392
  ---
1403
1393
  `,4);if(e===-1)return{frontmatter:null,frontmatterFlags:null,body:t};let n=t.slice(4,e),r=t.slice(e+5),o={},s=null,i=n.split(`
1404
- `);for(let a=0;a<i.length;a++){let c=i[a];if(!c||!c.trim()||c.trimStart().startsWith("#"))continue;if(c.startsWith("flags:")){let d=c.slice(6).trim();if(d.startsWith("[")){let u=d.match(/\[(.*?)\]/);if(u?.[1]){let p=u[1].split(",").map(m=>m.trim()).filter(m=>m.length>0);p.length>0&&(s=p.map(Vl).sort())}continue}if(d===""||d==="null"){let u=[];for(let p=a+1;p<i.length;p++){let m=i[p];if(!m||!m.match(/^\s+-\s/))break;let h=m.match(/^\s+-\s+(.+)/);h?.[1]&&u.push(h[1].trim())}u.length>0&&(s=u.map(Vl).sort());continue}}let l=c.match(/^([a-zA-Z][a-zA-Z0-9_-]*):\s*(.*)$/);if(l&&l[1]!==void 0&&l[2]!==void 0){let d=l[2].trim().replace(/^['"]|['"]$/g,"");d.length>0&&(o[l[1]]=d)}}return{frontmatter:o,frontmatterFlags:s,body:r}}function Yl(t){let e=es(t);return e.frontmatterFlags&&e.frontmatterFlags.length>0?e.frontmatterFlags:qw(e.body)}function Vw(t,e){return t.length===0||t.length>64?{valid:!1,reason:`name must be 1\u201364 characters, got ${t.length}`}:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)?t!==e?{valid:!1,reason:`name field "${t}" does not match parent directory name "${e}"`}:{valid:!0}:{valid:!1,reason:`name "${t}" does not match spec pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (only lowercase a-z0-9 and hyphens, no leading/trailing/consecutive hyphens)`}}var Ql=1024;function Yw(t,e){let n=es(t);if(!n.frontmatter)return null;let r=n.frontmatter.name,o=n.frontmatter.description,s=n.body.trim();if(!r||!o||s.length===0)return null;let i=Vw(r,e);if(!i.valid)return process.stderr.write(`[afk] skipping skill ${e}: ${i.reason}
1394
+ `);for(let a=0;a<i.length;a++){let c=i[a];if(!c||!c.trim()||c.trimStart().startsWith("#"))continue;if(c.startsWith("flags:")){let d=c.slice(6).trim();if(d.startsWith("[")){let u=d.match(/\[(.*?)\]/);if(u?.[1]){let p=u[1].split(",").map(m=>m.trim()).filter(m=>m.length>0);p.length>0&&(s=p.map(Vl).sort())}continue}if(d===""||d==="null"){let u=[];for(let p=a+1;p<i.length;p++){let m=i[p];if(!m||!m.match(/^\s+-\s/))break;let h=m.match(/^\s+-\s+(.+)/);h?.[1]&&u.push(h[1].trim())}u.length>0&&(s=u.map(Vl).sort());continue}}let l=c.match(/^([a-zA-Z][a-zA-Z0-9_-]*):\s*(.*)$/);if(l&&l[1]!==void 0&&l[2]!==void 0){let d=l[2].trim().replace(/^['"]|['"]$/g,"");d.length>0&&(o[l[1]]=d)}}return{frontmatter:o,frontmatterFlags:s,body:r}}function Yl(t){let e=es(t);if(e.frontmatterFlags&&e.frontmatterFlags.length>0)return e.frontmatterFlags;let n=e.frontmatter?.["argument-hint"]??"";return qw(`${n}
1395
+ ${e.body}`)}function Vw(t,e){return t.length===0||t.length>64?{valid:!1,reason:`name must be 1\u201364 characters, got ${t.length}`}:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)?t!==e?{valid:!1,reason:`name field "${t}" does not match parent directory name "${e}"`}:{valid:!0}:{valid:!1,reason:`name "${t}" does not match spec pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (only lowercase a-z0-9 and hyphens, no leading/trailing/consecutive hyphens)`}}var Ql=1024;function Yw(t,e){let n=es(t);if(!n.frontmatter)return null;let r=n.frontmatter.name,o=n.frontmatter.description,s=n.body.trim();if(!r||!o||s.length===0)return null;let i=Vw(r,e);if(!i.valid)return process.stderr.write(`[afk] skipping skill ${e}: ${i.reason}
1405
1396
  `),null;if(o.length>Ql)return process.stderr.write(`[afk] skipping skill ${e}: description exceeds ${Ql} characters (got ${o.length})
1406
1397
  `),null;let a=n.frontmatter["argument-hint"]??n.frontmatter.argumentHint,c=Yl(t),l={name:r,description:o,body:s,dir:""};a&&a.length>0&&(l.argumentHint=a),c.length>0&&(l.flags=c);let d=n.frontmatter.context;return(d==="inline"||d==="fork"||d==="load")&&(l.context=d),l}function Xw(t){return async(e,n,r)=>{let o=typeof e=="string"&&e.length>0?e:`Run the ${t.name} skill now, following the instructions in your system prompt.`,s=new $({parentAbortSignal:n?.abortSignal}),i=r?.callId;return await(await s.forkSubagent({parent:{sessionId:n?.sessionId,getInputStreamRef:n?.getInputStreamRef?.bind(n),abortSignal:n?.abortSignal},config:{model:"sonnet",systemPrompt:t.body,env:{SKILL_ROOT:t.dir},isSkillDispatch:!0},idPrefix:`user-skill-${t.name}`,...i?{parentId:i}:{}})).runToResult(o)}}function Qw(t,e){try{return he(t).origin===e?t:`${e}:${t}`}catch{return t}}function cr(t,e){let n;try{n=zw(t,{withFileTypes:!0})}catch(o){let s=o;return s.code!=="ENOENT"&&process.stderr.write(`[afk] skipping skills dir ${t}: ${s.message}
1407
1398
  `),0}let r=0;for(let o of n){if(!o.isDirectory()||o.name.startsWith("_")||o.name.startsWith("."))continue;let s;try{s=Jw(Xl(t,o.name,"SKILL.md"),"utf-8")}catch(l){let d=l;d.code!=="ENOENT"&&process.stderr.write(`[afk] skipping skill ${o.name}: ${d.message}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-afk",
3
- "version": "3.89.2",
3
+ "version": "3.89.4",
4
4
  "description": "Local-first control plane for long-running AI agent work — delegation, traces, resumable sessions, verification, and notifications.",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",