chainlesschain 0.45.67 → 0.45.74

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.
Files changed (91) hide show
  1. package/package.json +1 -1
  2. package/src/assets/web-panel/.build-hash +1 -1
  3. package/src/assets/web-panel/assets/Analytics-B4OM8S8X.css +1 -0
  4. package/src/assets/web-panel/assets/Analytics-sBrYoc3A.js +3 -0
  5. package/src/assets/web-panel/assets/AppLayout-BhJ3YFWt.js +1 -0
  6. package/src/assets/web-panel/assets/AppLayout-Cr2lWhF-.css +1 -0
  7. package/src/assets/web-panel/assets/Backup-D68fenbD.js +1 -0
  8. package/src/assets/web-panel/assets/Backup-fZqtfC1m.css +1 -0
  9. package/src/assets/web-panel/assets/{Chat-DXtvKoM0.js → Chat-DaxTP3x8.js} +1 -1
  10. package/src/assets/web-panel/assets/{Cron-BJ4ODHOy.js → Cron-CNs03iHJ.js} +2 -2
  11. package/src/assets/web-panel/assets/{Dashboard-BZd4wDPQ.js → Dashboard-CjlX4CrX.js} +2 -2
  12. package/src/assets/web-panel/assets/Git-CCMVr3Y8.js +2 -0
  13. package/src/assets/web-panel/assets/Git-DGcuBXST.css +1 -0
  14. package/src/assets/web-panel/assets/{Logs-CSeKZEG_.js → Logs-BY6A0UNG.js} +2 -2
  15. package/src/assets/web-panel/assets/{McpTools-BYQAK11r.js → McpTools-CrBVYlg6.js} +2 -2
  16. package/src/assets/web-panel/assets/{Memory-gkUAPyuZ.js → Memory-CWx3SpUt.js} +2 -2
  17. package/src/assets/web-panel/assets/{Notes-bjNrQgAo.js → Notes-1LcGD49x.js} +2 -2
  18. package/src/assets/web-panel/assets/Organization-DdOOM4ic.css +1 -0
  19. package/src/assets/web-panel/assets/Organization-Dx2DhbkM.js +4 -0
  20. package/src/assets/web-panel/assets/P2P-B16fjqfJ.js +2 -0
  21. package/src/assets/web-panel/assets/P2P-OEzOeMZX.css +1 -0
  22. package/src/assets/web-panel/assets/Permissions-BQbC9FzG.js +4 -0
  23. package/src/assets/web-panel/assets/Permissions-C9WlkGl-.css +1 -0
  24. package/src/assets/web-panel/assets/Projects-CjhZbNYm.js +2 -0
  25. package/src/assets/web-panel/assets/Projects-DxKelI5h.css +1 -0
  26. package/src/assets/web-panel/assets/Providers-BEakqcO5.css +1 -0
  27. package/src/assets/web-panel/assets/Providers-ivOAQtHM.js +2 -0
  28. package/src/assets/web-panel/assets/RssFeed-BlFC20eg.css +1 -0
  29. package/src/assets/web-panel/assets/RssFeed-BrsErdrU.js +3 -0
  30. package/src/assets/web-panel/assets/Security-DnEvJU5h.js +4 -0
  31. package/src/assets/web-panel/assets/Security-Dwxw7rfP.css +1 -0
  32. package/src/assets/web-panel/assets/{Services-CS0oMdxh.js → Services-7jQywNbl.js} +2 -2
  33. package/src/assets/web-panel/assets/Skills-BCvgBkD3.js +1 -0
  34. package/src/assets/web-panel/assets/{Tasks-qULws8pc.js → Tasks-CmJBC1cf.js} +1 -1
  35. package/src/assets/web-panel/assets/Templates-DOY_oZnm.css +1 -0
  36. package/src/assets/web-panel/assets/Templates-RXT8-DNk.js +1 -0
  37. package/src/assets/web-panel/assets/Wallet-3iYASEx_.js +4 -0
  38. package/src/assets/web-panel/assets/Wallet-DnIumafl.css +1 -0
  39. package/src/assets/web-panel/assets/WebAuthn-CNPl2VQR.css +1 -0
  40. package/src/assets/web-panel/assets/WebAuthn-s3Hzd9db.js +5 -0
  41. package/src/assets/web-panel/assets/{antd-CJSBocer.js → antd-gZyc63Qr.js} +114 -114
  42. package/src/assets/web-panel/assets/chat-BmwHBi9M.js +1 -0
  43. package/src/assets/web-panel/assets/index-DrmEk9S3.js +2 -0
  44. package/src/assets/web-panel/assets/{markdown-Bo5cVN4u.js → markdown-Bv7nG63L.js} +1 -1
  45. package/src/assets/web-panel/assets/ws-CU7Gvoom.js +1 -0
  46. package/src/assets/web-panel/index.html +2 -2
  47. package/src/commands/doctor.js +33 -151
  48. package/src/commands/mcp.js +1 -1
  49. package/src/commands/plugin.js +1 -1
  50. package/src/commands/session.js +106 -7
  51. package/src/commands/status.js +39 -69
  52. package/src/gateways/ws/message-dispatcher.js +9 -0
  53. package/src/gateways/ws/session-protocol.js +368 -1
  54. package/src/gateways/ws/ws-agent-handler.js +484 -0
  55. package/src/gateways/ws/ws-server.js +758 -4
  56. package/src/gateways/ws/ws-session-gateway.js +1432 -1
  57. package/src/harness/mcp-client.js +417 -0
  58. package/src/harness/mock-llm-provider.js +167 -0
  59. package/src/harness/plugin-manager.js +434 -0
  60. package/src/lib/agent-core.js +25 -1902
  61. package/src/lib/hashline.js +208 -0
  62. package/src/lib/jsonl-session-store.js +11 -0
  63. package/src/lib/mcp-client.js +14 -412
  64. package/src/lib/plugin-manager.js +29 -428
  65. package/src/lib/prompt-compressor.js +11 -0
  66. package/src/lib/session-hooks.js +61 -0
  67. package/src/lib/skill-loader.js +4 -0
  68. package/src/lib/skill-mcp.js +190 -0
  69. package/src/lib/workflow-state-reader.js +94 -0
  70. package/src/lib/ws-agent-handler.js +8 -472
  71. package/src/lib/ws-server.js +12 -726
  72. package/src/lib/ws-session-manager.js +8 -1178
  73. package/src/repl/agent-repl.js +27 -3
  74. package/src/runtime/agent-core.js +1760 -0
  75. package/src/runtime/agent-runtime.js +3 -1
  76. package/src/runtime/coding-agent-contract-shared.cjs +496 -0
  77. package/src/runtime/coding-agent-contract.js +49 -229
  78. package/src/runtime/coding-agent-events.cjs +14 -0
  79. package/src/runtime/coding-agent-policy.cjs +54 -5
  80. package/src/runtime/diagnostics.js +317 -0
  81. package/src/runtime/index.js +3 -0
  82. package/src/tools/index.js +3 -0
  83. package/src/tools/legacy-agent-tools.js +5 -0
  84. package/src/assets/web-panel/assets/AppLayout-B_tkw3Pn.js +0 -1
  85. package/src/assets/web-panel/assets/AppLayout-CFP4dGIJ.css +0 -1
  86. package/src/assets/web-panel/assets/Providers-Brm-S_hS.css +0 -1
  87. package/src/assets/web-panel/assets/Providers-Dbf57Tbv.js +0 -1
  88. package/src/assets/web-panel/assets/Skills-B2fgruv8.js +0 -1
  89. package/src/assets/web-panel/assets/chat-DnH09sSR.js +0 -1
  90. package/src/assets/web-panel/assets/index-IK-oro0g.js +0 -2
  91. package/src/assets/web-panel/assets/ws-DjelKkD6.js +0 -1
@@ -46,7 +46,7 @@ async function ensureSessionHandler(server, ws, session) {
46
46
  interaction: session.interaction,
47
47
  });
48
48
  } else {
49
- const { WSAgentHandler } = await import("../../lib/ws-agent-handler.js");
49
+ const { WSAgentHandler } = await import("./ws-agent-handler.js");
50
50
  handler = new WSAgentHandler({
51
51
  session,
52
52
  interaction: session.interaction,
@@ -1164,6 +1164,373 @@ export function handlePatchSummary(server, id, ws, message) {
1164
1164
  );
1165
1165
  }
1166
1166
 
1167
+ /**
1168
+ * Helper: emit a task-graph.* envelope through the session's interaction
1169
+ * adapter (same fan-out pattern as _emitPatchEvent).
1170
+ */
1171
+ function _emitTaskGraphEvent(server, session, type, payload, ws) {
1172
+ const envelope = createCodingAgentEvent(
1173
+ type,
1174
+ { ...(payload || {}), sessionId: session.id },
1175
+ {
1176
+ sessionId: session.id,
1177
+ source: "cli-runtime",
1178
+ },
1179
+ );
1180
+
1181
+ const interaction = session && session.interaction;
1182
+ if (interaction && typeof interaction.emit === "function") {
1183
+ try {
1184
+ interaction.emit(type, envelope.payload);
1185
+ return;
1186
+ } catch (_err) {
1187
+ // Fall through to ws send below.
1188
+ }
1189
+ }
1190
+
1191
+ if (ws) {
1192
+ server._send(ws, envelope);
1193
+ }
1194
+ }
1195
+
1196
+ /**
1197
+ * Create a session-scoped task graph.
1198
+ *
1199
+ * Message shape:
1200
+ * { type: "task-graph-create", id, sessionId, title?, nodes: [...] }
1201
+ */
1202
+ export function handleTaskGraphCreate(server, id, ws, message) {
1203
+ const { sessionId } = message || {};
1204
+
1205
+ if (!server.sessionManager) {
1206
+ server._send(
1207
+ ws,
1208
+ envelopeError(id, "NO_SESSION_SUPPORT", "Session support not configured"),
1209
+ );
1210
+ return;
1211
+ }
1212
+
1213
+ const session = server.sessionManager.getSession(sessionId);
1214
+ if (!session) {
1215
+ server._send(
1216
+ ws,
1217
+ envelopeError(
1218
+ id,
1219
+ "SESSION_NOT_FOUND",
1220
+ `Session not found: ${sessionId}`,
1221
+ sessionId,
1222
+ ),
1223
+ );
1224
+ return;
1225
+ }
1226
+
1227
+ if (!Array.isArray(message.nodes)) {
1228
+ server._send(
1229
+ ws,
1230
+ envelopeError(
1231
+ id,
1232
+ "INVALID_PAYLOAD",
1233
+ "task-graph-create requires a nodes array",
1234
+ sessionId,
1235
+ ),
1236
+ );
1237
+ return;
1238
+ }
1239
+
1240
+ const graph = server.sessionManager.createTaskGraph(sessionId, {
1241
+ graphId: message.graphId,
1242
+ title: message.title,
1243
+ description: message.description,
1244
+ nodes: message.nodes,
1245
+ });
1246
+
1247
+ server._send(
1248
+ ws,
1249
+ envelopeResponse(
1250
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_CREATED,
1251
+ id,
1252
+ { sessionId, graph },
1253
+ sessionId,
1254
+ ),
1255
+ );
1256
+
1257
+ _emitTaskGraphEvent(
1258
+ server,
1259
+ session,
1260
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_CREATED,
1261
+ { graph },
1262
+ ws,
1263
+ );
1264
+ }
1265
+
1266
+ /**
1267
+ * Add a node to an existing task graph.
1268
+ *
1269
+ * Message shape:
1270
+ * { type: "task-graph-add-node", id, sessionId, node: { id, title, dependsOn? } }
1271
+ */
1272
+ export function handleTaskGraphAddNode(server, id, ws, message) {
1273
+ const { sessionId } = message || {};
1274
+
1275
+ if (!server.sessionManager) {
1276
+ server._send(
1277
+ ws,
1278
+ envelopeError(id, "NO_SESSION_SUPPORT", "Session support not configured"),
1279
+ );
1280
+ return;
1281
+ }
1282
+
1283
+ const session = server.sessionManager.getSession(sessionId);
1284
+ if (!session) {
1285
+ server._send(
1286
+ ws,
1287
+ envelopeError(
1288
+ id,
1289
+ "SESSION_NOT_FOUND",
1290
+ `Session not found: ${sessionId}`,
1291
+ sessionId,
1292
+ ),
1293
+ );
1294
+ return;
1295
+ }
1296
+
1297
+ const node = message.node || null;
1298
+ if (!node || !node.id) {
1299
+ server._send(
1300
+ ws,
1301
+ envelopeError(
1302
+ id,
1303
+ "INVALID_PAYLOAD",
1304
+ "task-graph-add-node requires node.id",
1305
+ sessionId,
1306
+ ),
1307
+ );
1308
+ return;
1309
+ }
1310
+
1311
+ const graph = server.sessionManager.addTaskNode(sessionId, node);
1312
+ if (!graph) {
1313
+ server._send(
1314
+ ws,
1315
+ envelopeError(
1316
+ id,
1317
+ "TASK_GRAPH_ADD_FAILED",
1318
+ "Unable to add node (no graph, or duplicate id)",
1319
+ sessionId,
1320
+ ),
1321
+ );
1322
+ return;
1323
+ }
1324
+
1325
+ server._send(
1326
+ ws,
1327
+ envelopeResponse(
1328
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_NODE_ADDED,
1329
+ id,
1330
+ { sessionId, graph, nodeId: node.id },
1331
+ sessionId,
1332
+ ),
1333
+ );
1334
+
1335
+ _emitTaskGraphEvent(
1336
+ server,
1337
+ session,
1338
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_NODE_ADDED,
1339
+ { graph, nodeId: node.id },
1340
+ ws,
1341
+ );
1342
+ }
1343
+
1344
+ /**
1345
+ * Update a task graph node (status, result, error, metadata).
1346
+ *
1347
+ * Message shape:
1348
+ * { type: "task-graph-update-node", id, sessionId, nodeId, updates: { status?, result?, error? } }
1349
+ */
1350
+ export function handleTaskGraphUpdateNode(server, id, ws, message) {
1351
+ const { sessionId, nodeId } = message || {};
1352
+
1353
+ if (!server.sessionManager) {
1354
+ server._send(
1355
+ ws,
1356
+ envelopeError(id, "NO_SESSION_SUPPORT", "Session support not configured"),
1357
+ );
1358
+ return;
1359
+ }
1360
+
1361
+ const session = server.sessionManager.getSession(sessionId);
1362
+ if (!session) {
1363
+ server._send(
1364
+ ws,
1365
+ envelopeError(
1366
+ id,
1367
+ "SESSION_NOT_FOUND",
1368
+ `Session not found: ${sessionId}`,
1369
+ sessionId,
1370
+ ),
1371
+ );
1372
+ return;
1373
+ }
1374
+
1375
+ if (!nodeId) {
1376
+ server._send(
1377
+ ws,
1378
+ envelopeError(id, "INVALID_PAYLOAD", "nodeId is required", sessionId),
1379
+ );
1380
+ return;
1381
+ }
1382
+
1383
+ const graph = server.sessionManager.updateTaskNode(
1384
+ sessionId,
1385
+ nodeId,
1386
+ message.updates || {},
1387
+ );
1388
+
1389
+ if (!graph) {
1390
+ server._send(
1391
+ ws,
1392
+ envelopeError(
1393
+ id,
1394
+ "TASK_GRAPH_NODE_NOT_FOUND",
1395
+ `Task node not found: ${nodeId}`,
1396
+ sessionId,
1397
+ ),
1398
+ );
1399
+ return;
1400
+ }
1401
+
1402
+ const node = graph.nodes[nodeId];
1403
+ let eventType = CODING_AGENT_EVENT_TYPES.TASK_GRAPH_NODE_UPDATED;
1404
+ if (node && node.status === "completed") {
1405
+ eventType = CODING_AGENT_EVENT_TYPES.TASK_GRAPH_NODE_COMPLETED;
1406
+ } else if (node && node.status === "failed") {
1407
+ eventType = CODING_AGENT_EVENT_TYPES.TASK_GRAPH_NODE_FAILED;
1408
+ }
1409
+
1410
+ server._send(
1411
+ ws,
1412
+ envelopeResponse(eventType, id, { sessionId, graph, nodeId }, sessionId),
1413
+ );
1414
+
1415
+ _emitTaskGraphEvent(server, session, eventType, { graph, nodeId }, ws);
1416
+
1417
+ if (graph.status === "completed" || graph.status === "failed") {
1418
+ _emitTaskGraphEvent(
1419
+ server,
1420
+ session,
1421
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_COMPLETED,
1422
+ { graph },
1423
+ ws,
1424
+ );
1425
+ }
1426
+ }
1427
+
1428
+ /**
1429
+ * Advance the task graph: promote any pending node whose deps are satisfied.
1430
+ *
1431
+ * Message shape: { type: "task-graph-advance", id, sessionId }
1432
+ */
1433
+ export function handleTaskGraphAdvance(server, id, ws, message) {
1434
+ const { sessionId } = message || {};
1435
+
1436
+ if (!server.sessionManager) {
1437
+ server._send(
1438
+ ws,
1439
+ envelopeError(id, "NO_SESSION_SUPPORT", "Session support not configured"),
1440
+ );
1441
+ return;
1442
+ }
1443
+
1444
+ const session = server.sessionManager.getSession(sessionId);
1445
+ if (!session) {
1446
+ server._send(
1447
+ ws,
1448
+ envelopeError(
1449
+ id,
1450
+ "SESSION_NOT_FOUND",
1451
+ `Session not found: ${sessionId}`,
1452
+ sessionId,
1453
+ ),
1454
+ );
1455
+ return;
1456
+ }
1457
+
1458
+ const result = server.sessionManager.advanceTaskGraph(sessionId);
1459
+ if (!result) {
1460
+ server._send(
1461
+ ws,
1462
+ envelopeError(
1463
+ id,
1464
+ "TASK_GRAPH_NOT_FOUND",
1465
+ "No task graph on session",
1466
+ sessionId,
1467
+ ),
1468
+ );
1469
+ return;
1470
+ }
1471
+
1472
+ server._send(
1473
+ ws,
1474
+ envelopeResponse(
1475
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_ADVANCED,
1476
+ id,
1477
+ { sessionId, graph: result.graph, becameReady: result.becameReady },
1478
+ sessionId,
1479
+ ),
1480
+ );
1481
+
1482
+ _emitTaskGraphEvent(
1483
+ server,
1484
+ session,
1485
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_ADVANCED,
1486
+ { graph: result.graph, becameReady: result.becameReady },
1487
+ ws,
1488
+ );
1489
+ }
1490
+
1491
+ /**
1492
+ * Fetch the current task graph state.
1493
+ *
1494
+ * Message shape: { type: "task-graph-state", id, sessionId }
1495
+ */
1496
+ export function handleTaskGraphState(server, id, ws, message) {
1497
+ const { sessionId } = message || {};
1498
+
1499
+ if (!server.sessionManager) {
1500
+ server._send(
1501
+ ws,
1502
+ envelopeError(id, "NO_SESSION_SUPPORT", "Session support not configured"),
1503
+ );
1504
+ return;
1505
+ }
1506
+
1507
+ const session = server.sessionManager.getSession(sessionId);
1508
+ if (!session) {
1509
+ server._send(
1510
+ ws,
1511
+ envelopeError(
1512
+ id,
1513
+ "SESSION_NOT_FOUND",
1514
+ `Session not found: ${sessionId}`,
1515
+ sessionId,
1516
+ ),
1517
+ );
1518
+ return;
1519
+ }
1520
+
1521
+ const graph = server.sessionManager.getTaskGraph(sessionId);
1522
+
1523
+ server._send(
1524
+ ws,
1525
+ envelopeResponse(
1526
+ CODING_AGENT_EVENT_TYPES.TASK_GRAPH_STATE,
1527
+ id,
1528
+ { sessionId, graph },
1529
+ sessionId,
1530
+ ),
1531
+ );
1532
+ }
1533
+
1167
1534
  export function handleHostToolResult(server, id, ws, message) {
1168
1535
  const { sessionId, requestId, success, result, error, toolName } = message;
1169
1536