@dxos/compute 0.8.4-main.cb12b3f963 → 0.8.4-main.dfabb4ec29

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 (74) hide show
  1. package/dist/lib/neutral/StorageService.mjs +1 -1
  2. package/dist/lib/neutral/{chunk-S24LL2D5.mjs → chunk-CXDV2FPU.mjs} +6 -5
  3. package/dist/lib/neutral/chunk-CXDV2FPU.mjs.map +7 -0
  4. package/dist/lib/neutral/{chunk-FEABF5XY.mjs → chunk-EG7VLX2F.mjs} +3 -3
  5. package/dist/lib/neutral/{chunk-N462A6NO.mjs → chunk-JTZYM2QW.mjs} +7 -1
  6. package/dist/lib/neutral/chunk-JTZYM2QW.mjs.map +7 -0
  7. package/dist/lib/neutral/{chunk-4N4JAXCP.mjs → chunk-OA7JMLJK.mjs} +3 -3
  8. package/dist/lib/neutral/{chunk-QPCDM7MF.mjs → chunk-VIRNEVFD.mjs} +22 -2
  9. package/dist/lib/neutral/chunk-VIRNEVFD.mjs.map +7 -0
  10. package/dist/lib/neutral/{chunk-DDEBBRCI.mjs → chunk-XEVFBI6S.mjs} +1 -1
  11. package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
  12. package/dist/lib/neutral/{chunk-H6EHIVDN.mjs → chunk-YEDUHFRC.mjs} +3 -3
  13. package/dist/lib/neutral/fib-WSN4EY7R.mjs +10 -0
  14. package/dist/lib/neutral/index.mjs +186 -147
  15. package/dist/lib/neutral/index.mjs.map +4 -4
  16. package/dist/lib/neutral/meta.json +1 -1
  17. package/dist/lib/neutral/reply-XRLTFNDF.mjs +10 -0
  18. package/dist/lib/neutral/sleep-7O76LQCA.mjs +10 -0
  19. package/dist/lib/neutral/testing/index.mjs +7 -7
  20. package/dist/types/src/Blueprint.d.ts +8 -16
  21. package/dist/types/src/Blueprint.d.ts.map +1 -1
  22. package/dist/types/src/Credential.d.ts.map +1 -1
  23. package/dist/types/src/McpServer.d.ts +27 -0
  24. package/dist/types/src/McpServer.d.ts.map +1 -0
  25. package/dist/types/src/Operation.d.ts +6 -0
  26. package/dist/types/src/Operation.d.ts.map +1 -1
  27. package/dist/types/src/OperationHandlerSet.d.ts.map +1 -1
  28. package/dist/types/src/OperationRegistry.d.ts.map +1 -1
  29. package/dist/types/src/Routine.d.ts +6 -4
  30. package/dist/types/src/Routine.d.ts.map +1 -1
  31. package/dist/types/src/Script.d.ts.map +1 -1
  32. package/dist/types/src/StorageService.d.ts.map +1 -1
  33. package/dist/types/src/Template.d.ts +18 -12
  34. package/dist/types/src/Template.d.ts.map +1 -1
  35. package/dist/types/src/Template.test.d.ts +2 -0
  36. package/dist/types/src/Template.test.d.ts.map +1 -0
  37. package/dist/types/src/Trigger.d.ts.map +1 -1
  38. package/dist/types/src/TriggerEvent.d.ts.map +1 -1
  39. package/dist/types/src/errors.d.ts +69 -0
  40. package/dist/types/src/errors.d.ts.map +1 -1
  41. package/dist/types/src/index.d.ts +2 -1
  42. package/dist/types/src/index.d.ts.map +1 -1
  43. package/dist/types/src/testing/definitions.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +10 -10
  46. package/src/Blueprint.ts +5 -19
  47. package/src/Credential.ts +2 -0
  48. package/src/McpServer.ts +44 -0
  49. package/src/Operation.ts +23 -3
  50. package/src/OperationHandlerSet.ts +2 -0
  51. package/src/OperationRegistry.ts +2 -0
  52. package/src/Routine.ts +4 -0
  53. package/src/Script.ts +2 -0
  54. package/src/StorageService.ts +2 -0
  55. package/src/Template.test.ts +151 -0
  56. package/src/Template.ts +48 -31
  57. package/src/Trigger.ts +2 -0
  58. package/src/TriggerEvent.ts +2 -0
  59. package/src/errors.ts +21 -0
  60. package/src/index.ts +3 -1
  61. package/src/testing/definitions.ts +3 -3
  62. package/dist/lib/neutral/chunk-DDEBBRCI.mjs.map +0 -7
  63. package/dist/lib/neutral/chunk-N462A6NO.mjs.map +0 -7
  64. package/dist/lib/neutral/chunk-QPCDM7MF.mjs.map +0 -7
  65. package/dist/lib/neutral/chunk-S24LL2D5.mjs.map +0 -7
  66. package/dist/lib/neutral/fib-HDHBZHPE.mjs +0 -10
  67. package/dist/lib/neutral/reply-XSQMXAPX.mjs +0 -10
  68. package/dist/lib/neutral/sleep-WHTJQ56P.mjs +0 -10
  69. /package/dist/lib/neutral/{chunk-FEABF5XY.mjs.map → chunk-EG7VLX2F.mjs.map} +0 -0
  70. /package/dist/lib/neutral/{chunk-4N4JAXCP.mjs.map → chunk-OA7JMLJK.mjs.map} +0 -0
  71. /package/dist/lib/neutral/{chunk-H6EHIVDN.mjs.map → chunk-YEDUHFRC.mjs.map} +0 -0
  72. /package/dist/lib/neutral/{fib-HDHBZHPE.mjs.map → fib-WSN4EY7R.mjs.map} +0 -0
  73. /package/dist/lib/neutral/{reply-XSQMXAPX.mjs.map → reply-XRLTFNDF.mjs.map} +0 -0
  74. /package/dist/lib/neutral/{sleep-WHTJQ56P.mjs.map → sleep-7O76LQCA.mjs.map} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  list,
8
8
  set,
9
9
  withDefault
10
- } from "./chunk-DDEBBRCI.mjs";
10
+ } from "./chunk-XEVFBI6S.mjs";
11
11
  import "./chunk-J5LGTIGS.mjs";
12
12
  export {
13
13
  StorageService,
@@ -1,6 +1,7 @@
1
1
  import {
2
+ intrinsic,
2
3
  make
3
- } from "./chunk-QPCDM7MF.mjs";
4
+ } from "./chunk-VIRNEVFD.mjs";
4
5
 
5
6
  // src/testing/definitions.ts
6
7
  import * as Schema from "effect/Schema";
@@ -19,7 +20,7 @@ var Fibonacci = make({
19
20
  output: Schema.Struct({
20
21
  result: Schema.String
21
22
  })
22
- });
23
+ }).pipe(intrinsic);
23
24
  var Reply = make({
24
25
  meta: {
25
26
  key: "org.example.function.reply",
@@ -28,7 +29,7 @@ var Reply = make({
28
29
  },
29
30
  input: Schema.Any,
30
31
  output: Schema.Any
31
- });
32
+ }).pipe(intrinsic);
32
33
  var Sleep = make({
33
34
  meta: {
34
35
  key: "org.example.function.sleep",
@@ -42,11 +43,11 @@ var Sleep = make({
42
43
  })
43
44
  }),
44
45
  output: Schema.Void
45
- });
46
+ }).pipe(intrinsic);
46
47
 
47
48
  export {
48
49
  Fibonacci,
49
50
  Reply,
50
51
  Sleep
51
52
  };
52
- //# sourceMappingURL=chunk-S24LL2D5.mjs.map
53
+ //# sourceMappingURL=chunk-CXDV2FPU.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/testing/definitions.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Operation from '../Operation';\n\nexport const Fibonacci = Operation.make({\n meta: {\n key: 'org.example.function.fib',\n name: 'Fibonacci',\n description: 'Function that calculates a Fibonacci number',\n },\n input: Schema.Struct({\n iterations: Schema.optional(Schema.Number).annotations({\n description: 'Number of iterations',\n default: 100_000,\n }),\n }),\n output: Schema.Struct({\n result: Schema.String,\n }),\n}).pipe(Operation.intrinsic);\n\nexport const Reply = Operation.make({\n meta: {\n key: 'org.example.function.reply',\n name: 'Reply',\n description: 'Function that echoes the input',\n },\n input: Schema.Any,\n output: Schema.Any,\n}).pipe(Operation.intrinsic);\n\nexport const Sleep = Operation.make({\n meta: {\n key: 'org.example.function.sleep',\n name: 'Sleep',\n description: 'Function that sleeps for a given amount of time',\n },\n input: Schema.Struct({\n duration: Schema.optional(Schema.Number).annotations({\n description: 'Milliseconds to sleep',\n default: 100_000,\n }),\n }),\n output: Schema.Void,\n}).pipe(Operation.intrinsic);\n"],
5
+ "mappings": ";;;;;;AAIA,YAAYA,YAAY;AAIjB,IAAMC,YAAsBC,KAAK;EACtCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBC,YAAmBC,gBAAgBC,aAAM,EAAEC,YAAY;MACrDN,aAAa;MACbO,SAAS;IACX,CAAA;EACF,CAAA;EACAC,QAAeN,cAAO;IACpBO,QAAeC;EACjB,CAAA;AACF,CAAA,EAAGC,KAAeC,SAAS;AAEpB,IAAMC,QAAkBjB,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAca;EACdN,QAAeM;AACjB,CAAA,EAAGH,KAAeC,SAAS;AAEpB,IAAMG,QAAkBnB,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBc,UAAiBZ,gBAAgBC,aAAM,EAAEC,YAAY;MACnDN,aAAa;MACbO,SAAS;IACX,CAAA;EACF,CAAA;EACAC,QAAeS;AACjB,CAAA,EAAGN,KAAeC,SAAS;",
6
+ "names": ["Schema", "Fibonacci", "make", "meta", "key", "name", "description", "input", "Struct", "iterations", "optional", "Number", "annotations", "default", "output", "result", "String", "pipe", "intrinsic", "Reply", "Any", "Sleep", "duration", "Void"]
7
+ }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Fibonacci
3
- } from "./chunk-S24LL2D5.mjs";
3
+ } from "./chunk-CXDV2FPU.mjs";
4
4
  import {
5
5
  withHandler
6
- } from "./chunk-QPCDM7MF.mjs";
6
+ } from "./chunk-VIRNEVFD.mjs";
7
7
 
8
8
  // src/testing/fib.ts
9
9
  import * as Effect from "effect/Effect";
@@ -22,4 +22,4 @@ var fib_default = Fibonacci.pipe(withHandler(Effect.fn(function* ({ iterations =
22
22
  export {
23
23
  fib_default
24
24
  };
25
- //# sourceMappingURL=chunk-FEABF5XY.mjs.map
25
+ //# sourceMappingURL=chunk-EG7VLX2F.mjs.map
@@ -47,6 +47,10 @@ var InvalidOperationOutputError = class extends BaseError.extend("InvalidOperati
47
47
  };
48
48
  var TriggerStateNotFoundError = class extends BaseError.extend("TriggerStateNotFound", "Trigger state not found") {
49
49
  };
50
+ var FunctionsAiUpstreamError = class extends BaseError.extend("FunctionsAiUpstreamError", "Upstream AI service returned an error") {
51
+ };
52
+ var FunctionsAiMemoizationMissError = class extends BaseError.extend("FunctionsAiMemoizationMissError", "No memoized AI conversation found for the given cache key") {
53
+ };
50
54
 
51
55
  // src/OperationHandlerSet.ts
52
56
  var OperationHandlerSet_exports = {};
@@ -129,10 +133,12 @@ export {
129
133
  InvalidOperationInputError,
130
134
  InvalidOperationOutputError,
131
135
  TriggerStateNotFoundError,
136
+ FunctionsAiUpstreamError,
137
+ FunctionsAiMemoizationMissError,
132
138
  lazy,
133
139
  getHandler,
134
140
  getHandlerByKey,
135
141
  OperationHandlerProvider,
136
142
  OperationHandlerSet_exports
137
143
  };
138
- //# sourceMappingURL=chunk-N462A6NO.mjs.map
144
+ //# sourceMappingURL=chunk-JTZYM2QW.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/errors.ts", "../../../src/OperationHandlerSet.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\n// Errors from @dxos/operation.\n\nexport class InvokerNotInitializedError extends BaseError.extend(\n 'InvokerNotInitializedError',\n 'Invoker not initialized',\n) {\n constructor() {\n super();\n }\n}\n\nexport class NoHandlerError extends BaseError.extend('NoHandlerError', 'No handler found for operation. ') {\n constructor(operationKey: string) {\n super({ context: { operationKey } });\n }\n}\n\n// Errors from @dxos/functions.\n\nexport class ServiceNotAvailableError extends BaseError.extend('ServiceNotAvailable', 'Service not available') {\n constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { service }, ...options, message: `Service not available: ${service}` });\n }\n}\n\nexport class FunctionNotFoundError extends BaseError.extend('FunctionNotFound', 'Function not found') {\n constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { function: functionKey }, ...options });\n }\n}\n\nexport class FunctionError extends BaseError.extend('FunctionError', 'Function invocation error') {}\n\nexport class InvalidOperationInputError extends BaseError.extend(\n 'InvalidOperationInput',\n 'Operation input did not match schema',\n) {}\n\nexport class InvalidOperationOutputError extends BaseError.extend(\n 'InvalidOperationOutput',\n 'Operation output did not match schema',\n) {}\n\nexport class TriggerStateNotFoundError extends BaseError.extend('TriggerStateNotFound', 'Trigger state not found') {}\n\n/**\n * Raised when the upstream AI gateway responds with a structured JSON error envelope\n * (`{ \"type\": \"error\", \"error\": { \"type\": ..., \"message\": ... } }`). Surfaces as a typed\n * defect from `FunctionsAiHttpClient`, bypassing `@effect/ai`'s generic `HttpResponseError`\n * wrapping so callers can match on the error class directly.\n */\nexport class FunctionsAiUpstreamError extends BaseError.extend(\n 'FunctionsAiUpstreamError',\n 'Upstream AI service returned an error',\n) {}\n\n/**\n * Specialized `FunctionsAiUpstreamError` for the memoization layer: the recorded fixture for a\n * given cache key was not found and `ALLOW_LLM_GENERATION` is unset. The `cacheKey` is exposed\n * via `context.cacheKey` to make regeneration straightforward.\n */\nexport class FunctionsAiMemoizationMissError extends BaseError.extend(\n 'FunctionsAiMemoizationMissError',\n 'No memoized AI conversation found for the given cache key',\n) {}\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { assertArgument } from '@dxos/invariant';\n\nimport { NoHandlerError } from './errors';\nimport type * as Operation from './Operation';\n\nexport const TypeId = '~@dxos/operation/OperationHandlerSet' as const;\nexport type TypeId = typeof TypeId;\n\nexport interface OperationHandlerSet {\n [TypeId]: TypeId;\n\n readonly handlers: Effect.Effect<Operation.WithHandler<Operation.Definition.Any>[]>;\n\n getHandlers(): Promise<Operation.WithHandler<Operation.Definition.Any>[]>;\n}\n\nexport const isOperationHandlerSet = (value: unknown): value is OperationHandlerSet => {\n return typeof value === 'object' && value !== null && TypeId in value;\n};\n\nexport const empty: OperationHandlerSet = {\n [TypeId]: TypeId,\n handlers: Effect.succeed([]),\n getHandlers: () => Promise.resolve([]),\n};\n\n/**\n * Creates a new operation handler set from a list of handlers.\n *\n * @example\n * ```ts\n * const set = OperationHandlerSet.make(\n * Operation.withHandler(Operation.make({ input: Schema.Void, output: Schema.Void }), (input) => Effect.succeed({})),\n * Operation.withHandler(Operation.make({ input: Schema.Void, output: Schema.Void }), (input) => Effect.succeed({})),\n * );\n * ```\n */\nexport const make = (...handlers: Operation.WithHandler<Operation.Definition.Any>[]): OperationHandlerSet => {\n return async(() => Promise.resolve(handlers));\n};\n\nexport const async = (\n getHandlers: () => Promise<Operation.WithHandler<Operation.Definition.Any>[]>,\n): OperationHandlerSet => {\n // NOTE: Re-runing async module imports has a big performance penalty in Chrome.\n let promise: Promise<Operation.WithHandler<Operation.Definition.Any>[]> | null = null;\n const getHandlersCached = () => {\n if (!promise) {\n promise = getHandlers();\n }\n return promise;\n };\n return {\n [TypeId]: TypeId,\n getHandlers,\n handlers: Effect.promise(getHandlersCached),\n };\n};\n\n/**\n * Merges multiple operation handler sets into a single set.\n *\n */\nexport const merge = (...sets: OperationHandlerSet[]): OperationHandlerSet => {\n assertArgument(sets.every(isOperationHandlerSet), 'sets', 'sets must be an array of OperationHandlerSet');\n return async(() => Promise.all(sets.map((set) => set.getHandlers())).then((handlers) => handlers.flat()));\n};\n\n/**\n * Creates a new operation handler set from a list of lazy-loaded modules.\n *\n * @example\n * ```ts\n * const set = OperationHandlerSet.lazy(\n * () => import('./my-handler'),\n * () => import('./my-other-handler'),\n * );\n * ```\n */\nexport const lazy = (\n ...modules: (() => Promise<{ default: Operation.WithHandler<Operation.Definition.Any> }>)[]\n): OperationHandlerSet => {\n return async(() => Promise.all(modules.map((module) => module().then(({ default: handler }) => handler))));\n};\n\n/**\n * Gets a handler for an operation by definition.\n */\nexport const getHandler = <const Op extends Operation.Definition.Any>(\n set: OperationHandlerSet,\n definition: Op,\n): Effect.Effect<Operation.WithHandler<Op>, NoHandlerError> =>\n Effect.gen(function* () {\n const handlers = yield* set.handlers;\n const handler = handlers.find((handler) => handler.meta.key === definition.meta.key);\n if (!handler) {\n return yield* Effect.fail(new NoHandlerError(definition.meta.key));\n }\n return handler as any;\n });\n\n/**\n * Gets a handler for an operation by key.\n */\nexport const getHandlerByKey = (\n set: OperationHandlerSet,\n key: string,\n): Effect.Effect<Operation.WithHandler<Operation.Definition.Any>, NoHandlerError> =>\n Effect.gen(function* () {\n const handlers = yield* set.handlers;\n const handler = handlers.find((handler) => handler.meta.key === key);\n if (!handler) {\n return yield* Effect.fail(new NoHandlerError(key));\n }\n return handler as any;\n });\n\nexport class OperationHandlerProvider extends Context.Tag('@dxos/operation/OperationHandlerProvider')<\n OperationHandlerProvider,\n OperationHandlerSet\n>() {}\n\nexport const provide = (handlers: OperationHandlerSet): Layer.Layer<OperationHandlerProvider, never, never> =>\n Layer.succeed(OperationHandlerProvider, handlers);\n"],
5
+ "mappings": ";;;;;AAIA,SAASA,iBAAwC;AAI1C,IAAMC,6BAAN,cAAyCD,UAAUE,OACxD,8BACA,yBAAA,EAAA;EAEA,cAAc;AACZ,UAAK;EACP;AACF;AAEO,IAAMC,iBAAN,cAA6BH,UAAUE,OAAO,kBAAkB,kCAAA,EAAA;EACrE,YAAYE,cAAsB;AAChC,UAAM;MAAEC,SAAS;QAAED;MAAa;IAAE,CAAA;EACpC;AACF;AAIO,IAAME,2BAAN,cAAuCN,UAAUE,OAAO,uBAAuB,uBAAA,EAAA;EACpF,YAAYK,SAAiBC,SAA6C;AACxE,UAAM;MAAEH,SAAS;QAAEE;MAAQ;MAAG,GAAGC;MAASC,SAAS,0BAA0BF,OAAAA;IAAU,CAAA;EACzF;AACF;AAEO,IAAMG,wBAAN,cAAoCV,UAAUE,OAAO,oBAAoB,oBAAA,EAAA;EAC9E,YAAYS,aAAqBH,SAA6C;AAC5E,UAAM;MAAEH,SAAS;QAAEO,UAAUD;MAAY;MAAG,GAAGH;IAAQ,CAAA;EACzD;AACF;AAEO,IAAMK,gBAAN,cAA4Bb,UAAUE,OAAO,iBAAiB,2BAAA,EAAA;AAA8B;AAE5F,IAAMY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A,SAASiB,KAAI,CAAA;AACvG;AAaO,IAAMC,OAAO,IACfC,YAAAA;AAEH,SAAOb,MAAM,MAAMH,QAAQU,IAAIM,QAAQL,IAAI,CAACM,WAAWA,OAAAA,EAASJ,KAAK,CAAC,EAAEK,SAASC,QAAO,MAAOA,OAAAA,CAAAA,CAAAA;AACjG;AAKO,IAAMC,aAAa,CACxBR,KACAS,eAEOC,WAAI,aAAA;AACT,QAAMzB,WAAW,OAAOe,IAAIf;AAC5B,QAAMsB,UAAUtB,SAAS0B,KAAK,CAACJ,aAAYA,SAAQK,KAAKC,QAAQJ,WAAWG,KAAKC,GAAG;AACnF,MAAI,CAACN,SAAS;AACZ,WAAO,OAAcO,YAAK,IAAIC,eAAeN,WAAWG,KAAKC,GAAG,CAAA;EAClE;AACA,SAAON;AACT,CAAA;AAKK,IAAMS,kBAAkB,CAC7BhB,KACAa,QAEOH,WAAI,aAAA;AACT,QAAMzB,WAAW,OAAOe,IAAIf;AAC5B,QAAMsB,UAAUtB,SAAS0B,KAAK,CAACJ,aAAYA,SAAQK,KAAKC,QAAQA,GAAAA;AAChE,MAAI,CAACN,SAAS;AACZ,WAAO,OAAcO,YAAK,IAAIC,eAAeF,GAAAA,CAAAA;EAC/C;AACA,SAAON;AACT,CAAA;AAEK,IAAMU,2BAAN,cAA+CC,YAAI,0CAAA,EAAA,EAAA;AAGrD;AAEE,IAAMC,UAAU,CAAClC,aAChBC,cAAQ+B,0BAA0BhC,QAAAA;",
6
+ "names": ["BaseError", "InvokerNotInitializedError", "extend", "NoHandlerError", "operationKey", "context", "ServiceNotAvailableError", "service", "options", "message", "FunctionNotFoundError", "functionKey", "function", "FunctionError", "InvalidOperationInputError", "InvalidOperationOutputError", "TriggerStateNotFoundError", "FunctionsAiUpstreamError", "FunctionsAiMemoizationMissError", "Context", "Effect", "Layer", "assertArgument", "TypeId", "isOperationHandlerSet", "value", "empty", "handlers", "succeed", "getHandlers", "Promise", "resolve", "make", "async", "promise", "getHandlersCached", "merge", "sets", "assertArgument", "every", "all", "map", "set", "then", "flat", "lazy", "modules", "module", "default", "handler", "getHandler", "definition", "gen", "find", "meta", "key", "fail", "NoHandlerError", "getHandlerByKey", "OperationHandlerProvider", "Tag", "provide"]
7
+ }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Sleep
3
- } from "./chunk-S24LL2D5.mjs";
3
+ } from "./chunk-CXDV2FPU.mjs";
4
4
  import {
5
5
  withHandler
6
- } from "./chunk-QPCDM7MF.mjs";
6
+ } from "./chunk-VIRNEVFD.mjs";
7
7
 
8
8
  // src/testing/sleep.ts
9
9
  import * as Effect from "effect/Effect";
@@ -14,4 +14,4 @@ var sleep_default = Sleep.pipe(withHandler(Effect.fn(function* ({ duration = 1e5
14
14
  export {
15
15
  sleep_default
16
16
  };
17
- //# sourceMappingURL=chunk-4N4JAXCP.mjs.map
17
+ //# sourceMappingURL=chunk-OA7JMLJK.mjs.map
@@ -9,6 +9,7 @@ __export(Operation_exports, {
9
9
  PersistentOperation: () => PersistentOperation,
10
10
  Service: () => Service,
11
11
  deserialize: () => deserialize,
12
+ intrinsic: () => intrinsic,
12
13
  invoke: () => invoke,
13
14
  isOperationDefinition: () => isOperationDefinition,
14
15
  isOperationWithHandler: () => isOperationWithHandler,
@@ -45,6 +46,15 @@ var make = (props) => {
45
46
  }
46
47
  };
47
48
  };
49
+ var intrinsic = (op) => {
50
+ return {
51
+ ...op,
52
+ meta: {
53
+ ...op.meta,
54
+ deployedId: `intrinsic:${op.meta.key}`
55
+ }
56
+ };
57
+ };
48
58
  var withHandler = (opOrHandler, handler) => {
49
59
  if (handler === void 0) {
50
60
  const handlerFn = opOrHandler;
@@ -107,8 +117,17 @@ var PersistentOperation = Schema$.Struct({
107
117
  }),
108
118
  Annotation.SystemTypeAnnotation.set(true)
109
119
  );
120
+ var FUNCTION_META_KEY = "org.dxos.service.function";
110
121
  var serialize = (operation) => {
111
122
  return Obj.make(PersistentOperation, {
123
+ [Obj.Meta]: {
124
+ keys: operation.meta.deployedId ? [
125
+ {
126
+ source: FUNCTION_META_KEY,
127
+ id: operation.meta.deployedId
128
+ }
129
+ ] : []
130
+ },
112
131
  key: operation.meta.key,
113
132
  name: operation.meta.name ?? "",
114
133
  version: operation.meta.version ?? "0.0.0",
@@ -121,7 +140,7 @@ var serialize = (operation) => {
121
140
  });
122
141
  };
123
142
  var deserialize = (record) => {
124
- const deployedId = Obj.getMeta(record).keys.find((key) => key.source === "org.dxos.service.function")?.id;
143
+ const deployedId = Obj.getMeta(record).keys.find((key) => key.source === FUNCTION_META_KEY)?.id;
125
144
  return make({
126
145
  input: record.inputSchema ? JsonSchema.toEffectSchema(record.inputSchema) : Schema$.Unknown,
127
146
  output: record.outputSchema ? JsonSchema.toEffectSchema(record.outputSchema) : Schema$.Unknown,
@@ -170,10 +189,11 @@ var withInvocationOptions = (options) => Layer.effect(Service, Effect.gen(functi
170
189
 
171
190
  export {
172
191
  make,
192
+ intrinsic,
173
193
  withHandler,
174
194
  PersistentOperation,
175
195
  deserialize,
176
196
  invoke,
177
197
  Operation_exports
178
198
  };
179
- //# sourceMappingURL=chunk-QPCDM7MF.mjs.map
199
+ //# sourceMappingURL=chunk-VIRNEVFD.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Operation.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema$ from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\nimport { Annotation, JsonSchema, Obj, Ref, Type, type DXN, type Key } from '@dxos/echo';\n\nimport type { NoHandlerError } from './errors';\nimport type { Operation } from './index';\n\n/**\n * Schema type that accepts any Encoded form but requires no Context.\n * This allows ECHO object schemas where Type !== Encoded due to [KindId] symbol.\n */\ntype Schema<T> = Schema$.Schema<T, any, never>;\n\nexport const DefinitionTypeId = '~@dxos/operation/OperationDefinition' as const;\nexport type DefinitionTypeId = typeof DefinitionTypeId;\n\n/**\n * Serializable definition of an Operation.\n * Contains schema and metadata, but no runtime logic.\n */\nexport interface Definition<I, O, S = any> extends Pipeable.Pipeable, Definition.Variance<I, O, S> {\n /**\n * Input schema for the operation.\n */\n readonly input: Schema<I>;\n /**\n * Output schema for the operation.\n */\n readonly output: Schema<O>;\n\n readonly meta: {\n readonly key: string;\n readonly name?: string;\n readonly version?: string;\n readonly description?: string;\n /**\n * Deployment ID for remote invocation.\n * Assigned by the EDGE function service when deployed.\n */\n readonly deployedId?: string;\n };\n\n /**\n * Execution mode for the operation.\n * - 'sync': Operation completes synchronously (fast, UI-blocking acceptable).\n * - 'async': Operation may take time (should not block UI).\n */\n readonly executionMode: 'sync' | 'async';\n\n /**\n * ECHO types the operation uses.\n * Ensures types are available when the operation is executed remotely.\n */\n readonly types: readonly Type.AnyEntity[];\n\n /**\n * Effect services required by this operation.\n * These services will be automatically provided to the handler at invocation time.\n */\n readonly services: readonly Context.Tag<any, any>[];\n}\n\n/**\n * Namespace for OperationDefinition helper types.\n */\nexport declare namespace Definition {\n export interface Variance<I, O, S> {\n [DefinitionTypeId]: {\n readonly _Input: Types.Contravariant<I>;\n readonly _Output: Types.Covariant<O>;\n readonly _Services: Types.Covariant<S>;\n };\n }\n\n /**\n * Any operation definition, regardless of input/output types.\n */\n export type Any = Definition<any, any, any>;\n\n /**\n * Extract the input type from an operation definition.\n */\n export type Input<T extends Any> = T extends Variance<infer I, infer _O, infer _S> ? I : never;\n\n /**\n * Extract the output type from an operation definition.\n */\n export type Output<T extends Any> = T extends Variance<infer _I, infer O, infer _S> ? O : never;\n\n /**\n * Extract the service identifier types from an operation's services array.\n * Returns `never` if the operation has no services declared.\n */\n export type Services<T extends Any> = T extends Variance<infer _I, infer _O, infer S> ? S : never;\n\n export type HandlerType<T extends Any> =\n T extends Variance<infer I, infer O, infer S> ? Handler<I, O, any, S> : never;\n}\n\n/**\n * Runtime handler for an Operation.\n */\nexport type Handler<I, O, E = Error, R = never> = (input: I) => Effect.Effect<O, E, R>;\n\nexport type WithHandler<T extends Definition.Any> = T & {\n handler: Definition.HandlerType<T>;\n};\n\n/**\n * Checks if a value is an operation definition.\n */\nexport const isOperationDefinition = (value: unknown): value is Definition.Any => {\n return typeof value === 'object' && value !== null && DefinitionTypeId in value;\n};\n\n/**\n * Checks if a value is an operation with a handler.\n */\nexport const isOperationWithHandler = (value: unknown): value is WithHandler<Definition.Any> => {\n return isOperationDefinition(value) && 'handler' in value;\n};\n\n/**a\n * Props for creating an Operation definition.\n * Derived from OperationDefinition with executionMode made optional (defaults to 'async').\n */\nexport type Props<I, O> = Omit<Definition<I, O>, DefinitionTypeId | 'pipe' | 'executionMode' | 'types' | 'services'> & {\n readonly executionMode?: 'sync' | 'async';\n readonly types?: Definition<I, O>['types'];\n readonly services?: Definition<I, O>['services'];\n};\n\n/**\n * Creates a new Operation definition.\n * Applies default executionMode of 'async' if not specified.\n * The returned type preserves the literal types of props (including services).\n */\nexport const make = <const P extends Types.NoExcessProperties<Props<any, any>, P>>(\n props: P,\n): Definition<\n Schema$.Schema.Type<P['input']>,\n Schema$.Schema.Type<P['output']>,\n Context.Tag.Identifier<NonNullable<P['services']>[number]>\n> => {\n return {\n [DefinitionTypeId]: {},\n ...props,\n executionMode: props.executionMode ?? 'async',\n types: props.types ?? [],\n services: props.services ?? [],\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n },\n } as any;\n};\n\n/**\n * Marks an operation as intrinsic — provided directly by the DXOS platform runtime rather than\n * deployed as a user function. The `intrinsic:<key>` deployedId routes invocations to the\n * built-in implementation registered with the runtime.\n */\nexport const intrinsic = <const O extends Operation.Definition.Any>(op: O): O => {\n return {\n ...op,\n meta: {\n ...op.meta,\n deployedId: `intrinsic:${op.meta.key}`,\n },\n };\n};\n\n/**\n * Attaches a handler to an Operation definition.\n * The handler may use any services declared in the operation, plus Operation.Service (always available).\n * Dual API: can be called directly or used in a pipe.\n *\n * @example\n * ```ts\n * const MyOp = Operation.make({\n * input: Schema.Void,\n * output: Schema.Void,\n * meta: { key: 'my-op' },\n * services: [DatabaseService],\n * });\n *\n * // Direct call - handler can use DatabaseService\n * const op = Operation.withHandler(MyOp, (input) =>\n * Effect.gen(function* () {\n * const db = yield* DatabaseService;\n * return {};\n * }),\n * );\n *\n * // Piped call\n * const op = MyOp.pipe(Operation.withHandler((input) => Effect.succeed({})));\n * ```\n */\nexport const withHandler: {\n <Def extends Definition<any, any>, E = never>(\n handler: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n ): (op: Def) => WithHandler<Def>;\n <Def extends Definition<any, any>, E = never>(\n op: Def,\n handler: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n ): WithHandler<Def>;\n} = <Def extends Definition<any, any>, E = never>(\n opOrHandler: Def | Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n handler?: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n): WithHandler<Def> => {\n // If called with just handler (piped usage).\n if (handler === undefined) {\n const handlerFn = opOrHandler as Handler<\n Definition.Input<Def>,\n Definition.Output<Def>,\n E,\n Definition.Services<Def> | Service\n >;\n return ((op: Def) => ({\n ...op,\n handler: handlerFn,\n })) as any;\n }\n\n // If called with both op and handler (direct usage).\n const op = opOrHandler as Def;\n return {\n ...op,\n handler,\n } as any;\n};\n\n/**\n * Helper to make the handler type opaque.\n * Workaround for TypeScript's inability to infer the handler type from the operation definition:\n * ```\n * error TS2742: The inferred type of 'default' cannot be named without a reference.\n * ```\n *\n * Most of the time the exact handler type is not needed.\n *\n * @example\n * ```ts\n * const MyOp = Operation.make({\n * input: Schema.Void,\n * output: Schema.Void,\n * meta: { key: 'my-op' },\n * services: [DatabaseService],\n * });\n *\n * export default MyOp.pipe(\n * Operation.withHandler(\n * Effect.fn(function* (input) {\n * return { result: 'ok' };\n * }),\n * ),\n * Operation.opaqueHandler,\n * );\n * ```\n */\nexport const opaqueHandler = <T extends Operation.Definition.Any>(\n handler: Operation.WithHandler<T>,\n): Operation.WithHandler<Operation.Definition.Any> => handler;\n\n//\n// Invocation Interfaces\n//\n\n/**\n * Local invocation of an operation.\n */\nexport type Invoke = <I, O, E>(op: Definition<I, O>, input: I) => Effect.Effect<O, E>;\n\n/**\n * Remote invocation of an operation.\n */\nexport type InvokeRemote = <I, O, E>(\n op: Definition<I, O>,\n input: I,\n options?: { timeout?: number },\n) => Effect.Effect<O, E>;\n\n/**\n * Database record of an operation.\n */\nexport const PersistentOperation = Schema$.Struct({\n /**\n * Global registry ID.\n * NOTE: The `key` property refers to the original registry entry.\n */\n // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.\n // TODO(dmaretskyi): Consider making it part of ECHO meta.\n // TODO(dmaretskyi): Make required.\n key: Schema$.optional(Schema$.String).annotations({\n description: 'Unique registration key for the blueprint',\n }),\n\n name: Schema$.NonEmptyString,\n version: Schema$.String,\n\n description: Schema$.optional(Schema$.String),\n\n /**\n * ISO date string of the last deployment.\n */\n updated: Schema$.optional(Schema$.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema$.optional(Ref.Ref(Obj.Unknown)),\n\n inputSchema: Schema$.optional(JsonSchema.JsonSchema),\n outputSchema: Schema$.optional(JsonSchema.JsonSchema),\n\n /**\n * List of required services.\n * Match the Context.Tag keys of the FunctionServices variants.\n */\n services: Schema$.optional(Schema$.Array(Schema$.String)),\n\n // Local binding to a function name.\n // TODO(dmaretskyi): Add this field to Operation.Definition.\n binding: Schema$.optional(Schema$.String),\n}).pipe(\n // TODO(dmaretskyi): Keep typename as 'org.dxos.type.function' (not 'operation') to maintain\n // backward compatibility with existing data and avoid requiring data migration.\n Type.object({\n typename: 'org.dxos.type.function',\n version: '0.1.0',\n }),\n Annotation.LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--function--regular', hue: 'blue' }),\n Annotation.SystemTypeAnnotation.set(true),\n);\nexport interface PersistentOperation extends Schema$.Schema.Type<typeof PersistentOperation> {}\n\nconst FUNCTION_META_KEY = 'org.dxos.service.function';\n\n/**\n * Serialize an operation definition to a persistent operation record.\n */\nexport const serialize = (operation: Definition.Any): PersistentOperation => {\n return Obj.make(PersistentOperation, {\n [Obj.Meta]: {\n keys: operation.meta.deployedId ? [{ source: FUNCTION_META_KEY, id: operation.meta.deployedId }] : [],\n },\n key: operation.meta.key,\n name: operation.meta.name ?? '',\n version: operation.meta.version ?? '0.0.0',\n description: operation.meta.description,\n updated: undefined,\n source: undefined,\n inputSchema: JsonSchema.toJsonSchema(operation.input),\n outputSchema: JsonSchema.toJsonSchema(operation.output),\n services: operation.services.map((service) => service.key),\n });\n};\n\n/**\n * Deserialize a persistent operation record to an operation definition.\n */\nexport const deserialize = (record: PersistentOperation): Definition.Any => {\n // Extract deployed function ID from ECHO meta keys (matches FUNCTIONS_META_KEY in @dxos/functions).\n const deployedId = Obj.getMeta(record).keys.find((key) => key.source === FUNCTION_META_KEY)?.id;\n return make({\n input: record.inputSchema ? JsonSchema.toEffectSchema(record.inputSchema) : Schema$.Unknown,\n output: record.outputSchema ? JsonSchema.toEffectSchema(record.outputSchema) : Schema$.Unknown,\n services: record.services?.map((service) => Context.GenericTag(service)) ?? [],\n executionMode: 'async',\n types: [],\n meta: {\n key: record.key ?? record.name,\n name: record.name,\n version: record.version,\n description: record.description,\n deployedId,\n },\n });\n};\n\n/**\n * Update properties on the target operation record from the source operation record.\n */\nexport const setFrom = (target: PersistentOperation, source: PersistentOperation) => {\n Obj.update(target, (target) => {\n target.key = source.key ?? target.key;\n target.name = source.name ?? target.name;\n target.version = source.version;\n target.description = source.description;\n target.updated = source.updated;\n // TODO(dmaretskyi): A workaround for an ECHO bug.\n target.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : undefined;\n target.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : undefined;\n Obj.getMeta(target).keys = JSON.parse(JSON.stringify(Obj.getMeta(source).keys));\n });\n};\n\n/**\n * Options for operation invocation.\n */\nexport interface InvokeOptions {\n /**\n * Space ID to provide database context for the handler.\n */\n spaceId?: Key.SpaceId;\n /**\n * DXN string of the conversation feed (queue).\n * Passed to the process environment so nested operations can resolve AiContextService and related services.\n */\n conversation?: DXN.String;\n /**\n * Optional process-runtime tracing metadata (consumed by `@dxos/functions-runtime` when wired).\n */\n tracing?: unknown;\n}\n\n/**\n * Operation service interface - provides unified access to operation invocation and scheduling.\n * This service is automatically provided to operation handlers.\n */\nexport interface OperationService {\n /**\n * Invoke an operation as an Effect.\n * Returns an Effect that resolves to the operation output.\n */\n invoke: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n ) => Effect.Effect<O, NoHandlerError>;\n\n /**\n * Schedule an operation to run as a followup.\n * The followup is tracked and won't be cancelled when the parent operation completes.\n * Returns an Effect that completes immediately after scheduling.\n */\n schedule: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I] : [input: I]\n ) => Effect.Effect<void>;\n\n /**\n * Invoke an operation and return a Promise.\n * Useful for async contexts where Effect is not available.\n */\n invokePromise: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n ) => Promise<{ data?: O; error?: Error }>;\n}\n\n/**\n * Context tag for the Operation service.\n * Operation handlers can yield this to invoke other operations or schedule followups.\n *\n * @example\n * ```ts\n * const handler = (input) => Effect.gen(function* () {\n * // Schedule a followup (fire and forget)\n * yield* Operation.schedule(AnalyticsOperation, { event: 'completed' });\n *\n * // Invoke another operation\n * return yield* Operation.invoke(OtherOperation, { data: input.data });\n * });\n * ```\n */\n// TODO(dmaretskyi): Rename Operation.Invoker\nexport class Service extends Context.Tag('@dxos/operation/Service')<Service, OperationService>() {}\n\n//\n// Namespace functions - ergonomic access to Operation.Service methods.\n//\n\n/**\n * Invoke an operation as an Effect.\n * Yields the Operation.Service internally.\n *\n * @example\n * ```ts\n * yield* Operation.invoke(MyOperation, { data: 'test' });\n * ```\n */\nexport const invoke = <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n): Effect.Effect<O, NoHandlerError, Service> =>\n Effect.flatMap(Service, (ops) => ops.invoke(op, ...(args as [I, InvokeOptions?]))).pipe(\n Effect.withSpan('Operation.invoke'),\n );\n\n/**\n * Schedule an operation to run as a followup.\n * Yields the Operation.Service internally.\n *\n * @example\n * ```ts\n * yield* Operation.schedule(AnalyticsOperation, { event: 'completed' });\n * yield* Operation.schedule(VoidOperation); // input optional when void\n * ```\n */\nexport const schedule = <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I] : [input: I]\n): Effect.Effect<void, never, Service> =>\n Effect.flatMap(Service, (ops) => ops.schedule(op, args[0] as I)).pipe(Effect.withSpan('Operation.schedule'));\n\n/**\n * Provides additional invocation options to all invocations.\n */\nexport const withInvocationOptions = (options: InvokeOptions): Layer.Layer<Service, never, Service> =>\n Layer.effect(\n Service,\n Effect.gen(function* () {\n const service = yield* Service;\n return Service.of({\n invoke: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.invoke(op, input, { ...options, ...invocationOptions })) as any,\n invokePromise: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.invokePromise(op, input, { ...options, ...invocationOptions })) as any,\n schedule: service.schedule,\n });\n }),\n );\n"],
5
+ "mappings": ";;;;;AAAA;;;;;;;;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,aAAa;AAGzB,SAASC,Y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,IAAI4D,KAAK,CAAA,CAAE,CAAA,EAAQhE,KAAYmE,gBAAS,oBAAA,CAAA;AAKjF,IAAME,wBAAwB,CAACC,YAC9BC,aACJV,SACOW,WAAI,aAAA;AACT,QAAMxB,UAAU,OAAOa;AACvB,SAAOA,QAAQY,GAAG;IAChBV,QAAS,CAAC3D,IAA8ByC,OAAY6B,sBAClD1B,QAAQe,OAAO3D,IAAIyC,OAAO;MAAE,GAAGyB;MAAS,GAAGI;IAAkB,CAAA;IAC/DC,eAAgB,CAACvE,IAA8ByC,OAAY6B,sBACzD1B,QAAQ2B,cAAcvE,IAAIyC,OAAO;MAAE,GAAGyB;MAAS,GAAGI;IAAkB,CAAA;IACtEN,UAAUpB,QAAQoB;EACpB,CAAA;AACF,CAAA,CAAA;",
6
+ "names": ["Context", "Effect", "Layer", "Pipeable", "Schema$", "Annotation", "JsonSchema", "Obj", "Ref", "Type", "DefinitionTypeId", "isOperationDefinition", "value", "isOperationWithHandler", "make", "props", "executionMode", "types", "services", "pipe", "pipeArguments", "arguments", "intrinsic", "op", "meta", "deployedId", "key", "withHandler", "opOrHandler", "handler", "undefined", "handlerFn", "opaqueHandler", "PersistentOperation", "Struct", "optional", "String", "annotations", "description", "name", "NonEmptyString", "version", "updated", "source", "Unknown", "inputSchema", "outputSchema", "Array", "binding", "object", "typename", "LabelAnnotation", "set", "IconAnnotation", "icon", "hue", "SystemTypeAnnotation", "FUNCTION_META_KEY", "serialize", "operation", "Meta", "keys", "id", "toJsonSchema", "input", "output", "map", "service", "deserialize", "record", "getMeta", "find", "toEffectSchema", "GenericTag", "setFrom", "target", "update", "JSON", "parse", "stringify", "Service", "Tag", "invoke", "args", "flatMap", "ops", "withSpan", "schedule", "withInvocationOptions", "options", "effect", "gen", "of", "invocationOptions", "invokePromise"]
7
+ }
@@ -59,4 +59,4 @@ export {
59
59
  withDefault,
60
60
  StorageService_exports
61
61
  };
62
- //# sourceMappingURL=chunk-DDEBBRCI.mjs.map
62
+ //# sourceMappingURL=chunk-XEVFBI6S.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/StorageService.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\n\nexport interface Service {\n /** Read a value by key. Returns `None` if key does not exist. */\n get<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n ): Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S>>;\n\n /** Write a value for the given key. */\n set<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n value: Schema.Schema.Type<S>,\n ): Effect.Effect<void, never, Schema.Schema.Context<S>>;\n\n /** Remove a key. */\n delete(key: string): Effect.Effect<void>;\n\n /** List all keys, optionally filtered by prefix. */\n list(prefix?: string): Effect.Effect<readonly string[]>;\n\n /** Remove all keys managed by this scoped store. */\n clear(): Effect.Effect<void>;\n}\n\n/**\n * Scoped key-value storage service for processes.\n * Each process receives its own namespaced instance via the process manager.\n * Construct a live implementation with `StorageService.layer` from `@dxos/functions-runtime`.\n */\nexport class StorageService extends Context.Tag('@dxos/functions/StorageService')<StorageService, Service>() {}\n\nexport const get = Effect.serviceFunctionEffect(StorageService, (_) => _.get);\nexport const set = Effect.serviceFunctionEffect(StorageService, (_) => _.set);\nexport const deleteKey = Effect.serviceFunctionEffect(StorageService, (_) => _.delete);\nexport const list = Effect.serviceFunctionEffect(StorageService, (_) => _.list);\nexport const clear = Effect.serviceFunctionEffect(StorageService, (_) => _.clear);\n\n/**\n * Typed key in a storage service.\n */\nexport interface Key<T> extends Pipeable.Pipeable {\n readonly key: string;\n\n get: Effect.Effect<Option.Option<T>, never, StorageService>;\n set(value: T): Effect.Effect<void, never, StorageService>;\n delete(): Effect.Effect<void, never, StorageService>;\n}\n\n/**\n * Create a typed key in a storage service.\n */\nexport const key = <S extends Schema.Schema<any, string, any>>(schema: S, key: string): Key<Schema.Schema.Type<S>> => {\n return {\n key,\n get: get(schema, key),\n set: (value: Schema.Schema.Type<S>) => set(schema, key, value),\n delete: () => deleteKey(key),\n pipe(...args: any) {\n return Pipeable.pipeArguments(this, arguments);\n },\n };\n};\n\n/**\n * Typed key in a storage service with a default value.\n */\nexport interface KeyWithDefault<T, U> extends Pipeable.Pipeable {\n readonly key: string;\n get: Effect.Effect<T | U, never, StorageService>;\n set(value: U): Effect.Effect<void, never, StorageService>;\n delete(): Effect.Effect<void, never, StorageService>;\n}\n\n/**\n * Assign a default value to a key if it is not present.\n */\nexport const withDefault =\n <T>(getDefault: () => NoInfer<T>) =>\n (key: Key<T>): KeyWithDefault<T, T> => {\n return {\n key: key.key,\n get: key.get.pipe(Effect.map(Option.getOrElse(() => getDefault()))),\n set: (value) => key.set(value),\n delete: () => key.delete(),\n pipe(...args: any) {\n return Pipeable.pipeArguments(this, arguments);\n },\n };\n };\n"],
5
+ "mappings": ";;;;;AAAA;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAgCnB,IAAMC,iBAAN,cAAqCC,YAAI,gCAAA,EAAA,EAAA;AAA8D;AAEvG,IAAMC,MAAaC,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEF,GAAG;AACrE,IAAMG,MAAaF,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEC,GAAG;AACrE,IAAMC,YAAmBH,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEG,MAAM;AAC9E,IAAMC,OAAcL,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEI,IAAI;AACvE,IAAMC,QAAeN,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEK,KAAK;AAgBzE,IAAMC,MAAM,CAA4CC,QAAWD,SAAAA;AACxE,SAAO;IACLA,KAAAA;IACAR,KAAKA,IAAIS,QAAQD,IAAAA;IACjBL,KAAK,CAACO,UAAiCP,IAAIM,QAAQD,MAAKE,KAAAA;IACxDL,QAAQ,MAAMD,UAAUI,IAAAA;IACxBG,QAAQC,MAAS;AACf,aAAgBC,uBAAc,MAAMC,SAAAA;IACtC;EACF;AACF;AAeO,IAAMC,cACX,CAAIC,eACJ,CAACR,SAAAA;AACC,SAAO;IACLA,KAAKA,KAAIA;IACTR,KAAKQ,KAAIR,IAAIW,KAAYM,WAAWC,iBAAU,MAAMF,WAAAA,CAAAA,CAAAA,CAAAA;IACpDb,KAAK,CAACO,UAAUF,KAAIL,IAAIO,KAAAA;IACxBL,QAAQ,MAAMG,KAAIH,OAAM;IACxBM,QAAQC,MAAS;AACf,aAAgBC,uBAAc,MAAMC,SAAAA;IACtC;EACF;AACF;",
6
+ "names": ["Context", "Effect", "Option", "Pipeable", "StorageService", "Tag", "get", "serviceFunctionEffect", "_", "set", "deleteKey", "delete", "list", "clear", "key", "schema", "value", "pipe", "args", "pipeArguments", "arguments", "withDefault", "getDefault", "map", "getOrElse"]
7
+ }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Reply
3
- } from "./chunk-S24LL2D5.mjs";
3
+ } from "./chunk-CXDV2FPU.mjs";
4
4
  import {
5
5
  withHandler
6
- } from "./chunk-QPCDM7MF.mjs";
6
+ } from "./chunk-VIRNEVFD.mjs";
7
7
 
8
8
  // src/testing/reply.ts
9
9
  import * as Console from "effect/Console";
@@ -18,4 +18,4 @@ var reply_default = Reply.pipe(withHandler(Effect.fn(function* (input) {
18
18
  export {
19
19
  reply_default
20
20
  };
21
- //# sourceMappingURL=chunk-H6EHIVDN.mjs.map
21
+ //# sourceMappingURL=chunk-YEDUHFRC.mjs.map
@@ -0,0 +1,10 @@
1
+ import {
2
+ fib_default
3
+ } from "./chunk-EG7VLX2F.mjs";
4
+ import "./chunk-CXDV2FPU.mjs";
5
+ import "./chunk-VIRNEVFD.mjs";
6
+ import "./chunk-J5LGTIGS.mjs";
7
+ export {
8
+ fib_default as default
9
+ };
10
+ //# sourceMappingURL=fib-WSN4EY7R.mjs.map