@hasna/loops 0.3.38 → 0.3.40

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.
@@ -1,4 +1,4 @@
1
- import type { ExecutorResult, Goal, GoalRun, Loop, LoopRun, WorkflowEvent, WorkflowRun, WorkflowSpec, WorkflowStepRun } from "../types.js";
1
+ import type { ExecutorResult, Goal, GoalRun, Loop, LoopRun, WorkflowEvent, WorkflowInvocation, WorkflowRun, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem } from "../types.js";
2
2
  export declare function redact(value: string | undefined, visible?: number): string | undefined;
3
3
  export declare function textOutputBlocks(value: Pick<LoopRun | WorkflowStepRun, "stdout" | "stderr">, opts?: {
4
4
  indent?: string;
@@ -8,6 +8,8 @@ export declare function publicRun(run: LoopRun, showOutput?: boolean): Record<st
8
8
  export declare function publicExecutorResult(result: ExecutorResult, showOutput?: boolean): Record<string, unknown>;
9
9
  export declare function publicWorkflow(workflow: WorkflowSpec): Record<string, unknown>;
10
10
  export declare function publicWorkflowRun(run: WorkflowRun): Record<string, unknown>;
11
+ export declare function publicWorkflowInvocation(invocation: WorkflowInvocation): Record<string, unknown>;
12
+ export declare function publicWorkflowWorkItem(item: WorkflowWorkItem): Record<string, unknown>;
11
13
  export declare function publicWorkflowStepRun(run: WorkflowStepRun, showOutput?: boolean): Record<string, unknown>;
12
14
  export declare function publicWorkflowEvent(event: WorkflowEvent): Record<string, unknown>;
13
15
  export declare function publicGoal(goal: Goal): Record<string, unknown>;
@@ -0,0 +1,15 @@
1
+ export declare function safeRunPathSlug(value: string | undefined, fallback: string): string;
2
+ export declare function workflowRunSubjectKey(kind: string | undefined, rawSubjectRef: string | undefined): string;
3
+ export declare function workflowRunProjectSlug(projectKey: string | undefined): string;
4
+ export declare function writeWorkflowRunManifest(args: {
5
+ loopsDataDir: string;
6
+ workflowRunId: string;
7
+ workflowId: string;
8
+ workflowName: string;
9
+ invocationId?: string;
10
+ workItemId?: string;
11
+ projectKey?: string;
12
+ subjectKind?: string;
13
+ rawSubjectRef?: string;
14
+ payload: Record<string, unknown>;
15
+ }): string;
@@ -1,4 +1,4 @@
1
- import type { CreateLoopInput, CreateWorkflowInput, Goal, GoalAutoExecute, GoalPlanNode, GoalRun, GoalStatus, Loop, LoopRun, LoopStatus, RunStatus, WorkflowEvent, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun } from "../types.js";
1
+ import type { CreateLoopInput, CreateWorkflowInvocationInput, CreateWorkflowInput, Goal, GoalAutoExecute, GoalPlanNode, GoalRun, GoalStatus, Loop, LoopRun, LoopStatus, RunStatus, WorkflowEvent, WorkflowInvocation, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem, WorkflowWorkItemStatus, UpsertWorkflowWorkItemInput } from "../types.js";
2
2
  interface DaemonLeaseFence {
3
3
  daemonLeaseId?: string;
4
4
  now?: Date;
@@ -22,6 +22,8 @@ export interface CreateWorkflowRunInput {
22
22
  loopRun?: LoopRun;
23
23
  scheduledFor?: string;
24
24
  idempotencyKey?: string;
25
+ invocationId?: string;
26
+ workItemId?: string;
25
27
  daemonLeaseId?: string;
26
28
  }
27
29
  export interface CreateGoalInput {
@@ -56,6 +58,7 @@ export interface RecordGoalEventInput {
56
58
  }
57
59
  export declare class Store {
58
60
  private db;
61
+ private rootDir;
59
62
  constructor(path?: string);
60
63
  private migrate;
61
64
  /**
@@ -66,6 +69,7 @@ export declare class Store {
66
69
  * in {@link migrate}, never user input, so interpolation here is safe.
67
70
  */
68
71
  private addColumnIfMissing;
72
+ private createWorkflowRunBackfillIndexes;
69
73
  private assertDaemonLeaseFence;
70
74
  createLoop(input: CreateLoopInput, from?: Date): Loop;
71
75
  getLoop(id: string): Loop | undefined;
@@ -92,6 +96,35 @@ export declare class Store {
92
96
  limit?: number;
93
97
  }): WorkflowSpec[];
94
98
  archiveWorkflow(idOrName: string): WorkflowSpec;
99
+ createWorkflowInvocation(input: CreateWorkflowInvocationInput): WorkflowInvocation;
100
+ getWorkflowInvocation(id: string): WorkflowInvocation | undefined;
101
+ listWorkflowInvocations(opts?: {
102
+ limit?: number;
103
+ }): WorkflowInvocation[];
104
+ upsertWorkflowWorkItem(input: UpsertWorkflowWorkItemInput): WorkflowWorkItem;
105
+ getWorkflowWorkItem(id: string): WorkflowWorkItem | undefined;
106
+ findWorkflowWorkItem(routeKey: string, idempotencyKey: string): WorkflowWorkItem | undefined;
107
+ listWorkflowWorkItems(opts?: {
108
+ status?: WorkflowWorkItemStatus;
109
+ routeKey?: string;
110
+ limit?: number;
111
+ }): WorkflowWorkItem[];
112
+ countActiveWorkflowWorkItems(args?: {
113
+ projectKey?: string;
114
+ projectGroup?: string;
115
+ }): {
116
+ global: number;
117
+ project: number;
118
+ projectGroup?: number;
119
+ };
120
+ admitWorkflowWorkItem(id: string, patch: {
121
+ workflowId: string;
122
+ loopId: string;
123
+ reason?: string;
124
+ }): WorkflowWorkItem;
125
+ private setWorkflowWorkItemsForLoop;
126
+ private setWorkflowWorkItemsForWorkflowRun;
127
+ private setWorkflowWorkItemsForLoopRun;
95
128
  createGoal(input: CreateGoalInput, opts?: DaemonLeaseFence): Goal;
96
129
  getGoal(id: string): Goal | undefined;
97
130
  requireGoal(id: string): Goal;