@synadia-ai/agent-fabric-claude-code 0.1.0 → 0.2.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/.claude-plugin/plugin.json +4 -4
- package/.mcp.json +14 -0
- package/BUILD +4 -0
- package/LICENSE +18 -17
- package/README.md +52 -441
- package/hooks/hooks.json +31 -0
- package/hooks/session-event.js +11 -0
- package/package.json +23 -72
- package/runtime/chunk-prncr0vg.js +38 -0
- package/runtime/fabric.js +7 -0
- package/runtime/server.js +63 -0
- package/skills/configure/SKILL.md +190 -0
- package/skills/configure/list-contexts.sh +22 -0
- package/CHANGELOG.md +0 -18
- package/dist/index.cjs +0 -277
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -63
- package/dist/index.d.ts +0 -63
- package/dist/index.js +0 -248
- package/dist/index.js.map +0 -1
package/hooks/hooks.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
3
|
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/hooks/session-event.js\"",
|
|
9
|
+
"timeout": 10
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
},
|
|
4
13
|
{
|
|
5
14
|
"hooks": [
|
|
6
15
|
{
|
|
@@ -10,6 +19,28 @@
|
|
|
10
19
|
}
|
|
11
20
|
]
|
|
12
21
|
}
|
|
22
|
+
],
|
|
23
|
+
"Stop": [
|
|
24
|
+
{
|
|
25
|
+
"hooks": [
|
|
26
|
+
{
|
|
27
|
+
"type": "command",
|
|
28
|
+
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/hooks/session-event.js\"",
|
|
29
|
+
"timeout": 10
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"PreToolUse": [
|
|
35
|
+
{
|
|
36
|
+
"hooks": [
|
|
37
|
+
{
|
|
38
|
+
"type": "command",
|
|
39
|
+
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/hooks/session-event.js\"",
|
|
40
|
+
"timeout": 10
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
13
44
|
]
|
|
14
45
|
}
|
|
15
46
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
import{writeSync as K}from"fs";import{homedir as V}from"os";import{join as Y}from"path";import{existsSync as rn,mkdirSync as g,readdirSync as sn,readFileSync as w,renameSync as J,rmSync as j,writeFileSync as D}from"fs";import{join as f}from"path";var U=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,q=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/,F=["discover_agents","prompt_agent","wait_agent","answer_agent","cancel_agent","list_agent_calls"];function A(n){return typeof n==="string"&&U.test(n)}function L(n){return typeof n==="string"&&q.test(n)}function c(n){return f(n,"sessions")}function C(n,e){return f(c(n),String(e))}function b(n,e){return f(c(n),`${e}.stop`)}function h(n,e){return f(c(n),`${e}.nudge`)}function x(n,e){return f(c(n),`${e}.turn`)}function z(n,e){return f(c(n),`${e}.open`)}function Z(n,e){return f(c(n),`${e}.tools`)}function l(n,e){let t=`${n}.${process.pid}.tmp`;D(t,e),J(t,n)}var B=new RegExp(`^mcp__.+__(${F.join("|")})$`);function G(n){return B.test(n)}function v(n){if(!("background_tasks"in n)&&!("session_crons"in n))return;return k(n.background_tasks)||k(n.session_crons)}function k(n){if(n===void 0||n===null||n===!1||n===0||n==="")return!1;if(Array.isArray(n))return n.length>0;if(typeof n==="object")return Object.keys(n).length>0;return!0}function R(n,e,t,r=Date.now()){let s=t.hook_event_name,o=A(t.session_id)?t.session_id:void 0;if(s==="SessionStart"){if(o===void 0)return;let i=typeof t.source==="string"?t.source:"unknown";return g(c(n),{recursive:!0}),l(C(n,e),`${JSON.stringify({session_id:o,source:i,at_ms:r})}
|
|
4
|
+
`),"session"}if(s==="Stop"){let i=v(t),u=O(n,e),d=u===void 0||u.length>0?W(n,e)??N(t):void 0;return g(c(n),{recursive:!0}),l(b(n,e),`${JSON.stringify({...o?{session_id:o}:{},...i!==void 0?{background:i}:{},...d!==void 0?{final_text:d}:{},at_ms:r})}
|
|
5
|
+
`),Q(h(n,e)),"stop"}if(s==="PreToolUse"){let{tool_use_id:i,tool_name:u}=t;if(typeof u!=="string"||u.length===0)return;if(g(c(n),{recursive:!0}),H(n,e,t.prompt_id,r),!G(u)||!L(i))return"turn";let d=Z(n,e);return g(d,{recursive:!0}),l(f(d,i),`${JSON.stringify({tool_use_id:i,tool_name:u,tool_input:t.tool_input??null,at_ms:r})}
|
|
6
|
+
`),"tool"}return}function H(n,e,t,r){let s=A(t)?t:void 0,o=m(x(n,e)),i=p(o?.at_ms),u=p(o?.first_ms),d=p(m(b(n,e))?.at_ms),a=o!==void 0&&o.prompt_id===s&&i!==void 0&&u!==void 0&&(d===void 0||i>d);l(x(n,e),`${JSON.stringify({...s!==void 0?{prompt_id:s}:{},first_ms:a?u:r,at_ms:r})}
|
|
7
|
+
`)}function E(n,e,t){if(t.hook_event_name!=="Stop"||t.stop_hook_active===!0)return;if(v(t)!==!1)return;let r=O(n,e);if(r===void 0||r.length===0)return;let s=r.map((o)=>`"${o}"`).join(", ");return`The NATS channel ${r.length===1?"request":"requests"} ${s} ${r.length===1?"is":"are"} still open: the sender has not received an answer, and cannot see this session's own output. Send your answer with the reply tool (load it with ToolSearch if it is deferred), with the request_id and done: true.`}function I(n,e,t,r=Date.now()){let s=N(t);g(c(n),{recursive:!0}),l(h(n,e),`${JSON.stringify({...s!==void 0?{final_text:s}:{},at_ms:r})}
|
|
8
|
+
`)}function W(n,e){let t=m(h(n,e)),r=p(t?.at_ms);if(t===void 0||r===void 0)return;let s=p(m(b(n,e))?.at_ms);if(s!==void 0&&r<=s)return;let o=t.final_text;return typeof o==="string"&&o.length>0?o:void 0}function O(n,e){let t=m(z(n,e));if(!t)return;let{server_pid:r,request_ids:s}=t;if(typeof r!=="number"||!Number.isSafeInteger(r)||r<=0)return;if(!Array.isArray(s)||!s.every((o)=>typeof o==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(o)))return;if(!X(r))return;return s}function N(n){if("last_assistant_message"in n){let i=n.last_assistant_message;return typeof i==="string"&&i.trim().length>0?i.trim():void 0}let e=n.transcript_path;if(typeof e!=="string"||e.length===0)return;let t;try{t=w(e,"utf8")}catch{return}let r,s=[];for(let i of t.split(`
|
|
9
|
+
`)){if(i.trim().length===0)continue;let u;try{u=JSON.parse(i)}catch{continue}if(typeof u!=="object"||u===null)continue;let{type:d,message:a,uuid:T}=u;if(d!=="assistant"||typeof a!=="object"||a===null)continue;let{id:M,content:_}=a,y=M??T;if(y===void 0||y!==r)r=y,s=[];if(typeof _==="string")s.push(_);else if(Array.isArray(_))for(let P of _){let S=P;if(S?.type==="text"&&typeof S.text==="string")s.push(S.text)}}let o=s.join(`
|
|
10
|
+
`).trim();return o.length>0?o:void 0}function m(n){let e;try{e=w(n,"utf8")}catch{return}try{let t=JSON.parse(e);return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}}function p(n){return typeof n==="number"&&Number.isSafeInteger(n)&&n>=0?n:void 0}function Q(n){try{j(n,{recursive:!0,force:!0})}catch{}}function X(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var nn=5000;setTimeout(()=>process.exit(0),nn).unref();async function en(){let n=[];for await(let e of process.stdin)n.push(Buffer.from(e));return Buffer.concat(n).toString("utf8")}try{let n=process.env.CLAUDE_PID;if(n!==void 0&&/^\d+$/.test(n)){let e=JSON.parse(await en());if(typeof e==="object"&&e!==null&&!Array.isArray(e)){let t=process.env.NATS_STATE_DIR??Y(V(),".claude","channels","nats"),r=e,s=E(t,n,r);if(s!==void 0){try{I(t,n,r)}catch{}K(1,`${JSON.stringify({decision:"block",reason:s})}
|
|
11
|
+
`)}else R(t,n,r)}}}catch{}process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,58 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synadia-ai/agent-fabric-claude-code",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"require": "./dist/index.cjs",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
".claude-plugin",
|
|
21
|
-
"hooks",
|
|
22
|
-
"skills",
|
|
23
|
-
"README.md",
|
|
24
|
-
"CHANGELOG.md",
|
|
25
|
-
"LICENSE"
|
|
26
|
-
],
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=20.0.0"
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsup",
|
|
33
|
-
"build:sp": "sh ../scratchpad-skill/install.sh --dest skills/scratchpad --allowed-tools 'Bash(${CLAUDE_SKILL_DIR}/scripts/sp *)'",
|
|
34
|
-
"typecheck": "tsc --noEmit",
|
|
35
|
-
"lint": "eslint .",
|
|
36
|
-
"lint:fix": "eslint . --fix",
|
|
37
|
-
"format": "prettier --write .",
|
|
38
|
-
"format:check": "prettier --check .",
|
|
39
|
-
"test": "vitest run",
|
|
40
|
-
"test:unit": "vitest run test/unit",
|
|
41
|
-
"test:integration": "vitest run test/integration",
|
|
42
|
-
"test:watch": "vitest",
|
|
43
|
-
"check": "npm run typecheck && npm run lint && npm run format:check && npm run test",
|
|
44
|
-
"prepack": "npm run build:sp",
|
|
45
|
-
"prepublishOnly": "npm run build"
|
|
46
|
-
},
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Claude Code on the Synadia Agent Fabric: the NATS channel plugin for Claude Code with the fabric's tracing and ScratchPad, in one plugin",
|
|
47
5
|
"keywords": [
|
|
48
|
-
"nats",
|
|
49
|
-
"ai",
|
|
50
|
-
"agents",
|
|
51
|
-
"agent-fabric",
|
|
52
|
-
"tracing",
|
|
53
6
|
"claude-code",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
7
|
+
"claude-code-plugin",
|
|
8
|
+
"nats",
|
|
9
|
+
"agent",
|
|
10
|
+
"channel",
|
|
11
|
+
"synadia-agent-protocol",
|
|
12
|
+
"synadia-agent-fabric"
|
|
56
13
|
],
|
|
57
14
|
"license": "Apache-2.0",
|
|
58
15
|
"author": "Synadia Communications",
|
|
@@ -61,29 +18,23 @@
|
|
|
61
18
|
"url": "git+https://github.com/synadia-ai/agent-fabric-sdk.git",
|
|
62
19
|
"directory": "plugins/claude-code"
|
|
63
20
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./runtime/fabric.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./runtime/fabric.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
67
26
|
},
|
|
27
|
+
"files": [
|
|
28
|
+
".claude-plugin",
|
|
29
|
+
".mcp.json",
|
|
30
|
+
"runtime",
|
|
31
|
+
"hooks",
|
|
32
|
+
"skills",
|
|
33
|
+
"BUILD",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
68
37
|
"publishConfig": {
|
|
69
38
|
"access": "public"
|
|
70
|
-
},
|
|
71
|
-
"dependencies": {
|
|
72
|
-
"@synadia-ai/agent-fabric": "^0.1.0",
|
|
73
|
-
"@synadia-ai/agent-service": "^0.6.0",
|
|
74
|
-
"@synadia-ai/agents": "^0.6.0"
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"@nats-io/nats-core": "^3.4.0",
|
|
78
|
-
"@nats-io/transport-node": "^3.4.0",
|
|
79
|
-
"@types/node": "^20.16.0",
|
|
80
|
-
"ajv": "^8.17.0",
|
|
81
|
-
"eslint": "^9.0.0",
|
|
82
|
-
"eslint-config-prettier": "^9.1.0",
|
|
83
|
-
"prettier": "3.9.5",
|
|
84
|
-
"tsup": "^8.3.0",
|
|
85
|
-
"typescript": "~5.6.0",
|
|
86
|
-
"typescript-eslint": "^8.10.0",
|
|
87
|
-
"vitest": "^3.2.0"
|
|
88
39
|
}
|
|
89
40
|
}
|