macro-agent 0.1.11 → 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/dist/agent/agent-manager-v2.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.js +240 -7
- package/dist/agent/agent-manager-v2.js.map +1 -1
- package/dist/agent/types.d.ts +47 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/boot-v2.d.ts +33 -0
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +142 -11
- package/dist/boot-v2.js.map +1 -1
- package/dist/cli/inbox-mcp-proxy.d.ts +36 -0
- package/dist/cli/inbox-mcp-proxy.d.ts.map +1 -0
- package/dist/cli/inbox-mcp-proxy.js +51 -0
- package/dist/cli/inbox-mcp-proxy.js.map +1 -0
- package/dist/dispatch/loadout-translation.d.ts +100 -0
- package/dist/dispatch/loadout-translation.d.ts.map +1 -0
- package/dist/dispatch/loadout-translation.js +90 -0
- package/dist/dispatch/loadout-translation.js.map +1 -0
- package/dist/dispatch/mail-inbound-consumer.d.ts +89 -0
- package/dist/dispatch/mail-inbound-consumer.d.ts.map +1 -0
- package/dist/dispatch/mail-inbound-consumer.js +261 -0
- package/dist/dispatch/mail-inbound-consumer.js.map +1 -0
- package/dist/dispatch/mail-inbound-reuse-consumer.d.ts +75 -0
- package/dist/dispatch/mail-inbound-reuse-consumer.d.ts.map +1 -0
- package/dist/dispatch/mail-inbound-reuse-consumer.js +325 -0
- package/dist/dispatch/mail-inbound-reuse-consumer.js.map +1 -0
- package/dist/dispatch/permission-evaluator.d.ts +68 -0
- package/dist/dispatch/permission-evaluator.d.ts.map +1 -0
- package/dist/dispatch/permission-evaluator.js +159 -0
- package/dist/dispatch/permission-evaluator.js.map +1 -0
- package/dist/dispatch/permission-overlay.d.ts +64 -0
- package/dist/dispatch/permission-overlay.d.ts.map +1 -0
- package/dist/dispatch/permission-overlay.js +72 -0
- package/dist/dispatch/permission-overlay.js.map +1 -0
- package/dist/dispatch/permissions-handler.d.ts +71 -0
- package/dist/dispatch/permissions-handler.d.ts.map +1 -0
- package/dist/dispatch/permissions-handler.js +83 -0
- package/dist/dispatch/permissions-handler.js.map +1 -0
- package/dist/dispatch/spawn-agent-handler.d.ts +84 -0
- package/dist/dispatch/spawn-agent-handler.d.ts.map +1 -0
- package/dist/dispatch/spawn-agent-handler.js +85 -0
- package/dist/dispatch/spawn-agent-handler.js.map +1 -0
- package/dist/lifecycle/handlers-v2.d.ts +7 -0
- package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
- package/dist/lifecycle/handlers-v2.js +27 -0
- package/dist/lifecycle/handlers-v2.js.map +1 -1
- package/dist/map/lifecycle-bridge.d.ts +18 -0
- package/dist/map/lifecycle-bridge.d.ts.map +1 -1
- package/dist/map/lifecycle-bridge.js +23 -1
- package/dist/map/lifecycle-bridge.js.map +1 -1
- package/dist/map/mail-bridge.d.ts +55 -0
- package/dist/map/mail-bridge.d.ts.map +1 -0
- package/dist/map/mail-bridge.js +115 -0
- package/dist/map/mail-bridge.js.map +1 -0
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +245 -1
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/types.d.ts +15 -0
- package/dist/map/types.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.js +1 -0
- package/dist/mcp/tools/done-v2.js.map +1 -1
- package/dist/teams/seed-defaults.d.ts.map +1 -1
- package/dist/teams/seed-defaults.js +6 -2
- package/dist/teams/seed-defaults.js.map +1 -1
- package/dist/teams/team-loader.d.ts.map +1 -1
- package/dist/teams/team-loader.js +17 -1
- package/dist/teams/team-loader.js.map +1 -1
- package/dist/teams/team-runtime-v2.d.ts.map +1 -1
- package/dist/teams/team-runtime-v2.js +2 -0
- package/dist/teams/team-runtime-v2.js.map +1 -1
- package/package.json +6 -6
- package/src/agent/__tests__/agent-manager-v2.permission-interception.test.ts +296 -0
- package/src/agent/__tests__/agent-manager-v2.permissions.test.ts +233 -0
- package/src/agent/agent-manager-v2.ts +268 -8
- package/src/agent/types.ts +51 -0
- package/src/boot-v2.ts +190 -12
- package/src/cli/inbox-mcp-proxy.ts +56 -0
- package/src/dispatch/CLAUDE.md +129 -0
- package/src/dispatch/__tests__/loadout-translation.test.ts +141 -0
- package/src/dispatch/__tests__/mail-inbound-consumer.integration.test.ts +519 -0
- package/src/dispatch/__tests__/mail-inbound-consumer.test.ts +589 -0
- package/src/dispatch/__tests__/mail-inbound-reuse-consumer.test.ts +575 -0
- package/src/dispatch/__tests__/permission-evaluator.test.ts +196 -0
- package/src/dispatch/__tests__/permission-overlay.test.ts +56 -0
- package/src/dispatch/__tests__/permissions-handler.test.ts +168 -0
- package/src/dispatch/__tests__/spawn-agent-handler.test.ts +282 -0
- package/src/dispatch/loadout-translation.ts +138 -0
- package/src/dispatch/mail-inbound-consumer.ts +397 -0
- package/src/dispatch/mail-inbound-reuse-consumer.ts +479 -0
- package/src/dispatch/permission-evaluator.ts +191 -0
- package/src/dispatch/permission-overlay.ts +89 -0
- package/src/dispatch/permissions-handler.ts +112 -0
- package/src/dispatch/spawn-agent-handler.ts +160 -0
- package/src/lifecycle/handlers-v2.ts +34 -0
- package/src/map/__tests__/lifecycle-bridge.test.ts +64 -0
- package/src/map/__tests__/mail-bridge.test.ts +196 -0
- package/src/map/lifecycle-bridge.ts +48 -2
- package/src/map/mail-bridge.ts +203 -0
- package/src/map/sidecar.ts +346 -1
- package/src/map/types.ts +21 -0
- package/src/mcp/tools/done-v2.ts +1 -0
- package/src/teams/seed-defaults.ts +6 -2
- package/src/teams/team-loader.ts +21 -2
- package/src/teams/team-runtime-v2.ts +2 -0
- package/src/workspace/__tests__/self-driving-yaml.test.ts +10 -2
- package/templates/teams/self-driving/team.yaml +142 -0
- package/tsconfig.json +2 -1
|
@@ -13,9 +13,13 @@ import * as path from "path";
|
|
|
13
13
|
import { fileURLToPath } from "url";
|
|
14
14
|
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
// Package root: up from src/teams/ → src/ → package root
|
|
16
|
+
// Package root: up from src/teams/ → src/ → package root.
|
|
17
|
+
// Bundled templates live under `templates/teams/` so they're clearly shipped
|
|
18
|
+
// assets (not confused with user runtime config, which lives at
|
|
19
|
+
// `<project>/.multiagent/teams/` — a gitignored directory that this module
|
|
20
|
+
// seeds INTO on first use).
|
|
17
21
|
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
|
|
18
|
-
const BUNDLED_TEAMS_DIR = path.join(PACKAGE_ROOT, "
|
|
22
|
+
const BUNDLED_TEAMS_DIR = path.join(PACKAGE_ROOT, "templates", "teams");
|
|
19
23
|
const TEAMS_DIR = ".multiagent/teams";
|
|
20
24
|
|
|
21
25
|
/**
|
package/src/teams/team-loader.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* @module teams/team-loader
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import * as fs from "fs";
|
|
10
11
|
import * as path from "path";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
11
13
|
import { TemplateLoader } from "openteams";
|
|
12
14
|
import type {
|
|
13
15
|
ResolvedRole,
|
|
@@ -29,6 +31,15 @@ import {
|
|
|
29
31
|
|
|
30
32
|
const TEAMS_DIR = ".multiagent/teams";
|
|
31
33
|
|
|
34
|
+
// Bundled team templates shipped with the macro-agent package. Used as a
|
|
35
|
+
// fallback when a team name isn't present in the user's `.multiagent/teams/`
|
|
36
|
+
// — so a fresh project can `startTeam('self-driving', cwd)` without first
|
|
37
|
+
// running the seed step. User-local copies always win when present.
|
|
38
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
39
|
+
const __dirname = path.dirname(__filename);
|
|
40
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
|
|
41
|
+
const BUNDLED_TEAMS_DIR = path.join(PACKAGE_ROOT, "templates", "teams");
|
|
42
|
+
|
|
32
43
|
// =============================================================================
|
|
33
44
|
// TeamLoader
|
|
34
45
|
// =============================================================================
|
|
@@ -51,7 +62,13 @@ export async function loadTeam(
|
|
|
51
62
|
basePath?: string
|
|
52
63
|
): Promise<TeamManifest> {
|
|
53
64
|
const root = basePath ?? process.cwd();
|
|
54
|
-
const
|
|
65
|
+
const userTeamDir = path.join(root, TEAMS_DIR, teamName);
|
|
66
|
+
// Prefer a user-customised template; fall back to the bundled default
|
|
67
|
+
// shipped under `<package>/templates/teams/<name>/`. This lets fresh
|
|
68
|
+
// projects use built-in teams without an explicit seed step, while
|
|
69
|
+
// still honouring per-project overrides.
|
|
70
|
+
const bundledTeamDir = path.join(BUNDLED_TEAMS_DIR, teamName);
|
|
71
|
+
const teamDir = fs.existsSync(userTeamDir) ? userTeamDir : bundledTeamDir;
|
|
55
72
|
|
|
56
73
|
// 1. Load via openteams TemplateLoader with hooks
|
|
57
74
|
let template;
|
|
@@ -67,7 +84,9 @@ export async function loadTeam(
|
|
|
67
84
|
|
|
68
85
|
const manifest = template.manifest;
|
|
69
86
|
const communication = (manifest.communication ?? {}) as CommunicationConfig;
|
|
70
|
-
const macroAgent = parseMacroAgentExtensions(
|
|
87
|
+
const macroAgent = parseMacroAgentExtensions(
|
|
88
|
+
manifest.macro_agent as Record<string, unknown> | undefined,
|
|
89
|
+
);
|
|
71
90
|
|
|
72
91
|
// 2. Build enforcement-enriched roles
|
|
73
92
|
const resolvedRoles = new Map<string, ResolvedTeamRole>();
|
|
@@ -63,6 +63,8 @@ function manifestToResolved(manifest: TeamManifest): MacroResolvedTemplate {
|
|
|
63
63
|
roles: new Map(),
|
|
64
64
|
prompts: new Map(),
|
|
65
65
|
mcpServers: manifest._mcpServers,
|
|
66
|
+
mcpProviders: new Map(),
|
|
67
|
+
loadouts: new Map(),
|
|
66
68
|
sourcePath: "",
|
|
67
69
|
},
|
|
68
70
|
resolvedRoles: manifest._resolvedRoles,
|
|
@@ -19,9 +19,17 @@ import type { WorkspaceManager } from '../types.js';
|
|
|
19
19
|
import { vi } from 'vitest';
|
|
20
20
|
|
|
21
21
|
describe('self-driving team YAML (V3 migration)', () => {
|
|
22
|
+
// Resolve relative to this test file so the path is cwd-independent and
|
|
23
|
+
// points at the shipped package asset (not a user-runtime copy under
|
|
24
|
+
// <project>/.multiagent/ — that only exists after `seed-defaults` runs).
|
|
25
|
+
// `src/workspace/__tests__/` → `../../../` → package root.
|
|
26
|
+
const PACKAGE_ROOT = path.resolve(
|
|
27
|
+
path.dirname(new URL(import.meta.url).pathname),
|
|
28
|
+
'..', '..', '..'
|
|
29
|
+
);
|
|
22
30
|
const yamlPath = path.join(
|
|
23
|
-
|
|
24
|
-
'
|
|
31
|
+
PACKAGE_ROOT,
|
|
32
|
+
'templates/teams/self-driving/team.yaml'
|
|
25
33
|
);
|
|
26
34
|
|
|
27
35
|
it('exists on disk', () => {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
name: self-driving
|
|
2
|
+
description: "Cursor-style autonomous codebase development: planners explore and create tasks, grinders claim and execute in their own streams, judges evaluate quality."
|
|
3
|
+
version: 1
|
|
4
|
+
|
|
5
|
+
# ─────────────────────────────────────────────────────────────
|
|
6
|
+
# Roles
|
|
7
|
+
# ─────────────────────────────────────────────────────────────
|
|
8
|
+
roles:
|
|
9
|
+
- planner
|
|
10
|
+
- grinder
|
|
11
|
+
- judge
|
|
12
|
+
|
|
13
|
+
# ─────────────────────────────────────────────────────────────
|
|
14
|
+
# Topology
|
|
15
|
+
# ─────────────────────────────────────────────────────────────
|
|
16
|
+
topology:
|
|
17
|
+
root:
|
|
18
|
+
role: planner
|
|
19
|
+
prompt: prompts/planner.md
|
|
20
|
+
config:
|
|
21
|
+
model: sonnet
|
|
22
|
+
companions:
|
|
23
|
+
- role: judge
|
|
24
|
+
prompt: prompts/judge.md
|
|
25
|
+
config:
|
|
26
|
+
model: haiku
|
|
27
|
+
spawn_rules:
|
|
28
|
+
planner: [grinder, planner]
|
|
29
|
+
judge: []
|
|
30
|
+
grinder: []
|
|
31
|
+
|
|
32
|
+
# ─────────────────────────────────────────────────────────────
|
|
33
|
+
# Communication
|
|
34
|
+
# ─────────────────────────────────────────────────────────────
|
|
35
|
+
communication:
|
|
36
|
+
enforcement: permissive
|
|
37
|
+
|
|
38
|
+
channels:
|
|
39
|
+
task_updates:
|
|
40
|
+
description: "Task lifecycle events"
|
|
41
|
+
signals: [TASK_CREATED, TASK_COMPLETED, TASK_FAILED]
|
|
42
|
+
work_coordination:
|
|
43
|
+
description: "Work assignment and completion"
|
|
44
|
+
signals: [WORK_ASSIGNED, WORKER_DONE, MERGE_REQUEST]
|
|
45
|
+
health:
|
|
46
|
+
description: "System health monitoring"
|
|
47
|
+
signals: [HEALTH_CHECK, METRIC_SNAPSHOT, GREEN_SNAPSHOT, FIXUP_CREATED]
|
|
48
|
+
|
|
49
|
+
subscriptions:
|
|
50
|
+
planner:
|
|
51
|
+
- channel: task_updates
|
|
52
|
+
- channel: work_coordination
|
|
53
|
+
signals: [WORKER_DONE]
|
|
54
|
+
- channel: health
|
|
55
|
+
signals: [METRIC_SNAPSHOT, GREEN_SNAPSHOT, FIXUP_CREATED]
|
|
56
|
+
judge:
|
|
57
|
+
- channel: task_updates
|
|
58
|
+
signals: [TASK_FAILED]
|
|
59
|
+
- channel: work_coordination
|
|
60
|
+
signals: [WORKER_DONE]
|
|
61
|
+
- channel: health
|
|
62
|
+
grinder:
|
|
63
|
+
- channel: work_coordination
|
|
64
|
+
signals: [WORK_ASSIGNED]
|
|
65
|
+
|
|
66
|
+
emissions:
|
|
67
|
+
planner: [TASK_CREATED, WORK_ASSIGNED, PLANNING_COMPLETE]
|
|
68
|
+
judge: [HEALTH_CHECK, GREEN_SNAPSHOT, FIXUP_CREATED]
|
|
69
|
+
grinder: [WORKER_DONE]
|
|
70
|
+
|
|
71
|
+
routing:
|
|
72
|
+
peers:
|
|
73
|
+
- from: judge
|
|
74
|
+
to: planner
|
|
75
|
+
via: direct
|
|
76
|
+
signals: [FIXUP_CREATED, GREEN_SNAPSHOT]
|
|
77
|
+
- from: planner
|
|
78
|
+
to: judge
|
|
79
|
+
via: direct
|
|
80
|
+
signals: [CONVERGENCE_CHECK]
|
|
81
|
+
|
|
82
|
+
# ─────────────────────────────────────────────────────────────
|
|
83
|
+
# macro-agent specific extensions
|
|
84
|
+
# ─────────────────────────────────────────────────────────────
|
|
85
|
+
macro_agent:
|
|
86
|
+
# V3 stream-first workspace topology.
|
|
87
|
+
# Compiled by YamlDrivenTopology into per-spawn WorkspaceDecision values.
|
|
88
|
+
workspace:
|
|
89
|
+
default_stream:
|
|
90
|
+
fork_from: main
|
|
91
|
+
name_template: "{team}"
|
|
92
|
+
change_id_tracking: true
|
|
93
|
+
|
|
94
|
+
on_team_complete: keep
|
|
95
|
+
|
|
96
|
+
roles:
|
|
97
|
+
# Planner shares the team root stream — continuous exploration lives on the
|
|
98
|
+
# same branch as the team's accumulated work; no per-planner fork.
|
|
99
|
+
planner:
|
|
100
|
+
workspace: attach_to_team_root
|
|
101
|
+
capabilities:
|
|
102
|
+
- workspace.read
|
|
103
|
+
- agent.spawn
|
|
104
|
+
|
|
105
|
+
# Grinders fork their own stream off the team root, land via direct-push
|
|
106
|
+
# (trunk integration). A conflict during landing aborts and leaves the
|
|
107
|
+
# stream for human / judge review.
|
|
108
|
+
grinder:
|
|
109
|
+
workspace: new_stream
|
|
110
|
+
stream_lineage: fork_from_team_root
|
|
111
|
+
landing: direct_push
|
|
112
|
+
on_conflict: defer
|
|
113
|
+
capabilities:
|
|
114
|
+
- workspace.commit
|
|
115
|
+
- workspace.land
|
|
116
|
+
|
|
117
|
+
# Judge is read-only — it observes repo state but doesn't need a
|
|
118
|
+
# workspace of its own.
|
|
119
|
+
judge:
|
|
120
|
+
workspace: none
|
|
121
|
+
capabilities:
|
|
122
|
+
- workspace.read
|
|
123
|
+
|
|
124
|
+
# Declarative shorthand read by TeamRuntimeV2.getStrategyName(). `trunk`
|
|
125
|
+
# pairs with the grinder's direct_push landing above: every task lands
|
|
126
|
+
# straight onto the team-root stream rather than going through a merge
|
|
127
|
+
# queue. Kept here as a top-level scalar so runtimes that don't parse the
|
|
128
|
+
# full V3 workspace block (env-var consumers, logs, metrics labels) still
|
|
129
|
+
# see the integration strategy.
|
|
130
|
+
integration:
|
|
131
|
+
strategy: trunk
|
|
132
|
+
|
|
133
|
+
task_assignment:
|
|
134
|
+
mode: pull
|
|
135
|
+
pull:
|
|
136
|
+
idle_timeout_s: 300
|
|
137
|
+
claim_retry_delay_ms: 2000
|
|
138
|
+
max_concurrent_per_agent: 1
|
|
139
|
+
|
|
140
|
+
observability:
|
|
141
|
+
metrics_window_s: 3600
|
|
142
|
+
snapshot_interval_s: 300
|
package/tsconfig.json
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"declaration": true,
|
|
14
14
|
"declarationMap": true,
|
|
15
15
|
"sourceMap": true,
|
|
16
|
-
"resolveJsonModule": true
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"types": ["node", "better-sqlite3", "express", "js-yaml", "supertest", "ws"]
|
|
17
18
|
},
|
|
18
19
|
"include": ["src/**/*"],
|
|
19
20
|
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|