code60-transmission-server 0.1.0-staging.16 → 0.1.0-staging.18

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.md CHANGED
@@ -57,6 +57,29 @@ The MCP tools include status, paginated events, the paginated accepted diff, ans
57
57
 
58
58
  The engine stays up when the MCP client disconnects. Approved tasks, questions, verdicts, and attempts are stored in SQLite. On restart, the engine continues with the first unfinished task and retains partial working-tree changes. Restarting the engine preserves the task’s retry allowance. A lost harness consumes a fresh-session retry. Completed tasks stay accepted. Cancellation leaves the files available for review.
59
59
 
60
+ A client can render the ordered tasks by calling `get_workflow` with only the run ID. For example, during verification the response can look like this:
61
+
62
+ ```json
63
+ {
64
+ "runId": "6ef301cf-b89e-4c11-af33-e11b1171a6b8",
65
+ "status": "running",
66
+ "task": "Implement the fix",
67
+ "phase": "verifier",
68
+ "tasks": [
69
+ { "index": 0, "name": "Implement the fix", "state": "verifying" },
70
+ { "index": 1, "name": "Document it", "state": "pending" }
71
+ ],
72
+ "activeTaskIndex": 0,
73
+ "eventCursor": 37,
74
+ "accepted": [],
75
+ "attempts": []
76
+ }
77
+ ```
78
+
79
+ Each task keeps its zero-based index even when names repeat. The active row can be `implementing`, `verifying`, `repairing`, or `needs_input`. A terminal run has a null active index. Previously accepted rows stay `accepted`, the interrupted row records `failed` or `cancelled`, and unstarted rows stay `pending`.
80
+
81
+ For subsequent activity, call `get_workflow_events` with the same run ID and `after` set to the snapshot’s `eventCursor`. Use the last returned sequence for the next page. Sequence numbers can have gaps between events for a run. Use `after: 0` for earlier history, or refresh `get_workflow` for another complete snapshot.
82
+
60
83
  Private state defaults to `~/Library/Application Support/Code60 Transmission/workflows`. The first ordinary connection registers a per-user LaunchAgent to restart the engine at login. Keep Node and the installed package available at their original paths for login restart. Credentials supplied only through transient shell environment variables need to be available again after login. For an isolated engine, set `TRANSMISSION_STATE_DIR` to a new absolute directory. Isolated engines skip login registration. Use `code60 status` and `code60 stop` with the same state directory.
61
84
 
62
85
  ## Development and validation
@@ -32,7 +32,7 @@ export const operations = {
32
32
  };
33
33
  export const descriptions = {
34
34
  start_workflow: 'Run the exact workflow confirmed by the user. Design ordered tasks, each with implementation instructions and an independent verification prompt. Show the project, tasks and criteria to the user and obtain confirmation before calling. Reuse the same key on reconnect.',
35
- get_workflow: 'Read the current task, a decision needing input, the accepted results and verdicts, or the reason for failure.',
35
+ get_workflow: 'Read an ordered task snapshot by run ID, including the active task index, decision, accepted results, and event cursor. Pass eventCursor as after to get_workflow_events for subsequent activity.',
36
36
  get_workflow_events: 'Read the next page of progress, sessions, native tools and verifier feedback. Use the last sequence number as after.',
37
37
  get_workflow_diff: 'Read a page of the accepted patch relative to the initial working tree. Offset is in bytes; content is base64.',
38
38
  answer_workflow_question: 'Answer the outstanding decision by ID. For a permission question select an offered option ID.',
@@ -40,11 +40,54 @@ export const descriptions = {
40
40
  cancel_workflow: 'Stop the workflow and its active agent sessions. Leave working files available for review.',
41
41
  };
42
42
  export const terminal = (status) => ['completed', 'failed', 'cancelled'].includes(status);
43
+ const status = z.enum(['running', 'completed', 'needs_input', 'failed', 'cancelled']);
43
44
  const checkEvidence = z.object({
44
45
  command: text,
45
46
  passed: z.boolean(),
46
47
  evidence: text,
47
48
  });
49
+ const verdict = z.object({
50
+ decision: z.enum(['accept', 'reject']),
51
+ reason: z.string(),
52
+ checks: z.array(checkEvidence).optional(),
53
+ });
54
+ const accepted = z.object({
55
+ name: z.string(),
56
+ result: z.string(),
57
+ verdict,
58
+ worker: z.string(),
59
+ verifier: z.string(),
60
+ revision: z.string(),
61
+ });
62
+ const question = z.object({
63
+ id: z.uuid(),
64
+ text: z.string(),
65
+ options: z.array(z.object({ id: z.string(), name: z.string() })).optional(),
66
+ });
67
+ const taskState = z.enum([
68
+ 'pending', 'implementing', 'verifying', 'repairing',
69
+ 'needs_input', 'accepted', 'failed', 'cancelled',
70
+ ]);
71
+ const nonnegativeInteger = z.int().nonnegative();
72
+ export const workflowSnapshot = z.object({
73
+ runId,
74
+ status,
75
+ tasks: z.array(z.object({ index: nonnegativeInteger, name: z.string(), state: taskState })),
76
+ activeTaskIndex: nonnegativeInteger.nullable(),
77
+ eventCursor: nonnegativeInteger,
78
+ task: z.string().optional(),
79
+ phase: z.enum(['worker', 'verifier']).optional(),
80
+ decision: question.optional(),
81
+ reason: z.string().optional(),
82
+ attempts: z.array(z.string()),
83
+ accepted: z.array(accepted),
84
+ result: z.string().optional(),
85
+ verdict: verdict.optional(),
86
+ });
87
+ export const snapshotOperations = new Set([
88
+ 'start_workflow', 'get_workflow', 'answer_workflow_question',
89
+ 'send_workflow_message', 'cancel_workflow',
90
+ ]);
48
91
  export const workerReply = z.discriminatedUnion('kind', [
49
92
  z.object({ kind: z.literal('result'), summary: text }),
50
93
  z.object({ kind: z.literal('question'), question: text }),
@@ -6,6 +6,22 @@ import { AcpHarness } from './acp.js';
6
6
  import { terminal, verifierReply, workerReply, } from './contract.js';
7
7
  import { repository, snapshot, writePatch } from './repository.js';
8
8
  const diagnostic = (error) => error instanceof Error ? error.message : String(error);
9
+ function taskState(run, index) {
10
+ if (index < run.index)
11
+ return 'accepted';
12
+ if (index > run.index)
13
+ return 'pending';
14
+ switch (run.status) {
15
+ case 'running':
16
+ if (run.phase === 'verifier')
17
+ return 'verifying';
18
+ return run.repairsUsed > 0 ? 'repairing' : 'implementing';
19
+ case 'completed':
20
+ return 'accepted';
21
+ default:
22
+ return run.status;
23
+ }
24
+ }
9
25
  export class Engine {
10
26
  state;
11
27
  factory;
@@ -108,10 +124,19 @@ export class Engine {
108
124
  return this.status(id);
109
125
  }
110
126
  status(id) {
111
- const r = this.get(id);
127
+ const row = this.db.prepare(`
128
+ SELECT body, (SELECT MAX(sequence) FROM events WHERE run = runs.id) AS cursor
129
+ FROM runs WHERE id = ?
130
+ `).get(id);
131
+ if (!row)
132
+ throw new Error('Unknown workflow.');
133
+ const r = JSON.parse(String(row.body));
112
134
  return {
113
135
  runId: id,
114
136
  status: r.status,
137
+ tasks: r.plan.tasks.map(({ name }, index) => ({ index, name, state: taskState(r, index) })),
138
+ activeTaskIndex: terminal(r.status) ? null : r.index,
139
+ eventCursor: Number(row.cursor),
115
140
  task: r.plan.tasks[r.index]?.name,
116
141
  phase: terminal(r.status) ? undefined : r.phase,
117
142
  accepted: r.accepted,
package/dist/src/main.js CHANGED
@@ -3,7 +3,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
5
  import { z } from 'zod';
6
- import { operations, descriptions } from './contract.js';
6
+ import { operations, descriptions, snapshotOperations, workflowSnapshot } from './contract.js';
7
7
  import { call, ensure, serve } from './service.js';
8
8
  const cmd = process.argv[2] ?? 'mcp';
9
9
  async function main() {
@@ -34,9 +34,11 @@ async function main() {
34
34
  capabilities: { tools: {} },
35
35
  instructions: 'Design ordered tasks with independent verification criteria from the user’s goal. Present the workflow, obtain confirmation, then submit it once with start_workflow. Follow the same run. Ordinary repairs and retries run autonomously.',
36
36
  });
37
+ const outputSchema = z.toJSONSchema(workflowSnapshot);
37
38
  server.setRequestHandler(ListToolsRequestSchema, () => ({
38
39
  tools: Object.entries(operations).map(([name, schema]) => ({
39
40
  name,
41
+ ...(snapshotOperations.has(name) ? { outputSchema } : {}),
40
42
  description: descriptions[name],
41
43
  inputSchema: z.toJSONSchema(schema, { io: 'input' }),
42
44
  })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code60-transmission-server",
3
- "version": "0.1.0-staging.16",
3
+ "version": "0.1.0-staging.18",
4
4
  "description": "Run user-approved workflows with independent coding agents over ACP.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -106,7 +106,14 @@
106
106
  },
107
107
  "responses": {
108
108
  "200": {
109
- "description": "Workflow receipt"
109
+ "description": "Workflow snapshot",
110
+ "content": {
111
+ "application/json": {
112
+ "schema": {
113
+ "$ref": "#/components/schemas/WorkflowSnapshot"
114
+ }
115
+ }
116
+ }
110
117
  },
111
118
  "400": {
112
119
  "description": "Invalid input or workflow state"
@@ -120,7 +127,7 @@
120
127
  "/get_workflow": {
121
128
  "post": {
122
129
  "operationId": "get_workflow",
123
- "description": "Read the current task, a decision needing input, the accepted results and verdicts, or the reason for failure.",
130
+ "description": "Read an ordered task snapshot by run ID, including the active task index, decision, accepted results, and event cursor. Pass eventCursor as after to get_workflow_events for subsequent activity.",
124
131
  "security": [
125
132
  {
126
133
  "localToken": []
@@ -150,7 +157,14 @@
150
157
  },
151
158
  "responses": {
152
159
  "200": {
153
- "description": "Workflow receipt"
160
+ "description": "Workflow snapshot",
161
+ "content": {
162
+ "application/json": {
163
+ "schema": {
164
+ "$ref": "#/components/schemas/WorkflowSnapshot"
165
+ }
166
+ }
167
+ }
154
168
  },
155
169
  "400": {
156
170
  "description": "Invalid input or workflow state"
@@ -306,7 +320,14 @@
306
320
  },
307
321
  "responses": {
308
322
  "200": {
309
- "description": "Workflow receipt"
323
+ "description": "Workflow snapshot",
324
+ "content": {
325
+ "application/json": {
326
+ "schema": {
327
+ "$ref": "#/components/schemas/WorkflowSnapshot"
328
+ }
329
+ }
330
+ }
310
331
  },
311
332
  "400": {
312
333
  "description": "Invalid input or workflow state"
@@ -356,7 +377,14 @@
356
377
  },
357
378
  "responses": {
358
379
  "200": {
359
- "description": "Workflow receipt"
380
+ "description": "Workflow snapshot",
381
+ "content": {
382
+ "application/json": {
383
+ "schema": {
384
+ "$ref": "#/components/schemas/WorkflowSnapshot"
385
+ }
386
+ }
387
+ }
360
388
  },
361
389
  "400": {
362
390
  "description": "Invalid input or workflow state"
@@ -400,7 +428,14 @@
400
428
  },
401
429
  "responses": {
402
430
  "200": {
403
- "description": "Workflow receipt"
431
+ "description": "Workflow snapshot",
432
+ "content": {
433
+ "application/json": {
434
+ "schema": {
435
+ "$ref": "#/components/schemas/WorkflowSnapshot"
436
+ }
437
+ }
438
+ }
404
439
  },
405
440
  "400": {
406
441
  "description": "Invalid input or workflow state"
@@ -413,6 +448,276 @@
413
448
  }
414
449
  },
415
450
  "components": {
451
+ "schemas": {
452
+ "WorkflowSnapshot": {
453
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
454
+ "type": "object",
455
+ "properties": {
456
+ "runId": {
457
+ "type": "string",
458
+ "format": "uuid",
459
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
460
+ },
461
+ "status": {
462
+ "type": "string",
463
+ "enum": [
464
+ "running",
465
+ "completed",
466
+ "needs_input",
467
+ "failed",
468
+ "cancelled"
469
+ ]
470
+ },
471
+ "tasks": {
472
+ "type": "array",
473
+ "items": {
474
+ "type": "object",
475
+ "properties": {
476
+ "index": {
477
+ "type": "integer",
478
+ "minimum": 0,
479
+ "maximum": 9007199254740991
480
+ },
481
+ "name": {
482
+ "type": "string"
483
+ },
484
+ "state": {
485
+ "type": "string",
486
+ "enum": [
487
+ "pending",
488
+ "implementing",
489
+ "verifying",
490
+ "repairing",
491
+ "needs_input",
492
+ "accepted",
493
+ "failed",
494
+ "cancelled"
495
+ ]
496
+ }
497
+ },
498
+ "required": [
499
+ "index",
500
+ "name",
501
+ "state"
502
+ ],
503
+ "additionalProperties": false
504
+ }
505
+ },
506
+ "activeTaskIndex": {
507
+ "anyOf": [
508
+ {
509
+ "type": "integer",
510
+ "minimum": 0,
511
+ "maximum": 9007199254740991
512
+ },
513
+ {
514
+ "type": "null"
515
+ }
516
+ ]
517
+ },
518
+ "eventCursor": {
519
+ "type": "integer",
520
+ "minimum": 0,
521
+ "maximum": 9007199254740991
522
+ },
523
+ "task": {
524
+ "type": "string"
525
+ },
526
+ "phase": {
527
+ "type": "string",
528
+ "enum": [
529
+ "worker",
530
+ "verifier"
531
+ ]
532
+ },
533
+ "decision": {
534
+ "type": "object",
535
+ "properties": {
536
+ "id": {
537
+ "type": "string",
538
+ "format": "uuid",
539
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
540
+ },
541
+ "text": {
542
+ "type": "string"
543
+ },
544
+ "options": {
545
+ "type": "array",
546
+ "items": {
547
+ "type": "object",
548
+ "properties": {
549
+ "id": {
550
+ "type": "string"
551
+ },
552
+ "name": {
553
+ "type": "string"
554
+ }
555
+ },
556
+ "required": [
557
+ "id",
558
+ "name"
559
+ ],
560
+ "additionalProperties": false
561
+ }
562
+ }
563
+ },
564
+ "required": [
565
+ "id",
566
+ "text"
567
+ ],
568
+ "additionalProperties": false
569
+ },
570
+ "reason": {
571
+ "type": "string"
572
+ },
573
+ "attempts": {
574
+ "type": "array",
575
+ "items": {
576
+ "type": "string"
577
+ }
578
+ },
579
+ "accepted": {
580
+ "type": "array",
581
+ "items": {
582
+ "type": "object",
583
+ "properties": {
584
+ "name": {
585
+ "type": "string"
586
+ },
587
+ "result": {
588
+ "type": "string"
589
+ },
590
+ "verdict": {
591
+ "type": "object",
592
+ "properties": {
593
+ "decision": {
594
+ "type": "string",
595
+ "enum": [
596
+ "accept",
597
+ "reject"
598
+ ]
599
+ },
600
+ "reason": {
601
+ "type": "string"
602
+ },
603
+ "checks": {
604
+ "type": "array",
605
+ "items": {
606
+ "type": "object",
607
+ "properties": {
608
+ "command": {
609
+ "type": "string",
610
+ "minLength": 1,
611
+ "maxLength": 65536
612
+ },
613
+ "passed": {
614
+ "type": "boolean"
615
+ },
616
+ "evidence": {
617
+ "type": "string",
618
+ "minLength": 1,
619
+ "maxLength": 65536
620
+ }
621
+ },
622
+ "required": [
623
+ "command",
624
+ "passed",
625
+ "evidence"
626
+ ],
627
+ "additionalProperties": false
628
+ }
629
+ }
630
+ },
631
+ "required": [
632
+ "decision",
633
+ "reason"
634
+ ],
635
+ "additionalProperties": false
636
+ },
637
+ "worker": {
638
+ "type": "string"
639
+ },
640
+ "verifier": {
641
+ "type": "string"
642
+ },
643
+ "revision": {
644
+ "type": "string"
645
+ }
646
+ },
647
+ "required": [
648
+ "name",
649
+ "result",
650
+ "verdict",
651
+ "worker",
652
+ "verifier",
653
+ "revision"
654
+ ],
655
+ "additionalProperties": false
656
+ }
657
+ },
658
+ "result": {
659
+ "type": "string"
660
+ },
661
+ "verdict": {
662
+ "type": "object",
663
+ "properties": {
664
+ "decision": {
665
+ "type": "string",
666
+ "enum": [
667
+ "accept",
668
+ "reject"
669
+ ]
670
+ },
671
+ "reason": {
672
+ "type": "string"
673
+ },
674
+ "checks": {
675
+ "type": "array",
676
+ "items": {
677
+ "type": "object",
678
+ "properties": {
679
+ "command": {
680
+ "type": "string",
681
+ "minLength": 1,
682
+ "maxLength": 65536
683
+ },
684
+ "passed": {
685
+ "type": "boolean"
686
+ },
687
+ "evidence": {
688
+ "type": "string",
689
+ "minLength": 1,
690
+ "maxLength": 65536
691
+ }
692
+ },
693
+ "required": [
694
+ "command",
695
+ "passed",
696
+ "evidence"
697
+ ],
698
+ "additionalProperties": false
699
+ }
700
+ }
701
+ },
702
+ "required": [
703
+ "decision",
704
+ "reason"
705
+ ],
706
+ "additionalProperties": false
707
+ }
708
+ },
709
+ "required": [
710
+ "runId",
711
+ "status",
712
+ "tasks",
713
+ "activeTaskIndex",
714
+ "eventCursor",
715
+ "attempts",
716
+ "accepted"
717
+ ],
718
+ "additionalProperties": false
719
+ }
720
+ },
416
721
  "securitySchemes": {
417
722
  "localToken": {
418
723
  "type": "http",