@swirls/looms 0.16.0 → 0.18.0
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 +21 -0
- package/dist/actor/cell.d.ts +5 -1
- package/dist/actor/cell.js +2 -0
- package/dist/actor/host.d.ts +5 -1
- package/dist/actor/host.js +2 -0
- package/dist/agent/effects.d.ts +266 -266
- package/dist/approval/effects.d.ts +26 -26
- package/dist/approval/module.d.ts +52 -52
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.js +10 -4
- package/dist/cloudflare/durable-object.d.ts +5 -1
- package/dist/cloudflare/durable-object.js +2 -0
- package/dist/cloudflare/queue-consumer.js +11 -3
- package/dist/core/effects.d.ts +1 -1
- package/dist/core/module.d.ts +1 -0
- package/dist/core/run-context.d.ts +6 -2
- package/dist/core/sqlite-store.js +6 -0
- package/dist/core/store.js +5 -0
- package/dist/core/worker-callback.d.ts +5 -2
- package/dist/debugger/app/assets/{index-Br9tGbPI.js → index-BjZn1DuJ.js} +2 -2
- package/dist/debugger/app/assets/{routes-CZ0buqO7.js → routes-B90xnBF1.js} +2 -2
- package/dist/debugger/app/index.html +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/react.d.ts +33 -0
- package/dist/react/react.js +51 -0
- package/dist/runtime/effect-admission.d.ts +8 -3
- package/dist/runtime/effect-admission.js +23 -4
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/local-effect-executor.d.ts +8 -2
- package/dist/runtime/local-effect-executor.js +21 -8
- package/dist/runtime/looms.d.ts +6 -0
- package/dist/runtime/looms.js +2 -0
- package/dist/runtime/observer.d.ts +15 -0
- package/dist/runtime/run-secrets.d.ts +132 -0
- package/dist/runtime/run-secrets.js +154 -0
- package/dist/runtime/runtime.js +27 -25
- package/dist/runtime/secret-sealer.d.ts +24 -0
- package/dist/runtime/secret-sealer.js +120 -0
- package/dist/runtime/server/routes/runs.js +2 -1
- package/dist/runtime/types.d.ts +20 -7
- package/dist/runtime/wake-engine.d.ts +2 -0
- package/dist/runtime/wake-engine.js +23 -9
- package/dist/runtime/worker-callbacks.d.ts +4 -2
- package/dist/runtime/worker-callbacks.js +15 -2
- package/dist/runtime/worker-effect-dispatch.d.ts +1 -2
- package/dist/runtime/worker-effect-dispatch.js +0 -1
- package/dist/schedule/module.d.ts +36 -36
- package/package.json +1 -1
|
@@ -9,6 +9,32 @@ export declare const requestApprovalEffect: NoInfer<import("@swirls/looms/core")
|
|
|
9
9
|
}[];
|
|
10
10
|
readonly schema?: import("effect/Schema").Json | undefined;
|
|
11
11
|
}, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
12
|
+
readonly type: "approval.decided";
|
|
13
|
+
readonly payload: {
|
|
14
|
+
readonly approvalId: string;
|
|
15
|
+
readonly actionId: string;
|
|
16
|
+
readonly outcome: "approve" | "reject";
|
|
17
|
+
readonly payload?: import("effect/Schema").Json | undefined;
|
|
18
|
+
};
|
|
19
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
20
|
+
readonly type: "approval.requested";
|
|
21
|
+
readonly payload: {
|
|
22
|
+
readonly approvalId: string;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly description?: string | undefined;
|
|
25
|
+
readonly actions: readonly {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly outcome: "approve" | "reject";
|
|
29
|
+
}[];
|
|
30
|
+
readonly schema?: import("effect/Schema").Json | undefined;
|
|
31
|
+
};
|
|
32
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
33
|
+
readonly type: "approval.timed_out";
|
|
34
|
+
readonly payload: {
|
|
35
|
+
readonly approvalId: string;
|
|
36
|
+
};
|
|
37
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
12
38
|
readonly type: "runtime.child.close.requested";
|
|
13
39
|
readonly payload: {
|
|
14
40
|
readonly policy: "terminate" | "wait";
|
|
@@ -254,30 +280,4 @@ export declare const requestApprovalEffect: NoInfer<import("@swirls/looms/core")
|
|
|
254
280
|
readonly payload: import("effect/Schema").Json;
|
|
255
281
|
};
|
|
256
282
|
};
|
|
257
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
258
|
-
readonly type: "approval.decided";
|
|
259
|
-
readonly payload: {
|
|
260
|
-
readonly approvalId: string;
|
|
261
|
-
readonly actionId: string;
|
|
262
|
-
readonly outcome: "approve" | "reject";
|
|
263
|
-
readonly payload?: import("effect/Schema").Json | undefined;
|
|
264
|
-
};
|
|
265
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
266
|
-
readonly type: "approval.requested";
|
|
267
|
-
readonly payload: {
|
|
268
|
-
readonly approvalId: string;
|
|
269
|
-
readonly title: string;
|
|
270
|
-
readonly description?: string | undefined;
|
|
271
|
-
readonly actions: readonly {
|
|
272
|
-
readonly id: string;
|
|
273
|
-
readonly label: string;
|
|
274
|
-
readonly outcome: "approve" | "reject";
|
|
275
|
-
}[];
|
|
276
|
-
readonly schema?: import("effect/Schema").Json | undefined;
|
|
277
|
-
};
|
|
278
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
279
|
-
readonly type: "approval.timed_out";
|
|
280
|
-
readonly payload: {
|
|
281
|
-
readonly approvalId: string;
|
|
282
|
-
};
|
|
283
283
|
})>>;
|
|
@@ -32,6 +32,32 @@ export declare function approval(): import("@swirls/looms/core").RuntimeModule<"
|
|
|
32
32
|
}[];
|
|
33
33
|
readonly schema?: import("effect/Schema").Json | undefined;
|
|
34
34
|
}, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
35
|
+
readonly type: "approval.decided";
|
|
36
|
+
readonly payload: {
|
|
37
|
+
readonly approvalId: string;
|
|
38
|
+
readonly actionId: string;
|
|
39
|
+
readonly outcome: "approve" | "reject";
|
|
40
|
+
readonly payload?: import("effect/Schema").Json | undefined;
|
|
41
|
+
};
|
|
42
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
43
|
+
readonly type: "approval.requested";
|
|
44
|
+
readonly payload: {
|
|
45
|
+
readonly approvalId: string;
|
|
46
|
+
readonly title: string;
|
|
47
|
+
readonly description?: string | undefined;
|
|
48
|
+
readonly actions: readonly {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly label: string;
|
|
51
|
+
readonly outcome: "approve" | "reject";
|
|
52
|
+
}[];
|
|
53
|
+
readonly schema?: import("effect/Schema").Json | undefined;
|
|
54
|
+
};
|
|
55
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
56
|
+
readonly type: "approval.timed_out";
|
|
57
|
+
readonly payload: {
|
|
58
|
+
readonly approvalId: string;
|
|
59
|
+
};
|
|
60
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
35
61
|
readonly type: "runtime.child.close.requested";
|
|
36
62
|
readonly payload: {
|
|
37
63
|
readonly policy: "terminate" | "wait";
|
|
@@ -277,32 +303,6 @@ export declare function approval(): import("@swirls/looms/core").RuntimeModule<"
|
|
|
277
303
|
readonly payload: import("effect/Schema").Json;
|
|
278
304
|
};
|
|
279
305
|
};
|
|
280
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
281
|
-
readonly type: "approval.decided";
|
|
282
|
-
readonly payload: {
|
|
283
|
-
readonly approvalId: string;
|
|
284
|
-
readonly actionId: string;
|
|
285
|
-
readonly outcome: "approve" | "reject";
|
|
286
|
-
readonly payload?: import("effect/Schema").Json | undefined;
|
|
287
|
-
};
|
|
288
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
289
|
-
readonly type: "approval.requested";
|
|
290
|
-
readonly payload: {
|
|
291
|
-
readonly approvalId: string;
|
|
292
|
-
readonly title: string;
|
|
293
|
-
readonly description?: string | undefined;
|
|
294
|
-
readonly actions: readonly {
|
|
295
|
-
readonly id: string;
|
|
296
|
-
readonly label: string;
|
|
297
|
-
readonly outcome: "approve" | "reject";
|
|
298
|
-
}[];
|
|
299
|
-
readonly schema?: import("effect/Schema").Json | undefined;
|
|
300
|
-
};
|
|
301
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
302
|
-
readonly type: "approval.timed_out";
|
|
303
|
-
readonly payload: {
|
|
304
|
-
readonly approvalId: string;
|
|
305
|
-
};
|
|
306
306
|
})>;
|
|
307
307
|
}, {}, {
|
|
308
308
|
pendingApprovals: import("@swirls/looms/core").ProjectionDefinition<{
|
|
@@ -346,6 +346,32 @@ export declare function approval(): import("@swirls/looms/core").RuntimeModule<"
|
|
|
346
346
|
}[];
|
|
347
347
|
readonly schema?: import("effect/Schema").Json | undefined;
|
|
348
348
|
}, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
349
|
+
readonly type: "approval.decided";
|
|
350
|
+
readonly payload: {
|
|
351
|
+
readonly approvalId: string;
|
|
352
|
+
readonly actionId: string;
|
|
353
|
+
readonly outcome: "approve" | "reject";
|
|
354
|
+
readonly payload?: import("effect/Schema").Json | undefined;
|
|
355
|
+
};
|
|
356
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
357
|
+
readonly type: "approval.requested";
|
|
358
|
+
readonly payload: {
|
|
359
|
+
readonly approvalId: string;
|
|
360
|
+
readonly title: string;
|
|
361
|
+
readonly description?: string | undefined;
|
|
362
|
+
readonly actions: readonly {
|
|
363
|
+
readonly id: string;
|
|
364
|
+
readonly label: string;
|
|
365
|
+
readonly outcome: "approve" | "reject";
|
|
366
|
+
}[];
|
|
367
|
+
readonly schema?: import("effect/Schema").Json | undefined;
|
|
368
|
+
};
|
|
369
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
370
|
+
readonly type: "approval.timed_out";
|
|
371
|
+
readonly payload: {
|
|
372
|
+
readonly approvalId: string;
|
|
373
|
+
};
|
|
374
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
349
375
|
readonly type: "runtime.child.close.requested";
|
|
350
376
|
readonly payload: {
|
|
351
377
|
readonly policy: "terminate" | "wait";
|
|
@@ -591,32 +617,6 @@ export declare function approval(): import("@swirls/looms/core").RuntimeModule<"
|
|
|
591
617
|
readonly payload: import("effect/Schema").Json;
|
|
592
618
|
};
|
|
593
619
|
};
|
|
594
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
595
|
-
readonly type: "approval.decided";
|
|
596
|
-
readonly payload: {
|
|
597
|
-
readonly approvalId: string;
|
|
598
|
-
readonly actionId: string;
|
|
599
|
-
readonly outcome: "approve" | "reject";
|
|
600
|
-
readonly payload?: import("effect/Schema").Json | undefined;
|
|
601
|
-
};
|
|
602
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
603
|
-
readonly type: "approval.requested";
|
|
604
|
-
readonly payload: {
|
|
605
|
-
readonly approvalId: string;
|
|
606
|
-
readonly title: string;
|
|
607
|
-
readonly description?: string | undefined;
|
|
608
|
-
readonly actions: readonly {
|
|
609
|
-
readonly id: string;
|
|
610
|
-
readonly label: string;
|
|
611
|
-
readonly outcome: "approve" | "reject";
|
|
612
|
-
}[];
|
|
613
|
-
readonly schema?: import("effect/Schema").Json | undefined;
|
|
614
|
-
};
|
|
615
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
616
|
-
readonly type: "approval.timed_out";
|
|
617
|
-
readonly payload: {
|
|
618
|
-
readonly approvalId: string;
|
|
619
|
-
};
|
|
620
620
|
})>;
|
|
621
621
|
};
|
|
622
622
|
readonly threads: {};
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1775,6 +1775,7 @@ export declare function createLoomsClient<const Fields extends RunAttributeField
|
|
|
1775
1775
|
/** Start a new run that continues where a finished run ended. */
|
|
1776
1776
|
fork: (sourceRunId: string, forkOptions?: {
|
|
1777
1777
|
runId?: string;
|
|
1778
|
+
secrets?: SecretContext;
|
|
1778
1779
|
}) => Promise<{
|
|
1779
1780
|
readonly runId: string;
|
|
1780
1781
|
readonly threadId: string;
|
package/dist/client/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data, Effect, Option, Predicate, Schema, Stream } from 'effect';
|
|
2
|
-
import { createRunId, DefinitionCatalogSchema, EffectCatalogSchema, EventEnvelopeSchema, EventTypeCatalogSchema, JsonValueSchema, readSubscriptionData, ReplayStepSchema, RunStateSchema, RunSummariesSchema, SecretContextSchema, SignalCatalogSchema, stringifyJson, traceHeaders, } from '@swirls/looms/core';
|
|
2
|
+
import { createRunId, DefinitionCatalogSchema, EffectCatalogSchema, EventEnvelopeSchema, cleanUndefined, EventTypeCatalogSchema, JsonValueSchema, readSubscriptionData, ReplayStepSchema, RunStateSchema, RunSummariesSchema, SecretContextSchema, SignalCatalogSchema, stringifyJson, traceHeaders, } from '@swirls/looms/core';
|
|
3
3
|
import { consumeSseStreamEffect, eventsFromSseData, sseFrames } from './sse.js';
|
|
4
4
|
class LoomsClientError extends Data.TaggedError('LoomsClientError') {
|
|
5
5
|
constructor(message, cause) {
|
|
@@ -52,7 +52,13 @@ const WorkerCallbackResultSchema = Schema.Struct({
|
|
|
52
52
|
});
|
|
53
53
|
const WorkerSecretsResultSchema = Schema.Union([
|
|
54
54
|
Schema.Struct({ status: Schema.Literal('accepted'), secrets: SecretContextSchema }),
|
|
55
|
-
Schema.Struct({
|
|
55
|
+
Schema.Struct({
|
|
56
|
+
status: Schema.Union([
|
|
57
|
+
Schema.Literal('stale'),
|
|
58
|
+
Schema.Literal('cancelled'),
|
|
59
|
+
Schema.Literal('unavailable'),
|
|
60
|
+
]),
|
|
61
|
+
}),
|
|
56
62
|
]);
|
|
57
63
|
/** `appended` counts the events the run gained while the wake ran. */
|
|
58
64
|
const WakeResultSchema = Schema.Struct({
|
|
@@ -197,7 +203,7 @@ export function createLoomsClient(options = {}) {
|
|
|
197
203
|
body: stringifyJson(body),
|
|
198
204
|
});
|
|
199
205
|
};
|
|
200
|
-
/** Read the
|
|
206
|
+
/** Read the secrets for one attempt. Only the attempt that is currently running gets them. */
|
|
201
207
|
const workerSecrets = (runId, attempt) => request(`${attemptPath(runId, attempt)}/secrets`, WorkerSecretsResultSchema, {
|
|
202
208
|
method: 'POST',
|
|
203
209
|
headers: workerHeaders,
|
|
@@ -274,7 +280,7 @@ export function createLoomsClient(options = {}) {
|
|
|
274
280
|
/** Start a new run that continues where a finished run ended. */
|
|
275
281
|
fork: (sourceRunId, forkOptions) => request(`/runs/${encodeURIComponent(sourceRunId)}/fork`, StartResultSchema, {
|
|
276
282
|
method: 'POST',
|
|
277
|
-
body: stringifyJson(
|
|
283
|
+
body: stringifyJson(cleanUndefined({ runId: forkOptions?.runId, secrets: forkOptions?.secrets })),
|
|
278
284
|
}),
|
|
279
285
|
workerCallback,
|
|
280
286
|
workerSecrets,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurableObject } from 'cloudflare:workers';
|
|
2
2
|
import { type AnyRuntimeModule, type DefinitionResolver, type EventInput, type BlobStore, type EventStoreTrimCoverage, type LaunchRunArgs, type RunAttributeFields, type RunLauncher, type RunState, type RunStatusSnapshot } from '@swirls/looms/core';
|
|
3
3
|
import type { Projector } from '@swirls/looms/projectors';
|
|
4
|
-
import { type Authorize, type EffectWorker, type RunSignalOptions, type StartResult, type StartRunArgs, type RuntimeObserver } from '@swirls/looms/runtime';
|
|
4
|
+
import { type Authorize, type EffectWorker, type RunSignalOptions, type StartResult, type StartRunArgs, type RuntimeObserver, type SecretProvider, type SecretSealer } from '@swirls/looms/runtime';
|
|
5
5
|
import { type DeleteTerminalRunStorageOptions } from './delete-terminal-run-storage';
|
|
6
6
|
export interface LoomsDurableObjectConfig {
|
|
7
7
|
readonly modules: readonly AnyRuntimeModule[];
|
|
@@ -11,6 +11,10 @@ export interface LoomsDurableObjectConfig {
|
|
|
11
11
|
readonly attributes?: RunAttributeFields;
|
|
12
12
|
/** Told about wakes, appends, snapshots and effect attempts. See `CreateRuntimeOptions`. */
|
|
13
13
|
readonly observer?: RuntimeObserver;
|
|
14
|
+
/** Decides what a run holds and what each attempt receives. See `CreateRuntimeOptions`. */
|
|
15
|
+
readonly secretProvider?: SecretProvider;
|
|
16
|
+
/** Encrypts what a run holds before it is stored. See `secretSealer`. */
|
|
17
|
+
readonly secretSealer?: SecretSealer;
|
|
14
18
|
readonly projectors?: readonly Projector[];
|
|
15
19
|
/** Content-addressed store for event and snapshot JSON over the inline byte limits. */
|
|
16
20
|
readonly blobs?: BlobStore;
|
|
@@ -55,6 +55,8 @@ export class LoomsDurableObject extends DurableObject {
|
|
|
55
55
|
definitionResolver: config.definitionResolver,
|
|
56
56
|
attributes: config.attributes,
|
|
57
57
|
observer: config.observer,
|
|
58
|
+
secretProvider: config.secretProvider,
|
|
59
|
+
secretSealer: config.secretSealer,
|
|
58
60
|
snapshotEvery: config.snapshotEvery,
|
|
59
61
|
maxWakeIterations: config.maxWakeIterations,
|
|
60
62
|
livenessLeaseMs: config.livenessLeaseMs,
|
|
@@ -71,10 +71,18 @@ function runAttempt(task, attempt, handler, cancelRequested, options) {
|
|
|
71
71
|
if (result.status === 'accepted') {
|
|
72
72
|
return Effect.succeed(result.secrets);
|
|
73
73
|
}
|
|
74
|
+
// The host could not produce the secrets this time. The attempt fails under its retry
|
|
75
|
+
// policy, so a later attempt can ask again.
|
|
76
|
+
if (result.status === 'unavailable') {
|
|
77
|
+
return Effect.fail(new QueueTaskError({ message: 'secrets are unavailable for this attempt' }));
|
|
78
|
+
}
|
|
74
79
|
controller.abort();
|
|
75
|
-
return Effect.fail(new
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
return Effect.fail(new QueueTaskError({
|
|
81
|
+
message: `the attempt is ${result.status}`,
|
|
82
|
+
nonRetryable: true,
|
|
83
|
+
}));
|
|
84
|
+
}), Effect.catchTag('CallbackError', (error) => Effect.fail(new QueueTaskError({ message: error.message, nonRetryable: true }))));
|
|
85
|
+
return taskInput(task, options.blobs).pipe(Effect.flatMap((input) => loadSecrets().pipe(Effect.flatMap((secrets) => {
|
|
78
86
|
const ctx = {
|
|
79
87
|
placement: 'worker',
|
|
80
88
|
effectId: task.effectId,
|
package/dist/core/effects.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ export interface EffectContextBase {
|
|
|
177
177
|
/** Labels safe for every reader of the run. */
|
|
178
178
|
readonly attributes: RunAttributes;
|
|
179
179
|
/**
|
|
180
|
-
* Bearer material for this
|
|
180
|
+
* Bearer material for this attempt. Never copy it into an emitted event.
|
|
181
181
|
* On a durable worker transport this is loaded before the handler runs (same shape as local).
|
|
182
182
|
*/
|
|
183
183
|
readonly secrets: SecretContext;
|
package/dist/core/module.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface EffectAdmissionContext {
|
|
|
37
37
|
readonly threadId: string;
|
|
38
38
|
readonly causingEventId: string;
|
|
39
39
|
readonly attributes: RunAttributes;
|
|
40
|
+
/** The secrets this attempt will receive. */
|
|
40
41
|
readonly secrets: SecretContext;
|
|
41
42
|
readonly trace: TraceContext | null;
|
|
42
43
|
}
|
|
@@ -8,8 +8,9 @@ export type RunAttributes = {
|
|
|
8
8
|
readonly [key: string]: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Bearer material
|
|
12
|
-
*
|
|
11
|
+
* Bearer material, such as an attenuated macaroon. For a run it is stored beside the log, and it
|
|
12
|
+
* is never written to an event, snapshot, or HTTP response. For an attempt it is what the
|
|
13
|
+
* attempt's handler receives as `ctx.secrets`.
|
|
13
14
|
*/
|
|
14
15
|
export type SecretContext = {
|
|
15
16
|
readonly [key: string]: string;
|
|
@@ -67,7 +68,10 @@ export declare const RunAttributesSchema: Schema.$Record<Schema.String, Schema.S
|
|
|
67
68
|
export declare const SecretContextSchema: Schema.$Record<Schema.String, Schema.String>;
|
|
68
69
|
export interface RunSecretStore {
|
|
69
70
|
readonly get: (runId: string) => Effect.Effect<SecretContext, Error>;
|
|
71
|
+
/** Replaces what is stored for the run. */
|
|
70
72
|
readonly put: (runId: string, secrets: SecretContext) => Effect.Effect<void, Error>;
|
|
73
|
+
/** Removes what is stored for the run. Deleting a run that has nothing stored succeeds. */
|
|
74
|
+
readonly delete: (runId: string) => Effect.Effect<void, Error>;
|
|
71
75
|
}
|
|
72
76
|
export declare function hasEntries(record: {
|
|
73
77
|
readonly [key: string]: string;
|
|
@@ -265,6 +265,12 @@ function createSqliteSecrets(exec) {
|
|
|
265
265
|
},
|
|
266
266
|
catch: (cause) => new EventStoreError(`Failed to store secret context for ${runId}`, cause),
|
|
267
267
|
}),
|
|
268
|
+
delete: (runId) => Effect.try({
|
|
269
|
+
try: () => {
|
|
270
|
+
exec.run('DELETE FROM looms_run_secrets WHERE run_id = ?', [runId]);
|
|
271
|
+
},
|
|
272
|
+
catch: (cause) => new EventStoreError(`Failed to delete secret context for ${runId}`, cause),
|
|
273
|
+
}),
|
|
268
274
|
};
|
|
269
275
|
}
|
|
270
276
|
function createSqliteEventStore(exec) {
|
package/dist/core/store.js
CHANGED
|
@@ -122,6 +122,11 @@ export const makeMemoryEventStore = Effect.gen(function* () {
|
|
|
122
122
|
const runSecrets = {
|
|
123
123
|
get: (runId) => Ref.get(secrets).pipe(Effect.map((map) => readSecretContext(map.get(runId) ?? {}))),
|
|
124
124
|
put: (runId, value) => Ref.update(secrets, (map) => new Map(map).set(runId, value)),
|
|
125
|
+
delete: (runId) => Ref.update(secrets, (map) => {
|
|
126
|
+
const next = new Map(map);
|
|
127
|
+
next.delete(runId);
|
|
128
|
+
return next;
|
|
129
|
+
}),
|
|
125
130
|
};
|
|
126
131
|
const getOrCreate = (map, runId) => {
|
|
127
132
|
const existing = map.get(runId);
|
|
@@ -32,10 +32,13 @@ export interface WorkerCallbackResult {
|
|
|
32
32
|
readonly status: 'accepted' | 'stale' | 'cancelled';
|
|
33
33
|
readonly cancelRequested: boolean;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* The secrets for one attempt, released only to the attempt that is currently running.
|
|
37
|
+
* `unavailable` means the host could not produce them this time; the attempt can be retried.
|
|
38
|
+
*/
|
|
36
39
|
export type WorkerSecretsResult = {
|
|
37
40
|
readonly status: 'accepted';
|
|
38
41
|
readonly secrets: SecretContext;
|
|
39
42
|
} | {
|
|
40
|
-
readonly status: 'stale' | 'cancelled';
|
|
43
|
+
readonly status: 'stale' | 'cancelled' | 'unavailable';
|
|
41
44
|
};
|