@hasna/loops 0.3.38 → 0.3.39

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
  /**
@@ -92,6 +95,35 @@ export declare class Store {
92
95
  limit?: number;
93
96
  }): WorkflowSpec[];
94
97
  archiveWorkflow(idOrName: string): WorkflowSpec;
98
+ createWorkflowInvocation(input: CreateWorkflowInvocationInput): WorkflowInvocation;
99
+ getWorkflowInvocation(id: string): WorkflowInvocation | undefined;
100
+ listWorkflowInvocations(opts?: {
101
+ limit?: number;
102
+ }): WorkflowInvocation[];
103
+ upsertWorkflowWorkItem(input: UpsertWorkflowWorkItemInput): WorkflowWorkItem;
104
+ getWorkflowWorkItem(id: string): WorkflowWorkItem | undefined;
105
+ findWorkflowWorkItem(routeKey: string, idempotencyKey: string): WorkflowWorkItem | undefined;
106
+ listWorkflowWorkItems(opts?: {
107
+ status?: WorkflowWorkItemStatus;
108
+ routeKey?: string;
109
+ limit?: number;
110
+ }): WorkflowWorkItem[];
111
+ countActiveWorkflowWorkItems(args?: {
112
+ projectKey?: string;
113
+ projectGroup?: string;
114
+ }): {
115
+ global: number;
116
+ project: number;
117
+ projectGroup?: number;
118
+ };
119
+ admitWorkflowWorkItem(id: string, patch: {
120
+ workflowId: string;
121
+ loopId: string;
122
+ reason?: string;
123
+ }): WorkflowWorkItem;
124
+ private setWorkflowWorkItemsForLoop;
125
+ private setWorkflowWorkItemsForWorkflowRun;
126
+ private setWorkflowWorkItemsForLoopRun;
95
127
  createGoal(input: CreateGoalInput, opts?: DaemonLeaseFence): Goal;
96
128
  getGoal(id: string): Goal | undefined;
97
129
  requireGoal(id: string): Goal;