@synapse-research/synapse 0.2.12 → 0.2.13
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/.next/BUILD_ID +1 -1
- package/dist/.next/app-build-manifest.json +113 -113
- package/dist/.next/app-path-routes-manifest.json +27 -27
- package/dist/.next/build-manifest.json +2 -2
- package/dist/.next/prerender-manifest.json +6 -6
- package/dist/.next/server/app/(dashboard)/agents/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/compute/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/project-groups/[uuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/activity/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/dashboard/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/documents/[documentUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/documents/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/[designUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-runs/[runUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-runs/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiments/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiments/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/insights/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/related-works/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/research-questions/[questionUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/research-questions/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/settings/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/server/app/admin/companies/[uuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies/new.html +1 -1
- package/dist/.next/server/app/admin/companies/new.rsc +1 -1
- package/dist/.next/server/app/admin/companies/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies.html +1 -1
- package/dist/.next/server/app/admin/companies.rsc +1 -1
- package/dist/.next/server/app/admin/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin.html +1 -1
- package/dist/.next/server/app/admin.rsc +1 -1
- package/dist/.next/server/app/api/admin/companies/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/companies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/login/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/session/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/stats/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/[uuid]/sessions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/api-keys/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/api-keys/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/callback/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/check-default/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/default-login/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/identify/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/me/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/refresh/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/session/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/sync-token/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/comments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-gpus/[uuid]/release/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-nodes/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-nodes/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-pools/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-pools/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/documents/[uuid]/images/[filename]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/documents/[uuid]/images/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/documents/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/events/notifications/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/approve/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/close/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/reject/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/claim/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/dependencies/[dependsOnRunUuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/dependencies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/evaluate-criteria/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/registry/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/release/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/sessions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/progress/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/request-plan/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/reset/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/review/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/start/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/mcp/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/me/assignments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/mentionables/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/[uuid]/archive/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/[uuid]/read/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/preferences/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/read-all/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/unread-count/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/onboarding/status/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/[uuid]/dashboard/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/activity/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/agent-activity/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/available/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/baselines/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/documents/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/[designUuid]/validate/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/summary/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-runs/dependencies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-runs/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/github/branches/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/group/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/[workUuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/auto-search/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/auto-search/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/deep-research/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/deep-research/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/research-questions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/synthesis/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/synthesis/refresh/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/synthesis/trigger/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/claim/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/move/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/release/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/review/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/sessions/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/settings/integrations/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/ssh-config/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.rsc +1 -1
- package/dist/.next/server/app/login/admin/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/admin.html +1 -1
- package/dist/.next/server/app/login/admin.rsc +1 -1
- package/dist/.next/server/app/login/callback/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/callback.html +1 -1
- package/dist/.next/server/app/login/callback.rsc +1 -1
- package/dist/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/silent-refresh/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/silent-refresh.html +1 -1
- package/dist/.next/server/app/login/silent-refresh.rsc +1 -1
- package/dist/.next/server/app/login.html +1 -1
- package/dist/.next/server/app/login.rsc +1 -1
- package/dist/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/research-projects/new.html +1 -1
- package/dist/.next/server/app/research-projects/new.rsc +1 -1
- package/dist/.next/server/app/research-projects.html +1 -1
- package/dist/.next/server/app/research-projects.rsc +1 -1
- package/dist/.next/server/app/settings.html +1 -1
- package/dist/.next/server/app/settings.rsc +1 -1
- package/dist/.next/server/app-paths-manifest.json +27 -27
- package/dist/.next/server/middleware-manifest.json +1 -1
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/pages-manifest.json +1 -1
- package/package.json +4 -2
- package/dist/public/skill/SKILL.md +0 -200
- package/dist/public/skill/aris-synapse-sync/SKILL.md +0 -368
- package/dist/public/skill/package.json +0 -79
- package/dist/public/skill/references/00-common-tools.md +0 -253
- package/dist/public/skill/references/01-setup.md +0 -251
- package/dist/public/skill/references/02-pm-workflow.md +0 -584
- package/dist/public/skill/references/03-developer-workflow.md +0 -325
- package/dist/public/skill/references/04-admin-workflow.md +0 -328
- package/dist/public/skill/references/06-claude-code-agent-teams.md +0 -233
- package/dist/public/synapse-plugin/.claude-plugin/plugin.json +0 -20
- package/dist/public/synapse-plugin/.mcp.json +0 -11
- package/dist/public/synapse-plugin/bin/on-post-create-experiment.sh +0 -61
- package/dist/public/synapse-plugin/bin/on-post-submit-results.sh +0 -56
- package/dist/public/synapse-plugin/bin/on-pre-enter-plan.sh +0 -26
- package/dist/public/synapse-plugin/bin/on-pre-exit-plan.sh +0 -22
- package/dist/public/synapse-plugin/bin/on-pre-spawn-agent.sh +0 -64
- package/dist/public/synapse-plugin/bin/on-session-end.sh +0 -39
- package/dist/public/synapse-plugin/bin/on-session-start.sh +0 -284
- package/dist/public/synapse-plugin/bin/on-subagent-start.sh +0 -233
- package/dist/public/synapse-plugin/bin/on-subagent-stop.sh +0 -80
- package/dist/public/synapse-plugin/bin/on-task-completed.sh +0 -66
- package/dist/public/synapse-plugin/bin/on-teammate-idle.sh +0 -47
- package/dist/public/synapse-plugin/bin/on-user-prompt.sh +0 -57
- package/dist/public/synapse-plugin/bin/synapse-api.sh +0 -387
- package/dist/public/synapse-plugin/bin/test-syntax.sh +0 -85
- package/dist/public/synapse-plugin/hooks/hooks.json +0 -125
- package/dist/public/synapse-plugin/skills/autonomy/SKILL.md +0 -177
- package/dist/public/synapse-plugin/skills/experiments/SKILL.md +0 -135
- package/dist/public/synapse-plugin/skills/research/SKILL.md +0 -58
- package/dist/public/synapse-plugin/skills/sessions/SKILL.md +0 -176
- package/dist/public/synapse-plugin/skills/setup/SKILL.md +0 -108
- package/dist/public/synapse-plugin/skills/synapse/SKILL.md +0 -145
- package/dist/public/synapse-plugin/skills/synapse/package.json +0 -49
- package/dist/public/synapse-plugin/skills/synapse/references/00-common-tools.md +0 -144
- package/dist/public/synapse-plugin/skills/synapse/references/01-setup.md +0 -130
- package/dist/public/synapse-plugin/skills/synapse/references/02-research-workflow.md +0 -145
- package/dist/public/synapse-plugin/skills/synapse/references/03-experiment-workflow.md +0 -319
- package/dist/public/synapse-plugin/skills/synapse/references/04-autonomous-loop.md +0 -223
- package/dist/public/synapse-plugin/skills/synapse/references/05-session-sub-agent.md +0 -253
- /package/dist/.next/static/{CTg26EE4IkxbdY0E6xEiL → VlyiqgSt6DSLuCX7rlcKa}/_buildManifest.js +0 -0
- /package/dist/.next/static/{CTg26EE4IkxbdY0E6xEiL → VlyiqgSt6DSLuCX7rlcKa}/_ssgManifest.js +0 -0
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
# Claude Code Agent Teams + Synapse Integration
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This guide explains how to run **Claude Code Agent Teams** (swarm mode) with Synapse for full work observability. In this setup, a Team Lead agent orchestrates multiple sub-agents, each working on Synapse tasks in parallel.
|
|
6
|
-
|
|
7
|
-
### Two-Layer Architecture
|
|
8
|
-
|
|
9
|
-
Claude Code Agent Teams and Synapse serve different purposes:
|
|
10
|
-
|
|
11
|
-
| Layer | System | Purpose |
|
|
12
|
-
|-------|--------|---------|
|
|
13
|
-
| **Orchestration** | Claude Code Agent Teams | Spawning sub-agents, internal task dispatch, inter-agent messaging |
|
|
14
|
-
| **Work Tracking** | Synapse | Task lifecycle (claim → in_progress → to_verify → done), activity stream |
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
┌─────────────────────────────────────────────────────────┐
|
|
18
|
-
│ Claude Code Agent Teams (Orchestration) │
|
|
19
|
-
│ │
|
|
20
|
-
│ Team Lead ──spawn──> Sub-Agent A ──spawn──> Sub-Agent B│
|
|
21
|
-
│ │ │ │ │
|
|
22
|
-
│ TeamCreate Task tool Task tool │
|
|
23
|
-
│ TaskCreate SendMessage SendMessage│
|
|
24
|
-
│ TaskList/Update │
|
|
25
|
-
└───────┬──────────────────┬──────────────────────┬───────┘
|
|
26
|
-
│ │ │
|
|
27
|
-
▼ ▼ ▼
|
|
28
|
-
┌─────────────────────────────────────────────────────────┐
|
|
29
|
-
│ Synapse (Work Tracking & Observability) │
|
|
30
|
-
│ │
|
|
31
|
-
│ Task A ← Sub-Agent A Task B ← Sub-Agent B │
|
|
32
|
-
│ ├─ update_task(in_progress) ├─ update_task │
|
|
33
|
-
│ ├─ report_work ├─ report_work │
|
|
34
|
-
│ └─ submit_for_verify └─ submit_for_verify │
|
|
35
|
-
│ │
|
|
36
|
-
│ UI: Kanban board, Task Detail, Activity stream │
|
|
37
|
-
└─────────────────────────────────────────────────────────┘
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## MCP Access for Sub-Agents
|
|
43
|
-
|
|
44
|
-
Sub-agents spawned via Claude Code's `Task` tool can access Synapse MCP tools **if the MCP server is configured at the project level** (in `.claude/settings.json` or `.mcp.json`). This is the recommended setup.
|
|
45
|
-
|
|
46
|
-
If MCP is configured at the user level (`~/.claude/settings.json`), sub-agents may not have access. In that case, move the Synapse MCP config to the project level:
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
// .mcp.json (project root)
|
|
50
|
-
{
|
|
51
|
-
"mcpServers": {
|
|
52
|
-
"synapse": {
|
|
53
|
-
"type": "streamable-http",
|
|
54
|
-
"url": "<BASE_URL>/api/mcp",
|
|
55
|
-
"headers": {
|
|
56
|
-
"Authorization": "Bearer syn_xxxxxxxxxxxx"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Complete Workflow
|
|
66
|
-
|
|
67
|
-
### Phase 1: Team Lead — Plan & Prepare
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
# 1. Check in to Synapse
|
|
71
|
-
synapse_checkin()
|
|
72
|
-
|
|
73
|
-
# 2. Understand the project and available tasks
|
|
74
|
-
synapse_get_project({ projectUuid: "<project-uuid>" })
|
|
75
|
-
synapse_list_tasks({ projectUuid: "<project-uuid>", status: "assigned" })
|
|
76
|
-
|
|
77
|
-
# 3. Read task details to plan work distribution
|
|
78
|
-
synapse_get_task({ taskUuid: "<task-A-uuid>" })
|
|
79
|
-
synapse_get_task({ taskUuid: "<task-B-uuid>" })
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Phase 2: Team Lead — Create Claude Code Team & Spawn Sub-Agents
|
|
83
|
-
|
|
84
|
-
Pass Synapse task UUIDs in the prompt to each sub-agent.
|
|
85
|
-
|
|
86
|
-
```python
|
|
87
|
-
# 1. Create a Claude Code team
|
|
88
|
-
TeamCreate({ team_name: "feature-x", description: "Implementing feature X" })
|
|
89
|
-
|
|
90
|
-
# 2. Create internal tasks for tracking
|
|
91
|
-
TaskCreate({ subject: "Frontend: build user form", description: "synapse:task:<task-A-uuid>" })
|
|
92
|
-
TaskCreate({ subject: "Backend: create API endpoints", description: "synapse:task:<task-B-uuid>" })
|
|
93
|
-
|
|
94
|
-
# 3. Spawn sub-agents — pass task UUIDs in the prompt
|
|
95
|
-
Task({
|
|
96
|
-
subagent_type: "general-purpose",
|
|
97
|
-
team_name: "feature-x",
|
|
98
|
-
name: "frontend-worker",
|
|
99
|
-
prompt: """
|
|
100
|
-
You are a Developer Agent working with Synapse.
|
|
101
|
-
|
|
102
|
-
Your Synapse task UUID: task-A-uuid
|
|
103
|
-
Project UUID: project-uuid
|
|
104
|
-
|
|
105
|
-
Synapse workflow (do this FIRST before any coding):
|
|
106
|
-
1. synapse_update_task({ taskUuid: "task-A-uuid", status: "in_progress" })
|
|
107
|
-
|
|
108
|
-
Then implement the frontend user form component...
|
|
109
|
-
|
|
110
|
-
When done:
|
|
111
|
-
2. synapse_report_work({ taskUuid: "task-A-uuid", report: "..." })
|
|
112
|
-
3. synapse_submit_for_verify({ taskUuid: "task-A-uuid", summary: "..." })
|
|
113
|
-
"""
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Phase 3: Sub-Agent — Execute Work
|
|
118
|
-
|
|
119
|
-
Each sub-agent follows this sequence autonomously:
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
# === Synapse Setup (FIRST, before any coding) ===
|
|
123
|
-
|
|
124
|
-
# 1. Move task to in_progress
|
|
125
|
-
synapse_update_task({
|
|
126
|
-
taskUuid: "<my-task-uuid>",
|
|
127
|
-
status: "in_progress"
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
# === Do the actual work (coding, testing, etc.) ===
|
|
131
|
-
# ...write code, run tests, create commits...
|
|
132
|
-
|
|
133
|
-
# === Progress reporting (periodically during work) ===
|
|
134
|
-
|
|
135
|
-
# 2. Report progress
|
|
136
|
-
synapse_report_work({
|
|
137
|
-
taskUuid: "<my-task-uuid>",
|
|
138
|
-
report: "Completed user form component.\n- Files: src/components/UserForm.tsx\n- Commit: abc123"
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
# === Completion ===
|
|
142
|
-
|
|
143
|
-
# 3. Submit for verification
|
|
144
|
-
synapse_submit_for_verify({
|
|
145
|
-
taskUuid: "<my-task-uuid>",
|
|
146
|
-
summary: "Implemented user form with validation.\nFiles: ...\nAll tests passing."
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
# 4. Notify team lead via Claude Code messaging
|
|
150
|
-
SendMessage({ type: "message", recipient: "team-lead", content: "Task complete", summary: "Frontend task done" })
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Phase 4: Team Lead — Verify, Unblock & Close
|
|
154
|
-
|
|
155
|
-
The Team Lead monitors until all Synapse tasks reach `to_verify` or `done`. **Task verification (to_verify → done) is an Admin responsibility** — if you have admin role, verify tasks promptly to unblock downstream dependencies. `to_verify` does NOT resolve dependencies — only `done` does.
|
|
156
|
-
|
|
157
|
-
> **Note:** If you are using the Synapse Plugin for Claude Code, the TaskCompleted hook will automatically remind you each time a sub-agent finishes — showing the task's acceptance criteria status and any blocked downstream tasks.
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
# 1. Periodically check Synapse task status
|
|
161
|
-
synapse_list_tasks({ projectUuid: "<project-uuid>" })
|
|
162
|
-
|
|
163
|
-
# 2. Clean up Claude Code team
|
|
164
|
-
# Send shutdown requests to sub-agents, then TeamDelete
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Handling Task Dependencies (DAG)
|
|
170
|
-
|
|
171
|
-
When Synapse tasks have dependencies (Task B depends on Task A), the Team Lead must coordinate the execution order.
|
|
172
|
-
|
|
173
|
-
> **Server-side enforcement**: `synapse_update_task(status: "in_progress")` will automatically reject if any `dependsOn` task is not `done` or `closed`. The error includes detailed blocker info (title, status, assignee). Sub-agents do NOT need to manually poll dependency status — the server enforces it.
|
|
174
|
-
|
|
175
|
-
**Recommended: Wave-based sequential spawning**
|
|
176
|
-
- Use `synapse_get_unblocked_tasks` to find tasks ready to start (all deps resolved)
|
|
177
|
-
- Spawn sub-agents only for unblocked tasks (Wave 1)
|
|
178
|
-
- When Wave 1 tasks complete, check for newly unblocked tasks (Wave 2)
|
|
179
|
-
- Repeat until all tasks are done
|
|
180
|
-
|
|
181
|
-
**Alternative: Spawn all, server rejects blocked ones**
|
|
182
|
-
- Spawn all sub-agents immediately
|
|
183
|
-
- Sub-agents that try to move blocked tasks to `in_progress` will receive a clear error with blocker details
|
|
184
|
-
- Those sub-agents can then use `synapse_get_unblocked_tasks` to find other work, or wait and retry
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Multiple Tasks Per Sub-Agent
|
|
189
|
-
|
|
190
|
-
A single sub-agent can work on multiple Synapse tasks sequentially. The Team Lead passes multiple task UUIDs, and the sub-agent processes them in order:
|
|
191
|
-
|
|
192
|
-
```python
|
|
193
|
-
Task({
|
|
194
|
-
name: "full-stack-worker",
|
|
195
|
-
prompt: """
|
|
196
|
-
Your Synapse tasks (work in order):
|
|
197
|
-
1. task-schema-uuid — Create database schema
|
|
198
|
-
2. task-api-uuid — Implement API endpoints (depends on #1)
|
|
199
|
-
3. task-tests-uuid — Write integration tests (depends on #2)
|
|
200
|
-
|
|
201
|
-
For EACH task:
|
|
202
|
-
- synapse_update_task(in_progress) → work → synapse_report_work → synapse_submit_for_verify
|
|
203
|
-
"""
|
|
204
|
-
})
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Troubleshooting
|
|
210
|
-
|
|
211
|
-
### Sub-agent can't access Synapse MCP tools
|
|
212
|
-
- Verify MCP is configured at project level (`.mcp.json` or `.claude/settings.json`), not just user level
|
|
213
|
-
- Verify the API key in the MCP config has `developer_agent` role
|
|
214
|
-
|
|
215
|
-
### Task stuck in wrong status
|
|
216
|
-
- If a sub-agent crashed before completing, the task may be stuck in `in_progress`
|
|
217
|
-
- Team Lead can spawn a new sub-agent to continue, or use `synapse_update_task` to reset status
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
|
-
## Quick Reference
|
|
222
|
-
|
|
223
|
-
| Step | Who | Claude Code Tool | Synapse Tool |
|
|
224
|
-
|------|-----|-----------------|-------------|
|
|
225
|
-
| Plan work | Team Lead | — | `synapse_checkin`, `synapse_list_tasks` |
|
|
226
|
-
| Create team | Team Lead | `TeamCreate` | — |
|
|
227
|
-
| Spawn workers | Team Lead | `Task` (with task UUIDs in prompt) | — |
|
|
228
|
-
| Start work | Sub-Agent | — | `synapse_update_task(in_progress)` |
|
|
229
|
-
| Report progress | Sub-Agent | — | `synapse_report_work` |
|
|
230
|
-
| Complete task | Sub-Agent | — | `synapse_submit_for_verify` |
|
|
231
|
-
| Notify lead | Sub-Agent | `SendMessage` | — |
|
|
232
|
-
| Monitor | Team Lead | `TaskList` | `synapse_list_tasks` |
|
|
233
|
-
| Shutdown | Team Lead | `SendMessage(shutdown_request)` + `TeamDelete` | — |
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "synapse",
|
|
3
|
-
"description": "Synapse research orchestration plugin for Claude Code. Connects AI agents to Synapse for experiment execution, literature search, progress reporting, and autonomous research loops.",
|
|
4
|
-
"version": "0.8.0",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Vincentwei1021"
|
|
7
|
-
},
|
|
8
|
-
"homepage": "https://github.com/Vincentwei1021/Synapse",
|
|
9
|
-
"repository": "https://github.com/Vincentwei1021/Synapse",
|
|
10
|
-
"license": "AGPL-3.0",
|
|
11
|
-
"keywords": [
|
|
12
|
-
"synapse",
|
|
13
|
-
"research",
|
|
14
|
-
"orchestration",
|
|
15
|
-
"mcp",
|
|
16
|
-
"experiments",
|
|
17
|
-
"ai-agents",
|
|
18
|
-
"literature-search"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-post-create-experiment.sh — PostToolUse hook for synapse_create_experiment
|
|
3
|
-
# Triggered immediately after the agent creates an experiment.
|
|
4
|
-
# Reminds the main agent that the next step is a sub-agent self-review
|
|
5
|
-
# before the experiment is pushed to pending_review.
|
|
6
|
-
#
|
|
7
|
-
# Output: JSON with additionalContext (LLM-visible) + systemMessage (user toast)
|
|
8
|
-
|
|
9
|
-
set -euo pipefail
|
|
10
|
-
|
|
11
|
-
[ -z "${SYNAPSE_URL:-}" ] && exit 0
|
|
12
|
-
|
|
13
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
14
|
-
API="${SCRIPT_DIR}/synapse-api.sh"
|
|
15
|
-
|
|
16
|
-
EVENT=""
|
|
17
|
-
if [ ! -t 0 ]; then
|
|
18
|
-
EVENT=$(cat)
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
if [ -z "$EVENT" ]; then
|
|
22
|
-
exit 0
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
TOOL_NAME=$(echo "$EVENT" | jq -r '.tool_name // .toolName // empty' 2>/dev/null) || true
|
|
26
|
-
case "$TOOL_NAME" in
|
|
27
|
-
*synapse_create_experiment) ;;
|
|
28
|
-
*) exit 0 ;;
|
|
29
|
-
esac
|
|
30
|
-
|
|
31
|
-
# Try to extract the new experiment UUID from the tool response.
|
|
32
|
-
EXPERIMENT_UUID=$(echo "$EVENT" \
|
|
33
|
-
| jq -r '.tool_response.experiment.uuid // .tool_response.uuid // .response.experiment.uuid // empty' 2>/dev/null) || true
|
|
34
|
-
|
|
35
|
-
if [ -z "$EXPERIMENT_UUID" ]; then
|
|
36
|
-
EXPERIMENT_UUID=$(echo "$EVENT" \
|
|
37
|
-
| jq -r '.tool_response.content[0].text // empty' 2>/dev/null \
|
|
38
|
-
| jq -r '.experiment.uuid // .uuid // empty' 2>/dev/null) || true
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
if [ -n "$EXPERIMENT_UUID" ]; then
|
|
42
|
-
CONTEXT="[Synapse Plugin — Required next step after creating an experiment]
|
|
43
|
-
You just created experiment ${EXPERIMENT_UUID}. It is in 'draft'.
|
|
44
|
-
DO NOT push it to pending_review yet. First, spawn a sub-agent via the Task tool to self-review this draft. The sub-agent should call synapse_get_experiment, then evaluate:
|
|
45
|
-
- Is the objective specific and measurable?
|
|
46
|
-
- Is the methodology sound and reproducible?
|
|
47
|
-
- Are the success criteria aligned with the project's evaluationMethods?
|
|
48
|
-
- Is the compute budget realistic given current availability?
|
|
49
|
-
The sub-agent returns its verdict to you in-session — it does NOT write to Synapse.
|
|
50
|
-
Apply revisions with synapse_update_experiment_plan if needed.
|
|
51
|
-
Then call synapse_update_experiment_status({ experimentUuid: \"${EXPERIMENT_UUID}\", status: \"pending_review\" }) and present the self-review summary plus plan summary to the user.
|
|
52
|
-
Wait for the user's verbal approve / reject. On approve, call synapse_review_experiment with reviewNote quoting the user's words. On reject, summarize the user's revision request (including a quoted phrase) into reviewNote and call synapse_review_experiment with decision \"rejected\" — do NOT also call synapse_add_comment, the review tool writes the comment for you.
|
|
53
|
-
If the autonomy skill has marked this session as full_auto, skip the user gate and call synapse_review_experiment directly with reviewNote: 'Full-auto session authorized by <ownerName> at <ISO time>. Self-review pass: <key points>.'"
|
|
54
|
-
USER_MSG="Synapse: experiment ${EXPERIMENT_UUID:0:8} drafted — run self-review next"
|
|
55
|
-
else
|
|
56
|
-
CONTEXT="[Synapse Plugin — Required next step after creating an experiment]
|
|
57
|
-
You just created an experiment in 'draft'. Spawn a Task sub-agent to self-review the plan, revise via synapse_update_experiment_plan if needed, then push it to pending_review with synapse_update_experiment_status. After that, present the self-review summary to the user and wait for verbal approve / reject. Approvals call synapse_review_experiment with the user's quoted words in reviewNote; rejections summarize the user's revision request into reviewNote (the review tool writes the comment automatically — do not double-write)."
|
|
58
|
-
USER_MSG="Synapse: experiment drafted — run self-review next"
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
"$API" hook-output "$USER_MSG" "$CONTEXT" "PostToolUse"
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-post-submit-results.sh — PostToolUse hook for synapse_submit_experiment_results
|
|
3
|
-
# Triggered immediately after the agent submits experiment results.
|
|
4
|
-
# Injects a hard reminder that the agent MUST now call synapse_save_experiment_report
|
|
5
|
-
# to write the markdown experiment report. Runs while the agent is still alive,
|
|
6
|
-
# so it can act on the reminder in its very next turn.
|
|
7
|
-
#
|
|
8
|
-
# Output: JSON with additionalContext (LLM-visible) + systemMessage (user toast)
|
|
9
|
-
|
|
10
|
-
set -euo pipefail
|
|
11
|
-
|
|
12
|
-
[ -z "${SYNAPSE_URL:-}" ] && exit 0
|
|
13
|
-
|
|
14
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
15
|
-
API="${SCRIPT_DIR}/synapse-api.sh"
|
|
16
|
-
|
|
17
|
-
# Read event JSON from stdin
|
|
18
|
-
EVENT=""
|
|
19
|
-
if [ ! -t 0 ]; then
|
|
20
|
-
EVENT=$(cat)
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
if [ -z "$EVENT" ]; then
|
|
24
|
-
exit 0
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
# Only act on the submit-results tool. Tool names from CC arrive in either
|
|
28
|
-
# the bare form ("synapse_submit_experiment_results") or the MCP-prefixed form
|
|
29
|
-
# ("mcp__synapse__synapse_submit_experiment_results") depending on transport.
|
|
30
|
-
TOOL_NAME=$(echo "$EVENT" | jq -r '.tool_name // .toolName // empty' 2>/dev/null) || true
|
|
31
|
-
case "$TOOL_NAME" in
|
|
32
|
-
*synapse_submit_experiment_results) ;;
|
|
33
|
-
*) exit 0 ;;
|
|
34
|
-
esac
|
|
35
|
-
|
|
36
|
-
# Pull the experiment UUID out of the tool input so the reminder can be specific.
|
|
37
|
-
EXPERIMENT_UUID=$(echo "$EVENT" \
|
|
38
|
-
| jq -r '.tool_input.experimentUuid // .input.experimentUuid // empty' 2>/dev/null) || true
|
|
39
|
-
|
|
40
|
-
# Pull the outcome too — used only for phrasing.
|
|
41
|
-
OUTCOME=$(echo "$EVENT" \
|
|
42
|
-
| jq -r '.tool_input.outcome // .input.outcome // empty' 2>/dev/null) || true
|
|
43
|
-
|
|
44
|
-
if [ -n "$EXPERIMENT_UUID" ]; then
|
|
45
|
-
CONTEXT="[Synapse Plugin — Required next step after submitting results]
|
|
46
|
-
You just called synapse_submit_experiment_results for experiment ${EXPERIMENT_UUID}${OUTCOME:+ (outcome=${OUTCOME})}.
|
|
47
|
-
You MUST now immediately call synapse_save_experiment_report({ experimentUuid: \"${EXPERIMENT_UUID}\", title, content }) with a full markdown writeup (objective, methodology, results, analysis, charts where useful).
|
|
48
|
-
This is required for success, failure, and inconclusive outcomes alike. Do not finish the task, hand off, or move on until the report has been saved. Do not post the writeup as a comment — use synapse_save_experiment_report."
|
|
49
|
-
USER_MSG="Synapse: results submitted for ${EXPERIMENT_UUID:0:8} — now save the experiment report"
|
|
50
|
-
else
|
|
51
|
-
CONTEXT="[Synapse Plugin — Required next step after submitting results]
|
|
52
|
-
You just called synapse_submit_experiment_results. You MUST now immediately call synapse_save_experiment_report({ experimentUuid, title, content }) with a full markdown writeup (objective, methodology, results, analysis). This is required for every outcome — success, failure, and inconclusive. Do not finish the task or move on until the report has been saved."
|
|
53
|
-
USER_MSG="Synapse: results submitted — now save the experiment report"
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
"$API" hook-output "$USER_MSG" "$CONTEXT" "PostToolUse"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-pre-enter-plan.sh — PreToolUse hook for EnterPlanMode
|
|
3
|
-
# Injects guidance for the current ResearchQuestion -> Experiment workflow.
|
|
4
|
-
#
|
|
5
|
-
# Output: JSON with additionalContext
|
|
6
|
-
|
|
7
|
-
set -euo pipefail
|
|
8
|
-
|
|
9
|
-
[ -z "${SYNAPSE_URL:-}" ] && exit 0
|
|
10
|
-
|
|
11
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
-
API="${SCRIPT_DIR}/synapse-api.sh"
|
|
13
|
-
|
|
14
|
-
CONTEXT="[Synapse Planning Workflow]
|
|
15
|
-
When planning implementation, follow the current Synapse research lifecycle:
|
|
16
|
-
1. Identify the Research Project and, if needed, the relevant Research Question
|
|
17
|
-
2. Create or refine Experiment records directly for the work that should be executed
|
|
18
|
-
3. Break work into clear Experiment units with title, description, compute needs, and expected outcome
|
|
19
|
-
4. Keep new work in the Experiment pipeline (`draft` -> `pending_review` -> `pending_start` -> `in_progress` -> `completed`)
|
|
20
|
-
5. Do NOT route new work through Experiment Design or Experiment Run unless you are intentionally handling legacy compatibility surfaces
|
|
21
|
-
|
|
22
|
-
When planning sub-agent work distribution:
|
|
23
|
-
- The Synapse Plugin auto-manages session lifecycle — do NOT plan to create sessions manually.
|
|
24
|
-
- Plan which Synapse experiment UUIDs each sub-agent should execute — that is what the prompt should pass."
|
|
25
|
-
|
|
26
|
-
"$API" hook-output "Synapse: plan mode — use the Experiment workflow" "$CONTEXT" "PreToolUse"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-pre-exit-plan.sh — PreToolUse hook for ExitPlanMode
|
|
3
|
-
# Reminds the agent to exit planning with Experiment records, not legacy drafts.
|
|
4
|
-
#
|
|
5
|
-
# Output: JSON with additionalContext
|
|
6
|
-
|
|
7
|
-
set -euo pipefail
|
|
8
|
-
|
|
9
|
-
[ -z "${SYNAPSE_URL:-}" ] && exit 0
|
|
10
|
-
|
|
11
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
-
API="${SCRIPT_DIR}/synapse-api.sh"
|
|
13
|
-
|
|
14
|
-
CONTEXT="[Synapse Pre-Implementation Check]
|
|
15
|
-
Before exiting plan mode, ensure:
|
|
16
|
-
1. The work is represented as one or more current Synapse Experiments
|
|
17
|
-
2. Each Experiment has enough detail to execute without relying on legacy Experiment Design drafts
|
|
18
|
-
3. New human-created execution work is ready for the modern Experiment pipeline (usually `pending_start`, unless you intentionally keep it as `draft`)
|
|
19
|
-
4. Any sub-agent plan names the Experiment UUID each worker should execute
|
|
20
|
-
If no Experiment exists yet, create or propose one before implementing."
|
|
21
|
-
|
|
22
|
-
"$API" hook-output "" "$CONTEXT" "PreToolUse"
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-pre-spawn-agent.sh — PreToolUse hook for Task (spawning sub-agents)
|
|
3
|
-
# 1. Captures agent name + type from tool_input and writes a per-agent pending file
|
|
4
|
-
# (SubagentStart will claim this file atomically via mv)
|
|
5
|
-
# 2. Reminds Team Lead to pass Synapse experiment UUIDs to sub-agents.
|
|
6
|
-
#
|
|
7
|
-
# Concurrency safety: Each PreToolUse writes a separate file under .synapse/pending/
|
|
8
|
-
# so parallel spawns never contend on a shared file. SubagentStart claims files
|
|
9
|
-
# atomically with mv (only one process can successfully mv a given file).
|
|
10
|
-
#
|
|
11
|
-
# Output: JSON with additionalContext
|
|
12
|
-
|
|
13
|
-
set -euo pipefail
|
|
14
|
-
|
|
15
|
-
[ -z "${SYNAPSE_URL:-}" ] && exit 0
|
|
16
|
-
|
|
17
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
18
|
-
API="${SCRIPT_DIR}/synapse-api.sh"
|
|
19
|
-
|
|
20
|
-
# Read event from stdin to check agent type
|
|
21
|
-
EVENT=""
|
|
22
|
-
if [ ! -t 0 ]; then
|
|
23
|
-
EVENT=$(cat)
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
# Try to extract subagent_type and name from the tool input
|
|
27
|
-
AGENT_TYPE=""
|
|
28
|
-
AGENT_NAME=""
|
|
29
|
-
if [ -n "$EVENT" ]; then
|
|
30
|
-
AGENT_TYPE=$(echo "$EVENT" | jq -r '.tool_input.subagent_type // .input.subagent_type // empty' 2>/dev/null) || true
|
|
31
|
-
AGENT_NAME=$(echo "$EVENT" | jq -r '.tool_input.name // .input.name // empty' 2>/dev/null) || true
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
# Skip non-worker types — no need to remind for Explore/Plan agents
|
|
35
|
-
case "$(printf '%s' "$AGENT_TYPE" | tr '[:upper:]' '[:lower:]')" in
|
|
36
|
-
explore|plan|haiku|claude-code-guide|statusline-setup)
|
|
37
|
-
exit 0
|
|
38
|
-
;;
|
|
39
|
-
esac
|
|
40
|
-
|
|
41
|
-
# Write a per-agent pending file for SubagentStart to claim.
|
|
42
|
-
# SubagentStart only receives agent_id + agent_type — not the name.
|
|
43
|
-
# CC sometimes uses the agent name as agent_type, so we store both.
|
|
44
|
-
#
|
|
45
|
-
# Each spawn gets its own file — no shared state, no concurrency issues.
|
|
46
|
-
# File name is the agent name (or a unique fallback if name is empty).
|
|
47
|
-
# SubagentStart claims by mv (atomic on same filesystem).
|
|
48
|
-
#
|
|
49
|
-
# CC may internally spawn cleanup agents that bypass PreToolUse:Task —
|
|
50
|
-
# SubagentStart skips those if no pending file matches.
|
|
51
|
-
PENDING_DIR="${CLAUDE_PROJECT_DIR:-.}/.synapse/pending"
|
|
52
|
-
mkdir -p "$PENDING_DIR"
|
|
53
|
-
|
|
54
|
-
# Use agent name as filename; fall back to timestamp-based unique name
|
|
55
|
-
PENDING_NAME="${AGENT_NAME:-unknown-$(date +%s%N)}"
|
|
56
|
-
printf '{"name":"%s","type":"%s","ts":"%s"}\n' \
|
|
57
|
-
"${AGENT_NAME:-}" "${AGENT_TYPE:-}" "$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)" \
|
|
58
|
-
> "${PENDING_DIR}/${PENDING_NAME}"
|
|
59
|
-
|
|
60
|
-
CONTEXT="[Synapse Plugin — Sub-agent Spawn]
|
|
61
|
-
Session auto-managed by plugin. Do NOT call synapse_create_session.
|
|
62
|
-
Pass the Synapse experiment UUID in the sub-agent prompt. Current Experiment workflow instructions will be auto-injected by the SubagentStart hook."
|
|
63
|
-
|
|
64
|
-
"$API" hook-output "" "$CONTEXT" "PreToolUse"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# on-session-end.sh — SessionEnd hook
|
|
3
|
-
# Fires when Claude Code session ends.
|
|
4
|
-
# Cleans up the .synapse/ directory if all sessions are closed and state is empty.
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
STATE_DIR="${CLAUDE_PROJECT_DIR:-.}/.synapse"
|
|
9
|
-
|
|
10
|
-
# Nothing to clean up
|
|
11
|
-
if [ ! -d "$STATE_DIR" ]; then
|
|
12
|
-
exit 0
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
# Safety check: don't delete if there are still active session files
|
|
16
|
-
SESSIONS_DIR="${STATE_DIR}/sessions"
|
|
17
|
-
if [ -d "$SESSIONS_DIR" ]; then
|
|
18
|
-
REMAINING=0
|
|
19
|
-
for f in "$SESSIONS_DIR"/*.json; do
|
|
20
|
-
[ -f "$f" ] || continue
|
|
21
|
-
REMAINING=$((REMAINING + 1))
|
|
22
|
-
done
|
|
23
|
-
if [ "$REMAINING" -gt 0 ]; then
|
|
24
|
-
exit 0
|
|
25
|
-
fi
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
# Safety check: don't delete if state.json has meaningful content
|
|
29
|
-
if [ -f "${STATE_DIR}/state.json" ]; then
|
|
30
|
-
if command -v jq &>/dev/null; then
|
|
31
|
-
KEY_COUNT=$(jq 'length' "${STATE_DIR}/state.json" 2>/dev/null) || KEY_COUNT=0
|
|
32
|
-
if [ "$KEY_COUNT" -gt 0 ]; then
|
|
33
|
-
exit 0
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# All clear — remove .synapse/ directory
|
|
39
|
-
rm -rf "$STATE_DIR"
|