dispach 0.2.2 → 0.2.3

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 (105) hide show
  1. package/README.md +5 -2
  2. package/dist/APEv2Parser-ysjr6adv.js +5 -0
  3. package/dist/{AiffParser-y21k3fak.js → AiffParser-9hj6fpmy.js} +3 -3
  4. package/dist/{AiffParser-y21k3fak.js.map → AiffParser-9hj6fpmy.js.map} +1 -1
  5. package/dist/{App-4w3qkcs4.js → App-2f72vhjv.js} +7 -7
  6. package/dist/{App-4w3qkcs4.js.map → App-2f72vhjv.js.map} +3 -3
  7. package/dist/{AsfParser-wd98k2h4.js → AsfParser-7emspn04.js} +3 -3
  8. package/dist/{AsfParser-wd98k2h4.js.map → AsfParser-7emspn04.js.map} +1 -1
  9. package/dist/{DsdiffParser-cbfaj500.js → DsdiffParser-dz88pnnr.js} +3 -3
  10. package/dist/{DsdiffParser-cbfaj500.js.map → DsdiffParser-dz88pnnr.js.map} +1 -1
  11. package/dist/{DsfParser-tybrja4x.js → DsfParser-qgh63tbs.js} +2 -2
  12. package/dist/FlacParser-drm5wq0p.js +5 -0
  13. package/dist/{MP4Parser-gc94h1n9.js → MP4Parser-yr7p3z12.js} +3 -3
  14. package/dist/{MP4Parser-gc94h1n9.js.map → MP4Parser-yr7p3z12.js.map} +1 -1
  15. package/dist/{MatroskaParser-cy2k4fac.js → MatroskaParser-jkbsbsk3.js} +3 -3
  16. package/dist/{MatroskaParser-cy2k4fac.js.map → MatroskaParser-jkbsbsk3.js.map} +1 -1
  17. package/dist/{MpegParser-c460fwf0.js → MpegParser-t93vwnew.js} +3 -3
  18. package/dist/{MpegParser-c460fwf0.js.map → MpegParser-t93vwnew.js.map} +1 -1
  19. package/dist/{MusepackParser-8mq2eabg.js → MusepackParser-6e8kbh2d.js} +3 -3
  20. package/dist/{MusepackParser-8mq2eabg.js.map → MusepackParser-6e8kbh2d.js.map} +1 -1
  21. package/dist/{OggParser-7dnc6apg.js → OggParser-ggcypmag.js} +3 -3
  22. package/dist/{OggParser-7dnc6apg.js.map → OggParser-ggcypmag.js.map} +1 -1
  23. package/dist/{WavPackParser-kt7cds9c.js → WavPackParser-jw9stzqp.js} +3 -3
  24. package/dist/{WavPackParser-kt7cds9c.js.map → WavPackParser-jw9stzqp.js.map} +1 -1
  25. package/dist/{WaveParser-g47ja0vy.js → WaveParser-epmncs9w.js} +3 -3
  26. package/dist/{WaveParser-g47ja0vy.js.map → WaveParser-epmncs9w.js.map} +1 -1
  27. package/dist/{WizardApp-q4p979d1.js → WizardApp-pgzcz9zq.js} +2 -2
  28. package/dist/{channels-4t89qpdt.js → channels-m8nambmm.js} +2 -2
  29. package/dist/client.d.ts +43 -0
  30. package/dist/client.js +9 -9
  31. package/dist/client.js.map +5 -5
  32. package/dist/components/App.d.ts.map +1 -1
  33. package/dist/{config-35r6n1gh.js → config-hmgrqgf2.js} +4 -4
  34. package/dist/{config-35r6n1gh.js.map → config-hmgrqgf2.js.map} +1 -1
  35. package/dist/{credential-dpdgg4j6.js → credential-nkb2ya59.js} +2 -2
  36. package/dist/index-1mbdz3f7.js +12 -0
  37. package/dist/{index-wc4entme.js.map → index-1mbdz3f7.js.map} +3 -3
  38. package/dist/{index-ew997be5.js → index-22fzzn7z.js} +7 -7
  39. package/dist/{index-ew997be5.js.map → index-22fzzn7z.js.map} +1 -1
  40. package/dist/{index-ynsvkqgb.js → index-308y9xt0.js} +2 -2
  41. package/dist/{index-7mn8ack9.js → index-836hc2h1.js} +3 -3
  42. package/dist/{index-7mn8ack9.js.map → index-836hc2h1.js.map} +1 -1
  43. package/dist/{index-twn9bfm2.js → index-9t4dz145.js} +5 -5
  44. package/dist/{index-twn9bfm2.js.map → index-9t4dz145.js.map} +1 -1
  45. package/dist/{index-r4ax3x4d.js → index-djeqvfms.js} +25 -25
  46. package/dist/index-djeqvfms.js.map +13 -0
  47. package/dist/{index-z157at3s.js → index-dpcm1j62.js} +17 -17
  48. package/dist/{index-z157at3s.js.map → index-dpcm1j62.js.map} +1 -1
  49. package/dist/{index-kjqksgch.js → index-dv9pdjy4.js} +2 -2
  50. package/dist/{index-8h6kewy1.js → index-eztfverw.js} +2 -2
  51. package/dist/{index-haypwvzd.js → index-fxpmx6cr.js} +76 -76
  52. package/dist/{index-haypwvzd.js.map → index-fxpmx6cr.js.map} +3 -3
  53. package/dist/{index-a2eh8dnk.js → index-hgm2gchq.js} +2 -2
  54. package/dist/{index-qg9bn980.js → index-hpvfqq6r.js} +280 -241
  55. package/dist/{index-qg9bn980.js.map → index-hpvfqq6r.js.map} +15 -14
  56. package/dist/{index-fa9wvpyw.js → index-hrwakb11.js} +2 -2
  57. package/dist/{index-ma6p7bt4.js → index-jff5q27j.js} +2 -2
  58. package/dist/index-k8e9f466.js +110 -0
  59. package/dist/index-k8e9f466.js.map +13 -0
  60. package/dist/{index-gq1npngp.js → index-mjfv7k5w.js} +2 -2
  61. package/dist/{index-p1zy871m.js → index-pqw1n1pv.js} +3 -3
  62. package/dist/{index-p1zy871m.js.map → index-pqw1n1pv.js.map} +1 -1
  63. package/dist/{index-9914wh1d.js → index-qv6ktepc.js} +2 -2
  64. package/dist/{index-zce9gy22.js → index-ry6a4bqh.js} +2 -2
  65. package/dist/{index-fcsg95m5.js → index-sh44ymqz.js} +2 -2
  66. package/dist/{index-gbkma7ds.js → index-xg7s813b.js} +3 -3
  67. package/dist/{index-gbkma7ds.js.map → index-xg7s813b.js.map} +1 -1
  68. package/dist/{index-eqqd4k4f.js → index-y7dxq4a4.js} +3 -3
  69. package/dist/index.js +149 -149
  70. package/dist/index.js.map +6 -6
  71. package/dist/lib/source.d.ts +8 -0
  72. package/dist/lib/source.d.ts.map +1 -1
  73. package/dist/lib/types.d.ts +8 -2
  74. package/dist/lib/types.d.ts.map +1 -1
  75. package/dist/run.d.ts.map +1 -1
  76. package/dist/transcript.d.ts.map +1 -1
  77. package/dist/{web-zph4h3p9.js → web-gfv0mzgs.js} +2 -2
  78. package/dist/wire.d.ts +19 -0
  79. package/dist/wire.js +5 -5
  80. package/dist/wire.js.map +4 -4
  81. package/package.json +1 -1
  82. package/dist/APEv2Parser-etzjd528.js +0 -5
  83. package/dist/FlacParser-7t7da7qy.js +0 -5
  84. package/dist/index-664xcamy.js +0 -110
  85. package/dist/index-664xcamy.js.map +0 -13
  86. package/dist/index-r4ax3x4d.js.map +0 -13
  87. package/dist/index-wc4entme.js +0 -12
  88. /package/dist/{APEv2Parser-etzjd528.js.map → APEv2Parser-ysjr6adv.js.map} +0 -0
  89. /package/dist/{DsfParser-tybrja4x.js.map → DsfParser-qgh63tbs.js.map} +0 -0
  90. /package/dist/{FlacParser-7t7da7qy.js.map → FlacParser-drm5wq0p.js.map} +0 -0
  91. /package/dist/{WizardApp-q4p979d1.js.map → WizardApp-pgzcz9zq.js.map} +0 -0
  92. /package/dist/{channels-4t89qpdt.js.map → channels-m8nambmm.js.map} +0 -0
  93. /package/dist/{credential-dpdgg4j6.js.map → credential-nkb2ya59.js.map} +0 -0
  94. /package/dist/{index-ynsvkqgb.js.map → index-308y9xt0.js.map} +0 -0
  95. /package/dist/{index-kjqksgch.js.map → index-dv9pdjy4.js.map} +0 -0
  96. /package/dist/{index-8h6kewy1.js.map → index-eztfverw.js.map} +0 -0
  97. /package/dist/{index-a2eh8dnk.js.map → index-hgm2gchq.js.map} +0 -0
  98. /package/dist/{index-fa9wvpyw.js.map → index-hrwakb11.js.map} +0 -0
  99. /package/dist/{index-ma6p7bt4.js.map → index-jff5q27j.js.map} +0 -0
  100. /package/dist/{index-gq1npngp.js.map → index-mjfv7k5w.js.map} +0 -0
  101. /package/dist/{index-9914wh1d.js.map → index-qv6ktepc.js.map} +0 -0
  102. /package/dist/{index-zce9gy22.js.map → index-ry6a4bqh.js.map} +0 -0
  103. /package/dist/{index-fcsg95m5.js.map → index-sh44ymqz.js.map} +0 -0
  104. /package/dist/{index-eqqd4k4f.js.map → index-y7dxq4a4.js.map} +0 -0
  105. /package/dist/{web-zph4h3p9.js.map → web-gfv0mzgs.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{t,A,Le,Tt,F,Z,ne}from"./index-qg9bn980.js";import{le}from"./index-haypwvzd.js";import{Hr,Je}from"./index-fcsg95m5.js";import{qe,Ve,Ut,xt,me,ut,ln}from"./index-7mn8ack9.js";import{U}from"./index-38gs9anh.js";import{u,y,nA,dn,oA}from"./index-3vzf253k.js";import{Bs}from"./index-zw6wyas6.js";import{we,G,Eo,pn,Ae}from"./index-twn9bfm2.js";import{o,d,wa}from"./index-8tmv33mr.js";import{c}from"./index-323jvr1g.js";import{closeSync as je,existsSync as ve,mkdirSync as Ge,openSync as Ke,readFileSync as Xe,readSync as ze,statSync as be}from"node:fs";import{homedir as B}from"node:os";import{dirname as M,join as $e,resolve as Ye}from"node:path";function K(e){let n=[];if(e.problem!==void 0)n.push({code:"daemon_agent_unreadable",severity:"warn",message:`Agent "${e.agentId}" could not be read: ${e.problem}`,hint:"The host skips an agent whose manifest will not load and serves the rest, so this is a warning rather than a refusal — `validate` on that agent says exactly what is wrong with it."});if(e.envFileMode!==void 0&&(e.envFileMode&63)!==0)n.push({code:"daemon_env_world_readable",severity:"warn",message:`${e.agentId}'s .env is mode ${(e.envFileMode&511).toString(8)} and holds its only secrets.`,hint:`Under a service manager that file is the *only* path credentials arrive by — a unit carries none on purpose, because its manager echoes the environment in plaintext. \`chmod 600 ${e.agentDir}/.env\`.`});return n}function _e(e){let n=[];if(e.gitRoot!==void 0)n.push({code:"daemon_binary_in_checkout",severity:"warn",message:`The binary resolves to ${e.scriptPath}, inside a git checkout at ${e.gitRoot}.`,hint:"A rebuild, a branch switch or a `git clean` changes or breaks what the service runs, and the failure arrives with no obvious connection to the change. Fine for testing; install a released build for a service you intend to leave running."});if(/[/.](nvm|fnm|volta|asdf)\//.test(e.execPath))n.push({code:"daemon_versioned_runtime",severity:"warn",message:`The interpreter is a version-managed install: ${e.execPath}`,hint:"The absolute path is baked into the service definition, so removing that runtime version later kills the service with a message only the log file sees. A system or Homebrew install is more durable."});return n}function X(e){let n=[];for(let r of e.retiring)n.push({code:"daemon_per_agent_retired",severity:"warn",message:`Retiring ${r} — one service hosts every agent now.`,hint:"It is unloaded, re-enabled and its definition removed. The re-enable is not cosmetic: a `disable` row persists across boots and no verb deletes it, so a label left disabled makes any future job with that name install cleanly and silently never start. Per-agent on/off is `stop <agent>`, which persists in the store instead."});if(e.servedElsewhere.length>0){let r=e.servedElsewhere[0];n.push({code:"daemon_agents_held_elsewhere",severity:"warn",message:`${e.servedElsewhere.length} agent(s) are held by other live processes — ${r?.agentId} by pid ${r?.pid} (${r?.mode}).`,hint:"The service will start and serve everything else, and report those as served elsewhere rather than fighting for them — one listener per bot token is the whole reason the lease exists. `stop` with no agent ends the other processes."})}return n.push(..._e(e.binary)),n}function Te(e,n="serving on"){let r=e.lastIndexOf(n);return r===-1?e:e.slice(r)}function z(e){let n=Te(e),r=[],i=new Set;for(let a of n.matchAll(/denied — Sender "([^"]+)" is not in channel "([^"]+)"/g))if(a[1]!==void 0)i.add(`${a[1]}|${a[2]??""}`);for(let a of i){let[s,l]=a.split("|");r.push({code:"inbound_denied",summary:`messages from ${s} are being refused — they are not on channel "${l}"'s allowFrom list`,fix:`add ${s} to allowFrom in agent.yaml, then restart. An allowlist that is empty, or that has a typo in it, refuses silently from the sender's side: they see nothing at all.`})}if(/channel_telegram_unauthorized|telegram_token_missing/.test(n))r.push({code:"channel_unauthorized",summary:"the channel rejected its token",fix:"check the token in the .env beside the manifest, then restart."});return r}var Ie=3;function J(e,n){let r=Me(n),i=[];if(n.pid!==void 0)i.push({label:"state",value:`running · pid ${n.pid}`,...n.uptimeMs===void 0?{}:{note:`up ${dn(n.uptimeMs)}`}});else if(n.leasePid!==void 0)i.push({label:"state",value:`running · pid ${n.leasePid}`,note:"a serve process, not an installed service"});if(n.runs!==void 0&&n.runs>1)i.push({label:"starts",value:String(n.runs),...r==="restart-loop"?{note:`launchd has restarted this ${n.runs} times`}:{note:"since the service was installed"}});if(r!=="running"&&n.lastExitCode!==void 0&&n.lastExitCode!==0)i.push({label:"last exit",value:`code ${n.lastExitCode}`});if(n.stderrPath!==void 0)i.push({label:"logs",value:n.stderrPath,...n.stderrBytes===void 0?{}:{note:`(${nA(n.stderrBytes)})`}});return{verdict:r,healthy:r==="running",headline:r==="restart-loop"?`${e} — RESTART LOOP`:`${e} — ${Ce(r)}`,rows:i,wantsStderrTail:r==="restart-loop"||r==="failed"||r==="installed-idle"}}function Me(e){if(!e.installed)return e.leasePid===void 0?"absent":"running";if(e.pid!==void 0)return"running";if(e.disabled)return"stopped";if((e.runs??0)>=Ie&&(e.lastExitCode??0)!==0)return"restart-loop";if((e.lastExitCode??0)!==0)return"failed";return"installed-idle"}function Ce(e){switch(e){case"running":return"running";case"failed":return"STOPPED AFTER A FAILURE";case"restart-loop":return"exited · nothing is running";case"stopped":return"stopped by you";case"installed-idle":return"installed · not running";case"absent":return"not installed"}}function Y(e){return`${e.headline}
3
- ${u(e.rows)}`}function E(e){return["HOME","PATH","TMPDIR",`${e}SERVICE`,`${e}HOME`]}class C extends Error{code="daemon_secret_in_service";hint;constructor(e,n,r){super(`The service definition would carry an environment variable named ${e}.`);this.hint=`A ${r} unit is readable and its manager echoes every environment value in plaintext to any process running as this user — so a credential here is a credential published. The agent reads its own secrets from the .env beside its manifest, which is what the service is pointed at. Only these may appear: ${n.join(", ")}.`}}function O(e,n,r){let i=E(n);for(let a of Object.keys(e))if(!i.includes(a))throw new C(a,i,r)}var De={Crashed:!0},S=30,P=30;function tr(e,n){return`${e}.agent.${n}`}function x(e){return`${e}.server`}function b(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function R(e,n){O(e.environment,n,"launchd");let r=e.programArguments.map((s)=>` <string>${b(s)}</string>`).join(`
2
+ import{t,A,Le,Tt,F,Z,ne}from"./index-hpvfqq6r.js";import{le}from"./index-fxpmx6cr.js";import{Hr,Je}from"./index-sh44ymqz.js";import{qe,Ve,Ut,xt,me,ut,ln}from"./index-836hc2h1.js";import{U}from"./index-38gs9anh.js";import{u,y,nA,dn,oA}from"./index-3vzf253k.js";import{Bs}from"./index-zw6wyas6.js";import{we,P,Eo,pn,Ae}from"./index-9t4dz145.js";import{o,d,wa}from"./index-8tmv33mr.js";import{c}from"./index-323jvr1g.js";import{closeSync as je,existsSync as ve,mkdirSync as Ge,openSync as Ke,readFileSync as Xe,readSync as ze,statSync as be}from"node:fs";import{homedir as j}from"node:os";import{dirname as C,join as $e,resolve as Ye}from"node:path";function K(e){let n=[];if(e.problem!==void 0)n.push({code:"daemon_agent_unreadable",severity:"warn",message:`Agent "${e.agentId}" could not be read: ${e.problem}`,hint:"The host skips an agent whose manifest will not load and serves the rest, so this is a warning rather than a refusal — `validate` on that agent says exactly what is wrong with it."});if(e.envFileMode!==void 0&&(e.envFileMode&63)!==0)n.push({code:"daemon_env_world_readable",severity:"warn",message:`${e.agentId}'s .env is mode ${(e.envFileMode&511).toString(8)} and holds its only secrets.`,hint:`Under a service manager that file is the *only* path credentials arrive by — a unit carries none on purpose, because its manager echoes the environment in plaintext. \`chmod 600 ${e.agentDir}/.env\`.`});return n}function _e(e){let n=[];if(e.gitRoot!==void 0)n.push({code:"daemon_binary_in_checkout",severity:"warn",message:`The binary resolves to ${e.scriptPath}, inside a git checkout at ${e.gitRoot}.`,hint:"A rebuild, a branch switch or a `git clean` changes or breaks what the service runs, and the failure arrives with no obvious connection to the change. Fine for testing; install a released build for a service you intend to leave running."});if(/[/.](nvm|fnm|volta|asdf)\//.test(e.execPath))n.push({code:"daemon_versioned_runtime",severity:"warn",message:`The interpreter is a version-managed install: ${e.execPath}`,hint:"The absolute path is baked into the service definition, so removing that runtime version later kills the service with a message only the log file sees. A system or Homebrew install is more durable."});return n}function X(e){let n=[];for(let r of e.retiring)n.push({code:"daemon_per_agent_retired",severity:"warn",message:`Retiring ${r} — one service hosts every agent now.`,hint:"It is unloaded, re-enabled and its definition removed. The re-enable is not cosmetic: a `disable` row persists across boots and no verb deletes it, so a label left disabled makes any future job with that name install cleanly and silently never start. Per-agent on/off is `stop <agent>`, which persists in the store instead."});if(e.servedElsewhere.length>0){let r=e.servedElsewhere[0];n.push({code:"daemon_agents_held_elsewhere",severity:"warn",message:`${e.servedElsewhere.length} agent(s) are held by other live processes — ${r?.agentId} by pid ${r?.pid} (${r?.mode}).`,hint:"The service will start and serve everything else, and report those as served elsewhere rather than fighting for them — one listener per bot token is the whole reason the lease exists. `stop` with no agent ends the other processes."})}return n.push(..._e(e.binary)),n}function Te(e,n="serving on"){let r=e.lastIndexOf(n);return r===-1?e:e.slice(r)}function z(e){let n=Te(e),r=[],i=new Set;for(let a of n.matchAll(/denied — Sender "([^"]+)" is not in channel "([^"]+)"/g))if(a[1]!==void 0)i.add(`${a[1]}|${a[2]??""}`);for(let a of i){let[s,l]=a.split("|");r.push({code:"inbound_denied",summary:`messages from ${s} are being refused — they are not on channel "${l}"'s allowFrom list`,fix:`add ${s} to allowFrom in agent.yaml, then restart. An allowlist that is empty, or that has a typo in it, refuses silently from the sender's side: they see nothing at all.`})}if(/channel_telegram_unauthorized|telegram_token_missing/.test(n))r.push({code:"channel_unauthorized",summary:"the channel rejected its token",fix:"check the token in the .env beside the manifest, then restart."});return r}var Ie=3;function J(e,n){let r=Me(n),i=[];if(n.pid!==void 0)i.push({label:"state",value:`running · pid ${n.pid}`,...n.uptimeMs===void 0?{}:{note:`up ${dn(n.uptimeMs)}`}});else if(n.leasePid!==void 0)i.push({label:"state",value:`running · pid ${n.leasePid}`,note:"a serve process, not an installed service"});if(n.runs!==void 0&&n.runs>1)i.push({label:"starts",value:String(n.runs),...r==="restart-loop"?{note:`launchd has restarted this ${n.runs} times`}:{note:"since the service was installed"}});if(r!=="running"&&n.lastExitCode!==void 0&&n.lastExitCode!==0)i.push({label:"last exit",value:`code ${n.lastExitCode}`});if(n.stderrPath!==void 0)i.push({label:"logs",value:n.stderrPath,...n.stderrBytes===void 0?{}:{note:`(${nA(n.stderrBytes)})`}});return{verdict:r,healthy:r==="running",headline:r==="restart-loop"?`${e} — RESTART LOOP`:`${e} — ${Ce(r)}`,rows:i,wantsStderrTail:r==="restart-loop"||r==="failed"||r==="installed-idle"}}function Me(e){if(!e.installed)return e.leasePid===void 0?"absent":"running";if(e.pid!==void 0)return"running";if(e.disabled)return"stopped";if((e.runs??0)>=Ie&&(e.lastExitCode??0)!==0)return"restart-loop";if((e.lastExitCode??0)!==0)return"failed";return"installed-idle"}function Ce(e){switch(e){case"running":return"running";case"failed":return"STOPPED AFTER A FAILURE";case"restart-loop":return"exited · nothing is running";case"stopped":return"stopped by you";case"installed-idle":return"installed · not running";case"absent":return"not installed"}}function Y(e){return`${e.headline}
3
+ ${u(e.rows)}`}function O(e){return["HOME","PATH","TMPDIR",`${e}SERVICE`,`${e}HOME`]}class D extends Error{code="daemon_secret_in_service";hint;constructor(e,n,r){super(`The service definition would carry an environment variable named ${e}.`);this.hint=`A ${r} unit is readable and its manager echoes every environment value in plaintext to any process running as this user — so a credential here is a credential published. The agent reads its own secrets from the .env beside its manifest, which is what the service is pointed at. Only these may appear: ${n.join(", ")}.`}}function R(e,n,r){let i=O(n);for(let a of Object.keys(e))if(!i.includes(a))throw new D(a,i,r)}var De={Crashed:!0},S=30,k=30;function tr(e,n){return`${e}.agent.${n}`}function x(e){return`${e}.server`}function b(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function _(e,n){R(e.environment,n,"launchd");let r=e.programArguments.map((s)=>` <string>${b(s)}</string>`).join(`
4
4
  `),i=Object.entries(e.environment).map(([s,l])=>` <key>${b(s)}</key>
5
5
  <string>${b(l)}</string>`).join(`
6
6
  `);return`<?xml version="1.0" encoding="UTF-8"?>
@@ -27,7 +27,7 @@ ${r}
27
27
  <key>ThrottleInterval</key>
28
28
  <integer>${S}</integer>
29
29
  <key>ExitTimeOut</key>
30
- <integer>${P}</integer>
30
+ <integer>${k}</integer>
31
31
  <key>ProcessType</key>
32
32
  <string>Adaptive</string>
33
33
  <key>WorkingDirectory</key>
@@ -49,7 +49,7 @@ ${i}
49
49
  ── ${s.label} was emptied ──
50
50
  `),a=s.label;if(h.to<=h.from)continue;let g=n.read(s.path,h.from,h.to);if(g==="")continue;if(e.length>1&&s.label!==a)n.write(`
51
51
  ── ${s.label} ──
52
- `),a=s.label;n.write(g)}await n.wait(r.intervalMs)}}import{existsSync as Ne,mkdirSync as L,readdirSync as ae,rmSync as de,writeFileSync as ue}from"node:fs";import{basename as We,dirname as T,join as oe}from"node:path";import{join as re}from"node:path";function ie(e,n,r=process.env){let i=r.XDG_CONFIG_HOME,a=i===void 0||i===""?re(n,".config"):i;return re(a,"systemd","user",`${e}.service`)}function D(e,n){if(/[\r\n]/.test(e))throw Error(`${n} contains a newline, which systemd cannot express. hint: a unit value runs to end of line, so this would silently truncate rather than fail — rename the path.`)}function He(e){if(!/[\s"\\]/.test(e))return e;return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function _(e,n){O(e.environment,n,"systemd");for(let s of e.programArguments)D(s,"ExecStart");D(e.workingDirectory,"WorkingDirectory");for(let[s,l]of Object.entries(e.environment))D(l,`Environment=${s}`);let r=e.programArguments.map(He).join(" "),i=Object.entries(e.environment).map(([s,l])=>`Environment=${s}=${l}`).join(`
52
+ `),a=s.label;n.write(g)}await n.wait(r.intervalMs)}}import{existsSync as Ne,mkdirSync as H,readdirSync as ae,rmSync as de,writeFileSync as ue}from"node:fs";import{basename as We,dirname as I,join as oe}from"node:path";import{join as re}from"node:path";function ie(e,n,r=process.env){let i=r.XDG_CONFIG_HOME,a=i===void 0||i===""?re(n,".config"):i;return re(a,"systemd","user",`${e}.service`)}function L(e,n){if(/[\r\n]/.test(e))throw Error(`${n} contains a newline, which systemd cannot express. hint: a unit value runs to end of line, so this would silently truncate rather than fail — rename the path.`)}function He(e){if(!/[\s"\\]/.test(e))return e;return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function T(e,n){R(e.environment,n,"systemd");for(let s of e.programArguments)L(s,"ExecStart");L(e.workingDirectory,"WorkingDirectory");for(let[s,l]of Object.entries(e.environment))L(l,`Environment=${s}`);let r=e.programArguments.map(He).join(" "),i=Object.entries(e.environment).map(([s,l])=>`Environment=${s}=${l}`).join(`
53
53
  `);return`${e.provenance.map((s)=>`# ${s}`).join(`
54
54
  `)}
55
55
 
@@ -69,19 +69,19 @@ Restart=on-failure
69
69
  RestartSec=${S}
70
70
  # Must exceed the runtime's own stop deadline, or the reaper that kills backgrounded exec
71
71
  # children never finishes and they outlive the service.
72
- TimeoutStopSec=${P}
72
+ TimeoutStopSec=${k}
73
73
  KillMode=mixed
74
74
 
75
75
  [Install]
76
76
  WantedBy=default.target
77
- `}function se(e,n){return["systemctl --user daemon-reload",`systemctl --user enable --now ${e}`,`loginctl enable-linger ${n}`]}var Be=6000,Ue=200,ce=(e,n)=>{let r=Bs({command:e,args:n});return{code:r.code,stdout:r.stdout,stderr:r.stderr}};function rn(e,n){if(e==="darwin")return new pe(n);if(e==="linux")return new he(n);throw H(e)}function ge(e){return e==="darwin"}function H(e,n){let r=n===void 0?"":` For a systemd user unit, the line to write is:
77
+ `}function se(e,n){return["systemctl --user daemon-reload",`systemctl --user enable --now ${e}`,`loginctl enable-linger ${n}`]}var Be=6000,Ue=200,ce=(e,n)=>{let r=Bs({command:e,args:n});return{code:r.code,stdout:r.stdout,stderr:r.stderr}};function rn(e,n){if(e==="darwin")return new pe(n);if(e==="linux")return new he(n);throw N(e)}function ge(e){return e==="darwin"}function N(e,n){let r=n===void 0?"":` For a systemd user unit, the line to write is:
78
78
 
79
79
  ${n}
80
80
  Restart=on-failure
81
81
  RestartSec=30
82
82
 
83
- Put no secrets in the unit: the agent reads the .env beside its manifest, and \`systemctl show\` echoes Environment= to anyone.`;return new A({code:"daemon_platform_unsupported",message:`daemon installs a macOS LaunchAgent or a systemd user unit, and this platform is ${e}.`,hint:`No service manager is implemented for this platform.${r} In a container, run \`serve\` in the foreground and let the container runtime supervise it; that is the deployment this runtime is designed around.`})}class he{id="systemd";#r;#e;#i;#t;constructor(e){this.#r=e.home,this.#e=e.envPrefix,this.#i=e.exec??ce,this.#t=e.env??process.env}unitPath(e){return ie(e,this.#r,this.#t)}install(e){let n=this.unitPath(e.label),r=_(e,this.#e);L(T(n),{recursive:!0}),ue(n,r,{encoding:"utf8",mode:384})}uninstall(e){de(this.unitPath(e),{force:!0})}stop(e){throw this.#n(`systemctl --user stop ${e}`)}start(e){throw this.#n(`systemctl --user start ${e}`)}restart(e){throw this.#n(`systemctl --user restart ${e}`)}state(e){return{installed:Ne(this.unitPath(e)),disabled:!1,liveness:!1}}labels(e){try{return ae(T(this.unitPath(e))).filter((n)=>n.startsWith(e)&&n.endsWith(".service")).map((n)=>n.slice(0,-8)).sort()}catch{return[]}}followUp(e){return se(e,this.#s())}caution(){let e=this.#s(),n=this.#i("loginctl",["show-user",e,"--property=Linger"]);if(n.code===0&&/Linger=yes/i.test(n.stdout))return;return`A systemd user unit stops when your last session ends. \`loginctl enable-linger ${e}\` is what keeps it running after you log out or close an SSH connection.`}#s(){return this.#t.USER??this.#t.LOGNAME??We(this.#r)}#n(e){return new A({code:"daemon_manual_step",message:`This has to be run yourself: ${e}`,hint:`Unit files are written and read from here, and the lifecycle is not driven from here — nothing in this project's test environment can run \`systemctl --user\` (a container has no systemd, and a CI runner has no user session bus), and a command that reported success while nothing happened would be worse than this sentence. The unit is at ${this.unitPath(e.split(" ").pop()??"")}.`})}}class pe{id="launchd";#r;#e;#i;#t;constructor(e){this.#r=e.home,this.#e=`gui/${e.uid}`,this.#i=e.envPrefix,this.#t=e.exec??ce}unitPath(e){return oe(this.#r,"Library","LaunchAgents",`${e}.plist`)}install(e){let n=this.unitPath(e.label),r=R(e,this.#i);if(L(T(n),{recursive:!0}),L(T(e.stdoutPath),{recursive:!0}),this.#n(["bootout",`${this.#e}/${e.label}`],{tolerate:!0}),this.#s(e.label),ue(n,r,{encoding:"utf8",mode:384}),this.#n(["enable",`${this.#e}/${e.label}`],{tolerate:!0}),this.#n(["bootstrap",this.#e,n]),!this.state(e.label).installed)throw new A({code:"daemon_not_loaded",message:`${e.label} was written to ${n} but launchd did not load it.`,hint:`\`launchctl bootstrap\` returned success and \`launchctl print ${this.#e}/${e.label}\` finds nothing, which usually means an earlier copy was still unloading. Try again in a moment. Over SSH with no desktop session the ${this.#e} domain is unavailable and no LaunchAgent can load at all.`})}#s(e){let n=Date.now()+Be;while(Date.now()<n){if(this.#t("launchctl",["print",`${this.#e}/${e}`]).code!==0)return;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Ue)}}uninstall(e){this.#n(["bootout",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["enable",`${this.#e}/${e}`],{tolerate:!0}),de(this.unitPath(e),{force:!0})}stop(e){this.#n(["disable",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["bootout",`${this.#e}/${e}`],{tolerate:!0})}start(e){this.#n(["enable",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["bootstrap",this.#e,this.unitPath(e)])}restart(e){this.#n(["kickstart","-k",`${this.#e}/${e}`])}state(e){let n=this.#t("launchctl",["print",`${this.#e}/${e}`]),r=ee(this.#t("launchctl",["print-disabled",this.#e]).stdout).includes(e);if(n.code!==0)return{installed:!1,disabled:r,liveness:!0};let i=q(n.stdout);return{installed:!0,disabled:r,liveness:!0,print:i,...i.pid===void 0?{}:{pid:i.pid}}}labels(e){let n=Q(this.#t("launchctl",["list"]).stdout).map((i)=>i.label).filter((i)=>i.startsWith(e)),r=[];try{r=ae(oe(this.#r,"Library","LaunchAgents")).filter((i)=>i.startsWith(e)&&i.endsWith(".plist")).map((i)=>i.slice(0,-6))}catch{}return[...new Set([...n,...r])].sort()}followUp(){return[]}caution(){return}#n(e,n={}){let r=this.#t("launchctl",e);if(r.code===0||n.tolerate===!0)return r;throw new A({code:"daemon_launchctl_failed",message:`launchctl ${e.join(" ")} failed (${r.code}): ${r.stderr.trim()||"no output"}`,hint:`Code 5 usually means the service is already loaded — try \`daemon restart\`. Code 37 means an operation is still in progress; wait a moment. Code 125 or 112 means the ${this.#e} domain is unavailable, which happens over SSH with no GUI session: a LaunchAgent needs a logged-in desktop session, and the exit timeout is ${P}s.`})}}var fe=["install","uninstall","start","stop","restart","status","logs"];async function Ft(e){if(!fe.includes(e.action))throw new A({code:"cli_daemon_unknown_action",message:`daemon takes one of ${fe.join(", ")}, not "${e.action}".`,hint:`Usage: ${t.slug} daemon <action> <agent>. Run \`${t.slug} daemon --help\` for what each one does.`});let n=e.action;if(e.manifestPath!==void 0&&n!=="status"&&n!=="logs")throw new A({code:"daemon_per_agent_retired",message:`daemon ${n} no longer takes an agent — one service hosts every agent.`,hint:`\`${t.slug} daemon ${n}\` acts on that one service. Per-agent on/off is \`${t.slug} stop <agent>\` and \`${t.slug} start <agent>\`, which persist in the store rather than as a unit — so an agent you switch off stays off across a restart without the host going down with it.`});let r=e.platform??process.platform,i=Ze();if(r!=="darwin"&&r!=="linux"&&n!=="status")throw H(r,nn(i,e.manifestPath??"<manifest>"));let a=r==="darwin"||r==="linux"?rn(r,{home:B(),uid:process.getuid?.()??0,envPrefix:t.envPrefix,...e.exec===void 0?{}:{exec:e.exec},...e.env===void 0?{}:{env:e.env}}):void 0;switch(n){case"status":return await cn(e,a);case"install":return await Qe(e,i,a);case"uninstall":return an(e,a);case"start":case"stop":case"restart":return un(n,a);case"logs":return await fn(e)}}async function Qe(e,n,r){let i=x(t.slug),a=Eo(e.env),s=(r?.labels(`${t.slug}.agent.`)??[]).filter((p)=>p!==i),l=[...X({binary:n,retiring:s,servedElsewhere:(await xt(e.store)).filter((p)=>p.agentId!==Ut).map((p)=>({agentId:p.agentId,pid:p.pid,mode:p.mode}))}),...Ae(e.env).flatMap((p)=>{let m=on(p.dir);return K({agentId:p.id??p.ref,agentDir:p.dir,...p.problem===void 0?{}:{problem:p.problem},...m===void 0?{}:{envFileMode:m}})})],h={label:i,programArguments:[n.execPath,n.scriptPath,"serve","--store",G()].filter((p)=>p!==""),workingDirectory:we(e.env),stdoutPath:a.out,stderrPath:a.err,environment:tn(i),provenance:[`Generated by \`${t.slug} daemon install\`. One service hosts every agent.`,"Rewritten on every install — it names no agent, so there is nothing here to edit","when you add one. Switch an agent off with `stop <agent>`, which persists.","There are no secrets here and there never will be: a service manager echoes a","unit's environment in plaintext to anything running as this user. Each agent","reads its own credentials from the .env beside its manifest."]};if(e.dryRun===!0){if(process.stdout.write(r?.id==="systemd"?_(h,t.envPrefix):R(h,t.envPrefix)),l.length>0)process.stderr.write(ye(l));return o}for(let p of s)r?.uninstall(p);if(l.length>0)process.stdout.write(ye(l));Ge(M(a.out),{recursive:!0}),r?.install(h);let g=r?.followUp(i)??[];if(process.stdout.write(`${i} — ${g.length===0?"service installed":"unit written"}
84
- ${u([{label:"runs",value:`${k(n.execPath)} … serve`},{label:"hosts",value:"every agent in the sandbox that is not stopped"},{label:"logs",value:k(a.err)},{label:"restarts",value:`on crash only, at most one per ${S}s`}])}
83
+ Put no secrets in the unit: the agent reads the .env beside its manifest, and \`systemctl show\` echoes Environment= to anyone.`;return new A({code:"daemon_platform_unsupported",message:`daemon installs a macOS LaunchAgent or a systemd user unit, and this platform is ${e}.`,hint:`No service manager is implemented for this platform.${r} In a container, run \`serve\` in the foreground and let the container runtime supervise it; that is the deployment this runtime is designed around.`})}class he{id="systemd";#r;#e;#i;#t;constructor(e){this.#r=e.home,this.#e=e.envPrefix,this.#i=e.exec??ce,this.#t=e.env??process.env}unitPath(e){return ie(e,this.#r,this.#t)}install(e){let n=this.unitPath(e.label),r=T(e,this.#e);H(I(n),{recursive:!0}),ue(n,r,{encoding:"utf8",mode:384})}uninstall(e){de(this.unitPath(e),{force:!0})}stop(e){throw this.#n(`systemctl --user stop ${e}`)}start(e){throw this.#n(`systemctl --user start ${e}`)}restart(e){throw this.#n(`systemctl --user restart ${e}`)}state(e){return{installed:Ne(this.unitPath(e)),disabled:!1,liveness:!1}}labels(e){try{return ae(I(this.unitPath(e))).filter((n)=>n.startsWith(e)&&n.endsWith(".service")).map((n)=>n.slice(0,-8)).sort()}catch{return[]}}followUp(e){return se(e,this.#s())}caution(){let e=this.#s(),n=this.#i("loginctl",["show-user",e,"--property=Linger"]);if(n.code===0&&/Linger=yes/i.test(n.stdout))return;return`A systemd user unit stops when your last session ends. \`loginctl enable-linger ${e}\` is what keeps it running after you log out or close an SSH connection.`}#s(){return this.#t.USER??this.#t.LOGNAME??We(this.#r)}#n(e){return new A({code:"daemon_manual_step",message:`This has to be run yourself: ${e}`,hint:`Unit files are written and read from here, and the lifecycle is not driven from here — nothing in this project's test environment can run \`systemctl --user\` (a container has no systemd, and a CI runner has no user session bus), and a command that reported success while nothing happened would be worse than this sentence. The unit is at ${this.unitPath(e.split(" ").pop()??"")}.`})}}class pe{id="launchd";#r;#e;#i;#t;constructor(e){this.#r=e.home,this.#e=`gui/${e.uid}`,this.#i=e.envPrefix,this.#t=e.exec??ce}unitPath(e){return oe(this.#r,"Library","LaunchAgents",`${e}.plist`)}install(e){let n=this.unitPath(e.label),r=_(e,this.#i);if(H(I(n),{recursive:!0}),H(I(e.stdoutPath),{recursive:!0}),this.#n(["bootout",`${this.#e}/${e.label}`],{tolerate:!0}),this.#s(e.label),ue(n,r,{encoding:"utf8",mode:384}),this.#n(["enable",`${this.#e}/${e.label}`],{tolerate:!0}),this.#n(["bootstrap",this.#e,n]),!this.state(e.label).installed)throw new A({code:"daemon_not_loaded",message:`${e.label} was written to ${n} but launchd did not load it.`,hint:`\`launchctl bootstrap\` returned success and \`launchctl print ${this.#e}/${e.label}\` finds nothing, which usually means an earlier copy was still unloading. Try again in a moment. Over SSH with no desktop session the ${this.#e} domain is unavailable and no LaunchAgent can load at all.`})}#s(e){let n=Date.now()+Be;while(Date.now()<n){if(this.#t("launchctl",["print",`${this.#e}/${e}`]).code!==0)return;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Ue)}}uninstall(e){this.#n(["bootout",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["enable",`${this.#e}/${e}`],{tolerate:!0}),de(this.unitPath(e),{force:!0})}stop(e){this.#n(["disable",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["bootout",`${this.#e}/${e}`],{tolerate:!0})}start(e){this.#n(["enable",`${this.#e}/${e}`],{tolerate:!0}),this.#n(["bootstrap",this.#e,this.unitPath(e)])}restart(e){this.#n(["kickstart","-k",`${this.#e}/${e}`])}state(e){let n=this.#t("launchctl",["print",`${this.#e}/${e}`]),r=ee(this.#t("launchctl",["print-disabled",this.#e]).stdout).includes(e);if(n.code!==0)return{installed:!1,disabled:r,liveness:!0};let i=q(n.stdout);return{installed:!0,disabled:r,liveness:!0,print:i,...i.pid===void 0?{}:{pid:i.pid}}}labels(e){let n=Q(this.#t("launchctl",["list"]).stdout).map((i)=>i.label).filter((i)=>i.startsWith(e)),r=[];try{r=ae(oe(this.#r,"Library","LaunchAgents")).filter((i)=>i.startsWith(e)&&i.endsWith(".plist")).map((i)=>i.slice(0,-6))}catch{}return[...new Set([...n,...r])].sort()}followUp(){return[]}caution(){return}#n(e,n={}){let r=this.#t("launchctl",e);if(r.code===0||n.tolerate===!0)return r;throw new A({code:"daemon_launchctl_failed",message:`launchctl ${e.join(" ")} failed (${r.code}): ${r.stderr.trim()||"no output"}`,hint:`Code 5 usually means the service is already loaded — try \`daemon restart\`. Code 37 means an operation is still in progress; wait a moment. Code 125 or 112 means the ${this.#e} domain is unavailable, which happens over SSH with no GUI session: a LaunchAgent needs a logged-in desktop session, and the exit timeout is ${k}s.`})}}var fe=["install","uninstall","start","stop","restart","status","logs"];async function Ft(e){if(!fe.includes(e.action))throw new A({code:"cli_daemon_unknown_action",message:`daemon takes one of ${fe.join(", ")}, not "${e.action}".`,hint:`Usage: ${t.slug} daemon <action> <agent>. Run \`${t.slug} daemon --help\` for what each one does.`});let n=e.action;if(e.manifestPath!==void 0&&n!=="status"&&n!=="logs")throw new A({code:"daemon_per_agent_retired",message:`daemon ${n} no longer takes an agent — one service hosts every agent.`,hint:`\`${t.slug} daemon ${n}\` acts on that one service. Per-agent on/off is \`${t.slug} stop <agent>\` and \`${t.slug} start <agent>\`, which persist in the store rather than as a unit — so an agent you switch off stays off across a restart without the host going down with it.`});let r=e.platform??process.platform,i=Ze();if(r!=="darwin"&&r!=="linux"&&n!=="status")throw N(r,nn(i,e.manifestPath??"<manifest>"));let a=r==="darwin"||r==="linux"?rn(r,{home:j(),uid:process.getuid?.()??0,envPrefix:t.envPrefix,...e.exec===void 0?{}:{exec:e.exec},...e.env===void 0?{}:{env:e.env}}):void 0;switch(n){case"status":return await cn(e,a);case"install":return await Qe(e,i,a);case"uninstall":return an(e,a);case"start":case"stop":case"restart":return un(n,a);case"logs":return await fn(e)}}async function Qe(e,n,r){let i=x(t.slug),a=Eo(e.env),s=(r?.labels(`${t.slug}.agent.`)??[]).filter((p)=>p!==i),l=[...X({binary:n,retiring:s,servedElsewhere:(await xt(e.store)).filter((p)=>p.agentId!==Ut).map((p)=>({agentId:p.agentId,pid:p.pid,mode:p.mode}))}),...Ae(e.env).flatMap((p)=>{let m=on(p.dir);return K({agentId:p.id??p.ref,agentDir:p.dir,...p.problem===void 0?{}:{problem:p.problem},...m===void 0?{}:{envFileMode:m}})})],h={label:i,programArguments:[n.execPath,n.scriptPath,"serve","--store",P()].filter((p)=>p!==""),workingDirectory:we(e.env),stdoutPath:a.out,stderrPath:a.err,environment:tn(i),provenance:[`Generated by \`${t.slug} daemon install\`. One service hosts every agent.`,"Rewritten on every install — it names no agent, so there is nothing here to edit","when you add one. Switch an agent off with `stop <agent>`, which persists.","There are no secrets here and there never will be: a service manager echoes a","unit's environment in plaintext to anything running as this user. Each agent","reads its own credentials from the .env beside its manifest."]};if(e.dryRun===!0){if(process.stdout.write(r?.id==="systemd"?T(h,t.envPrefix):_(h,t.envPrefix)),l.length>0)process.stderr.write(ye(l));return o}for(let p of s)r?.uninstall(p);if(l.length>0)process.stdout.write(ye(l));Ge(C(a.out),{recursive:!0}),r?.install(h);let g=r?.followUp(i)??[];if(process.stdout.write(`${i} — ${g.length===0?"service installed":"unit written"}
84
+ ${u([{label:"runs",value:`${E(n.execPath)} … serve`},{label:"hosts",value:"every agent in the sandbox that is not stopped"},{label:"logs",value:E(a.err)},{label:"restarts",value:`on crash only, at most one per ${S}s`}])}
85
85
  `),g.length>0)process.stdout.write(`
86
86
  Not started yet — run these:
87
87
  ${g.map((p,m)=>` ${m+1}. ${p}`).join(`
@@ -90,13 +90,13 @@ ${g.map((p,m)=>` ${m+1}. ${p}`).join(`
90
90
  ${f}
91
91
  `);return process.stdout.write(`
92
92
  A configuration error stops it once rather than looping — \`${t.slug} daemon status\` says why.
93
- `),o}function Ze(){let e=N(process.execPath),n=N(process.argv[1]??""),r=en(M(n));return{execPath:e,scriptPath:n,...r===void 0?{}:{gitRoot:r}}}function N(e){try{return c("node:fs").realpathSync(e)}catch{return e}}function en(e){let n=e;for(let r=0;r<40;r+=1){if(ve($e(n,".git")))return n;let i=M(n);if(i===n)return;n=i}return}function nn(e,n){return`ExecStart=${e.execPath} ${e.scriptPath} serve ${n} --store ${G()}`}function tn(e){let n=B(),i=[M(N(process.execPath)),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].filter((l,h,g)=>g.indexOf(l)===h).join(":"),a={HOME:n,PATH:i,[`${t.envPrefix}SERVICE`]:e},s=process.env[`${t.envPrefix}HOME`];if(s!==void 0&&s!=="")a[`${t.envPrefix}HOME`]=s;return a}function on(e){try{return be($e(e,".env")).mode}catch{return}}function ye(e){return`${e.map((n)=>`${n.severity==="block"?"refused":"warning"}: ${n.message}
93
+ `),o}function Ze(){let e=W(process.execPath),n=W(process.argv[1]??""),r=en(C(n));return{execPath:e,scriptPath:n,...r===void 0?{}:{gitRoot:r}}}function W(e){try{return c("node:fs").realpathSync(e)}catch{return e}}function en(e){let n=e;for(let r=0;r<40;r+=1){if(ve($e(n,".git")))return n;let i=C(n);if(i===n)return;n=i}return}function nn(e,n){return`ExecStart=${e.execPath} ${e.scriptPath} serve ${n} --store ${P()}`}function tn(e){let n=j(),i=[C(W(process.execPath)),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].filter((l,h,g)=>g.indexOf(l)===h).join(":"),a={HOME:n,PATH:i,[`${t.envPrefix}SERVICE`]:e},s=process.env[`${t.envPrefix}HOME`];if(s!==void 0&&s!=="")a[`${t.envPrefix}HOME`]=s;return a}function on(e){try{return be($e(e,".env")).mode}catch{return}}function ye(e){return`${e.map((n)=>`${n.severity==="block"?"refused":"warning"}: ${n.message}
94
94
  hint: ${n.hint}`).join(`
95
95
 
96
96
  `)}
97
97
  `}function an(e,n){let r=x(t.slug),i=Eo(e.env);for(let a of(n?.labels(`${t.slug}.agent.`)??[]).filter((s)=>s!==r))n?.uninstall(a),process.stdout.write(` also removed ${a}
98
98
  `);return n?.uninstall(r),process.stdout.write(`${r} — service removed
99
- ${u([{label:"logs kept",value:k(i.err)},{label:"agents",value:"unchanged — nothing was switched off"}])}
99
+ ${u([{label:"logs kept",value:E(i.err)},{label:"agents",value:"unchanged — nothing was switched off"}])}
100
100
  `),o}function un(e,n){let r=x(t.slug);if(n===void 0)return d;if(e==="start")n.start(r);if(e==="stop")n.stop(r);if(e==="restart")n.restart(r);let i=e==="stop"?" — the whole host. It stays stopped across a login until you start it again, and no"+" agent was switched off":"";return process.stdout.write(`${r} — ${e}${e==="stop"?"ped":"ed"}${i}
101
101
  `),o}async function cn(e,n){let r=x(t.slug),i=await xt(e.store);if(e.manifestPath===void 0){if(n?.state(r).installed!==!0&&i.length===0)return process.stdout.write(`no server is installed and nothing is running
102
102
  hint: \`${t.slug} daemon install\` keeps one running after you close the terminal. One service hosts every agent.
@@ -116,12 +116,12 @@ ${y(g.tail,4)}
116
116
  `);for(let f of h)process.stdout.write(` ${f.agentId}${f.reason===void 0?"":` — ${f.reason}`}${f.disabledAt===void 0?"":` (since ${f.disabledAt})`}
117
117
  `);process.stdout.write(` \`${t.slug} start <agent>\` switches one back on — a restart alone will not.
118
118
 
119
- `)}}return s.every((g)=>g.report.healthy)?o:d}async function gn(){try{let e=await ne.open({path:G()});try{return(await e.agentState.list()).filter((n)=>!n.enabled).map((n)=>({agentId:n.agentId,...n.reason===void 0?{}:{reason:n.reason},...n.disabledAt===void 0?{}:{disabledAt:n.disabledAt}}))}finally{await e.close()}}catch{return[]}}async function hn(e,n,r){let i=r.label,a=i===void 0?void 0:n?.unitPath(i),s=i===void 0?void 0:n?.state(i),l=r.logs,h;try{let w=await ne.open({path:r.store??G()});h=await w.leases.get(r.leaseOf??e),await w.close()}catch{h=void 0}if(h!==void 0&&!Z(h.pid))h=void 0;let g=s?.print?.stderrPath??l.err,f=I(g),p={installed:a!==void 0&&ve(a)||s?.installed===!0,disabled:s?.disabled??!1,...s?.pid===void 0?{}:{pid:s.pid},...s?.print?.runs===void 0?{}:{runs:s.print.runs},...s?.print?.lastExitCode===void 0?{}:{lastExitCode:s.print.lastExitCode},stderrPath:k(g),...f===void 0?{}:{stderrBytes:f},...h===void 0?{}:{leasePid:h.pid,leaseMode:h.mode,leaseStartedAt:h.startedAt,uptimeMs:Date.now()-Date.parse(h.startedAt)}},m=J(e,p),v=z(W(l.out,200));return{agentId:e,report:m,tail:m.wantsStderrTail?W(g,20):"",attention:v}}async function fn(e){let n=e.manifestPath===void 0?void 0:xe(e.manifestPath),r=n??x(t.slug),i=n===void 0?Eo(e.env):pn(n);if(e.truncate===!0){for(let s of[i.out,i.err])try{c("node:fs").writeFileSync(s,"")}catch{}return process.stdout.write(`${r} — logs truncated
120
- `),o}let a=W(i.err,e.lines??40);if(process.stdout.write(a===""?`${k(i.err)} is empty
119
+ `)}}return s.every((g)=>g.report.healthy)?o:d}async function gn(){try{let e=await ne.open({path:P()});try{return(await e.agentState.list()).filter((n)=>!n.enabled).map((n)=>({agentId:n.agentId,...n.reason===void 0?{}:{reason:n.reason},...n.disabledAt===void 0?{}:{disabledAt:n.disabledAt}}))}finally{await e.close()}}catch{return[]}}async function hn(e,n,r){let i=r.label,a=i===void 0?void 0:n?.unitPath(i),s=i===void 0?void 0:n?.state(i),l=r.logs,h;try{let w=await ne.open({path:r.store??P()});h=await w.leases.get(r.leaseOf??e),await w.close()}catch{h=void 0}if(h!==void 0&&!Z(h.pid))h=void 0;let g=s?.print?.stderrPath??l.err,f=M(g),p={installed:a!==void 0&&ve(a)||s?.installed===!0,disabled:s?.disabled??!1,...s?.pid===void 0?{}:{pid:s.pid},...s?.print?.runs===void 0?{}:{runs:s.print.runs},...s?.print?.lastExitCode===void 0?{}:{lastExitCode:s.print.lastExitCode},stderrPath:E(g),...f===void 0?{}:{stderrBytes:f},...h===void 0?{}:{leasePid:h.pid,leaseMode:h.mode,leaseStartedAt:h.startedAt,uptimeMs:Date.now()-Date.parse(h.startedAt)}},m=J(e,p),v=z(B(l.out,200));return{agentId:e,report:m,tail:m.wantsStderrTail?B(g,20):"",attention:v}}async function fn(e){let n=e.manifestPath===void 0?void 0:xe(e.manifestPath),r=n??x(t.slug),i=n===void 0?Eo(e.env):pn(n);if(e.truncate===!0){for(let s of[i.out,i.err])try{c("node:fs").writeFileSync(s,"")}catch{}return process.stdout.write(`${r} — logs truncated
120
+ `),o}let a=B(i.err,e.lines??40);if(process.stdout.write(a===""?`${E(i.err)} is empty
121
121
  `:`${a}
122
- `),e.follow!==!0)return o;return await te([{path:i.err,label:"stderr"},{path:i.out,label:"stdout"}],yn(),{offsets:{[i.err]:I(i.err)??0,[i.out]:I(i.out)??0},intervalMs:wa}),o}function yn(){let e=!1,n,r=()=>{e=!0,n?.()};return process.on("SIGINT",r),U(()=>{process.off("SIGINT",r)}),{sizeOf:(i)=>I(i),read:(i,a,s)=>{try{let l=Ke(i,"r");try{let h=Buffer.alloc(s-a),g=ze(l,h,0,h.length,a);return h.subarray(0,g).toString("utf8")}finally{je(l)}}catch{return""}},write:(i)=>void process.stdout.write(i),wait:(i)=>new Promise((a)=>{if(e){a();return}let s=setTimeout(a,i);n=()=>{clearTimeout(s),a()}}),stopped:()=>e}}function xe(e){let n=F(e);if(n.id===void 0||n.id==="")throw new A({code:"cli_daemon_agent_id_missing",message:`${e} declares no id, so there is no stable name to install a service under.`,hint:"A service label is derived from the manifest id and has to survive a rename of the directory. Add `id: <name>` to the manifest."});return n.id}function k(e){return oA(Ye(e),B())}function I(e){try{return be(e).size}catch{return}}function W(e,n){try{let r=Xe(e,"utf8").trimEnd();if(r==="")return"";return r.split(`
122
+ `),e.follow!==!0)return o;return await te([{path:i.err,label:"stderr"},{path:i.out,label:"stdout"}],yn(),{offsets:{[i.err]:M(i.err)??0,[i.out]:M(i.out)??0},intervalMs:wa}),o}function yn(){let e=!1,n,r=()=>{e=!0,n?.()};return process.on("SIGINT",r),U(()=>{process.off("SIGINT",r)}),{sizeOf:(i)=>M(i),read:(i,a,s)=>{try{let l=Ke(i,"r");try{let h=Buffer.alloc(s-a),g=ze(l,h,0,h.length,a);return h.subarray(0,g).toString("utf8")}finally{je(l)}}catch{return""}},write:(i)=>void process.stdout.write(i),wait:(i)=>new Promise((a)=>{if(e){a();return}let s=setTimeout(a,i);n=()=>{clearTimeout(s),a()}}),stopped:()=>e}}function xe(e){let n=F(e);if(n.id===void 0||n.id==="")throw new A({code:"cli_daemon_agent_id_missing",message:`${e} declares no id, so there is no stable name to install a service under.`,hint:"A service label is derived from the manifest id and has to survive a rename of the directory. Add `id: <name>` to the manifest."});return n.id}function E(e){return oA(Ye(e),j())}function M(e){try{return be(e).size}catch{return}}function B(e,n){try{let r=Xe(e,"utf8").trimEnd();if(r==="")return"";return r.split(`
123
123
  `).slice(-n).join(`
124
- `)}catch{return""}}var wt=E(t.envPrefix);import{existsSync as mn}from"node:fs";function xr(e=process.env){return mn("/.dockerenv")||e.container!==void 0}function vn(e){let n=e.env??process.env;if(!e.needsServer)return"command-needs-no-server";if(e.disabled===!0)return"disabled-by-flag";if(n[`${t.envPrefix}SERVICE`]!==void 0)return"is-the-service";if(n[`${t.envPrefix}NO_BOOTSTRAP`]!==void 0)return"disabled-by-env";if(xr(n))return"in-container";if(n.CI!==void 0)return"in-ci";return}async function Ar(e){let n=vn(e);if(n!==void 0)return{kind:"skipped",reason:n};if((await xt(e.store)).length>0)return{kind:"already"};let i=e.platform??process.platform;if(!ge(i))return{kind:"manual",lines:[`${t.slug} daemon install`]};let a=e.install;if(a===void 0)return{kind:"failed",message:"no installer was supplied",hint:"This is a wiring mistake rather than a configuration one: `ensureServer` is called with an `install` callback by `index.ts`."};try{return await a()}catch(s){return{kind:"failed",message:s instanceof Error?s.message:String(s),hint:`The command ran anyway. \`${t.slug} daemon install\` reports the same failure with more detail — on macOS over SSH it is usually that a LaunchAgent needs a logged-in desktop session.`}}}function bA(e){switch(e.kind){case"started":return`started the background server · \`${t.slug} daemon uninstall\` to undo
124
+ `)}catch{return""}}var wt=O(t.envPrefix);import{existsSync as mn}from"node:fs";function xr(e=process.env){return mn("/.dockerenv")||e.container!==void 0}function vn(e){let n=e.env??process.env;if(!e.needsServer)return"command-needs-no-server";if(e.disabled===!0)return"disabled-by-flag";if(n[`${t.envPrefix}SERVICE`]!==void 0)return"is-the-service";if(n[`${t.envPrefix}NO_BOOTSTRAP`]!==void 0)return"disabled-by-env";if(xr(n))return"in-container";if(n.CI!==void 0)return"in-ci";return}async function Ar(e){let n=vn(e);if(n!==void 0)return{kind:"skipped",reason:n};if((await xt(e.store)).length>0)return{kind:"already"};let i=e.platform??process.platform;if(!ge(i))return{kind:"manual",lines:[`${t.slug} daemon install`]};let a=e.install;if(a===void 0)return{kind:"failed",message:"no installer was supplied",hint:"This is a wiring mistake rather than a configuration one: `ensureServer` is called with an `install` callback by `index.ts`."};try{return await a()}catch(s){return{kind:"failed",message:s instanceof Error?s.message:String(s),hint:`The command ran anyway. \`${t.slug} daemon install\` reports the same failure with more detail — on macOS over SSH it is usually that a LaunchAgent needs a logged-in desktop session.`}}}function bA(e){switch(e.kind){case"started":return`started the background server · \`${t.slug} daemon uninstall\` to undo
125
125
  `;case"manual":return`no server is running · ${e.lines.join(", then ")}
126
126
  `;case"failed":return`could not start a background server: ${e.message}
127
127
  hint: ${e.hint}
@@ -146,8 +146,8 @@ On the phone: WhatsApp › Settings › Linked devices › Link with phone numbe
146
146
  `),await p(e.pairWaitMs??kn,()=>s);if(s)return n(`
147
147
  Paired. WhatsApp is linked to +${e.number}.
148
148
  `),"paired";return"code-shown"}catch{return"no-code"}finally{await i.stop().catch(()=>{})}}function En(e){return e.length===8?`${e.slice(0,4)} ${e.slice(4)}`:e}function es(e){return` Pair WhatsApp later: \`${t.slug} channels pair ${e} wa\` — or from the web UI.
149
- `}import{existsSync as Se,readFileSync as Pe,rmSync as An}from"node:fs";import{dirname as ke,isAbsolute as On,join as Ee,resolve as Rn}from"node:path";var Oe=new Map([["telegram","tokenEnv"]]);function or(e){let r=F(e).channels??[],i=Hr(e),a=Se(i)?Tt(Pe(i,"utf8")):{};return r.map((s)=>{let l=Oe.get(s.type),h=l===void 0?void 0:typeof s[l]==="string"?s[l]:void 0;return{id:s.id,type:s.type,enabled:s.enabled!==!1,...h===void 0?{}:{credentialEnv:h},...h===void 0?{}:{credentialSet:(a[h]??"")!==""},...typeof s.pairWith==="string"?{pairWith:s.pairWith}:{},...s.type==="whatsapp"?{paired:Tn(e,s)}:{},...typeof s.authDir==="string"?{authDir:s.authDir}:{},allowFrom:s.allowFrom??[]}})}async function Vn(e,n,r){let i=F(e).channels??[],a=i.find((s)=>s.id===n);if(a===void 0)throw j(n,i.map((s)=>s.id));if(a.enabled!==!1===r)return{note:`Channel "${n}" is already ${r?"connected":"disconnected"}.`,changed:!1};return await Le({file:e,path:["channels"],value:i.map((s)=>s.id===n?{...s,enabled:r}:{...s})}),{note:r?`Channel "${n}" is connected — it starts at the agent's next start.`:`Channel "${n}" is disconnected. A disabled channel is never constructed, so it reads no credential and opens no socket.`,changed:!0}}function Wn(e,n,r){let i=F(e).channels??[],a=i.find((g)=>g.id===n);if(a===void 0)throw j(n,i.map((g)=>g.id));let s=Oe.get(a.type),l=s===void 0?void 0:typeof a[s]==="string"?a[s]:void 0;if(l===void 0)throw new A({code:"channel_has_no_credential",message:`Channel "${n}" (type ${a.type}) keeps no credential in the .env.`,hint:a.type==="whatsapp"?"WhatsApp is paired by scanning a QR, not by a value anybody types. Use `channels unpair` to forget the current pairing and scan a new code.":"Only a channel whose manifest entry names an environment variable has one to set. Check the entry's own fields.",field:`channels[${n}]`});return{note:`${Je(e,l,r).note}. It is read at the agent's next start.`,variable:l}}function j(e,n){return new A({code:"channel_unknown",message:`This agent declares no channel with id "${e}".`,hint:n.length===0?"It declares no channels at all. Add one with `config set <agent> channels`, or answer the channel questions in `init`.":`Declared: ${n.join(", ")}. The id is the channel's own, not its type.`,field:"channelId"})}function zn(e,n){let r=F(e).channels??[],i=r.find((s)=>s.id===n);if(i===void 0)throw j(n,r.map((s)=>s.id));let a=_n(e,i);if(a===void 0)throw new A({code:"channel_has_no_pairing",message:`Channel "${n}" (type ${i.type}) stores no pairing.`,hint:"Only a channel linked by scanning a code has one to forget. A credential somebody typed is changed with `channels credential`, and a channel is switched off with `channels disconnect`.",field:`channels[${n}]`});return An(a,{recursive:!0,force:!0}),{note:`Forgot the pairing — deleted ${a}. The next start offers a new code to scan; the old device may still be listed on the phone, which is the only place it can be removed.`}}function _n(e,n){if(n.type!=="whatsapp")return;let r=typeof n.authDir==="string"?n.authDir:"./.whatsapp";return Ee(ke(e),r)}function Tn(e,n){let r=typeof n.authDir==="string"?n.authDir:"./.whatsapp",i=On(r)?r:Rn(ke(e),r),a=Ee(i,"creds.json");if(!Se(a))return!1;try{return JSON.parse(Pe(a,"utf8")).registered===!0}catch{return!1}}
149
+ `}import{existsSync as Se,readFileSync as Pe,rmSync as An}from"node:fs";import{dirname as ke,isAbsolute as On,join as Ee,resolve as Rn}from"node:path";var Oe=new Map([["telegram","tokenEnv"]]);function or(e){let r=F(e).channels??[],i=Hr(e),a=Se(i)?Tt(Pe(i,"utf8")):{};return r.map((s)=>{let l=Oe.get(s.type),h=l===void 0?void 0:typeof s[l]==="string"?s[l]:void 0;return{id:s.id,type:s.type,enabled:s.enabled!==!1,...h===void 0?{}:{credentialEnv:h},...h===void 0?{}:{credentialSet:(a[h]??"")!==""},...typeof s.pairWith==="string"?{pairWith:s.pairWith}:{},...s.type==="whatsapp"?{paired:Tn(e,s)}:{},...typeof s.authDir==="string"?{authDir:s.authDir}:{},allowFrom:s.allowFrom??[]}})}async function Vn(e,n,r){let i=F(e).channels??[],a=i.find((s)=>s.id===n);if(a===void 0)throw G(n,i.map((s)=>s.id));if(a.enabled!==!1===r)return{note:`Channel "${n}" is already ${r?"connected":"disconnected"}.`,changed:!1};return await Le({file:e,path:["channels"],value:i.map((s)=>s.id===n?{...s,enabled:r}:{...s})}),{note:r?`Channel "${n}" is connected — it starts at the agent's next start.`:`Channel "${n}" is disconnected. A disabled channel is never constructed, so it reads no credential and opens no socket.`,changed:!0}}function Wn(e,n,r){let i=F(e).channels??[],a=i.find((g)=>g.id===n);if(a===void 0)throw G(n,i.map((g)=>g.id));let s=Oe.get(a.type),l=s===void 0?void 0:typeof a[s]==="string"?a[s]:void 0;if(l===void 0)throw new A({code:"channel_has_no_credential",message:`Channel "${n}" (type ${a.type}) keeps no credential in the .env.`,hint:a.type==="whatsapp"?"WhatsApp is paired by scanning a QR, not by a value anybody types. Use `channels unpair` to forget the current pairing and scan a new code.":"Only a channel whose manifest entry names an environment variable has one to set. Check the entry's own fields.",field:`channels[${n}]`});return{note:`${Je(e,l,r).note}. It is read at the agent's next start.`,variable:l}}function G(e,n){return new A({code:"channel_unknown",message:`This agent declares no channel with id "${e}".`,hint:n.length===0?"It declares no channels at all. Add one with `config set <agent> channels`, or answer the channel questions in `init`.":`Declared: ${n.join(", ")}. The id is the channel's own, not its type.`,field:"channelId"})}function zn(e,n){let r=F(e).channels??[],i=r.find((s)=>s.id===n);if(i===void 0)throw G(n,r.map((s)=>s.id));let a=_n(e,i);if(a===void 0)throw new A({code:"channel_has_no_pairing",message:`Channel "${n}" (type ${i.type}) stores no pairing.`,hint:"Only a channel linked by scanning a code has one to forget. A credential somebody typed is changed with `channels credential`, and a channel is switched off with `channels disconnect`.",field:`channels[${n}]`});return An(a,{recursive:!0,force:!0}),{note:`Forgot the pairing — deleted ${a}. The next start offers a new code to scan; the old device may still be listed on the phone, which is the only place it can be removed.`}}function _n(e,n){if(n.type!=="whatsapp")return;let r=typeof n.authDir==="string"?n.authDir:"./.whatsapp";return Ee(ke(e),r)}function Tn(e,n){let r=typeof n.authDir==="string"?n.authDir:"./.whatsapp",i=On(r)?r:Rn(ke(e),r),a=Ee(i,"creds.json");if(!Se(a))return!1;try{return JSON.parse(Pe(a,"utf8")).registered===!0}catch{return!1}}
150
150
  export{tr,rn,Ft,xr,Ar,bA,nr,jn,OA,NA,sn,Jn,qn,es,or,Vn,Wn,zn};
151
151
 
152
- //# debugId=E3E27176B81D368464756E2164756E21
153
- //# sourceMappingURL=index-z157at3s.js.map
152
+ //# debugId=0BBF4865FFA0249664756E2164756E21
153
+ //# sourceMappingURL=index-dpcm1j62.js.map
@@ -15,6 +15,6 @@
15
15
  "/**\n * Connect, disconnect, re-credential and unpair a channel — the four things a person does to one.\n *\n * ## Why this is a module rather than four call sites\n *\n * Every one of these was *possible* already and reachable from nowhere obvious. Disabling a channel\n * meant `config set <agent> channels '[{...the whole list again...}]'`; changing a token meant\n * knowing that `tokenEnv` names a variable and that `config env` writes it; relinking WhatsApp meant\n * finding a directory and deleting it. A capability reachable only by somebody who already knows the\n * field names is a capability the surface is hiding — the standing rule that put every provider in\n * `init`, and the same one applies to the thing a person touches most after creating an agent.\n *\n * So: one module, read by the `channels` command and by the HTTP routes the browser calls. Two\n * surfaces over one implementation, which is the only way they cannot disagree — and the lesson this\n * project has paid for repeatedly, most recently where `validate` and `run` disagreed about a cold\n * Composio cache.\n *\n * ## What \"connect\" means, and what it cannot mean\n *\n * `enabled: true` in the manifest, and nothing more. A channel is constructed at boot and\n * `Runtime.create` is what starts it, so flipping the flag on a running agent takes effect at its\n * next start — `manifest_changed` already says so for every other setting and this is no different.\n * Pretending otherwise by hot-starting a transport here would make \"connected\" mean two different\n * things depending on which surface you asked.\n */\n\nimport { existsSync, readFileSync, rmSync } from \"node:fs\"\nimport { dirname, isAbsolute, join, resolve } from \"node:path\"\nimport {\n type AgentManifest,\n editManifest,\n HarnessError,\n parseDotEnv,\n readManifestHeader,\n} from \"@dispach/core\"\nimport { applySecret, envPathOf } from \"#lib/config-apply\"\n\n/** One channel as every surface reports it, before any runtime state is layered on. */\nexport interface ChannelEntry {\n readonly id: string\n readonly type: string\n readonly enabled: boolean\n /** The env var this channel's credential lives in, when it has one. */\n readonly credentialEnv?: string\n /**\n * Whether that variable currently has a value.\n *\n * The **name and whether it is set**, never the value. A surface that could read a credential\n * back is one a leaked operator key turns into a credential dump, and nothing needs it: the only\n * question anybody asks is \"is this filled in\".\n */\n readonly credentialSet?: boolean\n /**\n * The WhatsApp account this channel links to, when one is configured.\n *\n * Its presence is what decides *how* pairing happens — a code typed into the phone rather than\n * a QR — so a listing that did not carry it had to describe the method with a constant, and\n * that constant said \"paired by QR\" for a channel that pairs by code and has never paired.\n */\n readonly pairWith?: string\n /**\n * Whether a pairing already exists on disk.\n *\n * A fact about the filesystem rather than about a running process, which is exactly why it\n * belongs in a manifest-reading listing: \"is this linked\" is answerable without a host, and\n * answering it is the difference between \"connected\" and something true.\n */\n readonly paired?: boolean\n /** Where a WhatsApp session lives, as written. Relative paths are relative to the manifest. */\n readonly authDir?: string\n /** Senders this channel accepts. Inbound only. */\n readonly allowFrom: readonly string[]\n}\n\n/**\n * Which manifest field holds a channel's credential variable, by channel type.\n *\n * A small table rather than a convention, because it *is* small and a convention would be a guess:\n * `tokenEnv` is Telegram's word and a plugin picks its own. A type that is not here has no\n * credential in the `.env` — WhatsApp is the case, and its pairing is `reset` rather than a value.\n */\nconst CREDENTIAL_FIELD: ReadonlyMap<string, string> = new Map([[\"telegram\", \"tokenEnv\"]])\n\nexport function channelsOf(manifestPath: string): readonly ChannelEntry[] {\n const header = readManifestHeader(manifestPath)\n const declared = header.channels ?? []\n const envPath = envPathOf(manifestPath)\n const env = existsSync(envPath) ? parseDotEnv(readFileSync(envPath, \"utf8\")) : {}\n\n return declared.map((channel) => {\n const field = CREDENTIAL_FIELD.get(channel.type)\n const variable =\n field === undefined\n ? undefined\n : typeof (channel as Record<string, unknown>)[field] === \"string\"\n ? ((channel as Record<string, unknown>)[field] as string)\n : undefined\n return {\n id: channel.id,\n type: channel.type,\n // Absent means enabled, which is the schema's default and what a reader expects.\n enabled: channel.enabled !== false,\n ...(variable === undefined ? {} : { credentialEnv: variable }),\n ...(variable === undefined ? {} : { credentialSet: (env[variable] ?? \"\") !== \"\" }),\n ...(typeof (channel as Record<string, unknown>).pairWith === \"string\"\n ? { pairWith: (channel as Record<string, unknown>).pairWith as string }\n : {}),\n ...(channel.type === \"whatsapp\"\n ? { paired: hasPairing(manifestPath, channel as Record<string, unknown>) }\n : {}),\n ...(typeof (channel as Record<string, unknown>).authDir === \"string\"\n ? { authDir: (channel as Record<string, unknown>).authDir as string }\n : {}),\n allowFrom: channel.allowFrom ?? [],\n }\n })\n}\n\n/**\n * Flip one channel's `enabled`, leaving every other entry byte-identical.\n *\n * Read-modify-write through `editManifest`, the one manifest writer, rather than asking a caller to\n * send the whole `channels` list back. Sending the list is what `config set` does and it is right\n * for a person editing YAML; for a button it would mean the browser reconstructing an array it did\n * not author, and two clients racing on that lose an entry rather than a flag.\n */\nexport async function setChannelEnabled(\n manifestPath: string,\n channelId: string,\n enabled: boolean,\n): Promise<{ readonly note: string; readonly changed: boolean }> {\n const entries = readManifestHeader(manifestPath).channels ?? []\n const existing = entries.find((entry) => entry.id === channelId)\n if (existing === undefined)\n throw unknownChannel(\n channelId,\n entries.map((e) => e.id),\n )\n if ((existing.enabled !== false) === enabled) {\n return {\n note: `Channel \"${channelId}\" is already ${enabled ? \"connected\" : \"disconnected\"}.`,\n changed: false,\n }\n }\n\n await editManifest({\n file: manifestPath,\n path: [\"channels\"],\n value: entries.map((entry) =>\n entry.id === channelId ? { ...entry, enabled } : { ...entry },\n ),\n })\n return {\n note: enabled\n ? `Channel \"${channelId}\" is connected — it starts at the agent's next start.`\n : `Channel \"${channelId}\" is disconnected. A disabled channel is never constructed, so it reads no credential and opens no socket.`,\n changed: true,\n }\n}\n\n/**\n * Write a channel's credential into the `.env` beside the manifest.\n *\n * The variable is the one the *manifest* names, resolved here rather than taken from the caller: a\n * surface that let a client name the variable would let it write any variable at all, including the\n * API token this server authenticates with.\n */\nexport function setChannelCredential(\n manifestPath: string,\n channelId: string,\n value: string,\n): { readonly note: string; readonly variable: string } {\n const entries = readManifestHeader(manifestPath).channels ?? []\n const existing = entries.find((entry) => entry.id === channelId)\n if (existing === undefined)\n throw unknownChannel(\n channelId,\n entries.map((e) => e.id),\n )\n\n const field = CREDENTIAL_FIELD.get(existing.type)\n const variable =\n field === undefined\n ? undefined\n : typeof (existing as Record<string, unknown>)[field] === \"string\"\n ? ((existing as Record<string, unknown>)[field] as string)\n : undefined\n if (variable === undefined) {\n throw new HarnessError({\n code: \"channel_has_no_credential\",\n message: `Channel \"${channelId}\" (type ${existing.type}) keeps no credential in the .env.`,\n hint:\n existing.type === \"whatsapp\"\n ? \"WhatsApp is paired by scanning a QR, not by a value anybody types. Use `channels unpair` to forget the current pairing and scan a new code.\"\n : \"Only a channel whose manifest entry names an environment variable has one to set. Check the entry's own fields.\",\n field: `channels[${channelId}]`,\n })\n }\n\n const applied = applySecret(manifestPath, variable, value)\n return {\n note: `${applied.note}. It is read at the agent's next start.`,\n variable,\n }\n}\n\nfunction unknownChannel(channelId: string, known: readonly string[]): HarnessError {\n return new HarnessError({\n code: \"channel_unknown\",\n message: `This agent declares no channel with id \"${channelId}\".`,\n hint:\n known.length === 0\n ? \"It declares no channels at all. Add one with `config set <agent> channels`, or answer the channel questions in `init`.\"\n : `Declared: ${known.join(\", \")}. The id is the channel's own, not its type.`,\n field: \"channelId\",\n })\n}\n\n/**\n * Delete a stored pairing on disk.\n *\n * The on-disk path, used when no live transport can be asked — a stopped agent, or one whose\n * channels a `run`-mode host never started. Both routes end in the same state, which is the state a\n * first start produces.\n */\nexport function unpairChannel(manifestPath: string, channelId: string): { readonly note: string } {\n const entries = readManifestHeader(manifestPath).channels ?? []\n const existing = entries.find((entry) => entry.id === channelId)\n if (existing === undefined)\n throw unknownChannel(\n channelId,\n entries.map((e) => e.id),\n )\n const dir = pairingDirOf(manifestPath, existing)\n if (dir === undefined) {\n throw new HarnessError({\n code: \"channel_has_no_pairing\",\n message: `Channel \"${channelId}\" (type ${existing.type}) stores no pairing.`,\n hint: \"Only a channel linked by scanning a code has one to forget. A credential somebody typed is changed with `channels credential`, and a channel is switched off with `channels disconnect`.\",\n field: `channels[${channelId}]`,\n })\n }\n rmSync(dir, { recursive: true, force: true })\n return {\n note: `Forgot the pairing — deleted ${dir}. The next start offers a new code to scan; the old device may still be listed on the phone, which is the only place it can be removed.`,\n }\n}\n\n/** Where a channel that stores a pairing keeps it, so a stopped agent can be unpaired too. */\nexport function pairingDirOf(\n manifestPath: string,\n channel: { readonly type: string; readonly authDir?: unknown },\n): string | undefined {\n if (channel.type !== \"whatsapp\") return undefined\n const configured = typeof channel.authDir === \"string\" ? channel.authDir : \"./.whatsapp\"\n return join(dirname(manifestPath), configured)\n}\n\nexport type { AgentManifest }\n\n/**\n * Whether this WhatsApp session is actually linked to an account.\n *\n * **`creds.json` existing is not the answer**, which is the second false claim this listing had:\n * Baileys writes that file the moment it connects, carrying freshly generated keys and\n * `registered: false`, so a channel that has never paired in its life has one. Measured on a live\n * run — the listing said `linked` and `needs_input` in the same row. `registered` inside it is the\n * real signal and is the same field the transport's own pairing guard reads.\n *\n * Unreadable or malformed reads as **not** linked: the cost of saying \"not linked yet\" about a\n * working channel is a person re-running a command, and the cost of the reverse is somebody\n * waiting for a pairing that nothing is going to offer.\n */\nfunction hasPairing(manifestPath: string, channel: Record<string, unknown>): boolean {\n const configured = typeof channel.authDir === \"string\" ? channel.authDir : \"./.whatsapp\"\n const dir = isAbsolute(configured) ? configured : resolve(dirname(manifestPath), configured)\n const file = join(dir, \"creds.json\")\n if (!existsSync(file)) return false\n try {\n const creds = JSON.parse(readFileSync(file, \"utf8\")) as { registered?: unknown }\n return creds.registered === true\n } catch {\n return false\n }\n}\n"
16
16
  ],
17
17
  "mappings": ";kaAoBA,oBACI,iBACA,gBACA,eACA,mBACA,eACA,eACA,iBAEJ,kBAAS,gBACT,kBAAS,UAAS,cAAM,mBC4CjB,SAAS,CAAa,CAAC,EAA8C,CACxE,IAAM,EAAiB,CAAC,EAExB,GAAI,EAAM,UAAY,OAClB,EAAI,KAAK,CACL,KAAM,0BACN,SAAU,OACV,QAAS,UAAU,EAAM,+BAA+B,EAAM,UAC9D,KAAM,qLACV,CAAC,EAGL,GAAI,EAAM,cAAgB,SAAc,EAAM,YAAc,MAAW,EACnE,EAAI,KAAK,CACL,KAAM,4BACN,SAAU,OACV,QAAS,GAAG,EAAM,2BAA2B,EAAM,YAAc,KAAO,SAAS,CAAC,gCAClF,KAAM,qLAAqL,EAAM,kBACrM,CAAC,EAGL,OAAO,EAGJ,SAAS,EAAc,CAAC,EAAyC,CACpE,IAAM,EAAiB,CAAC,EAExB,GAAI,EAAO,UAAY,OACnB,EAAI,KAAK,CACL,KAAM,4BACN,SAAU,OACV,QAAS,0BAA0B,EAAO,wCAAwC,EAAO,WACzF,KAAM,8OACV,CAAC,EAGL,GAAI,6BAA6B,KAAK,EAAO,QAAQ,EACjD,EAAI,KAAK,CACL,KAAM,2BACN,SAAU,OACV,QAAS,iDAAiD,EAAO,WACjE,KAAM,uMACV,CAAC,EAGL,OAAO,EA2BJ,SAAS,CAAc,CAAC,EAAiD,CAC5E,IAAM,EAAiB,CAAC,EAExB,QAAW,KAAS,EAAM,SACtB,EAAI,KAAK,CACL,KAAM,2BACN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Ae,GAC9B,KAAM,CACJ,MAAO",
18
- "debugId": "E3E27176B81D368464756E2164756E21",
18
+ "debugId": "0BBF4865FFA0249664756E2164756E21",
19
19
  "names": []
20
20
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{t,po,Xt}from"./index-qg9bn980.js";var mr=`---
2
+ import{t,po,Xt}from"./index-hpvfqq6r.js";var mr=`---
3
3
  name: {{SKILL_NAME}}
4
4
  description: Replace this description with what the skill does and when to use it, naming the specific words someone would type — file formats, tool names, the error they are looking at. Selection is lexical and this sentence is all it has.
5
5
  metadata:
@@ -426,4 +426,4 @@ What they brought me in for: ${r}.`,REMINDER_RULE:a}}var i=(e)=>`# ── ${e} $
426
426
  export{mr,lo,ze,Vt,FA,Io,En,uo,UA,Sr,Cn,at,aA,oi,Wt,xA,wr};
427
427
 
428
428
  //# debugId=62C847321C06FD2464756E2164756E21
429
- //# sourceMappingURL=index-kjqksgch.js.map
429
+ //# sourceMappingURL=index-dv9pdjy4.js.map
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import{A,Ne,lA,IA}from"./index-qg9bn980.js";import{Gt,on}from"./index-gq1npngp.js";import{$n,Xn,Je}from"./index-fcsg95m5.js";import{u,v,Q,y}from"./index-3vzf253k.js";import{readFileSync as c}from"node:fs";function WA(n){if(n===void 0||n===null)return"(not set)";if(typeof n==="string")return n===""?'""':n;if(typeof n==="boolean"||typeof n==="number")return String(n);return JSON.stringify(n)}function h(n){return n.split(/[.[]/)[0]??n}function Li(n,e){let t=[`${e}`,""],i=new Map;for(let r of n){let a=h(r.setting.path);i.set(a,[...i.get(a)??[],r])}let o=!0;for(let[r,a]of i){t.push(v(r,o)),o=!1;for(let s of a){let l=s.setting.agentListed?"":" · yours only",g=s.setting.via===void 0?"":` · set with \`${s.setting.via}\``,p=s.setting.confirm===void 0?"":" · asks first";t.push(u([{label:s.setting.path,value:WA(s.value)}]),y(`${s.setting.means}${l}${g}${p}`,4))}}return t.push("","A change takes effect the next time the agent starts. `yours only` marks a field the agent is","refused: what it may do is its to ask for, where it writes and who may reach it are yours."),t.join(`
2
+ import{A,Ne,lA,IA}from"./index-hpvfqq6r.js";import{Gt,on}from"./index-mjfv7k5w.js";import{$n,Xn,Je}from"./index-sh44ymqz.js";import{u,v,Q,y}from"./index-3vzf253k.js";import{readFileSync as c}from"node:fs";function WA(n){if(n===void 0||n===null)return"(not set)";if(typeof n==="string")return n===""?'""':n;if(typeof n==="boolean"||typeof n==="number")return String(n);return JSON.stringify(n)}function h(n){return n.split(/[.[]/)[0]??n}function Li(n,e){let t=[`${e}`,""],i=new Map;for(let r of n){let a=h(r.setting.path);i.set(a,[...i.get(a)??[],r])}let o=!0;for(let[r,a]of i){t.push(v(r,o)),o=!1;for(let s of a){let l=s.setting.agentListed?"":" · yours only",g=s.setting.via===void 0?"":` · set with \`${s.setting.via}\``,p=s.setting.confirm===void 0?"":" · asks first";t.push(u([{label:s.setting.path,value:WA(s.value)}]),y(`${s.setting.means}${l}${g}${p}`,4))}}return t.push("","A change takes effect the next time the agent starts. `yours only` marks a field the agent is","refused: what it may do is its to ask for, where it writes and who may reach it are yours."),t.join(`
3
3
  `)}function Pi(n,e){return[u([{label:n.path,value:WA(e)}]),y(n.means,4),...n.toAgent===void 0?[]:[y(`to the agent: ${n.toAgent}`,4)]].join(`
4
4
  `)}function Gi(n,e){if(n.confirm===void 0)return;if(n.path==="tools.untrusted.onMutate"&&String(e).toLowerCase()!=="allow")return;return n.confirm}function Fi(n){let e=[u([{label:"set",value:`${n.path} = ${WA(n.after)}`},{label:"was",value:n.before===void 0?"(not set)":WA(n.before)},{label:"file",value:n.file}])];if(n.reflowed)e.push("",Q("the block could not be edited in place, so the file was re-serialised — it is valid, and comments may have moved"));if(n.running!==void 0)e.push("",Q(`this agent is running (pid ${n.running.pid}, ${n.running.mode}) and holds its settings for its lifetime — the change applies after ${n.restartHint}`));for(let t of n.pending)e.push(Q(`${t.name} is not set — ${t.why}`)),e.push(Q(`fill it in with \`config env <agent> ${t.name}\``));return e.join(`
5
5
  `)}function Ui(){return IA.filter((n)=>n.via===void 0&&!/[[<]/.test(n.path)).map((n)=>n.path)}function zA(n){if(typeof n!=="object"||n===null)return[];let e=n,t=[],i=(s,l)=>{if(typeof s==="string"&&s!=="")t.push({name:s,why:l})},o=d(e.model);for(let s of["main","selector","compactor"]){let l=d(o?.[s]);i(l?.apiKeyEnv,"the manifest will not load until it is set")}if(Array.isArray(e.channels))for(let s of e.channels){let l=d(s);if(l===void 0||l.enabled===!1)continue;i(l.tokenEnv,`the ${String(l.id??l.type??"channel")} channel is read at boot, so the agent will not start until it is set`)}let r=d(e.server);if(r?.enabled===!0)i(r.tokenEnv,"the HTTP API would accept unauthenticated requests. This does not stop the agent starting");let a=d(d(e.tools)?.providers);for(let[s,l]of Object.entries(a??{}))i(d(l)?.apiKeyEnv,`the ${s} provider's tools will not work until it is set`);return t}function d(n){if(typeof n!=="object"||n===null||Array.isArray(n))return;return n}function qo(n,e){return n.filter((t)=>e[t.name]===void 0||e[t.name]==="")}function f(n,e){let t=[],i=new Map;for(let o of n){if(o.setting.via!==void 0||/[[<]/.test(o.setting.path))continue;let r=o.setting.path.split(".")[0]??o.setting.path;i.set(r,[...i.get(r)??[],o])}for(let[o,r]of i){t.push({kind:"heading",label:o});for(let a of r)t.push({kind:"setting",setting:a.setting,value:a.value})}if(e.channels.length>0){t.push({kind:"heading",label:"who may reach it"});for(let o of e.channels)t.push({kind:"allow",channelId:o.id,channelType:o.type,handles:o.allowFrom})}if(e.secrets.length>0){t.push({kind:"heading",label:"secrets — written to the .env, never shown"});for(let o of e.secrets)t.push({kind:"secret",name:o.name,why:o.why,present:e.present(o.name)})}return t}function Vo(n){let e=c(n,"utf8");return IA.map((t)=>{if(t.path==="channels[].allowFrom"){let i=Ne(e,["channels"]);if(!Array.isArray(i))return{setting:t,value:void 0};let o={};for(let r of i){if(typeof r!=="object"||r===null)continue;let a=r;if(typeof a.id!=="string")continue;o[a.id]=a.allowFrom??[]}return{setting:t,value:Object.keys(o).length===0?void 0:o}}if(t.path==="tools.providers.<id>.writeRoots"){let i=Ne(e,["tools","providers"]);if(typeof i!=="object"||i===null||Array.isArray(i))return{setting:t,value:void 0};let o={};for(let[r,a]of Object.entries(i)){if(typeof a!=="object"||a===null)continue;let s=a.writeRoots;if(s!==void 0)o[r]=s}return{setting:t,value:Object.keys(o).length===0?void 0:o}}return{setting:t,value:Ne(e,t.path.split("."))}})}function BA(n){let e=c(n,"utf8"),t=lA(e),i=Gt(n),o=Ne(e,["channels"]);return f(Vo(n),{channels:(Array.isArray(o)?o:[]).filter((r)=>typeof r==="object"&&r!==null&&!Array.isArray(r)).map((r)=>({id:String(r.id??""),type:String(r.type??""),allowFrom:Array.isArray(r.allowFrom)?r.allowFrom.map(String):[]})).filter((r)=>r.id!==""),secrets:zA(t),present:(r)=>on(i,r)})}async function Nn(n,e,t){switch(e.kind){case"setting":{if(t.trim()==="")throw new A({code:"cli_config_value_missing",message:`No value given for ${e.setting.path}.`,hint:'A bare word, a number, a list as ["a", "b"], or a map as {k: v}.',field:"value"});return(await $n(n,e.setting.path,t)).note}case"allow":{let i=t.trim()===""?[]:t.trim().split(/\s+/);return(await Xn(n,e.channelId,i)).note}case"secret":return Je(n,e.name,t).note;case"heading":return""}}
6
6
  export{WA,Li,Pi,Gi,Fi,Ui,zA,qo,Vo,BA,Nn};
7
7
 
8
8
  //# debugId=387917C94418F90664756E2164756E21
9
- //# sourceMappingURL=index-8h6kewy1.js.map
9
+ //# sourceMappingURL=index-eztfverw.js.map