@swirls/looms 0.5.1 → 0.6.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 +16 -0
- package/dist/actor/cell.d.ts +6 -1
- package/dist/actor/cell.js +1 -0
- package/dist/agent/definitions.d.ts +0 -12
- package/dist/agent/effects.js +0 -24
- package/dist/agent/module.d.ts +507 -507
- package/dist/agent/projections.d.ts +5 -0
- package/dist/agent/projections.js +5 -0
- package/dist/approval/effects.d.ts +26 -26
- package/dist/client/client.d.ts +2 -0
- package/dist/client/client.js +13 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/cloudflare/durable-object.d.ts +7 -1
- package/dist/cloudflare/durable-object.js +1 -0
- package/dist/cloudflare/queue-consumer.js +6 -1
- package/dist/core/blob-store.js +5 -1
- package/dist/core/definition-resolver.d.ts +16 -0
- package/dist/core/definition-resolver.js +23 -0
- package/dist/core/definition-version.d.ts +3 -0
- package/dist/core/definition-version.js +5 -0
- package/dist/core/effects.js +1 -1
- package/dist/core/module.d.ts +12 -3
- package/dist/core/module.js +18 -3
- package/dist/debugger/app/assets/{index-C31SnCuN.js → index-CUO1xyYW.js} +2 -2
- package/dist/debugger/app/assets/{routes-DPA3O5AF.js → routes-lt_6J025.js} +12 -12
- package/dist/debugger/app/index.html +1 -1
- package/dist/evaluator/effects.d.ts +33 -33
- package/dist/evaluator/module.d.ts +66 -66
- package/dist/react/store.d.ts +1 -1
- package/dist/react/store.js +2 -1
- package/dist/runtime/cancellation.js +21 -0
- package/dist/runtime/dispatch-effect.js +4 -1
- package/dist/runtime/filesystem-blob-store.js +17 -8
- package/dist/runtime/repository.js +2 -1
- package/dist/runtime/server/routes/runs.js +6 -11
- package/dist/runtime/sse.d.ts +3 -1
- package/dist/runtime/sse.js +5 -2
- package/dist/runtime/types.d.ts +2 -1
- package/dist/runtime/wake-engine.js +16 -11
- package/dist/runtime/worker-effect-dispatch.d.ts +3 -1
- package/dist/runtime/worker-effect-dispatch.js +14 -5
- package/dist/schedule/module.d.ts +36 -36
- package/dist/testing/corpus-module.js +11 -2
- package/dist/workflow/threads.js +5 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @swirls/looms
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1b27d12: Effect middleware can call `failEffect` and have it become `runtime.effect.failed` instead of failing the wake. `onEffect` wraps middleware for one effect definition with a typed input. Docs cover middleware scope (local effects only) and the `tokenUsage` / `agent.turn.usage` projection path for billing.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 5d0b988: Fix 0.5.x durability gaps: cancel launched children before recording close.requested; prime definition resolvers from snapshots; resolve relative WebSocket bases; filter SSE by threadId/includeEphemeral; write filesystem blobs atomically and repair corrupt digests; require start-to-close or heartbeat timeouts for acknowledged workers and retry lost terminal queue callbacks; clear workflow wait-child pending state on node finish.
|
|
12
|
+
|
|
13
|
+
## 0.5.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- a51bc1a: Allow Durable Object hosts to pass an `EffectWorker` through `LoomsDurableObjectConfig.worker` so queue-routed effects can leave the cell.
|
|
18
|
+
|
|
3
19
|
## 0.5.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/actor/cell.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyRuntimeModule, type DefinitionResolver, type EventInput, type EventStore, type EventStoreTrimCoverage, type LaunchRunArgs, type RunLauncher, type RunState, type RunStatusSnapshot, type SnapshotStore } from '@swirls/looms/core';
|
|
2
|
-
import { type Authorize, type LoomsRuntime, type StartResult, type StartRunArgs, type WakeScheduler } from '@swirls/looms/runtime';
|
|
2
|
+
import { type Authorize, type EffectWorker, type LoomsRuntime, type StartResult, type StartRunArgs, type WakeScheduler } from '@swirls/looms/runtime';
|
|
3
3
|
export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
4
4
|
readonly runId: string;
|
|
5
5
|
readonly store: EventStore;
|
|
@@ -19,6 +19,11 @@ export interface ActorCellOptions<TModules extends readonly AnyRuntimeModule[] =
|
|
|
19
19
|
readonly authorize?: Authorize;
|
|
20
20
|
/** Starts runs from effect handlers. Required for schedules; there is no default inside a cell. */
|
|
21
21
|
readonly launcher?: RunLauncher;
|
|
22
|
+
/**
|
|
23
|
+
* Dispatches `execution: 'worker'` effects out of the cell (for example a
|
|
24
|
+
* Cloudflare Queue producer). Without it, worker effects cannot leave the object.
|
|
25
|
+
*/
|
|
26
|
+
readonly worker?: EffectWorker;
|
|
22
27
|
}
|
|
23
28
|
export interface ActorCell<TModules extends readonly AnyRuntimeModule[] = readonly AnyRuntimeModule[]> {
|
|
24
29
|
readonly runId: string;
|
package/dist/actor/cell.js
CHANGED
|
@@ -14,6 +14,7 @@ export function createActorCell(options) {
|
|
|
14
14
|
store,
|
|
15
15
|
scheduler,
|
|
16
16
|
launcher: options.launcher,
|
|
17
|
+
worker: options.worker,
|
|
17
18
|
snapshotEvery: options.snapshotEvery,
|
|
18
19
|
maxWakeIterations: options.maxWakeIterations,
|
|
19
20
|
maxPendingRunOperations: options.maxPendingRunOperations,
|
|
@@ -87,11 +87,6 @@ export interface AgentToolResolutionContext<TInput = JsonValue> {
|
|
|
87
87
|
readonly turn: number;
|
|
88
88
|
readonly input: TInput;
|
|
89
89
|
}
|
|
90
|
-
export interface AgentUsage {
|
|
91
|
-
readonly input: number;
|
|
92
|
-
readonly output: number;
|
|
93
|
-
readonly turn: number;
|
|
94
|
-
}
|
|
95
90
|
export interface AgentTurnResult<TOutput extends JsonValue = JsonValue> {
|
|
96
91
|
message: Message;
|
|
97
92
|
toolCalls?: ToolCall[];
|
|
@@ -119,13 +114,6 @@ export interface AgentDefinition<TName extends string = string, TInput = JsonVal
|
|
|
119
114
|
resolveTools?(ctx: AgentToolResolutionContext<TInput>): Promise<readonly AgentToolEntry[]> | readonly AgentToolEntry[];
|
|
120
115
|
/** Shrinks the conversation after the model reports a context overflow. */
|
|
121
116
|
readonly compact?: AgentCompactor;
|
|
122
|
-
/** Runs before each model call. Throwing fails the agent thread with the thrown message. */
|
|
123
|
-
assertCredits?(ctx: AgentTurnContext<TInput>): Promise<void> | void;
|
|
124
|
-
/**
|
|
125
|
-
* Reports token usage after each model call. Usage is also recorded as `agent.turn.usage`;
|
|
126
|
-
* a retried turn calls this again, so deduplicate on `threadId` and `turn`.
|
|
127
|
-
*/
|
|
128
|
-
trackUsage?(usage: AgentUsage, ctx: AgentTurnContext<TInput>): Promise<void> | void;
|
|
129
117
|
readonly maxTurns?: number;
|
|
130
118
|
readonly conversational?: boolean;
|
|
131
119
|
readonly stopWhen?: StopWhen;
|
package/dist/agent/effects.js
CHANGED
|
@@ -129,24 +129,6 @@ function runCallLlm(args) {
|
|
|
129
129
|
instructions,
|
|
130
130
|
signal,
|
|
131
131
|
};
|
|
132
|
-
if (definition.assertCredits) {
|
|
133
|
-
const creditCheck = yield* Effect.tryPromise({
|
|
134
|
-
try: () => Promise.resolve(definition.assertCredits(turnCtx)),
|
|
135
|
-
catch: (cause) => new AgentExecutionError('credit gate check', cause),
|
|
136
|
-
}).pipe(Effect.match({
|
|
137
|
-
onFailure: (error) => ({ ok: false, error: error.message }),
|
|
138
|
-
onSuccess: () => ({ ok: true }),
|
|
139
|
-
}));
|
|
140
|
-
if (!creditCheck.ok) {
|
|
141
|
-
return [
|
|
142
|
-
{
|
|
143
|
-
type: 'runtime.thread.failed',
|
|
144
|
-
payload: { threadId, error: creditCheck.error },
|
|
145
|
-
threadId,
|
|
146
|
-
},
|
|
147
|
-
];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
132
|
const events = [
|
|
151
133
|
{
|
|
152
134
|
type: 'agent.turn.started',
|
|
@@ -243,12 +225,6 @@ function runCallLlm(args) {
|
|
|
243
225
|
},
|
|
244
226
|
threadId,
|
|
245
227
|
});
|
|
246
|
-
if (definition.trackUsage) {
|
|
247
|
-
yield* Effect.tryPromise({
|
|
248
|
-
try: () => Promise.resolve(definition.trackUsage({ input: result.usage.input, output: result.usage.output, turn }, turnCtx)),
|
|
249
|
-
catch: (cause) => new AgentExecutionError('track usage', cause),
|
|
250
|
-
}).pipe(Effect.catch((error) => Effect.logWarning('[@swirls/looms/agent] trackUsage failed', error)));
|
|
251
|
-
}
|
|
252
228
|
}
|
|
253
229
|
if (shouldStop) {
|
|
254
230
|
if (!definition.conversational) {
|