macro-agent 0.1.7 → 0.1.10
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.md +179 -38
- package/README.md +781 -131
- package/dist/acp/claude-code-replay.d.ts +11 -0
- package/dist/acp/claude-code-replay.d.ts.map +1 -0
- package/dist/acp/claude-code-replay.js +190 -0
- package/dist/acp/claude-code-replay.js.map +1 -0
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +155 -6
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/types.d.ts +9 -0
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js.map +1 -1
- package/dist/agent/agent-manager-v2.d.ts +21 -0
- package/dist/agent/agent-manager-v2.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.js +234 -71
- package/dist/agent/agent-manager-v2.js.map +1 -1
- package/dist/agent/agent-manager.d.ts +12 -0
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/agent/types.d.ts +15 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/boot-v2.d.ts +41 -0
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +34 -37
- package/dist/boot-v2.js.map +1 -1
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cognitive/macro-agent-backend.d.ts.map +1 -1
- package/dist/cognitive/macro-agent-backend.js +40 -22
- package/dist/cognitive/macro-agent-backend.js.map +1 -1
- package/dist/integrations/skilltree.d.ts.map +1 -1
- package/dist/integrations/skilltree.js +1 -0
- package/dist/integrations/skilltree.js.map +1 -1
- package/dist/lifecycle/cleanup.d.ts +33 -2
- package/dist/lifecycle/cleanup.d.ts.map +1 -1
- package/dist/lifecycle/cleanup.js +28 -6
- package/dist/lifecycle/cleanup.js.map +1 -1
- 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 +28 -2
- package/dist/lifecycle/handlers-v2.js.map +1 -1
- package/dist/lifecycle/types.d.ts +11 -0
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/lifecycle/types.js.map +1 -1
- package/dist/map/acp-bridge.d.ts +9 -0
- package/dist/map/acp-bridge.d.ts.map +1 -1
- package/dist/map/acp-bridge.js +15 -2
- package/dist/map/acp-bridge.js.map +1 -1
- package/dist/map/cascade-bridge.d.ts +44 -0
- package/dist/map/cascade-bridge.d.ts.map +1 -0
- package/dist/map/cascade-bridge.js +257 -0
- package/dist/map/cascade-bridge.js.map +1 -0
- package/dist/map/lifecycle-bridge.d.ts +1 -8
- package/dist/map/lifecycle-bridge.d.ts.map +1 -1
- package/dist/map/lifecycle-bridge.js +76 -22
- package/dist/map/lifecycle-bridge.js.map +1 -1
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +47 -6
- package/dist/map/server.js.map +1 -1
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +33 -4
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/types.d.ts +20 -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 +8 -0
- package/dist/mcp/tools/done-v2.js.map +1 -1
- package/dist/teams/team-manager-v2.d.ts.map +1 -1
- package/dist/teams/team-manager-v2.js +26 -0
- package/dist/teams/team-manager-v2.js.map +1 -1
- package/dist/teams/team-runtime-v2.d.ts.map +1 -1
- package/dist/teams/team-runtime-v2.js +16 -3
- package/dist/teams/team-runtime-v2.js.map +1 -1
- package/dist/workspace/config.d.ts +10 -10
- package/dist/workspace/config.d.ts.map +1 -1
- package/dist/workspace/config.js +4 -4
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/git-cascade-adapter.d.ts +510 -0
- package/dist/workspace/git-cascade-adapter.d.ts.map +1 -0
- package/dist/workspace/git-cascade-adapter.js +908 -0
- package/dist/workspace/git-cascade-adapter.js.map +1 -0
- package/dist/workspace/index.d.ts +3 -3
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/landing/direct-push.d.ts +20 -0
- package/dist/workspace/landing/direct-push.d.ts.map +1 -0
- package/dist/workspace/landing/direct-push.js +74 -0
- package/dist/workspace/landing/direct-push.js.map +1 -0
- package/dist/workspace/landing/index.d.ts +29 -0
- package/dist/workspace/landing/index.d.ts.map +1 -0
- package/dist/workspace/landing/index.js +37 -0
- package/dist/workspace/landing/index.js.map +1 -0
- package/dist/workspace/landing/merge-to-parent.d.ts +41 -0
- package/dist/workspace/landing/merge-to-parent.d.ts.map +1 -0
- package/dist/workspace/landing/merge-to-parent.js +185 -0
- package/dist/workspace/landing/merge-to-parent.js.map +1 -0
- package/dist/workspace/landing/optimistic-push.d.ts +16 -0
- package/dist/workspace/landing/optimistic-push.d.ts.map +1 -0
- package/dist/workspace/landing/optimistic-push.js +27 -0
- package/dist/workspace/landing/optimistic-push.js.map +1 -0
- package/dist/workspace/landing/queue-to-branch.d.ts +24 -0
- package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -0
- package/dist/workspace/landing/queue-to-branch.js +79 -0
- package/dist/workspace/landing/queue-to-branch.js.map +1 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts +10 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts.map +1 -1
- package/dist/workspace/merge-queue/merge-queue.js +10 -0
- package/dist/workspace/merge-queue/merge-queue.js.map +1 -1
- package/dist/workspace/merge-queue/types.d.ts +16 -2
- package/dist/workspace/merge-queue/types.d.ts.map +1 -1
- package/dist/workspace/merge-queue/types.js +9 -0
- package/dist/workspace/merge-queue/types.js.map +1 -1
- package/dist/workspace/pool/types.d.ts +1 -0
- package/dist/workspace/pool/types.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.js +1 -0
- package/dist/workspace/pool/worktree-pool.js.map +1 -1
- package/dist/workspace/recovery/abandon.d.ts +15 -0
- package/dist/workspace/recovery/abandon.d.ts.map +1 -0
- package/dist/workspace/recovery/abandon.js +45 -0
- package/dist/workspace/recovery/abandon.js.map +1 -0
- package/dist/workspace/recovery/auto-resolve.d.ts +27 -0
- package/dist/workspace/recovery/auto-resolve.d.ts.map +1 -0
- package/dist/workspace/recovery/auto-resolve.js +99 -0
- package/dist/workspace/recovery/auto-resolve.js.map +1 -0
- package/dist/workspace/recovery/defer.d.ts +15 -0
- package/dist/workspace/recovery/defer.d.ts.map +1 -0
- package/dist/workspace/recovery/defer.js +16 -0
- package/dist/workspace/recovery/defer.js.map +1 -0
- package/dist/workspace/recovery/escalate.d.ts +16 -0
- package/dist/workspace/recovery/escalate.d.ts.map +1 -0
- package/dist/workspace/recovery/escalate.js +24 -0
- package/dist/workspace/recovery/escalate.js.map +1 -0
- package/dist/workspace/recovery/index.d.ts +32 -0
- package/dist/workspace/recovery/index.d.ts.map +1 -0
- package/dist/workspace/recovery/index.js +45 -0
- package/dist/workspace/recovery/index.js.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts +45 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.js +111 -0
- package/dist/workspace/recovery/spawn-resolver.js.map +1 -0
- package/dist/workspace/recovery/types.d.ts +63 -0
- package/dist/workspace/recovery/types.d.ts.map +1 -0
- package/dist/workspace/recovery/types.js +12 -0
- package/dist/workspace/recovery/types.js.map +1 -0
- package/dist/workspace/topology/index.d.ts +9 -0
- package/dist/workspace/topology/index.d.ts.map +1 -0
- package/dist/workspace/topology/index.js +8 -0
- package/dist/workspace/topology/index.js.map +1 -0
- package/dist/workspace/topology/no-workspace.d.ts +18 -0
- package/dist/workspace/topology/no-workspace.d.ts.map +1 -0
- package/dist/workspace/topology/no-workspace.js +25 -0
- package/dist/workspace/topology/no-workspace.js.map +1 -0
- package/dist/workspace/topology/types.d.ts +97 -0
- package/dist/workspace/topology/types.d.ts.map +1 -0
- package/dist/workspace/topology/types.js +20 -0
- package/dist/workspace/topology/types.js.map +1 -0
- package/dist/workspace/topology/yaml-driven.d.ts +69 -0
- package/dist/workspace/topology/yaml-driven.d.ts.map +1 -0
- package/dist/workspace/topology/yaml-driven.js +273 -0
- package/dist/workspace/topology/yaml-driven.js.map +1 -0
- package/dist/workspace/types-v3.d.ts +110 -0
- package/dist/workspace/types-v3.d.ts.map +1 -0
- package/dist/workspace/types-v3.js +20 -0
- package/dist/workspace/types-v3.js.map +1 -0
- package/dist/workspace/types.d.ts +145 -17
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +92 -13
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.js +373 -13
- package/dist/workspace/workspace-manager.js.map +1 -1
- package/dist/workspace/yaml-schema.d.ts +254 -0
- package/dist/workspace/yaml-schema.d.ts.map +1 -0
- package/dist/workspace/yaml-schema.js +170 -0
- package/dist/workspace/yaml-schema.js.map +1 -0
- package/docs/conflict-recovery.md +472 -0
- package/docs/git-cascade-integration-gaps.md +678 -0
- package/docs/workspace-interfaces.md +731 -0
- package/docs/workspace-redesign-plan.md +302 -0
- package/package.json +4 -4
- package/src/__tests__/e2e/auto-sync.e2e.test.ts +257 -0
- package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +254 -0
- package/src/__tests__/e2e/cli-run.e2e.test.ts +167 -0
- package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +197 -0
- package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +200 -0
- package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +30 -22
- package/src/__tests__/e2e/workspace-v3.e2e.test.ts +413 -0
- package/src/acp/__tests__/claude-code-replay.test.ts +225 -0
- package/src/acp/__tests__/macro-agent.test.ts +39 -1
- package/src/acp/claude-code-replay.ts +208 -0
- package/src/acp/macro-agent.ts +167 -9
- package/src/acp/types.ts +10 -0
- package/src/agent/__tests__/agent-manager-topology.test.ts +73 -0
- package/src/agent/__tests__/agent-manager-v2.test.ts +71 -11
- package/src/agent/__tests__/task-ref-resolution.test.ts +231 -0
- package/src/agent/agent-manager-v2.ts +293 -77
- package/src/agent/agent-manager.ts +14 -0
- package/src/agent/types.ts +16 -2
- package/src/boot-v2.ts +87 -36
- package/src/cli/index.ts +61 -0
- package/src/cognitive/__tests__/macro-agent-backend.test.ts +47 -5
- package/src/cognitive/macro-agent-backend.ts +45 -29
- package/src/integrations/skilltree.ts +1 -0
- package/src/lifecycle/cleanup.ts +52 -3
- package/src/lifecycle/handlers-v2.ts +40 -3
- package/src/lifecycle/types.ts +12 -0
- package/src/map/__tests__/cascade-bridge.test.ts +229 -0
- package/src/map/__tests__/lifecycle-bridge.test.ts +165 -22
- package/src/map/acp-bridge.ts +26 -3
- package/src/map/cascade-bridge.ts +301 -0
- package/src/map/lifecycle-bridge.ts +77 -27
- package/src/map/server.ts +47 -6
- package/src/map/sidecar.ts +31 -3
- package/src/map/types.ts +20 -0
- package/src/mcp/tools/done-v2.ts +9 -0
- package/src/teams/team-manager-v2.ts +37 -0
- package/src/teams/team-runtime-v2.ts +23 -3
- package/src/workspace/__tests__/{dataplane-adapter.test.ts → git-cascade-adapter.test.ts} +209 -14
- package/src/workspace/__tests__/self-driving-yaml.test.ts +114 -0
- package/src/workspace/__tests__/shared-worktree-refcount.test.ts +154 -0
- package/src/workspace/__tests__/standalone-mode.test.ts +118 -0
- package/src/workspace/__tests__/workspace-manager-v3.test.ts +245 -0
- package/src/workspace/__tests__/yaml-schema.test.ts +210 -0
- package/src/workspace/config.ts +11 -11
- package/src/workspace/git-cascade-adapter.ts +1186 -0
- package/src/workspace/index.ts +11 -11
- package/src/workspace/landing/__tests__/strategies.test.ts +142 -0
- package/src/workspace/landing/direct-push.ts +91 -0
- package/src/workspace/landing/index.ts +40 -0
- package/src/workspace/landing/merge-to-parent.ts +228 -0
- package/src/workspace/landing/optimistic-push.ts +36 -0
- package/src/workspace/landing/queue-to-branch.ts +108 -0
- package/src/workspace/merge-queue/merge-queue.ts +10 -0
- package/src/workspace/merge-queue/types.ts +16 -2
- package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +5 -5
- package/src/workspace/pool/types.ts +1 -0
- package/src/workspace/pool/worktree-pool.ts +1 -0
- package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +127 -0
- package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +139 -0
- package/src/workspace/recovery/__tests__/strategies.test.ts +145 -0
- package/src/workspace/recovery/abandon.ts +51 -0
- package/src/workspace/recovery/auto-resolve.ts +119 -0
- package/src/workspace/recovery/defer.ts +23 -0
- package/src/workspace/recovery/escalate.ts +30 -0
- package/src/workspace/recovery/index.ts +58 -0
- package/src/workspace/recovery/spawn-resolver.ts +145 -0
- package/src/workspace/recovery/types.ts +54 -0
- package/src/workspace/topology/__tests__/yaml-driven.test.ts +345 -0
- package/src/workspace/topology/index.ts +18 -0
- package/src/workspace/topology/no-workspace.ts +39 -0
- package/src/workspace/topology/types.ts +116 -0
- package/src/workspace/topology/yaml-driven.ts +316 -0
- package/src/workspace/types-v3.ts +155 -0
- package/src/workspace/types.ts +191 -20
- package/src/workspace/workspace-manager.ts +474 -19
- package/src/workspace/yaml-schema.ts +216 -0
- package/src/workspace/dataplane-adapter.ts +0 -546
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML Zod schema for `macro_agent.workspace`.
|
|
3
|
+
*
|
|
4
|
+
* Teams declare workspace topology via `macro_agent.workspace` in their
|
|
5
|
+
* `team.yaml`. This module validates that section and exposes typed config
|
|
6
|
+
* objects that the TopologyPolicy compiler (Phase 3) consumes.
|
|
7
|
+
*
|
|
8
|
+
* @module workspace/yaml-schema
|
|
9
|
+
* @see docs/workspace-interfaces.md §8
|
|
10
|
+
* @see docs/workspace-redesign-plan.md Phase 2
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
// Enums
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
export const StreamLineageSchema = z.enum([
|
|
20
|
+
'from_team_root', // attach to the team's root stream (no new stream)
|
|
21
|
+
'fork_from_team_root', // fork a new stream off the team root
|
|
22
|
+
'fork_from_parent', // fork a new stream off the spawner's stream
|
|
23
|
+
'independent', // fork a new stream off a branch (no parent stream)
|
|
24
|
+
'track_existing_branch', // track an existing branch (no new stream/<id>)
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export const LandingStrategyNameSchema = z.enum([
|
|
28
|
+
'merge_to_parent_stream',
|
|
29
|
+
'queue_to_branch',
|
|
30
|
+
'cherry_pick_stack',
|
|
31
|
+
'direct_push',
|
|
32
|
+
'optimistic_push',
|
|
33
|
+
'none',
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
export const ConflictStrategyNameSchema = z.enum([
|
|
37
|
+
'abort',
|
|
38
|
+
'ours',
|
|
39
|
+
'theirs',
|
|
40
|
+
'defer',
|
|
41
|
+
'agent',
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Recovery strategies for landing conflicts.
|
|
46
|
+
* See docs/conflict-recovery.md §4.
|
|
47
|
+
*/
|
|
48
|
+
export const ConflictRecoveryStrategyNameSchema = z.enum([
|
|
49
|
+
'auto-resolve',
|
|
50
|
+
'defer',
|
|
51
|
+
'spawn-resolver',
|
|
52
|
+
'abandon',
|
|
53
|
+
'escalate',
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
export const WorkspaceKindSchema = z.enum([
|
|
57
|
+
'new_stream', // agent gets its own stream
|
|
58
|
+
'attach_to_team_root', // agent works on team root stream
|
|
59
|
+
'share_with_agent', // agent shares another agent's worktree (ref-counted)
|
|
60
|
+
'share_parent_cwd', // agent inherits spawner's cwd (no isolation)
|
|
61
|
+
'none', // no workspace; agent has no streaming concerns
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
export const AllocationSchema = z.enum([
|
|
65
|
+
'new_worktree',
|
|
66
|
+
'inherit_parent_cwd',
|
|
67
|
+
'pooled_worktree',
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
export const OnParentAdvancedSchema = z.enum([
|
|
71
|
+
'sync_with_parent',
|
|
72
|
+
'none',
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
export const OnTeamCompleteSchema = z.enum([
|
|
76
|
+
'keep',
|
|
77
|
+
'merge_to_main',
|
|
78
|
+
'abandon',
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
82
|
+
// Schemas
|
|
83
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
export const RoleWorkspaceConfigSchema = z.object({
|
|
86
|
+
workspace: WorkspaceKindSchema,
|
|
87
|
+
stream_lineage: StreamLineageSchema.optional(),
|
|
88
|
+
allocation: AllocationSchema.optional(),
|
|
89
|
+
|
|
90
|
+
// Landing
|
|
91
|
+
landing: LandingStrategyNameSchema.optional(),
|
|
92
|
+
landing_config: z.record(z.string(), z.unknown()).optional(),
|
|
93
|
+
|
|
94
|
+
// Conflict handling at landing time
|
|
95
|
+
on_conflict: ConflictStrategyNameSchema.optional(),
|
|
96
|
+
on_conflict_recovery: ConflictRecoveryStrategyNameSchema.optional(),
|
|
97
|
+
conflict_recovery_config: z.record(z.string(), z.unknown()).optional(),
|
|
98
|
+
|
|
99
|
+
// Cascade behavior
|
|
100
|
+
cascade_on_parent_update: z.boolean().optional(),
|
|
101
|
+
on_parent_advanced: OnParentAdvancedSchema.optional(),
|
|
102
|
+
|
|
103
|
+
// Cross-role references
|
|
104
|
+
share_with: z.string().optional(), // role name (for workspace: share_with_agent)
|
|
105
|
+
track_branch: z.string().optional(), // branch name (for stream_lineage: track_existing_branch)
|
|
106
|
+
|
|
107
|
+
// Capabilities granted to this role for MCP tool gating
|
|
108
|
+
capabilities: z.array(z.string()).optional(),
|
|
109
|
+
}).superRefine((val, ctx) => {
|
|
110
|
+
if (val.workspace === 'share_with_agent' && !val.share_with) {
|
|
111
|
+
ctx.addIssue({
|
|
112
|
+
code: 'custom',
|
|
113
|
+
path: ['share_with'],
|
|
114
|
+
message: 'share_with is required when workspace = share_with_agent',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (val.stream_lineage === 'track_existing_branch' && !val.track_branch) {
|
|
118
|
+
ctx.addIssue({
|
|
119
|
+
code: 'custom',
|
|
120
|
+
path: ['track_branch'],
|
|
121
|
+
message: 'track_branch is required when stream_lineage = track_existing_branch',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (val.workspace === 'new_stream' && !val.stream_lineage) {
|
|
125
|
+
ctx.addIssue({
|
|
126
|
+
code: 'custom',
|
|
127
|
+
path: ['stream_lineage'],
|
|
128
|
+
message: 'stream_lineage is required when workspace = new_stream',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export const PoolConfigSchema = z.object({
|
|
134
|
+
enabled: z.boolean().default(true),
|
|
135
|
+
max_size: z.number().int().positive().default(10),
|
|
136
|
+
reuse_across_streams: z.boolean().default(false),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const DefaultStreamConfigSchema = z.object({
|
|
140
|
+
fork_from: z.string().default('main'),
|
|
141
|
+
name_template: z.string().default('{team}'),
|
|
142
|
+
change_id_tracking: z.boolean().default(true),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const ConflictRecoveryTeamConfigSchema = z.object({
|
|
146
|
+
default_strategy: ConflictRecoveryStrategyNameSchema.default('defer'),
|
|
147
|
+
default_config: z.record(z.string(), z.unknown()).optional(),
|
|
148
|
+
escalation_target: z.string().optional(),
|
|
149
|
+
max_recovery_depth: z.number().int().positive().default(3),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
export const TeamWorkspaceConfigSchema = z.object({
|
|
153
|
+
default_stream: DefaultStreamConfigSchema.optional(),
|
|
154
|
+
on_team_complete: OnTeamCompleteSchema.default('keep'),
|
|
155
|
+
pool: PoolConfigSchema.optional(),
|
|
156
|
+
roles: z.record(z.string(), RoleWorkspaceConfigSchema),
|
|
157
|
+
conflict_recovery: ConflictRecoveryTeamConfigSchema.optional(),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
161
|
+
// Types (inferred)
|
|
162
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
163
|
+
|
|
164
|
+
export type StreamLineage = z.infer<typeof StreamLineageSchema>;
|
|
165
|
+
export type LandingStrategyName = z.infer<typeof LandingStrategyNameSchema>;
|
|
166
|
+
export type ConflictStrategyName = z.infer<typeof ConflictStrategyNameSchema>;
|
|
167
|
+
export type ConflictRecoveryStrategyName = z.infer<typeof ConflictRecoveryStrategyNameSchema>;
|
|
168
|
+
export type WorkspaceKind = z.infer<typeof WorkspaceKindSchema>;
|
|
169
|
+
export type Allocation = z.infer<typeof AllocationSchema>;
|
|
170
|
+
export type OnParentAdvanced = z.infer<typeof OnParentAdvancedSchema>;
|
|
171
|
+
export type OnTeamComplete = z.infer<typeof OnTeamCompleteSchema>;
|
|
172
|
+
export type RoleWorkspaceConfig = z.infer<typeof RoleWorkspaceConfigSchema>;
|
|
173
|
+
export type PoolConfig = z.infer<typeof PoolConfigSchema>;
|
|
174
|
+
export type DefaultStreamConfig = z.infer<typeof DefaultStreamConfigSchema>;
|
|
175
|
+
export type ConflictRecoveryTeamConfig = z.infer<typeof ConflictRecoveryTeamConfigSchema>;
|
|
176
|
+
export type TeamWorkspaceConfig = z.infer<typeof TeamWorkspaceConfigSchema>;
|
|
177
|
+
|
|
178
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
179
|
+
// Parsing helpers
|
|
180
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Parse and validate a `macro_agent.workspace` block from a team manifest.
|
|
184
|
+
*
|
|
185
|
+
* Returns `null` when the block is absent (indicating no workspace isolation
|
|
186
|
+
* is configured for the team). Throws on validation failure with a helpful
|
|
187
|
+
* error message.
|
|
188
|
+
*/
|
|
189
|
+
export function parseTeamWorkspaceConfig(
|
|
190
|
+
raw: unknown
|
|
191
|
+
): TeamWorkspaceConfig | null {
|
|
192
|
+
if (raw === undefined || raw === null) return null;
|
|
193
|
+
const result = TeamWorkspaceConfigSchema.safeParse(raw);
|
|
194
|
+
if (!result.success) {
|
|
195
|
+
const issues = result.error.issues
|
|
196
|
+
.map((i) => ` • ${i.path.join('.')}: ${i.message}`)
|
|
197
|
+
.join('\n');
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Invalid macro_agent.workspace configuration:\n${issues}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return result.data;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Extract the workspace block from a loaded openteams `TeamManifest`.
|
|
207
|
+
*
|
|
208
|
+
* openteams treats `macro_agent` as `Record<string, unknown>` — macro-agent
|
|
209
|
+
* owns the schema inside.
|
|
210
|
+
*/
|
|
211
|
+
export function extractWorkspaceConfig(
|
|
212
|
+
manifest: { macro_agent?: Record<string, unknown> }
|
|
213
|
+
): TeamWorkspaceConfig | null {
|
|
214
|
+
const workspaceRaw = manifest.macro_agent?.workspace;
|
|
215
|
+
return parseTeamWorkspaceConfig(workspaceRaw);
|
|
216
|
+
}
|