@messenger-agent/claude-agent 0.28.0 → 0.29.0-alpha.1
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{existsSync as r,readFileSync as i}from"node:fs";import{fileURLToPath as n}from"node:url";import{logger as c}from"@messenger-agent/shared/logger";const
|
|
2
|
-
`),
|
|
3
|
-
`),
|
|
4
|
-
`);function A(e,
|
|
5
|
-
${
|
|
6
|
-
`:""}${
|
|
1
|
+
import{existsSync as r,readFileSync as i}from"node:fs";import{fileURLToPath as n}from"node:url";import{logger as c}from"@messenger-agent/shared/logger";const l=[n(new URL("./assets/codex-home/AGENTS.md",import.meta.url)),n(new URL("../../../assets/codex-home/AGENTS.md",import.meta.url)),"/app/assets/codex-home/AGENTS.md"],d=["search_managed_tasks","get_managed_task","create_managed_task","update_managed_task","apply_managed_task_patch","delete_managed_task"],m=["## Claude Managed Task Tools","","When the user asks to create, update, inspect, continue, summarize, or delete managed tasks, use the managed task MCP tools. The available tool basenames are: "+d.map(e=>`\`${e}\``).join(", ")+". Claude may expose them with an MCP namespace such as `mcp__managed_tasks__<tool>`.",""].join(`
|
|
2
|
+
`),p=["## Response Style","","Do not use emoji in responses.","Use Markdown headings, bold, and italic formatting sparingly.","Other Markdown formatting, such as lists, inline code, links, and code blocks, may be used as needed.",""].join(`
|
|
3
|
+
`),u=["## Schedule Tool","","Use the single schedule MCP tool to prepare create/update proposals or list, inspect, pause, resume, and cancel schedules in the current trusted Matrix context. Select the action inside `input.action`; never ask for or invent a Room ID, actor ID, source event, or service credential. A successful create/update result is a proposal awaiting one explicit Messenger confirmation, not an active schedule. Do not ask for a chat reply or invoke another confirmation tool.",""].join(`
|
|
4
|
+
`);function A(e,s=!1){const a=`${m}
|
|
5
|
+
${s?`${u}
|
|
6
|
+
`:""}${p}`,t=[e??process.env.CLAUDE_MEMORY_TEMPLATE_PATH,...l].find(o=>!!(o&&r(o)));return t?`${i(t,"utf-8").trimEnd()}
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${a}`:(c.warn("Claude platform instructions template not found"),a)}export{A as loadClaudePlatformInstructions};
|
package/dist/schedule-mcp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSdkMcpServer as
|
|
1
|
+
import{randomUUID as a}from"node:crypto";import{createSdkMcpServer as c,tool as s}from"@anthropic-ai/claude-agent-sdk";import{executeScheduleTool as i,SCHEDULE_TOOL_DEFINITION as r,ScheduleToolError as u}from"@messenger-agent/shared/schedule-tools";const d="schedule";function p(t){return c({name:d,version:"0.1.0",instructions:"Manage schedules in the current trusted Matrix context.",alwaysLoad:!0,tools:[s(r.name,r.description,r.schema.shape,async n=>{try{const e=await i(t.config,t.context,n,fetch,a());return{content:[{type:"text",text:JSON.stringify(e)}],...e&&typeof e=="object"&&!Array.isArray(e)?{structuredContent:e}:null}}catch(e){const o=e instanceof u?{error:{code:e.code,message:e.message,retryable:e.retryable,currentRevision:e.currentRevision}}:{error:{code:"service_unavailable",message:e instanceof Error?e.message:String(e)}};return{content:[{type:"text",text:JSON.stringify(o)}],structuredContent:o,isError:!0}}},{alwaysLoad:!0,searchHint:r.name})]})}export{d as SCHEDULE_MCP_SERVER_NAME,p as createScheduleMcpServer};
|
package/dist/tunnel-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as f}from"node:module";import u from"ws";import{appConfig as p}from"./config.js";import{ChatBodySchema as y}from"./schemas.js";import{cancelClaudeConversation as C,ChatRequestError as
|
|
1
|
+
import{createRequire as f}from"node:module";import u from"ws";import{appConfig as p}from"./config.js";import{ChatBodySchema as y}from"./schemas.js";import{cancelClaudeConversation as C,ChatRequestError as m,handleClaudeChatStream as b}from"./routes/chat.js";import{logger as l}from"@messenger-agent/shared/logger";import{reconnectDelayWithJitter as g}from"@messenger-agent/shared/reconnect-backoff";import{sendHttpTunnelResponse as w}from"@messenger-agent/shared/tunnel-http";import{CODING_AGENT_TUNNEL_DUPLICATE_CLOSE_CODE as T,CODING_AGENT_TUNNEL_PROTOCOL_VERSION as v}from"@messenger-agent/shared/tunnel-protocol";const _=f(import.meta.url)("../package.json").version;function k(r){return new Promise(e=>setTimeout(e,r))}function I(r){try{const e=JSON.parse(r.toString());return!e||typeof e!="object"||!("type"in e)?void 0:e}catch{return}}function O(r){const e=new Headers;for(const[t,c]of Object.entries(r??{}))e.set(t,c);return e}function q(r){if(r.method==="POST")try{const e=new URL(r.path,"http://coding-agent-tunnel.local").pathname,t=/^\/v1\/chat\/([^/]+)\/cancel$/.exec(e);return t?decodeURIComponent(t[1]):void 0}catch{return}}class E{config;stopped=!1;socket;running=new Map;constructor(e){this.config=e}async start(){if(!this.config.enabled)return;if(!this.config.serverUrl||!this.config.tunnelId||!this.config.token)throw new Error("Tunnel config requires server_url, tunnel_id, and token when enabled");let e=this.config.reconnectInitialMs;for(;!this.stopped;){try{await this.connectOnce(),e=this.config.reconnectInitialMs}catch(t){if(this.stopped)break;l.warn("[TunnelClient] websocket tunnel connection failed:",t)}this.stopped||(await k(g(e)),e=Math.min(e*2,this.config.reconnectMaxMs))}}stop(){this.stopped=!0;for(const e of this.running.values())e.abortController.abort();this.running.clear(),this.socket?.close()}connectOnce(){return new Promise((e,t)=>{const c={Authorization:`Bearer ${this.config.token}`},o=new u(this.config.serverUrl,{headers:c});this.socket=o;let n,s=!1;const d=()=>{n&&clearInterval(n),this.socket===o&&(this.socket=void 0);for(const a of this.running.values())a.abortController.abort(new Error("Tunnel connection closed"));this.running.clear()};o.on("open",()=>{this.send({type:"hello",protocolVersion:v,tunnelId:this.config.tunnelId,agentType:"claude",clientVersion:_}),n=setInterval(()=>{this.send({type:"heartbeat"})},this.config.heartbeatIntervalMs),l.info(`[TunnelClient] connected to ${this.config.serverUrl} as ${this.config.tunnelId}`)}),o.on("message",a=>{const i=I(a);if(!i){l.warn("[TunnelClient] received invalid websocket message");return}if(i.type!=="heartbeat"){if(i.type==="cancel"){this.running.get(i.id)?.abortController.abort();return}i.type==="request"&&this.handleRequest(i).catch(h=>{l.error(`[TunnelClient] request ${i.id} failed:`,h)})}}),o.once("error",a=>{s||(s=!0,d(),t(a))}),o.once("close",(a,i)=>{d(),a===T&&(this.stopped=!0,l.warn(`[TunnelClient] duplicate websocket tunnel connection rejected; reconnect disabled: ${i.toString()}`)),s||(s=!0,e())})})}send(e){const t=this.socket;!t||t.readyState!==u.OPEN||t.send(JSON.stringify(e))}async handleRequest(e){const t=q(e);if(t){const n=C(t),s=Response.json(n?{success:!0}:{error:{type:"not_found_error",code:"conversation_not_found",message:`Conversation not found or already completed: ${t}`,param:"conversation_id"}},{status:n?200:404});await w(e.id,s,d=>this.send(d));return}if(e.method!=="POST"||e.path!=="/v1/chat/stream"){this.send({type:"response.error",id:e.id,code:"unsupported_request",errorText:`Unsupported tunnel request: ${e.method} ${e.path}`});return}const c=y.safeParse(e.body);if(!c.success){this.send({type:"response.error",id:e.id,code:"invalid_request",errorText:`Invalid chat request body: ${c.error.message}`});return}const o=new AbortController;this.running.set(e.id,{abortController:o}),this.send({type:"response.start",id:e.id,mode:"sse"});try{await b({body:c.data,headers:O(e.headers),signal:o.signal},{writeData:async n=>this.send({type:"response.chunk",id:e.id,data:n}),writeDone:async()=>this.send({type:"response.end",id:e.id})})}catch(n){const s=n instanceof Error?n.message:"Tunnel request failed",d=n instanceof m?`http_${n.status}`:"request_failed";this.send({type:"response.error",id:e.id,code:d,errorText:s})}finally{this.running.delete(e.id)}}}function L(r=p.tunnel){if(!r.enabled)return;const e=new E(r);return e.start().catch(t=>{l.error("[TunnelClient] stopped unexpectedly:",t)}),e}export{E as ClaudeTunnelClient,L as startClaudeTunnelClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-agent/claude-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"ws": "^8.21.0",
|
|
20
20
|
"yaml": "^2.9.0",
|
|
21
21
|
"zod": "^4.4.3",
|
|
22
|
-
"@messenger-agent/shared": "0.
|
|
22
|
+
"@messenger-agent/shared": "0.29.0-alpha.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/ws": "^8.18.1"
|