agentix-cli 0.195.0 → 0.197.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-HBM52GXI.js → App-GF6MCNH6.js} +2 -2
- package/dist/{App-HBM52GXI.js.map → App-GF6MCNH6.js.map} +1 -1
- package/dist/ChatApp-FO2JNLWI.js +7 -0
- package/dist/{ChatApp-N4P7M2TD.js.map → ChatApp-FO2JNLWI.js.map} +1 -1
- package/dist/absorb-eval-7KMQJ5BR.js +2 -0
- package/dist/{adapter-X6T3YBUB.js → adapter-V7DQXCII.js} +2 -2
- package/dist/{adapter-X6T3YBUB.js.map → adapter-V7DQXCII.js.map} +1 -1
- package/dist/{agent-3B4RMEDI.js → agent-PJBGUZMR.js} +2 -2
- package/dist/{board-dashboard-ZIDDOCOO.js → board-dashboard-M3RVQM7K.js} +1054 -346
- package/dist/board-dashboard-M3RVQM7K.js.map +1 -0
- package/dist/{chunk-I45E5TLK.js → chunk-27ICCQVL.js} +57 -57
- package/dist/chunk-27ICCQVL.js.map +1 -0
- package/dist/{chunk-PMSL4A5Y.js → chunk-35GSB7SK.js} +3 -3
- package/dist/{chunk-XH36J3Z2.js → chunk-3K3IBV5K.js} +2 -2
- package/dist/{chunk-ZALVAXQ4.js → chunk-3LMBT5LK.js} +2 -2
- package/dist/{chunk-MB5CBY2C.js → chunk-424CABZF.js} +7 -7
- package/dist/chunk-424CABZF.js.map +1 -0
- package/dist/{chunk-F2FJXKDG.js → chunk-425HPUKF.js} +2 -2
- package/dist/{chunk-PX7PWXBI.js → chunk-4O6ZFYWT.js} +2 -2
- package/dist/chunk-7AB3QUGH.js +2 -0
- package/dist/{chunk-3FZ6WHKX.js.map → chunk-7AB3QUGH.js.map} +1 -1
- package/dist/chunk-7MW44Y5O.js +145 -0
- package/dist/chunk-7MW44Y5O.js.map +1 -0
- package/dist/chunk-B3JQ5J47.js +2 -0
- package/dist/chunk-B3JQ5J47.js.map +1 -0
- package/dist/chunk-BMNDAEF4.js +2 -0
- package/dist/chunk-BMNDAEF4.js.map +1 -0
- package/dist/{chunk-2GCPSAXQ.js → chunk-BN5JVELZ.js} +2 -2
- package/dist/{chunk-LQIF2OHS.js → chunk-BY5CN7C7.js} +2 -2
- package/dist/{chunk-HOZZUN47.js → chunk-DHD4KUTW.js} +2 -2
- package/dist/{chunk-KE6BF4ZJ.js → chunk-GMP2IB4E.js} +2 -2
- package/dist/{chunk-K2BEV3BD.js → chunk-HIHROVHC.js} +2 -2
- package/dist/{chunk-KXJRXRSD.js → chunk-HOL645BZ.js} +2 -2
- package/dist/{chunk-7L54Z4EH.js → chunk-HUOR3FGJ.js} +2 -2
- package/dist/chunk-I22ZKW7Q.js +4 -0
- package/dist/chunk-I22ZKW7Q.js.map +1 -0
- package/dist/chunk-IFUAP7UD.js +11 -0
- package/dist/chunk-IFUAP7UD.js.map +1 -0
- package/dist/{chunk-OEG476JY.js → chunk-IOCULCCJ.js} +3 -3
- package/dist/{chunk-OEG476JY.js.map → chunk-IOCULCCJ.js.map} +1 -1
- package/dist/{chunk-XQF7UUZK.js → chunk-IQQ3I6R7.js} +312 -311
- package/dist/chunk-IQQ3I6R7.js.map +1 -0
- package/dist/{chunk-6V5JBHUN.js → chunk-J7PZJRYO.js} +2 -2
- package/dist/{chunk-F3CMNSON.js → chunk-K3623S4U.js} +2 -2
- package/dist/{chunk-2KYGPVTX.js → chunk-KB5JMDGS.js} +2 -2
- package/dist/{chunk-HNZEXUNM.js → chunk-OVB3LW6L.js} +2 -2
- package/dist/{chunk-6NQ7KYJH.js → chunk-OXTFAV2A.js} +2 -2
- package/dist/{chunk-VX4PSOKU.js → chunk-QABY3WEM.js} +2 -2
- package/dist/{chunk-M2E3CNFS.js → chunk-R3TH2OG7.js} +2 -2
- package/dist/chunk-RC3QYH2J.js +20 -0
- package/dist/chunk-RC3QYH2J.js.map +1 -0
- package/dist/{chunk-UOIWIVU3.js → chunk-RLI32DLG.js} +2 -2
- package/dist/{chunk-RW5FKJRE.js → chunk-SK7M6PS6.js} +2 -2
- package/dist/chunk-SNYAM7YB.js +116 -0
- package/dist/chunk-SNYAM7YB.js.map +1 -0
- package/dist/{chunk-BOCLWYWL.js → chunk-TBS7OVMI.js} +2 -2
- package/dist/{chunk-FO762MEC.js → chunk-TKXZHRV3.js} +2 -2
- package/dist/{chunk-PO2SORKY.js → chunk-WFPLZLCF.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/client-ZHE4B2DD.js +2 -0
- package/dist/config-THBWCNN7.js +2 -0
- package/dist/config-mutate-FBX6TFCY.js +2 -0
- package/dist/config-mutator-33RBNPV4.js +2 -0
- package/dist/{contributions-6VZ4OXJ5.js → contributions-2HR5ZGMK.js} +2 -2
- package/dist/{contributions-6VZ4OXJ5.js.map → contributions-2HR5ZGMK.js.map} +1 -1
- package/dist/doctor-VMWX6GKN.js +2 -0
- package/dist/{follow-up-tool-NVP56W7E.js → follow-up-tool-BCSCBKVL.js} +2 -2
- package/dist/{follow-up-tool-NVP56W7E.js.map → follow-up-tool-BCSCBKVL.js.map} +1 -1
- package/dist/hub-WPC6MTZY.js +2 -0
- package/dist/index.d.ts +131 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{note-tool-ANQWBBZE.js → note-tool-KVH3YBTX.js} +2 -2
- package/dist/ntfy-73UW6GHN.js +2 -0
- package/dist/{program-DW6VZ6LN.js → program-MOVUJBAA.js} +246 -246
- package/dist/program-MOVUJBAA.js.map +1 -0
- package/dist/promote-WWPXP5Z4.js +2 -0
- package/dist/push-E5YKRFAW.js +2 -0
- package/dist/push-bridge-RV3CBTYO.js +2 -0
- package/dist/query-F7HRTCWI.js +2 -0
- package/dist/{query-settings-C5UBKJMN.js → query-settings-Z32LXLJI.js} +2 -2
- package/dist/registry-D5HHCFCC.js +2 -0
- package/dist/request-planner-4FSNZJVQ.js +6 -0
- package/dist/{request-planner-G6IAUMSE.js.map → request-planner-4FSNZJVQ.js.map} +1 -1
- package/dist/review-candidates-U2DOD5Z3.js +4 -0
- package/dist/{review-candidates-ZL2SJXWC.js.map → review-candidates-U2DOD5Z3.js.map} +1 -1
- package/dist/routing-USMMBJYT.js +2 -0
- package/dist/schedule-tool-IRTB23XL.js +2 -0
- package/dist/scheduler-L4ERAOMG.js +2 -0
- package/dist/seat-3LW672DM.js +2 -0
- package/dist/select-MPMJSYKX.js +2 -0
- package/dist/{select-MU52ACKG.js.map → select-MPMJSYKX.js.map} +1 -1
- package/dist/self-HICJTWYO.js +2 -0
- package/dist/set-enabled-TQXG3MSQ.js +2 -0
- package/dist/{set-enabled-XRNSYEI3.js.map → set-enabled-TQXG3MSQ.js.map} +1 -1
- package/dist/{sprint-tool-E4MABD2N.js → sprint-tool-JQ5KCJDP.js} +2 -2
- package/dist/{sprint-tool-E4MABD2N.js.map → sprint-tool-JQ5KCJDP.js.map} +1 -1
- package/dist/{tool-ZYVT4VUU.js → tool-D4DHXF4Z.js} +2 -2
- package/dist/{tool-ZYVT4VUU.js.map → tool-D4DHXF4Z.js.map} +1 -1
- package/dist/tool-DHCKG3SK.js +10 -0
- package/dist/tool-DHCKG3SK.js.map +1 -0
- package/dist/{tool-V5Z4KWK7.js → tool-ZP3SZKYR.js} +2 -2
- package/dist/{tool-V5Z4KWK7.js.map → tool-ZP3SZKYR.js.map} +1 -1
- package/dist/wiki-CRH6XAXE.js +2 -0
- package/dist/wiki-enrich-YZEW6RZT.js +2 -0
- package/package.json +1 -1
- package/dist/ChatApp-N4P7M2TD.js +0 -7
- package/dist/absorb-eval-HRWWPKT3.js +0 -2
- package/dist/board-dashboard-ZIDDOCOO.js.map +0 -1
- package/dist/chunk-3FZ6WHKX.js +0 -2
- package/dist/chunk-5HLD66CW.js +0 -2
- package/dist/chunk-5HLD66CW.js.map +0 -1
- package/dist/chunk-AJ5HMDRW.js +0 -11
- package/dist/chunk-AJ5HMDRW.js.map +0 -1
- package/dist/chunk-I45E5TLK.js.map +0 -1
- package/dist/chunk-IS2IWRP7.js +0 -4
- package/dist/chunk-IS2IWRP7.js.map +0 -1
- package/dist/chunk-MB5CBY2C.js.map +0 -1
- package/dist/chunk-MC3ZZA5G.js +0 -143
- package/dist/chunk-MC3ZZA5G.js.map +0 -1
- package/dist/chunk-P6WSD2UR.js +0 -116
- package/dist/chunk-P6WSD2UR.js.map +0 -1
- package/dist/chunk-UOYIC7XN.js +0 -3
- package/dist/chunk-UOYIC7XN.js.map +0 -1
- package/dist/chunk-XQF7UUZK.js.map +0 -1
- package/dist/client-YN3T56NM.js +0 -2
- package/dist/config-G7T3TMWE.js +0 -2
- package/dist/config-mutate-6CRKZQVQ.js +0 -2
- package/dist/config-mutator-7VS3J5BY.js +0 -2
- package/dist/doctor-GFZZTK7C.js +0 -2
- package/dist/hub-B434CABZ.js +0 -2
- package/dist/ntfy-Q4YHFKWW.js +0 -2
- package/dist/program-DW6VZ6LN.js.map +0 -1
- package/dist/promote-3P6PGJOW.js +0 -2
- package/dist/push-PRFZMCIK.js +0 -2
- package/dist/push-bridge-NR7SLHGX.js +0 -2
- package/dist/query-E4V7TS5S.js +0 -2
- package/dist/registry-IG324PR3.js +0 -2
- package/dist/request-planner-G6IAUMSE.js +0 -6
- package/dist/review-candidates-ZL2SJXWC.js +0 -4
- package/dist/routing-2IBIZYQU.js +0 -2
- package/dist/schedule-tool-QCTT2R3B.js +0 -2
- package/dist/scheduler-ZGB7IKZQ.js +0 -2
- package/dist/seat-CFY7LMPS.js +0 -2
- package/dist/select-MU52ACKG.js +0 -2
- package/dist/self-ELWZIMVY.js +0 -2
- package/dist/set-enabled-XRNSYEI3.js +0 -2
- package/dist/tool-W6M7GYRZ.js +0 -8
- package/dist/tool-W6M7GYRZ.js.map +0 -1
- package/dist/wiki-VP6XRWIS.js +0 -2
- package/dist/wiki-enrich-LUFXPUYY.js +0 -2
- /package/dist/{absorb-eval-HRWWPKT3.js.map → absorb-eval-7KMQJ5BR.js.map} +0 -0
- /package/dist/{agent-3B4RMEDI.js.map → agent-PJBGUZMR.js.map} +0 -0
- /package/dist/{chunk-PMSL4A5Y.js.map → chunk-35GSB7SK.js.map} +0 -0
- /package/dist/{chunk-XH36J3Z2.js.map → chunk-3K3IBV5K.js.map} +0 -0
- /package/dist/{chunk-ZALVAXQ4.js.map → chunk-3LMBT5LK.js.map} +0 -0
- /package/dist/{chunk-F2FJXKDG.js.map → chunk-425HPUKF.js.map} +0 -0
- /package/dist/{chunk-PX7PWXBI.js.map → chunk-4O6ZFYWT.js.map} +0 -0
- /package/dist/{chunk-2GCPSAXQ.js.map → chunk-BN5JVELZ.js.map} +0 -0
- /package/dist/{chunk-LQIF2OHS.js.map → chunk-BY5CN7C7.js.map} +0 -0
- /package/dist/{chunk-HOZZUN47.js.map → chunk-DHD4KUTW.js.map} +0 -0
- /package/dist/{chunk-KE6BF4ZJ.js.map → chunk-GMP2IB4E.js.map} +0 -0
- /package/dist/{chunk-K2BEV3BD.js.map → chunk-HIHROVHC.js.map} +0 -0
- /package/dist/{chunk-KXJRXRSD.js.map → chunk-HOL645BZ.js.map} +0 -0
- /package/dist/{chunk-7L54Z4EH.js.map → chunk-HUOR3FGJ.js.map} +0 -0
- /package/dist/{chunk-6V5JBHUN.js.map → chunk-J7PZJRYO.js.map} +0 -0
- /package/dist/{chunk-F3CMNSON.js.map → chunk-K3623S4U.js.map} +0 -0
- /package/dist/{chunk-2KYGPVTX.js.map → chunk-KB5JMDGS.js.map} +0 -0
- /package/dist/{chunk-HNZEXUNM.js.map → chunk-OVB3LW6L.js.map} +0 -0
- /package/dist/{chunk-6NQ7KYJH.js.map → chunk-OXTFAV2A.js.map} +0 -0
- /package/dist/{chunk-VX4PSOKU.js.map → chunk-QABY3WEM.js.map} +0 -0
- /package/dist/{chunk-M2E3CNFS.js.map → chunk-R3TH2OG7.js.map} +0 -0
- /package/dist/{chunk-UOIWIVU3.js.map → chunk-RLI32DLG.js.map} +0 -0
- /package/dist/{chunk-RW5FKJRE.js.map → chunk-SK7M6PS6.js.map} +0 -0
- /package/dist/{chunk-BOCLWYWL.js.map → chunk-TBS7OVMI.js.map} +0 -0
- /package/dist/{chunk-FO762MEC.js.map → chunk-TKXZHRV3.js.map} +0 -0
- /package/dist/{chunk-PO2SORKY.js.map → chunk-WFPLZLCF.js.map} +0 -0
- /package/dist/{client-YN3T56NM.js.map → client-ZHE4B2DD.js.map} +0 -0
- /package/dist/{config-G7T3TMWE.js.map → config-THBWCNN7.js.map} +0 -0
- /package/dist/{config-mutate-6CRKZQVQ.js.map → config-mutate-FBX6TFCY.js.map} +0 -0
- /package/dist/{config-mutator-7VS3J5BY.js.map → config-mutator-33RBNPV4.js.map} +0 -0
- /package/dist/{doctor-GFZZTK7C.js.map → doctor-VMWX6GKN.js.map} +0 -0
- /package/dist/{hub-B434CABZ.js.map → hub-WPC6MTZY.js.map} +0 -0
- /package/dist/{note-tool-ANQWBBZE.js.map → note-tool-KVH3YBTX.js.map} +0 -0
- /package/dist/{ntfy-Q4YHFKWW.js.map → ntfy-73UW6GHN.js.map} +0 -0
- /package/dist/{promote-3P6PGJOW.js.map → promote-WWPXP5Z4.js.map} +0 -0
- /package/dist/{push-PRFZMCIK.js.map → push-E5YKRFAW.js.map} +0 -0
- /package/dist/{push-bridge-NR7SLHGX.js.map → push-bridge-RV3CBTYO.js.map} +0 -0
- /package/dist/{query-E4V7TS5S.js.map → query-F7HRTCWI.js.map} +0 -0
- /package/dist/{query-settings-C5UBKJMN.js.map → query-settings-Z32LXLJI.js.map} +0 -0
- /package/dist/{registry-IG324PR3.js.map → registry-D5HHCFCC.js.map} +0 -0
- /package/dist/{routing-2IBIZYQU.js.map → routing-USMMBJYT.js.map} +0 -0
- /package/dist/{schedule-tool-QCTT2R3B.js.map → schedule-tool-IRTB23XL.js.map} +0 -0
- /package/dist/{scheduler-ZGB7IKZQ.js.map → scheduler-L4ERAOMG.js.map} +0 -0
- /package/dist/{seat-CFY7LMPS.js.map → seat-3LW672DM.js.map} +0 -0
- /package/dist/{self-ELWZIMVY.js.map → self-HICJTWYO.js.map} +0 -0
- /package/dist/{wiki-VP6XRWIS.js.map → wiki-CRH6XAXE.js.map} +0 -0
- /package/dist/{wiki-enrich-LUFXPUYY.js.map → wiki-enrich-YZEW6RZT.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/requests/tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\nimport { awaitingQa, describeQa } from \"./qa\"\nimport type { GoalSummary } from \"./goals\"\nimport { describeGoalCheck, type GoalRecord } from \"./goal-store\"\nimport { describeFlow } from \"./flow\"\n\n// --- Agent-facing `agentx_request` tool (#356) ---\n//\n// Lets an agent say what it is doing with the owner's request, so the\n// request stays visible until it is closed:\n// accept I am taking this on; keep it open after this turn. With\n// `steps` (two or more): a tracked plan the daemon follows (#788).\n// `work` and `estimateMinutes` say what it is: code work or a\n// long estimate is refused without steps (#1048). `goal`\n// names the goal it serves (#1168)\n// step report on one step of a plan: progress, done, blocked\n// wait the next step is the owner's answer to this question\n// done finished, with a link to the evidence, or a typed proof\n// (link, test, output, check; #1138 D). On a loop with a\n// closeWhen the daemon runs its check first (#1039). A promise\n// closed with a proof leaves a dated wiki fact\n// decline I will not do it, with the reason\n// promise I owe someone something (owedTo, text, due, closeWhen):\n// an open loop of its own, listed with the open requests\n// describe what it is (headline) and what is needed from the owner\n// (need), for every card, push and Desk line (#1126). accept,\n// wait and promise take the two as well\n// qa a QA verdict on a request (#1188): block, risk or pass, with\n// a note. accept, wait, promise and describe take needsQa to\n// ask for one\n// list what is still open\n// goals every goal requests name: progress and cost (#1168)\n// goal one goal record (#1568): goalAction show (default), create\n// (goal {id, title}, doneWhen, check), close (evidence) or\n// drop (reason). A goal with a check closes by itself when it\n// is met; a cron that names it stops running then\n// flow the daily flow rate: today's, then one line per day (#1542)\n// It talks to the daemon's /requests endpoints. Dropping a request is the\n// owner's alone; there is no action for it here.\n\nexport interface RequestToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\n/** A done on a loop with a check waits for it: the slowest is an issue\n * check, three forge calls of up to 10 s each. */\nexport const DONE_TIMEOUT_MS = 45_000\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nconst STATE_WORDS: Record<string, string> = {\n in_progress: \"in progress\",\n waiting_owner: \"waiting on the owner\",\n waiting_other: \"waiting on another agent\",\n needs_attention: \"needs attention\",\n}\n\n/** One line per open request, oldest first. */\nexport function describeOpen(items: any[]): string {\n if (!items.length) return \"No open requests.\"\n return items.map((r) => {\n const when = new Date(r.createdAt).toISOString().slice(0, 16).replace(\"T\", \" \")\n const extra = r.state === \"waiting_owner\" && r.question ? ` Question: ${r.question}`\n : r.state === \"needs_attention\" && r.attentionReason ? ` ${r.attentionReason}` : \"\"\n const words = String(r.text).replace(/\\s+/g, \" \").trim()\n const loop = [\n r.promise && r.owedTo ? ` Promised to ${r.owedTo}.` : \"\",\n r.dueAt ? ` Due ${new Date(r.dueAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC.` : \"\",\n r.closeWhen ? ` Closes on its check (${r.closeWhen.kind})${r.verifyState ? `: ${r.verifyState}` : \"\"}.` : \"\",\n awaitingQa(r) ? \" Awaiting QA.\" : r.qa ? ` QA: ${describeQa(r.qa)}.` : \"\",\n r.goal ? ` Goal: ${r.goal.title} (${r.goal.id}).` : \"\",\n ].join(\"\")\n return `- ${r.id} [${STATE_WORDS[r.state] ?? r.state}] ${when} UTC, ${r.channel}, ${r.agentId}: ${words.length > 160 ? `${words.slice(0, 159)}…` : words}.${extra}${loop}`\n }).join(\"\\n\")\n}\n\n/** Dollars, to the cent; under a cent, to the tenth of one. */\nexport function usd(n: number): string {\n return `$${n > 0 && n < 0.01 ? n.toFixed(3) : n.toFixed(2)}`\n}\n\n/** One line per goal, most recently active first (#1168). */\nexport function describeGoals(goals: GoalSummary[], records: GoalRecord[] = []): string {\n if (!goals.length) return \"No request names a goal.\"\n const byId = new Map(records.map((g) => [g.id, g]))\n return goals.map((g) => {\n const far = g.progress === null ? \"nothing open or done\" : `${Math.round(g.progress * 100)}% done`\n const unpriced = g.unpriced ? `, ${g.unpriced} of ${g.runs} runs without a cost` : \"\"\n const rec = byId.get(g.id)\n const state = rec ? ` [${rec.state}${rec.ownerAgent ? `, owner ${rec.ownerAgent}` : \"\"}]` : \"\"\n return `- ${g.id} \"${rec?.title ?? g.title}\"${state}: ${g.open} open, ${g.done} done${g.dropped ? `, ${g.dropped} declined or dropped` : \"\"} (${far}). Cost ${usd(g.costUsd)}${unpriced}.`\n }).join(\"\\n\")\n}\n\n/** One goal record in a line (#1568). */\nexport function describeGoalRecord(g: GoalRecord): string {\n const check = g.check ? ` Check: ${describeGoalCheck(g.check)}${g.lastCheck ? ` (last: ${g.lastCheck})` : \"\"}.` : \"\"\n const closed = g.state !== \"active\" && g.evidence ? ` Closed: ${g.evidence}.` : \"\"\n return `${g.id} \"${g.title}\" [${g.state}${g.ownerAgent ? `, owner ${g.ownerAgent}` : \"\"}].${g.doneWhen ? ` Done when: ${g.doneWhen}.` : \"\"}${check}${closed}`\n}\n\nasync function goalTool(args: Record<string, unknown>, deps: RequestToolDeps, base: string, doFetch: typeof fetch): Promise<string> {\n const op = (str(args.goalAction) || \"show\").toLowerCase()\n const goalArg = args.goal && typeof args.goal === \"object\" ? args.goal as Record<string, unknown> : null\n const id = str(args.id) || str(goalArg?.id)\n if (op === \"show\") {\n if (!id) return \"Error: show needs id: the goal's id (goals lists them).\"\n const res = await doFetch(`${base}/requests/goals/${encodeURIComponent(id)}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const s = data.summary as GoalSummary | null\n return [\n data.goal ? describeGoalRecord(data.goal) : `${id} has no record yet: it is a label on its requests. Make one with goalAction create.`,\n s ? `Requests: ${s.open} open, ${s.done} done${s.dropped ? `, ${s.dropped} declined or dropped` : \"\"}. Cost ${usd(s.costUsd)}.` : \"No request names it yet.\",\n ].join(\"\\n\")\n }\n const env = deps.env ?? process.env\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/requests/goals`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action: op, agentId: caller.agentId, id, goal: args.goal, doneWhen: args.doneWhen,\n check: args.check ?? args.closeWhen, evidence: args.evidence, reason: args.reason,\n }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const g = data.goal as GoalRecord\n if (op === \"create\") {\n return `Goal ${res.status === 201 ? \"made\" : \"updated\"}: ${describeGoalRecord(g)}${g.check ? \" The daemon runs its check and closes it when it is met.\" : ` Close it with {action:\"goal\", goalAction:\"close\", id:\"${g.id}\", evidence:\"<link>\"} when it is reached.`} A cron with goal \"${g.id}\" stops running once it is closed.`\n }\n return `Goal ${g.id} is ${g.state}. Crons that name it no longer run.`\n}\n\n/** One line per plan step. */\nexport function describeSteps(steps: any[]): string[] {\n return (steps ?? []).map((s) => `${s.idx}. ${s.name} (${s.agentId}, ${s.kind}) [${s.state}]${s.needsApproval ? ` approval: ${s.approval}` : \"\"}`)\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runRequestTool(args: Record<string, unknown>, deps: RequestToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n\n try {\n if (action === \"goals\") {\n const res = await doFetch(`${base}/requests/goals`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const records: GoalRecord[] = data.records ?? []\n const named = new Set((data.goals ?? []).map((g: GoalSummary) => g.id))\n const bare = records.filter((g) => !named.has(g.id))\n return [\n `${data.count} goal${data.count === 1 ? \"\" : \"s\"}, most recently active first.\\n${describeGoals(data.goals ?? [], records)}`,\n ...(bare.length ? [\"Goal records no request names yet:\", ...bare.map((g) => `- ${describeGoalRecord(g)}`)] : []),\n ].join(\"\\n\")\n }\n\n if (action === \"goal\") return await goalTool(args, deps, base, doFetch)\n\n if (action === \"flow\") {\n const days = typeof args.days === \"number\" ? `?days=${Math.floor(args.days)}` : \"\"\n const res = await doFetch(`${base}/requests/flow${days}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (!data.enabled) return \"Requests are turned off on this node (requests.enabled), so nothing is recorded.\"\n return describeFlow(data)\n }\n\n if (action === \"list\") {\n const res = await doFetch(`${base}/requests`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (!data.enabled) return \"Requests are turned off on this node (requests.enabled), so nothing is recorded.\"\n return `${data.count} open request${data.count === 1 ? \"\" : \"s\"}, oldest first.\\n${describeOpen(data.items ?? [])}`\n }\n\n const env = deps.env ?? process.env\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/requests`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n id: args.id, question: args.question, evidence: args.evidence, proof: args.proof, reason: args.reason,\n steps: args.steps, work: args.work, estimateMinutes: args.estimateMinutes, step: args.step, status: args.status, note: args.note, home: args.home,\n owedTo: args.owedTo, text: args.text, due: args.due, closeWhen: args.closeWhen,\n headline: args.headline, need: args.need, needsQa: args.needsQa, verdict: args.verdict, goal: args.goal,\n }),\n signal: AbortSignal.timeout(action === \"done\" ? DONE_TIMEOUT_MS : 10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const r = data.request\n const serves = r.goal ? ` It serves the goal \"${r.goal.title}\" (${r.goal.id}).` : \"\"\n if (action === \"accept\" && data.plan) {\n return [\n `Request ${r.id} is open with a plan of ${data.steps.length} steps.${serves} The daemon hands each step to its agent in order, nudges a step that goes quiet, and tells the owner when it is finished or blocked.`,\n ...describeSteps(data.steps),\n `Steps the owner approves get a decision card now; an approved message is sent by the daemon itself. Report your own steps with {action:\"step\", id:\"${r.id}\", step:<n>, status:\"progress\"|\"done\"|\"blocked\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return [`Step reported. Plan of ${r.id}:`, ...describeSteps(data.steps)].join(\"\\n\")\n if (action === \"qa\") return `Verdict recorded on ${r.id}: ${describeQa(r.qa)}. It shows on the request's card; nobody is told.`\n if (action === \"describe\") return `Request ${r.id} now reads \"${r.headline ?? \"(no headline)\"}\" on the owner's cards. Needed from them: ${r.need ?? \"what follows from where it stands\"}.`\n if (action === \"accept\") return `Request ${r.id} is open and in progress.${serves} Close it with done (and a link to the evidence) or decline (and the reason); it stays on the owner's list until then.`\n if (action === \"wait\") return `Request ${r.id} is waiting on the owner with your question. Ask them the question now, once.`\n if (action === \"promise\") {\n return `Promise ${r.id} is open, owed to ${r.owedTo}${r.dueAt ? `, due ${new Date(r.dueAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC` : \"\"}. ` +\n (r.closeWhen ? \"The daemon checks its evidence and closes it once the check is met.\" : `Close it with {action:\"done\", id:\"${r.id}\", evidence:\"<link>\"} when it is kept.`)\n }\n if (action === \"done\" && data.verify === \"unverified\") {\n return `Request ${r.id} stays open: its check could not say whether it is finished (${data.detail}). It is marked unverified; the daemon checks again, and the owner can close it by hand.`\n }\n if (action === \"done\") {\n const fact = r.factId ? ` It left fact ${r.factId} in the wiki (agentx wiki facts show ${r.factId}).` : \"\"\n return `Request ${r.id} is closed as done${data.verified ? \" (its check was met)\" : \"\"}. Evidence: ${r.evidence}${fact}`\n }\n return `Request ${r.id} is closed as declined. Reason: ${r.closeReason}`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"sjBAiDO,IAAMA,EAAkB,KAEzBC,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAE1DC,EAAsC,CAC1C,YAAa,cACb,cAAe,uBACf,cAAe,2BACf,gBAAiB,iBACnB,EAGO,SAASC,EAAaC,EAAsB,CACjD,OAAKA,EAAM,OACJA,EAAM,IAAKC,GAAM,CACtB,IAAMC,EAAO,IAAI,KAAKD,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAG,EAAE,EAAE,QAAQ,IAAK,GAAG,EACxEE,EAAQF,EAAE,QAAU,iBAAmBA,EAAE,SAAW,cAAcA,EAAE,WACtEA,EAAE,QAAU,mBAAqBA,EAAE,gBAAkB,IAAIA,EAAE,kBAAoB,GAC7EG,EAAQ,OAAOH,EAAE,IAAI,EAAE,QAAQ,OAAQ,GAAG,EAAE,KAAK,EACjDI,EAAO,CACXJ,EAAE,SAAWA,EAAE,OAAS,gBAAgBA,EAAE,UAAY,GACtDA,EAAE,MAAQ,QAAQ,IAAI,KAAKA,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAG,EAAE,EAAE,QAAQ,IAAK,GAAG,SAAW,GAC1FA,EAAE,UAAY,yBAAyBA,EAAE,UAAU,QAAQA,EAAE,YAAc,KAAKA,EAAE,cAAgB,MAAQ,GAC1GK,EAAWL,CAAC,EAAI,gBAAkBA,EAAE,GAAK,QAAQM,EAAWN,EAAE,EAAE,KAAO,GACvEA,EAAE,KAAO,UAAUA,EAAE,KAAK,UAAUA,EAAE,KAAK,OAAS,EACtD,EAAE,KAAK,EAAE,EACT,MAAO,KAAKA,EAAE,OAA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AAC,EAAE,KAAK;AAAA,CAAI,EACzG,GAAIS,IAAW,KAAM,MAAO,uBAAuBxC,EAAE,OAAOM,EAAWN,EAAE,EAAE,qDAC3E,GAAIwC,IAAW,WAAY,MAAO,WAAWxC,EAAE,iBAAiBA,EAAE,UAAY,4DAA4DA,EAAE,MAAQ,uCACpJ,GAAIwC,IAAW,SAAU,MAAO,WAAWxC,EAAE,8BAA8B6C,0HAC3E,GAAIL,IAAW,OAAQ,MAAO,WAAWxC,EAAE,kFAC3C,GAAIwC,IAAW,UACb,MAAO,WAAWxC,EAAE,uBAAuBA,EAAE,SAASA,EAAE,MAAQ,SAAS,IAAI,KAAKA,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAG,EAAE,EAAE,QAAQ,IAAK,GAAG,QAAU,QAC7IA,EAAE,UAAY,sEAAwE,qCAAqCA,EAAE,4CAElI,GAAIwC,IAAW,QAAUT,EAAK,SAAW,aACvC,MAAO,WAAW/B,EAAE,kEAAkE+B,EAAK,iGAE7F,GAAIS,IAAW,OAAQ,CACrB,IAAMM,EAAO9C,EAAE,OAAS,iBAAiBA,EAAE,8CAA8CA,EAAE,WAAa,GACxG,MAAO,WAAWA,EAAE,uBAAuB+B,EAAK,SAAW,uBAAyB,iBAAiB/B,EAAE,WAAW8C,IAEpH,MAAO,WAAW9C,EAAE,qCAAqCA,EAAE,aAC7D,OAAS+C,EAAP,CACA,MAAO,qCAAqCA,GAAG,SAAWA,KAC5D,CACF","names":["DONE_TIMEOUT_MS","str","v","STATE_WORDS","describeOpen","items","r","when","extra","words","loop","awaitingQa","describeQa","usd","n","describeGoals","goals","records","byId","g","far","unpriced","rec","state","describeGoalRecord","check","describeGoalCheck","closed","goalTool","args","deps","base","doFetch","op","goalArg","id","res","data","s","env","caller","resolveScheduleCaller","callerHeaders","describeSteps","steps","runRequestTool","action","named","bare","days","describeFlow","serves","fact","e"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as f}from"./chunk-
|
|
1
|
+
import{b as f}from"./chunk-HIHROVHC.js";import"./chunk-RKPAVWXF.js";import{g as y}from"./chunk-MNG2AMKZ.js";import"./chunk-DHD4KUTW.js";import{b as u}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-7MW44Y5O.js";import"./chunk-HOL645BZ.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-SNYAM7YB.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-BMNDAEF4.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";var w=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function c(t){return typeof t=="string"?t.trim():""}async function b(t,s){let d=s.fetch??fetch,l=s.daemonUrl.replace(/\/$/,""),i=(c(t.action)||"create").toLowerCase(),o=f(t,s.env??process.env);if(i==="status"){let n=c(t.id);if(!n)return"Error: `id` is required for status (the card id you got when you raised it).";try{let a=await d(`${l}/approvals/${encodeURIComponent(n)}`,{signal:AbortSignal.timeout(1e4)}),r=await a.json().catch(()=>({}));if(!a.ok)return`Error: ${r?.error||`HTTP ${a.status}`}`;let e=r.card;if(o&&e.raised_by!==o.agentId)return`Error: card "${n}" was raised by another agent.`;if(e.status==="pending")return`Card ${e.id} is still waiting for the operator. It expires ${e.expires}; then "${e.if_silent}" applies.`;if(e.status==="decided"){let h=e.verdict==="yes"?y(e).join(`
|
|
2
2
|
`):"";return`Card ${e.id}: the operator said ${String(e.verdict).toUpperCase()}.${e.note?` Note: ${e.note}`:""}${h?`
|
|
3
3
|
${h}`:""}`}return e.status==="resolved"?`Card ${e.id} was closed by ${e.raised_by}: ${e.resolution??"answered outside the card"}.`:`Card ${e.id} expired unanswered; the default applied: ${e.outcome??e.if_silent}.`}catch(a){return`Error: couldn't reach the daemon (${a?.message??a}).`}}if(i==="resolve"){let n=c(t.id),a=c(t.reason);if(!n)return"Error: `id` is required for resolve (the card id you got when you raised it).";if(!a)return'Error: `reason` is required for resolve: where the owner answered and what you did, e.g. "approved in chat, done".';if(!o)return"Error: couldn't tell which agent you are. Pass callerAgentId.";try{let r=await d(`${l}/approvals/${encodeURIComponent(n)}/resolve`,{method:"POST",headers:{"Content-Type":"application/json",...u(s.env??process.env)},body:JSON.stringify({raised_by:o.agentId,reason:a}),signal:AbortSignal.timeout(1e4)}),e=await r.json().catch(()=>({}));return r.ok?`Card ${e.card.id} is closed. It left the operator's inbox, so nobody will be asked about it again.`:`Error: ${e?.error||`HTTP ${r.status}`}`}catch(r){return`Error: couldn't reach the daemon (${r?.message??r}).`}}if(i!=="create")return`Error: unknown action "${i}". Use create, status or resolve.`;if(!o)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let p=o.channel&&o.chatId&&!w.has(o.channel)?{channel:o.channel,chatId:o.chatId,...o.accountId?{accountId:o.accountId}:{}}:void 0,$={title:t.title,ask:t.ask,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,source:t.source,choices:t.choices,draft:t.draft,say:t.say,context:t.context,followup:t.followup,raised_by:o.agentId,...p?{reply:p}:{}};try{let n=await d(`${l}/approvals`,{method:"POST",headers:{"Content-Type":"application/json",...u(s.env??process.env)},body:JSON.stringify($),signal:AbortSignal.timeout(1e4)}),a=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${a?.error||`HTTP ${n.status}`}`;let r=a.card;return[`Decision card ${r.id} is in the operator's Approvals inbox.`,`If nobody answers by ${r.expires}, "${r.if_silent}" applies.`,"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat.",`If the operator answers the same thing in chat and you act on it, close the card with {action:"resolve", id:"${r.id}", reason:"approved in chat, done"} so it is not asked again.`].join(" ")}catch(n){return`Error: couldn't reach the daemon (${n?.message??n}).`}}export{b as runApprovalTool};
|
|
4
|
-
//# sourceMappingURL=tool-
|
|
4
|
+
//# sourceMappingURL=tool-ZP3SZKYR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/approvals/tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\nimport { answerLines } from \"./choices\"\n\n// --- Agent-facing `agentx_approval` tool ---\n//\n// Lets an agent raise a decision card instead of asking the operator in\n// chat, check what happened to one, and close its own card once the owner\n// answered the same thing in chat and it acted on that (#909). It talks to\n// the daemon's /approvals endpoints, which never decide: there is no\n// action here that approves or rejects anything.\n\nexport type ApprovalToolAction = \"create\" | \"status\" | \"resolve\"\n\nexport interface ApprovalToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runApprovalTool(args: Record<string, unknown>, deps: ApprovalToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"create\").toLowerCase() as ApprovalToolAction\n const caller = resolveScheduleCaller(args, deps.env ?? process.env)\n\n if (action === \"status\") {\n const id = str(args.id)\n if (!id) return \"Error: `id` is required for status (the card id you got when you raised it).\"\n try {\n const res = await doFetch(`${base}/approvals/${encodeURIComponent(id)}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const c = data.card\n if (caller && c.raised_by !== caller.agentId) return `Error: card \"${id}\" was raised by another agent.`\n if (c.status === \"pending\") return `Card ${c.id} is still waiting for the operator. It expires ${c.expires}; then \"${c.if_silent}\" applies.`\n if (c.status === \"decided\") {\n const picked = c.verdict === \"yes\" ? answerLines(c).join(\"\\n\") : \"\"\n return `Card ${c.id}: the operator said ${String(c.verdict).toUpperCase()}.${c.note ? ` Note: ${c.note}` : \"\"}${picked ? `\\n${picked}` : \"\"}`\n }\n if (c.status === \"resolved\") return `Card ${c.id} was closed by ${c.raised_by}: ${c.resolution ?? \"answered outside the card\"}.`\n return `Card ${c.id} expired unanswered; the default applied: ${c.outcome ?? c.if_silent}.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action === \"resolve\") {\n const id = str(args.id)\n const reason = str(args.reason)\n if (!id) return \"Error: `id` is required for resolve (the card id you got when you raised it).\"\n if (!reason) return \"Error: `reason` is required for resolve: where the owner answered and what you did, e.g. \\\"approved in chat, done\\\".\"\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n try {\n const res = await doFetch(`${base}/approvals/${encodeURIComponent(id)}/resolve`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(deps.env ?? process.env) },\n body: JSON.stringify({ raised_by: caller.agentId, reason }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return `Card ${data.card.id} is closed. It left the operator's inbox, so nobody will be asked about it again.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"create\") return `Error: unknown action \"${action}\". Use create, status or resolve.`\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n const payload = {\n title: args.title,\n ask: args.ask,\n recommend: args.recommend,\n if_silent: args.if_silent,\n expires: args.expires,\n source: args.source,\n choices: args.choices,\n draft: args.draft,\n say: args.say,\n context: args.context,\n followup: args.followup,\n raised_by: caller.agentId,\n ...(reply ? { reply } : {}),\n }\n try {\n const res = await doFetch(`${base}/approvals`, {\n method: \"POST\",\n // The headers name this run: a card moves a request to \"waiting on\n // the owner\" only when it comes from the turn of that request.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(deps.env ?? process.env) },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const c = data.card\n return [\n `Decision card ${c.id} is in the operator's Approvals inbox.`,\n `If nobody answers by ${c.expires}, \"${c.if_silent}\" applies.`,\n \"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat.\",\n `If the operator answers the same thing in chat and you act on it, close the card with {action:\"resolve\", id:\"${c.id}\", reason:\"approved in chat, done\"} so it is not asked again.`,\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/approvals/tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\nimport { answerLines } from \"./choices\"\n\n// --- Agent-facing `agentx_approval` tool ---\n//\n// Lets an agent raise a decision card instead of asking the operator in\n// chat, check what happened to one, and close its own card once the owner\n// answered the same thing in chat and it acted on that (#909). It talks to\n// the daemon's /approvals endpoints, which never decide: there is no\n// action here that approves or rejects anything.\n\nexport type ApprovalToolAction = \"create\" | \"status\" | \"resolve\"\n\nexport interface ApprovalToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runApprovalTool(args: Record<string, unknown>, deps: ApprovalToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"create\").toLowerCase() as ApprovalToolAction\n const caller = resolveScheduleCaller(args, deps.env ?? process.env)\n\n if (action === \"status\") {\n const id = str(args.id)\n if (!id) return \"Error: `id` is required for status (the card id you got when you raised it).\"\n try {\n const res = await doFetch(`${base}/approvals/${encodeURIComponent(id)}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const c = data.card\n if (caller && c.raised_by !== caller.agentId) return `Error: card \"${id}\" was raised by another agent.`\n if (c.status === \"pending\") return `Card ${c.id} is still waiting for the operator. It expires ${c.expires}; then \"${c.if_silent}\" applies.`\n if (c.status === \"decided\") {\n const picked = c.verdict === \"yes\" ? answerLines(c).join(\"\\n\") : \"\"\n return `Card ${c.id}: the operator said ${String(c.verdict).toUpperCase()}.${c.note ? ` Note: ${c.note}` : \"\"}${picked ? `\\n${picked}` : \"\"}`\n }\n if (c.status === \"resolved\") return `Card ${c.id} was closed by ${c.raised_by}: ${c.resolution ?? \"answered outside the card\"}.`\n return `Card ${c.id} expired unanswered; the default applied: ${c.outcome ?? c.if_silent}.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action === \"resolve\") {\n const id = str(args.id)\n const reason = str(args.reason)\n if (!id) return \"Error: `id` is required for resolve (the card id you got when you raised it).\"\n if (!reason) return \"Error: `reason` is required for resolve: where the owner answered and what you did, e.g. \\\"approved in chat, done\\\".\"\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n try {\n const res = await doFetch(`${base}/approvals/${encodeURIComponent(id)}/resolve`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(deps.env ?? process.env) },\n body: JSON.stringify({ raised_by: caller.agentId, reason }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return `Card ${data.card.id} is closed. It left the operator's inbox, so nobody will be asked about it again.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"create\") return `Error: unknown action \"${action}\". Use create, status or resolve.`\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n const payload = {\n title: args.title,\n ask: args.ask,\n recommend: args.recommend,\n if_silent: args.if_silent,\n expires: args.expires,\n source: args.source,\n choices: args.choices,\n draft: args.draft,\n say: args.say,\n context: args.context,\n followup: args.followup,\n raised_by: caller.agentId,\n ...(reply ? { reply } : {}),\n }\n try {\n const res = await doFetch(`${base}/approvals`, {\n method: \"POST\",\n // The headers name this run: a card moves a request to \"waiting on\n // the owner\" only when it comes from the turn of that request.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(deps.env ?? process.env) },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n const c = data.card\n return [\n `Decision card ${c.id} is in the operator's Approvals inbox.`,\n `If nobody answers by ${c.expires}, \"${c.if_silent}\" applies.`,\n \"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat.\",\n `If the operator answers the same thing in chat and you act on it, close the card with {action:\"resolve\", id:\"${c.id}\", reason:\"approved in chat, done\"} so it is not asked again.`,\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"ggBAoBA,IAAMA,EAAoB,IAAI,IAAI,CAAC,OAAQ,YAAa,MAAO,MAAO,OAAQ,YAAa,UAAU,CAAC,EAEtG,SAASC,EAAIC,EAAoB,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CAAE,MAAAA,CAAM,EAAI,CAAC,CAC3B,EACA,GAAI,CACF,IAAMR,EAAM,MAAMN,EAAQ,GAAGC,cAAkB,CAC7C,OAAQ,OAGR,QAAS,CAAE,eAAgB,mBAAoB,GAAGY,EAAcd,EAAK,KAAO,QAAQ,GAAG,CAAE,EACzF,KAAM,KAAK,UAAUgB,CAAO,EAC5B,OAAQ,YAAY,QAAQ,GAAM,CACpC,CAAC,EACKR,EAAO,MAAMD,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAC9C,GAAI,CAACA,EAAI,GAAI,MAAO,UAAUC,GAAM,OAAS,QAAQD,EAAI,WACzD,IAAME,EAAID,EAAK,KACf,MAAO,CACL,iBAAiBC,EAAE,2CACnB,wBAAwBA,EAAE,aAAaA,EAAE,sBACzC,+HACA,gHAAgHA,EAAE,iEACpH,EAAE,KAAK,GAAG,CACZ,OAASG,EAAP,CACA,MAAO,qCAAqCA,GAAG,SAAWA,KAC5D,CACF","names":["NON_CHAT_CHANNELS","str","v","runApprovalTool","args","deps","doFetch","base","action","caller","resolveScheduleCaller","id","res","data","c","picked","answerLines","e","reason","callerHeaders","reply","payload"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-SK7M6PS6.js";import{a}from"./chunk-3LMBT5LK.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{d as c}from"./chunk-35GSB7SK.js";import"./chunk-JTFCU5LH.js";import"./chunk-OXTFAV2A.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-KB5JMDGS.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-BERWTVG2.js";import"./chunk-AHWWJ7AF.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-SNYAM7YB.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-BMNDAEF4.js";import"./chunk-VQRY4IDI.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
|
|
2
|
+
//# sourceMappingURL=wiki-CRH6XAXE.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentix-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.197.0",
|
|
4
4
|
"description": "AI staff for a small company: they find sales, answer clients, write your posts and watch the money, on a machine you own. You approve what matters. Runs a team of AI agents across Telegram, WhatsApp, GitLab, GitHub, crons, webhooks and mesh tasks, on Claude Code, Codex, OpenCode or any LLM API. Web wizard for operators, CLI for engineers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
package/dist/ChatApp-N4P7M2TD.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{a as Y,b as Z,c as _,d as ee,e as te,f as ne,g as re}from"./chunk-U2CKL755.js";import{b as Q,g as X}from"./chunk-2GCPSAXQ.js";import"./chunk-P6WSD2UR.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";import{useCallback as oe,useMemo as H,useRef as P,useState as k}from"react";import{Box as g,Text as t,useApp as he,useInput as xe,useStdout as Te}from"ink";import{randomUUID as se}from"crypto";var m={accent:"cyan",agent:"green",working:"magenta",error:"red",muted:"gray"},q="\u25C7 agentx",F="\u258C";import{jsx as c,jsxs as o}from"react/jsx-runtime";var ie="/help /agent <id> /agents /clear /who /exit",be=[{cmd:"/agent",desc:"switch the target agent (/agent <id>)"},{cmd:"/agents",desc:"list registered agents"},{cmd:"/clear",desc:"start a fresh session"},{cmd:"/who",desc:"show agent + chat id"},{cmd:"/help",desc:"list commands"},{cmd:"/exit",desc:"quit the chat"}];function Pe({conn:n,agentId:p,channel:f,chatId:a,agents:h}){let{exit:w}=he(),{stdout:O}=Te(),V=Math.max(40,Math.min((O?.columns||80)-4,100)),[z,U]=k([]),[$,S]=k(null),[T,le]=k(p),[A,ae]=k(h),[E,ue]=k(a),[y,x]=k(""),[J,de]=k(""),W=P([]),u=P(-1),M=P(null),R=P(null),v=$?.live??!1,j=H(()=>Z(y,A.map(s=>s.id),process.cwd()),[y,A]),N=H(()=>{let s=/^\/(\w*)$/.exec(y);if(!s)return null;let e=be.filter(r=>r.cmd.slice(1).startsWith(s[1].toLowerCase()));return e.length?e:null},[y]),b=s=>de(s),K=oe(s=>{let e=se().slice(0,8),r=Date.now(),i=new AbortController;R.current=i;let d={id:e,you:s,agentId:T,segs:[],live:!0,startedAt:r};S({...d});let L=()=>S({...d,segs:d.segs.map(C=>({...C}))});(async()=>{try{let C=await X(n,T,s,{channel:f,chatId:E,signal:i.signal,onText:l=>{let I=d.segs[d.segs.length-1];I&&I.type==="text"?I.content=(I.content??"")+l:d.segs.push({type:"text",content:l}),L()},onThinking:l=>{d.thinking=(d.thinking??"")+l,L()},onTool:l=>{l.status==="start"&&l.name?(d.segs.push({type:"tool",name:l.name,arg:l.arg}),L()):l.status==="result"&&l.error&&(d.segs.push({type:"tool",name:l.name??"tool",error:!0}),L())}});U(l=>[...l,{...d,live:!1,elapsedMs:Date.now()-r,outTokens:C.usage?.outputTokens,error:C.error}]),S(null)}catch(C){let l=i.signal.aborted||C?.name==="AbortError";U(I=>[...I,{...d,live:!1,elapsedMs:Date.now()-r,interrupted:l,error:l?void 0:C?.message||String(C)}]),S(null)}finally{R.current===i&&(R.current=null)}})()},[n,T,f,E]),me=oe(s=>{let e=s.trim();if(e){if(W.current.push(e),u.current=-1,e==="/exit"||e==="/quit"){w();return}if(e==="/help"){b(ie);return}if(e==="/who"){b(`@${T} \xB7 chatId=${E} \xB7 channel=${f}`);return}if(e==="/clear"){let r=`chat-cli:${se().slice(0,12)}`;ue(r),U([]),b(`fresh chatId=${r} (warm process dropped)`);return}if(e==="/agents"){Q(n).then(r=>{ae(r),b(r.map(i=>i.id===T?`[${i.id}]`:i.id).join(" "))}).catch(r=>b(`failed to list agents: ${r?.message||r}`));return}if(e.startsWith("/agent ")){let r=e.slice(7).replace(/^@/,"").trim();if(!r){b("usage: /agent <id>");return}if(!A.find(i=>i.id===r)){b(`unknown agent: @${r}`);return}le(r),b(`now talking to @${r}`);return}if(e.startsWith("/")){b(`unknown command \xB7 ${ie}`);return}K(e)}},[n,T,A,f,E,w,K]);xe((s,e)=>{if(e.ctrl&&s==="c"){w();return}if(e.escape){if(v&&R.current){R.current.abort();return}w();return}if(e.tab){if(N){x(N[0].cmd+" ");return}let i=_(y,M,A.map(d=>d.id),process.cwd());i!==null&&(x(i),u.current=-1);return}if(e.upArrow){let i=W.current;if(!i.length)return;u.current=u.current<0?i.length-1:Math.max(0,u.current-1),x(i[u.current]??"");return}if(e.downArrow){let i=W.current;if(u.current<0)return;if(u.current=u.current+1,u.current>=i.length){u.current=-1,x("");return}x(i[u.current]??"");return}if(e.backspace||e.delete){M.current=null,x(i=>i.slice(0,-1));return}if(e.ctrl||e.meta)return;let r=ee(s??"",e.return,y);switch(r.kind){case"paste":M.current=null,x(i=>i+r.text),u.current=-1;return;case"type":M.current=null,x(i=>i+r.text),u.current=-1;return;case"continue":x(r.buffer);return;case"submit":if(v)return;M.current=null,x(""),me(r.text);return;case"none":return}});let G=v?m.working:m.accent,ge=y.length?y.split(`
|
|
2
|
-
`):[""],B=A.find(s=>s.id===T),D=ne(B?.tier??"",B?.model),pe=O?.rows||24,fe=z.slice(-40);return o(g,{flexDirection:"column",height:pe,children:[o(g,{flexDirection:"column",flexGrow:1,justifyContent:"flex-end",overflow:"hidden",children:[z.length===0&&!$?o(g,{flexDirection:"column",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),c(t,{dimColor:!0,children:" \u2014 chat with "}),o(t,{color:m.accent,children:["@",T]}),c(t,{dimColor:!0,children:" via "}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" (",B.model,")"]}):null]}),c(t,{dimColor:!0,children:"streaming \xB7 markdown \xB7 tools \xB7 type a message, or / for commands"})]}):null,fe.map(s=>c(ce,{turn:s,width:V},s.id)),$?c(ce,{turn:$,width:V}):null]}),N?c(g,{flexDirection:"column",marginTop:1,children:N.map((s,e)=>o(g,{children:[c(t,{color:e===0?m.accent:m.muted,bold:e===0,children:s.cmd.padEnd(10)}),c(t,{dimColor:!0,children:s.desc})]},s.cmd))}):j?o(g,{marginTop:1,children:[c(t,{color:m.accent,children:"\u21B9 "}),j.items.map((s,e)=>o(t,{color:e===0?m.accent:m.muted,children:[s,e<j.items.length-1?" ":""]},e))]}):J?c(g,{marginTop:1,children:c(t,{dimColor:!0,children:J})}):null,c(g,{borderStyle:"single",borderColor:G,borderLeft:!1,borderRight:!1,borderDimColor:!v,width:"100%",children:c(g,{flexDirection:"column",width:"100%",children:ge.map((s,e,r)=>o(g,{children:[c(t,{color:G,bold:!0,children:e===0?"\u203A ":" "}),c(t,{children:s}),e===r.length-1&&!v?c(t,{color:G,children:"\u258F"}):null]},e))})}),o(g,{justifyContent:"space-between",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),o(t,{dimColor:!0,children:[" \xB7 @",T," \xB7 "]}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" ",re(B.model)]}):null]}),o(t,{dimColor:!0,children:["\u21B5 send / cmds @ mention esc ",v?"stop":"exit"]})]})]})}function ce({turn:n,width:p}){let f=H(()=>ye(n,p),[n,p]),a=n.segs.some(h=>h.type==="text"&&h.content);return o(g,{flexDirection:"column",marginBottom:1,children:[o(t,{color:m.accent,bold:!0,children:[F," you"]}),n.you.split(`
|
|
3
|
-
`).map((h,w)=>o(t,{color:"white",children:[" ",h]},`u${w}`)),o(t,{color:m.agent,bold:!0,children:[F," ",n.agentId??"agent"]}),n.thinking?c(g,{flexDirection:"column",children:we(n.thinking,n.live?3:2).map((h,w)=>o(t,{dimColor:!0,italic:!0,children:[" ",h]},`th${w}`))}):null,f,n.live?c(te,{startedAt:n.startedAt,phase:a?"responding":"thinking",hint:"esc to interrupt"}):n.interrupted?o(t,{dimColor:!0,children:[" \u2298 interrupted \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s"]}):n.error?o(t,{color:"red",children:[" \u2717 ",n.error]}):n.elapsedMs!=null?o(t,{dimColor:!0,children:[" \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s",n.outTokens!=null?`, ${n.outTokens} tok`:""]}):null]})}function we(n,p){return n.split(`
|
|
4
|
-
`).filter(a=>a.trim()).slice(-p)}function ye(n,p){let f=[];return n.segs.forEach((a,h)=>{a.type==="tool"?f.push(o(t,{color:a.error?"red":"green",children:[" ","\u25CF ",o(t,{bold:!a.error,dimColor:a.error,children:[a.name,a.arg?o(t,{dimColor:!0,children:["(",a.arg,")"]}):null,a.error?" failed":""]})]},h)):a.content&&f.push(c(t,{children:Ce(Y(a.content,p,{balance:n.live}))},h))}),f}function Ce(n){return n.split(`
|
|
5
|
-
`).map(p=>p.length?" "+p:p).join(`
|
|
6
|
-
`)}export{Pe as ChatApp};
|
|
7
|
-
//# sourceMappingURL=ChatApp-N4P7M2TD.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-7L54Z4EH.js";import"./chunk-F3CMNSON.js";import"./chunk-PMSL4A5Y.js";import"./chunk-JTFCU5LH.js";import"./chunk-6NQ7KYJH.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-2KYGPVTX.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-BERWTVG2.js";import"./chunk-AHWWJ7AF.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-P6WSD2UR.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{i as JUDGE_ENTRY_CHARS,e as WEAK_CITATION,j as buildJudgePrompt,l as buildScorecard,f as checkArticle,n as envelopeUsage,h as findDuplicates,k as parseJudgeReply,b as pickSample,m as renderScorecard,a as seededRandom,o as summariseRuns,d as termOverlap,c as terms,g as uncitedWithFacts};
|
|
2
|
-
//# sourceMappingURL=absorb-eval-HRWWPKT3.js.map
|