@hasna/loops 0.4.27 → 0.4.29
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 +205 -1
- package/README.md +232 -49
- package/dist/api/index.d.ts +20 -19
- package/dist/api/index.js +7770 -1342
- package/dist/cli/index.js +2976 -966
- package/dist/cli/safe-error-context.d.ts +1 -0
- package/dist/daemon/daemon.d.ts +1 -0
- package/dist/daemon/index.js +1899 -499
- package/dist/generated/storage-kit/index.d.ts +1 -1
- package/dist/generated/storage-kit/mode.d.ts +6 -12
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5319 -1096
- package/dist/lib/advancement.d.ts +52 -0
- package/dist/lib/agent-adapter.d.ts +20 -2
- package/dist/lib/auth/route-policy.d.ts +14 -0
- package/dist/lib/auth/tenant-auth.d.ts +38 -0
- package/dist/lib/cloud/mode.d.ts +2 -8
- package/dist/lib/cloud/storage.d.ts +1 -2
- package/dist/lib/cloud/transport.d.ts +4 -18
- package/dist/lib/errors.d.ts +43 -1
- package/dist/lib/executor.d.ts +9 -0
- package/dist/lib/format.d.ts +2 -2
- package/dist/lib/goal/runner.d.ts +36 -3
- package/dist/lib/health.d.ts +1 -1
- package/dist/lib/labels.d.ts +4 -0
- package/dist/lib/loop-status.d.ts +4 -0
- package/dist/lib/migration.d.ts +70 -17
- package/dist/lib/mode.d.ts +2 -5
- package/dist/lib/mode.js +28 -37
- package/dist/lib/route/fields.d.ts +8 -0
- package/dist/lib/route/index.d.ts +2 -2
- package/dist/lib/route/throttle.d.ts +7 -0
- package/dist/lib/route/types.d.ts +3 -0
- package/dist/lib/run-completion.d.ts +18 -0
- package/dist/lib/scheduler.d.ts +5 -11
- package/dist/lib/storage/contract.d.ts +15 -1
- package/dist/lib/storage/index.d.ts +1 -1
- package/dist/lib/storage/index.js +4083 -486
- package/dist/lib/storage/pg-executor.d.ts +10 -5
- package/dist/lib/storage/postgres-loop-storage.d.ts +52 -26
- package/dist/lib/storage/postgres-schema.d.ts +8 -0
- package/dist/lib/storage/postgres-schema.js +1326 -1
- package/dist/lib/storage/postgres.d.ts +3 -1
- package/dist/lib/storage/postgres.js +1356 -27
- package/dist/lib/storage/provider-credentials.d.ts +84 -0
- package/dist/lib/storage/shared-database-transfer.d.ts +136 -0
- package/dist/lib/storage/sqlite.d.ts +15 -2
- package/dist/lib/storage/sqlite.js +1379 -217
- package/dist/lib/storage/tenant-backfill-s3.d.ts +53 -0
- package/dist/lib/storage/tenant-backfill.d.ts +40 -0
- package/dist/lib/store/index.d.ts +14 -8
- package/dist/lib/store.d.ts +129 -7
- package/dist/lib/store.js +1352 -218
- package/dist/lib/templates.d.ts +11 -0
- package/dist/lib/workflow-events.d.ts +6 -0
- package/dist/lib/workflow-provenance.d.ts +8 -0
- package/dist/lib/workflow-runner.d.ts +52 -4
- package/dist/mcp/index.js +2074 -657
- package/dist/runner/index.d.ts +20 -2
- package/dist/runner/index.js +2146 -183
- package/dist/sdk/http.d.ts +364 -4
- package/dist/sdk/http.js +379 -1
- package/dist/sdk/index.d.ts +7 -2
- package/dist/sdk/index.js +2341 -742
- package/dist/serve/index.d.ts +14 -0
- package/dist/serve/index.js +13269 -1830
- package/dist/types.d.ts +75 -3
- package/docs/AUTOMATION_RUNTIME_DESIGN.md +32 -32
- package/docs/CUTOVER-RUNBOOK.md +158 -31
- package/docs/DEPLOYMENT_MODES.md +84 -56
- package/docs/RUNTIME_BOUNDARY.md +26 -26
- package/docs/SHARED-DATABASE-TRANSFER.md +95 -0
- package/docs/SHARED_KIT_EXTRACTION_INVENTORY.md +631 -0
- package/docs/TRANSCRIPT_LOOP_PATTERNS.md +3 -3
- package/docs/UNIFIED_PRODUCT_CONTRACT.md +365 -0
- package/docs/USAGE.md +150 -56
- package/docs/workflows/transcript-feedback-to-loops.json +2 -2
- package/package.json +8 -4
- package/dist/lib/storage/pg-runner-claim.d.ts +0 -40
package/dist/lib/templates.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export interface AgentWorkflowTemplateBaseInput {
|
|
|
7
7
|
projectPath: string;
|
|
8
8
|
routeProjectPath?: string;
|
|
9
9
|
projectGroup?: string;
|
|
10
|
+
routeScope?: string;
|
|
11
|
+
routeThrottleLimits?: {
|
|
12
|
+
maxActive?: number;
|
|
13
|
+
maxActiveScope?: string;
|
|
14
|
+
maxActivePerProject?: number;
|
|
15
|
+
maxActivePerProjectGroup?: number;
|
|
16
|
+
maxPerProfile?: number;
|
|
17
|
+
};
|
|
10
18
|
provider?: AgentProvider;
|
|
11
19
|
authProfile?: string;
|
|
12
20
|
authProfilePool?: string[];
|
|
@@ -26,6 +34,9 @@ export interface AgentWorkflowTemplateBaseInput {
|
|
|
26
34
|
addDirs?: string[];
|
|
27
35
|
permissionMode?: AgentPermissionMode;
|
|
28
36
|
sandbox?: AgentSandbox;
|
|
37
|
+
allowTools?: string[];
|
|
38
|
+
allowCommands?: string[];
|
|
39
|
+
safetyReason?: string;
|
|
29
40
|
manualBreakGlass?: boolean;
|
|
30
41
|
worktreeMode?: AgentWorktreeMode;
|
|
31
42
|
worktreeRoot?: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentSessionContract, PublicWorkflowEvent, StoredWorkflowEvent, WorkflowLifecycleEventType } from "../types.js";
|
|
2
|
+
export declare const WORKFLOW_LIFECYCLE_EVENT_TYPES: readonly ["created", "workflow_archived", "todos_workflow_pointers_synced", "todos_workflow_pointers_sync_failed", "step_started", "step_progress", "recovered", "step_pending", "step_running", "step_succeeded", "step_failed", "step_timed_out", "step_skipped", "step_cancelled", "succeeded", "failed", "timed_out", "cancelled"];
|
|
3
|
+
export declare function isAgentSessionContract(value: unknown): value is AgentSessionContract;
|
|
4
|
+
export declare function isWorkflowLifecycleEventType(value: string): value is WorkflowLifecycleEventType;
|
|
5
|
+
/** Validate a raw storage/API row before exposing the public discriminated union. */
|
|
6
|
+
export declare function publicWorkflowEvent(event: StoredWorkflowEvent | PublicWorkflowEvent): PublicWorkflowEvent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowSpec } from "../types.js";
|
|
2
|
+
export declare function workflowDefinitionHash(workflow: WorkflowSpec): string;
|
|
3
|
+
export interface InitialAgentSessionContractEvent {
|
|
4
|
+
eventType: "agent_session_contract";
|
|
5
|
+
stepId: string;
|
|
6
|
+
payload: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare function initialAgentSessionContractEvents(workflow: WorkflowSpec): InitialAgentSessionContractEvent[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ExecutorResult, Loop, LoopRun, WorkflowSpec } from "../types.js";
|
|
1
|
+
import type { ExecutorResult, Loop, LoopRun, StoredWorkflowEvent, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun } from "../types.js";
|
|
2
2
|
import { preflightTarget, type ExecuteOptions } from "./executor.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreateWorkflowRunInput, WorkflowRecoveryContext } from "./store.js";
|
|
4
|
+
import type { GoalRunnerStore } from "./goal/runner.js";
|
|
4
5
|
export interface ExecuteWorkflowOptions extends ExecuteOptions {
|
|
5
6
|
loop?: Loop;
|
|
6
7
|
loopRun?: LoopRun;
|
|
@@ -11,6 +12,53 @@ export interface ExecuteWorkflowOptions extends ExecuteOptions {
|
|
|
11
12
|
/** Per-node goal prompt appended to agent step prompts when a goal executes this workflow. */
|
|
12
13
|
goalNodePrompt?: string;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
16
|
+
export interface WorkflowExecutionStore extends GoalRunnerStore {
|
|
17
|
+
/** Hosted runners receive server-derived contract events and must not append client-authored copies. */
|
|
18
|
+
readonly serverDerivedAgentSessionContracts?: boolean;
|
|
19
|
+
requireWorkflow(idOrName: string): MaybePromise<WorkflowSpec>;
|
|
20
|
+
createWorkflowRun(input: CreateWorkflowRunInput): MaybePromise<WorkflowRun>;
|
|
21
|
+
getWorkflowRun(id: string): MaybePromise<WorkflowRun | undefined>;
|
|
22
|
+
requireWorkflowRun(id: string): MaybePromise<WorkflowRun>;
|
|
23
|
+
listWorkflowStepRuns(workflowRunId: string): MaybePromise<WorkflowStepRun[]>;
|
|
24
|
+
getWorkflowStepRun(workflowRunId: string, stepId: string): MaybePromise<WorkflowStepRun | undefined>;
|
|
25
|
+
isWorkflowRunTerminal(workflowRunId: string): MaybePromise<boolean>;
|
|
26
|
+
startWorkflowStepRun(workflowRunId: string, stepId: string, opts?: {
|
|
27
|
+
daemonLeaseId?: string;
|
|
28
|
+
now?: Date;
|
|
29
|
+
}): MaybePromise<WorkflowStepRun>;
|
|
30
|
+
recoverWorkflowRun(workflowRunId: string, reason?: string, context?: WorkflowRecoveryContext): MaybePromise<{
|
|
31
|
+
run: WorkflowRun;
|
|
32
|
+
recoveredSteps: WorkflowStepRun[];
|
|
33
|
+
}>;
|
|
34
|
+
finalizeWorkflowStepRun(workflowRunId: string, stepId: string, patch: Pick<WorkflowStepRun, "status" | "finishedAt" | "durationMs" | "stdout" | "stderr"> & Partial<Pick<WorkflowStepRun, "exitCode" | "error">>, opts?: {
|
|
35
|
+
daemonLeaseId?: string;
|
|
36
|
+
now?: Date;
|
|
37
|
+
}): MaybePromise<WorkflowStepRun>;
|
|
38
|
+
finalizeWorkflowRun(workflowRunId: string, status: WorkflowRunStatus, patch?: Partial<Pick<WorkflowRun, "finishedAt" | "durationMs" | "error">>, opts?: {
|
|
39
|
+
daemonLeaseId?: string;
|
|
40
|
+
now?: Date;
|
|
41
|
+
}): MaybePromise<WorkflowRun>;
|
|
42
|
+
markWorkflowStepPid(workflowRunId: string, stepId: string, pid: number, opts?: {
|
|
43
|
+
daemonLeaseId?: string;
|
|
44
|
+
now?: Date;
|
|
45
|
+
}): MaybePromise<WorkflowStepRun>;
|
|
46
|
+
recordWorkflowStepProgress(workflowRunId: string, stepId: string, progress: {
|
|
47
|
+
stdout?: string;
|
|
48
|
+
stderr?: string;
|
|
49
|
+
payload?: Record<string, unknown>;
|
|
50
|
+
}, opts?: {
|
|
51
|
+
daemonLeaseId?: string;
|
|
52
|
+
now?: Date;
|
|
53
|
+
}): MaybePromise<WorkflowStepRun>;
|
|
54
|
+
appendWorkflowEvent(workflowRunId: string, eventType: string, stepId?: string, payload?: Record<string, unknown>): MaybePromise<unknown>;
|
|
55
|
+
listWorkflowEvents?(workflowRunId: string, limit?: number): MaybePromise<StoredWorkflowEvent[]>;
|
|
56
|
+
skipWorkflowStepRun(workflowRunId: string, stepId: string, reason: string, opts?: {
|
|
57
|
+
daemonLeaseId?: string;
|
|
58
|
+
now?: Date;
|
|
59
|
+
}): MaybePromise<WorkflowStepRun>;
|
|
60
|
+
}
|
|
61
|
+
export declare function executeWorkflow(store: WorkflowExecutionStore, workflow: WorkflowSpec, opts?: ExecuteWorkflowOptions): Promise<ExecutorResult>;
|
|
15
62
|
export declare function preflightWorkflow(workflow: WorkflowSpec, opts?: ExecuteOptions): ReturnType<typeof preflightTarget>[];
|
|
16
|
-
export declare function executeLoopTarget(store:
|
|
63
|
+
export declare function executeLoopTarget(store: WorkflowExecutionStore, loop: Loop, run: LoopRun, opts?: ExecuteOptions): Promise<ExecutorResult>;
|
|
64
|
+
export {};
|