jules-orchestrator-kit 0.42.0 → 0.52.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/src/mcp.mjs CHANGED
@@ -8,6 +8,13 @@ import { reapOrphanedIntents, reapStaleMutexDirs } from "./journal.mjs";
8
8
  import { readTelemetry } from "./telemetry.mjs";
9
9
  import { ProgressBus } from "./mcp-progress.mjs";
10
10
  import { KIT_VERSION } from "./version.mjs";
11
+ import { createProvider } from "./provider.mjs";
12
+ import {
13
+ extractSessionPatch,
14
+ applySessionPatch,
15
+ retrySession,
16
+ pruneSessions,
17
+ } from "./session-ops.mjs";
11
18
 
12
19
  export const MCP_SERVER_INFO = {
13
20
  name: "jules-orchestrator-kit",
@@ -196,6 +203,113 @@ export const MCP_TOOLS = [
196
203
  required: ["trigger", "solution"],
197
204
  },
198
205
  },
206
+ {
207
+ name: "jules_list_sessions",
208
+ description: "List remote Jules coding sessions with optional pagination and state filtering.",
209
+ inputSchema: {
210
+ type: "object",
211
+ properties: {
212
+ pageSize: { type: "number", description: "Maximum number of sessions to return (default 50)" },
213
+ pageToken: { type: "string", description: "Page token for cursor pagination" },
214
+ },
215
+ },
216
+ },
217
+ {
218
+ name: "jules_list_activities",
219
+ description: "List execution activities, logs, and error outputs for a specific Jules session.",
220
+ inputSchema: {
221
+ type: "object",
222
+ properties: {
223
+ sessionId: { type: "string", description: "Jules session ID" },
224
+ pageSize: { type: "number", description: "Maximum number of activities to return" },
225
+ pageToken: { type: "string", description: "Page token for pagination" },
226
+ },
227
+ required: ["sessionId"],
228
+ },
229
+ },
230
+ {
231
+ name: "jules_get_session_output",
232
+ description: "Extract the git diff patch, pull request metadata, and changed files from a Jules session.",
233
+ inputSchema: {
234
+ type: "object",
235
+ properties: {
236
+ sessionId: { type: "string", description: "Jules session ID" },
237
+ },
238
+ required: ["sessionId"],
239
+ },
240
+ },
241
+ {
242
+ name: "jules_archive_session",
243
+ description: "Archive a Jules coding session to clean up the dashboard.",
244
+ inputSchema: {
245
+ type: "object",
246
+ properties: {
247
+ sessionId: { type: "string", description: "Jules session ID to archive" },
248
+ },
249
+ required: ["sessionId"],
250
+ },
251
+ },
252
+ {
253
+ name: "jules_delete_session",
254
+ description: "Permanently delete a Jules coding session.",
255
+ inputSchema: {
256
+ type: "object",
257
+ properties: {
258
+ sessionId: { type: "string", description: "Jules session ID to delete" },
259
+ },
260
+ required: ["sessionId"],
261
+ },
262
+ },
263
+ {
264
+ name: "jules_retry_session",
265
+ description: "Retry a failed Jules session by extracting failure diagnostics and dispatching a new OODA repair session.",
266
+ inputSchema: {
267
+ type: "object",
268
+ properties: {
269
+ sessionId: { type: "string", description: "Original failed Jules session ID" },
270
+ role: { type: "string", description: "Optional specialist role override" },
271
+ withFailure: { type: "boolean", description: "Include previous failure diagnostic in retry prompt (default true)" },
272
+ },
273
+ required: ["sessionId"],
274
+ },
275
+ },
276
+ {
277
+ name: "jules_apply_patch",
278
+ description: "Extract and apply a Jules session's git patch to the local workspace with git apply safety verification.",
279
+ inputSchema: {
280
+ type: "object",
281
+ properties: {
282
+ sessionId: { type: "string", description: "Jules session ID to extract patch from" },
283
+ apply: { type: "boolean", description: "If true, applies the patch; if false, runs git apply --check dry-run" },
284
+ save: { type: "string", description: "Optional file path to save raw patch diff to" },
285
+ },
286
+ required: ["sessionId"],
287
+ },
288
+ },
289
+ {
290
+ name: "jules_list_sources",
291
+ description: "List connected GitHub repository sources available to the Jules account.",
292
+ inputSchema: {
293
+ type: "object",
294
+ properties: {
295
+ pageSize: { type: "number", description: "Maximum number of sources to return" },
296
+ pageToken: { type: "string", description: "Page token for pagination" },
297
+ },
298
+ },
299
+ },
300
+ {
301
+ name: "jules_prune_sessions",
302
+ description: "Batch-archive or prune old/completed Jules sessions matching age and state filters.",
303
+ inputSchema: {
304
+ type: "object",
305
+ properties: {
306
+ age: { type: "string", description: "Age cutoff string (e.g. '7d', '24h', '30m')" },
307
+ state: { type: "string", description: "Target session state to filter (e.g. 'FAILED', 'COMPLETED')" },
308
+ dryRun: { type: "boolean", description: "If true, previews sessions without modifying (default true)" },
309
+ delete: { type: "boolean", description: "If true, permanently deletes instead of archiving" },
310
+ },
311
+ },
312
+ },
199
313
  ];
200
314
 
201
315
  export async function handleMcpRequest(request, opts = {}) {
@@ -431,6 +545,169 @@ export async function handleMcpRequest(request, opts = {}) {
431
545
  };
432
546
  }
433
547
 
548
+ if (toolName === "jules_list_sessions") {
549
+ const provider = createProvider(config.provider || "jules", config);
550
+ const res = await provider.listSessions({ root, pageSize: args.pageSize, pageToken: args.pageToken });
551
+ return {
552
+ jsonrpc: "2.0",
553
+ id,
554
+ result: {
555
+ content: [{ type: "text", text: JSON.stringify({ ok: true, ...res }, null, 2) }],
556
+ },
557
+ };
558
+ }
559
+
560
+ if (toolName === "jules_list_activities") {
561
+ if (!args.sessionId) {
562
+ return {
563
+ jsonrpc: "2.0",
564
+ id,
565
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
566
+ };
567
+ }
568
+ const provider = createProvider(config.provider || "jules", config);
569
+ const res = await provider.listActivities(args.sessionId, { root, pageSize: args.pageSize, pageToken: args.pageToken });
570
+ return {
571
+ jsonrpc: "2.0",
572
+ id,
573
+ result: {
574
+ content: [{ type: "text", text: JSON.stringify({ ok: true, ...res }, null, 2) }],
575
+ },
576
+ };
577
+ }
578
+
579
+ if (toolName === "jules_get_session_output") {
580
+ if (!args.sessionId) {
581
+ return {
582
+ jsonrpc: "2.0",
583
+ id,
584
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
585
+ };
586
+ }
587
+ const res = await extractSessionPatch(args.sessionId, { root, config });
588
+ return {
589
+ jsonrpc: "2.0",
590
+ id,
591
+ result: {
592
+ content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
593
+ },
594
+ };
595
+ }
596
+
597
+ if (toolName === "jules_archive_session") {
598
+ if (!args.sessionId) {
599
+ return {
600
+ jsonrpc: "2.0",
601
+ id,
602
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
603
+ };
604
+ }
605
+ const provider = createProvider(config.provider || "jules", config);
606
+ const res = await provider.archiveSession(args.sessionId, { root });
607
+ return {
608
+ jsonrpc: "2.0",
609
+ id,
610
+ result: {
611
+ content: [{ type: "text", text: JSON.stringify({ ok: true, ...res }, null, 2) }],
612
+ },
613
+ };
614
+ }
615
+
616
+ if (toolName === "jules_delete_session") {
617
+ if (!args.sessionId) {
618
+ return {
619
+ jsonrpc: "2.0",
620
+ id,
621
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
622
+ };
623
+ }
624
+ const provider = createProvider(config.provider || "jules", config);
625
+ const res = await provider.deleteSession(args.sessionId, { root });
626
+ return {
627
+ jsonrpc: "2.0",
628
+ id,
629
+ result: {
630
+ content: [{ type: "text", text: JSON.stringify({ ok: true, ...res }, null, 2) }],
631
+ },
632
+ };
633
+ }
634
+
635
+ if (toolName === "jules_retry_session") {
636
+ if (!args.sessionId) {
637
+ return {
638
+ jsonrpc: "2.0",
639
+ id,
640
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
641
+ };
642
+ }
643
+ const res = await retrySession(args.sessionId, {
644
+ root,
645
+ config,
646
+ role: args.role,
647
+ withFailure: args.withFailure !== false,
648
+ });
649
+ return {
650
+ jsonrpc: "2.0",
651
+ id,
652
+ result: {
653
+ content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
654
+ },
655
+ };
656
+ }
657
+
658
+ if (toolName === "jules_apply_patch") {
659
+ if (!args.sessionId) {
660
+ return {
661
+ jsonrpc: "2.0",
662
+ id,
663
+ error: { code: -32602, message: "Missing required parameter 'sessionId'" },
664
+ };
665
+ }
666
+ const res = await applySessionPatch(args.sessionId, {
667
+ root,
668
+ config,
669
+ apply: Boolean(args.apply),
670
+ save: args.save,
671
+ });
672
+ return {
673
+ jsonrpc: "2.0",
674
+ id,
675
+ result: {
676
+ content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
677
+ },
678
+ };
679
+ }
680
+
681
+ if (toolName === "jules_list_sources") {
682
+ const provider = createProvider(config.provider || "jules", config);
683
+ const res = await provider.listSources({ root, pageSize: args.pageSize, pageToken: args.pageToken });
684
+ return {
685
+ jsonrpc: "2.0",
686
+ id,
687
+ result: {
688
+ content: [{ type: "text", text: JSON.stringify({ ok: true, ...res }, null, 2) }],
689
+ },
690
+ };
691
+ }
692
+
693
+ if (toolName === "jules_prune_sessions") {
694
+ const res = await pruneSessions({
695
+ root,
696
+ config,
697
+ age: args.age || "7d",
698
+ state: args.state,
699
+ delete: Boolean(args.delete),
700
+ dryRun: args.dryRun !== false,
701
+ });
702
+ return {
703
+ jsonrpc: "2.0",
704
+ id,
705
+ result: {
706
+ content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
707
+ },
708
+ };
709
+ }
710
+
434
711
  return {
435
712
  jsonrpc: "2.0",
436
713
  id,