@swirls/looms 0.10.0 → 0.11.1

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 (49) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/actor/cell.d.ts +3 -1
  3. package/dist/actor/cell.js +1 -0
  4. package/dist/actor/host.d.ts +3 -1
  5. package/dist/actor/host.js +1 -0
  6. package/dist/agent/effects.d.ts +256 -256
  7. package/dist/agent/module.d.ts +512 -512
  8. package/dist/agent/signals.d.ts +6 -2
  9. package/dist/agent/signals.js +7 -3
  10. package/dist/agent/threads.js +3 -0
  11. package/dist/cli/commands.d.ts +1 -1
  12. package/dist/cli/commands.js +47 -12
  13. package/dist/client/client.d.ts +20 -21
  14. package/dist/client/client.js +2 -1
  15. package/dist/cloudflare/delete-terminal-run-storage.d.ts +39 -0
  16. package/dist/cloudflare/delete-terminal-run-storage.js +98 -0
  17. package/dist/cloudflare/durable-object.d.ts +11 -1
  18. package/dist/cloudflare/durable-object.js +23 -0
  19. package/dist/cloudflare/index.d.ts +1 -0
  20. package/dist/cloudflare/index.js +1 -0
  21. package/dist/core/run-context.d.ts +50 -0
  22. package/dist/core/run-context.js +21 -1
  23. package/dist/debugger/app/assets/{index-D-2Q7ecG.js → index-BPu-NBr5.js} +2 -2
  24. package/dist/debugger/app/assets/{routes-lvmllT60.js → routes-FLQryDcz.js} +3 -3
  25. package/dist/debugger/app/index.html +1 -1
  26. package/dist/projectors/event-log-ops.d.ts +0 -6
  27. package/dist/projectors/event-log-ops.js +2 -12
  28. package/dist/projectors/event-log.d.ts +10 -5
  29. package/dist/projectors/event-log.js +26 -22
  30. package/dist/projectors/replica/columns.d.ts +41 -0
  31. package/dist/projectors/replica/columns.js +77 -0
  32. package/dist/projectors/replica/drizzle.d.ts +328 -57
  33. package/dist/projectors/replica/drizzle.js +18 -14
  34. package/dist/projectors/replica/migrations.d.ts +25 -5
  35. package/dist/projectors/replica/migrations.js +62 -14
  36. package/dist/projectors/replica/postgres.d.ts +12 -11
  37. package/dist/projectors/replica/postgres.js +12 -26
  38. package/dist/projectors/replica/sqlite-bun.d.ts +3 -1
  39. package/dist/projectors/replica/sqlite-bun.js +6 -2
  40. package/dist/projectors/replica/sqlite-migrations.d.ts +5 -5
  41. package/dist/projectors/replica/sqlite-migrations.js +22 -9
  42. package/dist/projectors/replica/sqlite.d.ts +12 -11
  43. package/dist/projectors/replica/sqlite.js +23 -16
  44. package/dist/runtime/looms.d.ts +27 -36
  45. package/dist/runtime/looms.js +1 -0
  46. package/dist/runtime/runtime.js +7 -1
  47. package/dist/runtime/server/http.js +4 -2
  48. package/dist/runtime/types.d.ts +6 -1
  49. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Clock, Effect, ManagedRuntime, Predicate } from 'effect';
2
- import { cachedDefinitionResolver, chainDefinitionResolvers, composeModules, createEvent, createThreadId, createRunId, DEFAULT_DEFINITION_VERSION, DEFAULT_SNAPSHOT_EVERY, staticDefinitionResolver, descendantThreadIds, EventStoreTag, foldRun, hasEntries, isRunTerminal, unavailableRunLauncher, planFork, project, readTraceContext, replayTo, sameStringRecord, summarizeRun, } from '@swirls/looms/core';
2
+ import { cachedDefinitionResolver, chainDefinitionResolvers, composeModules, createEvent, createThreadId, createRunId, DEFAULT_DEFINITION_VERSION, DEFAULT_SNAPSHOT_EVERY, staticDefinitionResolver, descendantThreadIds, EventStoreTag, foldRun, hasEntries, InvalidRunAttributesError, isRunTerminal, runAttributeIssues, unavailableRunLauncher, planFork, project, readTraceContext, replayTo, sameStringRecord, summarizeRun, } from '@swirls/looms/core';
3
3
  import { createCancellation } from './cancellation.js';
4
4
  import { nextRuntimeDeadline } from './deadline-transition-planner.js';
5
5
  import { ForkConflictError, RunNotFinishedError, RunNotFoundError, RunTerminalError, RuntimeExecutionError, SecretContextConflictError, StartRunConflictError, } from './errors.js';
@@ -158,6 +158,12 @@ export function createRuntime(options) {
158
158
  return committed.value;
159
159
  });
160
160
  const commitStart = (args, runId) => Effect.gen(function* () {
161
+ if (options.attributes) {
162
+ const issues = runAttributeIssues(options.attributes, args.attributes ?? {});
163
+ if (issues.length > 0) {
164
+ return yield* new InvalidRunAttributesError(issues);
165
+ }
166
+ }
161
167
  const definitionVersion = args.definitionVersion ?? DEFAULT_DEFINITION_VERSION;
162
168
  const resolved = yield* definitionResolver.resolve(args.kind, args.definitionName, definitionVersion);
163
169
  if (!resolved) {
@@ -1,5 +1,5 @@
1
1
  import { Data, Effect, Schema } from 'effect';
2
- import { EventStoreTag, ForkSourceError, InvalidEventError, InvalidInputError, JsonValueSchema, } from '@swirls/looms/core';
2
+ import { EventStoreTag, ForkSourceError, InvalidEventError, InvalidInputError, InvalidRunAttributesError, JsonValueSchema, } from '@swirls/looms/core';
3
3
  import { ForkConflictError, RunNotFinishedError, RunNotFoundError, RunOverloadedError, RunTerminalError, StartRunConflictError, } from '../runtime.js';
4
4
  export class RequestBodyError extends Data.TaggedError('RequestBodyError') {
5
5
  constructor(cause) {
@@ -57,7 +57,9 @@ export function toErrorResponse(err) {
57
57
  if (err instanceof RequestBodyError || err instanceof RequestQueryError) {
58
58
  return Response.json({ error: err.message }, { status: 400 });
59
59
  }
60
- if (err instanceof InvalidInputError || err instanceof InvalidEventError) {
60
+ if (err instanceof InvalidInputError ||
61
+ err instanceof InvalidEventError ||
62
+ err instanceof InvalidRunAttributesError) {
61
63
  return Response.json({ error: err.message, issues: err.issues }, { status: 400 });
62
64
  }
63
65
  if (err instanceof RunOverloadedError) {
@@ -1,5 +1,5 @@
1
1
  import type { Effect } from 'effect';
2
- import type { AnyRuntimeModule, ComposedRegistry, DefinitionResolver, EventEnvelope, EventInput, WorkerCallback, WorkerCallbackInput, DefinitionResolveError, WorkerCallbackResult, WorkerSecretsResult, EventStore, EventStoreAppendError, EventStoreError, EventStoreFencedError, EventStoreTag, EventStoreTrimCoverage, RunLauncher, RunLaunchSource, RunAttributes, SecretContext, TraceContext, EventStoreTruncationError, JsonValue, ProjectionDefinition, ReplayStep, RunState, RunSummary, SnapshotStore, SnapshotStoreError } from '@swirls/looms/core';
2
+ import type { AnyRuntimeModule, ComposedRegistry, DefinitionResolver, EventEnvelope, EventInput, WorkerCallback, WorkerCallbackInput, DefinitionResolveError, WorkerCallbackResult, WorkerSecretsResult, EventStore, EventStoreAppendError, EventStoreError, EventStoreFencedError, EventStoreTag, EventStoreTrimCoverage, RunLauncher, RunLaunchSource, RunAttributeFields, RunAttributes, SecretContext, TraceContext, EventStoreTruncationError, JsonValue, ProjectionDefinition, ReplayStep, RunState, RunSummary, SnapshotStore, SnapshotStoreError } from '@swirls/looms/core';
3
3
  import type { EventStoreTrimmedError } from '@swirls/looms/core';
4
4
  import type { DuplicateEffectDispatchError, MaxWakeIterationsError } from './errors';
5
5
  import type { RuntimeObserver } from './observer';
@@ -57,6 +57,11 @@ export interface CreateRuntimeOptions<TModules extends readonly AnyRuntimeModule
57
57
  readonly worker?: EffectWorker;
58
58
  /** Failure-isolated, framework-neutral operational event sink. */
59
59
  readonly observer?: RuntimeObserver;
60
+ /**
61
+ * Declared run attributes. When set, a start that misses a `required` attribute or sends an
62
+ * undeclared one fails with `InvalidRunAttributesError` and writes no events.
63
+ */
64
+ readonly attributes?: RunAttributeFields;
60
65
  }
61
66
  export interface EffectWorkerTask {
62
67
  readonly runId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/looms",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Pluggable event-sourced runtime for durable agents and workflows",
5
5
  "homepage": "https://github.com/ByteSliceHQ/looms#readme",
6
6
  "bugs": {