opencode-magi 0.0.0-dev-20260521222649 → 0.0.0-dev-20260522033138
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/dist/index.js +12 -0
- package/dist/orchestrator/run-manager.js +21 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,6 +457,7 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
457
457
|
prs: tool.schema.string(),
|
|
458
458
|
dryRun: tool.schema.boolean().optional(),
|
|
459
459
|
sync: tool.schema.boolean().optional(),
|
|
460
|
+
timeoutSeconds: tool.schema.number().optional(),
|
|
460
461
|
},
|
|
461
462
|
async execute(args, context) {
|
|
462
463
|
const parsed = parseRunArguments(args.prs, args.dryRun ?? false, "merge");
|
|
@@ -482,6 +483,9 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
482
483
|
parentSessionId: context.sessionID,
|
|
483
484
|
signal: context.abort,
|
|
484
485
|
sync,
|
|
486
|
+
timeoutMs: args.timeoutSeconds == null
|
|
487
|
+
? undefined
|
|
488
|
+
: args.timeoutSeconds * 1_000,
|
|
485
489
|
}), { signal: context.abort });
|
|
486
490
|
if (sync)
|
|
487
491
|
return syncResult(runManager, states);
|
|
@@ -499,6 +503,7 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
499
503
|
prs: tool.schema.string(),
|
|
500
504
|
dryRun: tool.schema.boolean().optional(),
|
|
501
505
|
sync: tool.schema.boolean().optional(),
|
|
506
|
+
timeoutSeconds: tool.schema.number().optional(),
|
|
502
507
|
},
|
|
503
508
|
async execute(args, context) {
|
|
504
509
|
const parsed = parseRunArguments(args.prs, args.dryRun ?? false);
|
|
@@ -523,6 +528,9 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
523
528
|
parentSessionId: context.sessionID,
|
|
524
529
|
signal: context.abort,
|
|
525
530
|
sync,
|
|
531
|
+
timeoutMs: args.timeoutSeconds == null
|
|
532
|
+
? undefined
|
|
533
|
+
: args.timeoutSeconds * 1_000,
|
|
526
534
|
}), { signal: context.abort });
|
|
527
535
|
if (sync)
|
|
528
536
|
return syncResult(runManager, states);
|
|
@@ -537,6 +545,7 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
537
545
|
issues: tool.schema.string(),
|
|
538
546
|
dryRun: tool.schema.boolean().optional(),
|
|
539
547
|
sync: tool.schema.boolean().optional(),
|
|
548
|
+
timeoutSeconds: tool.schema.number().optional(),
|
|
540
549
|
},
|
|
541
550
|
async execute(args, context) {
|
|
542
551
|
const parsed = parseIssueRunArguments(args.issues, args.dryRun ?? false);
|
|
@@ -567,6 +576,9 @@ export const MagiPlugin = async ({ client, directory }) => {
|
|
|
567
576
|
repository,
|
|
568
577
|
signal: context.abort,
|
|
569
578
|
sync,
|
|
579
|
+
timeoutMs: args.timeoutSeconds == null
|
|
580
|
+
? undefined
|
|
581
|
+
: args.timeoutSeconds * 1_000,
|
|
570
582
|
}), { signal: context.abort });
|
|
571
583
|
if (sync)
|
|
572
584
|
return syncResult(runManager, states);
|
|
@@ -15,7 +15,6 @@ const DEFAULT_CLEAR_OPTIONS = {
|
|
|
15
15
|
session: true,
|
|
16
16
|
worktree: true,
|
|
17
17
|
};
|
|
18
|
-
const SYNC_RUN_TIMEOUT_MS = 600_000;
|
|
19
18
|
function createRunId() {
|
|
20
19
|
return `run-${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
|
|
21
20
|
}
|
|
@@ -460,7 +459,7 @@ export class MagiRunManager {
|
|
|
460
459
|
signal: controller.signal,
|
|
461
460
|
});
|
|
462
461
|
if (input.sync)
|
|
463
|
-
return this.executeSync(state, controller, execute);
|
|
462
|
+
return this.executeSync(state, controller, execute, input.timeoutMs);
|
|
464
463
|
void execute().catch(async (error) => {
|
|
465
464
|
await this.failRun(runId, error);
|
|
466
465
|
});
|
|
@@ -521,7 +520,7 @@ export class MagiRunManager {
|
|
|
521
520
|
signal: controller.signal,
|
|
522
521
|
});
|
|
523
522
|
if (input.sync)
|
|
524
|
-
return this.executeSync(state, controller, execute);
|
|
523
|
+
return this.executeSync(state, controller, execute, input.timeoutMs);
|
|
525
524
|
void execute().catch(async (error) => {
|
|
526
525
|
await this.failRun(runId, error);
|
|
527
526
|
});
|
|
@@ -581,14 +580,14 @@ export class MagiRunManager {
|
|
|
581
580
|
signal: controller.signal,
|
|
582
581
|
});
|
|
583
582
|
if (input.sync)
|
|
584
|
-
return this.executeSync(state, controller, execute);
|
|
583
|
+
return this.executeSync(state, controller, execute, input.timeoutMs);
|
|
585
584
|
void execute().catch(async (error) => {
|
|
586
585
|
await this.failRun(runId, error);
|
|
587
586
|
});
|
|
588
587
|
return state;
|
|
589
588
|
}
|
|
590
589
|
async status(input = {}) {
|
|
591
|
-
const timeoutMs =
|
|
590
|
+
const timeoutMs = input.timeoutMs;
|
|
592
591
|
const startedAt = Date.now();
|
|
593
592
|
while (input.block) {
|
|
594
593
|
const states = await this.filteredStates(input);
|
|
@@ -596,7 +595,7 @@ export class MagiRunManager {
|
|
|
596
595
|
hasAllRequestedPrStates(states, input.pr) &&
|
|
597
596
|
states.every((state) => !isActiveStatus(state.status)))
|
|
598
597
|
return states;
|
|
599
|
-
if (Date.now() - startedAt >= timeoutMs)
|
|
598
|
+
if (timeoutMs != null && Date.now() - startedAt >= timeoutMs)
|
|
600
599
|
return states;
|
|
601
600
|
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
602
601
|
}
|
|
@@ -1220,19 +1219,24 @@ export class MagiRunManager {
|
|
|
1220
1219
|
hasBlockedAgents(state) {
|
|
1221
1220
|
return this.agentEntries(state).some(([, agent]) => agent.status === "blocked");
|
|
1222
1221
|
}
|
|
1223
|
-
async executeSync(state, controller, execute) {
|
|
1222
|
+
async executeSync(state, controller, execute, timeoutMs) {
|
|
1224
1223
|
let timeout;
|
|
1225
|
-
const timeoutPromise =
|
|
1226
|
-
|
|
1227
|
-
|
|
1224
|
+
const timeoutPromise = timeoutMs == null
|
|
1225
|
+
? undefined
|
|
1226
|
+
: new Promise((resolve) => {
|
|
1227
|
+
timeout = setTimeout(() => resolve("timeout"), timeoutMs);
|
|
1228
|
+
});
|
|
1228
1229
|
try {
|
|
1229
|
-
const result = await
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1230
|
+
const result = await (timeoutPromise
|
|
1231
|
+
? Promise.race([
|
|
1232
|
+
execute().then(() => "completed"),
|
|
1233
|
+
timeoutPromise,
|
|
1234
|
+
])
|
|
1235
|
+
: execute().then(() => "completed"));
|
|
1233
1236
|
if (result === "timeout") {
|
|
1237
|
+
const timeoutSeconds = (timeoutMs ?? 0) / 1_000;
|
|
1234
1238
|
controller.abort();
|
|
1235
|
-
await this.failRun(state.runId, new Error(
|
|
1239
|
+
await this.failRun(state.runId, new Error(`Magi sync run timed out after ${timeoutSeconds} seconds.`));
|
|
1236
1240
|
}
|
|
1237
1241
|
}
|
|
1238
1242
|
catch (error) {
|
|
@@ -1395,6 +1399,7 @@ export class MagiRunManager {
|
|
|
1395
1399
|
repository: input.repository,
|
|
1396
1400
|
signal: input.signal,
|
|
1397
1401
|
sync: input.sync,
|
|
1402
|
+
timeoutMs: input.timeoutMs,
|
|
1398
1403
|
});
|
|
1399
1404
|
if (input.sync)
|
|
1400
1405
|
this.assertSuccessfulSyncFollowUp(followUp);
|
|
@@ -1408,6 +1413,7 @@ export class MagiRunManager {
|
|
|
1408
1413
|
repository: input.repository,
|
|
1409
1414
|
signal: input.signal,
|
|
1410
1415
|
sync: input.sync,
|
|
1416
|
+
timeoutMs: input.timeoutMs,
|
|
1411
1417
|
});
|
|
1412
1418
|
if (input.sync)
|
|
1413
1419
|
this.assertSuccessfulSyncFollowUp(followUp);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-magi",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260522033138",
|
|
4
4
|
"description": "Multi-agent PR review and merge orchestration plugin for OpenCode.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
|