chainlesschain 0.45.81 → 0.47.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.
Files changed (71) hide show
  1. package/README.md +10 -0
  2. package/bin/chainlesschain.js +0 -0
  3. package/package.json +1 -1
  4. package/src/assets/web-panel/.build-hash +1 -1
  5. package/src/assets/web-panel/assets/{Analytics-C1AnPdMx.js → Analytics-DgypYeUB.js} +2 -2
  6. package/src/assets/web-panel/assets/AppLayout-Bzf3mSZI.js +1 -0
  7. package/src/assets/web-panel/assets/AppLayout-DQyDwGut.css +1 -0
  8. package/src/assets/web-panel/assets/{Backup-D31iZX3l.js → Backup-Ba9UybpT.js} +1 -1
  9. package/src/assets/web-panel/assets/{Chat-DiXJ3TuK.js → Chat-BwXskT21.js} +1 -1
  10. package/src/assets/web-panel/assets/Cowork-CXuhlHew.css +1 -0
  11. package/src/assets/web-panel/assets/Cowork-UmOe7qvE.js +7 -0
  12. package/src/assets/web-panel/assets/{Cron-DBt1ueXh.js → Cron-JHS-rc-4.js} +2 -2
  13. package/src/assets/web-panel/assets/{Dashboard-HPh9FcPt.js → Dashboard-B95cMCO7.js} +2 -2
  14. package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +1 -0
  15. package/src/assets/web-panel/assets/{Git-hwQ1oZHj.js → Git-CSYO0_zk.js} +2 -2
  16. package/src/assets/web-panel/assets/{Logs-4D9p6PRM.js → Logs-Hxw_K0km.js} +2 -2
  17. package/src/assets/web-panel/assets/{McpTools-CyAUjbbs.js → McpTools-DIE75TrB.js} +2 -2
  18. package/src/assets/web-panel/assets/{Memory-BMqOR7S-.js → Memory-C4KVnLlp.js} +2 -2
  19. package/src/assets/web-panel/assets/{Notes-Cmas8i4E.js → Notes-DuzrHMAk.js} +2 -2
  20. package/src/assets/web-panel/assets/{Organization-DnSa58Tl.js → Organization-DTq6uF82.js} +4 -4
  21. package/src/assets/web-panel/assets/{P2P-BxksIBWs.js → P2P-C0hjlhsR.js} +2 -2
  22. package/src/assets/web-panel/assets/{Permissions-Bq5Qn2s3.js → Permissions-Ec0NH-xC.js} +4 -4
  23. package/src/assets/web-panel/assets/{Projects-B7EM0uPg.js → Projects-U8D0asCS.js} +2 -2
  24. package/src/assets/web-panel/assets/{Providers-DAwgG5KV.js → Providers-BngtTLvJ.js} +2 -2
  25. package/src/assets/web-panel/assets/{RssFeed-HSZoRXvS.js → RssFeed-B9NbwCKM.js} +3 -3
  26. package/src/assets/web-panel/assets/{Security-Cz17qBny.js → Security-BL5Rkr1T.js} +3 -3
  27. package/src/assets/web-panel/assets/{Services-D2EsLq-v.js → Services-D4MJzLld.js} +2 -2
  28. package/src/assets/web-panel/assets/{Skills-C9v-f3vZ.js → Skills-CQTOMDwF.js} +1 -1
  29. package/src/assets/web-panel/assets/{Tasks-yMEcU0n7.js → Tasks-DepbJMnL.js} +1 -1
  30. package/src/assets/web-panel/assets/{Templates-l7SvlKuB.js → Templates-C24PVZPu.js} +1 -1
  31. package/src/assets/web-panel/assets/{Wallet-BHWhLWn9.js → Wallet-PQoSpN_P.js} +3 -3
  32. package/src/assets/web-panel/assets/{WebAuthn-kWhFYaUK.js → WebAuthn-BcuyQ4Lr.js} +4 -4
  33. package/src/assets/web-panel/assets/WorkflowEditor-C-SvXbHW.js +1 -0
  34. package/src/assets/web-panel/assets/WorkflowEditor-D5bX6woe.css +1 -0
  35. package/src/assets/web-panel/assets/{antd-D6h4fDFf.js → antd-DEjZPGMj.js} +82 -82
  36. package/src/assets/web-panel/assets/index-CwvzTTw_.js +2 -0
  37. package/src/assets/web-panel/assets/{markdown-BZsB-Dsv.js → markdown-CusdXFxb.js} +1 -1
  38. package/src/assets/web-panel/index.html +2 -2
  39. package/src/commands/cowork.js +867 -0
  40. package/src/gateways/ws/action-protocol.js +182 -2
  41. package/src/gateways/ws/message-dispatcher.js +5 -0
  42. package/src/gateways/ws/ws-server.js +21 -0
  43. package/src/lib/cowork-cron.js +474 -0
  44. package/src/lib/cowork-evomap-adapter.js +121 -0
  45. package/src/lib/cowork-learning.js +438 -0
  46. package/src/lib/cowork-mcp-tools.js +182 -0
  47. package/src/lib/cowork-observe-html.js +108 -0
  48. package/src/lib/cowork-observe.js +160 -0
  49. package/src/lib/cowork-share.js +322 -0
  50. package/src/lib/cowork-task-runner.js +317 -3
  51. package/src/lib/cowork-task-templates.js +101 -13
  52. package/src/lib/cowork-template-marketplace.js +205 -0
  53. package/src/lib/cowork-workflow.js +571 -0
  54. package/src/lib/provider-options.js +133 -0
  55. package/src/lib/skill-loader.js +65 -0
  56. package/src/lib/sub-agent-context.js +54 -2
  57. package/src/lib/sub-agent-profiles.js +164 -0
  58. package/src/lib/todo-manager.js +108 -0
  59. package/src/lib/turn-context.js +95 -0
  60. package/src/lib/web-fetch.js +224 -0
  61. package/src/lib/workflow-expr.js +318 -0
  62. package/src/repl/agent-repl.js +4 -0
  63. package/src/runtime/agent-core.js +135 -3
  64. package/src/runtime/coding-agent-contract-shared.cjs +131 -0
  65. package/src/runtime/coding-agent-policy.cjs +30 -0
  66. package/src/assets/web-panel/assets/AppLayout-YdvJBMHH.js +0 -1
  67. package/src/assets/web-panel/assets/AppLayout-cxfKLu-m.css +0 -1
  68. package/src/assets/web-panel/assets/Cowork-BnrHWwZw.js +0 -7
  69. package/src/assets/web-panel/assets/Cowork-CcSoS3eX.css +0 -1
  70. package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +0 -1
  71. package/src/assets/web-panel/assets/index-ByUk2Wmr.js +0 -2
@@ -19,22 +19,51 @@ export async function handleCoworkTask(server, id, ws, message) {
19
19
  _runningTasks.set(trackingId, ac);
20
20
 
21
21
  try {
22
- const { runCoworkTask } = await import("../../lib/cowork-task-runner.js");
22
+ const { runCoworkTask, runCoworkTaskParallel, runCoworkDebate } =
23
+ await import("../../lib/cowork-task-runner.js");
24
+ const { getTemplate } = await import("../../lib/cowork-task-templates.js");
25
+
26
+ // Determine execution mode: debate > parallel > sequential
27
+ const template = getTemplate(templateId);
28
+ const useDebate =
29
+ message.mode === "debate" ||
30
+ (message.mode !== "agent" && template.mode === "debate");
31
+ const useParallel =
32
+ !useDebate &&
33
+ (message.parallel === true ||
34
+ (message.parallel !== false && template.parallelStrategy === "always"));
23
35
 
24
36
  server._send(ws, {
25
37
  id,
26
38
  type: "cowork:started",
27
39
  templateId,
28
40
  trackingId,
41
+ parallel: useParallel,
42
+ mode: useDebate ? "debate" : "agent",
29
43
  });
30
44
 
31
- const result = await runCoworkTask({
45
+ const runner = useDebate
46
+ ? runCoworkDebate
47
+ : useParallel
48
+ ? runCoworkTaskParallel
49
+ : runCoworkTask;
50
+
51
+ const result = await runner({
32
52
  templateId,
33
53
  userMessage,
34
54
  files,
35
55
  cwd: server.projectRoot || process.cwd(),
36
56
  llmOptions: {},
37
57
  signal: ac.signal,
58
+ ...(useParallel
59
+ ? {
60
+ agents: message.agents || 3,
61
+ strategy: message.strategy,
62
+ }
63
+ : {}),
64
+ ...(useDebate && message.perspectives
65
+ ? { perspectives: message.perspectives }
66
+ : {}),
38
67
  onProgress: (progress) => {
39
68
  server._send(ws, {
40
69
  id,
@@ -59,6 +88,17 @@ export async function handleCoworkTask(server, id, ws, message) {
59
88
  toolsUsed: result.result?.toolsUsed || [],
60
89
  iterationCount: result.result?.iterationCount || 0,
61
90
  tokenCount: result.result?.tokenCount || 0,
91
+ parallel: result.parallel || false,
92
+ subtaskCount: result.result?.subtaskCount || 0,
93
+ mode: result.mode || (useDebate ? "debate" : "agent"),
94
+ ...(useDebate
95
+ ? {
96
+ verdict: result.result?.verdict,
97
+ consensusScore: result.result?.consensusScore,
98
+ reviews: result.result?.reviews || [],
99
+ perspectives: result.result?.perspectives || [],
100
+ }
101
+ : {}),
62
102
  });
63
103
  } catch (err) {
64
104
  server._send(ws, {
@@ -235,3 +275,143 @@ export async function handleOrchestrate(server, id, ws, message) {
235
275
  });
236
276
  }
237
277
  }
278
+
279
+ // ─── Workflow (N1) ───────────────────────────────────────────────────────────
280
+
281
+ function _cwd(server) {
282
+ return server.projectRoot || process.cwd();
283
+ }
284
+
285
+ function _sendError(server, ws, id, code, message) {
286
+ server._send(ws, { id, type: "error", code, message });
287
+ }
288
+
289
+ export async function handleWorkflowList(server, id, ws) {
290
+ try {
291
+ const { listWorkflows } = await import("../../lib/cowork-workflow.js");
292
+ const workflows = listWorkflows(_cwd(server));
293
+ server._send(ws, { id, type: "workflow:list", workflows });
294
+ } catch (err) {
295
+ _sendError(server, ws, id, "WORKFLOW_LIST_FAILED", err.message);
296
+ }
297
+ }
298
+
299
+ export async function handleWorkflowGet(server, id, ws, message) {
300
+ const { id: wfId } = message || {};
301
+ if (!wfId) return _sendError(server, ws, id, "MISSING_ID", "id required");
302
+ try {
303
+ const { getWorkflow } = await import("../../lib/cowork-workflow.js");
304
+ const workflow = getWorkflow(_cwd(server), wfId);
305
+ server._send(ws, { id, type: "workflow:get", workflow: workflow || null });
306
+ } catch (err) {
307
+ _sendError(server, ws, id, "WORKFLOW_GET_FAILED", err.message);
308
+ }
309
+ }
310
+
311
+ export async function handleWorkflowSave(server, id, ws, message) {
312
+ const { workflow } = message || {};
313
+ if (!workflow || typeof workflow !== "object") {
314
+ return _sendError(
315
+ server,
316
+ ws,
317
+ id,
318
+ "INVALID_WORKFLOW",
319
+ "workflow object required",
320
+ );
321
+ }
322
+ try {
323
+ const { validateWorkflow, saveWorkflow } =
324
+ await import("../../lib/cowork-workflow.js");
325
+ const result = validateWorkflow(workflow);
326
+ if (!result.valid) {
327
+ return _sendError(
328
+ server,
329
+ ws,
330
+ id,
331
+ "WORKFLOW_INVALID",
332
+ result.errors.join("; "),
333
+ );
334
+ }
335
+ saveWorkflow(_cwd(server), workflow);
336
+ server._send(ws, {
337
+ id,
338
+ type: "workflow:save",
339
+ saved: true,
340
+ workflowId: workflow.id,
341
+ });
342
+ } catch (err) {
343
+ _sendError(server, ws, id, "WORKFLOW_SAVE_FAILED", err.message);
344
+ }
345
+ }
346
+
347
+ export async function handleWorkflowRemove(server, id, ws, message) {
348
+ const { id: wfId } = message || {};
349
+ if (!wfId) return _sendError(server, ws, id, "MISSING_ID", "id required");
350
+ try {
351
+ const { removeWorkflow } = await import("../../lib/cowork-workflow.js");
352
+ const removed = removeWorkflow(_cwd(server), wfId);
353
+ server._send(ws, { id, type: "workflow:remove", removed });
354
+ } catch (err) {
355
+ _sendError(server, ws, id, "WORKFLOW_REMOVE_FAILED", err.message);
356
+ }
357
+ }
358
+
359
+ export async function handleWorkflowRun(server, id, ws, message) {
360
+ const { id: wfId } = message || {};
361
+ if (!wfId) return _sendError(server, ws, id, "MISSING_ID", "id required");
362
+
363
+ try {
364
+ const { getWorkflow, executeWorkflow } =
365
+ await import("../../lib/cowork-workflow.js");
366
+ const workflow = getWorkflow(_cwd(server), wfId);
367
+ if (!workflow) {
368
+ return _sendError(
369
+ server,
370
+ ws,
371
+ id,
372
+ "WORKFLOW_NOT_FOUND",
373
+ `No workflow: ${wfId}`,
374
+ );
375
+ }
376
+
377
+ const runId = `wf-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
378
+ server._send(ws, { id, type: "workflow:started", runId, workflowId: wfId });
379
+
380
+ const onStepStart = ({ stepId, message: stepMessage }) => {
381
+ server._send(ws, {
382
+ id,
383
+ type: "workflow:step-start",
384
+ runId,
385
+ stepId,
386
+ message: stepMessage,
387
+ });
388
+ };
389
+ const onStepComplete = (outcome) => {
390
+ server._send(ws, {
391
+ id,
392
+ type: "workflow:step-complete",
393
+ runId,
394
+ stepId: outcome?.id,
395
+ status: outcome?.status,
396
+ summary: outcome?.result?.summary,
397
+ });
398
+ };
399
+
400
+ const record = await executeWorkflow({
401
+ workflow,
402
+ cwd: _cwd(server),
403
+ onStepStart,
404
+ onStepComplete,
405
+ });
406
+
407
+ server._send(ws, {
408
+ id,
409
+ type: "workflow:done",
410
+ runId,
411
+ status: record?.status || "completed",
412
+ steps: record?.steps || [],
413
+ });
414
+ } catch (err) {
415
+ _sendError(server, ws, id, "WORKFLOW_RUN_FAILED", err.message);
416
+ }
417
+ }
@@ -47,6 +47,11 @@ export function createWsMessageDispatcher(server) {
47
47
  "cowork-cancel": () => server._handleCoworkCancel(id, ws, message),
48
48
  "cowork-templates": () => server._handleCoworkTemplates(id, ws),
49
49
  "cowork-history": () => server._handleCoworkHistory(id, ws, message),
50
+ "workflow-list": () => server._handleWorkflowList(id, ws),
51
+ "workflow-get": () => server._handleWorkflowGet(id, ws, message),
52
+ "workflow-save": () => server._handleWorkflowSave(id, ws, message),
53
+ "workflow-remove": () => server._handleWorkflowRemove(id, ws, message),
54
+ "workflow-run": () => server._handleWorkflowRun(id, ws, message),
50
55
  "tasks-list": () => server._handleTasksList(id, ws),
51
56
  "tasks-stop": () => server._handleTasksStop(id, ws, message),
52
57
  "tasks-detail": () => server._handleTaskDetail(id, ws, message),
@@ -55,6 +55,11 @@ import {
55
55
  handleCoworkCancel,
56
56
  handleCoworkTemplates,
57
57
  handleCoworkHistory,
58
+ handleWorkflowList,
59
+ handleWorkflowGet,
60
+ handleWorkflowSave,
61
+ handleWorkflowRemove,
62
+ handleWorkflowRun,
58
63
  } from "./action-protocol.js";
59
64
  import {
60
65
  handleWorktreeDiff,
@@ -321,6 +326,22 @@ export class ChainlessChainWSServer extends EventEmitter {
321
326
  return handleCoworkHistory(this, id, ws, message);
322
327
  }
323
328
 
329
+ _handleWorkflowList(id, ws) {
330
+ return handleWorkflowList(this, id, ws);
331
+ }
332
+ _handleWorkflowGet(id, ws, message) {
333
+ return handleWorkflowGet(this, id, ws, message);
334
+ }
335
+ _handleWorkflowSave(id, ws, message) {
336
+ return handleWorkflowSave(this, id, ws, message);
337
+ }
338
+ _handleWorkflowRemove(id, ws, message) {
339
+ return handleWorkflowRemove(this, id, ws, message);
340
+ }
341
+ _handleWorkflowRun(id, ws, message) {
342
+ return handleWorkflowRun(this, id, ws, message);
343
+ }
344
+
324
345
  /** @private – list background tasks */
325
346
  async _handleTasksList(id, ws) {
326
347
  try {