macro-agent 0.1.5 → 0.1.7
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/settings.json +128 -1
- package/.sessionlog/settings.json +4 -0
- package/CLAUDE.md +125 -10
- package/README.md +93 -31
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +1 -3
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/boot-v2.d.ts +1 -0
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +1 -0
- package/dist/boot-v2.js.map +1 -1
- package/dist/cognitive/workspace-handler.d.ts +17 -9
- package/dist/cognitive/workspace-handler.d.ts.map +1 -1
- package/dist/cognitive/workspace-handler.js +10 -11
- package/dist/cognitive/workspace-handler.js.map +1 -1
- package/dist/map/coordination-handler.d.ts +7 -23
- package/dist/map/coordination-handler.d.ts.map +1 -1
- package/dist/map/coordination-handler.js +124 -100
- package/dist/map/coordination-handler.js.map +1 -1
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +13 -3
- package/dist/map/server.js.map +1 -1
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +13 -15
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/trajectory-reporter.d.ts +4 -9
- package/dist/map/trajectory-reporter.d.ts.map +1 -1
- package/dist/map/trajectory-reporter.js +15 -129
- package/dist/map/trajectory-reporter.js.map +1 -1
- package/dist/map/types.d.ts +39 -0
- package/dist/map/types.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/e2e/cognitive-workspace.e2e.test.ts +1 -1
- package/src/acp/macro-agent.ts +1 -4
- package/src/boot-v2.ts +2 -0
- package/src/cognitive/__tests__/workspace-handler.test.ts +2 -10
- package/src/cognitive/workspace-handler.ts +18 -15
- package/src/map/__tests__/trajectory-reporter.test.ts +2 -254
- package/src/map/coordination-handler.ts +137 -120
- package/src/map/server.ts +14 -2
- package/src/map/sidecar.ts +13 -20
- package/src/map/trajectory-reporter.ts +16 -154
- package/src/map/types.ts +43 -2
- package/src/__tests__/e2e/trajectory-content.e2e.test.ts +0 -708
- package/src/map/__tests__/coordination-handler.test.ts +0 -598
|
@@ -2,153 +2,39 @@
|
|
|
2
2
|
* Trajectory Reporter — builds and reports trajectory checkpoints to the MAP hub.
|
|
3
3
|
*
|
|
4
4
|
* Sends checkpoints via the `trajectory/checkpoint` JSON-RPC extension.
|
|
5
|
-
*
|
|
6
|
-
* session
|
|
7
|
-
* Supports all agent types (Claude Code, Codex, Gemini, etc.) through
|
|
8
|
-
* sessionlog's adapter system.
|
|
5
|
+
* Also handles inbound `trajectory/content.request` notifications by serving
|
|
6
|
+
* session transcript data.
|
|
9
7
|
*
|
|
10
8
|
* @module map/trajectory-reporter
|
|
11
9
|
*/
|
|
12
|
-
/**
|
|
13
|
-
* Resolve transcript content for a checkpoint ID using sessionlog.
|
|
14
|
-
*
|
|
15
|
-
* Two-source strategy (matching cc-swarm):
|
|
16
|
-
* 1. Live session — use sessionlog's SessionStore to find a session
|
|
17
|
-
* matching the checkpoint ID, then read its transcript from disk.
|
|
18
|
-
* 2. Committed checkpoint — use sessionlog's CheckpointStore to read
|
|
19
|
-
* content from the git history.
|
|
20
|
-
*
|
|
21
|
-
* Returns null if no content is found or sessionlog is unavailable.
|
|
22
|
-
*/
|
|
23
|
-
async function resolveContent(checkpointId, sessionDirs) {
|
|
24
|
-
let sessionlog = null;
|
|
25
|
-
try {
|
|
26
|
-
sessionlog = await import("sessionlog");
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return null; // sessionlog not available
|
|
30
|
-
}
|
|
31
|
-
const { readFileSync, existsSync } = await import("node:fs");
|
|
32
|
-
// Derive the session ID from checkpoint ID (e.g., "sess-abc-step3" → "sess-abc")
|
|
33
|
-
const sessionId = checkpointId.replace(/-step\d+$/, "");
|
|
34
|
-
// ── 1. Live session lookup via SessionStore ────────────────────────────
|
|
35
|
-
for (const sessionsDir of sessionDirs) {
|
|
36
|
-
if (!existsSync(sessionsDir))
|
|
37
|
-
continue;
|
|
38
|
-
try {
|
|
39
|
-
const store = sessionlog.createSessionStore(undefined, sessionsDir);
|
|
40
|
-
// Try loading by derived session ID first, then by raw checkpoint ID
|
|
41
|
-
let state = await store.load(sessionId);
|
|
42
|
-
if (!state)
|
|
43
|
-
state = await store.load(checkpointId);
|
|
44
|
-
// If not found by ID, scan all sessions for checkpoint match
|
|
45
|
-
if (!state) {
|
|
46
|
-
const allSessions = await store.list();
|
|
47
|
-
state = allSessions.find((s) => s.lastCheckpointID === checkpointId ||
|
|
48
|
-
(s.turnCheckpointIDs || []).includes(checkpointId)) ?? null;
|
|
49
|
-
}
|
|
50
|
-
if (!state?.transcriptPath || !existsSync(state.transcriptPath))
|
|
51
|
-
continue;
|
|
52
|
-
const transcript = readFileSync(state.transcriptPath, "utf-8");
|
|
53
|
-
// Use sessionlog's prompt extraction if the agent has a TranscriptAnalyzer,
|
|
54
|
-
// otherwise fall back to the prompts stored in state
|
|
55
|
-
let prompts = "";
|
|
56
|
-
if (state.firstPrompt) {
|
|
57
|
-
// Collect from promptAttributions if available, otherwise use firstPrompt
|
|
58
|
-
const attrs = state.promptAttributions;
|
|
59
|
-
if (attrs && attrs.length > 0) {
|
|
60
|
-
prompts = attrs.map((a) => a.prompt).join("\n---\n");
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
prompts = state.firstPrompt;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
transcript,
|
|
68
|
-
prompts,
|
|
69
|
-
metadata: {
|
|
70
|
-
sessionID: state.sessionID,
|
|
71
|
-
phase: state.phase,
|
|
72
|
-
agentType: state.agentType,
|
|
73
|
-
stepCount: state.stepCount || 0,
|
|
74
|
-
filesTouched: state.filesTouched || [],
|
|
75
|
-
tokenUsage: state.tokenUsage || {},
|
|
76
|
-
startedAt: state.startedAt,
|
|
77
|
-
endedAt: state.endedAt,
|
|
78
|
-
source: "live",
|
|
79
|
-
},
|
|
80
|
-
context: `Session ${state.sessionID} (${state.phase})`,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// ── 2. Committed checkpoint via CheckpointStore ────────────────────────
|
|
88
|
-
try {
|
|
89
|
-
if (sessionlog.createCheckpointStore) {
|
|
90
|
-
const store = sessionlog.createCheckpointStore();
|
|
91
|
-
const content = await store.readSessionContent(checkpointId, 0);
|
|
92
|
-
if (content) {
|
|
93
|
-
return {
|
|
94
|
-
transcript: content.transcript,
|
|
95
|
-
prompts: content.prompts,
|
|
96
|
-
metadata: { ...content.metadata, source: "committed" },
|
|
97
|
-
context: content.context,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Checkpoint not found or store unavailable
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
10
|
/**
|
|
108
11
|
* Create a trajectory reporter that sends checkpoints to the MAP hub
|
|
109
|
-
* and serves
|
|
12
|
+
* and serves content on demand.
|
|
110
13
|
*/
|
|
111
14
|
export function createTrajectoryReporter(connection, config) {
|
|
112
15
|
// Cache the resource_id from the first checkpoint response
|
|
113
16
|
// so subsequent calls reuse it (avoids creating duplicate session resources)
|
|
114
17
|
let cachedResourceId;
|
|
115
|
-
// Build session directory search list
|
|
116
|
-
const defaultDirs = [];
|
|
117
|
-
try {
|
|
118
|
-
const cwd = process.cwd();
|
|
119
|
-
defaultDirs.push(`${cwd}/.git/sessionlog-sessions`, `${cwd}/.swarm/sessionlog/sessions`);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
// Can't resolve paths — will use config dirs only
|
|
123
|
-
}
|
|
124
|
-
const sessionDirs = [...(config.sessionDirs ?? []), ...defaultDirs];
|
|
125
18
|
// Handler for inbound content requests
|
|
126
19
|
const contentHandler = async (params) => {
|
|
127
20
|
const req = params;
|
|
128
21
|
if (!req?.request_id)
|
|
129
22
|
return;
|
|
130
23
|
try {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
await connection.sendNotification("trajectory/content.response", {
|
|
143
|
-
request_id: req.request_id,
|
|
144
|
-
transcript: "",
|
|
145
|
-
metadata: { source: "macro-agent" },
|
|
146
|
-
prompts: "",
|
|
147
|
-
context: "",
|
|
148
|
-
});
|
|
149
|
-
}
|
|
24
|
+
// Respond with what we have — macro-agent doesn't store full transcripts
|
|
25
|
+
// like sessionlog does, so we send a minimal response.
|
|
26
|
+
// Future: integrate with ACP session history for richer content.
|
|
27
|
+
await connection.sendNotification("trajectory/content.response", {
|
|
28
|
+
request_id: req.request_id,
|
|
29
|
+
transcript: null,
|
|
30
|
+
metadata: {
|
|
31
|
+
source: "macro-agent",
|
|
32
|
+
note: "Full transcript serving not yet implemented",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
150
35
|
}
|
|
151
36
|
catch {
|
|
37
|
+
// Best effort
|
|
152
38
|
try {
|
|
153
39
|
await connection.sendNotification("trajectory/content.response", {
|
|
154
40
|
request_id: req.request_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trajectory-reporter.js","sourceRoot":"","sources":["../../src/map/trajectory-reporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trajectory-reporter.js","sourceRoot":"","sources":["../../src/map/trajectory-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4BH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAAgC,EAChC,MAAqD;IAErD,2DAA2D;IAC3D,6EAA6E;IAC7E,IAAI,gBAAoC,CAAC;IAEzC,uCAAuC;IACvC,MAAM,cAAc,GAAG,KAAK,EAAE,M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AAO,GAAG,EAAE,CAAC;gBACb,kDAAkD;gBAClD,IAAI,CAAC;oBACH,MAAM,UAAU,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;wBACzD,UAAU;qBACX,CAAC,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,6CAA6C;gBAC/C,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI;YACF,UAAU,CAAC,eAAe,CACxB,4BAA4B,EAC5B,cAAc,CACf,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/map/types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface MAPSidecarConfig {
|
|
|
23
23
|
credential?: string;
|
|
24
24
|
/** Agent name for MAP registration (default: "macro-agent-sidecar") */
|
|
25
25
|
agentName?: string;
|
|
26
|
+
/** Swarm ID for stable identity across reconnections */
|
|
27
|
+
swarmId?: string;
|
|
26
28
|
/** Trajectory sync level */
|
|
27
29
|
trajectorySyncLevel?: "off" | "lifecycle" | "metrics" | "full";
|
|
28
30
|
/** Mesh transport (agentic-mesh P2P) */
|
|
@@ -103,6 +105,43 @@ export interface TrajectoryContentRequest {
|
|
|
103
105
|
request_id: string;
|
|
104
106
|
checkpoint_id: string;
|
|
105
107
|
}
|
|
108
|
+
/** Inbound task assignment from hub */
|
|
109
|
+
export interface CoordinationTaskAssign {
|
|
110
|
+
title: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
assigned_to?: string;
|
|
113
|
+
assigned_by: string;
|
|
114
|
+
priority?: string;
|
|
115
|
+
context?: Record<string, unknown>;
|
|
116
|
+
deadline?: string;
|
|
117
|
+
}
|
|
118
|
+
/** Inbound task status update from hub */
|
|
119
|
+
export interface CoordinationTaskStatus {
|
|
120
|
+
task_id: string;
|
|
121
|
+
status: string;
|
|
122
|
+
progress?: number;
|
|
123
|
+
result?: unknown;
|
|
124
|
+
error?: string;
|
|
125
|
+
}
|
|
126
|
+
/** Inbound context share from hub */
|
|
127
|
+
export interface CoordinationContextShare {
|
|
128
|
+
hive_id?: string;
|
|
129
|
+
source_swarm_id: string;
|
|
130
|
+
context_type: string;
|
|
131
|
+
data: unknown;
|
|
132
|
+
target_swarm_ids?: string[];
|
|
133
|
+
ttl_seconds?: number;
|
|
134
|
+
}
|
|
135
|
+
/** Inbound message from hub */
|
|
136
|
+
export interface CoordinationMessage {
|
|
137
|
+
hive_id?: string;
|
|
138
|
+
from_swarm_id: string;
|
|
139
|
+
to_swarm_id: string;
|
|
140
|
+
content_type: string;
|
|
141
|
+
content: unknown;
|
|
142
|
+
reply_to?: string;
|
|
143
|
+
metadata?: Record<string, unknown>;
|
|
144
|
+
}
|
|
106
145
|
/** Task bridge interface for emitting task events to MAP */
|
|
107
146
|
export interface TaskBridge {
|
|
108
147
|
taskCreated(task: {
|
package/dist/map/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/map/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMvE,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;IAEf,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,KAAK,GAAG,WAAW,GA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QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAED,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,CACd,UAAU,EAAE,2BAA2B,GACtC,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAC9C,IAAI,IAAI,IAAI,CAAC;CACd;AAMD,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,uBAAuB;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,sBAAsB;IACtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,4BAA4B;IAC5B,MAAM,IAAI,MAAM,CAAC;IACjB,uCAAuC;IACvC,kBAAkB,IAAI,MAAM,CAAC;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "macro-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Interact with multiple agents as if they were a single agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,11 +49,10 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
52
|
-
"@multi-agent-protocol/sdk": "^0.1.
|
|
52
|
+
"@multi-agent-protocol/sdk": "^0.1.11",
|
|
53
53
|
"@sudocode-ai/claude-code-acp": "^0.13.9",
|
|
54
54
|
"acp-factory": "^0.1.12",
|
|
55
55
|
"agent-inbox": "^0.1.8",
|
|
56
|
-
"agent-workspace": "^0.1.5",
|
|
57
56
|
"better-sqlite3": "^12.5.0",
|
|
58
57
|
"chalk": "^5.6.2",
|
|
59
58
|
"commander": "^14.0.2",
|
|
@@ -149,7 +149,7 @@ describe("Cognitive Workspace E2E", () => {
|
|
|
149
149
|
expect(sentMessages.length).toBe(1);
|
|
150
150
|
const result = sentMessages[0] as any;
|
|
151
151
|
expect(result.jsonrpc).toBe("2.0");
|
|
152
|
-
expect(result.method).toBe("x-
|
|
152
|
+
expect(result.method).toBe("x-openhive/learning.workspace.result");
|
|
153
153
|
expect(result.params.request_id).toBe("e2e-001");
|
|
154
154
|
expect(result.params.duration_ms).toBeGreaterThanOrEqual(0);
|
|
155
155
|
// Success or failure depends on whether mocked agent wrote output
|
package/src/acp/macro-agent.ts
CHANGED
|
@@ -414,11 +414,8 @@ export function createMacroAgent(
|
|
|
414
414
|
params: NewSessionRequest,
|
|
415
415
|
): Promise<NewSessionResponse> {
|
|
416
416
|
const cwd = params.cwd ?? defaultCwd;
|
|
417
|
-
|
|
418
417
|
// Get or create a head manager for this workspace
|
|
419
|
-
const headManager = await agentManager.getOrCreateHeadManager({
|
|
420
|
-
cwd,
|
|
421
|
-
});
|
|
418
|
+
const headManager = await agentManager.getOrCreateHeadManager({ cwd });
|
|
422
419
|
|
|
423
420
|
// Create session mapping
|
|
424
421
|
const mapping = sessionMapper.createMapping(
|
package/src/boot-v2.ts
CHANGED
|
@@ -110,6 +110,7 @@ export interface BootV2Config {
|
|
|
110
110
|
systemId?: string;
|
|
111
111
|
credential?: string;
|
|
112
112
|
agentName?: string;
|
|
113
|
+
swarmId?: string;
|
|
113
114
|
trajectorySyncLevel?: "off" | "lifecycle" | "metrics" | "full";
|
|
114
115
|
reconnectIntervalMs?: number;
|
|
115
116
|
reconnection?: {
|
|
@@ -476,6 +477,7 @@ export async function bootV2(
|
|
|
476
477
|
systemId: config.map.systemId,
|
|
477
478
|
credential: config.map.credential,
|
|
478
479
|
agentName: config.map.agentName,
|
|
480
|
+
swarmId: config.map.swarmId,
|
|
479
481
|
trajectorySyncLevel: config.map.trajectorySyncLevel,
|
|
480
482
|
reconnectIntervalMs: config.map.reconnectIntervalMs,
|
|
481
483
|
reconnection: config.map.reconnection,
|
|
@@ -52,15 +52,7 @@ function createMockBackend(session?: CognitiveAgentSession): MacroAgentBackend {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
describe("isWorkspaceExecuteMessage", () => {
|
|
55
|
-
it("should return true for
|
|
56
|
-
expect(
|
|
57
|
-
isWorkspaceExecuteMessage({
|
|
58
|
-
method: "x-workspace/task.execute",
|
|
59
|
-
}),
|
|
60
|
-
).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should return true for legacy x-openhive/learning.workspace.execute", () => {
|
|
55
|
+
it("should return true for workspace.execute messages", () => {
|
|
64
56
|
expect(
|
|
65
57
|
isWorkspaceExecuteMessage({
|
|
66
58
|
method: "x-openhive/learning.workspace.execute",
|
|
@@ -119,7 +111,7 @@ describe("handleWorkspaceExecute", () => {
|
|
|
119
111
|
expect(sentMessages.length).toBe(1);
|
|
120
112
|
const result = sentMessages[0] as any;
|
|
121
113
|
expect(result.jsonrpc).toBe("2.0");
|
|
122
|
-
expect(result.method).toBe("x-
|
|
114
|
+
expect(result.method).toBe("x-openhive/learning.workspace.result");
|
|
123
115
|
expect(result.params.request_id).toBe("req-001");
|
|
124
116
|
expect(result.params.success).toBe(true);
|
|
125
117
|
expect(result.params.duration_ms).toBeGreaterThanOrEqual(0);
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workspace Execution Handler
|
|
3
3
|
*
|
|
4
|
-
* Bridge between workspace
|
|
4
|
+
* Bridge between OpenHive's workspace.execute MAP messages and
|
|
5
5
|
* macro-agent's MacroAgentBackend. Receives workspace tasks from
|
|
6
|
-
*
|
|
6
|
+
* OpenHive, spawns analyst agents, and sends results back.
|
|
7
7
|
*
|
|
8
8
|
* Registered as a MAP notification handler on the swarm's inbound
|
|
9
|
-
* WebSocket connection to the hub.
|
|
9
|
+
* WebSocket connection to the OpenHive hub.
|
|
10
10
|
*
|
|
11
|
-
* Protocol
|
|
12
|
-
*
|
|
11
|
+
* Protocol:
|
|
12
|
+
* Hive → Swarm: x-openhive/learning.workspace.execute
|
|
13
13
|
* { request_id, prompt, cwd, system_context, timeout }
|
|
14
|
-
* Swarm →
|
|
14
|
+
* Swarm → Hive: x-openhive/learning.workspace.result
|
|
15
15
|
* { request_id, success, output, structured, duration_ms }
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { WORKSPACE_METHODS, WORKSPACE_METHODS_LEGACY } from "agent-workspace";
|
|
19
|
-
import type { WorkspaceExecuteParams, WorkspaceResultParams } from "agent-workspace";
|
|
20
18
|
import type { MacroAgentBackend } from "./macro-agent-backend.js";
|
|
21
19
|
import type { CognitiveAgentSpawnConfig } from "./types.js";
|
|
22
20
|
|
|
@@ -26,8 +24,13 @@ export interface WorkspaceHandlerDeps {
|
|
|
26
24
|
sendToHub: (message: object) => void;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export interface WorkspaceExecuteParams {
|
|
28
|
+
request_id: string;
|
|
29
|
+
prompt: string;
|
|
30
|
+
cwd: string;
|
|
31
|
+
system_context?: string;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* Handle an incoming workspace.execute request from OpenHive.
|
|
@@ -76,7 +79,7 @@ export async function handleWorkspaceExecute(
|
|
|
76
79
|
await backend.terminate(session.id).catch(() => {});
|
|
77
80
|
sendToHub({
|
|
78
81
|
jsonrpc: "2.0",
|
|
79
|
-
method:
|
|
82
|
+
method: "x-openhive/learning.workspace.result",
|
|
80
83
|
params: {
|
|
81
84
|
request_id,
|
|
82
85
|
success: false,
|
|
@@ -125,7 +128,7 @@ export async function handleWorkspaceExecute(
|
|
|
125
128
|
|
|
126
129
|
sendToHub({
|
|
127
130
|
jsonrpc: "2.0",
|
|
128
|
-
method:
|
|
131
|
+
method: "x-openhive/learning.workspace.result",
|
|
129
132
|
params: {
|
|
130
133
|
request_id,
|
|
131
134
|
success: finalSession.state === "completed",
|
|
@@ -138,7 +141,7 @@ export async function handleWorkspaceExecute(
|
|
|
138
141
|
} catch (err) {
|
|
139
142
|
sendToHub({
|
|
140
143
|
jsonrpc: "2.0",
|
|
141
|
-
method:
|
|
144
|
+
method: "x-openhive/learning.workspace.result",
|
|
142
145
|
params: {
|
|
143
146
|
request_id,
|
|
144
147
|
success: false,
|
|
@@ -155,6 +158,6 @@ export async function handleWorkspaceExecute(
|
|
|
155
158
|
*/
|
|
156
159
|
export function isWorkspaceExecuteMessage(
|
|
157
160
|
msg: { method?: string },
|
|
158
|
-
):
|
|
159
|
-
return msg.method ===
|
|
161
|
+
): msg is { method: "x-openhive/learning.workspace.execute"; params: WorkspaceExecuteParams } {
|
|
162
|
+
return msg.method === "x-openhive/learning.workspace.execute";
|
|
160
163
|
}
|