@dxos/compute 0.9.0 → 0.9.1-staging.ee54ba693a

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 (89) hide show
  1. package/README.md +4 -4
  2. package/dist/lib/neutral/AgentService.mjs +12 -0
  3. package/dist/lib/neutral/StorageService.mjs +3 -3
  4. package/dist/lib/neutral/{chunk-AFBNVFAY.mjs → chunk-2ZN64ZS7.mjs} +3 -3
  5. package/dist/lib/neutral/{chunk-JAU4E4EK.mjs → chunk-5VAXF6AH.mjs} +2 -2
  6. package/dist/lib/neutral/{chunk-QZS4G6PE.mjs → chunk-EVROJER7.mjs} +70 -25
  7. package/dist/lib/neutral/chunk-EVROJER7.mjs.map +7 -0
  8. package/dist/lib/neutral/{chunk-XEVFBI6S.mjs → chunk-PF7XP7XP.mjs} +13 -13
  9. package/dist/lib/neutral/{chunk-XEVFBI6S.mjs.map → chunk-PF7XP7XP.mjs.map} +3 -3
  10. package/dist/lib/neutral/{chunk-MEPE4HHX.mjs → chunk-SJ37RWHU.mjs} +3 -3
  11. package/dist/lib/neutral/chunk-VSAZPWSJ.mjs +25 -0
  12. package/dist/lib/neutral/chunk-VSAZPWSJ.mjs.map +7 -0
  13. package/dist/lib/neutral/{chunk-2B2KSJT6.mjs → chunk-WEO4FCQY.mjs} +3 -3
  14. package/dist/lib/neutral/fib-5XIYECL5.mjs +10 -0
  15. package/dist/lib/neutral/index.mjs +448 -399
  16. package/dist/lib/neutral/index.mjs.map +4 -4
  17. package/dist/lib/neutral/meta.json +1 -1
  18. package/dist/lib/neutral/reply-GCBRCUVM.mjs +10 -0
  19. package/dist/lib/neutral/sleep-XR6CL6W3.mjs +10 -0
  20. package/dist/lib/neutral/sleep-XR6CL6W3.mjs.map +7 -0
  21. package/dist/lib/neutral/testing/index.mjs +6 -6
  22. package/dist/types/src/AgentService.d.ts +71 -0
  23. package/dist/types/src/AgentService.d.ts.map +1 -0
  24. package/dist/types/src/Credential.d.ts +2 -0
  25. package/dist/types/src/Credential.d.ts.map +1 -1
  26. package/dist/types/src/Instructions.d.ts +33 -0
  27. package/dist/types/src/Instructions.d.ts.map +1 -0
  28. package/dist/types/src/McpServer.d.ts +1 -1
  29. package/dist/types/src/Operation.d.ts +92 -27
  30. package/dist/types/src/Operation.d.ts.map +1 -1
  31. package/dist/types/src/Operation.test.d.ts +2 -0
  32. package/dist/types/src/Operation.test.d.ts.map +1 -0
  33. package/dist/types/src/Process.d.ts +55 -21
  34. package/dist/types/src/Process.d.ts.map +1 -1
  35. package/dist/types/src/Runnable.d.ts +4 -0
  36. package/dist/types/src/Runnable.d.ts.map +1 -0
  37. package/dist/types/src/Script.d.ts +9 -11
  38. package/dist/types/src/Script.d.ts.map +1 -1
  39. package/dist/types/src/ServiceResolver.d.ts +1 -1
  40. package/dist/types/src/Skill.d.ts +157 -0
  41. package/dist/types/src/Skill.d.ts.map +1 -0
  42. package/dist/types/src/StorageService.d.ts +8 -8
  43. package/dist/types/src/StorageService.d.ts.map +1 -1
  44. package/dist/types/src/Template.d.ts +2 -4
  45. package/dist/types/src/Template.d.ts.map +1 -1
  46. package/dist/types/src/Trace.d.ts +16 -14
  47. package/dist/types/src/Trace.d.ts.map +1 -1
  48. package/dist/types/src/Trigger.d.ts +26 -61
  49. package/dist/types/src/Trigger.d.ts.map +1 -1
  50. package/dist/types/src/TriggerEvent.d.ts +3 -11
  51. package/dist/types/src/TriggerEvent.d.ts.map +1 -1
  52. package/dist/types/src/index.d.ts +5 -3
  53. package/dist/types/src/index.d.ts.map +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +22 -16
  56. package/src/AgentService.ts +90 -0
  57. package/src/Credential.ts +3 -0
  58. package/src/Instructions.ts +73 -0
  59. package/src/McpServer.ts +1 -1
  60. package/src/Operation.test.ts +39 -0
  61. package/src/Operation.ts +130 -54
  62. package/src/Process.ts +96 -26
  63. package/src/Runnable.ts +12 -0
  64. package/src/Script.ts +14 -14
  65. package/src/ServiceResolver.ts +1 -1
  66. package/src/Skill.ts +218 -0
  67. package/src/StorageService.ts +15 -12
  68. package/src/Template.ts +2 -1
  69. package/src/Trace.ts +13 -11
  70. package/src/Trigger.ts +57 -52
  71. package/src/index.ts +5 -3
  72. package/src/umbrella.test.ts +8 -6
  73. package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +0 -7
  74. package/dist/lib/neutral/fib-HBDUGQW7.mjs +0 -10
  75. package/dist/lib/neutral/reply-RJIAJ6FV.mjs +0 -10
  76. package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +0 -10
  77. package/dist/types/src/Blueprint.d.ts +0 -182
  78. package/dist/types/src/Blueprint.d.ts.map +0 -1
  79. package/dist/types/src/Routine.d.ts +0 -54
  80. package/dist/types/src/Routine.d.ts.map +0 -1
  81. package/src/Blueprint.ts +0 -224
  82. package/src/Routine.ts +0 -68
  83. /package/dist/lib/neutral/{fib-HBDUGQW7.mjs.map → AgentService.mjs.map} +0 -0
  84. /package/dist/lib/neutral/{chunk-AFBNVFAY.mjs.map → chunk-2ZN64ZS7.mjs.map} +0 -0
  85. /package/dist/lib/neutral/{chunk-JAU4E4EK.mjs.map → chunk-5VAXF6AH.mjs.map} +0 -0
  86. /package/dist/lib/neutral/{chunk-MEPE4HHX.mjs.map → chunk-SJ37RWHU.mjs.map} +0 -0
  87. /package/dist/lib/neutral/{chunk-2B2KSJT6.mjs.map → chunk-WEO4FCQY.mjs.map} +0 -0
  88. /package/dist/lib/neutral/{reply-RJIAJ6FV.mjs.map → fib-5XIYECL5.mjs.map} +0 -0
  89. /package/dist/lib/neutral/{sleep-3T2CZ7RE.mjs.map → reply-GCBRCUVM.mjs.map} +0 -0
package/src/Trigger.ts CHANGED
@@ -7,10 +7,12 @@
7
7
  import * as Schema from 'effect/Schema';
8
8
  import * as SchemaAST from 'effect/SchemaAST';
9
9
 
10
- import { DXN, Annotation, Feed, Obj, QueryAST, Ref, Type, type Query } from '@dxos/echo';
10
+ import { Annotation, DXN, Feed, Obj, type Query, QueryAST, Ref, Type } from '@dxos/echo';
11
11
  import { HiddenAnnotation } from '@dxos/echo/Annotation';
12
12
  import { OptionsAnnotationId } from '@dxos/echo/Format';
13
13
 
14
+ import * as Runnable from './Runnable';
15
+
14
16
  /**
15
17
  * Type discriminator for TriggerType.
16
18
  * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
@@ -51,10 +53,13 @@ export const specFeed = (feed: Feed.Feed): FeedSpec => ({
51
53
  */
52
54
  export const SubscriptionSpec = Schema.Struct({
53
55
  kind: Schema.Literal('subscription').annotations(kindLiteralAnnotations),
56
+
57
+ // TODO(burdon): Issue.
54
58
  query: Schema.Struct({
55
59
  raw: Schema.optional(Schema.String.annotations({ title: 'Query' })),
56
60
  ast: QueryAST.Query,
57
61
  }),
62
+
58
63
  options: Schema.optional(
59
64
  Schema.Struct({
60
65
  // Watch changes to object (not just creation).
@@ -139,58 +144,58 @@ export const Spec = Schema.Union(EmailSpec, FeedSpec, SubscriptionSpec, TimerSpe
139
144
  export type Spec = Schema.Schema.Type<typeof Spec>;
140
145
 
141
146
  /**
142
- * Function trigger.
143
- * Function is invoked with the `payload` passed as input data.
144
- * The event that triggers the function is available in the function context.
147
+ * Forms the input data passed to the function.
148
+ * Must match the function's input schema.
149
+ *
150
+ * @example
151
+ * {
152
+ * item: '{{event.item}}',
153
+ * instructions: 'Summarize and perform entity-extraction'
154
+ * mailbox: { '/': 'echo://AAA/ZZZ' }
155
+ * }
145
156
  */
146
- const TriggerSchema = Schema.Struct({
147
- /**
148
- * Function or workflow to invoke.
149
- */
150
- // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
151
- function: Schema.optional(Ref.Ref(Obj.Unknown).annotations({ title: 'Function' })),
152
-
153
- /**
154
- * Only used for workflowSchema.
155
- * Specifies the input node in the circuit.
156
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
157
- */
158
- inputNodeId: Schema.optional(Schema.String.annotations({ title: 'Input Node ID' })),
159
-
160
- // TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
161
- // Need lint rule; or agent rule to require PR review for "boolean" key word.
162
- enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),
163
-
164
- spec: Schema.optional(Spec),
165
-
166
- concurrency: Schema.optional(
167
- Schema.Number.annotations({
168
- title: 'Concurrency',
169
- default: 1,
170
- description:
171
- 'Maximum number of concurrent invocations of the trigger. For Feed triggers, this will process Feed items in parallel.',
172
- }),
173
- ),
157
+ export const InputTemplate = Schema.Record({ key: Schema.String, value: Schema.Any });
174
158
 
175
- /**
176
- * Passed as the input data to the function.
177
- * Must match the function's input schema.
178
- *
179
- * @example
180
- * {
181
- * item: '{{event.item}}',
182
- * instructions: 'Summarize and perform entity-extraction'
183
- * mailbox: { '/': 'echo://AAA/ZZZ' }
184
- * }
185
- */
186
- input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
187
- }).pipe(
188
- Annotation.IconAnnotation.set({ icon: 'ph--lightning--regular', hue: 'yellow' }),
189
- HiddenAnnotation.set(true),
190
- Type.makeObject(DXN.make('org.dxos.type.trigger', '0.1.0')),
191
- );
192
-
193
- export type Trigger = Type.InstanceType<typeof TriggerSchema>;
194
- export const Trigger: Type.Obj<Trigger> = TriggerSchema as any;
159
+ /**
160
+ * Function trigger.
161
+ * Runnable is invoked with the `payload` passed as input data.
162
+ * The event that fires the trigger is available in the runnable context.
163
+ */
164
+ export class Trigger extends Type.makeObject<Trigger>(DXN.make('org.dxos.type.trigger', '0.1.0'))(
165
+ Schema.Struct({
166
+ /**
167
+ * Runnable (operation or workflow) to invoke.
168
+ */
169
+ runnable: Schema.optional(Ref.Ref(Runnable.Runnable).annotations({ title: 'Runnable' })),
170
+ spec: Schema.optional(Spec),
171
+ enabled: Schema.optional(Schema.Boolean),
172
+
173
+ concurrency: Schema.Number.pipe(
174
+ Schema.annotations({
175
+ title: 'Concurrency',
176
+ default: 1,
177
+ description: 'Maximum number of concurrent invocations of the trigger.',
178
+ }),
179
+ Annotation.FormInputAnnotation.set(false),
180
+ Schema.optional,
181
+ ),
182
+
183
+ /**
184
+ * Only used for workflowSchema.
185
+ * Specifies the input node in the circuit.
186
+ * @deprecated Remove and enforce a single input node in all compute graphSchema.
187
+ */
188
+ inputNodeId: Schema.String.pipe(
189
+ Schema.annotations({ title: 'Input Node ID' }),
190
+ Annotation.FormInputAnnotation.set(false),
191
+ Schema.optional,
192
+ ),
193
+
194
+ /**
195
+ * Passed as the input data to the runnable.
196
+ */
197
+ input: InputTemplate.pipe(Annotation.FormInputAnnotation.set(false), Schema.optional),
198
+ }).pipe(Annotation.IconAnnotation.set({ icon: 'ph--lightning--regular', hue: 'yellow' }), HiddenAnnotation.set(true)),
199
+ ) {}
195
200
 
196
201
  export const make = (props: Obj.MakeProps<typeof Trigger>) => Obj.make(Trigger, props);
package/src/index.ts CHANGED
@@ -4,16 +4,18 @@
4
4
 
5
5
  export * from './errors';
6
6
 
7
- export * as Blueprint from './Blueprint';
7
+ export * as AgentService from './AgentService';
8
+ export * as Skill from './Skill';
8
9
  export * as Credential from './Credential';
9
10
  export * as Header from './Header';
10
- export * as McpServer from './McpServer';
11
+ export * as Instructions from './Instructions';
11
12
  export * as LayerSpec from './LayerSpec';
13
+ export * as McpServer from './McpServer';
12
14
  export * as Operation from './Operation';
13
15
  export * as OperationHandlerSet from './OperationHandlerSet';
14
16
  export * as OperationRegistry from './OperationRegistry';
15
17
  export * as Process from './Process';
16
- export * as Routine from './Routine';
18
+ export * as Runnable from './Runnable';
17
19
  export * as Script from './Script';
18
20
  export * as ServiceResolver from './ServiceResolver';
19
21
  export * as StorageService from './StorageService';
@@ -5,16 +5,17 @@
5
5
  import { describe, test } from 'vitest';
6
6
 
7
7
  import {
8
- Blueprint,
9
8
  Credential,
10
9
  FunctionNotFoundError,
10
+ Instructions,
11
11
  Operation,
12
12
  OperationHandlerSet,
13
13
  OperationRegistry,
14
14
  Process,
15
- Routine,
15
+ Runnable,
16
16
  Script,
17
17
  ServiceResolver,
18
+ Skill,
18
19
  StorageService,
19
20
  Template,
20
21
  Trace,
@@ -29,14 +30,15 @@ describe('umbrella re-exports', () => {
29
30
  expect(OperationHandlerSet).toBeDefined();
30
31
  expect(OperationRegistry).toBeDefined();
31
32
 
32
- // Blueprint primitives.
33
- expect(Blueprint).toBeDefined();
34
- expect(Blueprint.make).toBeTypeOf('function');
35
- expect(Routine).toBeDefined();
33
+ // Skill primitives.
34
+ expect(Skill).toBeDefined();
35
+ expect(Skill.make).toBeTypeOf('function');
36
+ expect(Instructions).toBeDefined();
36
37
  expect(Template).toBeDefined();
37
38
 
38
39
  // Function primitives.
39
40
  expect(Process).toBeDefined();
41
+ expect(Runnable).toBeDefined();
40
42
  expect(Trigger).toBeDefined();
41
43
  expect(TriggerEvent).toBeDefined();
42
44
  expect(Script).toBeDefined();
@@ -1,7 +0,0 @@
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 Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema$ from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\nimport { DXN, Annotation, JsonSchema, Migration, Obj, Ref, Type, type Key } from '@dxos/echo';\nimport type { URI } from '@dxos/keys';\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: 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 */\nexport const PersistentOperation = 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 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\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 // 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.makeObject(DXN.make('org.dxos.type.function', '0.2.0')),\n);\nexport type PersistentOperation = Type.InstanceType<typeof PersistentOperation>;\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 type Label = string | [string, { ns: string | readonly string[]; count?: number; defaultValue?: string }];\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 interface NotifyOptions {\n /** Shown when the invocation starts. */\n start?: Label;\n /** Shown when the invocation succeeds. */\n success?: Label;\n /** Shown when the invocation fails. */\n error?: Label;\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 AiContext.Service 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/**\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 * 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 * 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 const PersistentOperation_v0_1_0 = 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}).pipe(Type.makeObject(DXN.make('org.dxos.type.function', '0.1.0')));\nexport type PersistentOperation_v0_1_0 = Type.InstanceType<typeof PersistentOperation_v0_1_0>;\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"],
5
- "mappings": ";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAC1B,YAAYC,aAAa;AAGzB,SAASC,KAAKC,YAAYC,YAAYC,WAAWC,KAAKC,KAAKC,YAAsB;AAY1E,IAAMC,mBAAmB;AAkHzB,IAAMC,wBAAwB,CAACC,UAAAA;AACpC,SAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQF,oBAAoBE;AAC5E;AAKO,IAAMC,yBAAyB,CAACD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gB,iBAAiBO,cAAcN,cAAM,CAAA;EACvDO,SAAiBR,iBAAiBC,cAAM;AAC1C,CAAA,EAAGhB,KAAKV,KAAKwC,WAAW9C,IAAIW,KAAK,0BAA0B,OAAA,CAAA,CAAA;AAO3D,IAAM4F,aAAapG,UAAUqG,OAAO;EAClCC,MAAMH;EACNI,IAAIhF;EACJiF,WAAW,OAAOF,UAAU;IAC1B,CAACrG,IAAIoD,IAAI,GAAG;MAAEL,KAAKsD,KAAKtD;MAAKE,SAASoD,KAAKpD;IAAQ;IACnDzB,MAAM6E,KAAK7E;IACXE,aAAa2E,KAAK3E;IAClBG,SAASwE,KAAKxE;IACdC,QAAQuE,KAAKvE;IACbE,aAAaqE,KAAKrE;IAClBC,cAAcoE,KAAKpE;IACnBtB,UAAU0F,KAAK1F;IACfwB,SAASkE,KAAKlE;EAChB;AACF,CAAA;AAMO,IAAMqE,aAAa;EAACL;;",
6
- "names": ["Context", "Effect", "Layer", "Option", "Pipeable", "Schema$", "DXN", "Annotation", "JsonSchema", "Migration", "Obj", "Ref", "Type", "DefinitionTypeId", "isOperationDefinition", "value", "isOperationWithHandler", "make", "props", "executionMode", "types", "services", "pipe", "pipeArguments", "arguments", "withHandler", "opOrHandler", "handler", "undefined", "handlerFn", "op", "opaqueHandler", "PersistentOperation", "Struct", "name", "NonEmptyString", "description", "optional", "String", "updated", "source", "Unknown", "inputSchema", "outputSchema", "Array", "binding", "icon", "LabelAnnotation", "set", "IconAnnotation", "hue", "HiddenAnnotation", "makeObject", "FUNCTION_META_KEY", "getKey", "record", "getMeta", "key", "getVersion", "version", "serialize", "operation", "Meta", "meta", "keys", "deployedId", "id", "annotations", "toJsonSchema", "input", "output", "map", "service", "deserialize", "find", "toEffectSchema", "GenericTag", "tryMake", "setFrom", "target", "update", "JSON", "parse", "stringify", "sourceMeta", "targetMeta", "length", "IdempotentAnnotation", "schema", "Boolean", "isIdempotent", "getOrElse", "getDictionary", "Service", "Tag", "invoke", "args", "flatMap", "ops", "withSpan", "schedule", "withInvocationOptions", "options", "effect", "gen", "of", "invocationOptions", "invokePromise", "PersistentOperation_v0_1_0", "_migration", "define", "from", "to", "transform", "migrations"]
7
- }
@@ -1,10 +0,0 @@
1
- import {
2
- fib_default
3
- } from "./chunk-AFBNVFAY.mjs";
4
- import "./chunk-JAU4E4EK.mjs";
5
- import "./chunk-QZS4G6PE.mjs";
6
- import "./chunk-J5LGTIGS.mjs";
7
- export {
8
- fib_default as default
9
- };
10
- //# sourceMappingURL=fib-HBDUGQW7.mjs.map
@@ -1,10 +0,0 @@
1
- import {
2
- reply_default
3
- } from "./chunk-MEPE4HHX.mjs";
4
- import "./chunk-JAU4E4EK.mjs";
5
- import "./chunk-QZS4G6PE.mjs";
6
- import "./chunk-J5LGTIGS.mjs";
7
- export {
8
- reply_default as default
9
- };
10
- //# sourceMappingURL=reply-RJIAJ6FV.mjs.map
@@ -1,10 +0,0 @@
1
- import {
2
- sleep_default
3
- } from "./chunk-2B2KSJT6.mjs";
4
- import "./chunk-JAU4E4EK.mjs";
5
- import "./chunk-QZS4G6PE.mjs";
6
- import "./chunk-J5LGTIGS.mjs";
7
- export {
8
- sleep_default as default
9
- };
10
- //# sourceMappingURL=sleep-3T2CZ7RE.mjs.map
@@ -1,182 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import * as Schema from 'effect/Schema';
3
- import { Database, Migration, Obj, Registry, Type, URI } from '@dxos/echo';
4
- import { BaseError } from '@dxos/errors';
5
- import * as Operation from './Operation';
6
- /**
7
- * Blueprint schema defines the structure for AI assistant blueprints.
8
- * Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.
9
- * Blueprints may use tools to create and read artifacts, which are managed by the assistant.
10
- *
11
- * The registry `key` and `version` are stored in the object meta — access them via
12
- * `Obj.getMeta(blueprint).key` and `Obj.getMeta(blueprint).version`.
13
- */
14
- export declare const Blueprint: Type.Obj<{
15
- readonly name: string;
16
- readonly description?: string | undefined;
17
- readonly instructions: {
18
- readonly source: import("@dxos/echo/internal").Ref<{
19
- readonly name?: string | undefined;
20
- readonly content: string;
21
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
22
- readonly inputs?: readonly {
23
- readonly name: string;
24
- readonly kind: "operation" | "value";
25
- readonly default?: any;
26
- readonly operation?: string | undefined;
27
- }[] | undefined;
28
- };
29
- readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
30
- readonly agentCanEnable?: boolean | undefined;
31
- readonly mcpServers?: readonly {
32
- readonly name?: string | undefined;
33
- readonly url: string;
34
- readonly protocol: "http" | "sse";
35
- readonly apiKey?: string | undefined;
36
- }[] | undefined;
37
- }, Schema.Struct.Fields>;
38
- /**
39
- * TypeScript type for Blueprint.
40
- */
41
- export type Blueprint = Type.InstanceType<typeof Blueprint>;
42
- type MakeProps = {
43
- key: string;
44
- version?: string;
45
- name: string;
46
- } & Partial<Blueprint>;
47
- /**
48
- * Create a new Blueprint.
49
- * The `key` (and optional `version`) are stored in the object meta.
50
- */
51
- export declare const make: ({ key, version, tools, instructions, ...props }: MakeProps) => Obj.OfShape<{
52
- readonly name: string;
53
- readonly description?: string | undefined;
54
- readonly instructions: {
55
- readonly source: import("@dxos/echo/internal").Ref<{
56
- readonly name?: string | undefined;
57
- readonly content: string;
58
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
59
- readonly inputs?: readonly {
60
- readonly name: string;
61
- readonly kind: "operation" | "value";
62
- readonly default?: any;
63
- readonly operation?: string | undefined;
64
- }[] | undefined;
65
- };
66
- readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
67
- readonly agentCanEnable?: boolean | undefined;
68
- readonly mcpServers?: readonly {
69
- readonly name?: string | undefined;
70
- readonly url: string;
71
- readonly protocol: "http" | "sse";
72
- readonly apiKey?: string | undefined;
73
- }[] | undefined;
74
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>>;
75
- /**
76
- * Get the registry key for a blueprint.
77
- */
78
- export declare const getKey: (blueprint: Blueprint) => string;
79
- /**
80
- * Get the registry version for a blueprint, if any.
81
- */
82
- export declare const getVersion: (blueprint: Blueprint) => string | undefined;
83
- /**
84
- * Util to create tool definitions for a blueprint.
85
- */
86
- export declare const toolDefinitions: ({ tools, operations, }: {
87
- tools?: string[];
88
- operations?: Operation.Definition.Any[];
89
- }) => (string & import("effect/Brand").Brand<"ToolId">)[];
90
- /**
91
- * Factory for the blueprints.
92
- */
93
- export type Definition = {
94
- key: string;
95
- make: () => Blueprint;
96
- };
97
- /**
98
- * Returns the canonical URI used to reference this blueprint in the registry.
99
- * Valid DXN keys produce `dxn:<key>`; other keys use the raw key as a URI.
100
- * Use this URI with `Ref.fromURI` to bind a blueprint without cloning it to the DB.
101
- *
102
- * TODO(wittjosiah): Should use Obj.getURI instead once it supports options to prefer meta key over EID.
103
- */
104
- export declare const registryURI: (key: string) => URI.URI;
105
- /**
106
- * Resolves a blueprint from the registry by its meta key.
107
- * Does not check the local database for the blueprint.
108
- */
109
- export declare const resolve: (key: string) => Effect.Effect<Blueprint, NotFoundError, Registry.Service>;
110
- /**
111
- * Upserts a blueprint into the database.
112
- * If the blueprint already exists in the database, the local (possibly forked) copy is returned as-is.
113
- * Otherwise, a fresh copy is cloned from the registry and added.
114
- * @deprecated Since we're using a registry we no longer need to store blueprints in the database.
115
- */
116
- export declare const upsert: (key: string) => Effect.Effect<Blueprint, NotFoundError, Registry.Service | Database.Service>;
117
- declare const NotFoundError_base: {
118
- new (options?: import("@dxos/errors").BaseErrorOptions): {
119
- cause?: unknown;
120
- stack?: string;
121
- name: "BlueprintNotFound";
122
- context: Record<string, unknown>;
123
- readonly message: string;
124
- readonly _tag: "BlueprintNotFound";
125
- };
126
- isError(error: unknown): error is Error;
127
- name: "BlueprintNotFound";
128
- is(error: unknown): error is BaseError;
129
- wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
130
- ifTypeDiffers?: boolean;
131
- }): (error: unknown) => {
132
- cause?: unknown;
133
- stack?: string;
134
- name: "BlueprintNotFound";
135
- context: Record<string, unknown>;
136
- readonly message: string;
137
- readonly _tag: "BlueprintNotFound";
138
- };
139
- extend<Name extends string = string>(name: Name, message?: string): any;
140
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
141
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
142
- stackTraceLimit: number;
143
- };
144
- export declare class NotFoundError extends NotFoundError_base {
145
- }
146
- /**
147
- * Blueprint schema v0.1.0 — `key` is stored as a data property.
148
- * @deprecated Use {@link Blueprint} (v0.2.0) instead; the `key` and `version` now live in the object meta.
149
- */
150
- export declare const Blueprint_v0_1_0: Type.Obj<{
151
- readonly key: string;
152
- readonly name: string;
153
- readonly description?: string | undefined;
154
- readonly instructions: {
155
- readonly source: import("@dxos/echo/internal").Ref<{
156
- readonly name?: string | undefined;
157
- readonly content: string;
158
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
159
- readonly inputs?: readonly {
160
- readonly name: string;
161
- readonly kind: "operation" | "value";
162
- readonly default?: any;
163
- readonly operation?: string | undefined;
164
- }[] | undefined;
165
- };
166
- readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
167
- readonly agentCanEnable?: boolean | undefined;
168
- readonly mcpServers?: readonly {
169
- readonly name?: string | undefined;
170
- readonly url: string;
171
- readonly protocol: "http" | "sse";
172
- readonly apiKey?: string | undefined;
173
- }[] | undefined;
174
- }, Schema.Struct.Fields>;
175
- export type Blueprint_v0_1_0 = Type.InstanceType<typeof Blueprint_v0_1_0>;
176
- /**
177
- * Schema migrations exported by this module.
178
- * Exported as an array for extensibility — append future versions here.
179
- */
180
- export declare const migrations: Migration.ObjectMigration[];
181
- export {};
182
- //# sourceMappingURL=Blueprint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Blueprint.d.ts","sourceRoot":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MAAM,WAAW,QAAS,MAAM,KAAG,GAAG,CAAC,GAA8D,CAAC;AAE7G;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,CAAC,OAAO,CAQ1F,CAAC;AAEL;;;;;GAKG;AAEH,eAAO,MAAM,MAAM,QAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAO5G,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,aAAc,SAAQ,kBAA4D;CAAG;AAMlG;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;wBAsByC,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAmB1E;;;GAGG;AACH,eAAO,MAAM,UAAU,6BAAe,CAAC"}
@@ -1,54 +0,0 @@
1
- import * as Schema from 'effect/Schema';
2
- import { Obj, Ref, Type } from '@dxos/echo';
3
- import * as Blueprint from './Blueprint';
4
- /**
5
- * Prompt-based operation.
6
- * May reference blueprints and additional context.
7
- */
8
- export declare const Routine: Type.Obj<{
9
- readonly name?: string | undefined;
10
- readonly description?: string | undefined;
11
- readonly input: import("@dxos/echo/internal").JsonSchemaType;
12
- readonly output: import("@dxos/echo/internal").JsonSchemaType;
13
- readonly instructions: import("@dxos/echo/internal").Ref<{
14
- readonly name?: string | undefined;
15
- readonly content: string;
16
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
17
- readonly blueprints: readonly import("@dxos/echo/internal").Ref<{
18
- readonly name: string;
19
- readonly description?: string | undefined;
20
- readonly instructions: {
21
- readonly source: import("@dxos/echo/internal").Ref<{
22
- readonly name?: string | undefined;
23
- readonly content: string;
24
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
25
- readonly inputs?: readonly {
26
- readonly name: string;
27
- readonly kind: "operation" | "value";
28
- readonly default?: any;
29
- readonly operation?: string | undefined;
30
- }[] | undefined;
31
- };
32
- readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
33
- readonly agentCanEnable?: boolean | undefined;
34
- readonly mcpServers?: readonly {
35
- readonly name?: string | undefined;
36
- readonly url: string;
37
- readonly protocol: "http" | "sse";
38
- readonly apiKey?: string | undefined;
39
- }[] | undefined;
40
- } & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[];
41
- readonly context: readonly any[];
42
- }, Schema.Struct.Fields>;
43
- export type Routine = Type.InstanceType<typeof Routine>;
44
- export type MakeProps = {
45
- name?: string;
46
- description?: string;
47
- input?: Schema.Schema.AnyNoContext;
48
- output?: Schema.Schema.AnyNoContext;
49
- instructions?: string;
50
- blueprints?: Ref.Ref<Blueprint.Blueprint>[];
51
- context?: any[];
52
- };
53
- export declare const make: ({ name, description, input, output, instructions, blueprints, context, }: MakeProps) => Routine;
54
- //# sourceMappingURL=Routine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Routine.d.ts","sourceRoot":"","sources":["../../../src/Routine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAA+B,GAAG,EAAE,GAAG,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAGjF,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmBnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,IAAI,6EAQd,SAAS,KAAG,OASX,CAAC"}