@swirls/looms 0.5.2 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/agent/definitions.d.ts +0 -12
  3. package/dist/agent/effects.js +0 -24
  4. package/dist/agent/module.d.ts +507 -507
  5. package/dist/agent/projections.d.ts +5 -0
  6. package/dist/agent/projections.js +5 -0
  7. package/dist/approval/effects.d.ts +26 -26
  8. package/dist/client/client.d.ts +2 -0
  9. package/dist/client/client.js +13 -1
  10. package/dist/client/index.d.ts +1 -1
  11. package/dist/client/index.js +1 -1
  12. package/dist/cloudflare/queue-consumer.js +6 -1
  13. package/dist/core/blob-store.js +5 -1
  14. package/dist/core/definition-resolver.d.ts +16 -0
  15. package/dist/core/definition-resolver.js +23 -0
  16. package/dist/core/definition-version.d.ts +3 -0
  17. package/dist/core/definition-version.js +5 -0
  18. package/dist/core/effects.js +1 -1
  19. package/dist/core/module.d.ts +12 -3
  20. package/dist/core/module.js +18 -3
  21. package/dist/debugger/app/assets/{index-C31SnCuN.js → index-CUO1xyYW.js} +2 -2
  22. package/dist/debugger/app/assets/{routes-DPA3O5AF.js → routes-lt_6J025.js} +12 -12
  23. package/dist/debugger/app/index.html +1 -1
  24. package/dist/react/store.d.ts +1 -1
  25. package/dist/react/store.js +2 -1
  26. package/dist/runtime/cancellation.js +21 -0
  27. package/dist/runtime/dispatch-effect.js +4 -1
  28. package/dist/runtime/filesystem-blob-store.js +17 -8
  29. package/dist/runtime/repository.js +2 -1
  30. package/dist/runtime/server/routes/runs.js +6 -11
  31. package/dist/runtime/sse.d.ts +3 -1
  32. package/dist/runtime/sse.js +5 -2
  33. package/dist/runtime/types.d.ts +2 -1
  34. package/dist/runtime/wake-engine.js +16 -11
  35. package/dist/runtime/worker-effect-dispatch.d.ts +3 -1
  36. package/dist/runtime/worker-effect-dispatch.js +14 -5
  37. package/dist/testing/corpus-module.js +11 -2
  38. package/dist/workflow/threads.js +5 -8
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 0.5.2
4
14
 
5
15
  ### Patch Changes
@@ -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;
@@ -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) {