@dxos/blueprints 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b

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 (33) hide show
  1. package/dist/lib/browser/index.mjs +120 -54
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +120 -54
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/blueprint/blueprint.d.ts +38 -12
  8. package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
  9. package/dist/types/src/blueprint/registry.d.ts +1 -1
  10. package/dist/types/src/blueprint/registry.d.ts.map +1 -1
  11. package/dist/types/src/index.d.ts +1 -1
  12. package/dist/types/src/index.d.ts.map +1 -1
  13. package/dist/types/src/prompt/index.d.ts +2 -0
  14. package/dist/types/src/prompt/index.d.ts.map +1 -0
  15. package/dist/types/src/prompt/prompt.d.ts +79 -0
  16. package/dist/types/src/prompt/prompt.d.ts.map +1 -0
  17. package/dist/types/src/template/prompt.d.ts +1 -1
  18. package/dist/types/src/template/prompt.d.ts.map +1 -1
  19. package/dist/types/src/template/template.d.ts +9 -21
  20. package/dist/types/src/template/template.d.ts.map +1 -1
  21. package/dist/types/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +12 -14
  23. package/src/blueprint/blueprint.ts +26 -8
  24. package/src/blueprint/registry.ts +15 -1
  25. package/src/index.ts +1 -1
  26. package/src/prompt/index.ts +5 -0
  27. package/src/prompt/prompt.ts +81 -0
  28. package/src/template/prompt.test.ts +2 -2
  29. package/src/template/prompt.ts +5 -5
  30. package/src/template/template.ts +14 -22
  31. package/dist/types/src/artifacts.d.ts +0 -40
  32. package/dist/types/src/artifacts.d.ts.map +0 -1
  33. package/src/artifacts.ts +0 -60
@@ -4,21 +4,19 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // src/artifacts.ts
8
- var defineArtifact = (definition) => definition;
9
-
10
7
  // src/blueprint/index.ts
11
8
  var blueprint_exports = {};
12
9
  __export(blueprint_exports, {
13
10
  Blueprint: () => Blueprint,
14
- Registry: () => Registry
11
+ Registry: () => Registry,
12
+ make: () => make2,
13
+ toolDefinitions: () => toolDefinitions
15
14
  });
16
15
 
17
16
  // src/blueprint/blueprint.ts
18
- import { Schema as Schema2 } from "effect";
17
+ import * as Schema2 from "effect/Schema";
19
18
  import { ToolId } from "@dxos/ai";
20
- import { Type as Type2 } from "@dxos/echo";
21
- import { LabelAnnotation as LabelAnnotation2 } from "@dxos/echo-schema";
19
+ import { Annotation, Obj, Type as Type2 } from "@dxos/echo";
22
20
 
23
21
  // src/template/index.ts
24
22
  var template_exports = {};
@@ -26,38 +24,35 @@ __export(template_exports, {
26
24
  Input: () => Input,
27
25
  InputKind: () => InputKind,
28
26
  Template: () => Template,
29
- createPrompt: () => createPrompt,
30
- make: () => make
27
+ make: () => make,
28
+ process: () => process
31
29
  });
32
30
 
33
31
  // src/template/prompt.ts
34
32
  import handlebars from "handlebars";
35
- import defaultsDeep from "lodash.defaultsdeep";
36
33
  import { invariant } from "@dxos/invariant";
37
34
  var __dxlog_file = "/__w/dxos/dxos/packages/core/blueprints/src/template/prompt.ts";
38
- var createPrompt = (source, options = {}) => {
39
- invariant(source, void 0, {
35
+ var process = (source, variables = {}) => {
36
+ invariant(typeof source === "string", void 0, {
40
37
  F: __dxlog_file,
41
- L: 14,
38
+ L: 13,
42
39
  S: void 0,
43
40
  A: [
44
- "source",
41
+ "typeof source === 'string'",
45
42
  ""
46
43
  ]
47
44
  });
48
45
  let section = 0;
49
46
  handlebars.registerHelper("section", () => String(++section));
50
- const template = handlebars.compile(source);
51
- return template(defaultsDeep({}, options, {
52
- suggestions: true
53
- })).trim();
47
+ const template = handlebars.compile(source.trim());
48
+ const output = template(variables);
49
+ return output.trim().replace(/(\n\s*){3,}/g, "\n\n");
54
50
  };
55
51
 
56
52
  // src/template/template.ts
57
- import { Schema } from "effect";
58
- import { Obj, Ref, Type } from "@dxos/echo";
59
- import { LabelAnnotation } from "@dxos/echo-schema";
60
- import { DataType } from "@dxos/schema";
53
+ import * as Schema from "effect/Schema";
54
+ import { Ref, Type } from "@dxos/echo";
55
+ import { Text } from "@dxos/schema";
61
56
  var InputKind = Schema.Literal("value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema");
62
57
  var Input = Schema.mutable(Schema.Struct({
63
58
  name: Schema.String,
@@ -65,25 +60,15 @@ var Input = Schema.mutable(Schema.Struct({
65
60
  default: Schema.optional(Schema.Any)
66
61
  }));
67
62
  var Template = Schema.Struct({
68
- name: Schema.optional(Schema.String),
69
- source: Type.Ref(DataType.Text).annotations({
63
+ source: Type.Ref(Text.Text).annotations({
70
64
  description: "Handlebars template source"
71
65
  }),
72
66
  inputs: Schema.optional(Schema.mutable(Schema.Array(Input)))
73
- }).pipe(Type.Obj({
74
- typename: "dxos.org/type/Template",
75
- version: "0.1.0"
76
- }), LabelAnnotation.set([
77
- "name"
78
- ]));
79
- var make = ({ source = "", ...props }) => {
80
- return Obj.make(Template, {
81
- source: Ref.make(Obj.make(DataType.Text, {
82
- content: source
83
- })),
84
- ...props
85
- });
86
- };
67
+ }).pipe(Schema.mutable);
68
+ var make = ({ source, inputs = [], id } = {}) => ({
69
+ source: Ref.make(Text.make(source, id)),
70
+ inputs
71
+ });
87
72
 
88
73
  // src/blueprint/blueprint.ts
89
74
  var Blueprint = Schema2.Struct({
@@ -111,7 +96,7 @@ var Blueprint = Schema2.Struct({
111
96
  * Instructions that guide the AI assistant's behavior and responses.
112
97
  * These are system prompts or guidelines that the AI should follow.
113
98
  */
114
- instructions: Type2.Ref(Template).annotations({
99
+ instructions: Template.annotations({
115
100
  description: "Instructions that guide the AI assistant's behavior and responses"
116
101
  }),
117
102
  /**
@@ -120,22 +105,45 @@ var Blueprint = Schema2.Struct({
120
105
  tools: Schema2.Array(ToolId).annotations({
121
106
  description: "Array of tools that the AI assistant can use when this blueprint is active"
122
107
  })
123
- }).pipe(
124
- Type2.Obj({
125
- // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
126
- typename: "dxos.org/type/Blueprint",
127
- version: "0.1.0"
128
- }),
129
- // TODO(burdon): Move to Type.Obj def?
130
- LabelAnnotation2.set([
131
- "name"
132
- ])
133
- );
108
+ }).pipe(Type2.Obj({
109
+ // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
110
+ typename: "dxos.org/type/Blueprint",
111
+ version: "0.1.0"
112
+ }), Annotation.LabelAnnotation.set([
113
+ "name"
114
+ ]));
115
+ var make2 = ({ tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
116
+ tools,
117
+ instructions,
118
+ ...props
119
+ });
120
+ var toolDefinitions = ({ tools = [], functions = [] }) => [
121
+ ...functions.map((fn) => ToolId.make(fn.key)),
122
+ ...tools.map((tool) => ToolId.make(tool))
123
+ ];
134
124
 
135
125
  // src/blueprint/registry.ts
126
+ import { log } from "@dxos/log";
127
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/blueprints/src/blueprint/registry.ts";
136
128
  var Registry = class {
137
- constructor(_blueprints) {
138
- this._blueprints = _blueprints;
129
+ _blueprints = [];
130
+ constructor(blueprints) {
131
+ const seen = /* @__PURE__ */ new Set();
132
+ blueprints.forEach((blueprint) => {
133
+ if (seen.has(blueprint.key)) {
134
+ log.warn("duplicate blueprint", {
135
+ key: blueprint.key
136
+ }, {
137
+ F: __dxlog_file2,
138
+ L: 19,
139
+ S: this,
140
+ C: (f, a) => f(...a)
141
+ });
142
+ } else {
143
+ seen.add(blueprint.key);
144
+ this._blueprints.push(blueprint);
145
+ }
146
+ });
139
147
  this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
140
148
  }
141
149
  getByKey(key) {
@@ -145,9 +153,67 @@ var Registry = class {
145
153
  return this._blueprints;
146
154
  }
147
155
  };
156
+
157
+ // src/prompt/index.ts
158
+ var prompt_exports = {};
159
+ __export(prompt_exports, {
160
+ Prompt: () => Prompt,
161
+ make: () => make3
162
+ });
163
+
164
+ // src/prompt/prompt.ts
165
+ import * as Schema3 from "effect/Schema";
166
+ import { Annotation as Annotation2, JsonSchema, Obj as Obj2, Type as Type3 } from "@dxos/echo";
167
+ var Prompt$ = Schema3.Struct({
168
+ /**
169
+ * Name of the prompt.
170
+ */
171
+ name: Schema3.optional(Schema3.String),
172
+ /**
173
+ * Description of the prompt's purpose and functionality.
174
+ * Allows AI agents to execute prompts automatically as tools.
175
+ */
176
+ description: Schema3.optional(Schema3.String),
177
+ /**
178
+ * Input schema of the prompt.
179
+ */
180
+ input: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
181
+ /**
182
+ * Output schema of the prompt.
183
+ */
184
+ output: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
185
+ /**
186
+ * Natural language instructions for the prompt.
187
+ * These should provide concrete course of action for the AI to follow.
188
+ */
189
+ instructions: Template.pipe(Annotation2.FormInputAnnotation.set(false)),
190
+ /**
191
+ * Blueprints that the prompt may utilize.
192
+ */
193
+ blueprints: Schema3.Array(Type3.Ref(Blueprint)),
194
+ /**
195
+ * Additional context that the prompt may utilize.
196
+ */
197
+ context: Schema3.Array(Schema3.Any).pipe(Annotation2.FormInputAnnotation.set(false))
198
+ }).pipe(Type3.Obj({
199
+ typename: "dxos.org/type/Prompt",
200
+ version: "0.1.0"
201
+ }));
202
+ var Prompt = Prompt$;
203
+ var make3 = (params) => Obj2.make(Prompt, {
204
+ name: params.name,
205
+ description: params.description,
206
+ input: JsonSchema.toJsonSchema(params.input ?? Schema3.Void),
207
+ output: JsonSchema.toJsonSchema(params.output ?? Schema3.Void),
208
+ instructions: make({
209
+ source: params.instructions
210
+ }),
211
+ blueprints: params.blueprints ?? [],
212
+ context: params.context ?? []
213
+ });
148
214
  export {
149
215
  blueprint_exports as Blueprint,
150
- template_exports as Template,
151
- defineArtifact
216
+ prompt_exports as Prompt,
217
+ template_exports as Template
152
218
  };
153
219
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/artifacts.ts", "../../../src/blueprint/index.ts", "../../../src/blueprint/blueprint.ts", "../../../src/template/index.ts", "../../../src/template/prompt.ts", "../../../src/template/template.ts", "../../../src/blueprint/registry.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type ExecutableTool } from '@dxos/ai';\nimport { type SpaceId } from '@dxos/keys';\n\n/**\n * @deprecated\n */\n// TODO(burdon): Replace with Ref.\nexport type AssociatedArtifact = {\n spaceId: SpaceId;\n typename: string;\n id: string;\n};\n\n/**\n * Static artifact definition.\n * @deprecated\n */\n// TODO(burdon): Convert to effect schema.\nexport type ArtifactDefinition = {\n // TODO(wittjosiah): Is this actually an ObjectId or should it be a uri?\n // TODO(burdon): Plugin id?\n id: string;\n\n /**\n * Name.\n */\n name: string;\n\n /**\n * Description.\n */\n description?: string;\n\n /**\n * Instructions for how to use the artifact.\n */\n // TODO(burdon): Reference template object.\n instructions: string;\n\n /**\n * Schema that describes the shape of data which matches the artifact.\n */\n schema: Schema.Schema.AnyNoContext;\n\n /**\n * Tools that can be used to act on data which matches the artifact.\n */\n tools: ExecutableTool[];\n\n // TODO(wittjosiah): Add `component` field for rendering data which matches the artifact?\n // NOTE(burdon): I think that could just be provided separately by the plugin (since there might be multiple surface types).\n};\n\nexport const defineArtifact = (definition: ArtifactDefinition): ArtifactDefinition => definition;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * from './blueprint';\nexport * from './registry';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { ToolId } from '@dxos/ai';\nimport { Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\n\nimport { Template } from '../template';\n\n/**\n * Blueprint schema defines the structure for AI assistant blueprints.\n * Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.\n * Blueprints may use tools to create and read artifacts, which are managed by the assistant.\n */\nexport const Blueprint = Schema.Struct({\n /**\n * Global registry ID.\n * NOTE: The `key` property refers to the original registry entry.\n */\n // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.\n key: Schema.String.annotations({\n description: 'Unique registration key for the blueprint',\n }),\n\n /**\n * Human-readable name of the blueprint.\n */\n name: Schema.String.annotations({\n description: 'Human-readable name of the blueprint',\n }),\n\n /**\n * Description of the blueprint's purpose and functionality.\n */\n description: Schema.optional(Schema.String).annotations({\n description: \"Description of the blueprint's purpose and functionality\",\n }),\n\n /**\n * Instructions that guide the AI assistant's behavior and responses.\n * These are system prompts or guidelines that the AI should follow.\n */\n instructions: Type.Ref(Template).annotations({\n description: \"Instructions that guide the AI assistant's behavior and responses\",\n }),\n\n /**\n * Array of tools that the AI assistant can use when this blueprint is active.\n */\n tools: Schema.Array(ToolId).annotations({\n description: 'Array of tools that the AI assistant can use when this blueprint is active',\n }),\n}).pipe(\n Type.Obj({\n // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.\n typename: 'dxos.org/type/Blueprint',\n version: '0.1.0',\n }),\n\n // TODO(burdon): Move to Type.Obj def?\n LabelAnnotation.set(['name']),\n);\n\n/**\n * TypeScript type for Blueprint.\n */\nexport interface Blueprint extends Schema.Schema.Type<typeof Blueprint> {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * from './prompt';\nexport * from './template';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport handlebars from 'handlebars';\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { invariant } from '@dxos/invariant';\n\n/**\n * Process Handlebars template.\n */\nexport const createPrompt = <Options extends {}>(source: string, options: Options = {} as Options): string => {\n invariant(source);\n let section = 0;\n handlebars.registerHelper('section', () => String(++section));\n const template = handlebars.compile(source);\n return template(defaultsDeep({}, options, { suggestions: true })).trim();\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Template input kind determines how template variables are resolved.\n */\nexport const InputKind = Schema.Literal(\n 'value', // Literal value.\n 'pass-through',\n 'retriever',\n 'function',\n 'query',\n 'resolver',\n 'context',\n 'schema',\n);\n\nexport type InputKind = Schema.Schema.Type<typeof InputKind>;\n\n/**\n * Template input variable.\n * E.g., {{foo}}\n */\nexport const Input = Schema.mutable(\n Schema.Struct({\n name: Schema.String,\n kind: Schema.optional(InputKind),\n default: Schema.optional(Schema.Any),\n }),\n);\n\nexport type Input = Schema.Schema.Type<typeof Input>;\n\n/**\n * Template type.\n */\nexport const Template = Schema.Struct({\n name: Schema.optional(Schema.String),\n source: Type.Ref(DataType.Text).annotations({ description: 'Handlebars template source' }),\n inputs: Schema.optional(Schema.mutable(Schema.Array(Input))),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Template',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport interface Template extends Schema.Schema.Type<typeof Template> {}\n\n/**\n * Creates a template.\n */\nexport const make = ({ source = '', ...props }: Partial<Omit<Template, 'source'> & { source: string }>) => {\n return Obj.make(Template, {\n source: Ref.make(Obj.make(DataType.Text, { content: source })),\n ...props,\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Blueprint } from './blueprint';\n\n/**\n * Blueprint registry.\n */\nexport class Registry {\n constructor(private readonly _blueprints: Blueprint[]) {\n this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));\n }\n\n getByKey(key: string): Blueprint | undefined {\n return this._blueprints.find((blueprint) => blueprint.key === key);\n }\n\n query(): Blueprint[] {\n return this._blueprints;\n }\n}\n"],
5
- "mappings": ";;;;;;;AA2DO,IAAMA,iBAAiB,CAACC,eAAuDA;;;AC3DtF;;;;;;;ACIA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,MAAAA,MAA+D;AACpG,SAAON,IAAIK,KAAKhB,UAAU;IACxBC,QAAQE,IAAIa,KAAKL,IAAIK,KAAKZ,SAASC,MAAM;MAAEa,SAASjB;IAAO,CAAA,CAAA;IAC3D,GAAGgB;EACL,CAAA;AACF;;;AHhDO,IAAME,YAAYC,QAAOC,OAAO;;;;;;EAMrCC,KAAKF,QAAOG,OAAOC,YAAY;IAC7BC,aAAa;EACf,CAAA;;;;EAKAC,MAAMN,QAAOG,OAAOC,YAAY;IAC9BC,aAAa;EACf,CAAA;;;;EAKAA,aAAaL,QAAOO,SAASP,QAAOG,MAAM,EAAEC,YAAY;IACtDC,aAAa;EACf,CAAA;;;;;EAMAG,cAAcC,MAAKC,IAAIC,QAAAA,EAAUP,YAAY;IAC3CC,aAAa;EACf,CAAA;;;;EAKAO,OAAOZ,QAAOa,MAAMC,MAAAA,EAAQV,YAAY;IACtCC,aAAa;EACf,CAAA;AACF,CAAA,EAAGU;EACDN,MAAKO,IAAI;;IAEPC,UAAU;IACVC,SAAS;EACX,CAAA;;EAGAC,iBAAgBC,IAAI;IAAC;GAAO;AAAA;;;AItDvB,IAAMC,WAAN,MAAMA;EACX,YAA6BC,aAA0B;SAA1BA,cAAAA;AAC3B,SAAKA,YAAYC,KAAK,CAAC,EAAEC,MAAMC,EAAC,GAAI,EAAED,MAAME,EAAC,MAAOD,EAAEE,cAAcD,CAAAA,CAAAA;EACtE;EAEAE,SAASC,KAAoC;AAC3C,WAAO,KAAKP,YAAYQ,KAAK,CAACC,cAAcA,UAAUF,QAAQA,GAAAA;EAChE;EAEAG,QAAqB;AACnB,WAAO,KAAKV;EACd;AACF;",
6
- "names": ["defineArtifact", "definition", "Schema", "ToolId", "Type", "LabelAnnotation", "handlebars", "defaultsDeep", "invariant", "createPrompt", "source", "options", "section", "registerHelper", "String", "template", "compile", "suggestions", "trim", "Schema", "Obj", "Ref", "Type", "LabelAnnotation", "DataType", "InputKind", "Schema", "Literal", "Input", "mutable", "Struct", "name", "String", "kind", "optional", "default", "Any", "Template", "source", "Type", "Ref", "DataType", "Text", "annotations", "description", "inputs", "Array", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "make", "props", "content", "Blueprint", "Schema", "Struct", "key", "String", "annotations", "description", "name", "optional", "instructions", "Type", "Ref", "Template", "tools", "Array", "ToolId", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "Registry", "_blueprints", "sort", "name", "a", "b", "localeCompare", "getByKey", "key", "find", "blueprint", "query"]
3
+ "sources": ["../../../src/blueprint/index.ts", "../../../src/blueprint/blueprint.ts", "../../../src/template/index.ts", "../../../src/template/prompt.ts", "../../../src/template/template.ts", "../../../src/blueprint/registry.ts", "../../../src/prompt/index.ts", "../../../src/prompt/prompt.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport * from './blueprint';\nexport * from './registry';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { ToolId } from '@dxos/ai';\nimport { Annotation, Obj, Type } from '@dxos/echo';\nimport { type FunctionDefinition } from '@dxos/functions';\n\nimport * as Template from '../template';\n\n/**\n * Blueprint schema defines the structure for AI assistant blueprints.\n * Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.\n * Blueprints may use tools to create and read artifacts, which are managed by the assistant.\n */\nexport const Blueprint = Schema.Struct({\n /**\n * Global registry ID.\n * NOTE: The `key` property refers to the original registry entry.\n */\n // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.\n key: Schema.String.annotations({\n description: 'Unique registration key for the blueprint',\n }),\n\n /**\n * Human-readable name of the blueprint.\n */\n name: Schema.String.annotations({\n description: 'Human-readable name of the blueprint',\n }),\n\n /**\n * Description of the blueprint's purpose and functionality.\n */\n description: Schema.optional(Schema.String).annotations({\n description: \"Description of the blueprint's purpose and functionality\",\n }),\n\n /**\n * Instructions that guide the AI assistant's behavior and responses.\n * These are system prompts or guidelines that the AI should follow.\n */\n instructions: Template.Template.annotations({\n description: \"Instructions that guide the AI assistant's behavior and responses\",\n }),\n\n /**\n * Array of tools that the AI assistant can use when this blueprint is active.\n */\n tools: Schema.Array(ToolId).annotations({\n description: 'Array of tools that the AI assistant can use when this blueprint is active',\n }),\n}).pipe(\n Type.Obj({\n // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.\n typename: 'dxos.org/type/Blueprint',\n version: '0.1.0',\n }),\n Annotation.LabelAnnotation.set(['name']),\n);\n\n/**\n * TypeScript type for Blueprint.\n */\nexport interface Blueprint extends Schema.Schema.Type<typeof Blueprint> {}\n\n/**\n * Create a new Blueprint.\n */\nexport const make = ({\n tools = [],\n instructions = Template.make(),\n ...props\n}: Pick<Blueprint, 'key' | 'name'> & Partial<Blueprint>) => Obj.make(Blueprint, { tools, instructions, ...props });\n\n/**\n * Util to create tool definitions for a blueprint.\n */\nexport const toolDefinitions = ({\n tools = [],\n functions = [],\n}: {\n tools?: string[];\n functions?: FunctionDefinition[];\n}) => [...functions.map((fn) => ToolId.make(fn.key)), ...tools.map((tool) => ToolId.make(tool))];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * from './prompt';\nexport * from './template';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport handlebars from 'handlebars';\n\nimport { invariant } from '@dxos/invariant';\n\n/**\n * Process Handlebars template.\n */\nexport const process = <Options extends {}>(source: string, variables: Partial<Options> = {}): string => {\n invariant(typeof source === 'string');\n let section = 0;\n handlebars.registerHelper('section', () => String(++section));\n const template = handlebars.compile(source.trim());\n const output = template(variables);\n return output.trim().replace(/(\\n\\s*){3,}/g, '\\n\\n');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Ref, Type } from '@dxos/echo';\nimport { type ObjectId } from '@dxos/keys';\nimport { Text } from '@dxos/schema';\n\n/**\n * Template input kind determines how template variables are resolved.\n */\nexport const InputKind = Schema.Literal(\n 'value', // Literal value.\n 'pass-through',\n 'retriever',\n 'function',\n 'query',\n 'resolver',\n 'context',\n 'schema',\n);\n\nexport type InputKind = Schema.Schema.Type<typeof InputKind>;\n\n/**\n * Template input variable.\n * E.g., {{foo}}\n */\nexport const Input = Schema.mutable(\n Schema.Struct({\n name: Schema.String,\n kind: Schema.optional(InputKind),\n default: Schema.optional(Schema.Any),\n }),\n);\n\nexport type Input = Schema.Schema.Type<typeof Input>;\n\n/**\n * Template type.\n */\nexport const Template = Schema.Struct({\n source: Type.Ref(Text.Text).annotations({ description: 'Handlebars template source' }),\n inputs: Schema.optional(Schema.mutable(Schema.Array(Input))),\n}).pipe(Schema.mutable);\n\nexport interface Template extends Schema.Schema.Type<typeof Template> {}\n\nexport const make = ({\n source,\n inputs = [],\n id,\n}: { source?: string; inputs?: Input[]; id?: ObjectId } = {}): Template => ({\n source: Ref.make(Text.make(source, id)),\n inputs,\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { log } from '@dxos/log';\n\nimport { type Blueprint } from './blueprint';\n\n/**\n * Blueprint registry.\n */\nexport class Registry {\n private readonly _blueprints: Blueprint[] = [];\n\n constructor(blueprints: Blueprint[]) {\n const seen = new Set<string>();\n blueprints.forEach((blueprint) => {\n if (seen.has(blueprint.key)) {\n log.warn('duplicate blueprint', { key: blueprint.key });\n } else {\n seen.add(blueprint.key);\n this._blueprints.push(blueprint);\n }\n });\n\n this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));\n }\n\n getByKey(key: string): Blueprint | undefined {\n return this._blueprints.find((blueprint) => blueprint.key === key);\n }\n\n query(): Blueprint[] {\n return this._blueprints;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * from './prompt';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, JsonSchema, Obj, type Ref, Type } from '@dxos/echo';\n\nimport { Blueprint } from '../blueprint';\nimport * as Template from '../template';\n\n/**\n * Executable instructions, which may use Blueprints.\n * May reference additional context.\n */\nconst Prompt$ = Schema.Struct({\n /**\n * Name of the prompt.\n */\n name: Schema.optional(Schema.String),\n\n /**\n * Description of the prompt's purpose and functionality.\n * Allows AI agents to execute prompts automatically as tools.\n */\n description: Schema.optional(Schema.String),\n\n /**\n * Input schema of the prompt.\n */\n input: JsonSchema.JsonSchema.pipe(Annotation.FormInputAnnotation.set(false)),\n\n /**\n * Output schema of the prompt.\n */\n output: JsonSchema.JsonSchema.pipe(Annotation.FormInputAnnotation.set(false)),\n\n /**\n * Natural language instructions for the prompt.\n * These should provide concrete course of action for the AI to follow.\n */\n instructions: Template.Template.pipe(Annotation.FormInputAnnotation.set(false)),\n\n /**\n * Blueprints that the prompt may utilize.\n */\n blueprints: Schema.Array(Type.Ref(Blueprint)),\n\n /**\n * Additional context that the prompt may utilize.\n */\n context: Schema.Array(Schema.Any).pipe(Annotation.FormInputAnnotation.set(false)),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Prompt',\n version: '0.1.0',\n }),\n);\n\nexport interface Prompt extends Schema.Schema.Type<typeof Prompt$> {}\nexport interface Prompt_Encoded extends Schema.Schema.Encoded<typeof Prompt$> {}\nexport const Prompt: Schema.Schema<Prompt, Prompt_Encoded> = Prompt$;\n\nexport const make = (params: {\n name?: string;\n description?: string;\n input?: Schema.Schema.AnyNoContext;\n output?: Schema.Schema.AnyNoContext;\n instructions?: string;\n blueprints?: Ref.Ref<Blueprint>[];\n context?: any[];\n}): Prompt =>\n Obj.make(Prompt, {\n name: params.name,\n description: params.description,\n input: JsonSchema.toJsonSchema(params.input ?? Schema.Void),\n output: JsonSchema.toJsonSchema(params.output ?? Schema.Void),\n instructions: Template.make({ source: params.instructions }),\n blueprints: params.blueprints ?? [],\n context: params.context ?? [],\n });\n"],
5
+ "mappings": ";;;;;;;AAAA;;;;cAAAA;EAAA;;;;ACIA,YAAYC,aAAY;AAExB,SAASC,cAAc;AACvB,SAASC,YAAYC,KAAKC,QAAAA,aAAY;;;ACPtC;;;;;;;;;;ACIA,OAAOC,gBAAgB;AAE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;ACnCA;;;cAAAmB;;;;ACIA,YAAYC,aAAY;AAExB,SAASC,cAAAA,aAAYC,YAAYC,OAAAA,MAAeC,QAAAA,aAAY;AAS5D,IAAMC,UAAiBC,eAAO;;;;EAI5BC,MAAaC,iBAAgBC,cAAM;;;;;EAMnCC,aAAoBF,iBAAgBC,cAAM;;;;EAK1CE,OAAOC,WAAWA,WAAWC,KAAKC,YAAWC,oBAAoBC,IAAI,KAAA,CAAA;;;;EAKrEC,QAAQL,WAAWA,WAAWC,KAAKC,YAAWC,oBAAoBC,IAAI,KAAA,CAAA;;;;;EAMtEE,cAAuBC,SAASN,KAAKC,YAAWC,oBAAoBC,IAAI,KAAA,CAAA;;;;EAKxEI,YAAmBC,cAAMC,MAAKC,IAAIC,SAAAA,CAAAA;;;;EAKlCC,SAAgBJ,cAAaK,WAAG,EAAEb,KAAKC,YAAWC,oBAAoBC,IAAI,KAAA,CAAA;AAC5E,CAAA,EAAGH,KACDS,MAAKK,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;AAKK,IAAMC,SAAgDzB;AAEtD,IAAM0B,QAAO,CAACC,WASnBL,KAAII,KAAKD,QAAQ;EACfvB,MAAMyB,OAAOzB;EACbG,aAAasB,OAAOtB;EACpBC,OAAOC,WAAWqB,aAAaD,OAAOrB,SAAgBuB,YAAI;EAC1DjB,QAAQL,WAAWqB,aAAaD,OAAOf,UAAiBiB,YAAI;EAC5DhB,cAAuBa,KAAK;IAAEI,QAAQH,OAAOd;EAAa,CAAA;EAC1DE,YAAYY,OAAOZ,cAAc,CAAA;EACjCK,SAASO,OAAOP,WAAW,CAAA;AAC7B,CAAA;",
6
+ "names": ["make", "Schema", "ToolId", "Annotation", "Obj", "Type", "handlebars", "invariant", "process", "source", "variables", "section", "registerHelper", "String", "template", "compile", "trim", "output", "replace", "Schema", "Ref", "Type", "Text", "InputKind", "Literal", "Input", "mutable", "Struct", "name", "String", "kind", "optional", "default", "Any", "Template", "source", "Type", "Ref", "Text", "annotations", "description", "inputs", "Array", "pipe", "make", "id", "Blueprint", "Struct", "key", "String", "annotations", "description", "name", "optional", "instructions", "Template", "tools", "Array", "ToolId", "pipe", "Type", "Obj", "typename", "version", "Annotation", "LabelAnnotation", "set", "make", "props", "toolDefinitions", "functions", "map", "fn", "tool", "log", "Registry", "_blueprints", "blueprints", "seen", "Set", "forEach", "blueprint", "has", "key", "warn", "add", "push", "sort", "name", "a", "b", "localeCompare", "getByKey", "find", "query", "make", "Schema", "Annotation", "JsonSchema", "Obj", "Type", "Prompt$", "Struct", "name", "optional", "String", "description", "input", "JsonSchema", "pipe", "Annotation", "FormInputAnnotation", "set", "output", "instructions", "Template", "blueprints", "Array", "Type", "Ref", "Blueprint", "context", "Any", "Obj", "typename", "version", "Prompt", "make", "params", "toJsonSchema", "Void", "source"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/artifacts.ts":{"bytes":2355,"imports":[],"format":"esm"},"src/template/prompt.ts":{"bytes":2338,"imports":[{"path":"handlebars","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/template/template.ts":{"bytes":5350,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/template/index.ts":{"bytes":546,"imports":[{"path":"src/template/prompt.ts","kind":"import-statement","original":"./prompt"},{"path":"src/template/template.ts","kind":"import-statement","original":"./template"}],"format":"esm"},"src/blueprint/blueprint.ts":{"bytes":6427,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"src/template/index.ts","kind":"import-statement","original":"../template"}],"format":"esm"},"src/blueprint/registry.ts":{"bytes":1958,"imports":[],"format":"esm"},"src/blueprint/index.ts":{"bytes":554,"imports":[{"path":"src/blueprint/blueprint.ts","kind":"import-statement","original":"./blueprint"},{"path":"src/blueprint/registry.ts","kind":"import-statement","original":"./registry"}],"format":"esm"},"src/index.ts":{"bytes":762,"imports":[{"path":"src/artifacts.ts","kind":"import-statement","original":"./artifacts"},{"path":"src/blueprint/index.ts","kind":"import-statement","original":"./blueprint"},{"path":"src/template/index.ts","kind":"import-statement","original":"./template"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9767},"dist/lib/browser/index.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"handlebars","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"exports":["Blueprint","Template","defineArtifact"],"entryPoint":"src/index.ts","inputs":{"src/artifacts.ts":{"bytesInOutput":49},"src/index.ts":{"bytesInOutput":0},"src/blueprint/index.ts":{"bytesInOutput":119},"src/blueprint/blueprint.ts":{"bytesInOutput":1674},"src/template/index.ts":{"bytesInOutput":195},"src/template/prompt.ts":{"bytesInOutput":601},"src/template/template.ts":{"bytesInOutput":966},"src/blueprint/registry.ts":{"bytesInOutput":311}},"bytes":4434}}}
1
+ {"inputs":{"src/template/prompt.ts":{"bytes":2322,"imports":[{"path":"handlebars","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/template/template.ts":{"bytes":4366,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/template/index.ts":{"bytes":546,"imports":[{"path":"src/template/prompt.ts","kind":"import-statement","original":"./prompt"},{"path":"src/template/template.ts","kind":"import-statement","original":"./template"}],"format":"esm"},"src/blueprint/blueprint.ts":{"bytes":8089,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/template/index.ts","kind":"import-statement","original":"../template"}],"format":"esm"},"src/blueprint/registry.ts":{"bytes":3436,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/blueprint/index.ts":{"bytes":554,"imports":[{"path":"src/blueprint/blueprint.ts","kind":"import-statement","original":"./blueprint"},{"path":"src/blueprint/registry.ts","kind":"import-statement","original":"./registry"}],"format":"esm"},"src/prompt/prompt.ts":{"bytes":7298,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/blueprint/index.ts","kind":"import-statement","original":"../blueprint"},{"path":"src/template/index.ts","kind":"import-statement","original":"../template"}],"format":"esm"},"src/prompt/index.ts":{"bytes":456,"imports":[{"path":"src/prompt/prompt.ts","kind":"import-statement","original":"./prompt"}],"format":"esm"},"src/index.ts":{"bytes":813,"imports":[{"path":"src/blueprint/index.ts","kind":"import-statement","original":"./blueprint"},{"path":"src/template/index.ts","kind":"import-statement","original":"./template"},{"path":"src/prompt/index.ts","kind":"import-statement","original":"./prompt"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12982},"dist/lib/browser/index.mjs":{"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"handlebars","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["Blueprint","Prompt","Template"],"entryPoint":"src/index.ts","inputs":{"src/blueprint/index.ts":{"bytesInOutput":182},"src/blueprint/blueprint.ts":{"bytesInOutput":1839},"src/template/index.ts":{"bytesInOutput":185},"src/template/prompt.ts":{"bytesInOutput":609},"src/template/template.ts":{"bytesInOutput":711},"src/blueprint/registry.ts":{"bytesInOutput":834},"src/index.ts":{"bytesInOutput":0},"src/prompt/index.ts":{"bytesInOutput":100},"src/prompt/prompt.ts":{"bytesInOutput":1612}},"bytes":6629}}}
@@ -5,21 +5,19 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
- // src/artifacts.ts
9
- var defineArtifact = (definition) => definition;
10
-
11
8
  // src/blueprint/index.ts
12
9
  var blueprint_exports = {};
13
10
  __export(blueprint_exports, {
14
11
  Blueprint: () => Blueprint,
15
- Registry: () => Registry
12
+ Registry: () => Registry,
13
+ make: () => make2,
14
+ toolDefinitions: () => toolDefinitions
16
15
  });
17
16
 
18
17
  // src/blueprint/blueprint.ts
19
- import { Schema as Schema2 } from "effect";
18
+ import * as Schema2 from "effect/Schema";
20
19
  import { ToolId } from "@dxos/ai";
21
- import { Type as Type2 } from "@dxos/echo";
22
- import { LabelAnnotation as LabelAnnotation2 } from "@dxos/echo-schema";
20
+ import { Annotation, Obj, Type as Type2 } from "@dxos/echo";
23
21
 
24
22
  // src/template/index.ts
25
23
  var template_exports = {};
@@ -27,38 +25,35 @@ __export(template_exports, {
27
25
  Input: () => Input,
28
26
  InputKind: () => InputKind,
29
27
  Template: () => Template,
30
- createPrompt: () => createPrompt,
31
- make: () => make
28
+ make: () => make,
29
+ process: () => process
32
30
  });
33
31
 
34
32
  // src/template/prompt.ts
35
33
  import handlebars from "handlebars";
36
- import defaultsDeep from "lodash.defaultsdeep";
37
34
  import { invariant } from "@dxos/invariant";
38
35
  var __dxlog_file = "/__w/dxos/dxos/packages/core/blueprints/src/template/prompt.ts";
39
- var createPrompt = (source, options = {}) => {
40
- invariant(source, void 0, {
36
+ var process = (source, variables = {}) => {
37
+ invariant(typeof source === "string", void 0, {
41
38
  F: __dxlog_file,
42
- L: 14,
39
+ L: 13,
43
40
  S: void 0,
44
41
  A: [
45
- "source",
42
+ "typeof source === 'string'",
46
43
  ""
47
44
  ]
48
45
  });
49
46
  let section = 0;
50
47
  handlebars.registerHelper("section", () => String(++section));
51
- const template = handlebars.compile(source);
52
- return template(defaultsDeep({}, options, {
53
- suggestions: true
54
- })).trim();
48
+ const template = handlebars.compile(source.trim());
49
+ const output = template(variables);
50
+ return output.trim().replace(/(\n\s*){3,}/g, "\n\n");
55
51
  };
56
52
 
57
53
  // src/template/template.ts
58
- import { Schema } from "effect";
59
- import { Obj, Ref, Type } from "@dxos/echo";
60
- import { LabelAnnotation } from "@dxos/echo-schema";
61
- import { DataType } from "@dxos/schema";
54
+ import * as Schema from "effect/Schema";
55
+ import { Ref, Type } from "@dxos/echo";
56
+ import { Text } from "@dxos/schema";
62
57
  var InputKind = Schema.Literal("value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema");
63
58
  var Input = Schema.mutable(Schema.Struct({
64
59
  name: Schema.String,
@@ -66,25 +61,15 @@ var Input = Schema.mutable(Schema.Struct({
66
61
  default: Schema.optional(Schema.Any)
67
62
  }));
68
63
  var Template = Schema.Struct({
69
- name: Schema.optional(Schema.String),
70
- source: Type.Ref(DataType.Text).annotations({
64
+ source: Type.Ref(Text.Text).annotations({
71
65
  description: "Handlebars template source"
72
66
  }),
73
67
  inputs: Schema.optional(Schema.mutable(Schema.Array(Input)))
74
- }).pipe(Type.Obj({
75
- typename: "dxos.org/type/Template",
76
- version: "0.1.0"
77
- }), LabelAnnotation.set([
78
- "name"
79
- ]));
80
- var make = ({ source = "", ...props }) => {
81
- return Obj.make(Template, {
82
- source: Ref.make(Obj.make(DataType.Text, {
83
- content: source
84
- })),
85
- ...props
86
- });
87
- };
68
+ }).pipe(Schema.mutable);
69
+ var make = ({ source, inputs = [], id } = {}) => ({
70
+ source: Ref.make(Text.make(source, id)),
71
+ inputs
72
+ });
88
73
 
89
74
  // src/blueprint/blueprint.ts
90
75
  var Blueprint = Schema2.Struct({
@@ -112,7 +97,7 @@ var Blueprint = Schema2.Struct({
112
97
  * Instructions that guide the AI assistant's behavior and responses.
113
98
  * These are system prompts or guidelines that the AI should follow.
114
99
  */
115
- instructions: Type2.Ref(Template).annotations({
100
+ instructions: Template.annotations({
116
101
  description: "Instructions that guide the AI assistant's behavior and responses"
117
102
  }),
118
103
  /**
@@ -121,22 +106,45 @@ var Blueprint = Schema2.Struct({
121
106
  tools: Schema2.Array(ToolId).annotations({
122
107
  description: "Array of tools that the AI assistant can use when this blueprint is active"
123
108
  })
124
- }).pipe(
125
- Type2.Obj({
126
- // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
127
- typename: "dxos.org/type/Blueprint",
128
- version: "0.1.0"
129
- }),
130
- // TODO(burdon): Move to Type.Obj def?
131
- LabelAnnotation2.set([
132
- "name"
133
- ])
134
- );
109
+ }).pipe(Type2.Obj({
110
+ // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
111
+ typename: "dxos.org/type/Blueprint",
112
+ version: "0.1.0"
113
+ }), Annotation.LabelAnnotation.set([
114
+ "name"
115
+ ]));
116
+ var make2 = ({ tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
117
+ tools,
118
+ instructions,
119
+ ...props
120
+ });
121
+ var toolDefinitions = ({ tools = [], functions = [] }) => [
122
+ ...functions.map((fn) => ToolId.make(fn.key)),
123
+ ...tools.map((tool) => ToolId.make(tool))
124
+ ];
135
125
 
136
126
  // src/blueprint/registry.ts
127
+ import { log } from "@dxos/log";
128
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/blueprints/src/blueprint/registry.ts";
137
129
  var Registry = class {
138
- constructor(_blueprints) {
139
- this._blueprints = _blueprints;
130
+ _blueprints = [];
131
+ constructor(blueprints) {
132
+ const seen = /* @__PURE__ */ new Set();
133
+ blueprints.forEach((blueprint) => {
134
+ if (seen.has(blueprint.key)) {
135
+ log.warn("duplicate blueprint", {
136
+ key: blueprint.key
137
+ }, {
138
+ F: __dxlog_file2,
139
+ L: 19,
140
+ S: this,
141
+ C: (f, a) => f(...a)
142
+ });
143
+ } else {
144
+ seen.add(blueprint.key);
145
+ this._blueprints.push(blueprint);
146
+ }
147
+ });
140
148
  this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
141
149
  }
142
150
  getByKey(key) {
@@ -146,9 +154,67 @@ var Registry = class {
146
154
  return this._blueprints;
147
155
  }
148
156
  };
157
+
158
+ // src/prompt/index.ts
159
+ var prompt_exports = {};
160
+ __export(prompt_exports, {
161
+ Prompt: () => Prompt,
162
+ make: () => make3
163
+ });
164
+
165
+ // src/prompt/prompt.ts
166
+ import * as Schema3 from "effect/Schema";
167
+ import { Annotation as Annotation2, JsonSchema, Obj as Obj2, Type as Type3 } from "@dxos/echo";
168
+ var Prompt$ = Schema3.Struct({
169
+ /**
170
+ * Name of the prompt.
171
+ */
172
+ name: Schema3.optional(Schema3.String),
173
+ /**
174
+ * Description of the prompt's purpose and functionality.
175
+ * Allows AI agents to execute prompts automatically as tools.
176
+ */
177
+ description: Schema3.optional(Schema3.String),
178
+ /**
179
+ * Input schema of the prompt.
180
+ */
181
+ input: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
182
+ /**
183
+ * Output schema of the prompt.
184
+ */
185
+ output: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
186
+ /**
187
+ * Natural language instructions for the prompt.
188
+ * These should provide concrete course of action for the AI to follow.
189
+ */
190
+ instructions: Template.pipe(Annotation2.FormInputAnnotation.set(false)),
191
+ /**
192
+ * Blueprints that the prompt may utilize.
193
+ */
194
+ blueprints: Schema3.Array(Type3.Ref(Blueprint)),
195
+ /**
196
+ * Additional context that the prompt may utilize.
197
+ */
198
+ context: Schema3.Array(Schema3.Any).pipe(Annotation2.FormInputAnnotation.set(false))
199
+ }).pipe(Type3.Obj({
200
+ typename: "dxos.org/type/Prompt",
201
+ version: "0.1.0"
202
+ }));
203
+ var Prompt = Prompt$;
204
+ var make3 = (params) => Obj2.make(Prompt, {
205
+ name: params.name,
206
+ description: params.description,
207
+ input: JsonSchema.toJsonSchema(params.input ?? Schema3.Void),
208
+ output: JsonSchema.toJsonSchema(params.output ?? Schema3.Void),
209
+ instructions: make({
210
+ source: params.instructions
211
+ }),
212
+ blueprints: params.blueprints ?? [],
213
+ context: params.context ?? []
214
+ });
149
215
  export {
150
216
  blueprint_exports as Blueprint,
151
- template_exports as Template,
152
- defineArtifact
217
+ prompt_exports as Prompt,
218
+ template_exports as Template
153
219
  };
154
220
  //# sourceMappingURL=index.mjs.map