@dxos/compute 0.9.1-staging.ee54ba693a → 0.11.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/dist/lib/AgentService.mjs +16 -0
- package/dist/lib/AgentService.mjs.map +1 -0
- package/dist/lib/StorageService.mjs +59 -0
- package/dist/lib/StorageService.mjs.map +1 -0
- package/dist/lib/chunk-OperationHandlerSet.mjs +660 -0
- package/dist/lib/chunk-OperationHandlerSet.mjs.map +1 -0
- package/dist/lib/chunk-definitions.mjs +41 -0
- package/dist/lib/chunk-definitions.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/index.mjs +1576 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/testing.mjs +43 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/AgentIdentity.d.ts +27 -0
- package/dist/types/src/AgentIdentity.d.ts.map +1 -0
- package/dist/types/src/AgentService.d.ts +10 -2
- package/dist/types/src/AgentService.d.ts.map +1 -1
- package/dist/types/src/Cancellation.d.ts +19 -0
- package/dist/types/src/Cancellation.d.ts.map +1 -0
- package/dist/types/src/Credential.d.ts +41 -0
- package/dist/types/src/Credential.d.ts.map +1 -1
- package/dist/types/src/Operation.d.ts +79 -1
- package/dist/types/src/Operation.d.ts.map +1 -1
- package/dist/types/src/Process.d.ts +15 -3
- package/dist/types/src/Process.d.ts.map +1 -1
- package/dist/types/src/Trace.d.ts +55 -3
- package/dist/types/src/Trace.d.ts.map +1 -1
- package/dist/types/src/Trace.test.d.ts +2 -0
- package/dist/types/src/Trace.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +35 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -6
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/operation.d.ts +5 -0
- package/dist/types/src/testing/operation.d.ts.map +1 -0
- package/dist/types/src/{Instructions.d.ts → types/Instructions.d.ts} +14 -1
- package/dist/types/src/types/Instructions.d.ts.map +1 -0
- package/dist/types/src/types/Instructions.test.d.ts +2 -0
- package/dist/types/src/types/Instructions.test.d.ts.map +1 -0
- package/dist/types/src/types/Project.d.ts +53 -0
- package/dist/types/src/types/Project.d.ts.map +1 -0
- package/dist/types/src/types/Project.test.d.ts +2 -0
- package/dist/types/src/types/Project.test.d.ts.map +1 -0
- package/dist/types/src/types/Routine.d.ts +42 -0
- package/dist/types/src/types/Routine.d.ts.map +1 -0
- package/dist/types/src/types/Routine.test.d.ts +2 -0
- package/dist/types/src/types/Routine.test.d.ts.map +1 -0
- package/dist/types/src/types/Script.d.ts.map +1 -0
- package/dist/types/src/{Skill.d.ts → types/Skill.d.ts} +1 -1
- package/dist/types/src/types/Skill.d.ts.map +1 -0
- package/dist/types/src/{Template.d.ts → types/Template.d.ts} +2 -2
- package/dist/types/src/types/Template.d.ts.map +1 -0
- package/dist/types/src/types/Template.test.d.ts.map +1 -0
- package/dist/types/src/types/Trigger.d.ts +249 -0
- package/dist/types/src/types/Trigger.d.ts.map +1 -0
- package/dist/types/src/{TriggerEvent.d.ts → types/TriggerEvent.d.ts} +19 -6
- package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +9 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -17
- package/src/AgentIdentity.ts +35 -0
- package/src/AgentService.ts +10 -2
- package/src/Cancellation.ts +33 -0
- package/src/Credential.ts +52 -0
- package/src/Operation.ts +92 -2
- package/src/Process.ts +21 -4
- package/src/Trace.test.ts +155 -0
- package/src/Trace.ts +207 -6
- package/src/errors.ts +9 -5
- package/src/index.ts +3 -6
- package/src/testing/index.ts +1 -0
- package/src/testing/operation.ts +21 -0
- package/src/types/Instructions.test.ts +18 -0
- package/src/{Instructions.ts → types/Instructions.ts} +22 -1
- package/src/types/Project.test.ts +52 -0
- package/src/types/Project.ts +99 -0
- package/src/types/Routine.test.ts +18 -0
- package/src/types/Routine.ts +85 -0
- package/src/{Skill.ts → types/Skill.ts} +2 -2
- package/src/{Template.test.ts → types/Template.test.ts} +2 -2
- package/src/{Template.ts → types/Template.ts} +2 -2
- package/src/{Trigger.ts → types/Trigger.ts} +126 -8
- package/src/{TriggerEvent.ts → types/TriggerEvent.ts} +23 -5
- package/src/types/index.ts +12 -0
- package/dist/lib/neutral/AgentService.mjs +0 -12
- package/dist/lib/neutral/AgentService.mjs.map +0 -7
- package/dist/lib/neutral/StorageService.mjs +0 -22
- package/dist/lib/neutral/StorageService.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2ZN64ZS7.mjs +0 -25
- package/dist/lib/neutral/chunk-2ZN64ZS7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-5VAXF6AH.mjs +0 -53
- package/dist/lib/neutral/chunk-5VAXF6AH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EVROJER7.mjs +0 -285
- package/dist/lib/neutral/chunk-EVROJER7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PF7XP7XP.mjs +0 -62
- package/dist/lib/neutral/chunk-PF7XP7XP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SJ37RWHU.mjs +0 -21
- package/dist/lib/neutral/chunk-SJ37RWHU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VSAZPWSJ.mjs +0 -25
- package/dist/lib/neutral/chunk-VSAZPWSJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WEO4FCQY.mjs +0 -17
- package/dist/lib/neutral/chunk-WEO4FCQY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs +0 -174
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs.map +0 -7
- package/dist/lib/neutral/fib-5XIYECL5.mjs +0 -10
- package/dist/lib/neutral/fib-5XIYECL5.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -1232
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/reply-GCBRCUVM.mjs +0 -10
- package/dist/lib/neutral/reply-GCBRCUVM.mjs.map +0 -7
- package/dist/lib/neutral/sleep-XR6CL6W3.mjs +0 -10
- package/dist/lib/neutral/sleep-XR6CL6W3.mjs.map +0 -7
- package/dist/lib/neutral/testing/index.mjs +0 -32
- package/dist/lib/neutral/testing/index.mjs.map +0 -7
- package/dist/types/src/Instructions.d.ts.map +0 -1
- package/dist/types/src/Script.d.ts.map +0 -1
- package/dist/types/src/Skill.d.ts.map +0 -1
- package/dist/types/src/Template.d.ts.map +0 -1
- package/dist/types/src/Template.test.d.ts.map +0 -1
- package/dist/types/src/Trigger.d.ts +0 -157
- package/dist/types/src/Trigger.d.ts.map +0 -1
- package/dist/types/src/TriggerEvent.d.ts.map +0 -1
- /package/dist/types/src/{Script.d.ts → types/Script.d.ts} +0 -0
- /package/dist/types/src/{Template.test.d.ts → types/Template.test.d.ts} +0 -0
- /package/src/{Script.ts → types/Script.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-OperationHandlerSet.mjs","names":[],"sources":["../../src/errors.ts","../../src/Operation.ts","../../src/OperationHandlerSet.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\n/**\n * Raised when a function wants to yield to the scheduler to not exceed platform limits.\n * The scheduler will re-run the function after the yield.\n * It is assumed that the function can be retried with the same input.\n * The function might have produced side-effects on the first run.\n */\nexport class RunAgainError extends BaseError.extend('RunAgainError', 'Run again') {}\n\n// Errors from @dxos/operation.\n\nexport class InvokerNotInitializedError extends BaseError.extend(\n 'InvokerNotInitializedError',\n 'Invoker not initialized',\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 }, message: `Service not available: ${service}`, ...options });\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 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Cause from 'effect/Cause';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\nimport * as Schema$ from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\nimport { Annotation, DXN, JsonSchema, type Key, Migration, Obj, Ref, Type } from '@dxos/echo';\nimport type { URI } from '@dxos/keys';\n\nimport { type NoHandlerError, RunAgainError } 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: DXN.DXN;\n readonly name?: string;\n readonly version?: string;\n readonly description?: string;\n /**\n * Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).\n */\n readonly icon?: 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 * Dictionary of annotations for the operation.\n */\n // TODO(dmaretskyi): Make required, but this complicates `make` to fill in defaults.\n readonly annotations?: Annotation.Dictionary;\n\n /**\n * When true, this operation is not serialized into the hypergraph registry.\n * Use for UI-only operations that should not be discoverable by the AI agent.\n */\n readonly skipRegistry?: boolean;\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/**\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 * 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 * The registry `key` and `version` live in the object meta — access via\n * `Obj.getMeta(record).key` and `Obj.getMeta(record).version`.\n */\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.\nexport class PersistentOperation extends Type.makeObject<PersistentOperation>(\n DXN.make('org.dxos.type.function', '0.2.0'),\n)(\n Schema$.Struct({\n name: Schema$.NonEmptyString,\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 services the operation handler declares.\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\n /**\n * Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).\n */\n icon: Schema$.optional(Schema$.String),\n }).pipe(\n Annotation.LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--function--regular', hue: 'blue' }),\n Annotation.HiddenAnnotation.set(true),\n ),\n) {}\n\nconst FUNCTION_META_KEY = 'org.dxos.service.function';\n\n/**\n * Get the registry key for a persistent operation record (from the object meta).\n */\nexport const getKey = (record: PersistentOperation): string | undefined => Obj.getMeta(record).key;\n\n/**\n * Get the registry version for a persistent operation record (from the object meta).\n */\nexport const getVersion = (record: PersistentOperation): string | undefined => Obj.getMeta(record).version;\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 key: operation.meta.key,\n version: operation.meta.version ?? '0.0.0',\n keys: operation.meta.deployedId ? [{ source: FUNCTION_META_KEY, id: operation.meta.deployedId }] : [],\n annotations: operation.meta.annotations,\n },\n name: operation.meta.name ?? '',\n description: operation.meta.description,\n icon: operation.meta.icon,\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 const meta = Obj.getMeta(record);\n // Extract deployed function ID from ECHO meta keys (matches FUNCTIONS_META_KEY in @dxos/functions).\n const deployedId = meta.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: DXN.tryMake(meta.key ?? record.name) ?? DXN.make(meta.key ?? record.name),\n name: record.name,\n version: meta.version ?? '0.0.0',\n description: record.description,\n icon: record.icon,\n deployedId,\n annotations: meta.annotations ?? {},\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.name = source.name ?? target.name;\n target.description = source.description;\n target.icon = source.icon;\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 const sourceMeta = Obj.getMeta(source);\n const targetMeta = Obj.getMeta(target);\n targetMeta.key = sourceMeta.key ?? targetMeta.key;\n targetMeta.version = sourceMeta.version;\n // Only overwrite foreign keys when the source actually carries them; otherwise we'd wipe\n // bindings (e.g. the deployedId set by `deserialize`) on records produced by `serialize`.\n if (sourceMeta.keys.length > 0) {\n targetMeta.keys = JSON.parse(JSON.stringify(sourceMeta.keys));\n }\n targetMeta.annotations = sourceMeta.annotations ?? targetMeta.annotations;\n });\n};\n\n/**\n * Translatable label — a plain string or an i18next-style `[key, options]` tuple.\n * Defined locally to avoid a core dependency on UI translation packages; structurally compatible with\n * the app-level `Label` type so values flow into UI toasts unchanged.\n */\nexport const Label = Schema.Union(\n Schema.String,\n // `Schema.mutable` mirrors the app-level `Label` (whose tuple is mutable), so decoded values are\n // assignable to UI toast `title`/`label` slots without a readonly-vs-mutable tuple mismatch.\n Schema.mutable(\n Schema.Tuple(\n Schema.String,\n Schema.mutable(\n Schema.Struct({\n ns: Schema.String,\n count: Schema.optional(Schema.Number),\n defaultValue: Schema.optional(Schema.String),\n }),\n ),\n ),\n ),\n);\nexport type Label = Schema.Schema.Type<typeof Label>;\n\n/**\n * Per-phase user notification messages for an invocation.\n * A phase is notified to the user iff its message is provided; messages are translatable {@link Label}s.\n */\nexport const NotifyOptions = Schema.Struct({\n /** Shown when the invocation starts. */\n start: Schema.optional(Label),\n /** Shown when the invocation succeeds. */\n success: Schema.optional(Label),\n /** Shown when the invocation fails. */\n error: Schema.optional(Label),\n});\nexport type NotifyOptions = Schema.Schema.Type<typeof NotifyOptions>;\n\n/**\n * Annotation that configures the process to notify the user at the given invocation phases.\n */\nexport const NotifyOptionsAnnotation = Annotation.make({\n id: 'org.dxos.operation.notify-options',\n schema: NotifyOptions,\n});\n\n/**\n * A serializable reference to an operation invocation — the target operation's key plus its input.\n * Describes a deferred/late-bound invocation that must survive a serialization boundary (e.g. riding\n * on a process-failure error, or persisted) where a live {@link Definition} cannot. Resolve the key\n * with `OperationHandlerSet.getHandlerByKey` and hand the result to the invoker. Carries no functions,\n * so `input` must itself be serializable.\n */\nexport interface SerializedInvocation {\n /** Target operation key as a URI (a DXN, e.g. `dxn:org.dxos.plugin.deck.operation.open`). */\n readonly operation: URI.URI;\n /** Input passed to the operation; must be serializable. */\n readonly input?: unknown;\n}\n\n/**\n * Builds a {@link SerializedInvocation} from a live {@link Definition} and its input — the serializable\n * counterpart to a direct `invoke`, for describing an invocation that must cross a serialization\n * boundary (e.g. a deferred toast action). Resolve it later with `OperationHandlerSet.getHandlerByKey`.\n */\nexport const prepare = <I, O>(operation: Definition<I, O>, input: I): SerializedInvocation => ({\n operation: operation.meta.key,\n input,\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 * Request user-facing notifications at the given invocation phases.\n */\n notify?: NotifyOptions;\n /**\n * URI of the conversation feed (queue) — today always an EID, but typed as\n * `URI.URI` to accommodate future entity-kind extensions. Narrow with `EID.parse`\n * at the point of use.\n * Passed to the process environment so nested operations can resolve HarnessService and related services.\n */\n conversation?: URI.URI;\n /**\n * Optional process-runtime tracing metadata (consumed by `@dxos/functions-runtime` when wired).\n */\n tracing?: unknown;\n\n /**\n * Specifies the runtime environment for the operation.\n * By default, the operation is executed on the local runtime.\n */\n on?: 'edge' | 'local';\n}\n\n/**\n * Annotation that marks an operation as idempotent — safe to retry even if a previous execution\n * was interrupted mid-handler. When absent the operation is treated as non-idempotent, and the\n * process runtime will fail (rather than re-run) any handler that was interrupted.\n */\nexport const IdempotentAnnotation = Annotation.make({\n id: 'org.dxos.operation.idempotent',\n schema: Schema$.Boolean,\n});\n\n/**\n * Returns true when the operation is explicitly annotated as idempotent.\n */\nexport const isIdempotent = (op: Definition.Any): boolean =>\n op.meta.annotations\n ? Option.getOrElse(Annotation.getDictionary(op.meta.annotations, IdempotentAnnotation), () => false)\n : false;\n\n/**\n * Attaches an annotation to an operation definition, returning a new definition.\n * Combinators never mutate their input — operation definitions are module-level singletons\n * shared across handler sets, skills, and the registry, so a fresh value keeps the\n * annotated definition distinct from any other reference to the original.\n *\n * Type-preserving: an annotation does not change the operation's input/output/service types, so the\n * returned definition keeps `Def` (preserving `withHandler` inference and downstream usage).\n */\nexport const annotate =\n <T>(annotation: Annotation.Annotation<T>, value: T) =>\n <Def extends Definition.Any>(op: Def): Def => {\n const annotations = { ...(op.meta.annotations ?? {}) };\n Annotation.setDictionary(annotations, annotation, value);\n // The spread reconstructs the same shape with only `meta.annotations` changed; the checker can't\n // track the branded variance symbol through the untyped dictionary mutation, so reassert `Def`.\n return { ...op, meta: { ...op.meta, annotations } } as Def;\n };\n\n/**\n * Marks an operation as visible on user-facing operation surfaces (trigger/automation pickers,\n * manual invocation). Absent ⇒ internal: invoked programmatically by plugins and hidden from pickers.\n *\n * Polarity is inverted from the schema-level `HiddenAnnotation` (default visible): operations are\n * hidden by default, since most are internal plugin machinery and only a minority are user-facing.\n */\nexport const VisibleAnnotation = Annotation.make({\n id: 'org.dxos.operation.visible',\n schema: Schema$.Boolean,\n});\n\n/**\n * Pipeable combinator that marks an operation visible. Apply at the definition site:\n * `Operation.make({ ... }).pipe(Operation.visible)`.\n */\nexport const visible = annotate(VisibleAnnotation, true);\n\n/**\n * Returns true when an operation is annotated as visible on user-facing surfaces (trigger/automation\n * pickers, manual invocation). Reads from the persisted operation — the form every consumer holds.\n */\nexport const isVisible = (op: PersistentOperation): boolean =>\n Option.getOrElse(Annotation.get(op, VisibleAnnotation), () => false);\n\n/**\n * Projection marker for an operation exposed as an MCP tool to external agents.\n * See plugin-projects `MILESTONE-5.md` §7.4 for the full contract.\n */\nexport const McpTool = Schema$.Struct({\n /** Tool name as exposed to MCP clients; camelCase, domain-prefixed (e.g. `taskCreate`). */\n name: Schema$.String,\n /** Model-facing description; falls back to the operation's own description when absent. */\n description: Schema$.optional(Schema$.String),\n /**\n * Safety class the server maps to MCP tool hints: `read` is side-effect free (readOnlyHint),\n * `write` mutates space data, `destructive` deletes or is otherwise irreversible.\n */\n safety: Schema$.Literal('read', 'write', 'destructive'),\n /** Aspect/toolset, for server-side filtering (e.g. `/mcp?toolsets=tasks`). */\n aspect: Schema$.optional(Schema$.String),\n});\nexport type McpTool = Schema$.Schema.Type<typeof McpTool>;\n\n/**\n * Annotation that opts an operation into MCP projection. The annotation rides through\n * {@link serialize} into the persisted record, so a remote projector (edge mcp-space-service)\n * discovers tools from the operation registry rather than a hand-maintained table.\n *\n * Projected operations must be remotely invocable: refs (not live objects) in, JSON snapshots\n * out, schemas that survive serialization, and worker-safe handlers — MILESTONE-5.md §7.4.\n */\nexport const McpToolAnnotation = Annotation.make({\n id: 'org.dxos.operation.mcp-tool',\n schema: McpTool,\n});\n\n/**\n * Pipeable combinator that opts an operation into MCP projection. Apply at the definition site:\n * `Operation.make({ ... }).pipe(Operation.mcpTool({ name: 'taskComplete', safety: 'write' }))`.\n */\nexport const mcpTool = (props: McpTool) => annotate(McpToolAnnotation, props);\n\n/**\n * Returns the MCP projection descriptor when the operation is annotated for it, else undefined.\n * Reads from the persisted operation — the form the projector holds.\n */\nexport const getMcpTool = (op: PersistentOperation): McpTool | undefined =>\n Option.getOrUndefined(Annotation.get(op, McpToolAnnotation));\n\n/**\n * Pipeable combinator that marks an operation idempotent — see {@link IdempotentAnnotation}. Apply at\n * the definition site: `Operation.make({ ... }).pipe(Operation.idempotent)`.\n */\nexport const idempotent = annotate(IdempotentAnnotation, true);\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, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\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, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n): Effect.Effect<void, never, Service> =>\n Effect.flatMap(Service, (ops) => ops.schedule(op, ...(args as [I, InvokeOptions?]))).pipe(\n Effect.withSpan('Operation.schedule'),\n );\n\n/**\n * Call inside an operation to stop the current invocation and have the system re-run it (e.g. a capped\n * sync run with more work left). Surfaces as a {@link RunAgainError} defect; the trigger dispatcher\n * re-queues the same event FIFO to continue. A caller invoking via `Operation.invoke` directly gets the\n * defect and does not auto-continue.\n */\nexport const runAgain = (): Effect.Effect<never, void> => Effect.failCauseSync(() => Cause.die(new RunAgainError()));\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: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.schedule(op, input, { ...options, ...invocationOptions })) as any,\n });\n }),\n );\n\n//\n// Legacy schemas and migrations.\n//\n\n/**\n * Persistent operation schema v0.1.0 — `key` and `version` are stored as data properties.\n * @deprecated Use {@link PersistentOperation} (v0.2.0) instead; the `key` and `version` now live in the object meta.\n */\nexport class PersistentOperation_v0_1_0 extends Type.makeObject<PersistentOperation_v0_1_0>(\n DXN.make('org.dxos.type.function', '0.1.0'),\n)(\n Schema$.Struct({\n key: Schema$.optional(Schema$.String),\n name: Schema$.NonEmptyString,\n version: Schema$.String,\n description: Schema$.optional(Schema$.String),\n updated: Schema$.optional(Schema$.String),\n source: Schema$.optional(Ref.Ref(Obj.Unknown)),\n inputSchema: Schema$.optional(JsonSchema.JsonSchema),\n outputSchema: Schema$.optional(JsonSchema.JsonSchema),\n services: Schema$.optional(Schema$.Array(Schema$.String)),\n binding: Schema$.optional(Schema$.String),\n }),\n) {}\n\n/**\n * Migration from {@link PersistentOperation_v0_1_0} (v0.1.0) to {@link PersistentOperation} (v0.2.0).\n * Moves `key` and `version` from the data section into the object meta.\n */\nconst _migration = Migration.define({\n from: PersistentOperation_v0_1_0,\n to: PersistentOperation,\n transform: async (from) => ({\n [Obj.Meta]: { key: from.key, version: from.version },\n name: from.name,\n description: from.description,\n updated: from.updated,\n source: from.source as any,\n inputSchema: from.inputSchema,\n outputSchema: from.outputSchema,\n services: from.services,\n binding: from.binding,\n }),\n});\n\n/**\n * Schema migrations exported by this module.\n * Exported as an array for extensibility — append future versions here.\n */\nexport const migrations = [_migration];\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type Atom, type Registry } from '@effect-atom/atom';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport { pipe } from 'effect/Function';\nimport * as Layer from 'effect/Layer';\n\nimport { EffectEx } from '@dxos/effect';\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN } from '@dxos/keys';\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 * Builds a set backed by an atom of contributed sets. The merged result is\n * cached and invalidated whenever the atom changes, so most accesses are\n * cheap but newly registered handlers are picked up.\n */\nexport const reactive = (\n registry: Registry.Registry,\n atom: Atom.Atom<readonly OperationHandlerSet[]>,\n): OperationHandlerSet => {\n let cached: Promise<Operation.WithHandler<Operation.Definition.Any>[]> | null = null;\n registry.subscribe(atom, () => {\n cached = null;\n });\n // `suspend` defers `registry.get(atom)` until each run, so re-evaluations\n // after cache invalidation see the current contributed sets.\n const compute = Effect.suspend(() =>\n pipe(\n registry.get(atom),\n Effect.forEach((set) => set.handlers, { concurrency: 'unbounded' }),\n Effect.map((groups) => groups.flat()),\n // Reset cached on failure so a transient error doesn't permanently\n // poison subsequent calls.\n Effect.tapErrorCause(() =>\n Effect.sync(() => {\n cached = null;\n }),\n ),\n ),\n );\n const getHandlers = () => (cached ??= EffectEx.runAndForwardErrors(compute));\n return {\n [TypeId]: TypeId,\n getHandlers,\n handlers: Effect.promise(getHandlers),\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 * Accepts either a plain NSID (`org.dxos.function.database.contextAdd`) or a\n * full DXN string (`dxn:org.dxos.function.database.contextAdd`).\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 // Normalize both sides to plain NSID for comparison so callers can pass\n // either a ToolId (plain NSID) or a full DXN string.\n const normalizeKey = (k: string) => (DXN.isDXN(k) ? DXN.getName(k) : k);\n const normalizedKey = normalizeKey(key);\n const handler = handlers.find((handler) => normalizeKey(handler.meta.key) === normalizedKey);\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,IAAa,gBAAb,cAAmC,UAAU,OAAO,iBAAiB,WAAW,CAAC,CAAC,CAAC;AAInF,IAAa,6BAAb,cAAgD,UAAU,OACxD,8BACA,yBACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoC,UAAU,OAAO,kBAAkB,kCAAkC,CAAC,CAAC;CACzG,YAAY,cAAsB;EAChC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;CACrC;AACF;AAIA,IAAa,2BAAb,cAA8C,UAAU,OAAO,uBAAuB,uBAAuB,CAAC,CAAC;CAC7G,YAAY,SAAiB,SAA6C;EACxE,MAAM;GAAE,SAAS,EAAE,QAAQ;GAAG,SAAS,0BAA0B;GAAW,GAAG;EAAQ,CAAC;CAC1F;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,OAAO,CAAC,CAAC,CAAC;AAC3G;;;;AAKA,IAAa,cACX,KACA,eAEA,OAAO,IAAI,aAAa;CAEtB,MAAM,WAAU,OADQ,IAAI,SAAA,CACH,MAAM,YAAY,QAAQ,KAAK,QAAQ,WAAW,KAAK,GAAG;CACnF,IAAI,CAAC,SACH,OAAO,OAAO,OAAO,KAAK,IAAI,eAAe,WAAW,KAAK,GAAG,CAAC;CAEnE,OAAO;AACT,CAAC;;;;;;AAOH,IAAa,mBACX,KACA,QAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAO,IAAI;CAG5B,MAAM,gBAAgB,MAAe,MAAI,MAAM,CAAC,IAAI,MAAI,QAAQ,CAAC,IAAI;CACrE,MAAM,gBAAgB,aAAa,GAAG;CACtC,MAAM,UAAU,SAAS,MAAM,YAAY,aAAa,QAAQ,KAAK,GAAG,MAAM,aAAa;CAC3F,IAAI,CAAC,SACH,OAAO,OAAO,OAAO,KAAK,IAAI,eAAe,GAAG,CAAC;CAEnD,OAAO;AACT,CAAC;AAEH,IAAa,2BAAb,cAA8C,QAAQ,IAAI,0CAA0C,CAAC,CAGnG,CAAC,CAAC,CAAC;AAEL,IAAa,WAAW,aACtB,MAAM,QAAQ,0BAA0B,QAAQ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { p as make } from "./chunk-OperationHandlerSet.mjs";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { DXN } from "@dxos/keys";
|
|
4
|
+
//#region src/testing/definitions.ts
|
|
5
|
+
var Fibonacci = make({
|
|
6
|
+
meta: {
|
|
7
|
+
key: DXN.make("org.example.function.fib"),
|
|
8
|
+
name: "Fibonacci",
|
|
9
|
+
description: "Function that calculates a Fibonacci number"
|
|
10
|
+
},
|
|
11
|
+
input: Schema.Struct({ iterations: Schema.optional(Schema.Number).annotations({
|
|
12
|
+
description: "Number of iterations",
|
|
13
|
+
default: 1e5
|
|
14
|
+
}) }),
|
|
15
|
+
output: Schema.Struct({ result: Schema.String })
|
|
16
|
+
});
|
|
17
|
+
var Reply = make({
|
|
18
|
+
meta: {
|
|
19
|
+
key: DXN.make("org.example.function.reply"),
|
|
20
|
+
name: "Reply",
|
|
21
|
+
description: "Function that echoes the input"
|
|
22
|
+
},
|
|
23
|
+
input: Schema.Any,
|
|
24
|
+
output: Schema.Any
|
|
25
|
+
});
|
|
26
|
+
var Sleep = make({
|
|
27
|
+
meta: {
|
|
28
|
+
key: DXN.make("org.example.function.sleep"),
|
|
29
|
+
name: "Sleep",
|
|
30
|
+
description: "Function that sleeps for a given amount of time"
|
|
31
|
+
},
|
|
32
|
+
input: Schema.Struct({ duration: Schema.optional(Schema.Number).annotations({
|
|
33
|
+
description: "Milliseconds to sleep",
|
|
34
|
+
default: 1e5
|
|
35
|
+
}) }),
|
|
36
|
+
output: Schema.Void
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Reply as n, Sleep as r, Fibonacci as t };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=chunk-definitions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-definitions.mjs","names":[],"sources":["../../src/testing/definitions.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Operation from '../Operation';\n\nexport const Fibonacci = Operation.make({\n meta: {\n key: DXN.make('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});\n\nexport const Reply = Operation.make({\n meta: {\n key: DXN.make('org.example.function.reply'),\n name: 'Reply',\n description: 'Function that echoes the input',\n },\n input: Schema.Any,\n output: Schema.Any,\n});\n\nexport const Sleep = Operation.make({\n meta: {\n key: DXN.make('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});\n"],"mappings":";;;;AAUA,IAAa,YAAY,KAAe;CACtC,MAAM;EACJ,KAAK,IAAI,KAAK,0BAA0B;EACxC,MAAM;EACN,aAAa;CACf;CACA,OAAO,OAAO,OAAO,EACnB,YAAY,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,YAAY;EACrD,aAAa;EACb,SAAS;CACX,CAAC,EACH,CAAC;CACD,QAAQ,OAAO,OAAO,EACpB,QAAQ,OAAO,OACjB,CAAC;AACH,CAAC;AAED,IAAa,QAAQ,KAAe;CAClC,MAAM;EACJ,KAAK,IAAI,KAAK,4BAA4B;EAC1C,MAAM;EACN,aAAa;CACf;CACA,OAAO,OAAO;CACd,QAAQ,OAAO;AACjB,CAAC;AAED,IAAa,QAAQ,KAAe;CAClC,MAAM;EACJ,KAAK,IAAI,KAAK,4BAA4B;EAC1C,MAAM;EACN,aAAa;CACf;CACA,OAAO,OAAO,OAAO,EACnB,UAAU,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,YAAY;EACnD,aAAa;EACb,SAAS;CACX,CAAC,EACH,CAAC;CACD,QAAQ,OAAO;AACjB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|