hoi4-agent-tools 3.0.9 → 3.1.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/CHANGELOG.md +23 -1
- package/README.md +4 -0
- package/dist/bin/stdio.js +23 -12
- package/dist/hoi4_agent_tools/core/analysis-checkpoints.js +82 -0
- package/dist/hoi4_agent_tools/core/artifact-resource.js +173 -0
- package/dist/hoi4_agent_tools/core/artifacts.js +84 -2
- package/dist/hoi4_agent_tools/core/dependency-pages.js +216 -0
- package/dist/hoi4_agent_tools/core/dependency-walk.js +266 -0
- package/dist/hoi4_agent_tools/core/domain-validation.js +188 -0
- package/dist/hoi4_agent_tools/core/engine.js +48 -5
- package/dist/hoi4_agent_tools/core/helper-expansion.js +186 -0
- package/dist/hoi4_agent_tools/core/index-segments.js +137 -0
- package/dist/hoi4_agent_tools/core/index.js +47 -4
- package/dist/hoi4_agent_tools/core/job-controls.js +109 -0
- package/dist/hoi4_agent_tools/core/job-executor.js +190 -0
- package/dist/hoi4_agent_tools/core/job-service.js +112 -0
- package/dist/hoi4_agent_tools/core/job-store.js +641 -0
- package/dist/hoi4_agent_tools/core/job-transactions.js +126 -0
- package/dist/hoi4_agent_tools/core/job-worker-host.js +200 -0
- package/dist/hoi4_agent_tools/core/job-worker.js +62 -0
- package/dist/hoi4_agent_tools/core/operation-context.js +31 -0
- package/dist/hoi4_agent_tools/core/operation-result.js +412 -0
- package/dist/hoi4_agent_tools/core/operation-tasks.js +382 -0
- package/dist/hoi4_agent_tools/core/persistent-analysis-cache.js +383 -0
- package/dist/hoi4_agent_tools/core/result.js +1 -0
- package/dist/hoi4_agent_tools/core/scanner.js +15 -75
- package/dist/hoi4_agent_tools/core/semantic-dependencies.js +233 -0
- package/dist/hoi4_agent_tools/core/shared-request-capacity.js +43 -11
- package/dist/hoi4_agent_tools/core/source/cache.js +107 -0
- package/dist/hoi4_agent_tools/core/source/parser.js +11 -1
- package/dist/hoi4_agent_tools/core/transaction-execution.js +134 -0
- package/dist/hoi4_agent_tools/core/transactions.js +80 -27
- package/dist/hoi4_agent_tools/event/graph.js +214 -290
- package/dist/hoi4_agent_tools/event/helper-expansion.js +33 -0
- package/dist/hoi4_agent_tools/event/job-operations.js +51 -0
- package/dist/hoi4_agent_tools/event/operations.js +179 -0
- package/dist/hoi4_agent_tools/event/service.js +67 -15
- package/dist/hoi4_agent_tools/event/source-analysis.js +5 -4
- package/dist/hoi4_agent_tools/focus/job-operations.js +77 -0
- package/dist/hoi4_agent_tools/focus/tool-operations.js +669 -0
- package/dist/hoi4_agent_tools/focus/tool-support.js +123 -0
- package/dist/hoi4_agent_tools/gui/job-operations.js +81 -0
- package/dist/hoi4_agent_tools/gui/tool-operations.js +270 -0
- package/dist/hoi4_agent_tools/map/job-operations.js +76 -0
- package/dist/hoi4_agent_tools/map/tool-operations.js +493 -0
- package/dist/hoi4_agent_tools/mcp/prompts/probability.js +25 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register-modern.js +29 -0
- package/dist/hoi4_agent_tools/mcp/resources/register-modern.js +34 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js +4 -150
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +3 -219
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +188 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js +16 -6
- package/dist/hoi4_agent_tools/mcp/server/instructions.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/job-task-store.js +67 -0
- package/dist/hoi4_agent_tools/mcp/server/legacy-task-tools.js +20 -0
- package/dist/hoi4_agent_tools/mcp/server/modern-tasks.js +168 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js +17 -15
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +43 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js +2 -412
- package/dist/hoi4_agent_tools/mcp/server/task-request-context.js +9 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +14 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-definition.js +1 -0
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +1 -123
- package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +38 -21
- package/dist/hoi4_agent_tools/mcp/tools/event.js +24 -315
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +34 -1039
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +19 -504
- package/dist/hoi4_agent_tools/mcp/tools/job.js +46 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +21 -600
- package/dist/hoi4_agent_tools/mcp/tools/probability.js +39 -463
- package/dist/hoi4_agent_tools/mcp/tools/technology.js +40 -304
- package/dist/hoi4_agent_tools/mcp/transports/http.js +58 -1
- package/dist/hoi4_agent_tools/mcp/transports/modern-task-routing.js +109 -0
- package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +121 -0
- package/dist/hoi4_agent_tools/probability/job-operations.js +58 -0
- package/dist/hoi4_agent_tools/probability/operations.js +183 -0
- package/dist/hoi4_agent_tools/probability/service.js +24 -3
- package/dist/hoi4_agent_tools/schemas/common.js +2 -0
- package/dist/hoi4_agent_tools/schemas/event.js +72 -1
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +189 -0
- package/dist/hoi4_agent_tools/schemas/gui-requests.js +193 -0
- package/dist/hoi4_agent_tools/schemas/helper-expansion.js +58 -0
- package/dist/hoi4_agent_tools/schemas/map-requests.js +85 -0
- package/dist/hoi4_agent_tools/schemas/probability-requests.js +168 -0
- package/dist/hoi4_agent_tools/schemas/technology.js +90 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js +1 -0
- package/dist/hoi4_agent_tools/technology/graph.js +83 -78
- package/dist/hoi4_agent_tools/technology/helper-expansion.js +33 -0
- package/dist/hoi4_agent_tools/technology/job-operations.js +60 -0
- package/dist/hoi4_agent_tools/technology/operations.js +125 -0
- package/dist/hoi4_agent_tools/technology/service.js +89 -15
- package/dist/hoi4_agent_tools/technology/source-analysis.js +2 -1
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/README.md +2 -0
- package/docs/development.md +2 -0
- package/docs/events.md +7 -2
- package/docs/helper-expansion.md +78 -0
- package/docs/http.md +2 -0
- package/docs/jobs.md +85 -0
- package/docs/technology.md +6 -2
- package/package.json +11 -5
- package/schemas/configuration.schema.json +1 -1
- package/schemas/continuous-focus-palette.schema.json +1 -1
- package/schemas/custom-weighted-pool.schema.json +1 -1
- package/schemas/event-feature-manifest.schema.json +1 -1
- package/schemas/focus-plan.schema.json +1 -1
- package/schemas/focus-planning-sidecar.schema.json +1 -1
- package/schemas/gui-animation-source.schema.json +1 -1
- package/schemas/gui-helper.schema.json +1 -1
- package/schemas/gui-scenario.schema.json +1 -1
- package/schemas/helper-expansion-request.schema.json +44 -0
- package/schemas/helper-expansion-summary.schema.json +70 -0
- package/schemas/map-operation.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -312,6 +312,7 @@ export class TransactionManager {
|
|
|
312
312
|
diagnostics,
|
|
313
313
|
validation: { passed, checks: validation.checks },
|
|
314
314
|
artifacts,
|
|
315
|
+
executionArtifacts: [],
|
|
315
316
|
appliedFiles: [],
|
|
316
317
|
rollbackStatus: 'available',
|
|
317
318
|
};
|
|
@@ -398,11 +399,17 @@ export class TransactionManager {
|
|
|
398
399
|
}
|
|
399
400
|
if (manifest.diagnostics.length + result.diagnostics.length > TRANSACTION_MAX_DIAGNOSTICS ||
|
|
400
401
|
manifest.validation.checks.length + result.checks.length >
|
|
401
|
-
TRANSACTION_MAX_VALIDATION_CHECKS
|
|
402
|
-
|
|
402
|
+
TRANSACTION_MAX_VALIDATION_CHECKS ||
|
|
403
|
+
(manifest.executionArtifacts?.length ?? 0) + (result.artifacts?.length ?? 0) >
|
|
404
|
+
TRANSACTION_MAX_ARTIFACTS) {
|
|
405
|
+
throw new ServiceError('TRANSACTION_STRUCTURE_LIMIT', 'Post-write validation exceeds the supported transaction review or artifact limits');
|
|
403
406
|
}
|
|
404
407
|
manifest.diagnostics.push(...result.diagnostics);
|
|
405
408
|
manifest.validation.checks.push(...result.checks);
|
|
409
|
+
manifest.executionArtifacts ??= [];
|
|
410
|
+
for (const artifact of result.artifacts ?? [])
|
|
411
|
+
if (!manifest.executionArtifacts.some(({ uri }) => uri === artifact.uri))
|
|
412
|
+
manifest.executionArtifacts.push(artifact);
|
|
406
413
|
manifest.validation.passed =
|
|
407
414
|
manifest.validation.passed &&
|
|
408
415
|
result.checks.every(({ passed }) => passed) &&
|
|
@@ -513,6 +520,61 @@ export class TransactionManager {
|
|
|
513
520
|
totalSize: cached.bytes.length,
|
|
514
521
|
};
|
|
515
522
|
}
|
|
523
|
+
/** Reconcile one interrupted job's journal without sweeping unrelated transactions. */
|
|
524
|
+
async recoverTransaction(workspaceId, transactionId, principal, signal) {
|
|
525
|
+
signal?.throwIfAborted();
|
|
526
|
+
const workspace = this.resolver.get(workspaceId, principal);
|
|
527
|
+
// Authenticate the selected journal and authorize its owner before changing protected state.
|
|
528
|
+
const initial = await this.load(workspace, transactionId, {
|
|
529
|
+
headMode: 'none',
|
|
530
|
+
...(signal === undefined ? {} : { signal }),
|
|
531
|
+
});
|
|
532
|
+
this.assertRecoveryPrincipal(initial, principal);
|
|
533
|
+
return this.withWorkspaceLock(workspace, transactionId, async () => {
|
|
534
|
+
signal?.throwIfAborted();
|
|
535
|
+
// Never restore a pre-lock snapshot: a writer may have committed since the first read.
|
|
536
|
+
const current = await this.load(workspace, transactionId, {
|
|
537
|
+
headMode: 'none',
|
|
538
|
+
...(signal === undefined ? {} : { signal }),
|
|
539
|
+
});
|
|
540
|
+
this.assertRecoveryPrincipal(current, principal);
|
|
541
|
+
const manifest = await this.load(workspace, transactionId, {
|
|
542
|
+
headMode: 'reconcile',
|
|
543
|
+
...(signal === undefined ? {} : { signal }),
|
|
544
|
+
});
|
|
545
|
+
signal?.throwIfAborted();
|
|
546
|
+
if (manifest.state === 'applying' || manifest.state === 'rolling_back') {
|
|
547
|
+
await this.restoreInterruptedTransaction(workspace, manifest, principal);
|
|
548
|
+
}
|
|
549
|
+
return manifest;
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
assertRecoveryPrincipal(manifest, principal) {
|
|
553
|
+
if (principal !== undefined && (manifest.principal ?? null) !== principal) {
|
|
554
|
+
throw new ServiceError('TRANSACTION_PRINCIPAL_MISMATCH', 'Transaction recovery belongs to another principal');
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
async restoreInterruptedTransaction(workspace, manifest, principal) {
|
|
558
|
+
// Restoration and authenticated journal advancement are a non-cancellable critical phase.
|
|
559
|
+
try {
|
|
560
|
+
await this.restoreBeforeState(workspace, manifest, principal);
|
|
561
|
+
manifest.state = 'rolled_back';
|
|
562
|
+
manifest.failure = {
|
|
563
|
+
code: 'TRANSACTION_RECOVERED',
|
|
564
|
+
message: 'Incomplete transaction was rolled back during recovery',
|
|
565
|
+
};
|
|
566
|
+
await this.writeManifest(workspace, manifest);
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
manifest.rollbackStatus = 'failed';
|
|
570
|
+
manifest.state = 'failed';
|
|
571
|
+
manifest.failure = this.safeFailure(error, 'TRANSACTION_RECOVERY_FAILED', 'Interrupted transaction could not be recovered safely');
|
|
572
|
+
await this.writeManifest(workspace, manifest);
|
|
573
|
+
if (error instanceof ServiceError)
|
|
574
|
+
throw error;
|
|
575
|
+
throw new ServiceError('TRANSACTION_RECOVERY_FAILED', 'Interrupted transaction could not be recovered safely');
|
|
576
|
+
}
|
|
577
|
+
}
|
|
516
578
|
async recover(workspaceId, principal, signal) {
|
|
517
579
|
signal?.throwIfAborted();
|
|
518
580
|
const workspace = this.resolver.get(workspaceId, principal);
|
|
@@ -536,38 +598,29 @@ export class TransactionManager {
|
|
|
536
598
|
if (!transactionIdPattern.test(entry.name))
|
|
537
599
|
continue;
|
|
538
600
|
const manifest = await this.load(workspace, entry.name, {
|
|
539
|
-
headMode: '
|
|
601
|
+
headMode: 'none',
|
|
540
602
|
...(signal === undefined ? {} : { signal }),
|
|
541
603
|
});
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (manifest.state !== 'applying' && manifest.state !== 'rolling_back')
|
|
546
|
-
continue;
|
|
547
|
-
await this.withWorkspaceLock(workspace, manifest.transactionId, async () => {
|
|
548
|
-
signal?.throwIfAborted();
|
|
549
|
-
// Once source restoration starts, recovery and authenticated journal
|
|
550
|
-
// advancement form a non-cancellable critical phase.
|
|
604
|
+
this.assertRecoveryPrincipal(manifest, principal);
|
|
605
|
+
const interrupted = manifest.state === 'applying' || manifest.state === 'rolling_back';
|
|
606
|
+
if (!interrupted) {
|
|
551
607
|
try {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
};
|
|
558
|
-
await this.writeManifest(workspace, manifest);
|
|
608
|
+
// Ordinary startup must not contend with a live writer just to read terminal journals.
|
|
609
|
+
await this.load(workspace, entry.name, {
|
|
610
|
+
...(signal === undefined ? {} : { signal }),
|
|
611
|
+
});
|
|
612
|
+
continue;
|
|
559
613
|
}
|
|
560
614
|
catch (error) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
manifest.failure = this.safeFailure(error, 'TRANSACTION_RECOVERY_FAILED', 'Interrupted transaction could not be recovered safely');
|
|
564
|
-
await this.writeManifest(workspace, manifest);
|
|
565
|
-
if (error instanceof ServiceError)
|
|
615
|
+
if (!(error instanceof ServiceError) ||
|
|
616
|
+
error.code !== 'TRANSACTION_HEAD_RECONCILIATION_REQUIRED')
|
|
566
617
|
throw error;
|
|
567
|
-
throw new ServiceError('TRANSACTION_RECOVERY_FAILED', 'Interrupted transaction could not be recovered safely');
|
|
568
618
|
}
|
|
569
|
-
}
|
|
570
|
-
|
|
619
|
+
}
|
|
620
|
+
const reconciled = await this.recoverTransaction(workspaceId, entry.name, principal, signal);
|
|
621
|
+
if (interrupted) {
|
|
622
|
+
recovered.push(reconciled);
|
|
623
|
+
}
|
|
571
624
|
}
|
|
572
625
|
return recovered;
|
|
573
626
|
}
|