@dxos/blueprints 0.8.4-main.b97322e → 0.8.4-main.bc674ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +160 -58
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +160 -58
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +47 -34
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/registry.d.ts +2 -1
- package/dist/types/src/blueprint/registry.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/prompt/index.d.ts +2 -0
- package/dist/types/src/prompt/index.d.ts.map +1 -0
- package/dist/types/src/prompt/prompt.d.ts +54 -0
- package/dist/types/src/prompt/prompt.d.ts.map +1 -0
- package/dist/types/src/template/prompt.d.ts +6 -1
- package/dist/types/src/template/prompt.d.ts.map +1 -1
- package/dist/types/src/template/template.d.ts +23 -27
- package/dist/types/src/template/template.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -15
- package/src/blueprint/blueprint.ts +30 -9
- package/src/blueprint/registry.ts +19 -1
- package/src/index.ts +1 -1
- package/src/prompt/index.ts +5 -0
- package/src/prompt/prompt.ts +79 -0
- package/src/template/prompt.test.ts +2 -2
- package/src/template/prompt.ts +45 -5
- package/src/template/template.ts +25 -30
- package/dist/types/src/artifacts.d.ts +0 -40
- package/dist/types/src/artifacts.d.ts.map +0 -1
- 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
|
|
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,64 +24,85 @@ __export(template_exports, {
|
|
|
26
24
|
Input: () => Input,
|
|
27
25
|
InputKind: () => InputKind,
|
|
28
26
|
Template: () => Template,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
make: () => make,
|
|
28
|
+
process: () => process,
|
|
29
|
+
processTemplate: () => processTemplate
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
// src/template/prompt.ts
|
|
33
|
+
import * as Effect from "effect/Effect";
|
|
34
|
+
import * as Record from "effect/Record";
|
|
34
35
|
import handlebars from "handlebars";
|
|
35
|
-
import
|
|
36
|
+
import { Database } from "@dxos/echo";
|
|
37
|
+
import { FunctionInvocationService } from "@dxos/functions";
|
|
36
38
|
import { invariant } from "@dxos/invariant";
|
|
39
|
+
import { log } from "@dxos/log";
|
|
37
40
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/blueprints/src/template/prompt.ts";
|
|
38
|
-
var
|
|
39
|
-
invariant(source, void 0, {
|
|
41
|
+
var process = (source, variables = {}) => {
|
|
42
|
+
invariant(typeof source === "string", void 0, {
|
|
40
43
|
F: __dxlog_file,
|
|
41
|
-
L:
|
|
44
|
+
L: 26,
|
|
42
45
|
S: void 0,
|
|
43
46
|
A: [
|
|
44
|
-
"source",
|
|
47
|
+
"typeof source === 'string'",
|
|
45
48
|
""
|
|
46
49
|
]
|
|
47
50
|
});
|
|
48
51
|
let section = 0;
|
|
49
52
|
handlebars.registerHelper("section", () => String(++section));
|
|
50
|
-
const template = handlebars.compile(source);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})).trim();
|
|
53
|
+
const template = handlebars.compile(source.trim());
|
|
54
|
+
const output = template(variables);
|
|
55
|
+
return output.trim().replace(/(\n\s*){3,}/g, "\n\n");
|
|
54
56
|
};
|
|
57
|
+
var processTemplate = (template) => Effect.gen(function* () {
|
|
58
|
+
const functionInvoker = yield* FunctionInvocationService;
|
|
59
|
+
const variables = yield* Effect.forEach(template.inputs ?? [], (input) => Effect.gen(function* () {
|
|
60
|
+
if (input.kind === "function") {
|
|
61
|
+
const fn = yield* functionInvoker.resolveFunction(input.function);
|
|
62
|
+
const result = yield* functionInvoker.invokeFunction(fn, {});
|
|
63
|
+
return [
|
|
64
|
+
input.name,
|
|
65
|
+
result
|
|
66
|
+
];
|
|
67
|
+
} else {
|
|
68
|
+
return yield* Effect.dieMessage(`Unsupported input kind: ${input.kind}`);
|
|
69
|
+
}
|
|
70
|
+
})).pipe(Effect.map(Record.fromEntries));
|
|
71
|
+
log("processTemplate", {
|
|
72
|
+
variables
|
|
73
|
+
}, {
|
|
74
|
+
F: __dxlog_file,
|
|
75
|
+
L: 56,
|
|
76
|
+
S: this,
|
|
77
|
+
C: (f, a) => f(...a)
|
|
78
|
+
});
|
|
79
|
+
return process((yield* Database.Service.load(template.source)).content, variables);
|
|
80
|
+
});
|
|
55
81
|
|
|
56
82
|
// src/template/template.ts
|
|
57
|
-
import
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import { DataType } from "@dxos/schema";
|
|
83
|
+
import * as Schema from "effect/Schema";
|
|
84
|
+
import { Ref, Type } from "@dxos/echo";
|
|
85
|
+
import { Text } from "@dxos/schema";
|
|
61
86
|
var InputKind = Schema.Literal("value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema");
|
|
62
|
-
var Input = Schema.
|
|
87
|
+
var Input = Schema.Struct({
|
|
63
88
|
name: Schema.String,
|
|
64
89
|
kind: Schema.optional(InputKind),
|
|
65
|
-
default: Schema.optional(Schema.Any)
|
|
66
|
-
|
|
90
|
+
default: Schema.optional(Schema.Any),
|
|
91
|
+
/**
|
|
92
|
+
* Function to call if the kind is 'function'.
|
|
93
|
+
*/
|
|
94
|
+
function: Schema.optional(Schema.String)
|
|
95
|
+
});
|
|
67
96
|
var Template = Schema.Struct({
|
|
68
|
-
|
|
69
|
-
source: Type.Ref(DataType.Text).annotations({
|
|
97
|
+
source: Type.Ref(Text.Text).annotations({
|
|
70
98
|
description: "Handlebars template source"
|
|
71
99
|
}),
|
|
72
|
-
inputs: Schema.optional(Schema.
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
};
|
|
100
|
+
inputs: Schema.optional(Schema.Array(Input))
|
|
101
|
+
});
|
|
102
|
+
var make = ({ source, inputs = [], id } = {}) => ({
|
|
103
|
+
source: Ref.make(Text.make(source, id)),
|
|
104
|
+
inputs
|
|
105
|
+
});
|
|
87
106
|
|
|
88
107
|
// src/blueprint/blueprint.ts
|
|
89
108
|
var Blueprint = Schema2.Struct({
|
|
@@ -111,7 +130,7 @@ var Blueprint = Schema2.Struct({
|
|
|
111
130
|
* Instructions that guide the AI assistant's behavior and responses.
|
|
112
131
|
* These are system prompts or guidelines that the AI should follow.
|
|
113
132
|
*/
|
|
114
|
-
instructions:
|
|
133
|
+
instructions: Template.annotations({
|
|
115
134
|
description: "Instructions that guide the AI assistant's behavior and responses"
|
|
116
135
|
}),
|
|
117
136
|
/**
|
|
@@ -120,24 +139,50 @@ var Blueprint = Schema2.Struct({
|
|
|
120
139
|
tools: Schema2.Array(ToolId).annotations({
|
|
121
140
|
description: "Array of tools that the AI assistant can use when this blueprint is active"
|
|
122
141
|
})
|
|
123
|
-
}).pipe(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
}).pipe(Type2.object({
|
|
143
|
+
// TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
|
|
144
|
+
typename: "dxos.org/type/Blueprint",
|
|
145
|
+
version: "0.1.0"
|
|
146
|
+
}), Annotation.LabelAnnotation.set([
|
|
147
|
+
"name"
|
|
148
|
+
]));
|
|
149
|
+
var make2 = ({ tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
|
|
150
|
+
tools,
|
|
151
|
+
instructions,
|
|
152
|
+
...props
|
|
153
|
+
});
|
|
154
|
+
var toolDefinitions = ({ tools = [], functions = [] }) => [
|
|
155
|
+
...functions.map((fn) => ToolId.make(fn.key)),
|
|
156
|
+
...tools.map((tool) => ToolId.make(tool))
|
|
157
|
+
];
|
|
134
158
|
|
|
135
159
|
// src/blueprint/registry.ts
|
|
160
|
+
import { log as log2 } from "@dxos/log";
|
|
161
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/blueprints/src/blueprint/registry.ts";
|
|
136
162
|
var Registry = class {
|
|
137
|
-
|
|
138
|
-
|
|
163
|
+
_blueprints = [];
|
|
164
|
+
constructor(blueprints) {
|
|
165
|
+
const seen = /* @__PURE__ */ new Set();
|
|
166
|
+
blueprints.forEach((blueprint) => {
|
|
167
|
+
if (seen.has(blueprint.key)) {
|
|
168
|
+
log2.warn("duplicate blueprint", {
|
|
169
|
+
key: blueprint.key
|
|
170
|
+
}, {
|
|
171
|
+
F: __dxlog_file2,
|
|
172
|
+
L: 19,
|
|
173
|
+
S: this,
|
|
174
|
+
C: (f, a) => f(...a)
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
seen.add(blueprint.key);
|
|
178
|
+
this._blueprints.push(blueprint);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
139
181
|
this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
140
182
|
}
|
|
183
|
+
get blueprints() {
|
|
184
|
+
return this._blueprints;
|
|
185
|
+
}
|
|
141
186
|
getByKey(key) {
|
|
142
187
|
return this._blueprints.find((blueprint) => blueprint.key === key);
|
|
143
188
|
}
|
|
@@ -145,9 +190,66 @@ var Registry = class {
|
|
|
145
190
|
return this._blueprints;
|
|
146
191
|
}
|
|
147
192
|
};
|
|
193
|
+
|
|
194
|
+
// src/prompt/index.ts
|
|
195
|
+
var prompt_exports = {};
|
|
196
|
+
__export(prompt_exports, {
|
|
197
|
+
Prompt: () => Prompt,
|
|
198
|
+
make: () => make3
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/prompt/prompt.ts
|
|
202
|
+
import * as Schema3 from "effect/Schema";
|
|
203
|
+
import { Annotation as Annotation2, JsonSchema, Obj as Obj2, Type as Type3 } from "@dxos/echo";
|
|
204
|
+
var Prompt = Schema3.Struct({
|
|
205
|
+
/**
|
|
206
|
+
* Name of the prompt.
|
|
207
|
+
*/
|
|
208
|
+
name: Schema3.optional(Schema3.String),
|
|
209
|
+
/**
|
|
210
|
+
* Description of the prompt's purpose and functionality.
|
|
211
|
+
* Allows AI agents to execute prompts automatically as tools.
|
|
212
|
+
*/
|
|
213
|
+
description: Schema3.optional(Schema3.String),
|
|
214
|
+
/**
|
|
215
|
+
* Input schema of the prompt.
|
|
216
|
+
*/
|
|
217
|
+
input: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
|
|
218
|
+
/**
|
|
219
|
+
* Output schema of the prompt.
|
|
220
|
+
*/
|
|
221
|
+
output: JsonSchema.JsonSchema.pipe(Annotation2.FormInputAnnotation.set(false)),
|
|
222
|
+
/**
|
|
223
|
+
* Natural language instructions for the prompt.
|
|
224
|
+
* These should provide concrete course of action for the AI to follow.
|
|
225
|
+
*/
|
|
226
|
+
instructions: Template.pipe(Annotation2.FormInputAnnotation.set(false)),
|
|
227
|
+
/**
|
|
228
|
+
* Blueprints that the prompt may utilize.
|
|
229
|
+
*/
|
|
230
|
+
blueprints: Schema3.Array(Type3.Ref(Blueprint)),
|
|
231
|
+
/**
|
|
232
|
+
* Additional context that the prompt may utilize.
|
|
233
|
+
*/
|
|
234
|
+
context: Schema3.Array(Schema3.Any).pipe(Annotation2.FormInputAnnotation.set(false))
|
|
235
|
+
}).pipe(Type3.object({
|
|
236
|
+
typename: "dxos.org/type/Prompt",
|
|
237
|
+
version: "0.1.0"
|
|
238
|
+
}));
|
|
239
|
+
var make3 = (params) => Obj2.make(Prompt, {
|
|
240
|
+
name: params.name,
|
|
241
|
+
description: params.description,
|
|
242
|
+
input: JsonSchema.toJsonSchema(params.input ?? Schema3.Void),
|
|
243
|
+
output: JsonSchema.toJsonSchema(params.output ?? Schema3.Void),
|
|
244
|
+
instructions: make({
|
|
245
|
+
source: params.instructions
|
|
246
|
+
}),
|
|
247
|
+
blueprints: params.blueprints ?? [],
|
|
248
|
+
context: params.context ?? []
|
|
249
|
+
});
|
|
148
250
|
export {
|
|
149
251
|
blueprint_exports as Blueprint,
|
|
150
|
-
|
|
151
|
-
|
|
252
|
+
prompt_exports as Prompt,
|
|
253
|
+
template_exports as Template
|
|
152
254
|
};
|
|
153
255
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\
|
|
5
|
-
"mappings": ";;;;;;;
|
|
6
|
-
"names": ["
|
|
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.object({\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\ntype MakeProps = Pick<Blueprint, 'key' | 'name'> & Partial<Blueprint>;\n\n/**\n * Create a new Blueprint.\n */\nexport const make = ({ tools = [], instructions = Template.make(), ...props }: MakeProps) =>\n Obj.make(Blueprint, {\n tools,\n instructions,\n ...props,\n });\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 * as Effect from 'effect/Effect';\nimport * as Record from 'effect/Record';\nimport handlebars from 'handlebars';\n\nimport { Database } from '@dxos/echo';\nimport type { ObjectNotFoundError } from '@dxos/echo/Err';\nimport {\n type FunctionDefinition,\n FunctionInvocationService,\n type FunctionNotFoundError,\n type TracingService,\n} from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport type { Template } from '..';\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\nexport const processTemplate = (\n template: Template.Template,\n): Effect.Effect<string, ObjectNotFoundError | FunctionNotFoundError, FunctionInvocationService | TracingService> =>\n Effect.gen(function* () {\n const functionInvoker = yield* FunctionInvocationService;\n\n const variables = yield* Effect.forEach(template.inputs ?? [], (input) =>\n Effect.gen(function* () {\n if (input.kind === 'function') {\n const fn = (yield* functionInvoker.resolveFunction(input.function!)) as FunctionDefinition<\n {},\n unknown,\n never\n >;\n const result = yield* functionInvoker.invokeFunction(fn, {});\n return [input.name, result] as const;\n } else {\n return yield* Effect.dieMessage(`Unsupported input kind: ${input.kind}`);\n }\n }),\n ).pipe(Effect.map(Record.fromEntries));\n\n log('processTemplate', { variables });\n\n return process((yield* Database.Service.load(template.source)).content, variables);\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.Struct({\n name: Schema.String,\n kind: Schema.optional(InputKind),\n default: Schema.optional(Schema.Any),\n\n /**\n * Function to call if the kind is 'function'.\n */\n function: Schema.optional(Schema.String),\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.Array(Input)),\n});\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 get blueprints(): Blueprint[] {\n return this._blueprints;\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 */\nexport const 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.object({\n typename: 'dxos.org/type/Prompt',\n version: '0.1.0',\n }),\n);\n\nexport interface Prompt extends Schema.Schema.Type<typeof 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,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,OAAOC,gBAAgB;AAEvB,SAASC,gBAAgB;AAEzB,SAEEC,iCAGK;AACP,SAASC,iBAAiB;AAC1B,SAASC,WAAW;;AAOb,IAAMC,UAAU,CAAqBC,QAAgBC,YAA8B,CAAC,MAAC;AAC1FJ,YAAU,OAAOG,WAAW,UAAA,QAAA;;;;;;;;;AAC5B,MAAIE,UAAU;AACdR,aAAWS,eAAe,WAAW,MAAMC,OAAO,EAAEF,OAAAA,CAAAA;AACpD,QAAMG,WAAWX,WAAWY,QAAQN,OAAOO,KAAI,CAAA;AAC/C,QAAMC,SAASH,SAASJ,SAAAA;AACxB,SAAOO,OAAOD,KAAI,EAAGE,QAAQ,gBAAgB,MAAA;AAC/C;AAEO,IAAMC,kBAAkB,CAC7BL,aAEOM,WAAI,aAAA;AACT,QAAMC,kBAAkB,OAAOhB;AAE/B,QAAMK,YAAY,OAAcY,eAAQR,SAASS,UAAU,CAAA,GAAI,CAACC,UACvDJ,WAAI,aAAA;AACT,QAAII,MAAMC,SAAS,YAAY;AAC7B,YAAMC,KAAM,OAAOL,gBAAgBM,gBAAgBH,MAAMI,QAAQ;AAKjE,YAAMC,SAAS,OAAOR,gBAAgBS,eAAeJ,IAAI,CAAC,CAAA;AAC1D,aAAO;QAAC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;;ACIA,YAAYC,aAAY;AAExB,SAASC,cAAAA,aAAYC,YAAYC,OAAAA,MAAeC,QAAAA,aAAY;AASrD,IAAMC,SAAgBC,eAAO;;;;EAIlCC,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,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;AAKK,IAAMC,QAAO,CAACC,WASnBC,KAAIF,KAAKzB,QAAQ;EACfE,MAAMwB,OAAOxB;EACbG,aAAaqB,OAAOrB;EACpBC,OAAOC,WAAWqB,aAAaF,OAAOpB,SAAgBuB,YAAI;EAC1DjB,QAAQL,WAAWqB,aAAaF,OAAOd,UAAiBiB,YAAI;EAC5DhB,cAAuBY,KAAK;IAAEK,QAAQJ,OAAOb;EAAa,CAAA;EAC1DE,YAAYW,OAAOX,cAAc,CAAA;EACjCK,SAASM,OAAON,WAAW,CAAA;AAC7B,CAAA;",
|
|
6
|
+
"names": ["make", "Schema", "ToolId", "Annotation", "Obj", "Type", "Effect", "Record", "handlebars", "Database", "FunctionInvocationService", "invariant", "log", "process", "source", "variables", "section", "registerHelper", "String", "template", "compile", "trim", "output", "replace", "processTemplate", "gen", "functionInvoker", "forEach", "inputs", "input", "kind", "fn", "resolveFunction", "function", "result", "invokeFunction", "name", "dieMessage", "pipe", "map", "fromEntries", "Service", "load", "content", "Schema", "Ref", "Type", "Text", "InputKind", "Literal", "Input", "Struct", "name", "String", "kind", "optional", "default", "Any", "function", "Template", "source", "Type", "Ref", "Text", "annotations", "description", "inputs", "Array", "make", "id", "Blueprint", "Struct", "key", "String", "annotations", "description", "name", "optional", "instructions", "Template", "tools", "Array", "ToolId", "pipe", "Type", "object", "typename", "version", "Annotation", "LabelAnnotation", "set", "make", "props", "Obj", "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", "object", "typename", "version", "make", "params", "Obj", "toJsonSchema", "Void", "source"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/
|
|
1
|
+
{"inputs":{"src/template/prompt.ts":{"bytes":6924,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"handlebars","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/template/template.ts":{"bytes":4450,"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":8164,"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":3662,"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":7056,"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":15388},"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":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"handlebars","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","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},{"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":1842},"src/template/index.ts":{"bytesInOutput":227},"src/template/prompt.ts":{"bytesInOutput":1642},"src/template/template.ts":{"bytesInOutput":761},"src/blueprint/registry.ts":{"bytesInOutput":897},"src/index.ts":{"bytesInOutput":0},"src/prompt/index.ts":{"bytesInOutput":100},"src/prompt/prompt.ts":{"bytesInOutput":1592}},"bytes":7800}}}
|