agentix-cli 0.115.0 → 0.117.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/apps/mac-voice/Sources/AgentXVoice/AnswerView.swift +24 -2
- package/apps/mac-voice/Sources/AgentXVoice/ListenAgain.swift +26 -0
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +54 -0
- package/dist/{App-6OMMZW2M.js → App-UQP7UQYV.js} +2 -2
- package/dist/{ChatApp-EDDROHNA.js → ChatApp-VGSP5O6N.js} +2 -2
- package/dist/{agent-VPM3EEUB.js → agent-MO27U4Y7.js} +2 -2
- package/dist/{board-dashboard-4GQ7RTH3.js → board-dashboard-CSS7XMIZ.js} +255 -224
- package/dist/board-dashboard-CSS7XMIZ.js.map +1 -0
- package/dist/chunk-2WK5A3UV.js +482 -0
- package/dist/chunk-2WK5A3UV.js.map +1 -0
- package/dist/{chunk-S4XSVAAG.js → chunk-45GOH6F7.js} +2 -2
- package/dist/chunk-45YETJY4.js +2 -0
- package/dist/chunk-45YETJY4.js.map +1 -0
- package/dist/{chunk-CJJULHPJ.js → chunk-4ELAUGOP.js} +4 -4
- package/dist/{chunk-5FY7PWXW.js → chunk-5PPMPCHG.js} +2 -2
- package/dist/{chunk-BU4LE2RT.js → chunk-746KHKT4.js} +2 -2
- package/dist/{chunk-QLB76BGE.js → chunk-BQ2HJ7TS.js} +2 -2
- package/dist/{chunk-PITMPRVP.js → chunk-CKQ2YDFP.js} +2 -2
- package/dist/{chunk-7T7IXLLA.js → chunk-CUZTLQH2.js} +2 -2
- package/dist/chunk-DMHQIACQ.js +3 -0
- package/dist/chunk-DMHQIACQ.js.map +1 -0
- package/dist/chunk-EMGB23H5.js +3 -0
- package/dist/chunk-EMGB23H5.js.map +1 -0
- package/dist/chunk-FJI5GRBH.js +54 -0
- package/dist/chunk-FJI5GRBH.js.map +1 -0
- package/dist/chunk-GRMCAO3Q.js +2 -0
- package/dist/chunk-GRMCAO3Q.js.map +1 -0
- package/dist/{chunk-PX2AOZ5G.js → chunk-HVZVFCJX.js} +2 -2
- package/dist/{chunk-BXYKFWAI.js → chunk-HYGMWCUU.js} +2 -2
- package/dist/{chunk-ECBVOIIK.js → chunk-IZMXAXW3.js} +182 -182
- package/dist/chunk-IZMXAXW3.js.map +1 -0
- package/dist/{chunk-YE4HKOS5.js → chunk-J2YLOGNN.js} +2 -2
- package/dist/{chunk-2NYP4OQU.js → chunk-LNY6N73E.js} +4 -4
- package/dist/{chunk-2NYP4OQU.js.map → chunk-LNY6N73E.js.map} +1 -1
- package/dist/{chunk-EVXL6X2R.js → chunk-MSP25HE5.js} +58 -58
- package/dist/{chunk-EVXL6X2R.js.map → chunk-MSP25HE5.js.map} +1 -1
- package/dist/{chunk-MG5LRE5B.js → chunk-OJ7KM2UO.js} +2 -2
- package/dist/{chunk-4STXRZZS.js → chunk-PFK3QO6S.js} +2 -2
- package/dist/{chunk-K3BG77KK.js → chunk-PMQ47IPT.js} +2 -2
- package/dist/{chunk-KTF4YF4M.js → chunk-T2VDHVYW.js} +2 -2
- package/dist/{chunk-J5TZ6QGD.js → chunk-VEHTVYP6.js} +2 -2
- package/dist/{chunk-SDOSQ6TJ.js → chunk-VRXJW6JJ.js} +2 -2
- package/dist/{chunk-UQX2HY5M.js → chunk-W7WNRPNQ.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-VUNPLVCG.js → client-5UMNDY7Z.js} +2 -2
- package/dist/{config-HE2LGTTG.js → config-O44DOHFW.js} +2 -2
- package/dist/config-mutator-PRLY2TCE.js +2 -0
- package/dist/doctor-NKPH74F7.js +2 -0
- package/dist/index.d.ts +55 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{program-53CQJEUZ.js → program-RHIJYCEJ.js} +191 -187
- package/dist/program-RHIJYCEJ.js.map +1 -0
- package/dist/{promote-4PPJJ6AW.js → promote-ZRNVPWTD.js} +2 -2
- package/dist/push-DID6RZYI.js +2 -0
- package/dist/push-bridge-VPTQNM43.js +2 -0
- package/dist/push-store-L5QHMSST.js +2 -0
- package/dist/{query-ETDKC7WC.js → query-HURONGKA.js} +2 -2
- package/dist/{registry-AMETOJ3S.js → registry-AYGFAKTC.js} +2 -2
- package/dist/{request-planner-VFWWT5XR.js → request-planner-ZZRSOBQZ.js} +2 -2
- package/dist/{review-candidates-2PI4CGZO.js → review-candidates-KHH47PK7.js} +2 -2
- package/dist/routing-GUBKKWPT.js +2 -0
- package/dist/schedule-tool-VH77T3N3.js +2 -0
- package/dist/scheduler-SZ4YYXJE.js +2 -0
- package/dist/{seat-TVNR245I.js → seat-CVTTTE5V.js} +2 -2
- package/dist/{select-KY7B4HAS.js → select-OUTM6OBC.js} +2 -2
- package/dist/{set-enabled-NEINY2I2.js → set-enabled-2QKQRVUN.js} +2 -2
- package/dist/token-store-AY6OBDVI.js +2 -0
- package/dist/token-store-AY6OBDVI.js.map +1 -0
- package/dist/{tool-5JGMWH62.js → tool-OFXHMLE5.js} +2 -2
- package/dist/{tool-MQQ2W5LJ.js → tool-XY7QGHLV.js} +2 -2
- package/dist/wiki-46GMWX34.js +2 -0
- package/dist/wiki-46GMWX34.js.map +1 -0
- package/package.json +1 -1
- package/dist/board-dashboard-4GQ7RTH3.js.map +0 -1
- package/dist/chunk-2QSG53RN.js +0 -482
- package/dist/chunk-2QSG53RN.js.map +0 -1
- package/dist/chunk-ACFQBLPX.js +0 -3
- package/dist/chunk-ACFQBLPX.js.map +0 -1
- package/dist/chunk-ECBVOIIK.js.map +0 -1
- package/dist/chunk-IGORU3XR.js +0 -54
- package/dist/chunk-IGORU3XR.js.map +0 -1
- package/dist/config-mutator-22AVTST2.js +0 -2
- package/dist/doctor-6RDRST4G.js +0 -2
- package/dist/program-53CQJEUZ.js.map +0 -1
- package/dist/push-HEDA6P3B.js +0 -2
- package/dist/push-HEDA6P3B.js.map +0 -1
- package/dist/push-store-5VJ4FNI4.js +0 -2
- package/dist/routing-M7MDLD7Q.js +0 -2
- package/dist/schedule-tool-2EQ53IOQ.js +0 -2
- package/dist/scheduler-YGVINPZF.js +0 -2
- package/dist/token-store-YBSU2DTV.js +0 -2
- package/dist/wiki-COAUQ6TQ.js +0 -2
- /package/dist/{App-6OMMZW2M.js.map → App-UQP7UQYV.js.map} +0 -0
- /package/dist/{ChatApp-EDDROHNA.js.map → ChatApp-VGSP5O6N.js.map} +0 -0
- /package/dist/{agent-VPM3EEUB.js.map → agent-MO27U4Y7.js.map} +0 -0
- /package/dist/{chunk-S4XSVAAG.js.map → chunk-45GOH6F7.js.map} +0 -0
- /package/dist/{chunk-CJJULHPJ.js.map → chunk-4ELAUGOP.js.map} +0 -0
- /package/dist/{chunk-5FY7PWXW.js.map → chunk-5PPMPCHG.js.map} +0 -0
- /package/dist/{chunk-BU4LE2RT.js.map → chunk-746KHKT4.js.map} +0 -0
- /package/dist/{chunk-QLB76BGE.js.map → chunk-BQ2HJ7TS.js.map} +0 -0
- /package/dist/{chunk-PITMPRVP.js.map → chunk-CKQ2YDFP.js.map} +0 -0
- /package/dist/{chunk-7T7IXLLA.js.map → chunk-CUZTLQH2.js.map} +0 -0
- /package/dist/{chunk-PX2AOZ5G.js.map → chunk-HVZVFCJX.js.map} +0 -0
- /package/dist/{chunk-BXYKFWAI.js.map → chunk-HYGMWCUU.js.map} +0 -0
- /package/dist/{chunk-YE4HKOS5.js.map → chunk-J2YLOGNN.js.map} +0 -0
- /package/dist/{chunk-MG5LRE5B.js.map → chunk-OJ7KM2UO.js.map} +0 -0
- /package/dist/{chunk-4STXRZZS.js.map → chunk-PFK3QO6S.js.map} +0 -0
- /package/dist/{chunk-K3BG77KK.js.map → chunk-PMQ47IPT.js.map} +0 -0
- /package/dist/{chunk-KTF4YF4M.js.map → chunk-T2VDHVYW.js.map} +0 -0
- /package/dist/{chunk-J5TZ6QGD.js.map → chunk-VEHTVYP6.js.map} +0 -0
- /package/dist/{chunk-SDOSQ6TJ.js.map → chunk-VRXJW6JJ.js.map} +0 -0
- /package/dist/{chunk-UQX2HY5M.js.map → chunk-W7WNRPNQ.js.map} +0 -0
- /package/dist/{client-VUNPLVCG.js.map → client-5UMNDY7Z.js.map} +0 -0
- /package/dist/{config-HE2LGTTG.js.map → config-O44DOHFW.js.map} +0 -0
- /package/dist/{config-mutator-22AVTST2.js.map → config-mutator-PRLY2TCE.js.map} +0 -0
- /package/dist/{doctor-6RDRST4G.js.map → doctor-NKPH74F7.js.map} +0 -0
- /package/dist/{promote-4PPJJ6AW.js.map → promote-ZRNVPWTD.js.map} +0 -0
- /package/dist/{push-store-5VJ4FNI4.js.map → push-DID6RZYI.js.map} +0 -0
- /package/dist/{query-ETDKC7WC.js.map → push-bridge-VPTQNM43.js.map} +0 -0
- /package/dist/{registry-AMETOJ3S.js.map → push-store-L5QHMSST.js.map} +0 -0
- /package/dist/{routing-M7MDLD7Q.js.map → query-HURONGKA.js.map} +0 -0
- /package/dist/{schedule-tool-2EQ53IOQ.js.map → registry-AYGFAKTC.js.map} +0 -0
- /package/dist/{request-planner-VFWWT5XR.js.map → request-planner-ZZRSOBQZ.js.map} +0 -0
- /package/dist/{review-candidates-2PI4CGZO.js.map → review-candidates-KHH47PK7.js.map} +0 -0
- /package/dist/{scheduler-YGVINPZF.js.map → routing-GUBKKWPT.js.map} +0 -0
- /package/dist/{seat-TVNR245I.js.map → schedule-tool-VH77T3N3.js.map} +0 -0
- /package/dist/{token-store-YBSU2DTV.js.map → scheduler-SZ4YYXJE.js.map} +0 -0
- /package/dist/{wiki-COAUQ6TQ.js.map → seat-CVTTTE5V.js.map} +0 -0
- /package/dist/{select-KY7B4HAS.js.map → select-OUTM6OBC.js.map} +0 -0
- /package/dist/{set-enabled-NEINY2I2.js.map → set-enabled-2QKQRVUN.js.map} +0 -0
- /package/dist/{tool-5JGMWH62.js.map → tool-OFXHMLE5.js.map} +0 -0
- /package/dist/{tool-MQQ2W5LJ.js.map → tool-XY7QGHLV.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/daemon/app-push.ts","../src/daemon/app-fleet.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"http\"\nimport { mkdirSync, readFileSync, renameSync, writeFileSync } from \"fs\"\nimport { dirname, resolve } from \"path\"\nimport type { TokenRecord } from \"./token-store\"\nimport type { PushStore } from \"@/channels/push-store\"\nimport { PUSH_PREFS, type PushPrefName } from \"@/channels/push-prefs\"\nimport { readJson } from \"./app-fleet\"\n\n// --- Phone app: notifications (/api/app/push*, /api/app/alerts) ---\n//\n// Phase 4 of the mobile epic. Runs behind the device-token check in\n// app-routes.ts. A phone subscribes here; the daemon's PushAdapter reads the\n// same table to deliver. Each subscription is tied to the phone's device\n// token, so `agentx app revoke` also stops that phone's notifications.\n//\n// On a node that relays pushes (channels.push.relayTo), `forward` is set and\n// every call goes to the push host instead, through this node's daemon and\n// the mesh (push-bridge.ts), so a phone paired with any node can turn\n// notifications on (#711).\n\nexport interface AppPushDeps {\n /** Null when this node doesn't send pushes itself; `reason` says why. */\n store: () => PushStore | null\n /** VAPID public key the browser subscribes with, or null without keys. */\n publicKey: () => string | null\n keepRecent: number\n /** channels.push.allowedHosts: push services a phone may subscribe with. */\n allowedHosts: string[]\n reason?: string\n /** Set on a relaying node: sends each call to the push host. */\n forward?: (call: AppPushCall) => Promise<AppPushResult>\n}\n\n/** One phone-app push request, as handled here or by the push host. */\nexport interface AppPushCall {\n path: string\n method: string\n body: Record<string, any>\n device: { id: string; name: string }\n}\n\nexport interface AppPushResult {\n status: number\n body: unknown\n}\n\n/** The routes this module answers. */\nexport function isAppPushPath(path: string): boolean {\n return path === \"/api/app/push\" || path.startsWith(\"/api/app/push/\") || path === \"/api/app/alerts\"\n}\n\nconst MAX_ENDPOINT = 2048\nconst B64URL = /^[A-Za-z0-9_-]{8,256}$/\n\nexport async function handleAppPush(\n req: IncomingMessage,\n res: ServerResponse,\n path: string,\n method: string,\n device: TokenRecord,\n deps: AppPushDeps,\n): Promise<boolean> {\n if (!isAppPushPath(path)) return false\n let body: Record<string, any> = {}\n if (method === \"POST\") {\n try { body = await readJson(req) } catch (e: any) { return json(res, 400, { error: e.message }) }\n }\n const call: AppPushCall = { path, method, body, device: { id: device.id, name: device.name } }\n if (!deps.forward) {\n const out = runAppPush(call, deps)\n return json(res, out.status, out.body)\n }\n let out: AppPushResult\n try {\n out = await deps.forward(call)\n relayedPush.note(call, out)\n } catch (e: any) {\n out = unreachable(call, `${deps.reason ?? \"Can't reach the computer that sends notifications\"}: ${e?.message ?? e}`)\n }\n return json(res, out.status, out.body)\n}\n\n/** On a relaying node: what the push host last said about each phone, for\n * the checks that must answer at once (a finish notification, the\n * announcement switch). Filled from the phone's own calls on their way\n * through, so it is as fresh as the phone's last look at Alerts. */\nexport class RelayedPushState {\n private phones = new Map<string, { subscribed: boolean; prefs: Record<string, boolean> }>()\n private file: string | null = null\n\n /** Keeps the state in `file` too, so a dashboard restart doesn't stop\n * finish notifications until the phone next opens Alerts. Loads it the\n * first time; later calls with the same file do nothing. */\n persistTo(file: string): void {\n if (this.file === file) return\n this.file = file\n try {\n const saved = JSON.parse(readFileSync(file, \"utf-8\")) as Record<string, any>\n for (const [id, p] of Object.entries(saved ?? {})) {\n if (p && typeof p === \"object\" && typeof p.subscribed === \"boolean\") {\n this.phones.set(id, { subscribed: p.subscribed, prefs: pickPrefsFrom(p.prefs) })\n }\n }\n } catch { /* none yet, or unreadable: start empty */ }\n }\n\n note(call: AppPushCall, out: AppPushResult): void {\n if (out.status !== 200 || !out.body || typeof out.body !== \"object\") return\n const body = out.body as Record<string, any>\n const phone = this.phones.get(call.device.id) ?? { subscribed: false, prefs: {} }\n if (call.method === \"GET\" && call.path === \"/api/app/push\") {\n phone.subscribed = body.available === true && Number(body.subscriptions) > 0\n phone.prefs = pickPrefs(body)\n } else if (call.path === \"/api/app/push/prefs\") {\n phone.prefs = { ...phone.prefs, ...pickPrefs(body) }\n } else if (call.path === \"/api/app/push/subscribe\") {\n phone.subscribed = true\n } else if (call.path === \"/api/app/push/unsubscribe\") {\n if (body.removed) phone.subscribed = false\n } else {\n return\n }\n this.phones.set(call.device.id, phone)\n this.save()\n }\n\n private save(): void {\n if (!this.file) return\n try {\n mkdirSync(dirname(this.file), { recursive: true })\n const tmp = `${this.file}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.phones)) + \"\\n\", { encoding: \"utf-8\", mode: 0o600 })\n renameSync(tmp, this.file)\n } catch { /* kept in memory; written again at the next change */ }\n }\n\n /** A switch as last seen, or its default. */\n on(deviceId: string, name: PushPrefName): boolean {\n return this.phones.get(deviceId)?.prefs[PUSH_PREFS[name].field] ?? PUSH_PREFS[name].default\n }\n\n /** Subscribed and wanting finish notifications, as far as last seen. */\n finishOn(deviceId: string): boolean {\n return !!this.phones.get(deviceId)?.subscribed && this.on(deviceId, \"finish\")\n }\n}\n\n/** One per dashboard process. */\nexport const relayedPush = new RelayedPushState()\n\n/** relayedPush, kept in .agentx/ of the folder the dashboard runs in. */\nexport function relayedPushHere(): RelayedPushState {\n relayedPush.persistTo(resolve(process.cwd(), \".agentx/push-relayed.json\"))\n return relayedPush\n}\n\nfunction pickPrefs(body: Record<string, any>): Record<string, boolean> {\n const out: Record<string, boolean> = {}\n for (const p of Object.values(PUSH_PREFS)) if (typeof body[p.field] === \"boolean\") out[p.field] = body[p.field]\n return out\n}\n\nfunction pickPrefsFrom(v: unknown): Record<string, boolean> {\n return v && typeof v === \"object\" && !Array.isArray(v) ? pickPrefs(v as Record<string, any>) : {}\n}\n\n/** What a relaying node answers when the push host can't be reached: the\n * Alerts card says why instead of failing to load. */\nfunction unreachable(call: AppPushCall, reason: string): AppPushResult {\n if (call.method === \"GET\" && call.path === \"/api/app/push\") {\n return { status: 200, body: { available: false, reason, publicKey: null, subscriptions: 0, ...prefDefaults() } }\n }\n if (call.method === \"GET\" && call.path === \"/api/app/alerts\") return { status: 200, body: { items: [], error: reason } }\n return { status: 502, body: { error: reason } }\n}\n\n/** Answers one call against this node's own subscriptions table. Used for\n * a phone paired here, and by the push host for a phone paired with a\n * relaying node (push-bridge.ts), whose device id is then scoped to it. */\nexport function runAppPush(call: AppPushCall, deps: AppPushDeps): AppPushResult {\n const { path, method, body, device } = call\n if (!isAppPushPath(path)) return { status: 404, body: { error: \"not found\" } }\n const store = deps.store()\n const publicKey = store ? deps.publicKey() : null\n const unavailable = !store\n ? deps.reason ?? \"Notifications are not set up on this computer.\"\n : !publicKey ? \"This computer has no push keys yet. On it, run: agentx app push-keys\" : undefined\n\n if (method === \"GET\" && path === \"/api/app/push\") {\n return ok(200, {\n available: !unavailable,\n reason: unavailable ?? null,\n publicKey,\n // Only rows made with the current key count, so a phone subscribed\n // before `push-keys --force` sees 0 and subscribes again.\n subscriptions: store && publicKey ? store.list(device.id).filter((s) => s.publicKey === publicKey).length : 0,\n // Per-phone switches (push-prefs.ts): chatFinish, announce.\n ...(store ? store.prefs.all(device.id) : prefDefaults()),\n })\n }\n if (method === \"GET\" && path === \"/api/app/alerts\") {\n return ok(200, { items: store ? store.recent(deps.keepRecent, device.id) : [] })\n }\n if (method !== \"POST\" || (path !== \"/api/app/push/subscribe\" && path !== \"/api/app/push/unsubscribe\" && path !== \"/api/app/push/prefs\")) {\n return ok(404, { error: \"not found\" })\n }\n if (!store || unavailable) return ok(503, { error: unavailable })\n\n if (path === \"/api/app/push/prefs\") {\n // Any of the switches, each true or false; answers with those it set.\n const changes = (Object.keys(PUSH_PREFS) as PushPrefName[]).filter((n) => body[PUSH_PREFS[n].field] !== undefined)\n const fields = changes.map((n) => PUSH_PREFS[n].field).join(\", \")\n const all = Object.values(PUSH_PREFS).map((p) => p.field).join(\" or \")\n if (changes.length === 0) return ok(400, { error: `send ${all}, true or false` })\n if (changes.some((n) => typeof body[PUSH_PREFS[n].field] !== \"boolean\")) return ok(400, { error: `${fields} must be true or false` })\n const out: Record<string, boolean> = {}\n for (const n of changes) {\n store.prefs.set(device.id, n, body[PUSH_PREFS[n].field])\n out[PUSH_PREFS[n].field] = body[PUSH_PREFS[n].field]\n }\n return ok(200, { ok: true, ...out })\n }\n const endpoint = validEndpoint(body.endpoint, deps.allowedHosts)\n if (!endpoint) {\n let host = \"\"\n try { host = new URL(String(body.endpoint)).hostname } catch { /* not a URL */ }\n return ok(400, { error: `not a known push service${host ? `: ${host}` : \"\"} (see channels.push.allowedHosts)` })\n }\n\n if (path === \"/api/app/push/unsubscribe\") {\n return ok(200, { ok: true, removed: store.unsubscribe(endpoint, device.id) })\n }\n const p256dh = body.keys?.p256dh\n const auth = body.keys?.auth\n if (typeof p256dh !== \"string\" || !B64URL.test(p256dh) || typeof auth !== \"string\" || !B64URL.test(auth)) {\n return ok(400, { error: \"keys.p256dh and keys.auth are required\" })\n }\n // An endpoint belongs to one browser. If another device had it (a phone\n // re-paired under a new name), the latest pairing takes it over.\n // The browser subscribed with the key GET /api/app/push just handed it;\n // `publicKey` in the body must match it, so a stale page can't store a\n // subscription made with replaced keys.\n if (body.publicKey !== undefined && body.publicKey !== publicKey) {\n return ok(409, { error: \"this computer's push keys changed; turn notifications on again\" })\n }\n store.subscribe({ endpoint, p256dh, auth, deviceId: device.id, deviceName: device.name, publicKey: publicKey! })\n return ok(200, { ok: true })\n}\n\nfunction ok(status: number, body: unknown): AppPushResult {\n return { status, body }\n}\n\nfunction prefDefaults(): Record<string, boolean> {\n const out: Record<string, boolean> = {}\n for (const p of Object.values(PUSH_PREFS)) out[p.field] = p.default\n return out\n}\n\n/** The endpoint if it is https on an allowed push-service host (or a\n * subdomain of one). The daemon POSTs to whatever is stored, so a name\n * that merely looks public (and may resolve inside the network) is refused. */\nexport function validEndpoint(v: unknown, allowedHosts: string[]): string | null {\n if (typeof v !== \"string\" || v.length > MAX_ENDPOINT) return null\n try {\n const u = new URL(v)\n if (u.protocol !== \"https:\" || u.port || u.username || u.password) return null\n const host = u.hostname.toLowerCase()\n const ok = allowedHosts.some((h) => {\n const allowed = h.toLowerCase().replace(/^\\.+|\\.+$/g, \"\")\n return !!allowed && (host === allowed || host.endsWith(\".\" + allowed))\n })\n return ok ? v : null\n } catch {\n return null\n }\n}\n\nfunction json(res: ServerResponse, status: number, body: unknown): true {\n res.writeHead(status, { \"Content-Type\": \"application/json\", \"Cache-Control\": \"no-store\" })\n res.end(JSON.stringify(body))\n return true\n}\n","import type { IncomingMessage, ServerResponse } from \"http\"\n\n// --- Phone app: fleet, activity and control (/api/app/fleet, …) ---\n//\n// Phase 3 of the mobile epic. Runs behind the device-token check in\n// app-routes.ts, so every handler here may assume a paired phone.\n//\n// Reads reuse the dashboard's live snapshot (every node the dashboard can\n// see, including peers found through /mesh) and trim it to what a phone\n// shows: short previews, never full prompts, replies or errors. Writes go\n// to a node daemon through the dashboard's allowlisted, token-carrying POST\n// (AppFleetDeps.nodePost), the same path the desktop task and restart\n// buttons use, so the phone gets no power the dashboard doesn't already have.\n\nexport const PREVIEW_CHARS = 160\n\nexport interface SnapshotNode {\n id: string\n name: string\n url: string\n reachable: boolean\n error?: string\n uptimeSec?: number\n inflight?: number\n restart?: { state: string; requestedAt?: string; deadline?: string }\n agents: Array<{\n id: string\n name: string\n tier?: string\n color?: string\n active: number\n errors: number\n lastActive?: string\n lastSummary?: { text: string; at: string; ok: boolean }\n runningTasks?: Array<{ id: string; messagePreview: string; channel: string; chatId?: string; sender?: string; startedAt: string }>\n }>\n crons?: Array<{ id: string; enabled: boolean; schedule: string; agent: string; kind?: string; nextRun?: string; consecutiveErrors: number }>\n cronRuns?: Array<{ jobId: string; startedAt: string; status: string; responseSummary?: string; errorSummary?: string; isRetry?: boolean }>\n}\n\nexport interface ApprovalItem {\n key: string\n title: string\n ask?: string\n recommend?: string\n /** What yes and no do, in words. */\n yes?: string\n no?: string\n raisedBy?: string\n expires?: string\n}\n\nexport interface NodeApprovals {\n node: string\n nodeName: string\n items: ApprovalItem[]\n error?: string\n}\n\nexport interface NodeReply { status: number; body: any }\n\nexport interface AppFleetDeps {\n snapshot(day?: { date: string; timezone: string }): Promise<{ ts: string; nodes: SnapshotNode[] }>\n /** POST to a node daemon on the dashboard's allowlist, with its token. */\n nodePost(nodeUrl: string, path: string, body: unknown): Promise<NodeReply>\n approvals(): Promise<NodeApprovals[]>\n /** `by` names the phone, e.g. \"operator (phone: My phone)\". */\n decide(nodeUrl: string, key: string, action: \"yes\" | \"no\" | \"later\", by: string): Promise<NodeReply>\n}\n\nexport function clip(text: string | undefined, max = PREVIEW_CHARS): string | undefined {\n if (!text) return text\n const flat = text.replace(/\\s+/g, \" \").trim()\n return flat.length > max ? flat.slice(0, max - 1) + \"…\" : flat\n}\n\n/** One node, trimmed for the Fleet tab. Cron outcomes come from the node's\n * persisted run files (cronRuns), never the scheduler's counters. */\nexport function summarizeNode(n: SnapshotNode) {\n const lastRun = new Map<string, NonNullable<SnapshotNode[\"cronRuns\"]>[number]>()\n for (const r of n.cronRuns ?? []) {\n const prev = lastRun.get(r.jobId)\n if (!prev || prev.startedAt < r.startedAt) lastRun.set(r.jobId, r)\n }\n const today = { success: 0, failed: 0 }\n for (const r of n.cronRuns ?? []) {\n if (r.status === \"success\") today.success++\n else today.failed++\n }\n return {\n id: n.id,\n name: n.name,\n url: n.url,\n reachable: n.reachable,\n error: clip(n.error),\n uptimeSec: n.uptimeSec,\n inflight: n.inflight,\n restart: n.restart?.state && n.restart.state !== \"none\" ? n.restart : undefined,\n agents: n.agents.map((a) => ({\n id: a.id,\n name: a.name,\n tier: a.tier,\n active: a.active,\n errors: a.errors,\n lastActive: a.lastActive,\n last: a.lastSummary ? { text: clip(a.lastSummary.text), at: a.lastSummary.at, ok: a.lastSummary.ok } : undefined,\n })),\n crons: {\n today,\n items: (n.crons ?? []).map((c) => {\n const r = lastRun.get(c.id)\n return {\n id: c.id,\n enabled: c.enabled,\n schedule: c.schedule,\n agent: c.agent,\n nextRun: c.nextRun,\n consecutiveErrors: c.consecutiveErrors,\n last: r ? { status: r.status, at: r.startedAt, text: clip(r.status === \"success\" ? r.responseSummary : r.errorSummary) } : undefined,\n }\n }),\n },\n }\n}\n\n/** Every running task across the fleet, newest first. */\nexport function summarizeActivity(nodes: SnapshotNode[]) {\n const tasks = []\n for (const n of nodes) {\n for (const a of n.agents) {\n for (const t of a.runningTasks ?? []) {\n tasks.push({\n node: n.url,\n nodeName: n.name,\n agentId: a.id,\n agentName: a.name,\n taskId: t.id,\n preview: clip(t.messagePreview),\n channel: t.channel,\n startedAt: t.startedAt,\n })\n }\n }\n }\n return tasks.sort((x, y) => (x.startedAt < y.startedAt ? 1 : -1))\n}\n\nconst TASK_ACTION = /^\\/api\\/app\\/tasks\\/(cancel|followup)$/\n\n/** Handles /api/app/{fleet,activity,tasks,nodes,crons,approvals}. Returns\n * false for any other path so the caller can fall through. */\nexport async function handleAppFleet(\n req: IncomingMessage,\n res: ServerResponse,\n path: string,\n method: string,\n device: string,\n deps: AppFleetDeps,\n): Promise<boolean> {\n const url = new URL(req.url || path, \"http://localhost\")\n\n if (method === \"GET\" && (path === \"/api/app/fleet\" || path === \"/api/app/activity\")) {\n const timezone = validTimezone(url.searchParams.get(\"timezone\"))\n const snap = await deps.snapshot({ date: dateIn(timezone), timezone })\n if (path === \"/api/app/activity\") return json(res, 200, { ts: snap.ts, tasks: summarizeActivity(snap.nodes) })\n return json(res, 200, { ts: snap.ts, nodes: snap.nodes.map(summarizeNode) })\n }\n\n if (method === \"GET\" && path === \"/api/app/approvals\") {\n return json(res, 200, { nodes: await deps.approvals() })\n }\n\n if (method !== \"POST\") return false\n const taskAction = path.match(TASK_ACTION)\n const known = taskAction || [\n \"/api/app/nodes/restart\", \"/api/app/nodes/reload\", \"/api/app/crons/toggle\", \"/api/app/approvals/decide\",\n ].includes(path)\n if (!known) return false\n\n let body: Record<string, unknown>\n try { body = await readJson(req) } catch (e: any) { return json(res, 400, { error: e.message }) }\n const node = str(body.node)\n if (!node) return json(res, 400, { error: \"node is required\" })\n const by = `operator (phone: ${device})`\n\n let reply: NodeReply\n if (taskAction) {\n const taskId = str(body.taskId)\n if (!taskId) return json(res, 400, { error: \"taskId is required\" })\n const upstream = `/api/tasks/${encodeURIComponent(taskId)}/${taskAction[1]}`\n if (taskAction[1] === \"cancel\") {\n reply = await deps.nodePost(node, upstream, { reason: `cancelled by ${by}` })\n } else {\n const message = str(body.message)\n if (!message) return json(res, 400, { error: \"message is required\" })\n reply = await deps.nodePost(node, upstream, { message, sender: by })\n }\n } else if (path === \"/api/app/nodes/restart\") {\n reply = await deps.nodePost(node, body.cancel === true ? \"/daemon/restart/cancel\" : \"/daemon/restart\", {})\n } else if (path === \"/api/app/nodes/reload\") {\n reply = await deps.nodePost(node, \"/reload\", {})\n } else if (path === \"/api/app/crons/toggle\") {\n const cronId = str(body.cronId)\n if (!cronId || typeof body.enabled !== \"boolean\") return json(res, 400, { error: \"cronId and enabled (true or false) are required\" })\n reply = await deps.nodePost(node, `/crons/${encodeURIComponent(cronId)}/enabled`, { enabled: body.enabled })\n } else {\n const key = str(body.key)\n const action = body.action\n if (!key || (action !== \"yes\" && action !== \"no\" && action !== \"later\")) {\n return json(res, 400, { error: \"key and action (yes, no or later) are required\" })\n }\n reply = await deps.decide(node, key, action, by)\n }\n return json(res, reply.status, reply.body)\n}\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\nfunction validTimezone(tz: string | null): string {\n if (!tz) return \"UTC\"\n try { new Intl.DateTimeFormat(\"en-US\", { timeZone: tz }); return tz } catch { return \"UTC\" }\n}\n\n/** YYYY-MM-DD for \"today\" in the phone's time zone. */\nexport function dateIn(timezone: string, now = new Date()): string {\n return new Intl.DateTimeFormat(\"en-CA\", { timeZone: timezone, year: \"numeric\", month: \"2-digit\", day: \"2-digit\" }).format(now)\n}\n\nexport async function readJson(req: IncomingMessage, limit = 16 * 1024): Promise<Record<string, unknown>> {\n let size = 0\n const chunks: Buffer[] = []\n for await (const chunk of req) {\n size += (chunk as Buffer).length\n if (size > limit) throw new Error(\"body too large\")\n chunks.push(chunk as Buffer)\n }\n const raw = Buffer.concat(chunks).toString(\"utf-8\").trim()\n if (!raw) return {}\n const parsed = JSON.parse(raw)\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error(\"expected a JSON object\")\n return parsed\n}\n\nfunction json(res: ServerResponse, status: number, body: unknown): true {\n res.writeHead(status, { \"Content-Type\": \"application/json\", \"Cache-Control\": \"no-store\" })\n res.end(JSON.stringify(body))\n return true\n}\n"],"mappings":"wCACA,OAAS,aAAAA,EAAW,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KACnE,OAAS,WAAAC,EAAS,WAAAC,MAAe,OCoE1B,SAASC,EAAKC,EAA0BC,EAAM,IAAmC,CACtF,GAAI,CAACD,EAAM,OAAOA,EAClB,IAAME,EAAOF,EAAK,QAAQ,OAAQ,GAAG,EAAE,KAAK,EAC5C,OAAOE,EAAK,OAASD,EAAMC,EAAK,MAAM,EAAGD,EAAM,CAAC,EAAI,SAAMC,CAC5D,CAIO,SAASC,EAAcC,EAAiB,CAC7C,IAAMC,EAAU,IAAI,IACpB,QAAWC,KAAKF,EAAE,UAAY,CAAC,EAAG,CAChC,IAAMG,EAAOF,EAAQ,IAAIC,EAAE,KAAK,GAC5B,CAACC,GAAQA,EAAK,UAAYD,EAAE,YAAWD,EAAQ,IAAIC,EAAE,MAAOA,CAAC,EAEnE,IAAME,EAAQ,CAAE,QAAS,EAAG,OAAQ,CAAE,EACtC,QAAWF,KAAKF,EAAE,UAAY,CAAC,EACzBE,EAAE,SAAW,UAAWE,EAAM,UAC7BA,EAAM,SAEb,MAAO,CACL,GAAIJ,EAAE,GACN,KAAMA,EAAE,KACR,IAAKA,EAAE,IACP,UAAWA,EAAE,UACb,MAAOL,EAAKK,EAAE,KAAK,EACnB,UAAWA,EAAE,UACb,SAAUA,EAAE,SACZ,QAASA,EAAE,SAAS,OAASA,EAAE,QAAQ,QAAU,OAASA,EAAE,QAAU,OACtE,OAAQA,EAAE,OAAO,IAAKK,IAAO,CAC3B,GAAIA,EAAE,GACN,KAAMA,EAAE,KACR,KAAMA,EAAE,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AYA,EAAE,SAAU,OAAO,KAC1E,IAAML,EAAOK,EAAE,SAAS,YAAY,EAKpC,OAJWD,EAAa,KAAME,GAAM,CAClC,IAAMC,EAAUD,EAAE,YAAY,EAAE,QAAQ,aAAc,EAAE,EACxD,MAAO,CAAC,CAACC,IAAYP,IAASO,GAAWP,EAAK,SAAS,IAAMO,CAAO,EACtE,CAAC,EACWrB,EAAI,IAClB,MAAE,CACA,OAAO,IACT,CACF,CAEA,SAASzB,EAAKP,EAAqBiD,EAAgB7C,EAAqB,CACtE,OAAAJ,EAAI,UAAUiD,EAAQ,CAAE,eAAgB,mBAAoB,gBAAiB,UAAW,CAAC,EACzFjD,EAAI,IAAI,KAAK,UAAUI,CAAI,CAAC,EACrB,EACT","names":["mkdirSync","readFileSync","renameSync","writeFileSync","dirname","resolve","clip","text","max","flat","summarizeNode","n","lastRun","r","prev","today","a","c","summarizeActivity","nodes","tasks","t","x","y","TASK_ACTION","handleAppFleet","req","res","path","method","device","deps","url","timezone","validTimezone","snap","dateIn","json","taskAction","body","readJson","e","node","str","by","reply","taskId","upstream","message","cronId","key","action","v","tz","now","limit","size","chunks","chunk","raw","parsed","status","isAppPushPath","path","MAX_ENDPOINT","B64URL","handleAppPush","req","res","method","device","deps","body","readJson","e","json","call","out","runAppPush","relayedPush","unreachable","RelayedPushState","file","saved","readFileSync","id","p","pickPrefsFrom","phone","pickPrefs","mkdirSync","dirname","tmp","writeFileSync","renameSync","deviceId","name","PUSH_PREFS","relayedPushHere","resolve","v","reason","prefDefaults","store","publicKey","unavailable","ok","s","changes","n","fields","all","endpoint","validEndpoint","host","p256dh","auth","status","allowedHosts","u","h","allowed"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createHash as p,randomBytes as c}from"crypto";import{existsSync as d,mkdirSync as g,readFileSync as l,renameSync as A,writeFileSync as m}from"fs";import{resolve as x,dirname as k}from"path";var a="agx_live_",w=".agentx/tokens.json",h=class{file;constructor(e=process.cwd(),t=w){this.file=x(e,t)}load(){if(!d(this.file))return[];try{return JSON.parse(l(this.file,"utf-8"))}catch{return[]}}save(e){g(k(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.tmp`;m(t,JSON.stringify(e,null,2)+`
|
|
2
|
+
`,"utf-8"),A(t,this.file)}activePhoneIds(e=Date.now()){if(!d(this.file))return[];let t=JSON.parse(l(this.file,"utf-8"));if(!Array.isArray(t))throw new Error(`${this.file} is not a list of tokens`);return t.filter(s=>s?.scopes?.includes("app")&&!s.revokedAt&&!(s.expiresAt&&Date.parse(s.expiresAt)<e)).map(s=>s.id)}create(e){if(!e.name?.trim())throw new Error("Token name is required.");if(!Array.isArray(e.scopes)||e.scopes.length===0)throw new Error("At least one scope is required.");for(let o of e.scopes)if(!v(o))throw new Error(`Invalid scope: ${o}`);let t=c(32).toString("hex"),s=a+t,n={id:"tok_"+c(4).toString("hex"),name:e.name.trim(),prefix:a+t.slice(0,4),hash:u(s),scopes:[...e.scopes],createdAt:new Date().toISOString(),expiresAt:e.expiresInDays?new Date(Date.now()+e.expiresInDays*86400*1e3).toISOString():void 0},i=this.load();return i.push(n),this.save(i),{token:s,record:n}}list(){return this.load()}revoke(e){let t=this.load(),s=t.find(n=>n.id===e);return s?(s.revokedAt=new Date().toISOString(),this.save(t),s):null}isActive(e){let t=this.load().find(s=>s.id===e);return!!t&&!t.revokedAt&&!(t.expiresAt&&Date.parse(t.expiresAt)<Date.now())}verify(e){if(!e||!e.startsWith(a))return null;let t=u(e),s=this.load(),n=s.find(f=>f.hash===t);if(!n||n.revokedAt||n.expiresAt&&Date.parse(n.expiresAt)<Date.now())return null;let i=Date.now(),o=n.lastUsedAt?Date.parse(n.lastUsedAt):0;if(i-o>6e4){n.lastUsedAt=new Date(i).toISOString();try{this.save(s)}catch{}}return n}};function T(r,e){return!!(r.scopes.includes(e)||e.startsWith("agent:")&&r.scopes.includes("agent:*")||e==="dashboard:read"&&r.scopes.includes("dashboard:write"))}function v(r){return r==="dashboard:read"||r==="dashboard:write"||r==="agent:*"||/^agent:[a-z0-9][a-z0-9_-]*$/.test(r)||r==="mesh:peer"||r==="app"||/^member:[a-z0-9][a-z0-9_-]{0,39}$/.test(r)||/^guest:g-[a-z0-9]+-[a-z0-9]+$/.test(r)}function u(r){return"sha256:"+p("sha256").update(r).digest("hex")}function R(r){let e=r.headers.authorization,t=Array.isArray(e)?e[0]:e;if(t&&t.toLowerCase().startsWith("bearer "))return t.slice(7).trim();if(r.url)try{let n=new URL(r.url,"http://localhost").searchParams.get("token");if(n)return n}catch{}return null}export{a,h as b,T as c,u as d,R as e};
|
|
3
|
+
//# sourceMappingURL=chunk-EMGB23H5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/daemon/token-store.ts"],"sourcesContent":["import { createHash, randomBytes } from \"crypto\"\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"fs\"\nimport { resolve, dirname } from \"path\"\n\n// --- Scoped API tokens ---\n//\n// Tokens let external services (other agentx instances, webhook senders, custom\n// apps) talk to this daemon with explicit scopes instead of sharing a single\n// all-powerful dashboard token.\n//\n// We only ever store the sha256 of each token + its printable prefix. The full\n// token is shown exactly once, at creation time, and the operator copies it.\n// Format: agx_live_<hex(32)> — prefix lets secret-scanners catch leaks.\n//\n// Scopes (string equality; \"agent:*\" grants any agent):\n// dashboard:read — /api/live, /api/agents, /api/task/history\n// dashboard:write — /api/admin/*, config mutation endpoints\n// agent:<id> — /api/public/agents/<id>/messages\n// agent:* — any agent\n// mesh:peer — cross-node mesh (forward-compatible — not enforced yet)\n// app — the phone app (/app, /api/app/*) and nothing else;\n// minted per device by `agentx app pair`\n// member:<person> — one teammate's own work page (/member, /api/member/*)\n// and nothing else; minted per machine by\n// `agentx people invite` (#385)\n// guest:<grant> — a guest mesh's key: /mesh/guest/* inside that grant\n// and nothing else; minted by `agentx mesh guests\n// invite` (#380)\n\nexport const TOKEN_PREFIX = \"agx_live_\"\nconst DEFAULT_FILE = \".agentx/tokens.json\"\n\nexport interface TokenRecord {\n id: string // short public id (shown in lists)\n name: string\n prefix: string // full printable prefix (TOKEN_PREFIX + first-4 chars of body)\n hash: string // sha256 of the full token\n scopes: string[]\n createdAt: string\n expiresAt?: string\n revokedAt?: string\n lastUsedAt?: string\n}\n\nexport class TokenStore {\n private file: string\n\n constructor(baseDir: string = process.cwd(), fileRel: string = DEFAULT_FILE) {\n this.file = resolve(baseDir, fileRel)\n }\n\n private load(): TokenRecord[] {\n if (!existsSync(this.file)) return []\n try { return JSON.parse(readFileSync(this.file, \"utf-8\")) as TokenRecord[] } catch { return [] }\n }\n\n private save(records: TokenRecord[]): void {\n mkdirSync(dirname(this.file), { recursive: true })\n // Write then rename, so a reader in another process (the dashboard, the\n // daemon's push roster) never sees a half-written file.\n const tmp = `${this.file}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(records, null, 2) + \"\\n\", \"utf-8\")\n renameSync(tmp, this.file)\n }\n\n /** Ids of the paired phones that are neither revoked nor expired. Unlike\n * list(), throws when the file is there but can't be read or parsed,\n * so a bad read is never taken for \"no phones\" (the push roster would\n * then unsubscribe every one of them on the host, #711). */\n activePhoneIds(now = Date.now()): string[] {\n if (!existsSync(this.file)) return []\n const records = JSON.parse(readFileSync(this.file, \"utf-8\"))\n if (!Array.isArray(records)) throw new Error(`${this.file} is not a list of tokens`)\n return (records as TokenRecord[])\n .filter((r) => r?.scopes?.includes(\"app\") && !r.revokedAt && !(r.expiresAt && Date.parse(r.expiresAt) < now))\n .map((r) => r.id)\n }\n\n /**\n * Mint a new token. Returns the full token string AND the record.\n * The full token is the only place the secret is ever exposed — the caller\n * must surface it to the operator immediately; after this call the store only\n * knows the hash.\n */\n create(input: {\n name: string\n scopes: string[]\n expiresInDays?: number\n }): { token: string; record: TokenRecord } {\n if (!input.name?.trim()) throw new Error(\"Token name is required.\")\n if (!Array.isArray(input.scopes) || input.scopes.length === 0) {\n throw new Error(\"At least one scope is required.\")\n }\n for (const s of input.scopes) {\n if (!isValidScope(s)) throw new Error(`Invalid scope: ${s}`)\n }\n const body = randomBytes(32).toString(\"hex\")\n const token = TOKEN_PREFIX + body\n const record: TokenRecord = {\n id: \"tok_\" + randomBytes(4).toString(\"hex\"),\n name: input.name.trim(),\n prefix: TOKEN_PREFIX + body.slice(0, 4),\n hash: hashToken(token),\n scopes: [...input.scopes],\n createdAt: new Date().toISOString(),\n expiresAt: input.expiresInDays\n ? new Date(Date.now() + input.expiresInDays * 86400 * 1000).toISOString()\n : undefined,\n }\n const records = this.load()\n records.push(record)\n this.save(records)\n return { token, record }\n }\n\n list(): TokenRecord[] {\n return this.load()\n }\n\n revoke(id: string): TokenRecord | null {\n const records = this.load()\n const rec = records.find((r) => r.id === id)\n if (!rec) return null\n rec.revokedAt = new Date().toISOString()\n this.save(records)\n return rec\n }\n\n /** True when the token with this id exists and is neither revoked nor expired. */\n isActive(id: string): boolean {\n const rec = this.load().find((r) => r.id === id)\n return !!rec && !rec.revokedAt && !(rec.expiresAt && Date.parse(rec.expiresAt) < Date.now())\n }\n\n /**\n * Look up a token string. Returns the record on success, null on unknown /\n * revoked / expired. Updates lastUsedAt opportunistically (write-on-success).\n */\n verify(token: string): TokenRecord | null {\n if (!token || !token.startsWith(TOKEN_PREFIX)) return null\n const hash = hashToken(token)\n const records = this.load()\n const rec = records.find((r) => r.hash === hash)\n if (!rec) return null\n if (rec.revokedAt) return null\n if (rec.expiresAt && Date.parse(rec.expiresAt) < Date.now()) return null\n // Throttle lastUsedAt updates to at most once per minute to avoid disk churn.\n const now = Date.now()\n const last = rec.lastUsedAt ? Date.parse(rec.lastUsedAt) : 0\n if (now - last > 60_000) {\n rec.lastUsedAt = new Date(now).toISOString()\n try { this.save(records) } catch { /* best-effort */ }\n }\n return rec\n }\n}\n\n/**\n * Check whether a record has a given required scope. \"agent:<id>\" required\n * matches either itself or \"agent:*\". \"dashboard:write\" implicitly grants\n * \"dashboard:read\" for convenience.\n */\nexport function recordHasScope(record: TokenRecord, required: string): boolean {\n if (record.scopes.includes(required)) return true\n if (required.startsWith(\"agent:\") && record.scopes.includes(\"agent:*\")) return true\n if (required === \"dashboard:read\" && record.scopes.includes(\"dashboard:write\")) return true\n return false\n}\n\nfunction isValidScope(s: string): boolean {\n return (\n s === \"dashboard:read\" ||\n s === \"dashboard:write\" ||\n s === \"agent:*\" ||\n /^agent:[a-z0-9][a-z0-9_-]*$/.test(s) ||\n s === \"mesh:peer\" ||\n s === \"app\" ||\n /^member:[a-z0-9][a-z0-9_-]{0,39}$/.test(s) ||\n /^guest:g-[a-z0-9]+-[a-z0-9]+$/.test(s)\n )\n}\n\nexport function hashToken(token: string): string {\n return \"sha256:\" + createHash(\"sha256\").update(token).digest(\"hex\")\n}\n\n/**\n * Extract a bearer token from the request headers. Falls back to the\n * `?token=` query param so EventSource (which can't set headers in most\n * browsers) can still authenticate.\n */\nexport function extractToken(req: { headers: Record<string, string | string[] | undefined>; url?: string }): string | null {\n const auth = req.headers[\"authorization\"]\n const authHeader = Array.isArray(auth) ? auth[0] : auth\n if (authHeader && authHeader.toLowerCase().startsWith(\"bearer \")) {\n return authHeader.slice(7).trim()\n }\n if (req.url) {\n try {\n const u = new URL(req.url, \"http://localhost\")\n const tok = u.searchParams.get(\"token\")\n if (tok) return tok\n } catch { /* */ }\n }\n return null\n}\n"],"mappings":"AAAA,OAAS,cAAAA,EAAY,eAAAC,MAAmB,SACxC,OAAS,cAAAC,EAAY,aAAAC,EAAW,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KAC/E,OAAS,WAAAC,EAAS,WAAAC,MAAe,OA2B1B,IAAMC,EAAe,YACtBC,EAAe,sBAcRC,EAAN,KAAiB,CACd,KAER,YAAYC,EAAkB,QAAQ,IAAI,EAAGC,EAAkBH,EAAc,CAC3E,KAAK,KAAOH,EAAQK,EAASC,CAAO,CACtC,CAEQ,MAAsB,CAC5B,GAAI,CAACX,EAAW,KAAK,IAAI,EAAG,MAAO,CAAC,EACpC,GAAI,CAAE,OAAO,KA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AAMY,EAAO,IAAQ,CACvBF,EAAI,WAAa,IAAI,KAAKV,CAAG,EAAE,YAAY,EAC3C,GAAI,CAAE,KAAK,KAAKF,CAAO,CAAE,MAAE,CAA0B,EAEvD,OAAOY,CACT,CACF,EAOO,SAASG,EAAeN,EAAqBO,EAA2B,CAG7E,MAFI,GAAAP,EAAO,OAAO,SAASO,CAAQ,GAC/BA,EAAS,WAAW,QAAQ,GAAKP,EAAO,OAAO,SAAS,SAAS,GACjEO,IAAa,kBAAoBP,EAAO,OAAO,SAAS,iBAAiB,EAE/E,CAEA,SAASH,EAAaD,EAAoB,CACxC,OACEA,IAAM,kBACNA,IAAM,mBACNA,IAAM,WACN,8BAA8B,KAAKA,CAAC,GACpCA,IAAM,aACNA,IAAM,OACN,oCAAoC,KAAKA,CAAC,GAC1C,gCAAgC,KAAKA,CAAC,CAE1C,CAEO,SAASK,EAAUF,EAAuB,CAC/C,MAAO,UAAYtB,EAAW,QAAQ,EAAE,OAAOsB,CAAK,EAAE,OAAO,KAAK,CACpE,CAOO,SAASS,EAAaC,EAA8F,CACzH,IAAMC,EAAOD,EAAI,QAAQ,cACnBE,EAAa,MAAM,QAAQD,CAAI,EAAIA,EAAK,CAAC,EAAIA,EACnD,GAAIC,GAAcA,EAAW,YAAY,EAAE,WAAW,SAAS,EAC7D,OAAOA,EAAW,MAAM,CAAC,EAAE,KAAK,EAElC,GAAIF,EAAI,IACN,GAAI,CAEF,IAAMG,EADI,IAAI,IAAIH,EAAI,IAAK,kBAAkB,EAC/B,aAAa,IAAI,OAAO,EACtC,GAAIG,EAAK,OAAOA,CAClB,MAAE,CAAc,CAElB,OAAO,IACT","names":["createHash","randomBytes","existsSync","mkdirSync","readFileSync","renameSync","writeFileSync","resolve","dirname","TOKEN_PREFIX","DEFAULT_FILE","TokenStore","baseDir","fileRel","records","tmp","now","r","input","s","isValidScope","body","token","record","hashToken","id","rec","hash","last","recordHasScope","required","extractToken","req","auth","authHeader","tok"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import{b as M,d as B,h as We}from"./chunk-BRK6M6LA.js";import{l as U,m as F,n as Ke}from"./chunk-UIBUZ2N3.js";import{a as P,e as ze}from"./chunk-2QNT5JDS.js";import{a as m,b as He}from"./chunk-QIJLFPWE.js";import{z as i}from"zod";var Xe,Ze,Ge,Ye,Ve,Je,Qe,et,tt,H,z=m(()=>{"use strict";Xe=i.enum(["mon","tue","wed","thu","fri","sat","sun"]),Ze=i.object({days:i.array(Xe).default(["mon","tue","wed","thu","fri"]),start:i.string().regex(/^\d{2}:\d{2}$/),end:i.string().regex(/^\d{2}:\d{2}$/),lunch:i.object({start:i.string().regex(/^\d{2}:\d{2}$/),end:i.string().regex(/^\d{2}:\d{2}$/)}).optional()}),Ge=i.object({title:i.string(),responsibilities:i.array(i.string()).default([]),sopPath:i.string().optional(),kpis:i.array(i.string()).default([])}),Ye=i.object({role:i.string(),reportsTo:i.string().optional(),schedule:Ze,utilizationTarget:i.number().min(0).max(1).default(.8)}),Ve=i.object({channel:i.string(),chatId:i.string(),accountId:i.string().optional()}),Je=i.discriminatedUnion("type",[i.object({type:i.literal("backlog"),path:i.string().default(".agentx/backlog.md")}),i.object({type:i.literal("gitlab"),projects:i.array(i.string()).default([])}),i.object({type:i.literal("wiki"),path:i.string(),glob:i.string().default("**/*.md")})]),Qe=i.object({id:i.string(),pm:i.string().optional(),client:i.string().optional()}),et=i.object({channel:i.string().optional(),chatId:i.string().optional(),username:i.string().optional(),senderId:i.string().optional(),client:i.string(),project:i.string().optional(),displayName:i.string().optional()}),tt=i.object({name:i.string().optional(),kind:i.enum(["client","internal","own"]).optional(),respondWithin:i.string().optional(),standing:i.array(i.string()).default([])}),H=i.object({enabled:i.boolean().default(!1),timezone:i.string().default("UTC"),mainChannel:Ve,workSource:Je,roles:i.record(i.string(),Ge).default({}),orgChart:i.record(i.string(),Ye).default({}),projects:i.array(Qe).default([]),contactMap:i.array(et).default([]),clients:i.record(i.string(),tt).default({}),workTickMinutes:i.number().int().min(1).max(60).default(15),idleQueueThreshold:i.number().int().min(0).default(0),standup:i.object({enabled:i.boolean().default(!0),plansDir:i.string().default(".agentx/plans"),maxAgentsPerDay:i.number().int().min(1).max(100).default(20),dryRun:i.boolean().default(!1)}).default({})})});import{z as d}from"zod";function _n(r,n){let t=new Set(r.labels||[]);if(r.state==="closed"){let o=n.find(s=>s.kind==="closed");if(o)return o.id}for(let o of n)if(o.kind==="scoped-label"&&o.scopedLabel&&t.has(o.scopedLabel))return o.id;for(let o of n)if(o.kind==="label"&&o.mapsToLabel&&t.has(o.mapsToLabel))return o.id;let a=n.find(o=>o.kind==="open-backlog");if(a){let o=a.scopedPrefix+"::";return[...t].some(l=>l.startsWith(o))?null:a.id}return n[0]?.id??null}function Tn(r,n){let t=[],a=[],o=!1,s=!1;return n.kind==="scoped-label"&&n.scopedLabel?t.push(n.scopedLabel):n.kind==="label"&&n.mapsToLabel?t.push(n.mapsToLabel):n.kind==="closed"&&(o=!0),r&&(r.kind==="scoped-label"&&r.scopedLabel?a.push(r.scopedLabel):r.kind==="label"&&r.mapsToLabel?a.push(r.mapsToLabel):r.kind==="closed"&&n.kind!=="closed"&&(s=!0)),{addLabels:t.length?t:void 0,removeLabels:a.length?a:void 0,closeIssue:o||void 0,reopen:s||void 0}}var nt,rt,at,ot,st,it,W,lt,K,X=m(()=>{"use strict";nt=d.object({name:d.string(),color:d.string().regex(/^#[0-9a-f]{6}$/i).default("#6366f1"),description:d.string().optional()}),rt=d.object({id:d.string().regex(/^[a-z0-9_-]+$/,"column id must be lowercase slug"),title:d.string(),kind:d.enum(["open-backlog","scoped-label","closed","label"]).default("label"),mapsToLabel:d.string().optional(),scopedLabel:d.string().optional(),scopedPrefix:d.string().default("Status"),accent:d.string().optional()}),at=d.object({enabled:d.boolean().default(!0),staleDoingMinutes:d.number().int().min(1).default(45),respectLunchBreak:d.boolean().default(!0),respectSchedule:d.boolean().default(!0),action:d.enum(["badge","notify"]).default("badge")}),ot=d.discriminatedUnion("type",[d.object({type:d.literal("gitlab"),projects:d.array(d.string()).min(1)})]),st=[{id:"open",title:"Open",kind:"open-backlog",scopedPrefix:"Status",accent:"#6b7280"},{id:"todo",title:"To Do",kind:"scoped-label",scopedLabel:"Status::To Do",scopedPrefix:"Status",accent:"#fb7a35"},{id:"doing",title:"Doing",kind:"scoped-label",scopedLabel:"Status::Doing",scopedPrefix:"Status",accent:"#22c55e"},{id:"onhold",title:"On Hold",kind:"scoped-label",scopedLabel:"Status::On Hold",scopedPrefix:"Status",accent:"#f59e0b"},{id:"review",title:"Review",kind:"scoped-label",scopedLabel:"Status::Review",scopedPrefix:"Status",accent:"#3b82f6"},{id:"closed",title:"Closed",kind:"closed",scopedPrefix:"Status",accent:"#6b7280"}],it=d.object({id:d.string().regex(/^[a-z0-9_-]+$/,"board id must be lowercase slug"),name:d.string(),source:ot,primaryToolLabel:d.string().optional(),labels:d.array(nt).default([]),columns:d.array(rt).min(1).default(st),timeRangeDays:d.number().int().min(1).max(365).default(30),closedWindowDays:d.number().int().min(1).max(365).default(30),reconciliation:at.default({})}),W=d.array(it).default([]),lt=d.object({name:d.string(),url:d.string(),dashboardUrl:d.string().optional(),token:d.string().optional(),dashboardToken:d.string().optional()}),K=d.object({enabled:d.boolean().default(!1),port:d.number().int().default(4202),bind:d.string().default("127.0.0.1"),token:d.string().optional(),daemonUrl:d.string().default("http://localhost:18800"),daemons:d.array(lt).default([]),draftAgent:d.string().optional()}).default({})});function ft(r){let n=String(r??"").trim().toLowerCase();if(!n)return{ok:!1,error:"is empty"};let t=n.split("+").map(s=>s.trim());if(t.some(s=>!s))return{ok:!1,error:`"${r}" has an empty part; write it like opt+space`};let a=gt[t[t.length-1]]??t[t.length-1],o=new Set;for(let s of t.slice(0,-1)){let l=dt[s];if(!l)return{ok:!1,error:`"${s}" is not a modifier; use ctrl, opt, shift or cmd`};if(o.has(l))return{ok:!1,error:`"${r}" names ${l} twice`};o.add(l)}return mt(a)?!Z(a)&&!["ctrl","opt","cmd"].some(s=>o.has(s))?{ok:!1,error:`"${r}" needs ctrl, opt or cmd, or it would take that key away from your typing`}:{ok:!0,value:[...ut.filter(s=>o.has(s)),a].join("+")}:{ok:!1,error:`"${a}" is not a key AgentX Voice can use; use a letter, a digit, f1 to f20, or space, period, comma, slash, return, tab`}}function G(r){let n=ft(r);return n.ok?void 0:n.error}function Rn(r){let n={ctrl:"\u2303",opt:"\u2325",shift:"\u21E7",cmd:"\u2318"},t={space:"Space",period:".",comma:",",slash:"/",semicolon:";",quote:"'",minus:"-",equal:"=",leftbracket:"[",rightbracket:"]",backslash:"\\",grave:"`",return:"Return",tab:"Tab"},a=r.split("+"),o=a.pop()??"";return a.map(s=>n[s]??s).join("")+(t[o]??o.toUpperCase())}var dt,ut,ct,gt,Z,mt,k,Y=m(()=>{"use strict";dt={ctrl:"ctrl",control:"ctrl",opt:"opt",option:"opt",alt:"opt",shift:"shift",cmd:"cmd",command:"cmd"},ut=["ctrl","opt","shift","cmd"],ct=["space","period","comma","slash","semicolon","quote","minus","equal","leftbracket","rightbracket","backslash","grave","return","tab"],gt={".":"period",",":"comma","/":"slash",";":"semicolon","'":"quote","-":"minus","=":"equal","`":"grave",enter:"return"},Z=r=>/^f([1-9]|1[0-9]|20)$/.test(r),mt=r=>/^[a-z0-9]$/.test(r)||ct.includes(r)||Z(r);k={talk:"opt+space",stop:"cmd+opt+period",paste:"cmd+opt+v"}});function Q(r){let n=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(r);if(!n)return null;let[t,a,o]=n.slice(1).map(b=>parseInt(b,16)/255),s=Math.max(t,a,o),l=Math.min(t,a,o),u=s-l;return u<.04?null:((s===t?(a-o)/u%6:s===a?(o-t)/u+2:(t-a)/u+4)*60+360)%360}function pt(r){let n=Q(r);if(n===null)return y.find(o=>o.id==="lagoon");let t=y[0],a=360;for(let o of y){let s=Math.abs(o.hue-n),l=Math.min(s,360-s);l<a&&(t=o,a=l)}return t}function In(r,n=E){let t=l=>y.find(u=>u.id===l),a=t(r?.palette);if(a)return{...a,set:!0};let o=r?.color;return{...o&&Q(o)!==null?pt(o):t(n)??t(E),set:!1}}var y,V,J,L,E,ee=m(()=>{"use strict";y=[{id:"sunrise",label:"Sunrise",hue:18,colors:["#E8505B","#F2726F","#F79A5A","#FBBF4A","#FFE3A3"]},{id:"desert",label:"Desert",hue:36,colors:["#A4492C","#C8683E","#D9905E","#E7B98A","#F6E3C4"]},{id:"forest",label:"Forest",hue:100,colors:["#2F5D34","#4C7D3A","#6FA046","#9CC25E","#D5EBA4"]},{id:"lagoon",label:"Lagoon",hue:172,colors:["#0B6E73","#0E9594","#1FBFB2","#56DCCB","#B8F4EA"]},{id:"ocean",label:"Ocean",hue:205,colors:["#15457E","#1C6BA8","#2B93CF","#5DBBE8","#BFE6FA"]},{id:"dusk",label:"Dusk",hue:268,colors:["#2E2A7A","#5B3E9E","#8C4FB0","#C8649E","#F4A7B9"]},{id:"blossom",label:"Blossom",hue:330,colors:["#A3245B","#CF3F78","#E8699A","#F49BB8","#FFD6E0"]}],V=["orb","character"],J=["off","rarely","sometimes","often"],L=y.map(r=>r.id);E="lagoon"});function te(r){let n=(r.match(/[-ۿ]/g)??[]).length,t=(r.match(/[a-zA-ZÀ-ÿ]/g)??[]).length;if(n&&n>=t)return"ar";let a=0,o=0;for(let s of r.toLowerCase().replace(/[’]/g,"'").match(/[a-zà-ÿœ']+/g)??[])bt.has(s)&&a++,ht.has(s)||s.startsWith("l'")||s.startsWith("d'")||s.startsWith("qu'")?o++:xt.test(s)&&(o+=.5);return a===o?null:a>o?"en":"fr"}var bt,ht,xt,ne=m(()=>{"use strict";bt=new Set("the and is are was were i you he she we they it this that to of in for with not but yes what have has will would can your my".split(" ")),ht=new Set("le la les des du de un une et est sont je tu il elle nous vous ils elles ce cette c'est pas pour que qui avec dans sur au aux mais tr\xE8s oui non merci bonjour votre mon".split(" ")),xt=/[éèêëàâçùûîïôœ]/});function jn(r,n=O){let t=r;if(t=t.replace(/```[\s\S]*?```/g,". "),t=t.replace(/`[^`]*`/g,""),t=t.replace(/\*\*(.*?)\*\*/g,"$1"),t=t.replace(/__(.*?)__/g,"$1"),t=t.replace(/\*([^*]+)\*/g,"$1"),t=t.replace(/_([^_]+)_/g,"$1"),t=t.replace(/~~(.*?)~~/g,"$1"),t=t.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),t=t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"image$1 "),t=t.replace(/^#{1,6}\s+/gm,""),t=t.replace(/^[\s]*[-*+]\s+/gm,". "),t=t.replace(/^[\s]*\d+\.\s+/gm,". "),t=t.replace(/^[-=_]{3,}$/gm,""),t=t.replace(/^>\s*/gm,""),t=t.replace(/https?:\/\/\S+/g,"link"),t=t.replace(/\/\w+(\/\w+)+/g,a=>a.split("/").filter(Boolean).join(" slash ")),t=t.replace(/&/g," and "),t=t.replace(/@/g," at "),t=t.replace(/=>/g," returns "),t=t.replace(/->/g," to "),t=t.replace(/\|/g," or "),t=t.replace(/\be\.g\./gi,"for example"),t=t.replace(/\bi\.e\./gi,"that is"),t=t.replace(/\betc\./gi,"etcetera"),t=t.replace(/\bvs\.?\b/gi,"versus"),t=t.replace(/\n{2,}/g,". "),t=t.replace(/\n/g," "),t=t.replace(/\s+/g," "),t=t.replace(/\.\s*\./g,"."),t=t.replace(/\s+([.,!?])/g,"$1"),t=t.trim().replace(/^[.,:;]+\s*/,""),t.length>n){let a=t.slice(0,n),o=([...t.slice(0,n+1).matchAll(/[.!?؟](?=\s)/g)].at(-1)?.index??-1)+1;t=(o>=n/2?a.slice(0,o):a.replace(/\s+\S*$/,"")+"...")+" "+yt[te(a)??"en"]}return t}var O,yt,re=m(()=>{"use strict";ne();O=500,yt={en:"The rest is on screen.",fr:"La suite est \xE0 l'\xE9cran.",ar:"\u0627\u0644\u0628\u0627\u0642\u064A \u0639\u0644\u0649 \u0627\u0644\u0634\u0627\u0634\u0629."}});function qn(r,n=j){let t=new Set(n.map(ae)),a=r.replace(/\[([^\][]*)\]|\(([^()]*)\)/g,(o,s,l)=>t.has(ae(s??l))?"":o);return!/[\p{L}\p{N}]/u.test(a)}var j,$n,ae,oe=m(()=>{"use strict";j=["background noise","noise","mumbling","babbling","unintelligible","inaudible","muffled speech","pause","silence","music","outro jingle","blank audio"],$n="I didn't catch that.",ae=r=>r.toLowerCase().replace(/[_\s]+/g," ").trim()});import{z as c}from"zod";var se,St,ie,le=m(()=>{"use strict";se=c.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use HH:MM, 24-hour"),St=c.object({id:c.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/,"lowercase letters, digits, - and _"),enabled:c.boolean().default(!0),chats:c.array(c.string().min(1)).default([]),senders:c.array(c.string().min(1)).default([]),agent:c.string().min(1),prompt:c.string().max(4e3).optional(),quietHours:c.object({start:se,end:se}).optional(),autoAck:c.boolean().default(!1)}).refine(r=>r.chats.length>0||r.senders.length>0,{message:"a rule needs at least one chat or sender"}),ie=c.object({enabled:c.boolean().default(!1),secretEnv:c.string().regex(/^[A-Z_][A-Z0-9_]*$/).default("WACLI_WEBHOOK_SECRET"),batchSeconds:c.number().int().min(0).max(600).default(20),timezone:c.string().optional(),allowAutoAck:c.boolean().default(!1),describeMedia:c.boolean().default(!0),wacli:c.object({bin:c.string().default("wacli"),account:c.string().optional(),store:c.string().optional()}).default({}),rules:c.array(St).default([])}).default({})});function kt(r){r.exec(`
|
|
2
|
+
CREATE TABLE IF NOT EXISTS requests (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
state TEXT NOT NULL,
|
|
5
|
+
channel TEXT NOT NULL,
|
|
6
|
+
chat_id TEXT NOT NULL,
|
|
7
|
+
sender TEXT,
|
|
8
|
+
agent_id TEXT NOT NULL,
|
|
9
|
+
text TEXT NOT NULL,
|
|
10
|
+
created_at INTEGER NOT NULL,
|
|
11
|
+
updated_at INTEGER NOT NULL,
|
|
12
|
+
attention_reason TEXT,
|
|
13
|
+
notified_at INTEGER,
|
|
14
|
+
question TEXT,
|
|
15
|
+
closed_at INTEGER,
|
|
16
|
+
evidence TEXT,
|
|
17
|
+
close_reason TEXT
|
|
18
|
+
);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_requests_state_created ON requests(state, created_at);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_requests_chat ON requests(agent_id, channel, chat_id, created_at);
|
|
21
|
+
CREATE TABLE IF NOT EXISTS request_links (
|
|
22
|
+
request_id TEXT NOT NULL,
|
|
23
|
+
kind TEXT NOT NULL,
|
|
24
|
+
ref TEXT NOT NULL,
|
|
25
|
+
at INTEGER NOT NULL,
|
|
26
|
+
PRIMARY KEY (kind, ref),
|
|
27
|
+
FOREIGN KEY (request_id) REFERENCES requests(id) ON DELETE CASCADE
|
|
28
|
+
);
|
|
29
|
+
CREATE INDEX IF NOT EXISTS idx_request_links_request ON request_links(request_id);
|
|
30
|
+
`),F(r,"requests",U);let n=r.prepare("PRAGMA table_info(requests)").all();for(let[t,a]of[["pickup_at","INTEGER"],["owner_note","TEXT"],["note_said","INTEGER"],["asked_agent","TEXT"]])if(!n.some(o=>o.name===t))try{r.exec(`ALTER TABLE requests ADD COLUMN ${t} ${a}`)}catch(o){if(!/duplicate column name/i.test(String(o?.message)))throw o}}function Un(r){return!!r.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'requests'").get()}function h(r){return{id:r.id,state:r.state,channel:r.channel,chatId:r.chat_id,sender:r.sender??null,person:r.person??null,agentId:r.agent_id,text:r.text,createdAt:r.created_at,updatedAt:r.updated_at,attentionReason:r.attention_reason??null,notifiedAt:r.notified_at??null,question:r.question??null,closedAt:r.closed_at??null,evidence:r.evidence??null,closeReason:r.close_reason??null,ownerNote:r.owner_note??null,noteSaid:!!r.note_said,askedAgent:r.asked_agent??null}}var x,f,N,$,p,de,ue=m(()=>{"use strict";Ke();x=["in_progress","waiting_owner","waiting_other","needs_attention"],f=["done","declined","dropped"],N=4e3,$=500;p=r=>Array(r).fill("?").join(","),de=class{constructor(n){this.db=n;kt(n),n.pragma("foreign_keys = ON")}addCandidate(n){this.db.prepare(`INSERT OR IGNORE INTO requests (id, state, channel, chat_id, sender, person, agent_id, text, created_at, updated_at)
|
|
31
|
+
VALUES (?, 'candidate', ?, ?, ?, ?, ?, ?, ?, ?)`).run(n.id,n.channel,n.chatId,n.sender??null,n.person??null,n.agentId,n.text.slice(0,N),n.now,n.now),this.link(n.id,"run",n.runId,n.now)}get(n){let t=this.db.prepare("SELECT * FROM requests WHERE id = ?").get(n);return t?h(t):null}byLink(n,t){let a=this.db.prepare("SELECT r.* FROM requests r JOIN request_links l ON l.request_id = r.id WHERE l.kind = ? AND l.ref = ?").get(n,t);return a?h(a):null}link(n,t,a,o){this.db.prepare("INSERT OR IGNORE INTO request_links (request_id, kind, ref, at) VALUES (?, ?, ?, ?)").run(n,t,a,o)}links(n){return this.db.prepare("SELECT kind, ref, at FROM request_links WHERE request_id = ? ORDER BY at, rowid").all(n)}lastAnswer(n){try{return this.db.prepare(`SELECT t.agent_id AS agentId, t.final_response AS text, COALESCE(t.finished_at, t.started_at) AS at
|
|
32
|
+
FROM request_links l JOIN task_traces t ON t.task_id = l.ref
|
|
33
|
+
WHERE l.request_id = ? AND l.kind = 'run' AND t.final_response IS NOT NULL AND t.final_response != ''
|
|
34
|
+
ORDER BY t.started_at DESC LIMIT 1`).get(n)??null}catch{return null}}touch(n,t){this.db.prepare("UPDATE requests SET updated_at = ? WHERE id = ?").run(t,n)}progress(n,t,a="in_progress"){this.db.prepare(`UPDATE requests SET state = ?, updated_at = ?, attention_reason = NULL, notified_at = NULL, question = NULL
|
|
35
|
+
WHERE id = ? AND state NOT IN (${p(f.length)})`).run(a,t,n,...f)}waitOnOwner(n,t,a){this.db.prepare(`UPDATE requests SET state = 'waiting_owner', updated_at = ?, question = ?, attention_reason = NULL, notified_at = NULL
|
|
36
|
+
WHERE id = ? AND state NOT IN (${p(f.length)})`).run(a,t.slice(0,N),n,...f)}needsAttention(n,t,a){return this.db.prepare(`UPDATE requests SET state = 'needs_attention', updated_at = ?, attention_reason = ?, notified_at = NULL
|
|
37
|
+
WHERE id = ? AND state NOT IN ('needs_attention', ${p(f.length)})`).run(a,t.replace(/\s+/g," ").trim().slice(0,$),n,...f).changes>0}close(n,t,a,o){let s=a.trim();if(!s)throw new Error(t==="done"?"a finished request needs a link to the evidence":`a ${t} request needs a reason`);return this.db.prepare(`UPDATE requests SET state = ?, closed_at = ?, updated_at = ?, evidence = ?, close_reason = ?
|
|
38
|
+
WHERE id = ? AND state NOT IN (${p(f.length)})`).run(t,o,o,t==="done"?s.slice(0,$):null,t==="done"?null:s.slice(0,$),n,...f).changes>0}discardCandidate(n){return this.db.prepare("DELETE FROM requests WHERE id = ? AND state = 'candidate'").run(n).changes>0}listOpen(){return this.db.prepare(`SELECT * FROM requests WHERE state IN (${p(x.length)}) ORDER BY created_at, rowid`).all(...x).map(h)}quietSince(n,t){return this.db.prepare(`SELECT * FROM requests WHERE state IN (${p(n.length)}) AND updated_at < ? ORDER BY created_at, rowid`).all(...n,t).map(h)}awaitingNotice(){return this.db.prepare("SELECT * FROM requests WHERE state = 'needs_attention' AND notified_at IS NULL ORDER BY created_at, rowid").all().map(h)}markNotified(n,t){this.db.prepare("UPDATE requests SET notified_at = ? WHERE id = ?").run(t,n)}listByState(n){return this.db.prepare("SELECT * FROM requests WHERE state = ? ORDER BY created_at, rowid").all(n).map(h)}requestPickup(n,t){return this.db.prepare(`UPDATE requests SET state = 'in_progress', updated_at = ?, attention_reason = NULL, notified_at = NULL, pickup_at = ?
|
|
39
|
+
WHERE id = ? AND state = 'needs_attention'`).run(t,t,n).changes>0}handOff(n,t,a,o){return this.db.prepare(`UPDATE requests SET agent_id = ?, state = 'in_progress', updated_at = ?, attention_reason = NULL, notified_at = NULL,
|
|
40
|
+
question = NULL, pickup_at = ?, owner_note = ?, note_said = NULL, asked_agent = COALESCE(asked_agent, agent_id)
|
|
41
|
+
WHERE id = ? AND state IN (${p(x.length)})`).run(t,o,o,a.trim().slice(0,N)||null,n,...x).changes>0}setNoteSaid(n,t,a){this.db.prepare(`UPDATE requests SET note_said = ? WHERE id = ? AND owner_note = ?${a?" AND pickup_at IS NULL":""}`).run(a?1:null,n,t)}takePickups(){return this.db.prepare("UPDATE requests SET pickup_at = NULL WHERE pickup_at IS NOT NULL RETURNING *").all().map(h).filter(n=>n.state==="in_progress").sort((n,t)=>n.createdAt-t.createdAt)}pruneClosed(n){return this.db.prepare(`DELETE FROM requests WHERE state IN (${p(f.length)}) AND closed_at < ?`).run(...f,n).changes}}});function zn(r){return Object.assign({channel:me,chatId:r,sender:"operator"},{[fe]:!0})}function Wn(r){return!!r&&r[fe]===!0}function _t(r,n,t,a=!1){let o=_(n);if(r.channels.length&&!r.channels.map(_).includes(o))return!1;if(T.has(o))return a&&!Et.has((t?.name??"").toLowerCase());let s=wt.has(o)?t?.username:t?.id,l=s?ce(o,s):"";return l?r.from.some(u=>{let g=u.trim().toLowerCase(),b=g.indexOf(":");return b>0&&g.slice(0,b)===o&&ce(o,g.slice(b+1))===l}):!1}function Kn(r){if(!r)return;let n=a=>typeof a=="string"&&a?a.slice(0,120):void 0,t={name:n(r.sender),id:n(r.senderId),username:n(r.senderUsername)};return t.name||t.id||t.username?t:void 0}function Tt(r){return/\btimed? ?out\b|timeout/i.test(r)?"timed out":"failed"}var me,fe,T,Et,_,wt,ce,w,S,ge,pe=m(()=>{"use strict";ue();me="requests",fe=Symbol("requests.pickup");T=new Set(["voice","app","dashboard","webrtc"]),Et=new Set(["camera"]),_=r=>r.toLowerCase().split("@")[0],wt=new Set(["github","gitlab"]),ce=(r,n)=>r==="whatsapp"?n.replace(/@.*$/,"").replace(/\D/g,""):n.trim().toLowerCase().replace(/^@/,"");w=(r,n=200)=>{let t=r.replace(/\s+/g," ").trim();return t.length>n?`${t.slice(0,n-1)}\u2026`:t},S=(r,n,t)=>`${r}\0${n}\0${t}`,ge=class{constructor(n,t,a,o=Date.now){this.store=n;this.settings=t;this.log=a;this.now=o}live=new Map;guard(n,t){try{t()}catch(a){this.log(`[requests] ${n} failed: ${a?.message??a}`)}}isListedOwner(n){let t=_(n.channel),a=this.settings().channels;return a.length&&!a.map(_).includes(t)?!1:n.person?.role==="owner"&&!T.has(t)}liveRequestId(n,t,a){return this.live.get(S(n,t,a))?.requestId??null}taskStarted(n){n.taskId&&this.guard("capture",()=>{if(!this.settings().enabled)return;let t=this.now(),a=n.resumedFrom?this.store.byLink("run",n.resumedFrom):null,o=S(n.agentId,n.channel,n.chatId);if(a){this.store.link(a.id,"run",n.taskId,t),a.state==="candidate"?this.store.touch(a.id,t):this.store.progress(a.id,t),this.live.set(o,{requestId:a.id,runId:n.taskId});return}let s=n.pickup&&n.channel===me?this.store.get(n.chatId):null;if(s&&s.agentId===n.agentId){this.store.link(s.id,"run",n.taskId,t),this.store.touch(s.id,t),this.live.set(o,{requestId:s.id,runId:n.taskId});return}!n.humanRoot||!(_t(this.settings(),n.channel,n.sender,n.operator===!0)||this.isListedOwner(n))||(this.live.set(o,{requestId:`req-${n.taskId}`,runId:n.taskId}),this.store.addCandidate({id:`req-${n.taskId}`,runId:n.taskId,channel:n.channel,chatId:n.chatId,sender:n.sender?.name??n.sender?.username??n.sender?.id??null,person:n.person?.id??null,agentId:n.agentId,text:n.requestText??n.fullMessage??n.messagePreview,now:t}))})}taskCompleted(n){n.taskId&&this.guard("run end",()=>{let t=S(n.agentId,n.channel,n.chatId);this.live.get(t)?.runId===n.taskId&&this.live.delete(t);let a=this.store.byLink("run",n.taskId);if(!a)return;let o=this.now();if(!n.interrupted){if(n.error&&n.errorKind!=="cancelled"){let s=Tt(n.error);this.store.needsAttention(a.id,`${n.agentId} ${s}: ${w(n.error)}`,o)&&this.log(`[requests] ${a.id} needs attention: run ${n.taskId} ${s}`);return}a.state==="candidate"?this.store.discardCandidate(a.id):this.store.touch(a.id,o)}})}delegationStarted(n){this.guard("delegation start",()=>{if(!this.settings().enabled)return;let t=this.live.get(S(n.caller,n.origin.channel,n.origin.chatId));if(!t)return;let a=this.now();this.store.link(t.requestId,"delegation",n.id,a),this.store.progress(t.requestId,a,"waiting_other")})}delegationDone(n,t,a){this.guard("delegation end",()=>{let o=this.store.byLink("delegation",n.id);if(!o)return;let s=this.now(),l=n.peer?`${n.callee} on ${n.peer}`:n.callee;if(t==="done"){this.store.progress(o.id,s);return}let u={error:"failed",timeout:"did not answer in time",lost:"was lost in a restart"}[t];this.store.needsAttention(o.id,`The work handed to ${l} ${u}: ${w(a)}`,s)&&this.log(`[requests] ${o.id} needs attention: delegation ${n.id} ${t}`)})}cardRaised(n,t){t&&this.guard("card",()=>{if(!this.settings().enabled)return;let a=this.live.get(S(n.raised_by,t.channel,t.chatId))?.requestId;if(!a)return;let o=this.now();this.store.link(a,"card",n.id,o),this.store.waitOnOwner(a,n.ask,o)})}cardResolved(n){this.guard("card result",()=>{let t=this.store.byLink("card",n.id);if(!t)return;let a=this.now(),o=n.outcome??n.if_silent;n.status==="decided"||o==="approve"?t.state==="waiting_owner"&&this.store.progress(t.id,a):this.store.needsAttention(t.id,`Your answer did not come before the card expired (${w(n.ask)}); "${o}" was applied`,a)&&this.log(`[requests] ${t.id} needs attention: card ${n.id} expired unanswered`)})}closingNote(n){try{let t=this.store.byLink("delegation",n);return!t||!x.includes(t.state)?void 0:`This is part of the owner's open request ${t.id}. It stays on their list until it is closed. If it is finished now, close it with agentx_request: {action:"done", id:"${t.id}", evidence:"<link to the proof>"}. If you will not do it, use decline with the reason. If work goes on, leave it open.`}catch{return}}resumeOutcome(n){this.guard("restart",()=>{let t=this.store.byLink("run",n.taskId);if(!t)return;let a=this.now();n.decision==="resumed"?t.state==="candidate"?this.store.touch(t.id,a):this.store.progress(t.id,a):(n.decision==="reported"||n.decision==="resume-failed"||n.decision==="skipped")&&this.store.needsAttention(t.id,`Cut off by a restart and not picked up again (${w(n.reason)})`,a)&&this.log(`[requests] ${t.id} needs attention: run ${n.taskId} cut off by a restart`)})}}});import{randomBytes as At,timingSafeEqual as he}from"crypto";import{chmodSync as Rt,existsSync as vt,mkdirSync as It,readFileSync as Ct,writeFileSync as Lt}from"fs";import{networkInterfaces as Ot}from"os";import{dirname as jt,resolve as Nt}from"path";function Jn(r){return Object.assign(r,{[xe]:!0})}function ye(r){return!!r&&r[xe]===!0}function qt(r=process.cwd()){return Nt(r,".agentx","operator.key")}function Qn(r=process.cwd(),n={}){let t=qt(r);try{if(vt(t)){let o=Ct(t,"utf-8").trim();if(o)return o}if(!n.create)return null;let a=At(32).toString("hex");return It(jt(t),{recursive:!0}),Lt(t,a+`
|
|
42
|
+
`,{mode:384}),Rt(t,384),a}catch{return null}}function Dt(r,n){let t=Array.isArray(n)?n[0]:n;if(!r||!t)return!1;let a=Buffer.from(r),o=Buffer.from(t.trim());return a.length===o.length&&he(a,o)}function Mt(r,n,t,a){if(!r||typeof r!="object")return!1;let o=String(r.channel??"").toLowerCase().split("@")[0];return a.has(o)?Dt(t,n[$t]):!1}function Bt(r,n){let t=r[Pt];if((Array.isArray(t)?t[0]:t)!=="1")return!1;let a=r.authorization,o=(Array.isArray(a)?a[0]:a)||"",s=o.toLowerCase().startsWith("bearer ")?o.slice(7).trim():"";if(!s)return!1;let l=Buffer.from(s);for(let u of n){if(!u)continue;let g=Buffer.from(u);if(g.length===l.length&&he(g,l))return!0}return!1}function Ut(r,n=Ft()){let t=be(r??"");if(!t||t==="::1"||t.startsWith("127."))return!0;for(let a of n)if(be(a)===t)return!0;return!1}function Ft(){return Object.values(Ot()).flatMap(r=>(r??[]).map(n=>n.address))}function er(r,n,t){if(Mt(r,n.headers,t.key,t.operatorChannels))return!0;if(!r||typeof r!="object")return!1;let a=String(r.channel??"").toLowerCase().split("@")[0];return!t.operatorChannels.has(a)||Ut(n.remoteAddress,t.ownAddresses)?!1:Bt(n.headers,t.peerTokens)}var $t,xe,Pt,be,Se=m(()=>{"use strict";$t="x-agentx-operator",xe=Symbol("requests.operator");Pt="x-agentx-operator-vouch";be=r=>r.toLowerCase().replace(/^::ffff:/,"").replace(/%.*$/,"")});function sr(r,n){return r.find(t=>t.id===n)?.name??(n===A?"Owner":n)}function ke(r,n){let t=n.trim().toLowerCase();return r==="whatsapp"?t.replace(/@.*$/,"").replace(/\D/g,""):t.replace(/^@/,"")}function Ee(r){let n=r.indexOf(":");if(n<=0||n===r.length-1)return null;let t=q(r.slice(0,n).trim()),a=ke(t,r.slice(n+1));return a?{channel:t,value:a}:null}function we(r){let n=new Set,t=new Map;for(let a of r){if(n.has(a.id))return`person "${a.id}" is listed twice`;if(n.add(a.id),a.id===A&&a.role!=="owner")return`the id "${A}" is kept for a person with the owner role`;for(let o of a.identities){let s=Ee(o);if(!s)return`identity "${o}" of "${a.id}" must be written channel:id`;let l=`${s.channel}:${s.value}`,u=t.get(l);if(u&&u!==a.id)return`identity "${o}" belongs to both "${u}" and "${a.id}"`;t.set(l,a.id)}}return null}function Ht(r,n,t){let a=q(n),s=(a==="whatsapp"?[t?.id]:[t?.id,t?.username]).filter(l=>typeof l=="string"&&!!l).map(l=>ke(a,l)).filter(Boolean);return s.length?r.find(l=>l.identities.some(u=>{let g=Ee(u);return!!g&&g.channel===a&&s.includes(g.value)}))??null:null}function zt(r){let n=r.filter(t=>t.role==="owner");return n.length===0?{id:A,role:"owner"}:n.length===1?{id:n[0].id,role:"owner"}:null}function _e(r,n){let t=M(n);if(t)return t.person?{id:t.person}:null;if(!n||B(n)!=="human")return null;let a=String(n.channel??"");if(T.has(q(a)))return ye(n)?zt(r):null;let o=l=>typeof l=="string"?l:void 0,s=Ht(r,a,{id:o(n.senderId),username:o(n.senderUsername)});return s?{id:s.id,role:s.role}:null}function Wt(r,n){let t=r.agents??[];return r.role==="owner"||t.length===0||t.includes(n)}function ir(r,n,t){let a=_e(r,t);if(!a)return null;let o=r.find(l=>l.id===a.id);if(!o||Wt(o,n))return null;let s=(o.agents??[]).join(", ");return{person:o,note:`${o.name}, you can reach ${s} here, not ${n}. Ask the owner if you need ${n}.`}}function lr(r,n){let t=r.trim().split("*").map(a=>a.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"i").test(n.trim())}function dr(r,n){let t=_e(r,n);if(!t)return null;let a=r.find(l=>l.id===t.id);if(!a||a.role==="owner")return null;let o=a.deny?.tools??[],s=a.deny?.skills??[];return!o.length&&!s.length?null:{personId:a.id,name:a.name,tools:[...o],skills:[...s]}}var or,A,q,Te=m(()=>{"use strict";We();pe();Se();or=["owner","member","client","guest"],A="owner";q=r=>r.toLowerCase().split("@")[0]});function Ae(r){let n=new Set(Kt);return r.map(t=>t.trim()).filter(t=>t&&!n.has(t))}var Kt,Re=m(()=>{"use strict";Kt=["agentx_generate","agentx_inspect","agentx_skill_match","agentx_detect_output_type","agentx_channel_reply","agentx_channel_label","agentx_send","agentx_send_agent","agentx_recent","agentx_events","agentx_send_contact","agentx_task","agentx_agents","agentx_voice_queue","agentx_call_owner","agentx_camera_ask","agentx_camera_look","agentx_health","agentx_attach_next","agentx_attach_answer","agentx_crons","agentx_schedule","agentx_approval","agentx_request","agentx_debug","agentx_wiki_query","agentx_wiki_patch","agentx_wiki_interview","agentx_graph_review"]});var yn={};He(yn,{INTEGRATION_KINDS:()=>en,approvalsConfigSchema:()=>Ue,callsSchema:()=>$e,cameraBotSchema:()=>Ne,daemonConfigSchema:()=>Fe,eventSubscriptionSchema:()=>je,expandEnvVars:()=>C,loadDaemonConfig:()=>hn,membersConfigSchema:()=>Me,peopleConfigSchema:()=>Pe,personSchema:()=>De,requestStatusConfigSchema:()=>Be,requestsConfigSchema:()=>qe,validateWorkspaces:()=>xn});import{z as e}from"zod";import{readFileSync as Ie,existsSync as v}from"fs";import{resolve as I}from"path";function Xt(r){let n=I(r,".env");if(!v(n))return;let t=Ie(n,"utf-8");for(let a of t.split(`
|
|
43
|
+
`)){let o=a.trim();if(!o||o.startsWith("#"))continue;let s=o.indexOf("=");if(s===-1)continue;let l=o.slice(0,s).trim(),u=o.slice(s+1).trim();process.env[l]||(process.env[l]=u)}}function C(r){if(typeof r=="string")return r.replace(/\$\{(\w+)\}/g,(n,t)=>process.env[t]||"");if(Array.isArray(r))return r.map(C);if(r!==null&&typeof r=="object"){let n={};for(let[t,a]of Object.entries(r))n[t]=C(a);return n}return r}function bn(r,n){let t=[],a=new Set;for(let o of r){let s=o.path.join("."),l=/^channels\.telegram\.accounts\.([^.]+)\.token$/.exec(s);if(l&&o.message.toLowerCase().includes("required")){let u=l[1],g=`tg:${u}`;if(a.has(g))continue;a.add(g),t.push(`Hint: Telegram account "${u}" is enabled but has no bot token.
|
|
44
|
+
Either:
|
|
45
|
+
A) Open ${n} and set channels.telegram.accounts.${u}.token to your bot token (or "\${TG_${u.toUpperCase()}_BOT_TOKEN}" + the matching .env entry).
|
|
46
|
+
B) If you don't need Telegram on this instance, remove the entire "telegram" block under "channels" (or set channels.telegram.enabled to false AND drop accounts.${u}).`)}}return t}function hn(r){let n=r?[r]:[I(process.cwd(),"agentx.json"),I(process.cwd(),".agentx/config.json")];Xt(process.cwd());let t,a;for(let u of n)if(v(u)){t=Ie(u,"utf-8"),a=u;break}if(!t||!a)throw new Error(`No config found. Create agentx.json or .agentx/config.json
|
|
47
|
+
Searched: ${n.join(", ")}`);let o;try{o=JSON.parse(t)}catch(u){throw new Error(`Invalid JSON in ${a}: ${u.message}`)}let s=C(o),l=Fe.safeParse(s);if(!l.success){let u=l.error.issues.map(D=>` ${D.path.join(".")}: ${D.message}`).join(`
|
|
48
|
+
`),g=bn(l.error.issues,a),b=g.length?`
|
|
49
|
+
|
|
50
|
+
${g.join(`
|
|
51
|
+
|
|
52
|
+
`)}`:"";throw new Error(`Config validation failed (${a}):
|
|
53
|
+
${u}${b}`)}return l.data}function xn(r){let n=[];for(let[t,a]of Object.entries(r.agents)){if(!v(a.workspace)){n.push(`Agent "${t}": workspace not found at ${a.workspace}`);continue}if(a.tier==="claude-code"){let l=I(a.workspace,".claude");v(l)||n.push(`Agent "${t}": no .claude/ directory in workspace ${a.workspace}. Claude Code native features (hooks, MCP, skills) won't be available.`)}let o=a.provider||"claude",s=r.providers[o];!["claude-code","codex-cli","opencode"].includes(a.tier)&&(!s||!s.apiKey)&&n.push(`Agent "${t}": provider "${o}" has no API key configured. Set providers.${o}.apiKey in config or use a CLI-backed tier ("claude-code", "codex-cli", or "opencode").`)}for(let[t,a]of Object.entries(r.crons))r.agents[a.agent]||n.push(`Cron "${t}": references unknown agent "${a.agent}"`);if(r.channels.telegram.enabled)for(let[t,a]of Object.entries(r.channels.telegram.accounts))r.agents[a.agentBinding]||n.push(`Telegram account "${t}": references unknown agent "${a.agentBinding}"`);return n}var ve,Zt,Gt,Yt,Vt,Jt,Qt,en,Ce,Le,R,Oe,je,tn,nn,Ne,rn,an,on,sn,ln,dn,un,cn,gn,$e,mn,fn,pn,qe,De,Pe,Me,Be,Ue,Fe,Sn=m(()=>{z();X();ze();Y();ee();re();oe();le();Te();Re();ve=e.array(e.string().min(1)).superRefine((r,n)=>{let t=Ae(r);t.length&&n.addIssue({code:e.ZodIssueCode.custom,message:`not an agentx tool: ${t.join(", ")}. Use the names the agentx server lists, without "mcp__agentx__".`})}),Zt=e.object({apiKey:e.string().optional(),defaultModel:e.string().optional(),baseUrl:e.string().optional(),thinking:e.boolean().optional()}),Gt=e.object({type:e.literal("stdio").optional(),command:e.string(),args:e.array(e.string()).default([]),env:e.record(e.string(),e.string()).optional()}),Yt=e.object({type:e.literal("http"),url:e.string().url(),headers:e.record(e.string(),e.string()).optional()}),Vt=e.union([Yt,Gt]),Jt=e.object({tokenEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),privateAppTokenEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),apiKeyEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),refreshTokenEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),clientIdEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),clientSecretEnv:e.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),auth:e.literal("keyring").optional(),sessionDir:e.string().optional()}).strict(),Qt=e.object({kind:e.string().min(1),label:e.string().min(1),credentials:Jt.default({}),metadata:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()])).default({}),enabled:e.boolean().default(!0)}),en=["telegram-bot","whatsapp","gitlab-user","github-user","gmail","hotmail","smtp","hubspot","salesforce","pipedrive","odoo","trello","linear","asana","jira","notion","stripe","sentry","vercel","twilio","custom"],Ce=e.enum(["system","elevenlabs"]),Le=e.union([e.string(),e.record(e.string(),e.string())]),R=e.string().superRefine((r,n)=>{let t=G(r);t&&n.addIssue({code:e.ZodIssueCode.custom,message:`shortcut ${t}`})}),Oe=e.object({provider:Ce.optional(),system:Le.optional(),fallbacks:e.array(e.string().min(1)).optional(),elevenlabsVoiceId:e.string().optional(),gender:e.enum(["female","male","neutral"]).optional(),style:e.string().optional(),intro:e.string().optional(),narrate:e.enum(["off","on","all"]).optional(),rate:e.number().min(.75).max(1.5).optional(),priority:e.enum(["high","normal","low"]).optional(),hotkey:R.optional()}),je=e.object({kinds:e.array(e.string().min(1)).min(1),agents:e.array(e.string().min(1)).optional(),nodes:e.array(e.string().min(1)).optional(),match:e.string().min(1).optional(),delivery:e.enum(["pull","digest","wake"]).default("pull"),maxPerHour:e.number().int().min(1).max(60).default(4)}),tn=e.object({name:e.string(),workspace:e.string(),tier:e.enum(["claude-code","codex-cli","opencode","sdk","orchestrator"]).default("claude-code"),provider:e.string().optional(),model:e.string().optional(),systemPrompt:e.string().optional(),mentions:e.array(e.string()).default([]),intents:e.array(e.string()).default([]),maxDelegationDepth:e.number().int().min(0).max(50).default(5),mcp:e.record(e.string(),Vt).optional(),codegraph:e.boolean().default(!1),contextStrategy:e.enum(["layered","planner"]).optional(),contextReferences:e.boolean().default(!1),richMessages:e.boolean().default(!0),maxConcurrent:e.number().default(1),maxExecutionMinutes:e.number().int().min(1).max(240).default(20),preSpawnTimeoutSec:e.number().int().min(10).max(3600).default(300),drainTimeoutSeconds:e.number().int().min(0).max(86400).optional(),permissionMode:e.string().default("default"),billing:e.enum(["subscription","api"]).default("subscription"),cloudSessions:e.object({enabled:e.boolean().default(!1),maxPerDay:e.number().int().min(0).default(0),openHours:e.number().min(1).max(168).default(24),launchTimeoutSeconds:e.number().int().min(10).max(600).default(120)}).default({}),toolUseRequired:e.array(e.string()).default([]),gitlabAutoReply:e.boolean().optional(),persistentProcess:e.boolean().default(!1),queueMode:e.enum(["collect","followup","drop"]).default("collect"),heartbeat:e.object({enabled:e.boolean().default(!1),intervalMinutes:e.number().default(30),prompt:e.string().default("Check inbox, pending tasks, and system health. Report anything that needs attention."),channel:e.string().default("heartbeat")}).default({}),access:e.enum(["private","public"]).default("private"),admin:e.boolean().optional(),subscriptions:e.array(je).default([]),integrations:e.array(Qt).default([]),voice:Oe.optional(),presence:e.object({color:e.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),palette:e.enum(L).optional(),initial:e.string().max(2).optional(),label:e.string().optional(),allowActions:e.boolean().optional()}).optional()}),nn=e.object({token:e.string(),agentBinding:e.string(),allowFrom:e.array(e.string()).optional(),pollInbound:e.boolean().default(!0)}),Ne=e.object({frameIntervalSeconds:e.number().int().min(0).max(3600).default(0),maxSessionMinutes:e.number().int().min(1).max(240).default(10),maxFrameEdge:e.number().int().min(160).max(3840).default(1024),keepFrames:e.boolean().default(!1),streamFrameSeconds:e.number().int().min(2).max(60).default(5),streamMaxSeconds:e.number().int().min(10).max(600).default(60)}).default({}),rn=e.object({telegram:e.object({enabled:e.boolean().default(!1),accounts:e.record(e.string(),nn).default({}),policy:e.object({dm:e.enum(["pair","block"]).default("pair"),group:e.enum(["mention-required","all"]).default("mention-required"),allowFrom:e.array(e.string()).optional()}).default({})}).default({}),whatsapp:e.object({enabled:e.boolean().default(!1),sessionDir:e.string().default(".agentx/whatsapp-sessions"),defaultAgent:e.string().optional(),allowFrom:e.array(e.string()).optional(),routes:e.array(e.object({contact:e.string().optional(),group:e.string().optional(),agent:e.string()})).default([]),ingest:e.object({enabled:e.boolean().default(!1),mode:e.enum(["metadata-only","messages"]).default("metadata-only"),allowContacts:e.array(e.string()).default([]),allowGroups:e.array(e.string()).default([]),denyContacts:e.array(e.string()).default([]),denyGroups:e.array(e.string()).default([]),messageCap:e.number().int().min(1).max(500).default(50),historyDays:e.number().int().min(1).max(365).default(30),contactRefreshDays:e.number().int().min(1).max(90).default(7),throttle:e.object({minMsBetweenCalls:e.number().int().min(100).default(1500),maxCallsPerMinute:e.number().int().min(1).default(20),maxChatsPerSweep:e.number().int().min(1).default(25)}).default({}),retentionDays:e.number().int().min(0).default(0)}).default({})}).default({}),gitlab:e.object({enabled:e.boolean().default(!1),webhookPort:e.number().default(18810),webhookSecret:e.string().optional(),host:e.string().default("https://gitlab.com"),token:e.string().optional(),autoReplyLegacy:e.boolean().default(!0),routes:e.array(e.object({project:e.string(),agent:e.string()})).default([]),agentMappings:e.array(e.object({agentId:e.string(),gitlabUsernames:e.array(e.string()).default([]),keywords:e.array(e.string()).default([]),token:e.string().optional(),node:e.string().optional()})).default([]),agentUsernamePrefixes:e.array(e.string().min(1)).default([])}).default({}),github:e.object({enabled:e.boolean().default(!1),autoReplyLegacy:e.boolean().default(!0),cloudSessions:e.boolean().default(!1),token:e.string().optional(),tokenFile:e.string().optional(),appId:e.number().optional(),clientId:e.string().optional(),privateKeyFile:e.string().optional(),webhookSecret:e.string().optional(),routes:e.array(e.object({repo:e.string(),agent:e.string()})).default([]),agentMappings:e.array(e.object({agentId:e.string(),githubUsernames:e.array(e.string()).default([]),token:e.string().optional(),tokenFile:e.string().optional(),node:e.string().optional()})).default([]),issueActions:e.array(e.string().min(1)).default(["opened","reopened","assigned"]),pullRequestActions:e.array(e.string().min(1)).default(["opened","reopened","ready_for_review"]),ignoreOwnChanges:e.boolean().default(!0),debounceSeconds:e.number().min(0).max(3600).default(30)}).default({}),ntfy:e.object({enabled:e.boolean().default(!1),server:e.string().default("https://ntfy.sh"),topic:e.string().optional(),token:e.string().optional(),defaultPriority:e.number().int().min(1).max(5).default(3),defaultTitle:e.string().optional()}).default({}),push:e.object({enabled:e.boolean().default(!1),keysFile:e.string().default(".agentx/push-keys.json"),subject:e.string().regex(/^(mailto:|https:\/\/)/,"must start with mailto: or https://").optional(),relayTo:e.string().optional(),ttlSeconds:e.number().int().min(0).max(2419200).default(86400),keepRecent:e.number().int().min(0).max(1e3).default(50),allowedHosts:e.array(e.string().min(1)).default(["fcm.googleapis.com","push.services.mozilla.com","push.apple.com","notify.windows.com"])}).default({}),webrtc:e.object({enabled:e.boolean().default(!1),stunServers:e.array(e.string()).default(["stun:stun.l.google.com:19302"]),turnServers:e.array(e.object({urls:e.string(),username:e.string().optional(),credential:e.string().optional()})).default([]),allowedCallers:e.array(e.string()).default([]),ringNotify:e.array(e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()})).default([]),callUrlBase:e.string().optional(),bot:e.object({enabled:e.boolean().default(!1),defaultAgentId:e.string().optional(),whisperBackend:e.enum(["auto","mlx","openai"]).default("auto"),whisperModel:e.string().optional(),whisperLanguage:e.string().default("auto"),mlxBinary:e.string().optional(),transcriptChannel:e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()}).optional(),maxCallMinutes:e.number().int().min(1).max(240).default(30)}).default({}),camera:e.object({width:e.number().int().min(160).max(3840).default(1280),height:e.number().int().min(120).max(2160).default(720),frameRate:e.number().int().min(1).max(60).default(15),maxSeconds:e.number().int().min(10).max(7200).default(600),voiceInput:e.boolean().default(!0),speakAnswers:e.boolean().default(!0),bot:Ne}).default({})}).default({})}),an=e.object({enabled:e.boolean().default(!0),schedule:e.string(),timezone:e.string().default("UTC"),agent:e.string(),prompt:e.string().default(""),command:e.string().optional(),timeout:e.number().default(600),model:e.string().optional(),maxOutputTokens:e.number().int().min(50).max(8e3).optional(),autonomy:P.optional(),onError:e.union([e.enum(["log","notify","disable"]),e.array(e.enum(["log","notify","disable"]))]).default("log").transform(r=>Array.isArray(r)?r:[r]),notify:e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()}).optional(),fireToken:e.string().optional(),createdBy:e.string().optional(),approval:e.object({action:e.enum(["create","delete"]),requestedBy:e.string(),requestedAt:e.string()}).optional()}).refine(r=>!!(r.command?.trim()||r.prompt?.trim()),{message:"a cron needs either a prompt (dispatch an agent) or a command (run it directly)"}).refine(r=>!(r.command?.trim()&&r.autonomy&&r.autonomy!=="act"),{message:"autonomy applies to agent routines; a command cron runs no agent (remove autonomy or the command)"}),on=e.object({name:e.string(),triggers:e.array(e.object({pattern:e.string(),channel:e.string().optional()})),allowedContacts:e.array(e.string()).optional(),agent:e.string(),prompt:e.string(),schedule:e.string().optional(),timezone:e.string().default("UTC"),notify:e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()}).optional()}),sn=e.object({url:e.string(),name:e.string(),token:e.string().optional()}),ln=e.object({name:e.string(),agent:e.string(),enabled:e.boolean().default(!0)}),dn=e.object({enabled:e.boolean().default(!1),peers:e.array(sn).default([]),inboxes:e.array(ln).default([]),discovery:e.enum(["static","mdns"]).default("static"),healthCheck:e.object({interval:e.number().default(60),timeout:e.number().default(10)}).default({}),feed:e.object({enabled:e.boolean().default(!0),skipTypes:e.array(e.string().min(1)).default(["task:step"])}).default({}),delegation:e.object({asyncWhenHuman:e.boolean().default(!0),timeoutMinutes:e.number().int().min(1).max(240).default(30)}).default({})}),un=e.object({enabled:e.boolean().default(!1),baseDir:e.string().default(".agentx/graph"),draftAgent:e.string().optional(),reviewAgent:e.string().optional(),autoApproveStructure:e.enum(["strict","extend-leaves","any"]).default("extend-leaves"),autoApproveConfidence:e.number().min(0).max(1).default(1),classifierModel:e.string().default("claude-haiku-4-5-20251001"),retrievalWeights:e.object({graph:e.number().min(0).default(.6),bm25:e.number().min(0).default(.4)}).default({})}).default({}),cn=e.object({mode:e.enum(["off","shadow","active"]).default("off"),backend:e.string().optional(),model:e.string().optional(),timeoutMs:e.number().int().min(100).optional(),temperature:e.number().min(.01).default(1),explore:e.number().min(0).max(1).default(.15),holdout:e.number().min(0).max(1).optional()}).default({}),gn=e.object({enabled:e.boolean().default(!1),dbPath:e.string().default(".agentx/decisions/decisions.sqlite"),redactState:e.boolean().default(!1),keepStateRows:e.number().int().min(0).default(2e3),defaultBackend:e.string().default("local"),backends:e.object({local:e.object({provider:e.string().default("claude-code"),model:e.string().default("claude-haiku-4-5-20251001"),structureMode:e.enum(["auto","tool","text"]).default("auto"),normalizeProbabilities:e.boolean().default(!0),nRetryMalformedStructure:e.number().int().min(0).max(3).default(1),maxStateChars:e.number().int().min(500).default(24e3)}).default({}),simpleJev:e.object({baseUrl:e.string().default("http://127.0.0.1:8000/v1"),model:e.string().optional(),apiKeyEnv:e.string().optional(),timeoutMs:e.number().int().min(100).default(3e4),maxStateChars:e.number().int().min(500).default(6e3),maxChoiceOptions:e.number().int().min(2).max(255).default(50)}).default({}),jev:e.object({baseUrl:e.string().default("https://openrouter.ai/api/alpha"),path:e.string().default("/decisions"),model:e.string().default("jev-latest"),apiKeyEnv:e.string().default("OPENROUTER_API_KEY"),timeoutMs:e.number().int().min(100).default(3e4),maxStateChars:e.number().int().min(500).default(9e4),maxChoiceOptions:e.number().int().min(2).max(255).default(255)}).default({}),typesafe:e.object({baseUrl:e.string().default("https://api.typesafe.ai/v1"),path:e.string().default("/systemone"),model:e.string().default("jev-latest"),apiKeyEnv:e.string().default("TYPESAFE_API_KEY"),timeoutMs:e.number().int().min(100).default(3e4),maxStateChars:e.number().int().min(500).default(9e4),maxChoiceOptions:e.number().int().min(2).max(255).default(255)}).default({})}).default({}),seats:e.record(e.string(),cn).default({}),routing:e.object({cheapModel:e.string().optional(),cheapModels:e.object({"claude-code":e.string().optional(),"codex-cli":e.string().optional()}).optional()}).default({})}).default({}),$e=e.object({allow:e.array(e.string()).default([]),maxPerHour:e.number().int().min(1).max(60).default(3),ringSeconds:e.number().int().min(10).max(300).default(45),maxCallMinutes:e.number().int().min(1).max(240).default(30),ringSound:e.string().regex(/^[\w -]+$/).default("Submarine"),summary:e.boolean().default(!0)}).default({}),mn=e.object({longTaskThreshold:e.number().default(30),destination:e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()}).optional(),channel:e.string().optional(),on:e.object({taskComplete:e.boolean().default(!0),taskError:e.boolean().default(!0),taskQueued:e.boolean().default(!1)}).default({}),local:e.object({banner:e.boolean().default(!0),sound:e.boolean().default(!0),soundName:e.string().regex(/^[\w -]+$/).default("Glass"),volume:e.number().min(0).max(1).default(.4),icon:e.string().optional()}).default({})}).default({}),fn=e.object({x:e.number(),y:e.number(),width:e.number().positive(),height:e.number().positive()}),pn=e.object({maxPixels:e.number().int().positive().default(12e5),timeoutMs:e.number().int().positive().default(5e3),intervalMs:e.number().int().positive().default(100),changeThreshold:e.number().min(0).max(1).default(.015),stableMs:e.number().int().nonnegative().default(400),regions:e.record(e.string().regex(/^[a-z][\w-]*$/),fn).default({}),buffer:e.object({enabled:e.boolean().default(!1),seconds:e.number().positive().max(120).default(10),fps:e.number().positive().max(10).default(2),region:e.string().default("screen"),maxPixels:e.number().int().positive().default(3e5)}).default({})}).default({}),qe=e.object({enabled:e.boolean().default(!1),channels:e.array(e.string().min(1)).default([]),from:e.array(e.string().regex(/^[a-z0-9_-]+:\S+$/i,"use channel:id, for example telegram:123456789")).default([]),staleAfterHours:e.number().positive().max(24*365).default(24),retentionDays:e.number().positive().max(3650).default(90)}).default({}),De=e.object({id:e.string().regex(/^[a-z0-9][a-z0-9_-]{0,39}$/,"lower-case letters, digits, - and _"),name:e.string().min(1).max(80),say:e.string().trim().min(1).max(120).optional(),role:e.enum(["owner","member","client","guest"]).default("member"),identities:e.array(e.string().regex(/^[A-Za-z][\w-]*:\S.*$/,"write it as channel:id")).default([]),agents:e.array(e.string().min(1)).default([]),deny:e.object({tools:e.array(e.string().min(1)).default([]),skills:e.array(e.string().min(1)).default([])}).strict().default({})}),Pe=e.array(De).default([]).superRefine((r,n)=>{let t=we(r);t&&n.addIssue({code:e.ZodIssueCode.custom,message:t})}),Me=e.object({logRetentionDays:e.number().int().min(1).max(3650).default(90)}).default({}),Be=e.object({channels:e.array(e.string().min(1)).default([])}).default({}),Ue=e.object({defaultExpiryDays:e.number().positive().max(365).default(3),maxExpiryDays:e.number().positive().max(365).default(30),laterHours:e.number().positive().max(24*30).default(24),notifyAgent:e.boolean().default(!0),forwardTo:e.string().min(1).optional(),digest:e.object({enabled:e.boolean().default(!0),time:e.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use HH:MM, 24-hour").default("09:00"),timezone:e.string().refine(r=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:r}),!0}catch{return!1}},"unknown timezone").optional(),destination:e.object({channel:e.string(),chatId:e.string(),accountId:e.string().optional()}).optional()}).default({}),popup:e.object({enabled:e.boolean().default(!1),style:e.enum(["card","dialog"]).default("card"),theme:e.enum(["system","light","dark"]).default("system"),speak:e.boolean().default(!0),voice:e.string().regex(/^[\w .()-]+$/,"a voice name, as `say -v '?'` lists them").optional(),sound:e.string().regex(/^[\w -]*$/,"a sound name, like chime or Glass").default("chime"),volume:e.number().min(0).max(1).default(.4),timeoutSeconds:e.number().int().min(10).max(3600).default(600)}).default({}),checkin:e.object({enabled:e.boolean().default(!1),times:e.array(e.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use HH:MM, 24-hour")).default(["11:00","14:00","17:00"]),dailyAt:e.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use HH:MM, 24-hour").default("09:00"),timezone:e.string().refine(r=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:r}),!0}catch{return!1}},"unknown timezone").optional(),lists:e.array(e.string().min(1)).default(["Reminders"]),agent:e.string().min(1).optional(),dueWithinHours:e.number().positive().max(24*30).default(24),maxAsksPerPass:e.number().int().min(1).max(20).default(5),composeTimeoutSeconds:e.number().int().min(30).max(3600).default(300)}).default({})}).default({}),Fe=e.object({node:e.object({id:e.string(),name:e.string(),bind:e.string().default("127.0.0.1:18800"),defaultAgent:e.string().optional()}),providers:e.record(e.string(),Zt).default({}),agents:e.record(e.string(),tn).default({}),channels:rn.default({}),crons:e.record(e.string(),an).default({}),services:e.record(e.string(),on).default({}),notifications:mn,calls:$e,whatsappTriage:ie,approvals:Ue,shutdown:e.object({drainTimeoutSeconds:e.number().int().min(0).max(86400).optional(),restart:e.object({allowBy:e.string().optional(),window:e.string().regex(/^\d{1,2}:\d{2}$/,"window must be HH:MM").optional(),windowWaitMinutes:e.number().int().min(1).max(1440).default(180),forbidOnTimeoutRestart:e.boolean().default(!1)}).default({})}).default({}),resume:e.object({enabled:e.boolean().default(!0),maxAgeMinutes:e.number().int().positive().default(30),maxAttempts:e.number().int().min(0).default(1),reportOnlyChannels:e.array(e.string()).default([]),directChannels:e.array(e.string()).default([]),crashLoop:e.object({restarts:e.number().int().positive().default(3),windowMinutes:e.number().positive().default(10)}).default({})}).default({}),requests:qe,people:Pe,members:Me,requestStatus:Be,reminders:e.object({enabled:e.boolean().default(!1),lists:e.array(e.string().min(1)).default(["AgentX"]),pollSeconds:e.number().int().min(15).default(60),lookbackHours:e.number().positive().default(24),command:e.string().min(1).default("remindctl")}).default({}),app:e.object({android:e.object({packageName:e.string().regex(/^[a-zA-Z][\w]*(\.[a-zA-Z][\w]*)+$/,"must look like com.example.app").default("dev.agentx.phone"),certFingerprints:e.array(e.string().regex(/^([0-9A-Fa-f]{2}:){31}[0-9A-Fa-f]{2}$/,"must be 32 hex pairs separated by colons")).default([])}).default({}),places:e.object({enabled:e.boolean().default(!0),file:e.string().min(1).default(".agentx/places.json"),defaultRadiusMeters:e.number().int().min(50).max(5e4).default(150),minRadiusMeters:e.number().int().min(50).max(5e4).default(100),maxRadiusMeters:e.number().int().min(50).max(5e4).default(5e3),maxPlaces:e.number().int().min(1).max(100).default(50),maxRulesPerPlace:e.number().int().min(1).max(50).default(10),cooldownMinutes:e.number().int().min(0).max(1440).default(10),maxEventAgeMinutes:e.number().int().min(1).max(1440).default(30),syncMinutes:e.number().int().min(15).max(1440).default(60)}).default({})}).default({}),demo:e.object({startupTimeoutSeconds:e.number().int().positive().max(3600).optional()}).default({}),events:e.object({ringSize:e.number().int().min(1).max(1e5).default(1e3)}).default({}),screen:pn,mesh:dn.default({}),meshVoices:e.record(e.string(),Oe.omit({rate:!0,priority:!0,hotkey:!0}).extend({name:e.string().optional()})).default({}),voice:e.object({provider:Ce.default("system"),fallback:e.enum(["system","none"]).default("system"),system:Le.optional(),locale:e.string().default("en"),listener:e.string().optional(),pronunciations:e.array(e.object({written:e.string().trim().min(1).max(80),spoken:e.string().trim().min(1).max(120),languages:e.array(e.enum(["en","fr","ar"])).optional()}).strict()).max(200).default([]),pointer:e.boolean().default(!0),stt:e.enum(["auto","elevenlabs","local"]).default("auto"),allowUnmeasured:e.boolean().default(!1),spokenMaxChars:e.number().int().min(300).max(1500).default(O),noiseFilter:e.object({enabled:e.boolean().default(!0),markers:e.array(e.string()).default(j)}).default({}),localStt:e.enum(["mlx-whisper","parakeet"]).default("mlx-whisper"),endOfTurn:e.enum(["vad","volume"]).default("vad"),hotkeys:e.object({talk:R.default(k.talk),stop:R.default(k.stop),paste:R.default(k.paste)}).default({}),look:e.enum(V).default("orb"),startReduced:e.boolean().default(!1),stroll:e.boolean().default(!1),animations:e.enum(J).default("sometimes"),palette:e.enum(L).default(E),card:e.object({timeout:e.number().min(0).max(600).default(30),maxHeight:e.number().min(120).max(800).default(320)}).default({})}).default({}),business:H.optional(),boards:W,dashboard:K,graph:un,decisions:gn,workflows:e.object({enabled:e.boolean().default(!1),dir:e.string().default(".agentx/workflows"),n8n:e.object({baseUrl:e.string().default(""),apiKey:e.string().default("")}).default({baseUrl:"",apiKey:""}),matching:e.object({enabled:e.boolean().default(!1),mode:e.enum(["suggest","auto"]).default("suggest"),autoRunThreshold:e.number().min(0).max(1).default(.85),suggestThreshold:e.number().min(0).max(1).default(.65)}).default({}),editor:e.enum(["disabled","readonly","edit"]).default("edit")}).default({}),procedures:e.object({enabled:e.boolean().default(!0),dir:e.string().default(".agentx/procedures"),extraction:e.object({enabled:e.boolean().default(!1),onTaskCompletion:e.boolean().default(!1),minOccurrences:e.number().int().min(2).default(3),sinceDays:e.number().int().min(1).default(7),maxClusters:e.number().int().min(1).default(5),via:e.string().optional()}).default({}),injection:e.object({enabled:e.boolean().default(!0),maxProcedures:e.number().int().min(1).default(2),minScore:e.number().min(0).max(1).default(.5)}).default({})}).default({}),webhooks:e.array(e.object({id:e.string().regex(/^[a-z0-9][a-z0-9_-]*$/,"webhook id must be lowercase slug"),source:e.string().min(1),agentId:e.string(),secretEnv:e.string().optional(),description:e.string().optional(),enabled:e.boolean().default(!0),node:e.string().optional(),triggers:e.record(e.string(),e.string()).optional(),defaultWorkflow:e.string().optional()})).default([]),session:e.object({staleMinutes:e.number().int().min(1).max(1440).default(720),maxTurnsPerSession:e.number().int().min(2).max(200).default(40),tierTwoThresholdTokens:e.number().int().min(5e4).max(2e5).default(18e4),tierTwoThresholdTokensByChannel:e.record(e.number().int().min(5e4).max(2e5)).default({}),contextStrategy:e.enum(["layered","planner"]).default("layered"),maxClaudeCodeDispatchesPerHour:e.number().int().min(0).max(1e4).optional(),maxClaudeCodeDispatchesPer5h:e.number().int().min(0).max(5e4).optional(),continuityStateTurns:e.number().int().min(0).max(5).default(0),profileByChannel:e.record(e.enum(["full","lean"])).default({}),lean:e.object({mcpServers:e.array(e.string().min(1)).default(["agentx"]),settingSources:e.array(e.enum(["user","project","local"])).default(["project","local"]),contextOnDemand:e.boolean().default(!0),tools:e.array(e.string().min(1)).default([]),toolsByChannel:e.record(e.array(e.string().min(1))).default({}),agentxTools:ve.default([]),agentxToolsByChannel:e.record(ve).default({})}).default({}),triage:e.object({models:e.object({"claude-code":e.string().min(1).optional(),"codex-cli":e.string().min(1).optional()}).default({}),actions:e.array(e.string().min(1)).default(["labeled","unlabeled","closed"])}).default({}),memoryIndexMaxChars:e.number().int().min(0).max(2e5).default(0),observationPack:e.object({enabled:e.boolean().default(!1),limitBytes:e.number().int().min(1024).max(1048576).default(10240),headBytes:e.number().int().min(0).max(65536).default(1024),tailBytes:e.number().int().min(0).max(65536).default(1024),tools:e.array(e.string().min(1)).default(["Bash","Grep","Read","WebFetch","mcp__.*"]),retentionDays:e.number().int().min(0).max(3650).default(0)}).default({})}).default({}),plugins:e.array(e.string()).default([]),processPool:e.object({maxIdleSeconds:e.number().int().min(5).max(86400).default(30),maxAgeSeconds:e.number().int().min(60).max(86400).default(2700),sweepIntervalSeconds:e.number().int().min(1).max(300).default(5)}).default({})})});export{_n as a,Tn as b,X as c,ft as d,Rn as e,k as f,Y as g,y as h,V as i,J as j,L as k,In as l,ee as m,te as n,ne as o,jn as p,re as q,$n as r,qn as s,oe as t,ie as u,le as v,x as w,f as x,Un as y,de as z,ue as A,zn as B,Wn as C,T as D,Kn as E,ge as F,pe as G,$t as H,Jn as I,ye as J,Qn as K,Mt as L,er as M,Se as N,or as O,A as P,sr as Q,Ee as R,Ht as S,zt as T,_e as U,ir as V,lr as W,dr as X,Te as Y,en as Z,je as _,Ne as $,$e as aa,qe as ba,De as ca,Pe as da,Me as ea,Be as fa,Ue as ga,Fe as ha,C as ia,hn as ja,xn as ka,yn as la,Sn as ma};
|
|
54
|
+
//# sourceMappingURL=chunk-FJI5GRBH.js.map
|