jaxon-agents 0.1.0 → 0.3.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/README.agent.md +203 -168
- package/README.md +51 -34
- package/README.zh-CN.md +55 -38
- package/dist/BUILD_INFO.json +3 -3
- package/dist/PACKAGE_MANIFEST.json +63 -42
- package/dist/RELEASE_META.json +8 -2
- package/dist/agents/directory-store.js +66 -11
- package/dist/agents/jaxon-admin.entry.js +5 -3
- package/dist/agents/session-switch.js +6 -0
- package/dist/api/mcp-tools.js +76 -45
- package/dist/connections/health.js +4 -1
- package/dist/console/activity-client.js +644 -0
- package/dist/console/activity-page.js +24 -0
- package/dist/console/activity-topics.js +698 -0
- package/dist/console/activity.js +379 -0
- package/dist/console/assets.js +394 -241
- package/dist/console/chat-library.js +685 -0
- package/dist/console/console-info.js +30 -0
- package/dist/console/icons.js +14 -0
- package/dist/console/pages.js +94 -31
- package/dist/console/server.js +58 -8
- package/dist/console/station-pages.js +83 -25
- package/dist/daemon/client.js +1 -1
- package/dist/daemon/host.js +16 -3
- package/dist/environment/pi-launch-spec.js +1 -1
- package/dist/index.js +87 -8
- package/dist/launcher.js +17 -26
- package/dist/ops/catalog.js +18 -14
- package/dist/ops/core.js +157 -77
- package/dist/pi-host/history-reader.js +20 -0
- package/dist/pi-host/mcp-bridge.entry.js +55 -7
- package/dist/platform/index.js +22 -0
- package/dist/platform/linux.js +64 -0
- package/dist/release/handoff.js +6 -8
- package/dist/release/store.js +3 -13
- package/dist/sessions/dashboard-usage.js +5 -3
- package/dist/sessions/supervisor.js +449 -60
- package/dist/stations/activity.js +24 -28
- package/dist/stations/boards.js +10 -5
- package/dist/stations/cues.js +71 -48
- package/dist/stations/interactions.js +75 -0
- package/dist/stations/member-instructions.js +23 -0
- package/dist/stations/station-member.entry.js +31 -14
- package/examples/README.md +23 -8
- package/examples/agents/README.md +93 -35
- package/examples/agents/coder/README.md +37 -0
- package/examples/agents/custom-gateway/README.md +42 -0
- package/examples/agents/local-qwen/README.md +46 -0
- package/examples/agents/planner/README.md +39 -0
- package/examples/agents/reviewer/README.md +42 -0
- package/examples/mcp-clients/README.md +35 -16
- package/examples/stations/README.md +98 -21
- package/examples/stations/dev-loop/README.md +40 -0
- package/examples/stations/parallel-coders/README.md +40 -0
- package/examples/stations/parallel-coders/STATION.md +2 -2
- package/examples/stations/research-writer/README.md +39 -0
- package/examples/stations/research-writer/STATION.md +1 -1
- package/examples/workflows/01-dev-loop-e2e.md +27 -5
- package/examples/workflows/02-human-auth-and-roster-switch.md +25 -3
- package/examples/workflows/README.md +17 -0
- package/package.json +8 -2
- package/runtime/provenance.json +3 -3
- package/runtime/runtime-lock.json +2 -2
- package/runtime/runtime-package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { copySkill, overlaySkills, skillEntries, skillsLocation, workingSkills } from "./skills-directory.js";
|
|
2
2
|
import { changeServer, serverChange } from "./mcp-server-config.js";
|
|
3
|
+
import { defaultSessionSwitch, isSessionSwitch, sessionSwitchKey, sessionSwitchValues } from "./session-switch.js";
|
|
3
4
|
import * as fs from "node:fs";
|
|
4
5
|
import * as net from "node:net";
|
|
5
6
|
import * as path from "node:path";
|
|
@@ -85,6 +86,22 @@ export function current(name, revision) {
|
|
|
85
86
|
return { presetId: read(path.join(dir, "PRESET_ID")), rev, dir: revDir };
|
|
86
87
|
}
|
|
87
88
|
export const settingsOf = (dir) => readJson(path.join(dir, "settings.json"), {});
|
|
89
|
+
export function sessionSwitchFields(name, dir) {
|
|
90
|
+
if (name === JAXON)
|
|
91
|
+
return {};
|
|
92
|
+
let source = dir;
|
|
93
|
+
if (!source) {
|
|
94
|
+
try {
|
|
95
|
+
source = current(name).dir;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error?.code !== "PRESET_NOT_FOUND")
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const value = source ? settingsOf(source)?.[sessionSwitchKey] : undefined;
|
|
103
|
+
return { session_switch: isSessionSwitch(value) ? value : defaultSessionSwitch };
|
|
104
|
+
}
|
|
88
105
|
export const harnessOf = (dir) => {
|
|
89
106
|
const h = readJson(path.join(dir, "harness.json"), {});
|
|
90
107
|
return { connection: typeof h.connection === "string" && h.connection ? h.connection : null };
|
|
@@ -185,7 +202,7 @@ export function getPresetRedacted(name, includeFiles = true) {
|
|
|
185
202
|
catch { }
|
|
186
203
|
return {
|
|
187
204
|
name, description: description(name), preset_id: presetId, revision: rev,
|
|
188
|
-
connection: harnessOf(dir).connection, files, mcp_credentials_configured: mcp,
|
|
205
|
+
connection: harnessOf(dir).connection, files, mcp_credentials_configured: mcp, ...sessionSwitchFields(name, dir),
|
|
189
206
|
revisions: fs.readdirSync(path.join(presetDir(name), "revisions")).filter((r) => /^rev_/.test(r)).sort(),
|
|
190
207
|
};
|
|
191
208
|
}
|
|
@@ -209,6 +226,34 @@ function applyPatch(revDir, patch) {
|
|
|
209
226
|
}
|
|
210
227
|
}
|
|
211
228
|
}
|
|
229
|
+
function validateSessionSwitch(name, value, present) {
|
|
230
|
+
if (!present)
|
|
231
|
+
return;
|
|
232
|
+
if (name === JAXON)
|
|
233
|
+
fail("INVALID_ARGUMENT", "Session switch policy does not apply to JaXon", { field: "session_switch" });
|
|
234
|
+
if (!isSessionSwitch(value))
|
|
235
|
+
fail("INVALID_ARGUMENT", `Session switch policy must be one of: ${sessionSwitchValues.join(", ")}`, { field: "session_switch" });
|
|
236
|
+
}
|
|
237
|
+
function applySessionSwitch(name, dir, value) {
|
|
238
|
+
const settings = settingsOf(dir);
|
|
239
|
+
const hasSetting = settings != null && Object.hasOwn(settings, sessionSwitchKey);
|
|
240
|
+
validateSessionSwitch(name, settings?.[sessionSwitchKey], hasSetting);
|
|
241
|
+
if (value === undefined)
|
|
242
|
+
return;
|
|
243
|
+
if (name === JAXON)
|
|
244
|
+
fail("INVALID_ARGUMENT", "Session switch policy does not apply to JaXon", { field: "session_switch" });
|
|
245
|
+
if (value === null && !hasSetting)
|
|
246
|
+
return;
|
|
247
|
+
if (!settings || typeof settings !== "object" || Array.isArray(settings))
|
|
248
|
+
fail("INVALID_ARGUMENT", "settings.json must be an object to set a session switch policy", { field: "session_switch" });
|
|
249
|
+
if (value === null)
|
|
250
|
+
delete settings[sessionSwitchKey];
|
|
251
|
+
else {
|
|
252
|
+
validateSessionSwitch(name, value, true);
|
|
253
|
+
settings[sessionSwitchKey] = value;
|
|
254
|
+
}
|
|
255
|
+
fs.writeFileSync(path.join(dir, "settings.json"), JSON.stringify(settings, null, 2) + "\n");
|
|
256
|
+
}
|
|
212
257
|
function validateRevision(dir) {
|
|
213
258
|
const settings = settingsOf(dir);
|
|
214
259
|
const { connection } = harnessOf(dir);
|
|
@@ -221,7 +266,7 @@ function validateRevision(dir) {
|
|
|
221
266
|
return fail("CONNECTION_PROVIDER_MISMATCH", `${connection} is ${meta.provider}, preset needs ${settings.defaultProvider}`, { connection_id: connection, expected_provider: settings.defaultProvider });
|
|
222
267
|
}
|
|
223
268
|
/** Builds a complete revision off to the side, validates it, then atomically switches CURRENT. */
|
|
224
|
-
function publish(name, fromDir, patch, revNo, populate) {
|
|
269
|
+
function publish(name, fromDir, patch, revNo, populate, sessionSwitch) {
|
|
225
270
|
const dir = presetDir(name);
|
|
226
271
|
const rev = `rev_${String(revNo).padStart(4, "0")}`;
|
|
227
272
|
const tmp = path.join(dir, `.tmp_${rev}_${process.pid}`);
|
|
@@ -237,6 +282,7 @@ function publish(name, fromDir, patch, revNo, populate) {
|
|
|
237
282
|
fs.mkdirSync(tmp, { recursive: true });
|
|
238
283
|
applyPatch(tmp, patch);
|
|
239
284
|
populate?.(tmp);
|
|
285
|
+
applySessionSwitch(name, tmp, sessionSwitch);
|
|
240
286
|
validateRevision(tmp);
|
|
241
287
|
}
|
|
242
288
|
catch (e) {
|
|
@@ -262,7 +308,7 @@ function publish(name, fromDir, patch, revNo, populate) {
|
|
|
262
308
|
}
|
|
263
309
|
return rev;
|
|
264
310
|
}
|
|
265
|
-
function createFrom(name, fromDir, patch, desc) {
|
|
311
|
+
function createFrom(name, fromDir, patch, desc, sessionSwitch) {
|
|
266
312
|
return withPresetLock(name, () => {
|
|
267
313
|
const dir = presetDir(name);
|
|
268
314
|
if (fs.existsSync(path.join(dir, "CURRENT")))
|
|
@@ -270,14 +316,14 @@ function createFrom(name, fromDir, patch, desc) {
|
|
|
270
316
|
const presetId = `pst_${randomUUID().replace(/-/g, "")}`;
|
|
271
317
|
fs.mkdirSync(dir, { recursive: true });
|
|
272
318
|
try {
|
|
273
|
-
const rev = publish(name, fromDir, patch, 1);
|
|
319
|
+
const rev = publish(name, fromDir, patch, 1, undefined, sessionSwitch);
|
|
274
320
|
fs.writeFileSync(path.join(dir, "PRESET_ID"), presetId + "\n");
|
|
275
321
|
fs.writeFileSync(descriptionFile(name), desc.trim() + "\n");
|
|
276
322
|
const cred = path.join(dir, "credentials");
|
|
277
323
|
fs.mkdirSync(cred, { recursive: true, mode: 0o700 });
|
|
278
324
|
if (!fs.existsSync(path.join(cred, "mcp-auth.json")))
|
|
279
325
|
fs.writeFileSync(path.join(cred, "mcp-auth.json"), "{}", { mode: 0o600 });
|
|
280
|
-
return { name, preset_id: presetId, revision: rev };
|
|
326
|
+
return { name, preset_id: presetId, revision: rev, ...sessionSwitchFields(name, path.join(dir, "revisions", rev)) };
|
|
281
327
|
}
|
|
282
328
|
catch (e) {
|
|
283
329
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
@@ -285,8 +331,8 @@ function createFrom(name, fromDir, patch, desc) {
|
|
|
285
331
|
}
|
|
286
332
|
});
|
|
287
333
|
}
|
|
288
|
-
export function createPreset(name, patch, desc) {
|
|
289
|
-
return createFrom(name, null, patch, desc);
|
|
334
|
+
export function createPreset(name, patch, desc, sessionSwitch) {
|
|
335
|
+
return createFrom(name, null, patch, desc, sessionSwitch);
|
|
290
336
|
}
|
|
291
337
|
export async function duplicatePreset(source, name, o) {
|
|
292
338
|
const src = current(source, o.from_revision);
|
|
@@ -309,7 +355,7 @@ export async function duplicatePreset(source, name, o) {
|
|
|
309
355
|
if (custom.modelsJson && !patch["models.json"])
|
|
310
356
|
patch["models.json"] = custom.modelsJson;
|
|
311
357
|
}
|
|
312
|
-
const result = await createFrom(name, src.dir, patch, o.description ?? description(source));
|
|
358
|
+
const result = await createFrom(name, src.dir, patch, o.description ?? description(source), o.session_switch);
|
|
313
359
|
let mcpAuth = [];
|
|
314
360
|
try {
|
|
315
361
|
mcpAuth = Object.keys(readJson(path.join(mcpCredentialSource(source, src.presetId), "mcp-auth.json"), {}));
|
|
@@ -317,16 +363,17 @@ export async function duplicatePreset(source, name, o) {
|
|
|
317
363
|
catch { }
|
|
318
364
|
return { ...result, not_copied: { mcp_auth: mcpAuth } };
|
|
319
365
|
}
|
|
320
|
-
export function updatePresetRevision(name, patch, expectedRev, desc, fromRevision) {
|
|
366
|
+
export function updatePresetRevision(name, patch, expectedRev, desc, fromRevision, sessionSwitch) {
|
|
321
367
|
return withPresetLock(name, () => {
|
|
322
368
|
const cur = current(name);
|
|
323
369
|
if (expectedRev && expectedRev !== cur.rev)
|
|
324
370
|
fail("REVISION_CONFLICT", `current is ${cur.rev}`);
|
|
325
371
|
const base = fromRevision ? current(name, fromRevision) : cur;
|
|
372
|
+
const rev = Object.keys(patch).length || fromRevision || sessionSwitch !== undefined
|
|
373
|
+
? publish(name, base.dir, patch, Number(cur.rev.slice(4)) + 1, undefined, sessionSwitch) : cur.rev;
|
|
326
374
|
if (desc !== undefined)
|
|
327
375
|
writeAtomic(descriptionFile(name), desc.trim() + "\n");
|
|
328
|
-
|
|
329
|
-
return { name, preset_id: cur.presetId, revision: rev, description: description(name) };
|
|
376
|
+
return { name, preset_id: cur.presetId, revision: rev, description: description(name), ...sessionSwitchFields(name) };
|
|
330
377
|
});
|
|
331
378
|
}
|
|
332
379
|
export function listMcpServers(name, revision) {
|
|
@@ -433,6 +480,14 @@ export function snapshotRevision(name, targetDir, revision) {
|
|
|
433
480
|
const cur = current(name, revision);
|
|
434
481
|
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
435
482
|
fs.cpSync(cur.dir, targetDir, { recursive: true, verbatimSymlinks: true });
|
|
483
|
+
// Only JaXon uses this key. Keep it out of Pi's runtime settings, including probe snapshots.
|
|
484
|
+
const settings = settingsOf(targetDir);
|
|
485
|
+
if (settings != null && Object.hasOwn(settings, sessionSwitchKey)) {
|
|
486
|
+
delete settings[sessionSwitchKey];
|
|
487
|
+
const file = path.join(targetDir, "settings.json");
|
|
488
|
+
fs.rmSync(file);
|
|
489
|
+
fs.writeFileSync(file, JSON.stringify(settings, null, 2) + "\n");
|
|
490
|
+
}
|
|
436
491
|
if (!revision || read(path.join(presetDir(name), "CURRENT")) === revision)
|
|
437
492
|
overlaySkills(cur.dir, targetDir);
|
|
438
493
|
const { connection } = harnessOf(cur.dir);
|
|
@@ -2,6 +2,7 @@ import { adminScope } from "./admin-scope.js";
|
|
|
2
2
|
import * as net from "node:net";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
|
+
import { sessionSwitchValues } from "./session-switch.js";
|
|
5
6
|
import { computeFingerprint } from "../daemon/fingerprint.js";
|
|
6
7
|
import { RELEASE } from "../root.js";
|
|
7
8
|
// Old daemons only check client fingerprints on MCP connections.
|
|
@@ -70,21 +71,22 @@ export default function jaxonAdmin(pi) {
|
|
|
70
71
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], details: {} };
|
|
71
72
|
},
|
|
72
73
|
});
|
|
74
|
+
const session_switch = Type.Optional(Type.Union([...sessionSwitchValues.map(value => Type.Literal(value)), Type.Null()], { description: "How much context redundancy this role tolerates. Null clears it to Balanced. Not applicable to JaXon." }));
|
|
73
75
|
tool("agent_list", "List presets with connections and readiness.", Type.Object({}));
|
|
74
76
|
tool("agent_get", "Get a preset's redacted files, revisions and readiness.", Type.Object({ name: Type.String() }));
|
|
75
77
|
tool("agent_create", "Create a preset. A connection is optional but required before it can become ready.", Type.Object({
|
|
76
78
|
name: Type.String(), description: Type.String(), provider: Type.Optional(Type.String()), model: Type.Optional(Type.String()),
|
|
77
79
|
connection: Type.Optional(Type.Union([Type.String(), Type.Null()])), thinking: Type.Optional(Type.String()),
|
|
78
|
-
tools: Type.Optional(Type.Array(Type.String())), instructions: Type.Optional(Type.String()), files: Type.Optional(Patch),
|
|
80
|
+
tools: Type.Optional(Type.Array(Type.String())), instructions: Type.Optional(Type.String()), files: Type.Optional(Patch), session_switch,
|
|
79
81
|
}));
|
|
80
82
|
tool("agent_duplicate", "Duplicate a preset with optional overrides. Shared model auth is reused; MCP auth is not copied.", Type.Object({
|
|
81
83
|
source: Type.String(), name: Type.String(), description: Type.Optional(Type.String()), from_revision: Type.Optional(Type.String()),
|
|
82
84
|
instructions: Type.Optional(Type.String()), tools: Type.Optional(Type.Array(Type.String())), thinking: Type.Optional(Type.String()),
|
|
83
|
-
model: Type.Optional(Type.String()), connection: Type.Optional(Type.Union([Type.String(), Type.Null()])), patch: Type.Optional(Patch),
|
|
85
|
+
model: Type.Optional(Type.String()), connection: Type.Optional(Type.Union([Type.String(), Type.Null()])), patch: Type.Optional(Patch), session_switch,
|
|
84
86
|
}));
|
|
85
87
|
tool("agent_update", "Publish a revision, change description/connection, or roll back from_revision.", Type.Object({
|
|
86
88
|
name: Type.String(), patch: Type.Optional(Patch), description: Type.Optional(Type.String()),
|
|
87
|
-
connection: Type.Optional(Type.Union([Type.String(), Type.Null()])), from_revision: Type.Optional(Type.String()), expected_rev: Type.Optional(Type.String()),
|
|
89
|
+
connection: Type.Optional(Type.Union([Type.String(), Type.Null()])), from_revision: Type.Optional(Type.String()), expected_rev: Type.Optional(Type.String()), session_switch,
|
|
88
90
|
}));
|
|
89
91
|
tool("agent_delete", "Delete a non-JaXon preset.", Type.Object({ name: Type.String(), expected_rev: Type.Optional(Type.String()) }));
|
|
90
92
|
tool("agent_test", "Run or await a real Pi readiness test.", Type.Object({ name: Type.String(), wait_ms: Type.Optional(Type.Number()) }));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const sessionSwitchKey = "jaxonSessionSwitch";
|
|
2
|
+
export const sessionSwitchValues = ["strictly_eager", "eager", "balanced", "conservative"];
|
|
3
|
+
export const defaultSessionSwitch = "balanced";
|
|
4
|
+
export function isSessionSwitch(value) {
|
|
5
|
+
return sessionSwitchValues.some(choice => choice === value);
|
|
6
|
+
}
|
package/dist/api/mcp-tools.js
CHANGED
|
@@ -1,67 +1,70 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
1
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { fail, errorData } from "../ops/errors.js";
|
|
5
5
|
import { operationSchema } from "../ops/catalog.js";
|
|
6
6
|
import { APP_VERSION } from "../root.js";
|
|
7
|
+
import { consoleInfoFrom, consoleUrl } from "../console/console-info.js";
|
|
7
8
|
export const SERVER_INSTRUCTIONS = `jaxon-agents hosts isolated Pi sub-agent sessions. Start work with session_start,
|
|
8
9
|
follow up with session_send, answer blocking prompts with session_reply, and close
|
|
9
10
|
sessions you no longer need. Delegate authority: pass the goal, hard boundaries and
|
|
10
|
-
board references,
|
|
11
|
-
pre-write checklists—leave how to plan, code, test or review to the sub-agent.
|
|
11
|
+
board references, and leave how to plan, code, test or review to the sub-agent.
|
|
12
12
|
|
|
13
13
|
Waiting policy
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
- session_list returns an immediate snapshot of all sessions; read it whenever you
|
|
15
|
+
need the collective state.
|
|
16
|
+
- session_read(after=<latest cursor>, wait_ms) waits for one member: it returns on
|
|
17
|
+
turn end, input, failure or close, so a generous wait costs nothing when work
|
|
18
|
+
finishes early.
|
|
19
|
+
- After starting or sending, first start other independent sub-agents or do your own
|
|
20
|
+
parallel work; block only when nothing else can proceed.
|
|
19
21
|
- wait_ms is unlimited: try 60-120 s for research/coding and 20-40 s for a short
|
|
20
|
-
follow-up. After a timeout, roughly double during early/mid-stage work
|
|
21
|
-
to 20-30 s
|
|
22
|
-
- While tools continue without a wrap-up, lengthen the next wait (60 -> 120 ->
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
times out a wait, simply call it again with the same cursor.
|
|
22
|
+
follow-up. After a timeout, roughly double during early/mid-stage work and shorten
|
|
23
|
+
to 20-30 s for final checks, a report or a closing summary.
|
|
24
|
+
- While tools continue without a wrap-up, lengthen the next wait (60 -> 120 -> 240 s).
|
|
25
|
+
A board_write alone signals a normal step; shorten the wait for a closing summary.
|
|
26
|
+
- Pass the latest cursor on every wait; after a client timeout, call again with the
|
|
27
|
+
same cursor.
|
|
27
28
|
|
|
28
29
|
What you see
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
- History omits thinking by default and counts it in thinking_omitted. include_thinking
|
|
31
|
+
opts in; thinking greatly enlarges the context, so prefer actions, boards and results.
|
|
32
|
+
Usage includes reasoning tokens.
|
|
32
33
|
|
|
33
34
|
Human-only blocks and retries
|
|
34
35
|
- On NEEDS_HUMAN_AUTH, relay user_action and console_url to the user, then retry
|
|
35
|
-
resume.operation with resume.arguments unchanged.
|
|
36
|
+
resume.operation with resume.arguments unchanged. Credentials stay out of context;
|
|
37
|
+
never ask for secrets.
|
|
38
|
+
- Console address: read resource jaxon://console or service_status.console_url.
|
|
36
39
|
- Write operations accept client_request_id; reuse it when retrying after
|
|
37
40
|
DAEMON_RESTARTED. Reads can simply be retried.
|
|
38
41
|
|
|
39
42
|
Stations
|
|
40
43
|
- Run specialised agents inside a Station: find it with station_search and pass
|
|
41
|
-
station=<id or name> to session_start.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- While several members are busy, wait
|
|
58
|
-
|
|
59
|
-
- A result carrying station_pending means a roster change is queued. It applies
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- You alone decide every next step; boards
|
|
44
|
+
station=<id or name> to session_start. Prefer a Station over running without one.
|
|
45
|
+
- You and every member share the same Station description. When no member of a Station
|
|
46
|
+
is active, your first call for that Station also returns the full description as
|
|
47
|
+
station_context; read it before dispatching, and use station_get to read it again.
|
|
48
|
+
- All sessions of one preset share its role board. Every turn injects the full master
|
|
49
|
+
and own boards; read others with board_read and merge peers' latest content before
|
|
50
|
+
rewriting (a version conflict returns the current content). Put goals, constraints,
|
|
51
|
+
acceptance criteria, the final plan and decisions on master before dispatching, and
|
|
52
|
+
update boards at phase changes, key steps, blockers and wrap-up. Writes apply to the
|
|
53
|
+
next turn: dispatch short instructions that point to boards instead of pasting plans
|
|
54
|
+
or reports.
|
|
55
|
+
- Use session_send to continue a session; busy calls queue, and delivery=steer
|
|
56
|
+
redirects the current turn. Use session_start for a fresh, parallel context; a role
|
|
57
|
+
may hold several equal sessions that all share its board. Members use cue to remind
|
|
58
|
+
peers to read boards; it wakes an idle peer, and a cue chain stops waking after 5
|
|
59
|
+
hops. Write conclusions on boards first.
|
|
60
|
+
- While several members are busy, wait on the member expected to finish first with
|
|
61
|
+
session_read(after=<its cursor>, wait_ms).
|
|
62
|
+
- A result carrying station_pending means a roster change is queued. It applies by
|
|
63
|
+
itself once no member turn is in flight and every leaving member's session is closed.
|
|
64
|
+
Stop dispatching new turns, let busy turns finish, answer or close the blocked_by
|
|
65
|
+
sessions, then read station_context(reason=revised). Remove temporary members once the
|
|
66
|
+
task is done.
|
|
67
|
+
- You alone decide every next step; boards inform that decision.`;
|
|
65
68
|
const ok = (data, images = []) => ({
|
|
66
69
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }, ...images],
|
|
67
70
|
structuredContent: data,
|
|
@@ -74,7 +77,7 @@ const err = (e) => {
|
|
|
74
77
|
export function createMcpServer(ops, connectionSignal) {
|
|
75
78
|
const server = new McpServer({ name: "jaxon-agents", version: APP_VERSION }, {
|
|
76
79
|
instructions: SERVER_INSTRUCTIONS,
|
|
77
|
-
capabilities: { tools: { listChanged: true } },
|
|
80
|
+
capabilities: { tools: { listChanged: true }, resources: { listChanged: true, subscribe: true } },
|
|
78
81
|
});
|
|
79
82
|
const tools = ops.publicOperationMetadata().map(({ name, description, schema }) => ({ name, description,
|
|
80
83
|
inputSchema: z.toJSONSchema(operationSchema({ name, schema }), { target: "draft-07", io: "input" }),
|
|
@@ -106,5 +109,33 @@ export function createMcpServer(ops, connectionSignal) {
|
|
|
106
109
|
return err(e);
|
|
107
110
|
}
|
|
108
111
|
});
|
|
112
|
+
// jaxon://console: the master's reference entry to the local console (PLAN §20.2.2).
|
|
113
|
+
// It carries no credentials; tools/list stays at 25 because a resource is not a tool.
|
|
114
|
+
const subscriptions = new Set();
|
|
115
|
+
const consoleInfo = () => consoleInfoFrom(ops.serviceInfo?.() ?? { console_url: ops.connections.consoleUrl });
|
|
116
|
+
server.registerResource("JaXon console", "jaxon://console", {
|
|
117
|
+
mimeType: "application/json",
|
|
118
|
+
description: "Local JaXon console address for reference: when human action is needed, relay the relevant page link to the user; do not push it repeatedly. The human entry point is `jaxon-agents console`.",
|
|
119
|
+
}, (uri) => ({ contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(consoleInfo(), null, 2) }] }));
|
|
120
|
+
server.registerResource("JaXon console station", new ResourceTemplate("jaxon://console/stations/{station}", { list: undefined }), {
|
|
121
|
+
mimeType: "application/json",
|
|
122
|
+
description: "Same as jaxon://console, plus the full URL of one Station page.",
|
|
123
|
+
}, (uri, variables) => {
|
|
124
|
+
const info = consoleInfo();
|
|
125
|
+
const station = String(variables.station ?? "");
|
|
126
|
+
return { contents: [{ uri: uri.href, mimeType: "application/json",
|
|
127
|
+
text: JSON.stringify({ ...info, station, station_url: consoleUrl(info, "/stations/" + encodeURIComponent(station)) }, null, 2) }] };
|
|
128
|
+
});
|
|
129
|
+
server.server.setRequestHandler(SubscribeRequestSchema, async ({ params }) => { subscriptions.add(params.uri); return {}; });
|
|
130
|
+
server.server.setRequestHandler(UnsubscribeRequestSchema, async ({ params }) => { subscriptions.delete(params.uri); return {}; });
|
|
131
|
+
// A relay replay of notifications/initialized (daemon restart, possibly a new port) must
|
|
132
|
+
// refresh tools and resources, and re-notify anyone subscribed to the console resource.
|
|
133
|
+
server.server.oninitialized = () => {
|
|
134
|
+
const send = (action) => { void action.catch(() => { }); };
|
|
135
|
+
send(server.server.sendToolListChanged());
|
|
136
|
+
send(server.server.sendResourceListChanged());
|
|
137
|
+
for (const uri of subscriptions)
|
|
138
|
+
send(server.server.sendResourceUpdated({ uri }));
|
|
139
|
+
};
|
|
109
140
|
return server;
|
|
110
141
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
3
4
|
import * as fs from "node:fs";
|
|
4
5
|
import * as path from "node:path";
|
|
5
6
|
import { STATE } from "../root.js";
|
|
@@ -12,7 +13,7 @@ const boundedAppend = (current, chunk) => {
|
|
|
12
13
|
return (current + chunk.toString("utf8")).slice(0, OUTPUT_LIMIT);
|
|
13
14
|
};
|
|
14
15
|
/** Runs Pi without a shell and with the same scrubbed environment as managed sessions. */
|
|
15
|
-
export function runPi(args, agentDir, home, cwd, timeout, extraEnv = {}) {
|
|
16
|
+
export function runPi(args, agentDir, home, cwd, timeout, extraEnv = {}, onStdoutLine) {
|
|
16
17
|
if (!args.length)
|
|
17
18
|
throw new Error("runPi requires an executable");
|
|
18
19
|
fs.mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
@@ -43,6 +44,8 @@ export function runPi(args, agentDir, home, cwd, timeout, extraEnv = {}) {
|
|
|
43
44
|
let timedOut = false;
|
|
44
45
|
let spawnError;
|
|
45
46
|
child.stdout.on("data", (chunk) => { stdout = boundedAppend(stdout, chunk); });
|
|
47
|
+
if (onStdoutLine)
|
|
48
|
+
createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", onStdoutLine);
|
|
46
49
|
child.stderr.on("data", (chunk) => { stderr = boundedAppend(stderr, chunk); });
|
|
47
50
|
child.once("error", (e) => { spawnError = e.message; });
|
|
48
51
|
const timer = setTimeout(() => {
|