@hasna/loops 0.4.13 → 0.4.22
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 +99 -3
- package/README.md +171 -39
- package/dist/api/index.d.ts +36 -0
- package/dist/api/index.js +1518 -15
- package/dist/cli/index.js +7280 -3213
- package/dist/cli/ui.d.ts +44 -0
- package/dist/daemon/index.js +1433 -303
- package/dist/generated/storage-kit/health.d.ts +19 -0
- package/dist/generated/storage-kit/index.d.ts +7 -0
- package/dist/generated/storage-kit/migrations.d.ts +47 -0
- package/dist/generated/storage-kit/mode.d.ts +47 -0
- package/dist/generated/storage-kit/pool.d.ts +33 -0
- package/dist/generated/storage-kit/query.d.ts +35 -0
- package/dist/generated/storage-kit/tls.d.ts +25 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8689 -4837
- package/dist/lib/cloud/mode.d.ts +17 -0
- package/dist/lib/cloud/resolve.d.ts +16 -0
- package/dist/lib/cloud/storage.d.ts +82 -0
- package/dist/lib/cloud/transport.d.ts +148 -0
- package/dist/lib/format.d.ts +2 -1
- package/dist/lib/health.d.ts +83 -3
- package/dist/lib/migration.d.ts +40 -0
- package/dist/lib/mode.js +15 -3
- package/dist/lib/route/index.d.ts +2 -0
- package/dist/lib/route/policies.d.ts +51 -0
- package/dist/lib/route/provider-admission.d.ts +37 -0
- package/dist/lib/route/throttle.d.ts +4 -0
- package/dist/lib/route/types.d.ts +8 -0
- package/dist/lib/run-receipts.d.ts +14 -0
- package/dist/lib/scheduler.d.ts +5 -2
- package/dist/lib/storage/contract.d.ts +7 -1
- package/dist/lib/storage/index.d.ts +1 -0
- package/dist/lib/storage/index.js +2028 -231
- package/dist/lib/storage/pg-executor.d.ts +27 -0
- package/dist/lib/storage/pg-runner-claim.d.ts +40 -0
- package/dist/lib/storage/postgres-loop-storage.d.ts +120 -0
- package/dist/lib/storage/postgres-schema.js +29 -0
- package/dist/lib/storage/postgres.js +29 -0
- package/dist/lib/storage/sqlite.d.ts +6 -0
- package/dist/lib/storage/sqlite.js +748 -26
- package/dist/lib/store/index.d.ts +268 -0
- package/dist/lib/store.d.ts +282 -1
- package/dist/lib/store.js +746 -26
- package/dist/lib/template-kit.d.ts +25 -0
- package/dist/lib/templates.d.ts +16 -1
- package/dist/mcp/http.d.ts +16 -0
- package/dist/mcp/index.js +2885 -634
- package/dist/runner/index.js +198 -32
- package/dist/sdk/http.d.ts +182 -0
- package/dist/sdk/http.js +166 -0
- package/dist/sdk/index.d.ts +55 -18
- package/dist/sdk/index.js +2734 -617
- package/dist/serve/index.d.ts +4 -0
- package/dist/serve/index.js +9095 -0
- package/dist/types.d.ts +52 -0
- package/docs/AUTOMATION_RUNTIME_DESIGN.md +442 -1
- package/docs/CUTOVER-RUNBOOK.md +78 -0
- package/docs/DEPLOYMENT_MODES.md +35 -18
- package/docs/RUNTIME_BOUNDARY.md +203 -0
- package/docs/USAGE.md +195 -38
- package/package.json +15 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Loop, LoopRun, RunReceipt, RunReceiptMachine, WriteRunReceiptInput } from "../types.js";
|
|
2
|
+
export declare const RUN_RECEIPT_SUMMARY_TEXT_CHARS = 4096;
|
|
3
|
+
export declare const RUN_RECEIPT_MAX_IDS = 100;
|
|
4
|
+
export declare const RUN_RECEIPT_MAX_EVIDENCE_PATHS = 100;
|
|
5
|
+
export declare const RUN_RECEIPT_MAX_PATH_CHARS = 1024;
|
|
6
|
+
export interface NormalizeRunReceiptOptions {
|
|
7
|
+
now?: Date;
|
|
8
|
+
loop?: Loop;
|
|
9
|
+
run?: LoopRun;
|
|
10
|
+
defaultMachine?: RunReceiptMachine;
|
|
11
|
+
defaultRepo?: string;
|
|
12
|
+
existing?: RunReceipt;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeRunReceipt(input: WriteRunReceiptInput, opts?: NormalizeRunReceiptOptions): RunReceipt;
|
package/dist/lib/scheduler.d.ts
CHANGED
|
@@ -97,8 +97,8 @@ export declare const MAX_SKIPS_PER_LOOP_PER_TICK = 10;
|
|
|
97
97
|
/**
|
|
98
98
|
* Exponential retry backoff with jitter:
|
|
99
99
|
* delay = retryDelayMs * 2^(attempt-1) * (0.5 + random), capped at 6h.
|
|
100
|
-
* Failures classified as
|
|
101
|
-
* a throttled or
|
|
100
|
+
* Failures classified as provider-gated back off 4x harder, since hammering
|
|
101
|
+
* a throttled, misconfigured, or unavailable provider only makes things worse.
|
|
102
102
|
*/
|
|
103
103
|
export declare function retryBackoffDelayMs(loop: Loop, run: LoopRun, random?: () => number): number;
|
|
104
104
|
export interface AdvanceLoopOptions {
|
|
@@ -129,6 +129,9 @@ export declare function executeClaimedRun(deps: {
|
|
|
129
129
|
beforeFinalize?: (loop: Loop, run: LoopRun) => void;
|
|
130
130
|
daemonLeaseId?: string;
|
|
131
131
|
execute?: (loop: Loop, run: LoopRun) => Promise<ExecutorResult>;
|
|
132
|
+
finalizeResult?: (result: ExecutorResult, loop: Loop, run: LoopRun) => Omit<ExecutorResult, "status"> & {
|
|
133
|
+
status: LoopRun["status"];
|
|
134
|
+
};
|
|
132
135
|
onError?: (loop: Loop, error: unknown) => void;
|
|
133
136
|
}): Promise<LoopRun>;
|
|
134
137
|
export declare function claimDueRuns(deps: SchedulerDeps & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Store } from "../store.js";
|
|
2
2
|
export type LoopStorageBackend = "sqlite" | "postgres";
|
|
3
|
-
export type LoopStorageMethodName = "createLoop" | "getLoop" | "findLoopByName" | "requireLoop" | "listLoops" | "dueLoops" | "updateLoop" | "renameLoop" | "archiveLoop" | "unarchiveLoop" | "deleteLoop" | "createWorkflow" | "getWorkflow" | "listWorkflows" | "countWorkflows" | "archiveWorkflow" | "createWorkflowInvocation" | "getWorkflowInvocation" | "listWorkflowInvocations" | "upsertWorkflowWorkItem" | "getWorkflowWorkItem" | "listWorkflowWorkItems" | "countActiveWorkflowWorkItems" | "admitWorkflowWorkItem" | "createGoal" | "getGoal" | "listGoals" | "createGoalPlanNodes" | "listGoalPlanNodes" | "updateGoalStatus" | "updateGoalPlanNode" | "recordGoalEvent" | "listGoalRuns" | "createWorkflowRun" | "getWorkflowRun" | "listWorkflowRuns" | "listWorkflowStepRuns" | "getWorkflowStepRun" | "startWorkflowStepRun" | "recoverWorkflowRun" | "finalizeWorkflowStepRun" | "finalizeWorkflowRun" | "appendWorkflowEvent" | "listWorkflowEvents" | "recordRunProcess" | "createSkippedRun" | "getRun" | "getRunBySlot" | "claimRun" | "finalizeRun" | "heartbeatRunLease" | "listRuns" | "recoverExpiredRunLeases" | "recoverExpiredRunLeasesDetailed" | "countLoops" | "countRuns" | "pruneHistory" | "acquireDaemonLease" | "heartbeatDaemonLease" | "releaseDaemonLease" | "getDaemonLease";
|
|
3
|
+
export type LoopStorageMethodName = "createLoop" | "getLoop" | "findLoopByName" | "requireLoop" | "listLoops" | "dueLoops" | "updateLoop" | "renameLoop" | "archiveLoop" | "unarchiveLoop" | "deleteLoop" | "upsertMigrationLoop" | "upsertMigrationRun" | "upsertMigrationWorkflow" | "createWorkflow" | "getWorkflow" | "listWorkflows" | "countWorkflows" | "archiveWorkflow" | "createWorkflowInvocation" | "getWorkflowInvocation" | "listWorkflowInvocations" | "upsertWorkflowWorkItem" | "getWorkflowWorkItem" | "listWorkflowWorkItems" | "countActiveWorkflowWorkItems" | "admitWorkflowWorkItem" | "createGoal" | "getGoal" | "listGoals" | "createGoalPlanNodes" | "listGoalPlanNodes" | "updateGoalStatus" | "updateGoalPlanNode" | "recordGoalEvent" | "listGoalRuns" | "createWorkflowRun" | "getWorkflowRun" | "listWorkflowRuns" | "listWorkflowStepRuns" | "getWorkflowStepRun" | "startWorkflowStepRun" | "recoverWorkflowRun" | "finalizeWorkflowStepRun" | "finalizeWorkflowRun" | "appendWorkflowEvent" | "listWorkflowEvents" | "recordRunProcess" | "createSkippedRun" | "getRun" | "getRunBySlot" | "claimRun" | "finalizeRun" | "heartbeatRunLease" | "listRuns" | "writeRunReceipt" | "getRunReceipt" | "listRunReceipts" | "recoverExpiredRunLeases" | "recoverExpiredRunLeasesDetailed" | "countLoops" | "countRuns" | "pruneHistory" | "acquireDaemonLease" | "heartbeatDaemonLease" | "releaseDaemonLease" | "getDaemonLease";
|
|
4
4
|
type AsyncStoreMethod<K extends LoopStorageMethodName> = Store[K] extends (...args: infer Args) => infer Result ? (...args: Args) => Promise<Result> : never;
|
|
5
5
|
export interface LoopStorageContract extends Record<LoopStorageMethodName, (...args: never[]) => Promise<unknown>> {
|
|
6
6
|
readonly backend: LoopStorageBackend;
|
|
@@ -17,6 +17,9 @@ export interface LoopStorageContract extends Record<LoopStorageMethodName, (...a
|
|
|
17
17
|
archiveLoop: AsyncStoreMethod<"archiveLoop">;
|
|
18
18
|
unarchiveLoop: AsyncStoreMethod<"unarchiveLoop">;
|
|
19
19
|
deleteLoop: AsyncStoreMethod<"deleteLoop">;
|
|
20
|
+
upsertMigrationLoop: AsyncStoreMethod<"upsertMigrationLoop">;
|
|
21
|
+
upsertMigrationRun: AsyncStoreMethod<"upsertMigrationRun">;
|
|
22
|
+
upsertMigrationWorkflow: AsyncStoreMethod<"upsertMigrationWorkflow">;
|
|
20
23
|
createWorkflow: AsyncStoreMethod<"createWorkflow">;
|
|
21
24
|
getWorkflow: AsyncStoreMethod<"getWorkflow">;
|
|
22
25
|
listWorkflows: AsyncStoreMethod<"listWorkflows">;
|
|
@@ -58,6 +61,9 @@ export interface LoopStorageContract extends Record<LoopStorageMethodName, (...a
|
|
|
58
61
|
finalizeRun: AsyncStoreMethod<"finalizeRun">;
|
|
59
62
|
heartbeatRunLease: AsyncStoreMethod<"heartbeatRunLease">;
|
|
60
63
|
listRuns: AsyncStoreMethod<"listRuns">;
|
|
64
|
+
writeRunReceipt: AsyncStoreMethod<"writeRunReceipt">;
|
|
65
|
+
getRunReceipt: AsyncStoreMethod<"getRunReceipt">;
|
|
66
|
+
listRunReceipts: AsyncStoreMethod<"listRunReceipts">;
|
|
61
67
|
recoverExpiredRunLeases: AsyncStoreMethod<"recoverExpiredRunLeases">;
|
|
62
68
|
recoverExpiredRunLeasesDetailed: AsyncStoreMethod<"recoverExpiredRunLeasesDetailed">;
|
|
63
69
|
countLoops: AsyncStoreMethod<"countLoops">;
|
|
@@ -2,5 +2,6 @@ export type { AppliedStorageMigration, AuditEventRecord, LoopStorageBackend, Loo
|
|
|
2
2
|
export { SqliteLoopStorage, createSqliteLoopStorage } from "./sqlite.js";
|
|
3
3
|
export { PostgresStorage, createPostgresStorage } from "./postgres.js";
|
|
4
4
|
export type { PostgresQueryExecutor } from "./postgres.js";
|
|
5
|
+
export { PostgresLoopStorage, createPostgresLoopStorage, NotImplementedError, } from "./postgres-loop-storage.js";
|
|
5
6
|
export { POSTGRES_MIGRATION_LEDGER_TABLE, POSTGRES_STORAGE_MIGRATIONS, checksumStorageSql, } from "./postgres-schema.js";
|
|
6
7
|
export { Store } from "../store.js";
|