intentdna 1.9.0 → 1.9.3

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 (131) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +227 -87
  4. package/dist/cli/commands/run-lifecycle.d.ts +61 -11
  5. package/dist/cli/commands/run-lifecycle.js +184 -50
  6. package/dist/cli/commands/run-observer.d.ts +15 -0
  7. package/dist/cli/commands/run-observer.js +210 -0
  8. package/dist/cli/commands/run.d.ts +16 -20
  9. package/dist/cli/commands/run.js +461 -659
  10. package/dist/cli/commands/sync.js +16 -12
  11. package/dist/cli/index.js +14 -5
  12. package/dist/compiler/compile.d.ts +1 -0
  13. package/dist/compiler/compile.js +1 -1
  14. package/dist/compiler/controller.d.ts +16 -0
  15. package/dist/compiler/controller.js +693 -0
  16. package/dist/compiler/input-resolver.d.ts +2 -0
  17. package/dist/compiler/input-resolver.js +22 -6
  18. package/dist/hooks/cli.d.ts +45 -0
  19. package/dist/hooks/cli.js +263 -31
  20. package/dist/hooks/host-event.d.ts +57 -0
  21. package/dist/hooks/host-event.js +187 -0
  22. package/dist/hooks/index.d.ts +1 -0
  23. package/dist/hooks/index.js +1 -0
  24. package/dist/hooks/protocol.d.ts +7 -0
  25. package/dist/hooks/schema.d.ts +1 -0
  26. package/dist/hooks/schema.js +89 -1
  27. package/dist/hooks/state.d.ts +23 -1
  28. package/dist/hooks/state.js +9 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/mcp/index.js +2 -0
  32. package/dist/mcp/tools-run.d.ts +4 -0
  33. package/dist/mcp/tools-run.js +419 -0
  34. package/dist/mcp/tools-state.d.ts +1 -1
  35. package/dist/mcp/tools-state.js +13 -241
  36. package/dist/runtime/artifact-store.d.ts +146 -0
  37. package/dist/runtime/artifact-store.js +1436 -0
  38. package/dist/runtime/canonical-attempt-outcome.d.ts +12 -0
  39. package/dist/runtime/canonical-attempt-outcome.js +195 -0
  40. package/dist/runtime/canonical-json.d.ts +10 -0
  41. package/dist/runtime/canonical-json.js +105 -0
  42. package/dist/runtime/canonical-run-application.d.ts +93 -0
  43. package/dist/runtime/canonical-run-application.js +229 -0
  44. package/dist/runtime/canonical-run-service.d.ts +454 -0
  45. package/dist/runtime/canonical-run-service.js +4760 -0
  46. package/dist/runtime/canonical-runtime-composition.d.ts +22 -0
  47. package/dist/runtime/canonical-runtime-composition.js +34 -0
  48. package/dist/runtime/canonical-runtime-projection.d.ts +3 -0
  49. package/dist/runtime/canonical-runtime-projection.js +4 -0
  50. package/dist/runtime/canonical-target-compiler.d.ts +46 -0
  51. package/dist/runtime/canonical-target-compiler.js +514 -0
  52. package/dist/runtime/claude-agent-identity.d.ts +2 -0
  53. package/dist/runtime/claude-agent-identity.js +21 -0
  54. package/dist/runtime/executable-run-plan.d.ts +328 -0
  55. package/dist/runtime/executable-run-plan.js +1485 -0
  56. package/dist/runtime/execution-authority.d.ts +83 -0
  57. package/dist/runtime/execution-authority.js +98 -0
  58. package/dist/runtime/handoff-resolver.js +4 -1
  59. package/dist/runtime/harness-pull-adapter.d.ts +146 -0
  60. package/dist/runtime/harness-pull-adapter.js +315 -0
  61. package/dist/runtime/index.d.ts +39 -14
  62. package/dist/runtime/index.js +29 -7
  63. package/dist/runtime/local-execution-authority.d.ts +194 -0
  64. package/dist/runtime/local-execution-authority.js +2897 -0
  65. package/dist/runtime/local-execution-reconciliation.d.ts +20 -0
  66. package/dist/runtime/local-execution-reconciliation.js +107 -0
  67. package/dist/runtime/local-execution-supervisor-script.d.ts +7 -0
  68. package/dist/runtime/local-execution-supervisor-script.js +793 -0
  69. package/dist/runtime/local-provider-sandbox.d.ts +42 -0
  70. package/dist/runtime/local-provider-sandbox.js +154 -0
  71. package/dist/runtime/local-verifier-execution.d.ts +24 -0
  72. package/dist/runtime/local-verifier-execution.js +290 -0
  73. package/dist/runtime/local-windows-execution-supervisor-script.d.ts +6 -0
  74. package/dist/runtime/local-windows-execution-supervisor-script.js +788 -0
  75. package/dist/runtime/plan-store.d.ts +30 -0
  76. package/dist/runtime/plan-store.js +231 -0
  77. package/dist/runtime/process-tree.d.ts +9 -0
  78. package/dist/runtime/process-tree.js +97 -24
  79. package/dist/runtime/providers/codex.js +2 -2
  80. package/dist/runtime/push-driver.d.ts +184 -0
  81. package/dist/runtime/push-driver.js +1002 -0
  82. package/dist/runtime/result-store.d.ts +34 -3
  83. package/dist/runtime/result-store.js +1073 -2
  84. package/dist/runtime/run-binding.d.ts +68 -0
  85. package/dist/runtime/run-binding.js +278 -0
  86. package/dist/runtime/run-contracts.d.ts +575 -0
  87. package/dist/runtime/run-contracts.js +58 -7
  88. package/dist/runtime/run-controller.d.ts +1 -6
  89. package/dist/runtime/run-controller.js +0 -41
  90. package/dist/runtime/run-store.d.ts +85 -7
  91. package/dist/runtime/run-store.js +2528 -186
  92. package/dist/runtime/skill-adapter.d.ts +18 -7
  93. package/dist/runtime/skill-adapter.js +100 -742
  94. package/dist/runtime/structured-output-validator.d.ts +44 -0
  95. package/dist/runtime/structured-output-validator.js +171 -0
  96. package/dist/runtime/verifier-command-binding.d.ts +22 -0
  97. package/dist/runtime/verifier-command-binding.js +162 -0
  98. package/dist/runtime/verifier.d.ts +46 -6
  99. package/dist/runtime/verifier.js +355 -53
  100. package/dist/runtime/windows-job-keeper.d.ts +47 -0
  101. package/dist/runtime/windows-job-keeper.js +231 -0
  102. package/dist/runtime/worker-executor.d.ts +17 -1
  103. package/dist/runtime/worker-executor.js +26 -5
  104. package/dist/runtime/workflow-plan-adapter.d.ts +19 -0
  105. package/dist/runtime/workflow-plan-adapter.js +502 -6
  106. package/dist/runtime/workflow-runtime-manifest.d.ts +1 -0
  107. package/dist/runtime/workflow-runtime-manifest.js +5 -0
  108. package/dist/runtime/workspace-isolation.d.ts +29 -2
  109. package/dist/runtime/workspace-isolation.js +488 -11
  110. package/dist/runtime/workspace-observation.d.ts +44 -0
  111. package/dist/runtime/workspace-observation.js +216 -0
  112. package/dist/schema/controller-registry.d.ts +0 -7
  113. package/dist/schema/controller-registry.js +0 -8
  114. package/dist/schema/types.d.ts +84 -10
  115. package/dist/schema/types.js +2 -0
  116. package/dist/schema/validate.js +151 -1
  117. package/dist/schema/validators/controllers.d.ts +1 -1
  118. package/dist/schema/validators/controllers.js +126 -41
  119. package/dist/schema/workflow-authoring-contract.js +2 -0
  120. package/dist/schema/yaml-parser.js +1 -1
  121. package/dist/templates/flutter-rewrite-new.dna.yaml +1 -0
  122. package/dist/templates/flutter-rewrite.dna.yaml +87 -60
  123. package/dist/templates/safe-refactoring.dna.yaml +1 -0
  124. package/native/windows-job-keeper/README.md +80 -0
  125. package/native/windows-job-keeper/bin/aarch64/intentdna-windows-job-keeper.exe +0 -0
  126. package/native/windows-job-keeper/bin/x86_64/intentdna-windows-job-keeper.exe +0 -0
  127. package/native/windows-job-keeper/keeper.c +979 -0
  128. package/native/windows-job-keeper/manifest.json +33 -0
  129. package/package.json +6 -2
  130. package/scripts/build-windows-job-keeper.mjs +172 -0
  131. package/scripts/verify-windows-job-keeper.mjs +184 -0
@@ -16,6 +16,7 @@ interface ControllerHandoffBase {
16
16
  export interface ControllerReferenceHandoff extends ControllerHandoffBase {
17
17
  readonly mode: "reference";
18
18
  readonly source: SourceWithoutResultId;
19
+ readonly artifact_kind: "file" | "directory" | "git_commit";
19
20
  }
20
21
  export interface ControllerQuoteHandoff extends ControllerHandoffBase {
21
22
  readonly mode: "quote";
@@ -153,11 +154,5 @@ export declare class RunController {
153
154
  requestCancellation(runId: RunId, reason?: string | null): Promise<RunStoreSnapshot>;
154
155
  private finalizeRunIfTerminal;
155
156
  private launchClaimed;
156
- /**
157
- * Runs scheduling until durable terminal state. Every successful claim creates
158
- * a fresh attempt and worker session; this Controller never gives a worker a
159
- * second Step.
160
- */
161
- runUntilTerminal(runId: RunId): Promise<RunStoreSnapshot>;
162
157
  }
163
158
  export {};
@@ -1205,45 +1205,4 @@ export class RunController {
1205
1205
  });
1206
1206
  return completion;
1207
1207
  }
1208
- /**
1209
- * Runs scheduling until durable terminal state. Every successful claim creates
1210
- * a fresh attempt and worker session; this Controller never gives a worker a
1211
- * second Step.
1212
- */
1213
- async runUntilTerminal(runId) {
1214
- while (true) {
1215
- let snapshot = await this.resume(runId);
1216
- snapshot = await this.refreshDependencyReadiness(runId);
1217
- snapshot = await this.finalizeRunIfTerminal(runId);
1218
- if (snapshot.run.terminal !== null)
1219
- return snapshot;
1220
- let launched = false;
1221
- while (this.active.size < this.maxConcurrency) {
1222
- const claimed = await this.claimNextReady(runId);
1223
- if (!claimed)
1224
- break;
1225
- launched = true;
1226
- void this.launchClaimed(claimed);
1227
- }
1228
- if (this.active.size > 0) {
1229
- await Promise.race([...this.active.values()].map((entry) => entry.completion));
1230
- continue;
1231
- }
1232
- snapshot = await this.store.requireRun(runId);
1233
- const externallyActive = snapshot.tasks.some((task) => task.state === "claimed" || task.state === "running");
1234
- const retryPending = snapshot.tasks.some((task) => {
1235
- if (task.state !== "ready")
1236
- return false;
1237
- const definition = this.definitionByStep.get(task.step_id);
1238
- return definition
1239
- ? this.readyAt(definition, task, snapshot) > this.now().getTime()
1240
- : false;
1241
- });
1242
- if (externallyActive || retryPending || launched) {
1243
- await sleep(this.schedulerPollMs);
1244
- continue;
1245
- }
1246
- throw new RunControllerError("scheduler_stalled", `run ${runId} has no runnable or active Step`);
1247
- }
1248
- }
1249
1208
  }
@@ -1,5 +1,9 @@
1
- import type { AttemptRecord, CommittedStepResult, JsonValue, RunId, RuntimeEvent, TaskClaim, TaskRecord } from "./run-contracts.js";
1
+ import type { CanonicalActivationRecord, CanonicalAttemptClaim, CanonicalAttemptRecord, CanonicalResultRef, CanonicalRuntimeEvent, AttemptRecord, CommittedStepResult, JsonValue, RunId, RuntimeEvent, TaskClaim, TaskRecord } from "./run-contracts.js";
2
+ import type { Sha256Digest } from "./executable-run-plan.js";
3
+ import { type StoredRunBinding } from "./run-binding.js";
4
+ export declare const LEGACY_RUN_STORE_SCHEMA_VERSION: 1;
2
5
  export declare const RUN_STORE_SCHEMA_VERSION: 1;
6
+ export declare const CANONICAL_RUN_STORE_SCHEMA_VERSION: 2;
3
7
  export declare const RUN_STATUS_VALUES: readonly ["active", "cancelling", "succeeded", "failed", "cancelled"];
4
8
  export type RunStatus = typeof RUN_STATUS_VALUES[number];
5
9
  export type TerminalRunStatus = Extract<RunStatus, "succeeded" | "failed" | "cancelled">;
@@ -12,6 +16,9 @@ export interface RunTerminalRecord {
12
16
  readonly reason: string | null;
13
17
  readonly completed_at: string;
14
18
  }
19
+ export interface CanonicalRunTerminalRecord extends RunTerminalRecord {
20
+ readonly reason_code: string;
21
+ }
15
22
  export interface RunRecord {
16
23
  readonly run_id: RunId;
17
24
  readonly workflow_id: string;
@@ -30,7 +37,7 @@ export interface RunRecord {
30
37
  */
31
38
  export type StoredTaskClaim = TaskClaim;
32
39
  export interface RunStoreSnapshot {
33
- readonly schema_version: typeof RUN_STORE_SCHEMA_VERSION;
40
+ readonly schema_version: typeof LEGACY_RUN_STORE_SCHEMA_VERSION;
34
41
  readonly record_version: number;
35
42
  readonly run: RunRecord;
36
43
  readonly tasks: readonly TaskRecord[];
@@ -41,10 +48,44 @@ export interface RunStoreSnapshot {
41
48
  readonly created_at: string;
42
49
  readonly updated_at: string;
43
50
  }
51
+ export interface CanonicalRunTarget {
52
+ readonly kind: "workflow" | "controller";
53
+ readonly key: string;
54
+ }
55
+ export interface CanonicalRunRecord {
56
+ readonly run_id: RunId;
57
+ readonly target: CanonicalRunTarget;
58
+ readonly plan_id: Sha256Digest;
59
+ readonly plan_digest: Sha256Digest;
60
+ readonly run_binding: StoredRunBinding;
61
+ readonly status: RunStatus;
62
+ readonly cancellation: RunCancellationIntent | null;
63
+ readonly terminal: CanonicalRunTerminalRecord | null;
64
+ readonly metadata: JsonValue;
65
+ readonly created_at: string;
66
+ readonly updated_at: string;
67
+ }
68
+ export interface CanonicalRunStoreSnapshot {
69
+ readonly schema_version: typeof CANONICAL_RUN_STORE_SCHEMA_VERSION;
70
+ readonly record_version: number;
71
+ readonly run: CanonicalRunRecord;
72
+ readonly activations: readonly CanonicalActivationRecord[];
73
+ readonly attempts: readonly CanonicalAttemptRecord[];
74
+ readonly claims: readonly CanonicalAttemptClaim[];
75
+ readonly events: readonly CanonicalRuntimeEvent[];
76
+ readonly result_refs: readonly CanonicalResultRef[];
77
+ readonly created_at: string;
78
+ readonly updated_at: string;
79
+ }
80
+ export type AnyRunStoreSnapshot = RunStoreSnapshot | CanonicalRunStoreSnapshot;
44
81
  export interface CreateRunStoreRecord {
45
82
  readonly run: RunRecord;
46
83
  readonly tasks?: readonly TaskRecord[];
47
84
  }
85
+ export interface CreateCanonicalRunStoreRecord {
86
+ readonly run: CanonicalRunRecord;
87
+ readonly activations?: readonly CanonicalActivationRecord[];
88
+ }
48
89
  /**
49
90
  * Collections are upserted by their durable identity. Events and results are
50
91
  * append-only: an exact/idempotent replay is ignored and a conflict is rejected.
@@ -65,6 +106,22 @@ export interface RunStoreUpdateResult {
65
106
  readonly duplicate_event_ids: readonly string[];
66
107
  readonly duplicate_result_ids: readonly string[];
67
108
  }
109
+ export interface CanonicalRunStoreUpdate {
110
+ readonly run_id: RunId;
111
+ readonly expected_record_version: number;
112
+ readonly run?: CanonicalRunRecord;
113
+ readonly activations?: readonly CanonicalActivationRecord[];
114
+ readonly attempts?: readonly CanonicalAttemptRecord[];
115
+ readonly claims?: readonly CanonicalAttemptClaim[];
116
+ readonly events?: readonly CanonicalRuntimeEvent[];
117
+ readonly result_refs?: readonly CanonicalResultRef[];
118
+ }
119
+ export interface CanonicalRunStoreUpdateResult {
120
+ readonly snapshot: CanonicalRunStoreSnapshot;
121
+ readonly applied: boolean;
122
+ readonly duplicate_event_ids: readonly string[];
123
+ readonly duplicate_result_ids: readonly string[];
124
+ }
68
125
  export interface DurableRunStoreOptions {
69
126
  readonly root_directory: string;
70
127
  readonly lock_wait_ms?: number;
@@ -72,25 +129,46 @@ export interface DurableRunStoreOptions {
72
129
  readonly lock_retry_ms?: number;
73
130
  readonly lock_heartbeat_ms?: number;
74
131
  }
75
- export type RunStoreErrorCode = "invalid_options" | "invalid_record" | "unsupported_schema" | "run_exists" | "run_not_found" | "version_conflict" | "immutable_record" | "identity_conflict" | "event_conflict" | "result_conflict" | "lock_timeout" | "lock_lost";
132
+ export type RunStoreErrorCode = "invalid_options" | "invalid_record" | "unsupported_schema" | "unsupported_legacy_run" | "run_exists" | "run_not_found" | "version_conflict" | "immutable_record" | "identity_conflict" | "event_conflict" | "result_conflict" | "lock_timeout" | "lock_lost";
76
133
  export declare class RunStoreError extends Error {
77
134
  readonly code: RunStoreErrorCode;
78
- constructor(code: RunStoreErrorCode, message: string);
135
+ constructor(code: RunStoreErrorCode, message: string, options?: ErrorOptions);
79
136
  }
80
137
  export declare class DurableRunStore {
81
138
  private readonly options;
82
139
  constructor(options: DurableRunStoreOptions);
140
+ serviceOwnedRuntimeDirectory(component: "handoffs" | "workspace-locks"): string;
83
141
  private runDirectory;
84
142
  private ledgerPath;
85
- private lockDirectory;
143
+ private versionsDirectory;
144
+ private versionPath;
145
+ private readLedgerSnapshot;
146
+ private readCommittedHeadFromDirectory;
147
+ private readCommittedHead;
148
+ private readProjectionForRepair;
149
+ private projectCommittedHead;
150
+ protected beforeLedgerCommit(_snapshot: AnyRunStoreSnapshot): Promise<void>;
151
+ protected afterLedgerCommit(_snapshot: AnyRunStoreSnapshot): Promise<void>;
152
+ private commitSnapshot;
153
+ private readAnySnapshot;
86
154
  private readSnapshot;
87
155
  createRun(input: CreateRunStoreRecord): Promise<RunStoreSnapshot>;
156
+ createCanonicalRun(input: CreateCanonicalRunStoreRecord): Promise<CanonicalRunStoreSnapshot>;
88
157
  loadRun(runId: RunId): Promise<RunStoreSnapshot | null>;
89
158
  requireRun(runId: RunId): Promise<RunStoreSnapshot>;
159
+ cancelLegacyRun(runId: RunId, reason?: string | null): Promise<RunStoreSnapshot>;
160
+ closeLegacyRun(runId: RunId, reason?: string | null): Promise<RunStoreSnapshot>;
161
+ loadAnyRun(runId: RunId): Promise<AnyRunStoreSnapshot | null>;
162
+ requireAnyRun(runId: RunId): Promise<AnyRunStoreSnapshot>;
163
+ loadCanonicalRun(runId: RunId): Promise<CanonicalRunStoreSnapshot | null>;
164
+ requireCanonicalRun(runId: RunId): Promise<CanonicalRunStoreSnapshot>;
90
165
  updateRun(update: RunStoreUpdate): Promise<RunStoreUpdateResult>;
166
+ updateCanonicalRun(update: CanonicalRunStoreUpdate): Promise<CanonicalRunStoreUpdateResult>;
167
+ loadAllAnyRuns(): Promise<readonly AnyRunStoreSnapshot[]>;
91
168
  /**
92
- * Reads every valid run ledger after restart. No worker-session directory is
93
- * consulted, and this store intentionally exposes no worker cleanup operation.
169
+ * Reads every valid legacy ledger after restart while allowing canonical
170
+ * ledgers to coexist in the same durable root.
94
171
  */
95
172
  loadAllRuns(): Promise<readonly RunStoreSnapshot[]>;
173
+ loadAllCanonicalRuns(): Promise<readonly CanonicalRunStoreSnapshot[]>;
96
174
  }