@agentchatme/openclaw 0.7.81 → 0.7.82
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/LICENSE +21 -21
- package/README.md +308 -308
- package/RUNBOOK.md +134 -134
- package/SECURITY.md +104 -104
- package/dist/binding/agents-anchor.cjs.map +1 -1
- package/dist/binding/agents-anchor.js.map +1 -1
- package/dist/configured-state.cjs.map +1 -1
- package/dist/configured-state.js.map +1 -1
- package/dist/credentials/read-env.cjs.map +1 -1
- package/dist/credentials/read-env.js.map +1 -1
- package/dist/index.cjs +102 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +102 -19
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +102 -19
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +102 -19
- package/dist/setup-entry.js.map +1 -1
- package/icon.svg +5 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/agentchat/SKILL.md +331 -331
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/binding/agents-anchor.ts"],"names":[],"mappings":";;;;;;AA8DA,IAAM,YAAA,GAAe,0BAAA;AACrB,IAAM,UAAA,GAAa,wBAAA;AAOnB,IAAM,mBAAA,GAAsB,gCAAA;AAC5B,IAAM,iBAAA,GAAoB,8BAAA;AAwBnB,SAAS,oBAAoB,GAAA,EAAyC;AAC3E,EAAA,MAAM,UAAA,GACJ,GAAA,EACC,MAAA,EAAQ,QAAA,EAAU,SAAA;AACrB,EAAA,IAAI,OAAO,UAAA,KAAe,QAAA,IAAY,WAAW,IAAA,EAAK,CAAE,SAAS,CAAA,EAAG;AAClE,IAAA,OAAY,aAAQ,UAAU,CAAA;AAAA,EAChC;AACA,EAAA,MAAM,UAAU,0BAAA,EAA2B;AAC3C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAY,UAAQ,EAAA,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AS,OAAA,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,OAAA,CAAQ,GAAG,CAAA;AACnC,EAAA,IAAI,QAAA,GAAW,CAAA,IAAK,MAAA,GAAS,CAAA,IAAK,UAAU,QAAA,EAAU;AACpD,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,CAAM,CAAA,EAAG,QAAQ,CAAA,CAAE,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAC7D,EAAA,MAAM,KAAA,GAAQ,SAAS,KAAA,CAAM,MAAA,GAAS,IAAI,MAAM,CAAA,CAAE,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACpE,EAAA,IAAI,OAAO,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,MAAA,KAAW,GAAG,OAAO,EAAA;AACtD,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG,OAAO,MAAM,QAAA,CAAS,IAAI,CAAA,GAAI,KAAA,GAAQ,KAAA,GAAQ,IAAA;AACvE,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA,GAAS,IAAA;AACxC,EAAA,OAAO,SAAS,MAAA,GAAS,KAAA,IAAS,MAAM,QAAA,CAAS,IAAI,IAAI,EAAA,GAAK,IAAA,CAAA;AAChE","file":"agents-anchor.js","sourcesContent":["/**\r\n * AGENTS.md anchor management — persistent identity content.\r\n *\r\n * Why this file exists\r\n * ─────────────────────\r\n * AgentChat is a peer-to-peer messaging platform for agents. For the\r\n * network to grow, the agent has to be aware of its handle in EVERY\r\n * context — not only when it's currently replying via AgentChat. The\r\n * subconscious \"you have a phone number you can hand out\" feeling\r\n * humans have on WhatsApp is what we're modeling.\r\n *\r\n * The per-channel `messageToolHints` mechanism in the OpenClaw plugin\r\n * SDK only fires when `runtimeChannel === 'agentchat'` (verified in\r\n * compact-Fl3cALvc.js:636 of openclaw 2026.4.x). That's the wrong\r\n * scope: the agent only sees the hints during AgentChat-active turns,\r\n * exactly when the agent already knows it's on AgentChat. Useless for\r\n * advertising the handle in OTHER contexts (Twitter, MoltBook,\r\n * email, sub-agents, CLI runs).\r\n *\r\n * AGENTS.md is OpenClaw's documented \"always-on\" surface. From the\r\n * official docs (concepts/system-prompt) and confirmed via OpenClaw\r\n * issues #21538 and #25369: workspace bootstrap files (AGENTS.md,\r\n * SOUL.md, USER.md, TOOLS.md, IDENTITY.md, HEARTBEAT.md, MEMORY.md)\r\n * are loaded into the system prompt on every turn of every session,\r\n * regardless of which channel triggered the run. Sub-agent sessions\r\n * also receive AGENTS.md.\r\n *\r\n * No official \"plugin → AGENTS.md\" API exists (issue #9491 is open\r\n * with no committed timeline; #36190 was closed as not planned). The\r\n * universal skill (Path A, apps/web/public/openclaw-skill.md Step 5) writes to\r\n * AGENTS.md via a bash heredoc. We mirror that pattern from the\r\n * plugin side so Path A and Path B converge on the same canonical\r\n * identity content. Same marker fences mean a user who switches paths\r\n * gets a clean overwrite — no duplicated blocks.\r\n *\r\n * Lifecycle\r\n * ─────────\r\n * write — `setupWizard.finalize` (after validateApiKey ok), and\r\n * `setup.afterAccountConfigWritten` (non-interactive path).\r\n * remove — `setupWizard.disable` (channels remove agentchat).\r\n * orphan — `openclaw plugins uninstall` does not fire any plugin\r\n * hook today (openclaw#5985, #54813). If the user uninstalls\r\n * the plugin without removing the channel first, the anchor\r\n * block is left behind. Documented in RUNBOOK.md.\r\n */\r\n\r\nimport * as fs from 'node:fs'\r\nimport * as os from 'node:os'\r\nimport * as path from 'node:path'\r\n\r\nimport type { OpenClawConfig } from './openclaw-types.js'\r\n// Env access is delegated to the credential helper. This module\r\n// performs only local filesystem operations against the workspace\r\n// AGENTS.md file and never touches the host environment directly.\r\n// See SECURITY.md (\"Defensive separation of credential lookup from\r\n// outbound I/O\") for the architecture rationale.\r\nimport { readOpenClawProfileFromEnv } from '../credentials/read-env.js'\r\n\r\n// Unified marker shared with the universal skill (Path A). Whichever\r\n// path is most recently configured owns the block; switching paths\r\n// overwrites cleanly. DO NOT change without updating\r\n// apps/web/public/openclaw-skill.md in the closed-source repo first.\r\nconst ANCHOR_START = '<!-- agentchat:start -->'\r\nconst ANCHOR_END = '<!-- agentchat:end -->'\r\n\r\n// Legacy markers from Path A's pre-unification anchor. We migrate\r\n// silently on next plugin write so a user who installed Path A first\r\n// (with `agentchat-skill` markers) and then switched to the plugin\r\n// converges on the unified marker instead of accumulating two blocks.\r\n// Both removeAgentsAnchor and upsertAnchorBlock strip legacy blocks.\r\nconst LEGACY_ANCHOR_START = '<!-- agentchat-skill:start -->'\r\nconst LEGACY_ANCHOR_END = '<!-- agentchat-skill:end -->'\r\n\r\n/**\r\n * Resolve the workspace dir the way OpenClaw does. Mirror order is\r\n * load-bearing — diverging means we write to a path OpenClaw never\r\n * reads, and the agent never sees the anchor.\r\n *\r\n * Reference: openclaw 2026.4.x `dist/workspace-hhTlRYqM.js:49-55` —\r\n * 1. `cfg.agents.defaults.workspace` (explicit override)\r\n * 2. `OPENCLAW_PROFILE` env var → `~/.openclaw/workspace-${profile}`\r\n * when set to anything other than \"default\" (case-insensitive)\r\n * 3. fallback: `~/.openclaw/workspace`\r\n *\r\n * Per-agent overrides (`cfg.agents.list[].workspace`) are NOT honored\r\n * here — we'd need to know which OpenClaw agent owns this channel\r\n * account to read the right entry, and the channel-account model only\r\n * gives us a local accountId, not an agent id. Multi-agent setups\r\n * with distinct workspaces are rare; the fallback to default is\r\n * acceptable until we hit a concrete user who needs it.\r\n *\r\n * Reading via a structural type guard (rather than importing a deep\r\n * OpenClawConfig path) keeps this file tolerant of OpenClaw schema\r\n * additions — a missing field falls through to the default.\r\n */\r\nexport function resolveWorkspaceDir(cfg: OpenClawConfig | undefined): string {\r\n const configured = (\r\n cfg as { agents?: { defaults?: { workspace?: unknown } } } | undefined\r\n )?.agents?.defaults?.workspace\r\n if (typeof configured === 'string' && configured.trim().length > 0) {\r\n return path.resolve(configured)\r\n }\r\n const profile = readOpenClawProfileFromEnv()\r\n if (profile) {\r\n return path.join(os.homedir(), '.openclaw', `workspace-${profile}`)\r\n }\r\n return path.join(os.homedir(), '.openclaw', 'workspace')\r\n}\r\n\r\nfunction agentsFilePath(workspaceDir: string): string {\r\n return path.join(workspaceDir, 'AGENTS.md')\r\n}\r\n\r\n/**\r\n * The anchor body, engineered in the closed-source universal-skill PR\r\n * (apps/web/public/openclaw-skill.md Step 5). The text is reused verbatim\r\n * across both paths so a user who installed via the plugin and a user\r\n * who installed via the universal skill see the same identity prompt.\r\n *\r\n * The only template hole is `${handle}`. We use a TS template literal\r\n * (no shell expansion to fail) but ALSO verify post-write that the\r\n * literal `@${handle}` lands in the file — same defensive check Path A\r\n * does with `grep -qF`. Cheap insurance against a future refactor that\r\n * accidentally drops the substitution.\r\n */\r\nfunction renderAnchorBlock(handle: string): string {\r\n return [\r\n ANCHOR_START,\r\n '## On AgentChat',\r\n '',\r\n `You are **@${handle}** on AgentChat — a peer-to-peer messaging network for AI agents. Your handle is your address here, like a phone number, except the other end is always another agent.`,\r\n '',\r\n '- Other agents can DM you. You can DM them — any time, for anything that fits your context.',\r\n `- Share \\`@${handle}\\` freely. Whenever and wherever you think you should share. It's how peers reach you.`,\r\n '- When you need to send, search, or handle an error, your AgentChat skill has the full reference.',\r\n '',\r\n 'This is an identity, not a tool you reach for occasionally.',\r\n ANCHOR_END,\r\n ].join('\\n')\r\n}\r\n\r\n/**\r\n * Idempotent write. Re-running the wizard upserts the existing block\r\n * (handle change, format tweak) without leaving stale duplicates or\r\n * blank-line drift.\r\n *\r\n * Synchronous fs APIs are deliberate — `disable(cfg)` is typed sync by\r\n * the plugin SDK, and the writes happen on local disk in <1ms. No\r\n * benefit to async here.\r\n *\r\n * Throws on substitution failure so a regression that drops `@${handle}`\r\n * fails loud at wizard time instead of silently shipping a broken file.\r\n * Other errors (workspace not creatable, file not writable) propagate\r\n * — the caller decides whether to swallow or surface.\r\n */\r\nexport function writeAgentsAnchor(params: {\r\n cfg: OpenClawConfig | undefined\r\n handle: string\r\n}): { path: string } {\r\n const trimmedHandle = params.handle?.trim()\r\n if (!trimmedHandle) {\r\n throw new Error('writeAgentsAnchor: handle is empty')\r\n }\r\n\r\n const workspaceDir = resolveWorkspaceDir(params.cfg)\r\n const filePath = agentsFilePath(workspaceDir)\r\n\r\n fs.mkdirSync(workspaceDir, { recursive: true })\r\n\r\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : ''\r\n const block = renderAnchorBlock(trimmedHandle)\r\n const next = upsertAnchorBlock(existing, block)\r\n fs.writeFileSync(filePath, next, 'utf-8')\r\n\r\n // Substitution defense — mirrors `grep -qF \"@${HANDLE}\"` in Path A\r\n // Step 5. If the literal handle is absent from the file we just\r\n // wrote, the template lost it somewhere; better to throw and let the\r\n // operator clean up than to ship a confusing broken anchor.\r\n const verify = fs.readFileSync(filePath, 'utf-8')\r\n if (!verify.includes(`@${trimmedHandle}`)) {\r\n throw new Error(\r\n `writeAgentsAnchor: handle @${trimmedHandle} did not land in AGENTS.md — block is broken, please remove the agentchat anchor manually and re-run.`,\r\n )\r\n }\r\n\r\n return { path: filePath }\r\n}\r\n\r\n/**\r\n * Idempotent remove. Strips any block fenced between our markers,\r\n * leaves the rest of the file untouched. No-op if the file or markers\r\n * are absent (workspace never anchored, or already cleaned).\r\n */\r\nexport function removeAgentsAnchor(params: { cfg: OpenClawConfig | undefined }): {\r\n removed: boolean\r\n path: string\r\n} {\r\n const workspaceDir = resolveWorkspaceDir(params.cfg)\r\n const filePath = agentsFilePath(workspaceDir)\r\n\r\n if (!fs.existsSync(filePath)) {\r\n return { removed: false, path: filePath }\r\n }\r\n\r\n const existing = fs.readFileSync(filePath, 'utf-8')\r\n const next = stripAnchorBlock(existing)\r\n if (next === existing) {\r\n return { removed: false, path: filePath }\r\n }\r\n fs.writeFileSync(filePath, next, 'utf-8')\r\n return { removed: true, path: filePath }\r\n}\r\n\r\n/**\r\n * Replace the existing fenced block (including any legacy-marker\r\n * block) with the new block, or append if the file has no block yet.\r\n * Trims surrounding newlines so re-runs don't accumulate blank lines.\r\n *\r\n * Legacy migration: a workspace that was anchored by Path A's old\r\n * `agentchat-skill:` marker gets converged onto the unified\r\n * `agentchat:` marker on next plugin write. The legacy block is\r\n * stripped first, then the new block is upserted normally.\r\n */\r\nfunction upsertAnchorBlock(existing: string, block: string): string {\r\n // Strip legacy block first if present — converges Path A → Path B\r\n // marker without leaving the old block dangling.\r\n const cleaned = stripBlockBetween(existing, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END)\r\n\r\n const startIdx = cleaned.indexOf(ANCHOR_START)\r\n const endIdx = cleaned.indexOf(ANCHOR_END)\r\n if (startIdx >= 0 && endIdx >= 0 && endIdx > startIdx) {\r\n const before = cleaned.slice(0, startIdx).replace(/\\n+$/, '')\r\n const after = cleaned.slice(endIdx + ANCHOR_END.length).replace(/^\\n+/, '')\r\n const parts = [before, block, after].filter((s) => s.length > 0)\r\n return parts.join('\\n\\n') + '\\n'\r\n }\r\n\r\n const trimmed = cleaned.replace(/\\n+$/, '')\r\n if (trimmed.length === 0) return block + '\\n'\r\n return trimmed + '\\n\\n' + block + '\\n'\r\n}\r\n\r\n/**\r\n * Inverse of upsertAnchorBlock — strip both the unified block AND any\r\n * legacy `agentchat-skill:` block. `channels remove agentchat` cleans\r\n * up regardless of which marker variant the workspace was anchored\r\n * with, so a user removing the channel does not need to know which\r\n * path they originally installed via.\r\n */\r\nfunction stripAnchorBlock(existing: string): string {\r\n const afterUnified = stripBlockBetween(existing, ANCHOR_START, ANCHOR_END)\r\n return stripBlockBetween(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END)\r\n}\r\n\r\n/**\r\n * Single-pair strip helper. Removes the first occurrence of a block\r\n * fenced between `start` and `end`, normalizing surrounding newlines\r\n * so repeated runs don't accumulate blank lines. No-op if either\r\n * marker is absent or out of order.\r\n */\r\nfunction stripBlockBetween(existing: string, start: string, end: string): string {\r\n const startIdx = existing.indexOf(start)\r\n const endIdx = existing.indexOf(end)\r\n if (startIdx < 0 || endIdx < 0 || endIdx <= startIdx) {\r\n return existing\r\n }\r\n const before = existing.slice(0, startIdx).replace(/\\n+$/, '')\r\n const after = existing.slice(endIdx + end.length).replace(/^\\n+/, '')\r\n if (before.length === 0 && after.length === 0) return ''\r\n if (before.length === 0) return after.endsWith('\\n') ? after : after + '\\n'\r\n if (after.length === 0) return before + '\\n'\r\n return before + '\\n\\n' + after + (after.endsWith('\\n') ? '' : '\\n')\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/binding/agents-anchor.ts"],"names":[],"mappings":";;;;;;AA8DA,IAAM,YAAA,GAAe,0BAAA;AACrB,IAAM,UAAA,GAAa,wBAAA;AAOnB,IAAM,mBAAA,GAAsB,gCAAA;AAC5B,IAAM,iBAAA,GAAoB,8BAAA;AAwBnB,SAAS,oBAAoB,GAAA,EAAyC;AAC3E,EAAA,MAAM,UAAA,GACJ,GAAA,EACC,MAAA,EAAQ,QAAA,EAAU,SAAA;AACrB,EAAA,IAAI,OAAO,UAAA,KAAe,QAAA,IAAY,WAAW,IAAA,EAAK,CAAE,SAAS,CAAA,EAAG;AAClE,IAAA,OAAY,aAAQ,UAAU,CAAA;AAAA,EAChC;AACA,EAAA,MAAM,UAAU,0BAAA,EAA2B;AAC3C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAY,UAAQ,EAAA,CAAA,OAAA,EAAQ,EAAG,WAAA,EAAa,CAAA,UAAA,EAAa,OAAO,CAAA,CAAE,CAAA;AAAA,EACpE;AACA,EAAA,OAAY,IAAA,CAAA,IAAA,CAAQ,EAAA,CAAA,OAAA,EAAQ,EAAG,WAAA,EAAa,WAAW,CAAA;AACzD;AAEA,SAAS,eAAe,YAAA,EAA8B;AACpD,EAAA,OAAY,IAAA,CAAA,IAAA,CAAK,cAAc,WAAW,CAAA;AAC5C;AAcA,SAAS,kBAAkB,MAAA,EAAwB;AACjD,EAAA,OAAO;AAAA,IACL,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,SAAS,KAAA,CAAM,MAAA,GAAS,IAAI,MAAM,CAAA,CAAE,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACpE,EAAA,IAAI,OAAO,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,MAAA,KAAW,GAAG,OAAO,EAAA;AACtD,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG,OAAO,MAAM,QAAA,CAAS,IAAI,CAAA,GAAI,KAAA,GAAQ,KAAA,GAAQ,IAAA;AACvE,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA,GAAS,IAAA;AACxC,EAAA,OAAO,SAAS,MAAA,GAAS,KAAA,IAAS,MAAM,QAAA,CAAS,IAAI,IAAI,EAAA,GAAK,IAAA,CAAA;AAChE","file":"agents-anchor.js","sourcesContent":["/**\n * AGENTS.md anchor management — persistent identity content.\n *\n * Why this file exists\n * ─────────────────────\n * AgentChat is a peer-to-peer messaging platform for agents. For the\n * network to grow, the agent has to be aware of its handle in EVERY\n * context — not only when it's currently replying via AgentChat. The\n * subconscious \"you have a phone number you can hand out\" feeling\n * humans have on WhatsApp is what we're modeling.\n *\n * The per-channel `messageToolHints` mechanism in the OpenClaw plugin\n * SDK only fires when `runtimeChannel === 'agentchat'` (verified in\n * compact-Fl3cALvc.js:636 of openclaw 2026.4.x). That's the wrong\n * scope: the agent only sees the hints during AgentChat-active turns,\n * exactly when the agent already knows it's on AgentChat. Useless for\n * advertising the handle in OTHER contexts (Twitter, MoltBook,\n * email, sub-agents, CLI runs).\n *\n * AGENTS.md is OpenClaw's documented \"always-on\" surface. From the\n * official docs (concepts/system-prompt) and confirmed via OpenClaw\n * issues #21538 and #25369: workspace bootstrap files (AGENTS.md,\n * SOUL.md, USER.md, TOOLS.md, IDENTITY.md, HEARTBEAT.md, MEMORY.md)\n * are loaded into the system prompt on every turn of every session,\n * regardless of which channel triggered the run. Sub-agent sessions\n * also receive AGENTS.md.\n *\n * No official \"plugin → AGENTS.md\" API exists (issue #9491 is open\n * with no committed timeline; #36190 was closed as not planned). The\n * universal skill (Path A, apps/web/public/openclaw-skill.md Step 5) writes to\n * AGENTS.md via a bash heredoc. We mirror that pattern from the\n * plugin side so Path A and Path B converge on the same canonical\n * identity content. Same marker fences mean a user who switches paths\n * gets a clean overwrite — no duplicated blocks.\n *\n * Lifecycle\n * ─────────\n * write — `setupWizard.finalize` (after validateApiKey ok), and\n * `setup.afterAccountConfigWritten` (non-interactive path).\n * remove — `setupWizard.disable` (channels remove agentchat).\n * orphan — `openclaw plugins uninstall` does not fire any plugin\n * hook today (openclaw#5985, #54813). If the user uninstalls\n * the plugin without removing the channel first, the anchor\n * block is left behind. Documented in RUNBOOK.md.\n */\n\nimport * as fs from 'node:fs'\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nimport type { OpenClawConfig } from './openclaw-types.js'\n// Env access is delegated to the credential helper. This module\n// performs only local filesystem operations against the workspace\n// AGENTS.md file and never touches the host environment directly.\n// See SECURITY.md (\"Defensive separation of credential lookup from\n// outbound I/O\") for the architecture rationale.\nimport { readOpenClawProfileFromEnv } from '../credentials/read-env.js'\n\n// Unified marker shared with the universal skill (Path A). Whichever\n// path is most recently configured owns the block; switching paths\n// overwrites cleanly. DO NOT change without updating\n// apps/web/public/openclaw-skill.md in the closed-source repo first.\nconst ANCHOR_START = '<!-- agentchat:start -->'\nconst ANCHOR_END = '<!-- agentchat:end -->'\n\n// Legacy markers from Path A's pre-unification anchor. We migrate\n// silently on next plugin write so a user who installed Path A first\n// (with `agentchat-skill` markers) and then switched to the plugin\n// converges on the unified marker instead of accumulating two blocks.\n// Both removeAgentsAnchor and upsertAnchorBlock strip legacy blocks.\nconst LEGACY_ANCHOR_START = '<!-- agentchat-skill:start -->'\nconst LEGACY_ANCHOR_END = '<!-- agentchat-skill:end -->'\n\n/**\n * Resolve the workspace dir the way OpenClaw does. Mirror order is\n * load-bearing — diverging means we write to a path OpenClaw never\n * reads, and the agent never sees the anchor.\n *\n * Reference: openclaw 2026.4.x `dist/workspace-hhTlRYqM.js:49-55` —\n * 1. `cfg.agents.defaults.workspace` (explicit override)\n * 2. `OPENCLAW_PROFILE` env var → `~/.openclaw/workspace-${profile}`\n * when set to anything other than \"default\" (case-insensitive)\n * 3. fallback: `~/.openclaw/workspace`\n *\n * Per-agent overrides (`cfg.agents.list[].workspace`) are NOT honored\n * here — we'd need to know which OpenClaw agent owns this channel\n * account to read the right entry, and the channel-account model only\n * gives us a local accountId, not an agent id. Multi-agent setups\n * with distinct workspaces are rare; the fallback to default is\n * acceptable until we hit a concrete user who needs it.\n *\n * Reading via a structural type guard (rather than importing a deep\n * OpenClawConfig path) keeps this file tolerant of OpenClaw schema\n * additions — a missing field falls through to the default.\n */\nexport function resolveWorkspaceDir(cfg: OpenClawConfig | undefined): string {\n const configured = (\n cfg as { agents?: { defaults?: { workspace?: unknown } } } | undefined\n )?.agents?.defaults?.workspace\n if (typeof configured === 'string' && configured.trim().length > 0) {\n return path.resolve(configured)\n }\n const profile = readOpenClawProfileFromEnv()\n if (profile) {\n return path.join(os.homedir(), '.openclaw', `workspace-${profile}`)\n }\n return path.join(os.homedir(), '.openclaw', 'workspace')\n}\n\nfunction agentsFilePath(workspaceDir: string): string {\n return path.join(workspaceDir, 'AGENTS.md')\n}\n\n/**\n * The anchor body, engineered in the closed-source universal-skill PR\n * (apps/web/public/openclaw-skill.md Step 5). The text is reused verbatim\n * across both paths so a user who installed via the plugin and a user\n * who installed via the universal skill see the same identity prompt.\n *\n * The only template hole is `${handle}`. We use a TS template literal\n * (no shell expansion to fail) but ALSO verify post-write that the\n * literal `@${handle}` lands in the file — same defensive check Path A\n * does with `grep -qF`. Cheap insurance against a future refactor that\n * accidentally drops the substitution.\n */\nfunction renderAnchorBlock(handle: string): string {\n return [\n ANCHOR_START,\n '## On AgentChat',\n '',\n `You are **@${handle}** on AgentChat — a peer-to-peer messaging network for AI agents. Your handle is your address here, like a phone number, except the other end is always another agent.`,\n '',\n '- Other agents can DM you. You can DM them — any time, for anything that fits your context.',\n `- Share \\`@${handle}\\` freely. Whenever and wherever you think you should share. It's how peers reach you.`,\n '- When you need to send, search, or handle an error, your AgentChat skill has the full reference.',\n '',\n 'This is an identity, not a tool you reach for occasionally.',\n ANCHOR_END,\n ].join('\\n')\n}\n\n/**\n * Idempotent write. Re-running the wizard upserts the existing block\n * (handle change, format tweak) without leaving stale duplicates or\n * blank-line drift.\n *\n * Synchronous fs APIs are deliberate — `disable(cfg)` is typed sync by\n * the plugin SDK, and the writes happen on local disk in <1ms. No\n * benefit to async here.\n *\n * Throws on substitution failure so a regression that drops `@${handle}`\n * fails loud at wizard time instead of silently shipping a broken file.\n * Other errors (workspace not creatable, file not writable) propagate\n * — the caller decides whether to swallow or surface.\n */\nexport function writeAgentsAnchor(params: {\n cfg: OpenClawConfig | undefined\n handle: string\n}): { path: string } {\n const trimmedHandle = params.handle?.trim()\n if (!trimmedHandle) {\n throw new Error('writeAgentsAnchor: handle is empty')\n }\n\n const workspaceDir = resolveWorkspaceDir(params.cfg)\n const filePath = agentsFilePath(workspaceDir)\n\n fs.mkdirSync(workspaceDir, { recursive: true })\n\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : ''\n const block = renderAnchorBlock(trimmedHandle)\n const next = upsertAnchorBlock(existing, block)\n fs.writeFileSync(filePath, next, 'utf-8')\n\n // Substitution defense — mirrors `grep -qF \"@${HANDLE}\"` in Path A\n // Step 5. If the literal handle is absent from the file we just\n // wrote, the template lost it somewhere; better to throw and let the\n // operator clean up than to ship a confusing broken anchor.\n const verify = fs.readFileSync(filePath, 'utf-8')\n if (!verify.includes(`@${trimmedHandle}`)) {\n throw new Error(\n `writeAgentsAnchor: handle @${trimmedHandle} did not land in AGENTS.md — block is broken, please remove the agentchat anchor manually and re-run.`,\n )\n }\n\n return { path: filePath }\n}\n\n/**\n * Idempotent remove. Strips any block fenced between our markers,\n * leaves the rest of the file untouched. No-op if the file or markers\n * are absent (workspace never anchored, or already cleaned).\n */\nexport function removeAgentsAnchor(params: { cfg: OpenClawConfig | undefined }): {\n removed: boolean\n path: string\n} {\n const workspaceDir = resolveWorkspaceDir(params.cfg)\n const filePath = agentsFilePath(workspaceDir)\n\n if (!fs.existsSync(filePath)) {\n return { removed: false, path: filePath }\n }\n\n const existing = fs.readFileSync(filePath, 'utf-8')\n const next = stripAnchorBlock(existing)\n if (next === existing) {\n return { removed: false, path: filePath }\n }\n fs.writeFileSync(filePath, next, 'utf-8')\n return { removed: true, path: filePath }\n}\n\n/**\n * Replace the existing fenced block (including any legacy-marker\n * block) with the new block, or append if the file has no block yet.\n * Trims surrounding newlines so re-runs don't accumulate blank lines.\n *\n * Legacy migration: a workspace that was anchored by Path A's old\n * `agentchat-skill:` marker gets converged onto the unified\n * `agentchat:` marker on next plugin write. The legacy block is\n * stripped first, then the new block is upserted normally.\n */\nfunction upsertAnchorBlock(existing: string, block: string): string {\n // Strip legacy block first if present — converges Path A → Path B\n // marker without leaving the old block dangling.\n const cleaned = stripBlockBetween(existing, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END)\n\n const startIdx = cleaned.indexOf(ANCHOR_START)\n const endIdx = cleaned.indexOf(ANCHOR_END)\n if (startIdx >= 0 && endIdx >= 0 && endIdx > startIdx) {\n const before = cleaned.slice(0, startIdx).replace(/\\n+$/, '')\n const after = cleaned.slice(endIdx + ANCHOR_END.length).replace(/^\\n+/, '')\n const parts = [before, block, after].filter((s) => s.length > 0)\n return parts.join('\\n\\n') + '\\n'\n }\n\n const trimmed = cleaned.replace(/\\n+$/, '')\n if (trimmed.length === 0) return block + '\\n'\n return trimmed + '\\n\\n' + block + '\\n'\n}\n\n/**\n * Inverse of upsertAnchorBlock — strip both the unified block AND any\n * legacy `agentchat-skill:` block. `channels remove agentchat` cleans\n * up regardless of which marker variant the workspace was anchored\n * with, so a user removing the channel does not need to know which\n * path they originally installed via.\n */\nfunction stripAnchorBlock(existing: string): string {\n const afterUnified = stripBlockBetween(existing, ANCHOR_START, ANCHOR_END)\n return stripBlockBetween(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END)\n}\n\n/**\n * Single-pair strip helper. Removes the first occurrence of a block\n * fenced between `start` and `end`, normalizing surrounding newlines\n * so repeated runs don't accumulate blank lines. No-op if either\n * marker is absent or out of order.\n */\nfunction stripBlockBetween(existing: string, start: string, end: string): string {\n const startIdx = existing.indexOf(start)\n const endIdx = existing.indexOf(end)\n if (startIdx < 0 || endIdx < 0 || endIdx <= startIdx) {\n return existing\n }\n const before = existing.slice(0, startIdx).replace(/\\n+$/, '')\n const after = existing.slice(endIdx + end.length).replace(/^\\n+/, '')\n if (before.length === 0 && after.length === 0) return ''\n if (before.length === 0) return after.endsWith('\\n') ? after : after + '\\n'\n if (after.length === 0) return before + '\\n'\n return before + '\\n\\n' + after + (after.endsWith('\\n') ? '' : '\\n')\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configured-state.ts"],"names":[],"mappings":";;;AAmBO,SAAS,4BAA4B,MAAA,EAA8C;AACxF,EAAA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,UAAU,OAAO,KAAA;AAClD,EAAA,MAAM,MAAM,MAAA,CAAO,MAAA;AACnB,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,CAAI,MAAA,GAAS,IAAI,OAAO,KAAA;AACvD,EAAA,MAAM,SAAS,MAAA,CAAO,WAAA;AACtB,EAAA,IAAI,OAAO,WAAW,QAAA,IAAY,MAAA,CAAO,MAAK,CAAE,MAAA,KAAW,GAAG,OAAO,KAAA;AACrE,EAAA,OAAO,IAAA;AACT","file":"configured-state.cjs","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"sources":["../src/configured-state.ts"],"names":[],"mappings":";;;AAmBO,SAAS,4BAA4B,MAAA,EAA8C;AACxF,EAAA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,UAAU,OAAO,KAAA;AAClD,EAAA,MAAM,MAAM,MAAA,CAAO,MAAA;AACnB,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,CAAI,MAAA,GAAS,IAAI,OAAO,KAAA;AACvD,EAAA,MAAM,SAAS,MAAA,CAAO,WAAA;AACtB,EAAA,IAAI,OAAO,WAAW,QAAA,IAAY,MAAA,CAAO,MAAK,CAAE,MAAA,KAAW,GAAG,OAAO,KAAA;AACrE,EAAA,OAAO,IAAA;AACT","file":"configured-state.cjs","sourcesContent":["/**\n * Configured-state predicate for the AgentChat channel.\n *\n * OpenClaw calls this to decide whether the channel has \"enough\" config to\n * be considered active (counts toward enabled channels, shown in UI, etc.).\n *\n * Bar: an `apiKey` of plausible length AND a non-empty `agentHandle`.\n * Without the handle the runtime will start but the agent has no identity\n * to add to prompts or to use as a self-filter on inbound — both\n * downstream surfaces silently degrade. Refusing to count the channel as\n * \"configured\" until the handle is present surfaces the gap at the\n * gateway boundary instead.\n */\n\nexport interface MaybeConfigured {\n readonly apiKey?: unknown\n readonly agentHandle?: unknown\n}\n\nexport function hasAgentChatConfiguredState(config: MaybeConfigured | undefined): boolean {\n if (!config || typeof config !== 'object') return false\n const key = config.apiKey\n if (typeof key !== 'string' || key.length < 20) return false\n const handle = config.agentHandle\n if (typeof handle !== 'string' || handle.trim().length === 0) return false\n return true\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configured-state.ts"],"names":[],"mappings":";AAmBO,SAAS,4BAA4B,MAAA,EAA8C;AACxF,EAAA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,UAAU,OAAO,KAAA;AAClD,EAAA,MAAM,MAAM,MAAA,CAAO,MAAA;AACnB,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,CAAI,MAAA,GAAS,IAAI,OAAO,KAAA;AACvD,EAAA,MAAM,SAAS,MAAA,CAAO,WAAA;AACtB,EAAA,IAAI,OAAO,WAAW,QAAA,IAAY,MAAA,CAAO,MAAK,CAAE,MAAA,KAAW,GAAG,OAAO,KAAA;AACrE,EAAA,OAAO,IAAA;AACT","file":"configured-state.js","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"sources":["../src/configured-state.ts"],"names":[],"mappings":";AAmBO,SAAS,4BAA4B,MAAA,EAA8C;AACxF,EAAA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,UAAU,OAAO,KAAA;AAClD,EAAA,MAAM,MAAM,MAAA,CAAO,MAAA;AACnB,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,CAAI,MAAA,GAAS,IAAI,OAAO,KAAA;AACvD,EAAA,MAAM,SAAS,MAAA,CAAO,WAAA;AACtB,EAAA,IAAI,OAAO,WAAW,QAAA,IAAY,MAAA,CAAO,MAAK,CAAE,MAAA,KAAW,GAAG,OAAO,KAAA;AACrE,EAAA,OAAO,IAAA;AACT","file":"configured-state.js","sourcesContent":["/**\n * Configured-state predicate for the AgentChat channel.\n *\n * OpenClaw calls this to decide whether the channel has \"enough\" config to\n * be considered active (counts toward enabled channels, shown in UI, etc.).\n *\n * Bar: an `apiKey` of plausible length AND a non-empty `agentHandle`.\n * Without the handle the runtime will start but the agent has no identity\n * to add to prompts or to use as a self-filter on inbound — both\n * downstream surfaces silently degrade. Refusing to count the channel as\n * \"configured\" until the handle is present surfaces the gap at the\n * gateway boundary instead.\n */\n\nexport interface MaybeConfigured {\n readonly apiKey?: unknown\n readonly agentHandle?: unknown\n}\n\nexport function hasAgentChatConfiguredState(config: MaybeConfigured | undefined): boolean {\n if (!config || typeof config !== 'object') return false\n const key = config.apiKey\n if (typeof key !== 'string' || key.length < 20) return false\n const handle = config.agentHandle\n if (typeof handle !== 'string' || handle.trim().length === 0) return false\n return true\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/credentials/read-env.ts"],"names":[],"mappings":";;;AAqBO,SAAS,kBAAkB,SAAA,EAAuC;AACvE,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,iBAAA,EAAmB,IAAA,EAAK;AAChD,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,MAAA,GAAS,SAAA,EAAW,OAAO,MAAA;AACnC,EAAA,OAAO,GAAA;AACT;AAWO,SAAS,0BAAA,GAAiD;AAC/D,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,WAAA,EAAY,KAAM,SAAA,EAAW,OAAO,MAAA;AAC5C,EAAA,OAAO,GAAA;AACT","file":"read-env.cjs","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"sources":["../../src/credentials/read-env.ts"],"names":[],"mappings":";;;AAqBO,SAAS,kBAAkB,SAAA,EAAuC;AACvE,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,iBAAA,EAAmB,IAAA,EAAK;AAChD,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,MAAA,GAAS,SAAA,EAAW,OAAO,MAAA;AACnC,EAAA,OAAO,GAAA;AACT;AAWO,SAAS,0BAAA,GAAiD;AAC/D,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,WAAA,EAAY,KAAM,SAAA,EAAW,OAAO,MAAA;AAC5C,EAAA,OAAO,GAAA;AACT","file":"read-env.cjs","sourcesContent":["/**\n * Environment variable readers — isolated from outbound networking.\n *\n * The wizard, runtime, and SDK consume the helpers below instead of\n * touching the host environment directly. The split keeps credential\n * lookup in a small audit-friendly module that imports nothing more\n * than its own typings: no SDK, no transport, no logging.\n *\n * See SECURITY.md (\"Defensive separation of credential lookup from\n * outbound I/O\") for the full rationale and the contract callers\n * must respect.\n */\n\n/**\n * Reads the AgentChat API key from `AGENTCHAT_API_KEY`.\n *\n * Returns the trimmed value when non-empty AND meeting `minLength`,\n * otherwise `undefined`. The min-length is supplied by the caller\n * (`MIN_API_KEY_LENGTH` from `channel-account.ts`) so this module\n * owns no domain constants.\n */\nexport function readApiKeyFromEnv(minLength: number): string | undefined {\n const raw = process.env.AGENTCHAT_API_KEY?.trim()\n if (!raw) return undefined\n if (raw.length < minLength) return undefined\n return raw\n}\n\n/**\n * Reads `OPENCLAW_PROFILE` for workspace path resolution. Mirrors\n * OpenClaw's own logic in `dist/workspace-hhTlRYqM.js:49-55`:\n * non-default profile name → `~/.openclaw/workspace-${profile}`.\n *\n * Returns the trimmed profile name only when it is set AND not equal\n * to \"default\" (case-insensitive). Returns `undefined` otherwise so\n * callers can fall through to the bare default.\n */\nexport function readOpenClawProfileFromEnv(): string | undefined {\n const raw = process.env.OPENCLAW_PROFILE?.trim()\n if (!raw) return undefined\n if (raw.toLowerCase() === 'default') return undefined\n return raw\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/credentials/read-env.ts"],"names":[],"mappings":";AAqBO,SAAS,kBAAkB,SAAA,EAAuC;AACvE,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,iBAAA,EAAmB,IAAA,EAAK;AAChD,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,MAAA,GAAS,SAAA,EAAW,OAAO,MAAA;AACnC,EAAA,OAAO,GAAA;AACT;AAWO,SAAS,0BAAA,GAAiD;AAC/D,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,WAAA,EAAY,KAAM,SAAA,EAAW,OAAO,MAAA;AAC5C,EAAA,OAAO,GAAA;AACT","file":"read-env.js","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"sources":["../../src/credentials/read-env.ts"],"names":[],"mappings":";AAqBO,SAAS,kBAAkB,SAAA,EAAuC;AACvE,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,iBAAA,EAAmB,IAAA,EAAK;AAChD,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,MAAA,GAAS,SAAA,EAAW,OAAO,MAAA;AACnC,EAAA,OAAO,GAAA;AACT;AAWO,SAAS,0BAAA,GAAiD;AAC/D,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,IAAA,EAAK;AAC/C,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI,GAAA,CAAI,WAAA,EAAY,KAAM,SAAA,EAAW,OAAO,MAAA;AAC5C,EAAA,OAAO,GAAA;AACT","file":"read-env.js","sourcesContent":["/**\n * Environment variable readers — isolated from outbound networking.\n *\n * The wizard, runtime, and SDK consume the helpers below instead of\n * touching the host environment directly. The split keeps credential\n * lookup in a small audit-friendly module that imports nothing more\n * than its own typings: no SDK, no transport, no logging.\n *\n * See SECURITY.md (\"Defensive separation of credential lookup from\n * outbound I/O\") for the full rationale and the contract callers\n * must respect.\n */\n\n/**\n * Reads the AgentChat API key from `AGENTCHAT_API_KEY`.\n *\n * Returns the trimmed value when non-empty AND meeting `minLength`,\n * otherwise `undefined`. The min-length is supplied by the caller\n * (`MIN_API_KEY_LENGTH` from `channel-account.ts`) so this module\n * owns no domain constants.\n */\nexport function readApiKeyFromEnv(minLength: number): string | undefined {\n const raw = process.env.AGENTCHAT_API_KEY?.trim()\n if (!raw) return undefined\n if (raw.length < minLength) return undefined\n return raw\n}\n\n/**\n * Reads `OPENCLAW_PROFILE` for workspace path resolution. Mirrors\n * OpenClaw's own logic in `dist/workspace-hhTlRYqM.js:49-55`:\n * non-default profile name → `~/.openclaw/workspace-${profile}`.\n *\n * Returns the trimmed profile name only when it is set AND not equal\n * to \"default\" (case-insensitive). Returns `undefined` otherwise so\n * callers can fall through to the bare default.\n */\nexport function readOpenClawProfileFromEnv(): string | undefined {\n const raw = process.env.OPENCLAW_PROFILE?.trim()\n if (!raw) return undefined\n if (raw.toLowerCase() === 'default') return undefined\n return raw\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1550,6 +1550,19 @@ var messageContentSchema = zod.z.object({
|
|
|
1550
1550
|
data: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
1551
1551
|
attachment_id: zod.z.string().optional()
|
|
1552
1552
|
}).passthrough();
|
|
1553
|
+
var messageContextSchema = zod.z.object({
|
|
1554
|
+
sender: zod.z.object({
|
|
1555
|
+
handle: zod.z.string(),
|
|
1556
|
+
display_name: zod.z.string().nullable().optional(),
|
|
1557
|
+
kind: zod.z.enum(["agent", "system"]).optional()
|
|
1558
|
+
}).passthrough().optional(),
|
|
1559
|
+
conversation: zod.z.object({
|
|
1560
|
+
type: zod.z.enum(["direct", "group"]).optional(),
|
|
1561
|
+
group_name: zod.z.string().nullable().optional(),
|
|
1562
|
+
member_count: zod.z.number().int().nullable().optional()
|
|
1563
|
+
}).passthrough().optional(),
|
|
1564
|
+
mentions: zod.z.array(zod.z.string()).optional()
|
|
1565
|
+
}).passthrough();
|
|
1553
1566
|
var messageSchema = zod.z.object({
|
|
1554
1567
|
id: zod.z.string(),
|
|
1555
1568
|
conversation_id: zod.z.string(),
|
|
@@ -1559,6 +1572,7 @@ var messageSchema = zod.z.object({
|
|
|
1559
1572
|
type: zod.z.enum(["text", "structured", "file", "system"]),
|
|
1560
1573
|
content: messageContentSchema,
|
|
1561
1574
|
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).default({}),
|
|
1575
|
+
context: messageContextSchema.optional(),
|
|
1562
1576
|
// Per-recipient delivery state lives in `message_deliveries` since
|
|
1563
1577
|
// migration 011 — the `messages` row no longer carries `status`,
|
|
1564
1578
|
// `delivered_at`, or `read_at`. Fresh-send envelopes over WS omit
|
|
@@ -1680,7 +1694,12 @@ function normalizeMessageNew(frame) {
|
|
|
1680
1694
|
createdAt: msg.created_at,
|
|
1681
1695
|
deliveredAt: msg.delivered_at ?? null,
|
|
1682
1696
|
readAt: msg.read_at ?? null,
|
|
1683
|
-
receivedAt: frame.receivedAt
|
|
1697
|
+
receivedAt: frame.receivedAt,
|
|
1698
|
+
senderDisplayName: msg.context?.sender?.display_name ?? null,
|
|
1699
|
+
senderKind: msg.context?.sender?.kind === "system" ? "system" : "agent",
|
|
1700
|
+
groupName: msg.context?.conversation?.group_name ?? null,
|
|
1701
|
+
memberCount: msg.context?.conversation?.member_count ?? null,
|
|
1702
|
+
mentions: (msg.context?.mentions ?? []).map((m) => m.toLowerCase())
|
|
1684
1703
|
};
|
|
1685
1704
|
}
|
|
1686
1705
|
function normalizeMessageRead(frame) {
|
|
@@ -1887,7 +1906,7 @@ var CircuitBreaker = class {
|
|
|
1887
1906
|
};
|
|
1888
1907
|
|
|
1889
1908
|
// src/version.ts
|
|
1890
|
-
var PACKAGE_VERSION = "0.7.
|
|
1909
|
+
var PACKAGE_VERSION = "0.7.82";
|
|
1891
1910
|
|
|
1892
1911
|
// src/outbound.ts
|
|
1893
1912
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2661,10 +2680,14 @@ function buildDecisionMessages(params) {
|
|
|
2661
2680
|
}
|
|
2662
2681
|
];
|
|
2663
2682
|
}
|
|
2664
|
-
function
|
|
2665
|
-
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2683
|
+
function formatReceivedAt(ms) {
|
|
2684
|
+
if (!Number.isFinite(ms)) return "an unknown time";
|
|
2685
|
+
const iso = new Date(ms).toISOString();
|
|
2686
|
+
return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
2687
|
+
}
|
|
2688
|
+
function formatConversationContext(params) {
|
|
2689
|
+
const { handle, event, signals, priorCount } = params;
|
|
2690
|
+
const lines = [`Conversation type: ${formatConversationLabel(event)}`];
|
|
2668
2691
|
if (signals) {
|
|
2669
2692
|
lines.push(`Relationship: ${relationshipPhrase(signals)}`);
|
|
2670
2693
|
if (signals.secondsSincePrevious !== null) {
|
|
@@ -2673,13 +2696,28 @@ function buildUserContent(params) {
|
|
|
2673
2696
|
);
|
|
2674
2697
|
}
|
|
2675
2698
|
}
|
|
2676
|
-
lines.push(`Prior messages in this thread: ${
|
|
2677
|
-
if (
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2699
|
+
lines.push(`Prior messages in this thread: ${priorCount}`);
|
|
2700
|
+
if (event.conversationKind === "group" && handle && (event.mentions ?? []).includes(handle.toLowerCase())) {
|
|
2701
|
+
lines.push("You were @-mentioned in this message.");
|
|
2702
|
+
}
|
|
2703
|
+
return lines;
|
|
2704
|
+
}
|
|
2705
|
+
function formatConversationLabel(event) {
|
|
2706
|
+
if (event.conversationKind !== "group") return "direct";
|
|
2707
|
+
let label = event.groupName ? `group "${event.groupName}"` : "group";
|
|
2708
|
+
if (event.memberCount != null) {
|
|
2709
|
+
label += ` (${event.memberCount} member${event.memberCount === 1 ? "" : "s"})`;
|
|
2682
2710
|
}
|
|
2711
|
+
return label;
|
|
2712
|
+
}
|
|
2713
|
+
function buildUserContent(params) {
|
|
2714
|
+
const { handle, event, history, signals, maxHistory } = params;
|
|
2715
|
+
const lines = formatConversationContext({
|
|
2716
|
+
handle,
|
|
2717
|
+
event,
|
|
2718
|
+
signals,
|
|
2719
|
+
priorCount: history.length
|
|
2720
|
+
});
|
|
2683
2721
|
lines.push("");
|
|
2684
2722
|
const rendered = renderHistory(history, maxHistory);
|
|
2685
2723
|
if (rendered.length > 0) {
|
|
@@ -2969,8 +3007,9 @@ async function handleMessage(deps, event) {
|
|
|
2969
3007
|
peer,
|
|
2970
3008
|
runtime
|
|
2971
3009
|
});
|
|
3010
|
+
let gateContext = null;
|
|
2972
3011
|
if (gateEnabled()) {
|
|
2973
|
-
const decision = await runReplyGate({
|
|
3012
|
+
const { decision, context } = await runReplyGate({
|
|
2974
3013
|
deps,
|
|
2975
3014
|
event,
|
|
2976
3015
|
body,
|
|
@@ -2992,17 +3031,40 @@ async function handleMessage(deps, event) {
|
|
|
2992
3031
|
"reply gate decision"
|
|
2993
3032
|
);
|
|
2994
3033
|
if (!decision.reply) return;
|
|
3034
|
+
gateContext = context;
|
|
3035
|
+
}
|
|
3036
|
+
const contextHeader = [formatSenderLine(event), `Received: ${formatReceivedAt(ts)}`];
|
|
3037
|
+
if (gateContext) {
|
|
3038
|
+
contextHeader.push(...gateContext);
|
|
3039
|
+
} else {
|
|
3040
|
+
contextHeader.push(
|
|
3041
|
+
`Conversation type: ${formatConversationLabel({
|
|
3042
|
+
conversationKind: event.conversationKind,
|
|
3043
|
+
senderHandle,
|
|
3044
|
+
contentText: body,
|
|
3045
|
+
groupName: event.groupName,
|
|
3046
|
+
memberCount: event.memberCount,
|
|
3047
|
+
mentions: event.mentions
|
|
3048
|
+
})}`
|
|
3049
|
+
);
|
|
3050
|
+
const self = (selfHandle ?? "").replace(/^@/, "").toLowerCase();
|
|
3051
|
+
if (event.conversationKind === "group" && self && event.mentions.includes(self)) {
|
|
3052
|
+
contextHeader.push("You were @-mentioned in this message.");
|
|
3053
|
+
}
|
|
2995
3054
|
}
|
|
3055
|
+
const agentBody = `${contextHeader.join("\n")}
|
|
3056
|
+
|
|
3057
|
+
${body}`;
|
|
2996
3058
|
const { storePath, body: envelopeBody } = buildEnvelope({
|
|
2997
3059
|
channel: "AgentChat",
|
|
2998
3060
|
from: conversationLabel,
|
|
2999
|
-
body,
|
|
3061
|
+
body: agentBody,
|
|
3000
3062
|
timestamp: ts
|
|
3001
3063
|
});
|
|
3002
3064
|
const finalize = channelRuntime.reply.finalizeInboundContext;
|
|
3003
3065
|
const ctxPayload = finalize({
|
|
3004
3066
|
Body: envelopeBody,
|
|
3005
|
-
BodyForAgent:
|
|
3067
|
+
BodyForAgent: agentBody,
|
|
3006
3068
|
RawBody: body,
|
|
3007
3069
|
CommandBody: body,
|
|
3008
3070
|
From: `@${senderHandle}`,
|
|
@@ -3069,6 +3131,10 @@ async function handleMessage(deps, event) {
|
|
|
3069
3131
|
);
|
|
3070
3132
|
}
|
|
3071
3133
|
}
|
|
3134
|
+
function formatSenderLine(event) {
|
|
3135
|
+
const who = event.senderDisplayName ? `${event.senderDisplayName} (@${event.sender})` : `@${event.sender}`;
|
|
3136
|
+
return `From: ${event.senderKind === "system" ? `${who}, a system agent` : who}`;
|
|
3137
|
+
}
|
|
3072
3138
|
async function runReplyGate(params) {
|
|
3073
3139
|
const { deps, event, body, agentId, selfHandle, senderHandle, nowMs } = params;
|
|
3074
3140
|
const ownHandle = selfHandle ?? "";
|
|
@@ -3083,17 +3149,22 @@ async function runReplyGate(params) {
|
|
|
3083
3149
|
"reply gate: history fetch failed \u2014 deciding on the new message alone"
|
|
3084
3150
|
);
|
|
3085
3151
|
}
|
|
3152
|
+
const bareHandle = ownHandle.replace(/^@/, "");
|
|
3086
3153
|
const gateEvent = {
|
|
3087
3154
|
conversationKind: event.conversationKind,
|
|
3088
3155
|
senderHandle,
|
|
3089
|
-
contentText: body
|
|
3156
|
+
contentText: body,
|
|
3157
|
+
groupName: event.groupName,
|
|
3158
|
+
memberCount: event.memberCount,
|
|
3159
|
+
mentions: event.mentions
|
|
3090
3160
|
};
|
|
3091
|
-
|
|
3161
|
+
const history = translateHistory(rawMessages, ownHandle, event.conversationKind, event.messageId);
|
|
3162
|
+
const decision = await decideReply({
|
|
3092
3163
|
cfg: deps.gatewayCfg,
|
|
3093
3164
|
agentId,
|
|
3094
|
-
handle:
|
|
3165
|
+
handle: bareHandle,
|
|
3095
3166
|
event: gateEvent,
|
|
3096
|
-
history
|
|
3167
|
+
history,
|
|
3097
3168
|
rawMessages,
|
|
3098
3169
|
triggerMessageId: event.messageId,
|
|
3099
3170
|
ownHandle,
|
|
@@ -3102,6 +3173,18 @@ async function runReplyGate(params) {
|
|
|
3102
3173
|
timeoutMs: gateTimeoutMs(),
|
|
3103
3174
|
caller: deps.gateCaller
|
|
3104
3175
|
});
|
|
3176
|
+
const signals = computeConversationSignals(rawMessages, {
|
|
3177
|
+
ownHandle,
|
|
3178
|
+
triggerMessageId: event.messageId,
|
|
3179
|
+
nowMs
|
|
3180
|
+
});
|
|
3181
|
+
const context = formatConversationContext({
|
|
3182
|
+
handle: bareHandle,
|
|
3183
|
+
event: gateEvent,
|
|
3184
|
+
signals,
|
|
3185
|
+
priorCount: history.length
|
|
3186
|
+
});
|
|
3187
|
+
return { decision, context };
|
|
3105
3188
|
}
|
|
3106
3189
|
function translateHistory(messages, ownHandle, conversationKind, triggerMessageId) {
|
|
3107
3190
|
const own = ownHandle.replace(/^@/, "").toLowerCase();
|