@channlize/mcp 0.3.0 → 0.5.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/CHANGELOG.md +56 -0
- package/README.md +152 -11
- package/dist/agents.d.mts +84 -0
- package/dist/agents.d.ts +84 -0
- package/dist/agents.js +821 -0
- package/dist/agents.js.map +1 -0
- package/dist/agents.mjs +784 -0
- package/dist/agents.mjs.map +1 -0
- package/dist/inbox-BfpFVoK7.d.mts +194 -0
- package/dist/inbox-BfpFVoK7.d.ts +194 -0
- package/dist/inbox.d.mts +3 -0
- package/dist/inbox.d.ts +3 -0
- package/dist/inbox.js +587 -0
- package/dist/inbox.js.map +1 -0
- package/dist/inbox.mjs +547 -0
- package/dist/inbox.mjs.map +1 -0
- package/dist/index.d.mts +22 -72
- package/dist/index.d.ts +22 -72
- package/dist/index.js +1628 -238
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1610 -231
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +1542 -239
- package/dist/server.js.map +1 -1
- package/package.json +14 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents.ts","../src/api.ts"],"sourcesContent":["/**\n * The Channlize for Agents toolset: names, zod input/output schemas and\n * handlers for talking to other agents and to people in agent channels,\n * through `/v1/agents`.\n *\n * Like `inbox.ts`, it has no dependency on the MCP server or its\n * transports, so any agent can import it (`@channlize/mcp/agents`): the\n * stdio/HTTP server registers these tools (`registerAgentTools` in\n * `tools.ts`), and an LLM loop can run the same handlers with its own client\n * (anything with a `request(method, path, { query, body })`).\n *\n * Identity: the key decides who the tools act as. An agent key acts as its\n * agent; a multi-agent key acts as one of its agents, picked by `agentId`\n * on the call or the requester's default `agentId` (`CHANNLIZE_AGENT_ID` /\n * `--agent-id` on the server).\n *\n * Scopes: `agents:send` (post messages, create, update and hand off\n * tasks, answer escalated questions), `agents:read` (directory, channels,\n * inbox and ack, tasks, the org chart), `agents:ask_human` (ask people and\n * read the answer) and `agents:admin` (`get_effective_policy` only).\n *\n * No admin-write tools: changing policies, teams, the org chart or an\n * agent's status stays in the dashboard or `@channlize/core` with an\n * `agents:admin` key. Policies are the guardrails on what an agent may do,\n * so the agent that runs these tools shouldn't be able to rewrite them.\n */\nimport * as z from 'zod/v4';\nimport { ToolError, type HttpMethod } from './api';\nimport type { ToolAnnotations } from './inbox';\n\ntype Json = Record<string, unknown>;\ntype Query = Record<string, string | number | boolean | undefined>;\n\n/** What a handler needs: `ChannlizeApi` from this package, or your own. */\nexport interface AgentsRequester {\n request<T>(\n method: HttpMethod,\n path: string,\n /** `timeout` (ms) overrides the default, for the `get_answer` long-poll. */\n options?: { query?: Query; body?: unknown; timeout?: number }\n ): Promise<T>;\n /** The agent to act as when a call doesn't pass `agentId`. */\n readonly agentId?: string;\n}\n\n/** The API key scope a tool needs. */\nexport type AgentScope =\n 'agents:send' | 'agents:read' | 'agents:ask_human' | 'agents:admin';\n\nexport interface AgentTool<\n I extends z.ZodObject = z.ZodObject,\n O extends z.ZodObject = z.ZodObject,\n> {\n name: string;\n title: string;\n description: string;\n scope: AgentScope;\n /** The HTTP endpoint it calls, for docs and logs. */\n endpoint: string;\n inputSchema: I;\n outputSchema: O;\n annotations: ToolAnnotations;\n handler: (api: AgentsRequester, args: z.output<I>) => Promise<z.output<O>>;\n}\n\nfunction defineTool<I extends z.ZodObject, O extends z.ZodObject>(\n tool: AgentTool<I, O>\n): AgentTool {\n return tool as unknown as AgentTool;\n}\n\n/** Task lifecycle (same values as the API). */\nexport const AGENT_TASK_STATUSES = [\n 'open',\n 'working',\n 'input_required',\n 'completed',\n 'failed',\n 'canceled',\n 'rejected',\n] as const;\n\n// ----- shared schemas -----\n\nconst uuid = (what: string) => z.string().uuid().describe(what);\n\nconst agentId = uuid(\n 'The agent to act as (from list_agents). Needed with a multi-agent key unless the server has a default agent (CHANNLIZE_AGENT_ID); leave it out with an agent key.'\n).optional();\n\nconst channelId = uuid('Agent channel ID (from list_agent_channels)');\n\nconst threadId = uuid(\n 'Reply in this thread: the id of any message in it (thread_id or id from read_agent_inbox)'\n).optional();\n\nconst mentions = z\n .array(z.string().uuid())\n .max(50)\n .optional()\n .describe('Agent IDs to mention (from list_agents)');\n\nconst data = z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Structured data for the recipients (JSON object)');\n\nconst usage = {\n tokens: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Tokens you used for this message (reporting)'),\n cost: z\n .number()\n .min(0)\n .optional()\n .describe('What this message cost you, in USD (reporting)'),\n};\n\nconst message = z.looseObject({\n id: z.string(),\n channel_id: z.string(),\n thread_id: z.string().nullable(),\n type: z.string(),\n text: z.string(),\n sender: z.looseObject({ kind: z.string() }),\n task_status: z.string().nullable().optional(),\n});\n\nconst sendOutput = z.object({\n message,\n deliveries: z.array(\n z.looseObject({ id: z.string(), agent_id: z.string(), status: z.string() })\n ),\n});\n\nconst dueAt = z\n .string()\n .max(40)\n .optional()\n .describe('Due date: an ISO date (2026-11-30) or date-time');\n\nconst task = z.looseObject({\n id: z.string(),\n channel_id: z.string(),\n text: z.string(),\n board_status: z.string(),\n assignee_agent_id: z.string().nullable(),\n due_at: z.string().nullable(),\n});\n\nconst deliveries = z.array(\n z.looseObject({ id: z.string(), agent_id: z.string(), status: z.string() })\n);\n\nconst question = z.looseObject({\n id: z.string(),\n kind: z.string(),\n question: z.string(),\n status: z.string(),\n answer: z.looseObject({}).nullable(),\n});\n\nconst questionId = uuid('The question ID (from ask_human or list_questions)');\n\nconst BOARD_STATUSES = [\n 'open',\n 'in_progress',\n 'blocked',\n 'done',\n 'failed',\n] as const;\n\n/** The longest single long-poll the API holds (`/questions/:id/wait`). */\nexport const QUESTION_WAIT_MAX_SECONDS = 25;\n\nconst READ: ToolAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n};\nconst SEND: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n};\n\n/** The call's agent, else the requester's default. */\nfunction actingAs(api: AgentsRequester, id: string | undefined) {\n return id ?? api.agentId;\n}\n\n/** Inbox and ack need the agent in the path. */\nfunction requireAgent(api: AgentsRequester, id: string | undefined): string {\n const agent = actingAs(api, id);\n if (!agent) {\n throw new ToolError(\n 'Pass agentId (from list_agents), or set CHANNLIZE_AGENT_ID / --agent-id on the MCP server.'\n );\n }\n return agent;\n}\n\nasync function send(\n api: AgentsRequester,\n body: Json\n): Promise<z.output<typeof sendOutput>> {\n const r = await api.request<z.output<typeof sendOutput>>(\n 'POST',\n '/v1/agents/messages',\n { body }\n );\n return { message: r.message, deliveries: r.deliveries ?? [] };\n}\n\nconst enc = encodeURIComponent;\n\n/** One line about a closed question, for the model. */\nfunction outcomeMessage(status: string, q: Json): string {\n const answer = (q.answer ?? {}) as Json;\n const choice = answer.option_label ?? answer.option_id;\n const comment = answer.comment ? `: ${String(answer.comment)}` : '';\n switch (status) {\n case 'answered':\n if (q.kind === 'approval') {\n return answer.approved\n ? `Approved${comment}. Go ahead.`\n : `Denied${comment}. Don't do it.`;\n }\n return `Answered: ${[choice, answer.text].filter(Boolean).join(' / ') || '(empty)'}.`;\n case 'expired_default':\n return `Nobody answered by the deadline: the default option applies (${String(choice ?? 'none')}).`;\n case 'expired':\n return 'Nobody answered by the deadline and there is no default: decide whether to ask again or drop it. For an approval, treat it as not approved.';\n case 'canceled':\n return 'The question was canceled.';\n default:\n return `Status: ${status}.`;\n }\n}\n\n// ----- the tools -----\n\nexport const AGENT_TOOLS: readonly AgentTool[] = [\n defineTool({\n name: 'send_agent_message',\n title: 'Send agent message',\n description:\n 'Post a message to an agent channel as your agent. Every other agent in the channel receives it (webhook, inbox or A2A), people see it in Slack and the dashboard, and it counts as one Event. Reply in a thread with threadId; mention agents with mentions. Needs the agents:send scope, and the agent must be a member of the channel.',\n scope: 'agents:send',\n endpoint: 'POST /v1/agents/messages',\n inputSchema: z.object({\n agentId,\n channelId,\n text: z.string().min(1).max(40_000).describe('Message text'),\n threadId,\n mentions,\n data,\n ...usage,\n }),\n outputSchema: sendOutput,\n annotations: SEND,\n handler: (api, a) =>\n send(api, {\n agent_id: actingAs(api, a.agentId),\n channel_id: a.channelId,\n type: 'message',\n text: a.text,\n thread_id: a.threadId,\n mentions: a.mentions,\n data: a.data,\n tokens: a.tokens,\n cost: a.cost,\n }),\n }),\n\n defineTool({\n name: 'create_task',\n title: 'Create task',\n description:\n 'Hand a task to an agent of a channel: creates a task (board status open) that starts its own thread, optionally assigned to a member agent (assigneeAgentId, who is mentioned) and with a due date. The returned taskId is for update_task, update_task_status and handoff_task. Your policy may refuse the channel or the assignee (POLICY_* errors). Needs the agents:send scope.',\n scope: 'agents:send',\n endpoint: 'POST /v1/agents/tasks',\n inputSchema: z.object({\n agentId,\n channelId,\n text: z\n .string()\n .min(1)\n .max(40_000)\n .describe('What should be done, with enough context to do it'),\n assigneeAgentId: uuid(\n 'The agent that should do it: a member of the channel (from list_agents)'\n ).optional(),\n dueAt,\n threadId,\n mentions,\n data,\n }),\n // `message` is the task too (a task is its `task` message plus board fields).\n outputSchema: z.object({ taskId: z.string(), task, message, deliveries }),\n annotations: SEND,\n handler: async (api, a) => {\n const r = await api.request<{ task: Json; deliveries?: Json[] }>(\n 'POST',\n '/v1/agents/tasks',\n {\n body: {\n agent_id: actingAs(api, a.agentId),\n channel_id: a.channelId,\n text: a.text,\n assignee_agent_id: a.assigneeAgentId,\n due_at: a.dueAt,\n thread_id: a.threadId,\n mentions: a.mentions,\n data: a.data,\n },\n }\n );\n return {\n taskId: String(r.task.id),\n task: r.task as never,\n message: r.task as never,\n deliveries: (r.deliveries ?? []) as never,\n };\n },\n }),\n\n defineTool({\n name: 'update_task_status',\n title: 'Update task status',\n description:\n 'Report progress on a task (from create_task or a task in your inbox): working, input_required, completed, failed, canceled or rejected, with an optional note and result data. It is posted in the task thread and moves the task on the board (working → in_progress, input_required → blocked, completed → done; canceled and rejected show as failed). completed, failed, canceled and rejected are final: a closed task cannot be reopened (TASK_CLOSED). To change the due date, use update_task. Needs the agents:send scope.',\n scope: 'agents:send',\n endpoint: 'POST /v1/agents/messages',\n inputSchema: z.object({\n agentId,\n channelId,\n taskId: uuid('The task message ID'),\n status: z\n .enum(AGENT_TASK_STATUSES)\n .describe('The new status of the task'),\n text: z\n .string()\n .max(40_000)\n .optional()\n .describe('What changed, e.g. the result or what input is needed'),\n data,\n ...usage,\n }),\n outputSchema: sendOutput,\n annotations: SEND,\n handler: (api, a) =>\n send(api, {\n agent_id: actingAs(api, a.agentId),\n channel_id: a.channelId,\n type: 'status',\n text: a.text ?? '',\n task_id: a.taskId,\n task_status: a.status,\n data: a.data,\n tokens: a.tokens,\n cost: a.cost,\n }),\n }),\n\n defineTool({\n name: 'update_task',\n title: 'Update task',\n description:\n \"Move a task on the board (open, in_progress, blocked, done, failed) and/or change its due date, with a note: posted as a status update in the task thread, recorded in the task's history and shown on its Slack card. Only the task's assignee or creator can change it (NOT_TASK_PARTICIPANT), and a closed task can't change (TASK_CLOSED). To cancel or reject, or to attach result data, use update_task_status. Needs the agents:send scope.\",\n scope: 'agents:send',\n endpoint: 'PATCH /v1/agents/tasks/:taskId',\n inputSchema: z.object({\n agentId,\n taskId: uuid('The task ID'),\n status: z.enum(BOARD_STATUSES).optional().describe('The board column'),\n dueAt: z\n .string()\n .max(40)\n .nullable()\n .optional()\n .describe('New due date (ISO date or date-time); null clears it'),\n note: z\n .string()\n .max(2000)\n .optional()\n .describe('What changed, shown with the update'),\n }),\n outputSchema: z.object({ task, changed: z.boolean() }),\n annotations: SEND,\n handler: async (api, a) => {\n if (a.status === undefined && a.dueAt === undefined) {\n throw new ToolError('Pass status or dueAt.');\n }\n const r = await api.request<{ task: Json; changed?: boolean }>(\n 'PATCH',\n `/v1/agents/tasks/${enc(a.taskId)}`,\n {\n body: {\n agent_id: actingAs(api, a.agentId),\n status: a.status,\n due_at: a.dueAt,\n note: a.note,\n },\n }\n );\n return { task: r.task as never, changed: Boolean(r.changed) };\n },\n }),\n\n defineTool({\n name: 'handoff_task',\n title: 'Hand off task',\n description:\n \"Hand a task you are assigned to (or created) to another member agent of its channel, with the reason: the new and the previous assignee get a status message (data.handoff), and it's recorded in the task's history. Use it when another agent is better placed, then stop working on the task. Errors: ALREADY_ASSIGNED, AGENT_NOT_IN_CHANNEL, TASK_CLOSED, NOT_TASK_PARTICIPANT, POLICY_DM_NOT_ALLOWED. Needs the agents:send scope.\",\n scope: 'agents:send',\n endpoint: 'POST /v1/agents/tasks/:taskId/handoff',\n inputSchema: z.object({\n agentId,\n taskId: uuid('The task ID'),\n toAgentId: uuid('The new assignee (from list_agents or get_org_chart)'),\n reason: z\n .string()\n .max(2000)\n .optional()\n .describe('Why, and what the new assignee needs to know'),\n }),\n outputSchema: z.object({ task, deliveries }),\n annotations: SEND,\n handler: async (api, a) => {\n const r = await api.request<{ task: Json; deliveries?: Json[] }>(\n 'POST',\n `/v1/agents/tasks/${enc(a.taskId)}/handoff`,\n {\n body: {\n agent_id: actingAs(api, a.agentId),\n to_agent_id: a.toAgentId,\n reason: a.reason,\n },\n }\n );\n return {\n task: r.task as never,\n deliveries: (r.deliveries ?? []) as never,\n };\n },\n }),\n\n defineTool({\n name: 'list_tasks',\n title: 'List tasks',\n description:\n \"List a channel's tasks, newest first, with their board status (open, in_progress, blocked, done, failed), assignee, due date and last handoff. Filter by assignee (your own agent id for your work) or status. channelId is required unless the key is an agents:admin key. Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/tasks',\n inputSchema: z.object({\n agentId,\n channelId: channelId.optional(),\n assigneeAgentId: uuid('Only tasks assigned to this agent').optional(),\n status: z.enum(BOARD_STATUSES).optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(500)\n .default(50)\n .describe('How many to return (1-500, default 50)'),\n }),\n outputSchema: z.object({ tasks: z.array(task) }),\n annotations: READ,\n handler: async (api, a) => {\n const r = await api.request<{ tasks?: Json[] }>(\n 'GET',\n '/v1/agents/tasks',\n {\n query: {\n agent_id: actingAs(api, a.agentId),\n channel_id: a.channelId,\n assignee_agent_id: a.assigneeAgentId,\n status: a.status,\n limit: a.limit,\n },\n }\n );\n return { tasks: (r.tasks ?? []) as never };\n },\n }),\n\n defineTool({\n name: 'get_task_board',\n title: 'Get task board',\n description:\n \"A channel's task board: tasks grouped by column (open, in_progress, blocked, done, failed), counts per column, and the agents on it. Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/tasks/board',\n inputSchema: z.object({\n agentId,\n channelId,\n assigneeAgentId: uuid('Only tasks assigned to this agent').optional(),\n }),\n outputSchema: z.object({\n channel_id: z.string(),\n columns: z.record(z.string(), z.array(task)),\n counts: z.record(z.string(), z.number()),\n agents: z.array(z.looseObject({ id: z.string() })),\n truncated: z.boolean(),\n }),\n annotations: READ,\n handler: async (api, a) =>\n (await api.request<Json>('GET', '/v1/agents/tasks/board', {\n query: {\n agent_id: actingAs(api, a.agentId),\n channel_id: a.channelId,\n assignee_agent_id: a.assigneeAgentId,\n },\n })) as never,\n }),\n\n defineTool({\n name: 'ask_human',\n title: 'Ask a human',\n description:\n \"Ask people a question, or for an approval (kind approval: Approve / Deny), when you can't or shouldn't decide alone. It's posted in Slack (the channel's linked Slack channel, else the escalation channel) with a button per option, and escalates (manager, owner, supervisors, escalation channel) until someone answers or the deadline passes; with a defaultOption, the default applies at the deadline. Returns at once with the questionId: then call get_answer, which waits for the answer. Don't act on what you asked about before the answer. Counts as one Event. Your policy may refuse (POLICY_ASK_HUMAN_NOT_ALLOWED, POLICY_URGENCY_NOT_ALLOWED). Needs the agents:ask_human scope.\",\n scope: 'agents:ask_human',\n endpoint: 'POST /v1/agents/questions',\n inputSchema: z.object({\n agentId,\n kind: z\n .enum(['question', 'approval'])\n .default('question')\n .describe('question (default) or approval (answered Approve / Deny)'),\n question: z\n .string()\n .min(1)\n .max(3000)\n .describe('The question, with what people need to answer it'),\n options: z\n .array(\n z.object({\n id: z.string().min(1).max(100),\n label: z.string().min(1).max(75),\n })\n )\n .max(10)\n .optional()\n .describe('Up to 10 answers to pick from (ignored for approvals)'),\n freeText: z\n .boolean()\n .optional()\n .describe('Allow a typed answer (always on without options)'),\n urgency: z\n .enum(['low', 'normal', 'high', 'urgent'])\n .optional()\n .describe('How fast it escalates (default normal)'),\n deadline: z\n .string()\n .max(40)\n .optional()\n .describe('ISO date-time, at most 30 days away'),\n defaultOption: z\n .string()\n .max(100)\n .optional()\n .describe('Option id applied at the deadline when nobody answered'),\n channelId: channelId\n .optional()\n .describe('Post it in this agent channel (from list_agent_channels)'),\n threadId,\n context: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Facts shown with the question (JSON object)'),\n amount: z\n .number()\n .min(0)\n .optional()\n .describe('Approvals: the amount at stake'),\n currency: z\n .string()\n .regex(/^[A-Za-z]{3}$/)\n .optional()\n .describe('Approvals: ISO 4217 currency code'),\n resource: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Approvals: what is being approved (JSON object)'),\n requiredRoles: z\n .array(z.string().min(1).max(40))\n .max(10)\n .optional()\n .describe('Approvals: roles that may answer, e.g. [\"admin\"]'),\n }),\n outputSchema: z.object({ questionId: z.string(), question }),\n annotations: SEND,\n handler: async (api, a) => {\n const r = await api.request<{ question: Json }>(\n 'POST',\n '/v1/agents/questions',\n {\n body: {\n agent_id: actingAs(api, a.agentId),\n kind: a.kind,\n question: a.question,\n options: a.options,\n free_text: a.freeText,\n urgency: a.urgency,\n deadline: a.deadline,\n default_option: a.defaultOption,\n channel_id: a.channelId,\n thread_id: a.threadId,\n context: a.context,\n amount: a.amount,\n currency: a.currency,\n resource: a.resource,\n required_roles: a.requiredRoles,\n },\n }\n );\n return {\n questionId: String(r.question.id),\n question: r.question as never,\n };\n },\n }),\n\n defineTool({\n name: 'get_answer',\n title: 'Get answer',\n description: `Wait for the answer to a question from ask_human: holds up to waitSeconds (default and maximum ${QUESTION_WAIT_MAX_SECONDS}) and returns as soon as it closes. status is answered (answer.option_id / answer.text; approvals have answer.approved), expired_default (the default option applied), expired (no answer by the deadline) or canceled. When waiting is true nobody has answered yet: call get_answer again, or do other work and come back. Needs the agents:ask_human scope (or agents:read).`,\n scope: 'agents:ask_human',\n endpoint: 'GET /v1/agents/questions/:id/wait',\n inputSchema: z.object({\n agentId,\n questionId,\n waitSeconds: z\n .number()\n .int()\n .min(0)\n .max(QUESTION_WAIT_MAX_SECONDS)\n .default(QUESTION_WAIT_MAX_SECONDS)\n .describe(\n `Seconds to wait for an answer (0-${QUESTION_WAIT_MAX_SECONDS}, default ${QUESTION_WAIT_MAX_SECONDS}); 0 only checks`\n ),\n }),\n outputSchema: z.object({\n questionId: z.string(),\n status: z.string(),\n waiting: z.boolean(),\n answer: z.looseObject({}).nullable(),\n message: z.string(),\n question,\n }),\n annotations: READ,\n handler: async (api, a) => {\n const r = await api.request<{ question: Json; timed_out?: boolean }>(\n 'GET',\n `/v1/agents/questions/${enc(a.questionId)}/wait`,\n {\n query: {\n agent_id: actingAs(api, a.agentId),\n timeout: a.waitSeconds,\n },\n // The API holds the request for up to waitSeconds.\n timeout: (a.waitSeconds + 10) * 1000,\n }\n );\n const status = String(r.question.status);\n const waiting = status === 'open';\n return {\n questionId: a.questionId,\n status,\n waiting,\n answer: (r.question.answer ?? null) as never,\n message: waiting\n ? `Still waiting: nobody has answered yet. Call get_answer again with questionId ${a.questionId}, or check back later; don't act on the question meanwhile.`\n : outcomeMessage(status, r.question),\n question: r.question as never,\n };\n },\n }),\n\n defineTool({\n name: 'list_questions',\n title: 'List questions',\n description:\n 'List your questions and the ones escalated to you as a manager agent, newest first. Filter with status open to find what still needs an answer (answer_escalated_question). Needs the agents:read scope (or agents:ask_human).',\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/questions',\n inputSchema: z.object({\n agentId,\n status: z\n .enum(['open', 'answered', 'expired_default', 'expired', 'canceled'])\n .optional(),\n kind: z.enum(['question', 'approval']).optional(),\n channelId: channelId.optional(),\n cursor: z\n .string()\n .max(300)\n .optional()\n .describe('nextCursor of the previous call'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(200)\n .default(20)\n .describe('How many to return (1-200, default 20)'),\n }),\n outputSchema: z.object({\n questions: z.array(question),\n nextCursor: z.string().nullable(),\n }),\n annotations: READ,\n handler: async (api, a) => {\n const r = await api.request<{\n questions?: Json[];\n next_cursor?: string | null;\n }>('GET', '/v1/agents/questions', {\n query: {\n agent_id: actingAs(api, a.agentId),\n status: a.status,\n kind: a.kind,\n channel_id: a.channelId,\n cursor: a.cursor,\n limit: a.limit,\n },\n });\n return {\n questions: (r.questions ?? []) as never,\n nextCursor: r.next_cursor ?? null,\n };\n },\n }),\n\n defineTool({\n name: 'cancel_question',\n title: 'Cancel question',\n description:\n \"Cancel one of your open questions when it no longer matters (you found the answer, the work was dropped): its Slack post is updated and escalation stops. Only the agent that asked can cancel, and a closed question can't be (QUESTION_CLOSED). Needs the agents:ask_human scope.\",\n scope: 'agents:ask_human',\n endpoint: 'DELETE /v1/agents/questions/:id',\n inputSchema: z.object({ agentId, questionId }),\n outputSchema: z.object({ question }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n },\n handler: async (api, a) => {\n const r = await api.request<{ question: Json }>(\n 'DELETE',\n `/v1/agents/questions/${enc(a.questionId)}`,\n { query: { agent_id: actingAs(api, a.agentId) } }\n );\n return { question: r.question as never };\n },\n }),\n\n defineTool({\n name: 'answer_escalated_question',\n title: 'Answer escalated question',\n description:\n \"Answer a question another agent asked, when it was escalated to you as its manager agent (a question.escalated delivery, or list_questions with status open). Pick an optionId (approve / deny for approvals, with a comment), or give text when free text is allowed. The first answer wins (QUESTION_CLOSED after), approvals that require a role need a person (APPROVAL_ROLE_REQUIRED), and you can't answer your own question. Needs the agents:send scope.\",\n scope: 'agents:send',\n endpoint: 'POST /v1/agents/questions/:id/answer',\n inputSchema: z.object({\n agentId,\n questionId,\n optionId: z\n .string()\n .min(1)\n .max(100)\n .optional()\n .describe('One of the question options (approve / deny for approvals)'),\n text: z\n .string()\n .max(3000)\n .optional()\n .describe('A typed answer, when the question allows free text'),\n comment: z\n .string()\n .max(2000)\n .optional()\n .describe('Why (shown with the answer; say why on a deny)'),\n }),\n outputSchema: z.object({ question }),\n annotations: SEND,\n handler: async (api, a) => {\n if (!a.optionId && !a.text) throw new ToolError('Pass optionId or text.');\n const r = await api.request<{ question: Json }>(\n 'POST',\n `/v1/agents/questions/${enc(a.questionId)}/answer`,\n {\n body: {\n agent_id: actingAs(api, a.agentId),\n option_id: a.optionId,\n text: a.text,\n comment: a.comment,\n },\n }\n );\n return { question: r.question as never };\n },\n }),\n\n defineTool({\n name: 'get_org_chart',\n title: 'Get org chart',\n description:\n \"The organization's agents with their manager (an agent or a person), owner and teams, the teams, and the reporting tree. Use it to find who to hand a task off to, or who manages an agent. Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/org-chart',\n inputSchema: z.object({\n teamId: uuid('Only this team').optional(),\n channelId: uuid('Only the agents of this channel').optional(),\n includeRetired: z\n .boolean()\n .optional()\n .describe('Include retired agents (default false)'),\n }),\n outputSchema: z.object({\n agents: z.array(z.looseObject({ id: z.string() })),\n users: z.array(z.looseObject({ id: z.string() })),\n teams: z.array(z.looseObject({ id: z.string() })),\n tree: z.array(z.looseObject({})),\n }),\n annotations: READ,\n handler: async (api, a) =>\n (await api.request<Json>('GET', '/v1/agents/org-chart', {\n query: {\n team_id: a.teamId,\n channel_id: a.channelId,\n include_retired: a.includeRetired ? 'true' : undefined,\n },\n })) as never,\n }),\n\n defineTool({\n name: 'get_effective_policy',\n title: 'Get effective policy',\n description:\n 'The policy in force for an agent (in a channel): the merged rules (allowed channels, direct messages, asking humans, rate, budgets, working hours, thread depth, humans-win minutes), which policy set each, current usage, working hours now, and with a channel whether it may post and read there now. Read-only. Needs an unbound key with the agents:admin scope: a key bound to agents gets 403 AGENT_ADMIN_KEY_REQUIRED.',\n scope: 'agents:admin',\n endpoint: 'GET /v1/agents/policies/preview',\n inputSchema: z.object({\n agentId: uuid(\n 'The agent (from list_agents). Default: the server agent (CHANNLIZE_AGENT_ID)'\n ).optional(),\n channelId: channelId.optional(),\n }),\n outputSchema: z.looseObject({\n agent_id: z.string(),\n channel_id: z.string().nullable(),\n rules: z.looseObject({}),\n working_hours: z.looseObject({}),\n usage: z.looseObject({}),\n checks: z.looseObject({}).nullable(),\n }),\n annotations: READ,\n handler: async (api, a) =>\n (await api.request<Json>('GET', '/v1/agents/policies/preview', {\n query: {\n agent_id: requireAgent(api, a.agentId),\n channel_id: a.channelId,\n },\n })) as never,\n }),\n\n defineTool({\n name: 'read_agent_inbox',\n title: 'Read agent inbox',\n description:\n \"Read your agent's unacknowledged messages, oldest first: messages, tasks and task status updates from other agents and people, each with its channel, thread and sender. Messages stay until ack_agent_messages acknowledges them, so read, handle, then ack. Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/:id/inbox',\n inputSchema: z.object({\n agentId,\n cursor: z\n .string()\n .max(200)\n .optional()\n .describe('Read after this cursor (nextCursor of the previous call)'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(200)\n .default(20)\n .describe('How many to return (1-200, default 20)'),\n }),\n outputSchema: z.object({\n agentId: z.string(),\n messages: z.array(\n z.looseObject({\n delivery_id: z.string(),\n cursor: z.string(),\n message,\n })\n ),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n }),\n annotations: READ,\n handler: async (api, a) => {\n const id = requireAgent(api, a.agentId);\n const r = await api.request<Json>('GET', `/v1/agents/${enc(id)}/inbox`, {\n query: { cursor: a.cursor, limit: a.limit },\n });\n return {\n agentId: id,\n messages: (r.messages ?? []) as never,\n nextCursor: (r.next_cursor as string | null | undefined) ?? null,\n hasMore: Boolean(r.has_more),\n };\n },\n }),\n\n defineTool({\n name: 'ack_agent_messages',\n title: 'Acknowledge agent messages',\n description:\n 'Acknowledge inbox messages you handled so read_agent_inbox stops returning them: upTo acks everything up to and including that delivery or message ID, ids acks just those. Acking twice is harmless. Needs the agents:read scope.',\n scope: 'agents:read',\n endpoint: 'POST /v1/agents/:id/inbox/ack',\n inputSchema: z.object({\n agentId,\n upTo: z\n .string()\n .uuid()\n .optional()\n .describe('Ack everything up to and including this delivery_id'),\n ids: z\n .array(z.string().uuid())\n .min(1)\n .max(500)\n .optional()\n .describe('Ack these delivery (or message) IDs'),\n }),\n outputSchema: z.object({ acked: z.number() }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n handler: async (api, a) => {\n if (!a.upTo === !a.ids) {\n throw new ToolError('Pass either upTo or ids.');\n }\n const id = requireAgent(api, a.agentId);\n const r = await api.request<{ acked?: number }>(\n 'POST',\n `/v1/agents/${enc(id)}/inbox/ack`,\n { body: a.upTo ? { up_to: a.upTo } : { ids: a.ids } }\n );\n return { acked: Number(r.acked ?? 0) };\n },\n }),\n\n defineTool({\n name: 'list_agents',\n title: 'List agents',\n description:\n \"List the organization's agents: id, slug, name, role, description, status (active, paused, retired) and how they receive messages. Use the ids for mentions and agentId. Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents',\n inputSchema: z.object({\n includeRetired: z\n .boolean()\n .optional()\n .describe('Include retired agents (default false)'),\n }),\n outputSchema: z.object({\n agents: z.array(\n z.looseObject({\n id: z.string(),\n slug: z.string(),\n name: z.string(),\n status: z.string(),\n })\n ),\n }),\n annotations: READ,\n handler: async (api, a) => {\n const r = await api.request<{ agents?: Json[] }>('GET', '/v1/agents', {\n query: { include_retired: a.includeRetired || undefined },\n });\n return { agents: (r.agents ?? []) as never };\n },\n }),\n\n defineTool({\n name: 'list_agent_channels',\n title: 'List agent channels',\n description:\n \"List the agent channels your key's agents are members or observers of: id, slug, name, description and whether they are archived. Post with send_agent_message (members only). Needs the agents:read scope.\",\n scope: 'agents:read',\n endpoint: 'GET /v1/agents/channels',\n inputSchema: z.object({\n includeArchived: z\n .boolean()\n .optional()\n .describe('Include archived channels (default false)'),\n }),\n outputSchema: z.object({\n channels: z.array(\n z.looseObject({\n id: z.string(),\n slug: z.string(),\n name: z.string(),\n archived: z.boolean(),\n })\n ),\n }),\n annotations: READ,\n handler: async (api, a) => {\n const r = await api.request<{ channels?: Json[] }>(\n 'GET',\n '/v1/agents/channels',\n { query: { include_archived: a.includeArchived || undefined } }\n );\n return { channels: (r.channels ?? []) as never };\n },\n }),\n];\n\nexport const AGENT_TOOL_NAMES = AGENT_TOOLS.map(t => t.name);\n\nexport function getAgentTool(name: string): AgentTool | undefined {\n return AGENT_TOOLS.find(t => t.name === name);\n}\n\n/**\n * Validate `args` against the tool's input schema and run it. Throws\n * `ToolError` for an unknown tool or invalid arguments, and for API\n * failures (`toToolError` in `api.ts` words them for the model).\n */\nexport async function runAgentTool(\n api: AgentsRequester,\n name: string,\n args: unknown\n): Promise<Json> {\n const tool = getAgentTool(name);\n if (!tool) throw new ToolError(`Unknown agent tool \"${name}\"`);\n const parsed = tool.inputSchema.safeParse(args ?? {});\n if (!parsed.success) {\n throw new ToolError(\n `Invalid arguments for ${name}: ${parsed.error.issues\n .map(i => `${i.path.join('.') || 'input'}: ${i.message}`)\n .join('; ')}`\n );\n }\n return (await tool.handler(api, parsed.data)) as Json;\n}\n\n/**\n * The tools as JSON Schema function definitions, for LLM APIs that take\n * `{ name, description, parameters }` (OpenAI / OpenRouter style).\n */\nexport function agentToolsAsJsonSchema(\n filter: (tool: AgentTool) => boolean = () => true\n): Array<{ name: string; description: string; parameters: Json }> {\n return AGENT_TOOLS.filter(filter).map(t => ({\n name: t.name,\n description: t.description,\n parameters: z.toJSONSchema(t.inputSchema, { io: 'input' }) as Json,\n }));\n}\n","import {\n ChannlizeClient,\n ChannlizeError,\n parseApiError,\n} from '@channlize/core';\nimport type { ResolvedConfig } from './config';\n\nexport type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';\n\n/**\n * A failed Channlize call, worded for the model: what went wrong and how\n * to fix it (wrong key, missing scope, unknown id). Tool handlers throw it\n * and the MCP server returns it as a tool error (`isError: true`).\n */\nexport class ToolError extends Error {\n constructor(\n message: string,\n public statusCode?: number,\n public code?: string,\n /** ISO time the call may succeed again (agent policies, takeovers). */\n public retryAt?: string\n ) {\n super(message);\n this.name = 'ToolError';\n }\n}\n\ntype Query = Record<string, string | number | boolean | undefined>;\n\n/** The scope to add for an \"API key lacks required permission: <perm>\" 403. */\nfunction scopeFor(apiMessage: string): string {\n const perm = /permission:\\s*([\\w:*-]+)/i.exec(apiMessage)?.[1] ?? '';\n switch (perm) {\n case 'inbox:read':\n return 'inbox:read (or read)';\n case 'inbox:write':\n return 'inbox:write';\n case 'routing:read':\n return 'routing:write, inbox:read (or read)';\n case 'routing:write':\n return 'routing:write';\n case 'analytics:read':\n return 'analytics:read (or read)';\n case 'agents:send':\n return 'agents:send';\n case 'agents:read':\n return 'agents:read';\n case 'agents:ask_human':\n return 'agents:ask_human';\n case 'agents:admin':\n return 'agents:admin (an unbound key)';\n default:\n return /write|notify/.test(apiMessage) ? 'write' : 'read';\n }\n}\n\n/** \" Retry after <time>.\" for a refusal that names one. */\nfunction retryText(retryAt: string | undefined): string {\n return retryAt ? ` Retry after ${retryAt}, not before.` : '';\n}\n\n/** Hints for the Channlize for Agents error codes. */\nfunction agentHint(\n code: string | undefined,\n body: Record<string, unknown> = {}\n): string | undefined {\n const retryAt = typeof body.retryAt === 'string' ? body.retryAt : undefined;\n switch (code) {\n case 'AGENT_KEY_REQUIRED':\n return 'Agent tools need an agent key or a multi-agent key: create one under SDK & Integration → API keys and pick the agents.';\n case 'AGENT_NOT_ALLOWED':\n return \"The key can't act as that agent: pass one of the key's agents as agentId (list_agents), or fix CHANNLIZE_AGENT_ID.\";\n case 'NOT_A_CHANNEL_MEMBER':\n return 'Only channel members can post (observers only read): use list_agent_channels, or ask an admin to add the agent to the channel.';\n case 'AGENT_PAUSED':\n case 'AGENT_RETIRED':\n return 'Only active agents can act: ask an admin to reactivate it in the dashboard.';\n case 'AGENT_RATE_LIMITED':\n return 'The agent is sending too fast: wait a minute before sending again.';\n case 'AGENT_THREAD_PAUSED': {\n const why =\n body.reason === 'ping_pong'\n ? ' (two agents were going back and forth)'\n : body.reason === 'duplicate_content'\n ? ' (the same message kept being posted)'\n : '';\n return `The loop guard paused this thread${why}: stop sending in it until a person replies or resumes it. Don't rephrase and retry.`;\n }\n case 'HUMAN_TAKEOVER':\n return `A person took over this thread: don't post in it until the takeover ends or they hand it back.${retryText(retryAt)}`;\n case 'POLICY_RATE_LIMITED':\n case 'POLICY_BUDGET_EXHAUSTED':\n case 'POLICY_OUTSIDE_WORKING_HOURS':\n return `The agent's policy refuses this for now: wait, don't retry in a loop.${retryText(retryAt)}`;\n case 'POLICY_CHANNEL_NOT_ALLOWED':\n case 'POLICY_DM_NOT_ALLOWED':\n case 'POLICY_ASK_HUMAN_NOT_ALLOWED':\n case 'POLICY_URGENCY_NOT_ALLOWED':\n case 'POLICY_MAX_DEPTH':\n return \"The agent's policy forbids this: retrying won't help. Pick another channel, agent or urgency, or ask an admin to change the policy.\";\n case 'TASK_CLOSED':\n return 'The task is closed (completed, failed, canceled or rejected) and cannot change: create a new task instead.';\n case 'ALREADY_ASSIGNED':\n return 'The task is already assigned to that agent.';\n case 'AGENT_NOT_IN_CHANNEL':\n return \"The other agent isn't a member of the task's channel: pick a member (list_agent_channels), or ask an admin to add it.\";\n case 'NOT_TASK_PARTICIPANT':\n return \"Only the task's assignee or creator can change it or hand it off.\";\n case 'QUESTION_CLOSED':\n return 'The question is already closed (answered, expired or canceled): the first answer wins. Read it with get_answer.';\n case 'APPROVAL_ROLE_REQUIRED':\n return 'This approval needs a person with the required role: an agent cannot answer it.';\n case 'AGENT_ADMIN_KEY_REQUIRED':\n return 'This needs an unbound agents:admin key (not a key bound to agents): create one under SDK & Integration → API keys.';\n case 'INVALID_ANSWER':\n return \"Answer with one of the question's option ids (approve / deny for approvals), or text when free text is allowed.\";\n default:\n return undefined;\n }\n}\n\nfunction hintFor(\n status: number,\n apiMessage: string,\n code?: string,\n body?: Record<string, unknown>\n): string {\n const agent = agentHint(code, body);\n if (agent) return `${apiMessage}. ${agent}`;\n if (status === 400 && /agent_id is required/i.test(apiMessage)) {\n return `${apiMessage}. Pass agentId (from list_agents), or set CHANNLIZE_AGENT_ID / --agent-id on the MCP server.`;\n }\n switch (status) {\n case 401:\n return `${apiMessage}. The server API key is invalid, revoked or expired: create a new one under SDK & Integration → API keys and update CHANNLIZE_SERVER_API_KEY.`;\n case 403:\n return /permission/i.test(apiMessage)\n ? `${apiMessage}. This needs a server API key with the ${scopeFor(\n apiMessage\n )} scope: create one under SDK & Integration → API keys.`\n : apiMessage;\n case 404:\n return `${apiMessage}. Check the ID (and CHANNLIZE_PROJECT_ID): it must belong to the key's organization.`;\n case 429:\n return `${apiMessage}. Rate limited: wait a little before retrying.`;\n default:\n return apiMessage;\n }\n}\n\n/** Maps a `@channlize/core` error to a `ToolError` with the same hints. */\nexport function toToolError(err: unknown): ToolError {\n if (err instanceof ToolError) return err;\n if (err instanceof ChannlizeError) {\n return new ToolError(\n err.statusCode\n ? hintFor(\n err.statusCode,\n err.message.replace(/\\.$/, ''),\n err.code,\n err.details\n )\n : err.message,\n err.statusCode,\n err.code,\n err.retryAt\n );\n }\n return new ToolError(err instanceof Error ? err.message : String(err));\n}\n\n/**\n * Thin client for the API-key endpoints `@channlize/core` doesn't wrap\n * (projects, the inbox, routing rules, contacts, Events and log reads,\n * agents). Widget-key\n * calls and `notify` go through `@channlize/core`.\n */\nexport class ChannlizeApi {\n private projectIdPromise?: Promise<string>;\n private widgetClient?: ChannlizeClient;\n\n constructor(readonly config: ResolvedConfig) {}\n\n get hasServerKey(): boolean {\n return !!this.config.serverApiKey;\n }\n\n get hasWidgetKey(): boolean {\n return !!this.config.widgetKey;\n }\n\n /** The default agent for the agent tools (`CHANNLIZE_AGENT_ID`). */\n get agentId(): string | undefined {\n return this.config.agentId;\n }\n\n private requireServerKey(): string {\n if (!this.config.serverApiKey) {\n throw new ToolError(\n 'This tool needs a server API key (ch_live_…): set CHANNLIZE_SERVER_API_KEY or pass --server-api-key.'\n );\n }\n return this.config.serverApiKey;\n }\n\n async request<T>(\n method: HttpMethod,\n path: string,\n options: {\n query?: Query;\n body?: unknown;\n headers?: Record<string, string>;\n /** Overrides the configured timeout, in ms (long-polls). */\n timeout?: number;\n } = {}\n ): Promise<T> {\n const key = this.requireServerKey();\n const timeout = options.timeout ?? this.config.timeout;\n const url = new URL(`${this.config.baseUrl}${path}`);\n for (const [k, v] of Object.entries(options.query ?? {})) {\n if (v !== undefined && v !== '') url.searchParams.set(k, String(v));\n }\n\n let res: Response;\n try {\n res = await fetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${key}`,\n Accept: 'application/json',\n ...(options.body !== undefined\n ? { 'Content-Type': 'application/json' }\n : {}),\n ...options.headers,\n },\n // oxlint-disable-next-line unicorn/no-invalid-fetch-options -- `method` is dynamic; GET calls never pass a body.\n body:\n options.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal: AbortSignal.timeout(timeout),\n });\n } catch (err) {\n const e = err as Error;\n if (e.name === 'TimeoutError' || e.name === 'AbortError') {\n throw new ToolError(\n `Channlize API timed out after ${timeout} ms (${method} ${url.pathname}). Retry, or raise CHANNLIZE_TIMEOUT.`,\n 408,\n 'TIMEOUT'\n );\n }\n throw new ToolError(\n `Could not reach the Channlize API at ${this.config.baseUrl}: ${e.message}`\n );\n }\n\n const text = await res.text();\n let data: unknown = undefined;\n if (text) {\n try {\n data = JSON.parse(text);\n } catch {\n data = undefined;\n }\n }\n\n if (!res.ok) {\n const { message, code, body } = parseApiError(\n res.status,\n data,\n res.statusText\n );\n const retryAt =\n typeof body.retryAt === 'string' ? body.retryAt : undefined;\n throw new ToolError(\n hintFor(res.status, message.replace(/\\.$/, ''), code, body),\n res.status,\n code,\n retryAt\n );\n }\n if (data === undefined) {\n throw new ToolError(\n `Unexpected non-JSON response from ${method} ${url.pathname}`\n );\n }\n return data as T;\n }\n\n /**\n * `CHANNLIZE_PROJECT_ID`, or the first project of the key's organization\n * (`GET /projects/me`), looked up once.\n */\n projectId(): Promise<string> {\n if (this.config.projectId) return Promise.resolve(this.config.projectId);\n this.projectIdPromise ??= this.request<{ project: { id: string } }>(\n 'GET',\n '/projects/me'\n )\n .then(r => {\n if (!r.project?.id) {\n throw new ToolError(\n 'Could not find a project for this key: set CHANNLIZE_PROJECT_ID.'\n );\n }\n return r.project.id;\n })\n .catch(err => {\n this.projectIdPromise = undefined;\n throw err;\n });\n return this.projectIdPromise;\n }\n\n /** `@channlize/core` client bound to the widget key (visitor tools). */\n widget(): ChannlizeClient {\n if (!this.config.widgetKey) {\n throw new ToolError(\n 'This tool needs the public widget key (wk_…): set CHANNLIZE_WIDGET_KEY or pass --widget-key.'\n );\n }\n this.widgetClient ??= new ChannlizeClient({\n apiKey: this.config.widgetKey,\n projectId: this.config.projectId ?? '',\n baseUrl: this.config.baseUrl,\n timeout: this.config.timeout,\n });\n return this.widgetClient;\n }\n\n /** `@channlize/core` client for `notify` (server key + project). */\n async notifier(): Promise<ChannlizeClient> {\n const serverApiKey = this.requireServerKey();\n return new ChannlizeClient({\n // core requires a widget key; notify only uses serverApiKey.\n apiKey: this.config.widgetKey ?? 'unused',\n serverApiKey,\n projectId: await this.projectId(),\n baseUrl: this.config.baseUrl,\n timeout: this.config.timeout,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,QAAmB;;;AC1BnB,kBAIO;AAUA,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC,YACEA,UACO,YACA,MAEA,SACP;AACA,UAAMA,QAAO;AALN;AACA;AAEA;AAGP,SAAK,OAAO;AAAA,EACd;AAAA,EAPS;AAAA,EACA;AAAA,EAEA;AAKX;;;ADwCA,SAAS,WACP,MACW;AACX,SAAO;AACT;AAGO,IAAM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