@rigkit/engine 0.2.6 → 0.2.8

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/index.ts CHANGED
@@ -10,6 +10,13 @@ export type {
10
10
  EngineOperationKind,
11
11
  EngineOperationSource,
12
12
  EngineOperationSummary,
13
+ EngineCacheClearResult,
14
+ EngineCacheClearScope,
15
+ EngineCacheEntry,
16
+ EngineCacheList,
17
+ EngineCacheScope,
18
+ GlobalFragmentStateLocationInput,
19
+ GlobalFragmentStateLocator,
13
20
  InteractionPresenter,
14
21
  InteractionPresentationRequest,
15
22
  } from "./engine.ts";
package/src/state.ts CHANGED
@@ -60,6 +60,11 @@ export interface StateService {
60
60
  upstreamRunIds: readonly string[];
61
61
  }): WorkflowNodeRunRecord | undefined;
62
62
  saveNodeRun(run: WorkflowNodeRunRecord): void;
63
+ clearNodeRuns(input?: {
64
+ workflow?: string;
65
+ nodePaths?: readonly string[];
66
+ }): number;
67
+ deleteNodeRunsById(ids: readonly string[]): number;
63
68
  invalidateNodeRuns(input: {
64
69
  workflow: string;
65
70
  nodePaths: readonly string[];
@@ -174,6 +179,37 @@ export class StateStore implements StateService {
174
179
  this.db.insert(workflowNodeRuns).values(run).run();
175
180
  }
176
181
 
182
+ clearNodeRuns(input: {
183
+ workflow?: string;
184
+ nodePaths?: readonly string[];
185
+ } = {}): number {
186
+ const nodePaths = input.nodePaths ? new Set(input.nodePaths) : undefined;
187
+ const rows = this.db
188
+ .select({ id: workflowNodeRuns.id, workflow: workflowNodeRuns.workflow, nodePath: workflowNodeRuns.nodePath })
189
+ .from(workflowNodeRuns)
190
+ .all()
191
+ .filter((row) =>
192
+ (input.workflow === undefined || row.workflow === input.workflow) &&
193
+ (nodePaths === undefined || nodePaths.has(row.nodePath))
194
+ );
195
+
196
+ for (const row of rows) {
197
+ this.db.delete(workflowNodeRuns).where(eq(workflowNodeRuns.id, row.id)).run();
198
+ }
199
+
200
+ return rows.length;
201
+ }
202
+
203
+ deleteNodeRunsById(ids: readonly string[]): number {
204
+ if (ids.length === 0) return 0;
205
+ let deleted = 0;
206
+ for (const id of ids) {
207
+ this.db.delete(workflowNodeRuns).where(eq(workflowNodeRuns.id, id)).run();
208
+ deleted += 1;
209
+ }
210
+ return deleted;
211
+ }
212
+
177
213
  invalidateNodeRuns(input: {
178
214
  workflow: string;
179
215
  nodePaths: readonly string[];
package/src/types.ts CHANGED
@@ -95,7 +95,7 @@ export type LocalCommandResult = {
95
95
  stderr: string | null;
96
96
  };
97
97
 
98
- export type WorkflowLogStream = "stdout" | "stderr" | "info";
98
+ export type WorkflowLogStream = "stdout" | "stderr" | "info" | "debug" | "warn";
99
99
 
100
100
  export type WorkflowProviderDefinition<
101
101
  ProviderId extends string = string,
@@ -139,7 +139,6 @@ export type WorkflowRuntimeHelpers = {
139
139
  readonly workflow: string;
140
140
  readonly nodePath: string;
141
141
  metadata(metadata: JsonObject): void;
142
- log(data: string, options?: { stream?: WorkflowLogStream; label?: string }): void;
143
142
  };
144
143
 
145
144
  export const STEP_INVALIDATION_KIND = "rigkit.step.invalidate" as const;
@@ -166,9 +165,11 @@ export type WorkflowTaskRuntime<
166
165
  Providers extends WorkflowProviderMap,
167
166
  Context extends JsonObject,
168
167
  PreviousTaskIds extends string = string,
168
+ Config extends JsonObject = JsonObject,
169
169
  > = ProviderRuntimeMap<Providers> & {
170
170
  readonly providers: ProviderRuntimeMap<Providers>;
171
171
  readonly step: WorkflowStepRuntime<Context, PreviousTaskIds>;
172
+ readonly config: Readonly<Config>;
172
173
  };
173
174
 
174
175
  export type WorkflowTaskResult =
@@ -182,7 +183,8 @@ export type WorkflowTaskHandler<
182
183
  Context extends JsonObject,
183
184
  PreviousTaskIds extends string = string,
184
185
  Result extends WorkflowTaskResult = WorkflowTaskResult,
185
- > = (context: WorkflowTaskRuntime<Providers, Context, PreviousTaskIds>) => MaybePromise<Result>;
186
+ Config extends JsonObject = JsonObject,
187
+ > = (context: WorkflowTaskRuntime<Providers, Context, PreviousTaskIds, Config>) => MaybePromise<Result>;
186
188
 
187
189
  export type WorkflowInputFieldKind = "workspace" | "string" | "boolean" | "number";
188
190
 
@@ -424,6 +426,7 @@ export type WorkflowTaskCacheTTL =
424
426
  };
425
427
 
426
428
  export type WorkflowNodeKind = "task" | "sequence" | "parallel";
429
+ export type WorkflowCacheScope = "local" | "global";
427
430
 
428
431
  export type WorkflowDefinition<
429
432
  Name extends string = string,
@@ -490,6 +493,8 @@ export type WorkflowNodeDefinition<
490
493
  readonly nodeKind: WorkflowNodeKind;
491
494
  readonly name: string;
492
495
  readonly workflow: WorkflowDefinition<string, Providers>;
496
+ readonly cacheScope?: WorkflowCacheScope;
497
+ readonly config?: JsonObject;
493
498
  readonly workspaceDefinition?: WorkflowWorkspaceDefinition<Providers, OutputContext>;
494
499
  readonly operations?: readonly WorkflowOperationDefinition<Providers, any>[];
495
500
  readonly workspaceOperations?: readonly WorkflowWorkspaceOperationDefinition<Providers, OutputContext, any, any>[];
@@ -502,10 +507,17 @@ export type WorkflowTaskNode<
502
507
  Providers extends WorkflowProviderMap,
503
508
  InputContext extends JsonObject,
504
509
  OutputContext extends JsonObject,
510
+ Config extends JsonObject = {},
505
511
  > = WorkflowNodeDefinition<Providers, InputContext, OutputContext> & {
506
512
  readonly nodeKind: "task";
507
513
  readonly options?: WorkflowTaskOptions;
508
- readonly handler: WorkflowTaskHandler<Providers, InputContext, string, any>;
514
+ readonly handler: WorkflowTaskHandler<Providers, InputContext, string, any, Config>;
515
+
516
+ global(): WorkflowTaskNode<Providers, InputContext, OutputContext, Config>;
517
+ local(): WorkflowTaskNode<Providers, InputContext, OutputContext, Config>;
518
+ configure<const NextConfig extends JsonObject>(
519
+ config: NextConfig,
520
+ ): WorkflowTaskNode<Providers, InputContext, OutputContext, Merge<Config, NextConfig>>;
509
521
  };
510
522
 
511
523
  export type WorkflowSequenceBuilder<
@@ -516,13 +528,14 @@ export type WorkflowSequenceBuilder<
516
528
  OperationIds extends string = never,
517
529
  WorkspaceOperationIds extends string = never,
518
530
  PreviousTaskIds extends string = never,
531
+ Config extends JsonObject = {},
519
532
  > = WorkflowNodeDefinition<Providers, InputContext, OutputContext> & {
520
533
  readonly nodeKind: "sequence";
521
534
  readonly children: readonly WorkflowNodeDefinition<Providers, any, any>[];
522
535
 
523
536
  task<const Id extends string, Result extends WorkflowTaskResult>(
524
537
  name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
525
- handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result>,
538
+ handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result, Config>,
526
539
  ): WorkflowSequenceBuilder<
527
540
  Providers,
528
541
  InputContext,
@@ -530,7 +543,8 @@ export type WorkflowSequenceBuilder<
530
543
  WorkspaceData,
531
544
  OperationIds,
532
545
  WorkspaceOperationIds,
533
- PreviousTaskIds | Id
546
+ PreviousTaskIds | Id,
547
+ Config
534
548
  >;
535
549
 
536
550
  task<
@@ -540,7 +554,7 @@ export type WorkflowSequenceBuilder<
540
554
  >(
541
555
  name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
542
556
  options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
543
- handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult>,
557
+ handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult, Config>,
544
558
  ): WorkflowSequenceBuilder<
545
559
  Providers,
546
560
  InputContext,
@@ -548,12 +562,13 @@ export type WorkflowSequenceBuilder<
548
562
  WorkspaceData,
549
563
  OperationIds,
550
564
  WorkspaceOperationIds,
551
- PreviousTaskIds | Id
565
+ PreviousTaskIds | Id,
566
+ Config
552
567
  >;
553
568
 
554
569
  step<const Id extends string, Result extends WorkflowTaskResult>(
555
570
  name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
556
- handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result>,
571
+ handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result, Config>,
557
572
  ): WorkflowSequenceBuilder<
558
573
  Providers,
559
574
  InputContext,
@@ -561,7 +576,8 @@ export type WorkflowSequenceBuilder<
561
576
  WorkspaceData,
562
577
  OperationIds,
563
578
  WorkspaceOperationIds,
564
- PreviousTaskIds | Id
579
+ PreviousTaskIds | Id,
580
+ Config
565
581
  >;
566
582
 
567
583
  step<
@@ -571,7 +587,7 @@ export type WorkflowSequenceBuilder<
571
587
  >(
572
588
  name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
573
589
  options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
574
- handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult>,
590
+ handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult, Config>,
575
591
  ): WorkflowSequenceBuilder<
576
592
  Providers,
577
593
  InputContext,
@@ -579,7 +595,8 @@ export type WorkflowSequenceBuilder<
579
595
  WorkspaceData,
580
596
  OperationIds,
581
597
  WorkspaceOperationIds,
582
- PreviousTaskIds | Id
598
+ PreviousTaskIds | Id,
599
+ Config
583
600
  >;
584
601
 
585
602
  add<Node extends WorkflowNodeDefinition<Providers, any, any>>(
@@ -591,7 +608,8 @@ export type WorkflowSequenceBuilder<
591
608
  WorkspaceData,
592
609
  OperationIds,
593
610
  WorkspaceOperationIds,
594
- PreviousTaskIds
611
+ PreviousTaskIds,
612
+ Config
595
613
  >;
596
614
 
597
615
  parallel<const Branches extends Record<string, WorkflowNodeDefinition<Providers, any, any>>>(
@@ -607,7 +625,8 @@ export type WorkflowSequenceBuilder<
607
625
  WorkspaceData,
608
626
  OperationIds,
609
627
  WorkspaceOperationIds,
610
- PreviousTaskIds
628
+ PreviousTaskIds,
629
+ Config
611
630
  >;
612
631
 
613
632
  workspace<Data extends JsonObject>(
@@ -619,7 +638,8 @@ export type WorkflowSequenceBuilder<
619
638
  ReadonlyWorkspaceContext<Data>,
620
639
  OperationIds,
621
640
  WorkspaceOperationIds,
622
- PreviousTaskIds
641
+ PreviousTaskIds,
642
+ Config
623
643
  >;
624
644
 
625
645
  operation<const Id extends string, Input extends object = {}>(
@@ -632,7 +652,8 @@ export type WorkflowSequenceBuilder<
632
652
  WorkspaceData,
633
653
  OperationIds | Id,
634
654
  WorkspaceOperationIds,
635
- PreviousTaskIds
655
+ PreviousTaskIds,
656
+ Config
636
657
  >;
637
658
 
638
659
  workspaceOperation<const Id extends string, Input extends object = {}>(
@@ -645,7 +666,41 @@ export type WorkflowSequenceBuilder<
645
666
  WorkspaceData,
646
667
  OperationIds,
647
668
  WorkspaceOperationIds | Id,
648
- PreviousTaskIds
669
+ PreviousTaskIds,
670
+ Config
671
+ >;
672
+
673
+ global(): WorkflowSequenceBuilder<
674
+ Providers,
675
+ InputContext,
676
+ OutputContext,
677
+ WorkspaceData,
678
+ OperationIds,
679
+ WorkspaceOperationIds,
680
+ PreviousTaskIds,
681
+ Config
682
+ >;
683
+
684
+ local(): WorkflowSequenceBuilder<
685
+ Providers,
686
+ InputContext,
687
+ OutputContext,
688
+ WorkspaceData,
689
+ OperationIds,
690
+ WorkspaceOperationIds,
691
+ PreviousTaskIds,
692
+ Config
693
+ >;
694
+
695
+ configure<const NextConfig extends JsonObject>(config: NextConfig): WorkflowSequenceBuilder<
696
+ Providers,
697
+ InputContext,
698
+ OutputContext,
699
+ WorkspaceData,
700
+ OperationIds,
701
+ WorkspaceOperationIds,
702
+ PreviousTaskIds,
703
+ Merge<Config, NextConfig>
649
704
  >;
650
705
  };
651
706
 
@@ -804,7 +859,14 @@ export type WorkflowEvent =
804
859
  title: string;
805
860
  }
806
861
  | { type: "artifact.created"; nodePath: string; providerId: string; kind: string; ref: JsonValue }
807
- | { type: "workspace.ready"; workspaceId: string };
862
+ | { type: "workflow.apply.started"; workflow: string }
863
+ | { type: "workflow.apply.completed"; workflow: string; nodeCount: number; cachedNodeCount: number; durationMs: number }
864
+ | { type: "workspace.create.started"; workspaceName: string }
865
+ | { type: "workspace.ready"; workspaceId: string }
866
+ | { type: "workspace.remove.started"; workspaceName: string }
867
+ | { type: "workspace.remove.completed"; workspaceName: string }
868
+ | { type: "workspace.operation.started"; workspaceName: string; operationId: string }
869
+ | { type: "workspace.operation.completed"; workspaceName: string; operationId: string };
808
870
 
809
871
  export type DevMachineEvent = WorkflowEvent;
810
872
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RIGKIT_ENGINE_VERSION = "0.2.6";
1
+ export const RIGKIT_ENGINE_VERSION = "0.2.8";