manifest 5.2.1 → 5.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ To resolve the conflict:`,(0,Jo.getConflictResolutionRecipe)(u,r))),c=a):JM.diag
|
|
|
16
16
|
openclaw config set plugins.entries.manifest.config.endpoint https://app.manifest.build/otlp`:`Invalid apiKey format. Keys must start with '${Ie}'. Fix it via:
|
|
17
17
|
openclaw config set manifest.apiKey ${Ie}YOUR_KEY`:`Missing apiKey. Set it via:
|
|
18
18
|
openclaw config set manifest.apiKey ${Ie}YOUR_KEY
|
|
19
|
-
or export MANIFEST_API_KEY=${Ie}YOUR_KEY`}var Xi=ve(iM()),$i=ve(li()),UI=ve(PI()),DI=ve(bI()),VI=ve(_o());m();var qr=null,Wr=null,yc=null,Pc=null;function Qi(o,r){let i=new VI.Resource({"service.name":o.serviceName,"service.version":"5.2.
|
|
19
|
+
or export MANIFEST_API_KEY=${Ie}YOUR_KEY`}var Xi=ve(iM()),$i=ve(li()),UI=ve(PI()),DI=ve(bI()),VI=ve(_o());m();var qr=null,Wr=null,yc=null,Pc=null;function Qi(o,r){let i=new VI.Resource({"service.name":o.serviceName,"service.version":"5.2.4","manifest.plugin":"true"}),c={Authorization:`Bearer ${o.apiKey}`},a=new UI.OTLPTraceExporter({url:`${o.endpoint}/v1/traces`,headers:c});qr=new Xi.BasicTracerProvider({resource:i,spanProcessors:[new Xi.BatchSpanProcessor(a,{scheduledDelayMillis:5e3,maxQueueSize:2048,maxExportBatchSize:512})]}),qr.register(),r.info(`[manifest] Trace exporter -> ${o.endpoint}/v1/traces`);let u=new DI.OTLPMetricExporter({url:`${o.endpoint}/v1/metrics`,headers:c});return Wr=new $i.MeterProvider({resource:i,readers:[new $i.PeriodicExportingMetricReader({exporter:u,exportIntervalMillis:o.metricsIntervalMs})]}),Nt.setGlobalMeterProvider(Wr),r.info(`[manifest] Metrics exporter -> ${o.endpoint}/v1/metrics (interval=${o.metricsIntervalMs}ms)`),yc=Ge.getTracer("manifest-plugin","5.2.4"),Pc=Nt.getMeter("manifest-plugin","5.2.4"),{tracer:yc,meter:Pc}}async function Zi(o){o.info("[manifest] Shutting down telemetry..."),qr&&(await qr.shutdown(),qr=null),Wr&&(await Wr.shutdown(),Wr=null),yc=null,Pc=null,o.info("[manifest] Telemetry shut down")}m();var sr=new Map,wI,BI,GI,HI,v5,kI,YI,FI,KI;function ea(o){wI=o.createCounter(Oe.LLM_REQUESTS,{description:"Total LLM inference requests"}),BI=o.createCounter(Oe.LLM_TOKENS_INPUT,{description:"Total input tokens sent to LLM"}),GI=o.createCounter(Oe.LLM_TOKENS_OUTPUT,{description:"Total output tokens from LLM"}),HI=o.createCounter(Oe.LLM_TOKENS_CACHE_READ,{description:"Total cache-read tokens"}),v5=o.createHistogram(Oe.LLM_DURATION,{description:"LLM request duration in ms",unit:"ms"}),kI=o.createCounter(Oe.TOOL_CALLS,{description:"Total tool invocations"}),YI=o.createCounter(Oe.TOOL_ERRORS,{description:"Total tool errors"}),FI=o.createHistogram(Oe.TOOL_DURATION,{description:"Tool execution duration in ms",unit:"ms"}),KI=o.createCounter(Oe.MESSAGES_RECEIVED,{description:"Total messages received from users"})}function ta(o,r,i,c){o.on("message_received",a=>{let u=a.sessionKey||a.session?.key||`agent:${a.agent||"main"}:main`,t=a.channel||"unknown",e=r.startSpan(Qr.REQUEST,{kind:we.SERVER,attributes:{[w.SESSION_KEY]:u,[w.CHANNEL]:t}});sr.set(u,{root:e}),KI.add(1,{[w.CHANNEL]:t}),c.debug(`[manifest] Root span started for session=${u}`)}),o.on("before_agent_start",a=>{let u=a.sessionKey||a.session?.key||`agent:${a.agent||"main"}:main`,t=a.agent||"main",e=sr.get(u),n=e?.root?Ge.setSpan(Be.active(),e.root):Be.active(),s=r.startSpan(Qr.AGENT_TURN,{kind:we.INTERNAL,attributes:{[w.AGENT_NAME]:t,[w.SESSION_KEY]:u}},n);e?e.turn=s:sr.set(u,{root:s,turn:s}),c.debug(`[manifest] Agent turn started: agent=${t}, session=${u}`)}),o.on("tool_result_persist",a=>{let u=a.toolName||a.tool||"unknown",t=a.durationMs||0,e=a.error==null,n=a.sessionKey||"unknown",s=sr.get(n),l=s?.turn?Ge.setSpan(Be.active(),s.turn):Be.active(),E=r.startSpan(`${Qr.TOOL_PREFIX}${u}`,{kind:we.INTERNAL,attributes:{[w.TOOL_NAME]:u,[w.TOOL_SUCCESS]:String(e),[w.SESSION_KEY]:n}},l);e||(E.setStatus({code:ht.ERROR,message:a.error?.message||"Tool execution failed"}),YI.add(1,{[w.TOOL_NAME]:u})),E.end(),kI.add(1,{[w.TOOL_NAME]:u}),FI.record(t,{[w.TOOL_NAME]:u})}),o.on("agent_end",a=>{let u=a.sessionKey||a.session?.key||`agent:${a.agent||"main"}:main`,e=[...a.messages||[]].reverse().find(Jr=>Jr.role==="assistant"&&Jr.usage),n=e?.model||a.model||"unknown",s=e?.provider||a.provider||"unknown",l=e?.usage||a.usage||{},E=l.input||l.inputTokens||0,O=l.output||l.outputTokens||0,g=l.cacheRead||l.cacheReadTokens||0,pe=l.cacheWrite||l.cacheWriteTokens||0,Ae=sr.get(u);Ae?.turn&&(Ae.turn.setAttributes({[w.MODEL]:n,[w.PROVIDER]:s,[w.INPUT_TOKENS]:E,[w.OUTPUT_TOKENS]:O,[w.CACHE_READ_TOKENS]:g,[w.CACHE_WRITE_TOKENS]:pe}),Ae.turn.end()),Ae?.root&&Ae.root!==Ae.turn&&Ae.root.end(),sr.delete(u);let Le={[w.MODEL]:n,[w.PROVIDER]:s};wI.add(1,Le),BI.add(E,Le),GI.add(O,Le),g>0&&HI.add(g,Le),c.debug(`[manifest] agent_end tokens: in=${E}, out=${O}, cache=${g}`),c.debug(`[manifest] Trace completed for session=${u}`)}),c.info("[manifest] All hooks registered")}async function ra(o){let r=o.endpoint.replace(/\/otlp(\/v1)?\/?$/,""),i={endpointReachable:!1,authValid:!1,agentName:null,error:null};try{let c=await fetch(`${r}/api/v1/health`,{signal:AbortSignal.timeout(5e3)});if(!c.ok)return i.error=`Health endpoint returned ${c.status}`,i;i.endpointReachable=!0}catch(c){let a=c instanceof Error?c.message:String(c);return i.error=`Cannot reach endpoint: ${a}`,i}try{let c=await fetch(`${r}/api/v1/agent/usage?range=24h`,{headers:{Authorization:`Bearer ${o.apiKey}`},signal:AbortSignal.timeout(5e3)});if(c.status===401||c.status===403)return i.error="API key rejected \u2014 check your mnfst_ key is correct",i;if(!c.ok)return i.error=`Usage endpoint returned ${c.status}`,i;i.authValid=!0;let a=await c.json();a&&typeof a.agentName=="string"&&(i.agentName=a.agentName)}catch(c){let a=c instanceof Error?c.message:String(c);return i.error=`Auth check failed: ${a}`,i}return i}var jI={today:"24h",week:"7d",month:"30d"};async function qI(o,r,i,c){let a=`${o}${r}`;try{let u=await fetch(a,{headers:{Authorization:`Bearer ${i}`}});return u.ok?{result:await u.json()}:{error:`API returned ${u.status}`}}catch(u){let t=u instanceof Error?u.message:String(u);return c.error(`[manifest] API call failed: ${t}`),{error:t}}}function na(o,r,i){let c=r.endpoint.replace(/\/otlp(\/v1)?\/?$/,"");o.registerTool({name:"manifest_usage",description:"Get token consumption for this agent: total, input, output, cache-read tokens, and action count. Use when the user asks about token usage or consumption.",parameters:{type:"object",properties:{period:{type:"string",enum:["today","week","month"],default:"today",description:"Time period"}}},handler:async a=>{let u=jI[a.period||"today"]||"24h";return qI(c,`/api/v1/agent/usage?range=${u}`,r.apiKey,i)}}),o.registerTool({name:"manifest_costs",description:"Get cost breakdown for this agent in USD, grouped by model. Use when the user asks about costs, spending, or money burned.",parameters:{type:"object",properties:{period:{type:"string",enum:["today","week","month"],default:"week",description:"Time period"}}},handler:async a=>{let u=jI[a.period||"week"]||"7d";return qI(c,`/api/v1/agent/costs?range=${u}`,r.apiKey,i)}}),o.registerTool({name:"manifest_health",description:"Check whether Manifest observability is connected and working. Use when the user asks if monitoring is set up or wants a connectivity test.",parameters:{type:"object",properties:{}},handler:async()=>{let a=await ra(r);return a.error?{error:a.error}:{result:{endpointReachable:a.endpointReachable,authValid:a.authValid,agentName:a.agentName,status:"ok"}}}}),i.info("[manifest] Registered agent tools: manifest_usage, manifest_costs, manifest_health")}var de=require("fs"),ia=require("path"),WI=require("os"),zI=require("crypto");var oa=(0,ia.join)((0,WI.homedir)(),".openclaw","manifest"),zr=(0,ia.join)(oa,"config.json");function O5(){(0,de.existsSync)(oa)||(0,de.mkdirSync)(oa,{recursive:!0,mode:448})}function m5(){if(O5(),(0,de.existsSync)(zr))try{let i=JSON.parse((0,de.readFileSync)(zr,"utf-8"));if(i.apiKey&&i.apiKey.startsWith(Ie))return i.apiKey}catch{}let o=`${Ie}local_${(0,zI.randomBytes)(24).toString("hex")}`,r={};if((0,de.existsSync)(zr))try{r=JSON.parse((0,de.readFileSync)(zr,"utf-8"))}catch{}return(0,de.writeFileSync)(zr,JSON.stringify({...r,apiKey:o},null,2),{mode:384}),o}function JI(o,r,i){let c=r.port,a=r.host,u=m5(),t=(0,ia.join)(oa,"manifest.db");i.info("[manifest] Local mode \u2014 starting embedded server...");let e;try{e=require("@mnfst/server")}catch{i.error(`[manifest] @mnfst/server is not installed.
|
|
20
20
|
Install it with: npm install @mnfst/server
|
|
21
21
|
Then restart the gateway.`);return}let n=`http://${a}:${c}/otlp`,s={...r,apiKey:u,endpoint:n},{tracer:l,meter:E}=Qi(s,i);ea(E),ta(o,l,s,i),typeof o.registerTool=="function"&&na(o,s,i),o.registerService({id:"manifest-local",start:async()=>{try{await e.start({port:c,host:a,dbPath:t}),i.info(`[manifest] Local server running on http://${a}:${c}`),i.info(`[manifest] Dashboard: http://${a}:${c}`),i.info(`[manifest] DB: ${t}`)}catch(O){let g=O instanceof Error?O.message:String(O);g.includes("EADDRINUSE")||g.includes("address already in use")?i.error(`[manifest] Port ${c} is already in use.
|
|
22
22
|
Change it with: openclaw config set plugins.entries.manifest.config.port ${c+1}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "manifest",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "Observability plugin for OpenClaw — traces, metrics, and cost tracking for your AI agent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
"homepage": "https://manifest.build",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/mnfst/manifest"
|
|
11
|
+
"url": "https://github.com/mnfst/manifest",
|
|
12
|
+
"directory": "packages/openclaw-plugin"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/mnfst/manifest/issues"
|
|
12
16
|
},
|
|
13
17
|
"files": [
|
|
14
18
|
"dist/index.js",
|
|
@@ -64,6 +68,5 @@
|
|
|
64
68
|
"@types/jest": "^29.5.0",
|
|
65
69
|
"jest": "^29.7.0",
|
|
66
70
|
"ts-jest": "^29.2.0"
|
|
67
|
-
}
|
|
68
|
-
"peerDependencies": {}
|
|
71
|
+
}
|
|
69
72
|
}
|