@dxos/assistant 0.8.4-main.fd6878d → 0.8.4-main.fffef41
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/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/extraction/index.mjs +121 -165
- package/dist/lib/browser/extraction/index.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +1097 -161
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/extraction/index.mjs +121 -165
- package/dist/lib/node-esm/extraction/index.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +1097 -161
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/conversation/context.d.ts +23 -10
- package/dist/types/src/conversation/context.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.d.ts +22 -31
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/diff.d.ts +15 -0
- package/dist/types/src/diff.d.ts.map +1 -0
- package/dist/types/src/diff.test.d.ts +2 -0
- package/dist/types/src/diff.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +45 -13
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/execution-graph.d.ts +85 -0
- package/dist/types/src/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph.test.d.ts +2 -0
- package/dist/types/src/execution-graph.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +82 -43
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +262 -225
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts +1 -1
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/functions/services.d.ts +18 -5
- package/dist/types/src/functions/services.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/GenericToolkit.d.ts +84 -0
- package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
- package/dist/types/src/session/artifact-diff.d.ts +2 -2
- package/dist/types/src/session/artifact-diff.d.ts.map +1 -1
- package/dist/types/src/session/error-handling.d.ts +4 -0
- package/dist/types/src/session/error-handling.d.ts.map +1 -0
- package/dist/types/src/session/format.d.ts +5 -161
- package/dist/types/src/session/format.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +3 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/observer.d.ts +22 -0
- package/dist/types/src/session/observer.d.ts.map +1 -0
- package/dist/types/src/session/session.d.ts +22 -138
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/toolkit.d.ts +15 -0
- package/dist/types/src/session/toolkit.d.ts.map +1 -0
- package/dist/types/src/session/version-pin.d.ts +3 -3
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/templates/system.d.ts +8 -12
- package/dist/types/src/templates/system.d.ts.map +1 -1
- package/dist/types/src/types/artifact.d.ts +20 -0
- package/dist/types/src/types/artifact.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -31
- package/src/conversation/context.ts +75 -22
- package/src/conversation/conversation.ts +80 -77
- package/src/diff.test.ts +43 -0
- package/src/diff.ts +84 -0
- package/src/errors.ts +6 -1
- package/src/execution-graph.test.ts +740 -0
- package/src/execution-graph.ts +509 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +9 -9
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +47 -56
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +16 -16
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +42 -43
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
- package/src/extraction/extraction.ts +7 -6
- package/src/extraction/quotes.test.ts +2 -2
- package/src/extraction/quotes.ts +3 -3
- package/src/functions/services.ts +104 -56
- package/src/index.ts +3 -1
- package/src/session/GenericToolkit.ts +130 -0
- package/src/session/artifact-diff.ts +8 -4
- package/src/session/error-handling.ts +41 -0
- package/src/session/format.test.ts +5 -4
- package/src/session/format.ts +27 -22
- package/src/session/index.ts +4 -0
- package/src/session/observer.ts +59 -0
- package/src/session/session.conversations.json +1 -0
- package/src/session/session.test.ts +35 -191
- package/src/session/session.ts +119 -185
- package/src/session/toolkit.ts +48 -0
- package/src/session/version-pin.ts +4 -5
- package/src/templates/{format.tpl → instructions/format.tpl} +8 -2
- package/src/templates/{system.tpl → instructions/system.tpl} +15 -14
- package/src/templates/system.ts +25 -16
- package/src/{types.ts → types/artifact.ts} +22 -3
- package/src/types/index.ts +5 -0
- package/dist/lib/browser/chunk-6WRGDEMH.mjs +0 -89
- package/dist/lib/browser/chunk-6WRGDEMH.mjs.map +0 -7
- package/dist/lib/browser/chunk-NZGGCEF3.mjs +0 -341
- package/dist/lib/browser/chunk-NZGGCEF3.mjs.map +0 -7
- package/dist/lib/browser/named-entity-recognition-O46UTCLR.mjs +0 -13
- package/dist/lib/node-esm/chunk-3UU5V4FS.mjs +0 -91
- package/dist/lib/node-esm/chunk-3UU5V4FS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XOOPGSGW.mjs +0 -343
- package/dist/lib/node-esm/chunk-XOOPGSGW.mjs.map +0 -7
- package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs +0 -14
- package/dist/types/src/session/version-pin.test.d.ts +0 -2
- package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
- package/dist/types/src/summarization/summarization.test.d.ts +0 -2
- package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -16
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/session/__snapshots__/session.test.ts.snap +0 -32
- package/src/session/version-pin.test.ts +0 -7
- package/src/summarization/summarization.test.ts +0 -197
- /package/dist/lib/browser/{named-entity-recognition-O46UTCLR.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{named-entity-recognition-W4VMRCH6.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
- /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/conversation/context.ts", "../../../src/conversation/conversation.ts", "../../../src/functions/services.ts", "../../../src/templates/system.ts", "raw-loader
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, computed } from '@preact/signals-core';\nimport { Schema } from 'effect';\nimport { Array, pipe } from 'effect';\n\nimport { Blueprint } from '@dxos/blueprints';\nimport { Obj, type Ref, type Relation, Type } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { ComplexSet } from '@dxos/util';\n\n/**\n * Thread message that binds or unbinds contextual objects to a conversation.\n */\n// TODO(burdon): Move to @dxos/schema ContentBlock.\nexport const ContextBinding = Schema.Struct({\n blueprints: Schema.Struct({\n added: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n removed: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n }),\n\n // TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)\n objects: Schema.Struct({\n added: Schema.Array(Type.Ref(Type.Expando)),\n removed: Schema.Array(Type.Ref(Type.Expando)),\n }),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/ContextBinding',\n version: '0.1.0',\n }),\n);\n\nexport interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {}\n\nexport type BindingProps = Partial<{\n blueprints: Ref.Ref<Blueprint.Blueprint>[];\n objects: Ref.Ref<Type.Expando>[];\n}>;\n\nexport class Bindings {\n readonly blueprints = new ComplexSet<Ref.Ref<Blueprint.Blueprint>>((ref) => ref.dxn.toString());\n readonly objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.toString());\n\n toJSON() {\n return {\n blueprints: Array.fromIterable(this.blueprints).map((ref) => ref.dxn.toString()),\n objects: Array.fromIterable(this.objects).map((ref) => ref.dxn.toString()),\n };\n }\n}\n\n/**\n * Manages bindings of blueprints and objects to a conversation.\n */\nexport class AiContextBinder {\n /**\n * Reactive query of all bindings.\n */\n // TODO(burdon): Cache value?\n readonly bindings: ReadonlySignal<Bindings> = computed(() => this._reduce(this._queue.objects));\n\n readonly blueprints: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]> = computed(() => [\n ...this.bindings.value.blueprints,\n ]);\n\n readonly objects: ReadonlySignal<Ref.Ref<Type.Expando>[]> = computed(() => [...this.bindings.value.objects]);\n\n constructor(private readonly _queue: Queue) {}\n\n /**\n * Asynchronous query of all bindings.\n */\n async query(): Promise<Bindings> {\n const queueItems = await this._queue.queryObjects();\n return this._reduce(queueItems);\n }\n\n // TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.\n async bind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: props.blueprints ?? [],\n removed: [],\n },\n objects: {\n added: props.objects ?? [],\n removed: [],\n },\n }),\n ]);\n }\n\n async unbind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: [],\n removed: props.blueprints ?? [],\n },\n objects: {\n added: [],\n removed: props.objects ?? [],\n },\n }),\n ]);\n }\n\n private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {\n return pipe(\n items,\n Array.filter(Obj.instanceOf(ContextBinding)),\n Array.reduce(new Bindings(), (context, item) => {\n item.blueprints.removed.forEach((item) => context.blueprints.delete(item));\n item.blueprints.added.forEach((item) => context.blueprints.add(item));\n item.objects.removed.forEach((item) => context.objects.delete(item));\n item.objects.added.forEach((item) => context.objects.add(item));\n return context;\n }),\n );\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AiError, type AiLanguageModel, type AiTool, type AiToolkit } from '@effect/ai';\nimport { Effect } from 'effect';\n\nimport {\n type AiInputPreprocessingError,\n type AiToolNotFoundError,\n type ToolExecutionService,\n type ToolResolverService,\n} from '@dxos/ai';\nimport { Event } from '@dxos/async';\nimport { Obj } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { DatabaseService } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\nimport { type AiAssistantError } from '../errors';\nimport { AiSession, type GenerationObserver } from '../session';\n\nimport { AiContextBinder, type ContextBinding } from './context';\n\nexport interface AiConversationRunParams<Tools extends AiTool.Any> {\n prompt: string;\n system?: string;\n toolkit?: AiToolkit.AiToolkit<Tools>;\n observer?: GenerationObserver;\n\n /**\n * @deprecated Remove\n */\n session?: AiSession;\n}\n\nexport type AiConversationOptions = {\n queue: Queue<DataType.Message | ContextBinding>;\n};\n\n/**\n * Persistent conversation state.\n * Context + history + artifacts.\n * Backed by a Queue.\n */\nexport class AiConversation {\n private readonly _queue: Queue<DataType.Message | ContextBinding>;\n\n /**\n * Blueprints bound to the conversation.\n */\n public readonly _context: AiContextBinder;\n\n /**\n * Fired when the execution loop begins.\n * This is called before the first message is sent.\n *\n * @deprecated Pass in a session instead.\n */\n // TODO(burdon): Is this still deprecated?\n public readonly onBegin = new Event<AiSession>();\n\n constructor(options: AiConversationOptions) {\n this._queue = options.queue;\n this._context = new AiContextBinder(this._queue);\n }\n\n get context() {\n return this._context;\n }\n\n async getHistory(): Promise<DataType.Message[]> {\n const queueItems = await this._queue.queryObjects();\n return queueItems.filter(Obj.instanceOf(DataType.Message));\n }\n\n /**\n * Executes a prompt.\n * Each invocation creates a new `AiSession`, which handles potential tool calls.\n */\n run = <Tools extends AiTool.Any>({\n // TODO(burdon): Decide whether to pass in or to fully encapsulate.\n session = new AiSession(),\n ...params\n }: AiConversationRunParams<Tools>): Effect.Effect<\n DataType.Message[],\n AiAssistantError | AiInputPreprocessingError | AiError.AiError | AiToolNotFoundError,\n AiLanguageModel.AiLanguageModel | ToolResolverService | ToolExecutionService | AiTool.ToHandler<Tools>\n > =>\n Effect.gen(this, function* () {\n const history = yield* Effect.promise(() => this.getHistory());\n const context = yield* Effect.promise(() => this.context.query());\n const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.load);\n\n // TODO(burdon): These don't need to be loaded; just need id and typename from context.\n const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.load);\n\n log.info('run', {\n prompt: params.prompt,\n system: params.system,\n history: history.length,\n objects: objects.length,\n blueprints: blueprints.length,\n toolkit: params.toolkit,\n });\n\n const start = Date.now();\n this.onBegin.emit(session);\n\n const messages = yield* session.run({\n prompt: params.prompt,\n system: params.system,\n history,\n objects,\n blueprints,\n toolkit: params.toolkit,\n observer: params.observer,\n });\n\n log.info('result', { messages: messages, duration: Date.now() - start });\n yield* Effect.promise(() => this._queue.append(messages));\n return messages;\n }).pipe(Effect.withSpan('AiConversation.run'));\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { AiTool, type AiToolkit } from '@effect/ai';\nimport { Context, Effect, Layer, Match, Predicate, Record, Schema } from 'effect';\n\nimport { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { type FunctionDefinition, LocalFunctionExecutionService } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\nexport const makeToolResolverFromFunctions = (\n functions: FunctionDefinition<any, any>[],\n toolkit: AiToolkit.Any,\n): Layer.Layer<ToolResolverService> => {\n return Layer.succeed(ToolResolverService, {\n resolve: Effect.fn('resolveTool')(function* (id) {\n const tool = toolkit.tools[id];\n if (tool) {\n return tool;\n }\n\n const fn = functions.find((f) => f.name === id);\n if (!fn) {\n return yield* Effect.fail(new AiToolNotFoundError(id));\n }\n\n return projectFunctionToTool(fn);\n }),\n });\n};\n\nexport const makeToolExecutionServiceFromFunctions = (\n functions: FunctionDefinition<any, any>[],\n toolkit: AiToolkit.AiToolkit<AiTool.Any>,\n handlersLayer: Layer.Layer<AiTool.ToHandler<AiTool.AiTool<any>>, never, never>,\n): Layer.Layer<ToolExecutionService, never, LocalFunctionExecutionService> => {\n return Layer.effect(\n ToolExecutionService,\n Effect.gen(function* () {\n const toolkitHandler = yield* toolkit.pipe(Effect.provide(handlersLayer));\n\n const localFunctionExecutionService = yield* LocalFunctionExecutionService;\n return {\n handlersFor: (toolkit) => {\n const makeHandler = (tool: AiTool.Any): ((params: unknown) => Effect.Effect<unknown, any, any>) => {\n return Effect.fn('toolFunctionHandler')(function* (input: any) {\n if (toolkitHandler.tools.find((t: AiTool.Any) => t.name === tool.name)) {\n // TODO(wittjosiah): Everything is `never` here.\n return yield* (toolkitHandler.handle as any)(tool.name, input);\n }\n\n const { functionName } = Context.get(FunctionToolAnnotation)(tool.annotations as any);\n const fnDef = functions.find((f) => f.name === functionName);\n if (!fnDef) {\n return yield* Effect.fail(new AiToolNotFoundError(tool.name));\n }\n\n return yield* localFunctionExecutionService\n .invokeFunction(fnDef, input)\n .pipe(Effect.catchAllDefect((defect) => Effect.fail(defect)));\n });\n };\n\n return toolkit.of(Record.map(toolkit.tools, (tool, _name) => makeHandler(tool)) as any) as any;\n },\n };\n }),\n );\n};\n\n/**\n * Tools that are projected from functions have this annotation.\n */\nclass FunctionToolAnnotation extends Context.Tag('@dxos/assisatnt/FunctionToolAnnotation')<\n FunctionToolAnnotation,\n {\n functionName: string;\n }\n>() {}\n\nconst toolCache = new WeakMap<FunctionDefinition<any, any>, AiTool.Any>();\nconst projectFunctionToTool = (fn: FunctionDefinition<any, any>): AiTool.Any => {\n if (toolCache.has(fn)) {\n return toolCache.get(fn)!;\n }\n const tool = AiTool.make(makeToolName(fn.name), {\n description: fn.description,\n parameters: createStructFieldsFromSchema(fn.inputSchema),\n // TODO(dmaretskyi): Include output schema.\n failure: Schema.Any, // TODO(dmaretskyi): Better type for the failure?\n }).annotate(FunctionToolAnnotation, { functionName: fn.name });\n toolCache.set(fn, tool);\n return tool;\n};\n\n/**\n * @returns Tool name produced from function name by escaping invalid characters.\n */\nconst makeToolName = (name: string) => {\n const toolName = name.replace(/[^a-zA-Z0-9]/g, '_');\n invariant(toolName.match(/^[a-zA-Z_][a-zA-Z0-9-_]*$/));\n return toolName;\n};\n\n// TODO(dmaretskyi): Factor out.\nconst createStructFieldsFromSchema = (schema: Schema.Schema<any, any>): Record<string, Schema.Schema<any, any>> => {\n return Match.value(schema.ast).pipe(\n Match.when(Predicate.isTagged('TypeLiteral'), (ast) => {\n return Object.fromEntries(ast.propertySignatures.map((prop) => [prop.name, Schema.make(prop.type)]));\n }),\n Match.orElseAbsurd,\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Template } from '@dxos/blueprints';\n\nimport FORMAT from './format.tpl?raw';\nimport SYSTEM from './system.tpl?raw';\n\ntype PromptOptions = {\n /**\n * Emit chain-of-thought inside <cot> tag.\n * Should be `false` for models with built-in reasoning: Claude, deepseek, o1.\n */\n cot?: boolean;\n\n /**\n * Whether to include suggestions in the prompt.\n */\n suggestions?: boolean;\n};\n\n/**\n * Base system prompt.\n * NOTE: This contains protocol instructions that can not be dynamically edited.\n */\nexport const createSystemPrompt = (options: PromptOptions) => Template.process<PromptOptions>(FORMAT, options);\n\nexport const templates = {\n // Editable system prompt.\n system: Template.make({ source: SYSTEM }),\n};\n", "{{! System Core }}\n\n## Input Formats\n\n### Blueprints\n\nYou may be provided with Blueprint definitions that include specific instructions and tools for a given set of tasks.\nBlue print instructions will be enclosed in a <blueprint> tag.\n\n### Context objects\n\nYou may be provided with references to objects that are relevant to the current prompt.\nObjects will be in the form of a <object> tag with a <dxn> element that is the unique key of the object required by many tools.\nThe <typename> element is the type of the object.\n\n<object>\n <dxn>object-id</dxn>\n <typename>example.com/type/TypeName</typename>\n</object>\n\n## Response Formats\n\nIt is very important to respond in the correct format.\nYou response must be valid Markdown.\nIn some cases you should respond with well-formed XML tags along with the content.\n\n{{#if cot}}\nBefore responding, explain your reasoning and include your detailed chain-of-thought enclosed in a <cot> tag.\nThe <cot> tag should be the first thing in your response.\n{{/if}}\n\n## Block references\n\nYou can reply with a block reference for objects if you have the DXN. For example:\n\n<object>\n <dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n<object>\n <dxn>dxn:echo:@:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n\n### Suggestions\n\nEach suggestion must in the form of a proposed action enclosed in a <suggest> tag.\nExample: <suggest>Show on a map</suggest>\n\n### Multiple choice questions\n\nYou may ask multiple choice questions by wrapping consise options inside <option> tags inside a well formed <select> tag.\nExample: <select><option>Yes</option><option>No</option></select>\n\n## Toolkit\n\nIf the user asks for a list of tools, then just emit a single self-closing <toolkit/> tag instead of listing the tools.\n", "{{! System Prompt }}\n\nYou are a helpful assistant called Kai. \nYour name is Kai and you are powered by different language models.\nYou were created by DXOS and operate in Composer and on the DXOS EDGE network.\nIn your initial greeting state your name and make some suggestions based on the current context objects.\n\nYou are an advanced AI assistant capable of creating and managing artifacts from provided data and tools.\nYour task is to process user commands and questions and decide how best to respond.\nIn general be concise and direct.\n\nFollow these guidelines carefully:\n\nInclude the following steps:\n\n- Analyze the structure and type of the content in the user's message.\n- Determine if you complete the task using the available blueprint definitions?\n- If you can't complete the task using the available blueprint definitions, query the list of available blueprint definitions using the appropriate tool.\n- Identify which blueprint definitions are relevant to the user's request.\n- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.\n- Make a final decision on whether to create an artifact and explain your reasoning.\n- Are the required blueprint definitions already available?\n- If not, select which blueprint definition(s) will be the most relevant and require them using the require_artifact_definitions tool.\n- The require'd artifact tools will be available for use after require.\n- If creating an artifact, outline how you will structure it within the response.\n- Decide if the artifact needs to be shown to the user.\n- Call the show tool to show the artifact to the user.\n- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.\n\n# Blueprints\n\n- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.\n- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.\n- If it is ambiguous, query for existing artifacts first and then decide.\n- If you decide to create an artifact, call the associated tool to create the artifact.\n- Artifacts are stored in the database. Tools are used to create and query artifacts.\n- If you are unsure about creating an artifact ask the user for clarification.\n\n- Artifacts are mutable objects that can change over the course of the conversation.\n- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.\n- You must never generate the id of the artifact; only recall the ids that are already in the history.\n- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.\n\n- You can add suggested actions at the end of your response.\n- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.\n- Suggested actions must be in the form of a user instruction that you can follow.\n- Suggested actions could include actions that create artifacts.\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { type ObjectId } from '@dxos/echo-schema';\nimport { DXN, LOCAL_SPACE_TAG, type SpaceId } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\n/**\n * @deprecated\n */\nexport const createArtifactElement = (id: ObjectId) => `<artifact id=${id} />`;\n\n/**\n * A model-friendly way to reference an object.\n * Supports vairous formats that will be normalized to a DXN.\n */\n// TODO(burdon): Rename ObjectReference?\nexport const ArtifactId: Schema.Schema<string> & {\n toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;\n} = class extends Schema.String.annotations({\n description: trim`\n The ID of the referenced object. Formats accepted:\n - DXN (dxn:echo:@:XXXXX). DXNs can be prepended with an @ symbol for compatibility with in-text references.\n - space ID, object ID tuple (spaceID:objectID)\n - Only object ID that is assumed to be in the current space (XXXXX)\n `,\n examples: ['dxn:echo:@:XXXXX', '@dxn:echo:@:XXXXX', 'spaceID:objectID', 'XXXXX'],\n}) {\n static toDXN(reference: ArtifactId, owningSpaceId?: SpaceId): DXN {\n // Allow @dxn: prefix for compatibility with in-text references.\n if (reference.startsWith('@dxn:')) {\n return DXN.parse(reference.slice(1));\n } else if (reference.startsWith('dxn:')) {\n return DXN.parse(reference);\n } else if (/^[A-Z0-9]+:[A-Z0-9]+$/.test(reference)) {\n const [spaceId, objectId] = reference.split(':');\n // This is a workaround because the current Filter API doesn't work with fully qualified Echo DXNs.\n // We check if the space ID is the same as the owning space and then use LOCAL_SPACE_TAG for local references.\n // TODO(dmaretskyi): Fix this in the Echo and Filter API to properly handle fully qualified DXNs.\n return new DXN(DXN.kind.ECHO, [spaceId === owningSpaceId ? LOCAL_SPACE_TAG : spaceId, objectId]);\n } else if (/^[A-Z0-9]+$/.test(reference)) {\n return DXN.fromLocalObjectId(reference);\n } else {\n throw new Error(`Unable to parse object reference: ${reference}`);\n }\n }\n};\n\nexport type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,SAA8BA,gBAAgB;AAC9C,SAASC,cAAc;AACvB,SAASC,OAAOC,YAAY;AAE5B,SAASC,iBAAiB;AAC1B,SAASC,KAA8BC,YAAY;AAEnD,SAASC,kBAAkB;AAMpB,IAAMC,iBAAiBC,OAAOC,OAAO;EAC1CC,YAAYF,OAAOC,OAAO;IACxBE,OAAOH,OAAOI,MAAMC,KAAKC,IAAIC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GAAA;AAI5C,aAAO,IAAIN,IAAIA,IAAIO,KAAKC,MAAM;QAACJ,YAAYN,gBAAgBW,kBAAkBL;QAASC;OAAS;IACjG,WAAW,cAAcF,KAAKN,SAAAA,GAAY;AACxC,aAAOG,IAAIU,kBAAkBb,SAAAA;IAC/B,OAAO;AACL,YAAM,IAAIc,MAAM,qCAAqCd,SAAAA,EAAW;IAClE;EACF;AACF;",
|
|
6
|
-
"names": ["computed", "
|
|
3
|
+
"sources": ["../../../src/conversation/context.ts", "../../../src/conversation/conversation.ts", "../../../src/session/artifact-diff.ts", "../../../src/session/observer.ts", "../../../src/session/session.ts", "../../../src/session/format.ts", "../../../src/errors.ts", "../../../src/session/toolkit.ts", "../../../src/session/version-pin.ts", "../../../src/session/GenericToolkit.ts", "../../../src/diff.ts", "../../../src/execution-graph.ts", "../../../src/functions/services.ts", "../../../src/templates/system.ts", "raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/format.tpl?raw", "raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/system.tpl?raw", "../../../src/types/artifact.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReadonlySignal, computed } from '@preact/signals-core';\nimport * as Array from 'effect/Array';\nimport * as Context from 'effect/Context';\nimport * as Function from 'effect/Function';\nimport * as Schema from 'effect/Schema';\n\nimport { Blueprint } from '@dxos/blueprints';\nimport { Resource } from '@dxos/context';\nimport { DXN, Filter, Obj, Query, type Ref, type Relation, Type } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { invariant } from '@dxos/invariant';\nimport { ComplexSet } from '@dxos/util';\n\n/**\n * Thread message that binds or unbinds contextual objects to a conversation.\n */\n// TODO(burdon): Move to @dxos/schema ContentBlock?\nexport const ContextBinding = Schema.Struct({\n blueprints: Schema.Struct({\n added: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n removed: Schema.Array(Type.Ref(Blueprint.Blueprint)),\n }),\n\n // TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)\n objects: Schema.Struct({\n added: Schema.Array(Type.Ref(Type.Expando)),\n removed: Schema.Array(Type.Ref(Type.Expando)),\n }),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/ContextBinding',\n version: '0.1.0',\n }),\n);\n\nexport interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {}\n\nexport type BindingProps = Partial<{\n blueprints: Ref.Ref<Blueprint.Blueprint>[];\n objects: Ref.Ref<Type.Expando>[];\n}>;\n\nexport class Bindings {\n readonly blueprints = new ComplexSet<Ref.Ref<Blueprint.Blueprint>>((ref) => ref.dxn.toString());\n // TODO(burdon): Some DXNs have the Space prefix so only compare the object ID.\n readonly objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.asEchoDXN()?.echoId);\n\n toJSON() {\n return {\n blueprints: Array.fromIterable(this.blueprints).map((ref) => ref.dxn.toString()),\n objects: Array.fromIterable(this.objects).map((ref) => ref.dxn.toString()),\n };\n }\n}\n\n/**\n * Manages bindings of blueprints and objects to a conversation.\n */\n// TODO(burdon): Context should manage ephemeral state of bindings until prompt is issued?\nexport class AiContextBinder extends Resource {\n /**\n * Reactive query of all bindings.\n */\n // TODO(burdon): Cache value?\n private _bindings?: ReadonlySignal<Bindings>;\n private _blueprints?: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]>;\n private _objects?: ReadonlySignal<Ref.Ref<Type.Expando>[]>;\n\n constructor(private readonly _queue: Queue) {\n super();\n }\n\n get bindings() {\n invariant(this._bindings, 'AiContextBinder not open');\n return this._bindings;\n }\n\n get blueprints() {\n invariant(this._blueprints, 'AiContextBinder not open');\n return this._blueprints;\n }\n\n get objects() {\n invariant(this._objects, 'AiContextBinder not open');\n return this._objects;\n }\n\n // TODO(wittjosiah): Use parent context?\n protected override async _open(): Promise<void> {\n const query = this._queue.query(Query.select(Filter.everything()));\n this._ctx.onDispose(query.subscribe(() => {}));\n this._bindings = computed(() => this._reduce(query.objects));\n this._blueprints = computed(() => [...this.bindings.value.blueprints]);\n this._objects = computed(() => [...this.bindings.value.objects]);\n }\n\n protected override async _close(): Promise<void> {\n this._bindings = undefined;\n this._blueprints = undefined;\n this._objects = undefined;\n }\n\n /**\n * Asynchronous query of all bindings.\n */\n async query(): Promise<Bindings> {\n const { objects } = await this._queue.query(Query.select(Filter.everything())).run();\n return this._reduce(objects);\n }\n\n // TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.\n async bind(props: BindingProps): Promise<void> {\n const blueprints =\n props.blueprints?.filter((ref) => !this.blueprints.peek().find((b) => b.dxn.toString() === ref.dxn.toString())) ??\n [];\n const objects =\n props.objects?.filter((ref) => !this.objects.peek().find((o) => o.dxn.toString() === ref.dxn.toString())) ?? [];\n\n if (!blueprints.length && !objects.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: blueprints,\n removed: [],\n },\n objects: {\n added: objects,\n removed: [],\n },\n }),\n ]);\n }\n\n async unbind(props: BindingProps): Promise<void> {\n if (!props.blueprints?.length && !props.objects?.length) {\n return;\n }\n\n await this._queue.append([\n Obj.make(ContextBinding, {\n blueprints: {\n added: [],\n removed: props.blueprints ?? [],\n },\n objects: {\n added: [],\n removed: props.objects ?? [],\n },\n }),\n ]);\n }\n\n private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {\n return Function.pipe(\n items,\n Array.filter(Obj.instanceOf(ContextBinding)),\n Array.reduce(new Bindings(), (context, item) => {\n item.blueprints.removed.forEach((ref) => context.blueprints.delete(ref));\n item.blueprints.added.forEach((ref) => context.blueprints.add(ref));\n item.objects.removed.forEach((ref) => {\n for (const obj of context.objects) {\n if (DXN.equalsEchoId(obj.dxn, ref.dxn)) {\n context.objects.delete(obj);\n }\n }\n });\n item.objects.added.forEach((ref) => context.objects.add(ref));\n return context;\n }),\n );\n }\n}\n\nexport class AiContextService extends Context.Tag('@dxos/assistant/AiContextService')<\n AiContextService,\n {\n binder: AiContextBinder;\n }\n>() {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Toolkit from '@effect/ai/Toolkit';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Resource } from '@dxos/context';\nimport { Obj } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { DatabaseService } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { Message } from '@dxos/types';\n\nimport {\n AiSession,\n type AiSessionRunError,\n type AiSessionRunRequirements,\n type GenerationObserver,\n createToolkit,\n} from '../session';\n\nimport { AiContextBinder, AiContextService, type ContextBinding } from './context';\n\nexport interface AiConversationRunParams {\n prompt: string;\n system?: string;\n observer?: GenerationObserver;\n}\n\n/**\n * Durable conversation state (initiated by users and agents) backed by a Queue.\n * Executes tools based on AI responses and supports cancellation of in-progress requests.\n */\nexport class AiConversation extends Resource {\n /**\n * Message and binding queue.\n */\n private readonly _queue: Queue<Message.Message | ContextBinding>;\n\n /**\n * Blueprints bound to the conversation.\n */\n private readonly _context: AiContextBinder;\n\n /**\n * Toolkit from the current session request.\n */\n private _toolkit: Toolkit.WithHandler<any> | undefined;\n\n public constructor(queue: Queue<Message.Message | ContextBinding>) {\n super();\n this._queue = queue;\n this._context = new AiContextBinder(this._queue);\n }\n\n protected override async _open(): Promise<void> {\n // TODO(wittjosiah): Pass in parent context?\n await this._context.open();\n }\n\n protected override async _close(): Promise<void> {\n await this._context.close();\n }\n\n public get context() {\n return this._context;\n }\n\n public get toolkit() {\n return this._toolkit;\n }\n\n public async getHistory(): Promise<Message.Message[]> {\n const queueItems = await this._queue.queryObjects();\n return queueItems.filter(Obj.instanceOf(Message.Message));\n }\n\n /**\n * Creates a new cancelable request effect.\n */\n createRequest(\n params: AiConversationRunParams,\n ): Effect.Effect<Message.Message[], AiSessionRunError, AiSessionRunRequirements> {\n return Effect.gen(this, function* () {\n const session = new AiSession();\n const history = yield* Effect.promise(() => this.getHistory());\n\n // Get context objects.\n const context = yield* Effect.promise(() => this.context.query());\n const blueprints = yield* Effect.forEach(context.blueprints.values(), DatabaseService.loadOption).pipe(\n Effect.map(Array.filter(Option.isSome)),\n Effect.map(Array.map((option) => option.value)),\n );\n const objects = yield* Effect.forEach(context.objects.values(), DatabaseService.loadOption).pipe(\n Effect.map(Array.filter(Option.isSome)),\n Effect.map(Array.map((option) => option.value)),\n );\n\n // Create toolkit.\n const toolkit = yield* createToolkit({ blueprints });\n this._toolkit = toolkit;\n\n const start = Date.now();\n log('run', {\n history: history.length,\n blueprints: blueprints.length,\n objects: objects.length,\n tools: this._toolkit?.tools.length ?? 0,\n });\n\n // Process request.\n const messages = yield* session.run({ history, blueprints, objects, toolkit, ...params }).pipe(\n Effect.provideService(AiContextService, {\n binder: this.context,\n }),\n );\n\n log('result', { messages: messages.length, duration: Date.now() - start });\n\n // Append to queue.\n yield* Effect.promise(() => this._queue.append(messages));\n return messages;\n }).pipe(Effect.withSpan('AiConversation.request'));\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\n\nimport { type ObjectId } from '@dxos/echo/internal';\nimport { type ObjectVersion } from '@dxos/echo-db';\n\n/**\n * Resolves artifact ids to their versions.\n * Used to give the model a sense of the changes to the artifacts made by users during the conversation.\n * The artifacts versions are pinned in the history, and whenever the artifact changes in-between assistant's steps,\n * a diff is inserted into the conversation.\n *\n * Can be optionally provided to the session run call.\n */\n// TODO(dmaretskyi): Convert to Context.Reference\nexport class ArtifactDiffResolver extends Context.Tag('@dxos/assistant/ArtifactDiffResolver')<\n ArtifactDiffResolver,\n ArtifactDiffResolver.Service\n>() {}\n\nexport namespace ArtifactDiffResolver {\n export type Service = {\n resolve: (\n artifacts: {\n id: ObjectId;\n lastVersion: ObjectVersion;\n }[],\n ) => Promise<\n Map<\n ObjectId,\n {\n version: ObjectVersion;\n diff?: string;\n }\n >\n >;\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport { type AiParser, type ConsolePrinter } from '@dxos/ai';\nimport { type Message } from '@dxos/types';\n\n/**\n * Live observer of the generation process.\n */\nexport interface GenerationObserver extends AiParser.ParseResponseCallbacks {\n /**\n * Complete messages fired during the session, both from the model and from the user.\n * This message will contain all message blocks emitted through the `onBlock` callback.\n */\n onMessage: (message: Message.Message) => Effect.Effect<void>;\n}\n\nexport const GenerationObserver = Object.freeze({\n make: ({\n onBegin = Function.constant(Effect.void),\n onPart = Function.constant(Effect.void),\n onBlock = Function.constant(Effect.void),\n onEnd = Function.constant(Effect.void),\n onMessage = Function.constant(Effect.void),\n }: Partial<GenerationObserver> = {}): GenerationObserver => ({\n onBegin,\n onPart,\n onBlock,\n onEnd,\n onMessage,\n }),\n\n noop: () => GenerationObserver.make(),\n\n /**\n * Debug printer to be used in unit-tests and browser devtools.\n */\n fromPrinter: (printer: ConsolePrinter) =>\n GenerationObserver.make({\n onBlock: (block) =>\n Effect.sync(() => {\n if (block.pending) {\n return; // Only prints full blocks (better for unit-tests and browser devtools).\n }\n printer.printContentBlock(block);\n }),\n onMessage: (message) =>\n Effect.sync(() => {\n if (message.sender.role === 'assistant') {\n return; // Skip assistant messages since they are printed in the `onBlock` callback.\n }\n printer.printMessage(message);\n }),\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as AiError from '@effect/ai/AiError';\nimport * as LanguageModel from '@effect/ai/LanguageModel';\nimport type * as Tool from '@effect/ai/Tool';\nimport type * as Toolkit from '@effect/ai/Toolkit';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport type * as Schema from 'effect/Schema';\nimport * as Stream from 'effect/Stream';\n\nimport {\n AiParser,\n AiPreprocessor,\n type AiToolNotFoundError,\n type PromptPreprocessingError,\n type ToolExecutionService,\n type ToolResolverService,\n callTool,\n getToolCalls,\n} from '@dxos/ai';\nimport { type Blueprint } from '@dxos/blueprints';\nimport { todo } from '@dxos/debug';\nimport { Obj } from '@dxos/echo';\nimport { TracingService } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { Message } from '@dxos/types';\n\nimport { type AiAssistantError } from '../errors';\n\nimport { formatSystemPrompt, formatUserPrompt } from './format';\nimport { GenerationObserver } from './observer';\n\nexport type AiSessionRunError = AiError.AiError | PromptPreprocessingError | AiToolNotFoundError | AiAssistantError;\n\nexport type AiSessionRunRequirements =\n | LanguageModel.LanguageModel\n | ToolExecutionService\n | ToolResolverService\n | TracingService;\n\nexport type AiSessionRunParams<Tools extends Record<string, Tool.Any>> = {\n prompt: string;\n // TODO(wittjosiah): Rename to systemPrompt.\n system?: string;\n history?: Message.Message[];\n objects?: Obj.Any[];\n blueprints?: Blueprint.Blueprint[];\n toolkit?: Toolkit.WithHandler<Tools>;\n observer?: GenerationObserver;\n};\n\nexport type AiSessionOptions = {};\n\n/**\n * Contains message history, tools, current context.\n * Current context means the state of the app, time of day, and other contextual information.\n * It makes requests to the model, its a state machine.\n * It keeps track of the current goal.\n * It manages the context window.\n * Tracks the success criteria of reaching the goal, exposing metrics (stretch).\n * Could be run locally in the app or remotely.\n * Could be personal or shared.\n */\nexport class AiSession {\n /** Prevents concurrent execution of session. */\n private readonly _semaphore = Effect.runSync(Effect.makeSemaphore(1));\n\n /** Message history from queue. */\n // TODO(burdon): Evolve into supporting a git-like graph of messages.\n private _history: Message.Message[] = [];\n\n /** Pending messages for this session (incl. the current prompt). */\n private _pending: Message.Message[] = [];\n\n constructor(private readonly _options: AiSessionOptions = {}) {}\n\n run = <Tools extends Record<string, Tool.Any>>({\n prompt,\n system: systemTemplate,\n history = [],\n objects = [],\n blueprints = [],\n toolkit,\n observer = GenerationObserver.noop(),\n }: AiSessionRunParams<Tools>): Effect.Effect<Message.Message[], AiSessionRunError, AiSessionRunRequirements> =>\n Effect.gen(this, function* () {\n this._history = [...history];\n this._pending = [];\n const pending = this._pending;\n\n const submitMessage = Effect.fnUntraced(function* (message: Message.Message) {\n pending.push(message);\n yield* observer.onMessage(message);\n yield* TracingService.emitConverationMessage(message);\n return message;\n });\n\n // Submit the prompt.\n // TODO(burdon): Remove if cancelled?\n const promptMessage = yield* submitMessage(yield* formatUserPrompt({ prompt, history }));\n\n // Generate system and prompt messages.\n const system = yield* formatSystemPrompt({ system: systemTemplate, blueprints, objects });\n\n // Tool call loop.\n do {\n log('request', {\n prompt: promptMessage,\n system: { snippet: createSnippet(system), length: system.length },\n pending: this._pending.length,\n history: this._history.length,\n objects: objects?.length ?? 0,\n });\n\n const prompt = yield* AiPreprocessor.preprocessPrompt([...this._history, ...this._pending], { system });\n\n // Execute the stream request.\n // logDump('prompt', Prompt.Prompt.pipe(Schema.encodeSync)(prompt));\n const blocks = yield* LanguageModel.streamText({\n prompt,\n toolkit,\n disableToolCallResolution: true,\n }).pipe(\n // TOOD(dmaretskyi): Error mapping.\n AiParser.parseResponse({\n onBegin: () => observer.onBegin(),\n onBlock: (block) => observer.onBlock(block),\n onPart: (part) => observer.onPart(part),\n onEnd: (summary) => observer.onEnd(summary),\n }),\n Stream.runCollect,\n Effect.map(Chunk.toArray),\n );\n\n // Create the response message.\n const response = yield* submitMessage(\n Obj.make(Message.Message, {\n created: new Date().toISOString(),\n sender: { role: 'assistant' },\n blocks,\n }),\n );\n\n // Parse the response for tool calls.\n const toolCalls = getToolCalls(response);\n if (toolCalls.length === 0) {\n break;\n } else if (!toolkit) {\n throw new Error('No toolkit provided'); // TODO(burdon): Throw user error?\n }\n\n // Execute the tool calls.\n // TODO(burdon): Retry errors? Write result when each completes individually?\n const toolResults = yield* Effect.forEach(toolCalls, (toolCall) => {\n return callTool(toolkit, toolCall).pipe(\n Effect.provide(\n TracingService.layerSubframe((context) => ({\n ...context,\n parentMessage: response.id,\n toolCallId: toolCall.toolCallId,\n })),\n ),\n );\n });\n\n // Add to queue and continue loop.\n // TODO(wittjosiah): Sometimes tool error results are added to the queue before the tool agent statuses.\n // This results in a broken execution graph.\n yield* submitMessage(\n Obj.make(Message.Message, {\n created: new Date().toISOString(),\n sender: { role: 'tool' },\n blocks: toolResults,\n }),\n );\n } while (true);\n\n log('done', { pending: this._pending.length });\n return this._pending;\n }).pipe(this._semaphore.withPermits(1), Effect.withSpan('AiSession.run'));\n\n /**\n * @deprecated\n */\n // TODO(burdon): Implement or remove.\n async runStructured<S extends Schema.Schema.AnyNoContext>(\n _schema: S,\n _options: AiSessionRunParams<any>,\n ): Promise<Schema.Schema.Type<S>> {\n return todo();\n // const parser = structuredOutputParser(schema);\n // const result = await this.run({\n // ...options,\n // executableTools: [...(options.executableTools ?? []), parser.tool],\n // });\n // return parser.getResult(result);\n }\n}\n\nconst createSnippet = (text: string, len = 32) =>\n text.length <= len * 2 ? text : [text.slice(0, len), '...', text.slice(-len)].join('');\n\n// TODO(dmaretskyi): Extract as a general util.\nconst logDump = (message: string, data: unknown) => {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { writeFileSync } = require('node:fs');\n const path = `/tmp/log-data-${Date.now()}.json`;\n writeFileSync(path, JSON.stringify(data, null, 2));\n log.info(message, { path });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\n\nimport { Template } from '@dxos/blueprints';\nimport { Obj } from '@dxos/echo';\nimport { type ObjectId } from '@dxos/echo/internal';\nimport { DatabaseService, ObjectVersion } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { type ContentBlock, Message } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nimport { AiAssistantError } from '../errors';\n\nimport { ArtifactDiffResolver } from './artifact-diff';\nimport { type AiSessionRunError, type AiSessionRunParams } from './session';\n\n/**\n * Formats the system prompt.\n */\n// TODO(burdon): Move to AiPreprocessor.\nexport const formatSystemPrompt = ({\n system,\n blueprints = [],\n objects = [],\n}: Pick<AiSessionRunParams<any>, 'system' | 'blueprints' | 'objects'>) =>\n Effect.gen(function* () {\n const blueprintDefs = yield* Function.pipe(\n blueprints,\n Effect.forEach((blueprint) => Effect.succeed(blueprint.instructions)),\n Effect.flatMap(Effect.forEach((template) => DatabaseService.loadOption(template.source))),\n Effect.map(Array.filter(Option.isSome)),\n Effect.map(\n Array.map(\n (template) => trim`\n <blueprint>\n ${Template.process(template.value.content)}\n </blueprint>\n `,\n ),\n ),\n Effect.map((blueprints) =>\n blueprints.length > 0 ? ['## Blueprints Definitions', ...blueprints].join('\\n\\n') : undefined,\n ),\n );\n\n const objectDefs = yield* Function.pipe(\n objects,\n Effect.forEach((object) =>\n Effect.succeed(trim`\n <object>\n <dxn>${Obj.getDXN(object)}</dxn>\n <typename>${Obj.getTypename(object)}</typename>\n </object>\n `),\n ),\n Effect.map((objects) => (objects.length > 0 ? ['## Context Objects', ...objects].join('\\n\\n') : undefined)),\n );\n\n return yield* Function.pipe(\n Effect.succeed([system, blueprintDefs, objectDefs].filter((def): def is string => def !== undefined)),\n Effect.map((parts) => parts.join('\\n\\n')),\n );\n });\n\n/**\n * Formats the user prompt.\n */\n// TODO(burdon): Move to AiPreprocessor.\n// TODO(burdon): Convert util below to `Effect.fn` (to preserve stack info)\nexport const formatUserPrompt = ({\n prompt,\n history = [],\n}: Pick<AiSessionRunParams<any>, 'prompt' | 'history'>): Effect.Effect<Message.Message, AiSessionRunError> =>\n Effect.gen(function* () {\n const blocks: ContentBlock.Any[] = [];\n\n // TODO(dmaretskyi): Evaluate other approaches as `serviceOption` isn't represented in the type system.\n const artifactDiffResolver = yield* Effect.serviceOption(ArtifactDiffResolver);\n if (Option.isSome(artifactDiffResolver)) {\n const versions = gatherObjectVersions(history);\n const artifactDiff = yield* Effect.tryPromise({\n try: () =>\n artifactDiffResolver.value.resolve(\n [...versions.entries()].map(([id, version]) => ({ id, lastVersion: version })),\n ),\n catch: AiAssistantError.wrap({ message: 'Artifact diff resolution error' }),\n });\n\n log('version', { artifactDiff, versions });\n for (const [id, { version }] of [...artifactDiff.entries()]) {\n if (ObjectVersion.equals(version, versions.get(id)!)) {\n artifactDiff.delete(id);\n continue;\n }\n\n blocks.push({ _tag: 'anchor', objectId: id, version });\n }\n\n if (artifactDiff.size > 0) {\n blocks.push(createArtifactUpdateBlock(artifactDiff));\n }\n }\n\n return Obj.make(Message.Message, {\n created: new Date().toISOString(),\n sender: { role: 'user' },\n blocks: [...blocks, { _tag: 'text', text: prompt }],\n });\n });\n\nconst gatherObjectVersions = (messages: Message.Message[]): Map<ObjectId, ObjectVersion> => {\n const artifactIds = new Map<ObjectId, ObjectVersion>();\n for (const message of messages) {\n for (const block of message.blocks) {\n if (block._tag === 'anchor') {\n artifactIds.set(block.objectId, block.version as ObjectVersion);\n }\n }\n }\n\n return artifactIds;\n};\n\nconst createArtifactUpdateBlock = (\n artifactDiff: Map<ObjectId, { version: ObjectVersion; diff?: string }>,\n): ContentBlock.Any => {\n return {\n _tag: 'text',\n // TODO(dmaretskyi): Does this need to be a special content-block?\n disposition: 'artifact-update',\n text: trim`\n The following artifacts have been updated since the last message:\n ${[...artifactDiff.entries()]\n .map(([id, { diff }]) => `<changed-artifact id=\"${id}\">${diff ? `\\n${diff}` : ''}</changed-artifact>`)\n .join('\\n')}\n `,\n };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError } from '@dxos/errors';\n\n/**\n * Generic error from AI model.\n */\nexport class AiModelError extends BaseError.extend('AI_MODEL_ERROR', 'AI model error') {}\n\n/**\n * Generic error for AI agent execution.\n */\nexport class AiAssistantError extends BaseError.extend('AI_ASSISTANT_ERROR', 'AI assistant error') {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Tool from '@effect/ai/Tool';\nimport * as Toolkit from '@effect/ai/Toolkit';\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nimport { type AiToolNotFoundError, ToolExecutionService, type ToolId, ToolResolverService } from '@dxos/ai';\nimport { type Blueprint } from '@dxos/blueprints';\nimport { isTruthy } from '@dxos/util';\n\nexport type ToolkitParams<Tools extends Record<string, Tool.Any>> = {\n toolkit?: Toolkit.Toolkit<Tools>;\n toolIds?: ToolId[];\n blueprints?: Blueprint.Blueprint[];\n};\n\n/**\n * Build a combined toolkit from the blueprint tools and the provided toolkit.\n */\nexport const createToolkit = <Tools extends Record<string, Tool.Any> = {}>({\n toolkit: toolkitParam,\n toolIds = [],\n blueprints = [],\n}: ToolkitParams<Tools>): Effect.Effect<\n Toolkit.WithHandler<any>,\n AiToolNotFoundError,\n ToolResolverService | ToolExecutionService | Tool.HandlersFor<Tools>\n> =>\n Effect.gen(function* () {\n const blueprintToolkit = yield* ToolResolverService.resolveToolkit([\n ...blueprints.flatMap(({ tools }) => tools),\n ...toolIds,\n ]);\n\n const blueprintToolkitHandler: Context.Context<Tool.HandlersFor<any>> = yield* blueprintToolkit.toContext(\n ToolExecutionService.handlersFor(blueprintToolkit),\n );\n\n const toolkit = Toolkit.merge(...[toolkitParam, blueprintToolkit].filter(isTruthy));\n return yield* toolkit.pipe(Effect.provide(blueprintToolkitHandler)) as any as Effect.Effect<\n Toolkit.WithHandler<any>,\n never,\n Tool.HandlersFor<Tools>\n >;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type AnyEchoObject, ObjectId } from '@dxos/echo/internal';\nimport { type ObjectVersion, getVersion } from '@dxos/echo-db';\nimport { type ContentBlock } from '@dxos/types';\n\n// TODO(dmaretskyi): Extract.\nconst ObjectVersionSchema = Schema.Unknown as Schema.Schema<ObjectVersion>;\n\nconst VersionPinSchema = Schema.Struct({\n // TODO(dmaretskyi): Use Ref when those support encoding.\n objectId: ObjectId,\n // TODO(dmaretskyi): Could be opaque.\n version: ObjectVersionSchema,\n});\n\n/**\n * Used to pin a specific version of an object during the course of a conversation.\n * This allows us to detect when the object changes during the course of the conversation.\n */\nexport interface VersionPin extends Schema.Schema.Type<typeof VersionPinSchema> {}\n\nexport const VersionPin: typeof VersionPinSchema & {\n DISPOSITION: 'version-pin';\n fromObject: (object: AnyEchoObject) => VersionPin;\n createBlock: (pin: VersionPin) => ContentBlock.Any;\n} = class extends VersionPinSchema {\n static readonly DISPOSITION = 'version-pin';\n static fromObject(object: AnyEchoObject): VersionPin {\n return VersionPin.make({\n objectId: object.id,\n version: getVersion(object),\n });\n }\n\n static createBlock(pin: VersionPin): ContentBlock.Any {\n return {\n _tag: 'json',\n disposition: VersionPin.DISPOSITION,\n data: JSON.stringify(pin),\n };\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Tool from '@effect/ai/Tool';\nimport * as Toolkit from '@effect/ai/Toolkit';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Pipeable from 'effect/Pipeable';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\n\n/**\n * Unique identifier for generic toolkit instances.\n */\nexport const TypeId = '~@dxos/assistant/GenericToolkit';\n\n/**\n * Type-level representation of the generic toolkit identifier.\n */\nexport type TypeId = typeof TypeId;\n\n/**\n * Type-safe way to define toolkits where we don't know specific types of tools,\n * and we want to bundle definition and handlers together.\n *\n * Usefull for plugin-based systems, where tools are dynamically added.\n *\n * @param TR requirements type to the tool invocation.\n * @param E failure type to the handlers layer.\n * @param R requirements type to the handlers layer.\n */\nexport interface GenericToolkit<TR = never, E = never, R = never> extends Pipeable.Pipeable {\n readonly [TypeId]: TypeId;\n\n /**\n * Toolkit definition.\n */\n readonly toolkit: Toolkit.Toolkit<GenericTools<TR>>;\n\n /**\n * Handlers layer.\n */\n readonly layer: Layer.Layer<unknown, E, R>;\n\n /**\n * Handlers effect.\n */\n readonly handlers: Effect.Effect<Toolkit.WithHandler<GenericTools<TR>>, E, R>;\n}\n\n/**\n * Generic constraint.\n *\n * NOTE: Only use in place of `T extends PortableToolkit.Any`. Not suitable for standalone use.\n */\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly toolkit: Toolkit.Toolkit<any>;\n readonly layer: Layer.Layer<unknown, any, any>;\n}\n\nexport type InvocationRequirements<T extends Any> = T extends GenericToolkit<infer TR, infer _E, infer _R> ? TR : never;\nexport type Failure<T extends Any> = T extends GenericToolkit<infer _TR, infer E, infer _R> ? E : never;\nexport type Requirements<T extends Any> = T extends GenericToolkit<infer _TR, infer _E, infer R> ? R : never;\n\n/**\n * Creates a portable toolkit from toolkit definition and handlers layer.\n */\nexport const make = <Tools extends Record<string, Tool.Any>, E, R>(\n toolkit: Toolkit.Toolkit<Tools>,\n layer: Layer.Layer<Tool.HandlersFor<Tools>, E, R>,\n): GenericToolkit<E, R> => {\n return {\n [TypeId]: TypeId,\n toolkit: toolkit as any,\n layer: layer as any,\n handlers: toolkit.pipe(Effect.provide(layer)) as any,\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n },\n };\n};\n\n/**\n * Merges multiple portable toolkits into a single portable toolkit.\n */\nexport const merge = <const Toolkits extends ReadonlyArray<Any>>(\n /**\n * The toolkits to merge together.\n */\n ...toolkits: Toolkits\n): GenericToolkit<\n InvocationRequirements<Toolkits[number]>,\n Failure<Toolkits[number]>,\n Requirements<Toolkits[number]>\n> => {\n return make(\n Toolkit.merge(...toolkits.map((t) => t.toolkit)),\n Layer.mergeAll(...(toolkits.map((t) => t.layer) as any)),\n ) as any;\n};\n\n/**\n * Generic tools type where we cannot statically enumerate individual tools.\n */\nexport type GenericTools<R = never> = Record<\n string,\n Tool.Tool<\n string,\n {\n readonly parameters: AnyStructSchemaNoContext;\n readonly success: Schema.Schema.AnyNoContext;\n readonly failure: typeof Schema.Never;\n },\n R\n >\n>;\n\nexport interface AnyStructSchemaNoContext extends Pipeable.Pipeable {\n readonly [Schema.TypeId]: any;\n readonly make: any;\n readonly Type: any;\n readonly Encoded: any;\n readonly Context: never;\n readonly ast: SchemaAST.AST;\n readonly fields: Schema.Struct.Fields;\n readonly annotations: any;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { next as A, type Doc } from '@automerge/automerge';\n\nimport { DocAccessor, toCursorRange } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { isNonNullable } from '@dxos/util';\n\n// Relevant info:\n// https://github.com/Minahil-official/GPT-4.1-Promting-Guide?tab=readme-ov-file#-apply-patch-tool-format-v4a-diff\n\n// TODO(burdon): Anthropic only.\n// https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool#example-str-replace-command\n// AI_TOOL_NOT_FOUND: str_replace_based_edit_tool\n// 'str_replace_based_edit_tool',\n\n// TOOD(burdon): Support append to end (no \"-\").\n\nexport type Diff = {\n match: string;\n replace: string;\n};\n\n/**\n * Convert a list of diffs into a list of operations.\n */\nexport const reduceDiffs = (diffs: readonly string[]): Diff[] => {\n return diffs.reduce<Diff[]>((acc, diff) => {\n const current = acc[acc.length - 1];\n const [op, ...rest] = diff.split(' ');\n switch (op) {\n case '-': {\n if (current && !current.match) {\n current.match += rest.join(' ');\n } else {\n acc.push({ match: rest.join(' '), replace: '' });\n }\n return acc;\n }\n case '+': {\n if (current && !current.replace) {\n current.replace += rest.join(' ');\n } else {\n acc.push({ match: '', replace: rest.join(' ') });\n }\n return acc;\n }\n }\n\n return acc;\n }, []);\n};\n\nexport const computeDiffsWithCursors = <T>(accessor: DocAccessor<T>, diffs: readonly string[]) => {\n return reduceDiffs(diffs)\n .map((diff) => {\n const text = DocAccessor.getValue<string>(accessor);\n const idx = text.indexOf(diff.match);\n if (idx !== -1) {\n return { cursor: toCursorRange(accessor, idx, idx + diff.match.length), text: diff.replace };\n }\n })\n .filter(isNonNullable);\n};\n\nexport const applyDiffs = <T>(accessor: DocAccessor<T>, diffs: readonly string[]): string => {\n for (const diff of reduceDiffs(diffs)) {\n accessor.handle.change((doc: Doc<T>) => {\n const text = DocAccessor.getValue<string>(accessor);\n const idx = text.indexOf(diff.match);\n if (idx !== -1) {\n // TODO(burdon): Replace smallest substring.\n // NOTE: This only replaces the first match.\n A.splice(doc, accessor.path as A.Prop[], idx, diff.match.length, diff.replace);\n } else {\n log.warn('diff not found', diff);\n }\n });\n }\n\n return DocAccessor.getValue<string>(accessor);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { AgentStatus } from '@dxos/ai';\nimport { Obj, type Ref } from '@dxos/echo';\nimport { MESSAGE_PROPERTY_TOOL_CALL_ID } from '@dxos/functions';\nimport { type ObjectId } from '@dxos/keys';\nimport { LogLevel } from '@dxos/log';\nimport { ContentBlock, Message } from '@dxos/types';\nimport { isNonNullable } from '@dxos/util';\n\nconst SKIP_BLOCKS: ContentBlock.Any['_tag'][] = ['text'];\n\n/**\n * Mercurial-style Commit.\n */\n// TODO(wittjosiah): Reconcile with @dxos/react-ui-components.\nexport type Commit = {\n id: string;\n parents: string[];\n branch: string;\n icon?: string;\n level?: LogLevel;\n message: string;\n timestamp?: Date;\n tags?: string[];\n};\n\n// TODO(burdon): Add colors?\nenum IconType {\n // General status.\n SUCCESS = 'ph--check-circle--regular',\n WARNING = 'ph--warning-circle--regular',\n ERROR = 'ph--x-circle--regular',\n FLAG = 'ph--flag--regular',\n ROCKET = 'ph--rocket--regular',\n TIMER = 'ph--timer--regular',\n\n // Interactions.\n USER = 'ph--user--regular',\n USER_INTERACTION = 'ph--user-sound--regular',\n AGENT = 'ph--robot--regular',\n THINKING = 'ph--brain--regular',\n LINK = 'ph--link--regular',\n TOOL = 'ph--wrench--regular',\n}\n\n/**\n * Models the execution graph based on a stream of events.\n */\nexport class ExecutionGraph {\n // TODO(dmaretskyi): Evolve the internal state to support chats, functions, circuit workflows, etc.\n private _commits: Commit[] = [];\n private _branchNames = new Set<string>();\n private _lastBlockId: string | undefined;\n\n // Tool call tracking.\n private _toolCallCommitIds = new Map<string, string>(); // toolCallId -> commitId\n private _lastCommitByBranch = new Map<string, string>(); // branch -> last commitId\n private _pendingToolResults = new Map<string, string>(); // toolCallId -> toolResultCommitId\n\n constructor(private readonly _skipBlocks: ContentBlock.Any['_tag'][] = SKIP_BLOCKS) {}\n\n /**\n * Adds events to the graph.\n */\n addEvents(events: Obj.Any[]) {\n const sortedEvents = this.sortObjectsByCreated(events);\n for (const event of sortedEvents) {\n if (Obj.instanceOf(Message.Message, event)) {\n this._processMessage(event);\n } else if (Obj.instanceOf(AgentStatus, event)) {\n this._processAgentStatus(event);\n }\n }\n }\n\n /**\n * Processes a message event and creates commits for its blocks.\n */\n private _processMessage(message: Message.Message) {\n const messageCommits = messageToCommits(\n message,\n this._lastBlockId,\n this._toolCallCommitIds,\n this._lastCommitByBranch,\n this._skipBlocks,\n );\n this._commits.push(...messageCommits);\n\n // Track branches.\n messageCommits.forEach((commit) => this._branchNames.add(commit.branch));\n\n // Track tool calls and update pending tool results.\n this._trackToolCalls(messageCommits);\n\n // Update last block ID for sequential chaining.\n if (messageCommits.length > 0) {\n this._lastBlockId = messageCommits[messageCommits.length - 1].id;\n }\n }\n\n /**\n * Processes an AgentStatus event.\n */\n private _processAgentStatus(event: AgentStatus) {\n const branch = this._getToolCallBranch(event.parentMessage, event.toolCallId);\n this._branchNames.add(branch);\n\n const agentStatusCommit: Commit = {\n id: event.id,\n branch,\n message: event.message,\n icon: IconType.FLAG,\n parents: this._getAgentStatusParents(event),\n timestamp: new Date(event.created),\n };\n\n this._commits.push(agentStatusCommit);\n\n // Update last block ID for sequential chaining.\n this._lastBlockId = event.id;\n\n // Update pending tool results to point to this AgentStatus.\n if (event.toolCallId) {\n this._lastCommitByBranch.set(branch, event.id);\n this._updatePendingToolResults(event.toolCallId, event.id);\n }\n }\n\n /**\n * Stable sort: objects with 'created' field are sorted by it, others remain in place.\n */\n private sortObjectsByCreated(objects: any[]) {\n const sortedObjects = objects.slice();\n // Find indices of objects with 'created'\n const createdObjects: { idx: number; obj: any }[] = [];\n sortedObjects.forEach((obj, idx) => {\n if (obj && typeof obj.created === 'string') {\n createdObjects.push({ idx, obj });\n }\n });\n // Sort only the objects with 'created' by their date, stable\n createdObjects.sort((a, b) => {\n const aDate = new Date(a.obj.created).getTime();\n const bDate = new Date(b.obj.created).getTime();\n return aDate - bDate;\n });\n // Place sorted createdObjects back into their original positions\n let createdIdx = 0;\n return sortedObjects.map((obj, _idx) => {\n if (obj && typeof obj.created === 'string') {\n return createdObjects[createdIdx++].obj;\n }\n return obj;\n });\n }\n\n /**\n * Returns the current state of the graph.\n */\n getGraph(lastRequest = false): { branches: string[]; commits: Commit[] } {\n const idx = lastRequest ? this._commits.findLastIndex((c) => c.tags?.includes('user')) : -1;\n const commits = idx === -1 ? this._commits : this._commits.slice(idx);\n\n return {\n branches: Array.from(this._branchNames),\n commits,\n };\n }\n\n /**\n * Tracks tool calls and handles pending tool result updates.\n */\n private _trackToolCalls(commits: Commit[]) {\n commits.forEach((commit) => {\n if (this._isToolCallCommit(commit)) {\n const toolCallId = this._extractToolCallId(commit.id);\n if (toolCallId) {\n this._toolCallCommitIds.set(toolCallId, commit.id);\n }\n }\n\n if (this._isToolResultCommit(commit)) {\n const toolCallId = this._extractToolCallId(commit.id);\n if (toolCallId) {\n this._pendingToolResults.set(toolCallId, commit.id);\n this._handleLateToolResultUpdate(toolCallId, commit.id);\n }\n }\n\n this._lastCommitByBranch.set(commit.branch, commit.id);\n });\n }\n\n /**\n * Updates pending tool results to point to an AgentStatus event.\n */\n private _updatePendingToolResults(toolCallId: string, agentStatusId: string) {\n const toolResultId = this._pendingToolResults.get(toolCallId);\n if (!toolResultId) return;\n\n const toolResultCommit = this._commits.find((c) => c.id === toolResultId);\n if (!toolResultCommit) return;\n\n const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);\n if (!toolCallCommitId) return;\n\n // Replace tool call commit with AgentStatus commit.\n const toolCallIndex = toolResultCommit.parents.indexOf(toolCallCommitId);\n if (toolCallIndex !== -1) {\n toolResultCommit.parents[toolCallIndex] = agentStatusId;\n }\n\n this._pendingToolResults.delete(toolCallId);\n }\n\n /**\n * Handles late updates when AgentStatus is processed before tool result.\n */\n private _handleLateToolResultUpdate(toolCallId: string, toolResultId: string) {\n const toolCallCommitId = this._toolCallCommitIds.get(toolCallId);\n if (!toolCallCommitId) return;\n\n const messageId = toolCallCommitId.split('_toolCall_')[0];\n const toolCallBranch = `${messageId}_${toolCallId}`;\n const agentStatusCommitId = this._lastCommitByBranch.get(toolCallBranch);\n\n if (agentStatusCommitId && agentStatusCommitId !== toolCallCommitId) {\n const toolResultCommit = this._commits.find((c) => c.id === toolResultId);\n if (toolResultCommit) {\n const toolCallIndex = toolResultCommit.parents.indexOf(toolCallCommitId);\n if (toolCallIndex !== -1) {\n toolResultCommit.parents[toolCallIndex] = agentStatusCommitId;\n }\n }\n this._pendingToolResults.delete(toolCallId);\n }\n }\n\n /**\n * Gets the branch name for a tool call.\n */\n private _getToolCallBranch(parentMessage?: ObjectId, toolCallId?: string): string {\n if (toolCallId) {\n return toolCallId;\n }\n return parentMessage || 'main';\n }\n\n /**\n * Gets the parents for an AgentStatus commit.\n */\n private _getAgentStatusParents(event: AgentStatus): string[] {\n if (event.parentMessage && event.toolCallId) {\n return [getToolCallId(event.parentMessage, event.toolCallId)];\n }\n return [];\n }\n\n /**\n * Checks if a commit is a tool call commit.\n */\n private _isToolCallCommit(commit: Commit): boolean {\n return commit.message.includes('Calling tool');\n }\n\n /**\n * Checks if a commit is a tool result commit.\n */\n private _isToolResultCommit(commit: Commit): boolean {\n return commit.message.includes('Tool call succeeded') || commit.message.includes('Tool error:');\n }\n\n /**\n * Extracts tool call ID from a commit ID.\n */\n private _extractToolCallId(commitId: string): string | undefined {\n const toolCallMatch = commitId.match(/_toolCall_(.+)$/);\n const toolResultMatch = commitId.match(/_toolResult_(.+)$/);\n return toolCallMatch?.[1] || toolResultMatch?.[1];\n }\n}\n\n/**\n * Creates commits for all blocks in a message.\n */\n// TODO(burdon): Pass in AiToolProvider.\nconst messageToCommits = (\n message: Message.Message,\n lastBlockId?: string,\n toolCallIds?: Map<string, string>,\n lastCommitByBranch?: Map<string, string>,\n skipBlocks?: ContentBlock.Any['_tag'][],\n): Commit[] => {\n let previousBlockId: string | undefined = lastBlockId;\n\n return message.blocks\n .map((block, idx) => {\n const branch = getMessageBranch(message);\n const parents = getBlockParents(block, previousBlockId, message, toolCallIds, lastCommitByBranch);\n if (skipBlocks?.includes(block._tag)) {\n return null;\n }\n\n const commit = createBlockCommit(block, message, branch, parents, idx);\n if (commit) {\n previousBlockId = commit.id;\n }\n\n return commit;\n })\n .filter(isNonNullable);\n};\n\n/**\n * Determines the parent commits for a block based on its type and context.\n */\nconst getBlockParents = (\n block: ContentBlock.Any,\n previousBlockId: string | undefined,\n message: Message.Message,\n toolCallIds?: Map<string, string>,\n lastCommitByBranch?: Map<string, string>,\n): string[] => {\n const parents: string[] = [];\n\n if (block._tag === 'toolResult') {\n // Tool results have two parents: previous block and last block from tool call branch.\n if (previousBlockId) {\n parents.push(previousBlockId);\n }\n\n const toolCallCommitId = toolCallIds?.get(block.toolCallId);\n if (toolCallCommitId) {\n const toolCallBranch = getToolCallBranchFromCommitId(toolCallCommitId, block.toolCallId);\n const lastBlockFromToolCallBranch = lastCommitByBranch?.get(toolCallBranch);\n\n if (lastBlockFromToolCallBranch) {\n parents.push(lastBlockFromToolCallBranch);\n } else {\n // Fallback to tool call commit if no AgentStatus exists yet.\n parents.push(toolCallCommitId);\n }\n }\n } else {\n // For other blocks, use previous block as parent (or tool call parent for first block).\n if (previousBlockId) {\n parents.push(previousBlockId);\n } else {\n const toolCallParent = getParentId(message);\n if (toolCallParent) {\n parents.push(toolCallParent);\n }\n }\n }\n\n return parents;\n};\n\n/**\n * Creates a commit for a specific block.\n */\nconst createBlockCommit = (\n block: ContentBlock.Any,\n message: Message.Message,\n branch: string,\n parents: string[],\n idx: number,\n): Commit | null => {\n const timestamp = new Date(message.created);\n switch (block._tag) {\n case 'text':\n if (!block.text.trim().length) return null;\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n ...(message.sender.role === 'user'\n ? {\n icon: IconType.USER,\n tags: ['user'],\n message: 'Processing request...',\n }\n : {\n icon: IconType.AGENT,\n message: `Response (${block.text.split(' ').length} words)`,\n }),\n } satisfies Commit;\n\n case 'toolCall':\n return {\n id: getToolCallId(message.id, block.toolCallId),\n branch,\n parents,\n timestamp,\n icon: IconType.TOOL,\n level: LogLevel.INFO,\n message: `Calling tool (${block.name})`,\n } satisfies Commit;\n\n case 'toolResult':\n return {\n id: getToolResultId(message.id, block.toolCallId),\n branch,\n parents,\n timestamp,\n icon: block.error ? IconType.ERROR : IconType.SUCCESS,\n level: block.error ? LogLevel.ERROR : LogLevel.INFO,\n message: block.error ? 'Tool error: ' + block.error : 'Tool call succeeded',\n } satisfies Commit;\n\n case 'summary':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n icon: IconType.ROCKET,\n level: LogLevel.INFO,\n message: ContentBlock.createSummaryMessage(block),\n } satisfies Commit;\n\n case 'status':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n message: block.statusText,\n level: LogLevel.INFO,\n icon: IconType.FLAG,\n } satisfies Commit;\n\n case 'reasoning':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n message: block.reasoningText ?? 'Thinking...',\n icon: IconType.THINKING,\n } satisfies Commit;\n\n case 'reference':\n return {\n id: getGenericBlockId(message.id, idx),\n branch,\n parents,\n timestamp,\n icon: IconType.LINK,\n message: stringifyRef(block.reference),\n } satisfies Commit;\n\n default:\n return null;\n }\n};\n\n/**\n * Gets the tool call branch name from a tool call commit ID.\n */\nconst getToolCallBranchFromCommitId = (toolCallCommitId: string, toolCallId: string): string => {\n const messageId = toolCallCommitId.split('_toolCall_')[0];\n return `${messageId}_${toolCallId}`;\n};\n\nconst getToolCallId = (messageId: ObjectId, toolCallId: string) => `${messageId}_toolCall_${toolCallId}`;\nconst getToolResultId = (messageId: ObjectId, toolCallId: string) => `${messageId}_toolResult_${toolCallId}`;\nconst getGenericBlockId = (messageId: ObjectId, idx: number) => `${messageId}_block_${idx}`;\n\nconst getBranchName = (options: { parentMessage?: ObjectId; toolCallId?: string }) => {\n if (options.toolCallId) {\n return options.toolCallId;\n } else if (options.parentMessage) {\n return options.parentMessage;\n } else {\n return 'main';\n }\n};\n\nconst getMessageBranch = (message: Message.Message) => {\n return getBranchName({\n parentMessage: message.parentMessage,\n toolCallId: message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID],\n });\n};\n\nconst getParentId = (message: Message.Message) => {\n if (message.parentMessage && message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]) {\n return getToolCallId(message.parentMessage, message.properties[MESSAGE_PROPERTY_TOOL_CALL_ID]);\n } else {\n return undefined;\n }\n};\n\nconst stringifyRef = (ref: Ref.Any) => {\n if (ref.target) {\n return stringifyObject(ref.target);\n }\n\n return ref.dxn.asEchoDXN()?.echoId ?? ref.dxn.asQueueDXN()?.objectId ?? '';\n};\n\nconst stringifyObject = (obj: Obj.Any) => {\n return Obj.getLabel(obj) ?? Obj.getTypename(obj) ?? obj.id;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Tool from '@effect/ai/Tool';\nimport type * as Toolkit from '@effect/ai/Toolkit';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Record from 'effect/Record';\nimport * as Schema from 'effect/Schema';\n\nimport { AiToolNotFoundError, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { todo } from '@dxos/debug';\nimport { Query } from '@dxos/echo';\nimport { DatabaseService } from '@dxos/echo-db';\nimport { Function, FunctionDefinition, FunctionInvocationService } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\n/**\n * Constructs a `ToolResolverService` whose `resolve(id)` looks up tools in the following order:\n * 1. Toolkit: return an existing tool from the provided `toolkit` if one is present under `id`.\n * 2. Functions in DB: query `FunctionType` by `key=id`; if found, deserialize and project to a tool\n * (propagating any `deployedFunctionId` discovered in the object's metadata).\n * 3. Functions passed in: fall back to a matching `FunctionDefinition` from the `functions` array.\n *\n * If none of the above yield a match, the effect fails with `AiToolNotFoundError`.\n *\n * Requires `DatabaseService` in the environment.\n */\nexport const makeToolResolverFromFunctions = (\n functions: FunctionDefinition.Any[],\n toolkit: Toolkit.Toolkit<any>,\n): Layer.Layer<ToolResolverService, never, DatabaseService> => {\n return Layer.effect(\n ToolResolverService,\n Effect.gen(function* () {\n const dbService = yield* DatabaseService;\n return {\n resolve: (id): Effect.Effect<Tool.Any, AiToolNotFoundError> =>\n Effect.gen(function* () {\n const tool = toolkit.tools[id];\n if (tool) {\n return tool;\n }\n\n const {\n objects: [dbFunction],\n } = yield* DatabaseService.runQuery(Query.type(Function.Function, { key: id }));\n\n const functionDef = dbFunction\n ? FunctionDefinition.deserialize(dbFunction)\n : functions.find((fn) => fn.key === id);\n\n if (!functionDef) {\n return yield* Effect.fail(new AiToolNotFoundError(id));\n }\n\n return projectFunctionToTool(functionDef);\n }).pipe(Effect.provideService(DatabaseService, dbService)),\n } satisfies Context.Tag.Service<ToolResolverService>;\n }),\n );\n};\n\nexport const makeToolExecutionServiceFromFunctions = (\n toolkit: Toolkit.Toolkit<any>,\n handlersLayer: Layer.Layer<Tool.Handler<any>, never, never>,\n): Layer.Layer<ToolExecutionService, never, FunctionInvocationService> => {\n return Layer.effect(\n ToolExecutionService,\n Effect.gen(function* () {\n const toolkitHandler = yield* toolkit.pipe(Effect.provide(handlersLayer));\n invariant(isHandlerLike(toolkitHandler));\n const functionInvocationService = yield* FunctionInvocationService;\n\n return {\n handlersFor: (toolkit) => {\n const makeHandler = (tool: Tool.Any): ((params: unknown) => Effect.Effect<unknown, any, any>) => {\n return Effect.fn(`toolFunctionHandler ${tool.name}`)(function* (input: any) {\n if (toolkitHandler.tools[tool.name]) {\n if (Tool.isProviderDefined(tool)) {\n throw new Error('Attempted to call a provider-defined tool');\n }\n // TODO(wittjosiah): Everything is `never` here.\n const { result } = yield* (toolkitHandler.handle as any)(tool.name, input);\n return result;\n }\n\n const { definition: functionDef } = Context.get(FunctionToolAnnotation)(tool.annotations as any);\n\n return yield* functionInvocationService\n .invokeFunction(functionDef, input as any)\n .pipe(Effect.catchAllDefect((defect) => Effect.fail(defect)));\n });\n };\n\n return toolkit.of(\n Record.map(toolkit.tools, (tool, _name) => (Tool.isUserDefined(tool) ? makeHandler(tool) : null)) as any,\n ) as any;\n },\n };\n }),\n );\n};\n\nclass FunctionToolAnnotation extends Context.Tag('@dxos/assistant/FunctionToolAnnotation')<\n FunctionToolAnnotation,\n { definition: FunctionDefinition.Any }\n>() {}\n\nconst toolCache = new WeakMap<FunctionDefinition.Any, Tool.Any>();\n\n/**\n * Projects a `FunctionDefinition` into an `AiTool`.\n *\n * @param fn The function definition to project into a tool.\n * @param meta Optional projection metadata.\n * @param meta.deployedFunctionId Backend deployment ID used for remote invocation when present.\n * This is the EDGE service's function deployment identifier (not the ECHO object ID/DXN and not `FunctionDefinition.key`).\n */\nconst projectFunctionToTool = (fn: FunctionDefinition.Any): Tool.Any => {\n if (toolCache.has(fn)) {\n return toolCache.get(fn)!;\n }\n\n // TODO(burdon): Use and map function.key?\n // TODO(dmaretskyi): Use function key instead.\n const tool = Tool.make(makeToolName(fn.name), {\n description: fn.description,\n parameters: createStructFieldsFromSchema(fn.inputSchema),\n // TODO(dmaretskyi): Include output schema.\n failure: Schema.Any, // TODO(dmaretskyi): Better type for the failure?\n }).annotate(FunctionToolAnnotation, { definition: fn });\n toolCache.set(fn, tool);\n return tool;\n};\n\n/**\n * @returns Tool name produced from function name by escaping invalid characters.\n */\nconst makeToolName = (name: string) => {\n const toolName = name.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-');\n invariant(toolName.match(/^[a-z_][a-z0-9-_]*$/));\n return toolName;\n};\n\n// TODO(dmaretskyi): Factor out.\nconst createStructFieldsFromSchema = (schema: Schema.Schema<any, any>): Record<string, Schema.Schema<any, any>> => {\n switch (schema.ast._tag) {\n case 'TypeLiteral':\n return Object.fromEntries(schema.ast.propertySignatures.map((prop) => [prop.name, Schema.make(prop.type)]));\n case 'VoidKeyword':\n return {};\n default:\n return todo(`Unsupported schema AST: ${schema.ast._tag}`);\n }\n};\n\nconst isHandlerLike = (value: unknown): value is Toolkit.WithHandler<Record<string, Tool.Any>> => {\n return typeof (value as any).tools === 'object' && typeof (value as any).handle === 'function';\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { type ModelCapabilities } from '@dxos/ai';\nimport { Template } from '@dxos/blueprints';\n\nimport FORMAT from './instructions/format.tpl?raw';\nimport SYSTEM from './instructions/system.tpl?raw';\n\n/**\n * System template variables.\n */\nexport type SystemPromptOptions = ModelCapabilities & {\n DATETIME: string;\n};\n\n/**\n * Base system prompt.\n * NOTE: This contains protocol instructions that can not be dynamically edited.\n */\nexport const createSystemPrompt = (options: Partial<SystemPromptOptions> = {}) =>\n Template.process<SystemPromptOptions>(\n FORMAT,\n defaultsDeep(options, {\n DATETIME: new Date().toISOString(),\n }),\n );\n\nexport const templates = {\n /** Editable system prompt.*/\n system: Template.make({\n /**\n * NOTE: We are forbidden from accessing randomness at model level in cloudflare, so we have to have pre-generated ids.\n */\n id: '01K2J2FZWH39F55CS7B26GP1Q3',\n source: SYSTEM,\n }),\n};\n", "{{! System Core }}\n\n## Input Formats\n\n### Blueprints\n\nYou may be provided with Blueprint definitions that include specific instructions and tools for a given set of tasks.\nBlue print instructions will be enclosed in a <blueprint> tag.\n\n### Context objects\n\nYou may be provided with references to objects that are relevant to the current prompt.\nObjects will be in the form of a <object> tag with a <dxn> element that is the unique key of the object required by many tools.\nThe <typename> element is the type of the object.\n\n<object>\n <dxn>object-id</dxn>\n <typename>example.com/type/TypeName</typename>\n</object>\n\n## Response Formats\n\nIt is very important to respond in the correct format.\nYou response must be valid Markdown.\nIn some cases you should respond with well-formed XML tags along with the content.\nCode snippets should use 2-space indents.\n\n{{#if cot}}\nBefore responding, explain your reasoning and include your detailed chain-of-thought enclosed in a <cot> tag.\nThe <cot> tag should be the first thing in your response.\n{{/if}}\n\n## Block references\n\nYou can reply with a block reference for objects if you have the DXN. For example:\n\n<object>\n <dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n<object>\n <dxn>dxn:echo:@:01K24XPK464FSCKVQJAB2H662M</dxn>\n</object>\n\n### Suggestions\n\nEach suggestion must in the form of a proposed action enclosed in a <suggestion> tag.\nExample: <suggestion>Show on a map</suggestion>\nDo not use bullets when listing suggestions.\n\n### Multiple choice questions\n\nYou may ask multiple choice questions by wrapping consise options inside <option> tags inside a well formed <select> tag.\nExample: <select><option>Yes</option><option>No</option></select>\n\n## Toolkit\n\nIf the user asks for a list of tools, then just emit a single self-closing <toolkit/> tag instead of listing the tools.\n\n## Context\n\nThe current date and time is {{DATETIME}}.\n", "{{! System Prompt }}\n\n- You are a helpful assistant called Kai. \n- Your name is Kai and you are powered by different language models.\n- You were created by DXOS and operate inside of Composer and on the DXOS EDGE network.\n- In your initial greeting state your name and make some suggestions based on the current context objects.\n- You are an advanced AI assistant capable of creating and managing artifacts from provided data and tools.\n- Your task is to process user commands and questions and decide how best to respond.\n- In general be concise and direct.\n- Follow all instructions carefully.\n\n## Planning\n\n- Analyze the structure and type of the content in the user's message.\n- Determine if you complete the task using the available blueprint definitions?\n- If you can't complete the task using the available blueprint definitions, query the list of available blueprint definitions using the appropriate tool.\n- Identify which blueprint definitions are relevant to the user's request.\n- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.\n- Make a final decision on whether to create an artifact and explain your reasoning.\n- Are the required blueprint definitions already available?\n- If not, select which blueprint definition(s) will be the most relevant and require them using the require_artifact_definitions tool.\n- The require'd artifact tools will be available for use after require.\n- If creating an artifact, outline how you will structure it within the response.\n- Decide if the artifact needs to be shown to the user.\n- Call the show tool to show the artifact to the user.\n- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.\n\n## Blueprints and Artifacts\n\n- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.\n- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.\n- If it is ambiguous, query for existing artifacts first and then decide.\n- If you decide to create an artifact, call the associated tool to create the artifact.\n- Artifacts are stored in the database. Tools are used to create and query artifacts.\n- If you are unsure about creating an artifact ask the user for clarification.\n- Artifacts are mutable objects that can change over the course of the conversation.\n- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.\n- You must never generate the id of the artifact; only recall the ids that are already in the history.\n- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.\n- You can add suggested actions at the end of your response.\n- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.\n- Suggested actions must be in the form of a user instruction that you can follow.\n- Suggested actions could include actions that create artifacts.\n- After creating an artifact use a tool to add it to the chat context.\n\n## Context\n\nToday is {{DATETIME}}.\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { type ObjectNotFoundError, type Type } from '@dxos/echo';\nimport { type ObjectId } from '@dxos/echo/internal';\nimport { DatabaseService } from '@dxos/echo-db';\nimport { DXN, LOCAL_SPACE_TAG, type SpaceId } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\n/**\n * @deprecated\n */\nexport const createArtifactElement = (id: ObjectId) => `<artifact id=${id} />`;\n\n/**\n * A model-friendly way to reference an object.\n * Supports vairous formats that will be normalized to a DXN.\n */\n// TODO(burdon): Rename RefFromLLM?\nexport const ArtifactId: Schema.Schema<string> & {\n toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;\n resolve: <S extends Type.Obj.Any | Type.Relation.Any>(\n schema: S,\n ref: ArtifactId,\n ) => Effect.Effect<Schema.Schema.Type<S>, ObjectNotFoundError, DatabaseService>;\n} = class extends Schema.String.annotations({\n // TODO(dmaretskyi): This section gets overriden.\n description: trim`\n The ID of the referenced object. Formats accepted:\n - DXN (dxn:echo:@:XXXXX). DXNs can be prepended with an @ symbol for compatibility with in-text references.\n - space ID, object ID tuple (spaceID:objectID)\n - Only object ID that is assumed to be in the current space (XXXXX)\n `,\n examples: ['dxn:echo:@:XXXXX', '@dxn:echo:@:XXXXX', 'spaceID:objectID', 'XXXXX'],\n}) {\n static toDXN(reference: ArtifactId, owningSpaceId?: SpaceId): DXN {\n // Allow @dxn: prefix for compatibility with in-text references.\n if (reference.startsWith('@dxn:')) {\n return DXN.parse(reference.slice(1));\n } else if (reference.startsWith('dxn:')) {\n return DXN.parse(reference);\n } else if (/^[A-Z0-9]+:[A-Z0-9]+$/.test(reference)) {\n const [spaceId, objectId] = reference.split(':');\n // This is a workaround because the current Filter API doesn't work with fully qualified Echo DXNs.\n // We check if the space ID is the same as the owning space and then use LOCAL_SPACE_TAG for local references.\n // TODO(dmaretskyi): Fix this in the Echo and Filter API to properly handle fully qualified DXNs.\n return new DXN(DXN.kind.ECHO, [spaceId === owningSpaceId ? LOCAL_SPACE_TAG : spaceId, objectId]);\n } else if (/^[A-Z0-9]+$/.test(reference)) {\n return DXN.fromLocalObjectId(reference);\n } else {\n throw new Error(`Unable to parse object reference: ${reference}`);\n }\n }\n\n /**\n * Resolves an artifact ID to an object.\n */\n static resolve<S extends Type.Obj.Any | Type.Relation.Any>(\n schema: S,\n ref: ArtifactId,\n ): Effect.Effect<Schema.Schema.Type<S>, ObjectNotFoundError, DatabaseService> {\n const dxn = ArtifactId.toDXN(ref);\n return DatabaseService.resolve(dxn, schema);\n }\n};\n\nexport type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAA8BA,gBAAgB;AAC9C,YAAYC,YAAW;AACvB,YAAYC,aAAa;AACzB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,KAAKC,QAAQC,KAAKC,OAAgCC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,KAAKC,MAAM;QAACJ,YAAYN,gBAAgBW,kBAAkBL;QAASC;OAAS;IACjG,WAAW,cAAcF,KAAKN,SAAAA,GAAY;AACxC,aAAOG,KAAIU,kBAAkBb,SAAAA;IAC/B,OAAO;AACL,YAAM,IAAIc,MAAM,qCAAqCd,SAAAA,EAAW;IAClE;EACF;;;;EAKA,OAAOe,QACLC,QACAC,KAC4E;AAC5E,UAAMC,MAAMzB,WAAWM,MAAMkB,GAAAA;AAC7B,WAAOE,iBAAgBJ,QAAQG,KAAKF,MAAAA;EACtC;AACF;",
|
|
6
|
+
"names": ["computed", "Array", "Context", "Function", "Schema", "Blueprint", "Resource", "DXN", "Filter", "Obj", "Query", "Type", "invariant", "ComplexSet", "ContextBinding", "Struct", "blueprints", "added", "Ref", "removed", "objects", "Expando", "pipe", "typename", "version", "Bindings", "ref", "dxn", "toString", "asEchoDXN", "echoId", "toJSON", "fromIterable", "map", "AiContextBinder", "_bindings", "_blueprints", "_objects", "_queue", "bindings", "_open", "query", "select", "everything", "_ctx", "onDispose", "subscribe", "_reduce", "value", "_close", "undefined", "run", "bind", "props", "filter", "peek", "find", "b", "o", "length", "append", "make", "unbind", "items", "instanceOf", "reduce", "context", "item", "forEach", "delete", "add", "obj", "equalsEchoId", "AiContextService", "Tag", "Array", "Effect", "Option", "Resource", "Obj", "DatabaseService", "log", "Message", "Context", "ArtifactDiffResolver", "Tag", "Effect", "Function", "GenerationObserver", "Object", "freeze", "make", "onBegin", "constant", "void", "onPart", "onBlock", "onEnd", "onMessage", "noop", "fromPrinter", "printer", "block", "sync", "pending", "printContentBlock", "message", "sender", "role", "printMessage", "LanguageModel", "Chunk", "Effect", "Stream", "AiParser", "AiPreprocessor", "callTool", "getToolCalls", "todo", "Obj", "TracingService", "log", "Message", "Array", "Effect", "Function", "Option", "Template", "Obj", "DatabaseService", "ObjectVersion", "log", "Message", "trim", "BaseError", "AiModelError", "BaseError", "extend", "AiAssistantError", "formatSystemPrompt", "system", "blueprints", "objects", "gen", "blueprintDefs", "pipe", "forEach", "blueprint", "succeed", "instructions", "flatMap", "template", "DatabaseService", "loadOption", "source", "map", "filter", "isSome", "trim", "Template", "process", "value", "content", "length", "join", "undefined", "objectDefs", "object", "Obj", "getDXN", "getTypename", "def", "parts", "formatUserPrompt", "prompt", "history", "blocks", "artifactDiffResolver", "serviceOption", "ArtifactDiffResolver", "versions", "gatherObjectVersions", "artifactDiff", "tryPromise", "try", "resolve", "entries", "id", "version", "lastVersion", "catch", "AiAssistantError", "wrap", "message", "log", "ObjectVersion", "equals", "get", "delete", "push", "_tag", "objectId", "size", "createArtifactUpdateBlock", "make", "Message", "created", "Date", "toISOString", "sender", "role", "text", "messages", "artifactIds", "Map", "block", "set", "disposition", "diff", "AiSession", "_semaphore", "runSync", "makeSemaphore", "_history", "_pending", "_options", "run", "prompt", "system", "systemTemplate", "history", "objects", "blueprints", "toolkit", "observer", "GenerationObserver", "noop", "gen", "pending", "submitMessage", "fnUntraced", "message", "push", "onMessage", "TracingService", "emitConverationMessage", "promptMessage", "formatUserPrompt", "formatSystemPrompt", "log", "snippet", "createSnippet", "length", "AiPreprocessor", "preprocessPrompt", "blocks", "streamText", "disableToolCallResolution", "pipe", "AiParser", "parseResponse", "onBegin", "onBlock", "block", "onPart", "part", "onEnd", "summary", "runCollect", "map", "toArray", "response", "Obj", "make", "Message", "created", "Date", "toISOString", "sender", "role", "toolCalls", "getToolCalls", "Error", "toolResults", "forEach", "toolCall", "callTool", "provide", "layerSubframe", "context", "parentMessage", "id", "toolCallId", "withPermits", "withSpan", "runStructured", "_schema", "todo", "text", "len", "slice", "join", "Toolkit", "Effect", "ToolExecutionService", "ToolResolverService", "isTruthy", "createToolkit", "toolkit", "toolkitParam", "toolIds", "blueprints", "gen", "blueprintToolkit", "ToolResolverService", "resolveToolkit", "flatMap", "tools", "blueprintToolkitHandler", "toContext", "ToolExecutionService", "handlersFor", "merge", "filter", "isTruthy", "pipe", "provide", "Schema", "ObjectId", "getVersion", "ObjectVersionSchema", "Unknown", "VersionPinSchema", "Struct", "objectId", "ObjectId", "version", "VersionPin", "DISPOSITION", "fromObject", "object", "make", "id", "getVersion", "createBlock", "pin", "_tag", "disposition", "data", "JSON", "stringify", "merge", "Toolkit", "Effect", "Layer", "Pipeable", "TypeId", "make", "toolkit", "layer", "handlers", "pipe", "provide", "pipeArguments", "arguments", "merge", "toolkits", "map", "t", "mergeAll", "AiConversation", "Resource", "_queue", "_context", "_toolkit", "queue", "AiContextBinder", "_open", "open", "_close", "close", "context", "toolkit", "getHistory", "queueItems", "queryObjects", "filter", "Obj", "instanceOf", "Message", "createRequest", "params", "gen", "session", "AiSession", "history", "promise", "query", "blueprints", "forEach", "values", "DatabaseService", "loadOption", "pipe", "map", "isSome", "option", "value", "objects", "createToolkit", "start", "Date", "now", "log", "length", "tools", "messages", "run", "provideService", "AiContextService", "binder", "duration", "append", "withSpan", "next", "A", "DocAccessor", "toCursorRange", "log", "isNonNullable", "reduceDiffs", "diffs", "reduce", "acc", "diff", "current", "length", "op", "rest", "split", "match", "join", "push", "replace", "computeDiffsWithCursors", "accessor", "map", "text", "getValue", "idx", "indexOf", "cursor", "filter", "applyDiffs", "handle", "change", "doc", "splice", "path", "warn", "AgentStatus", "Obj", "MESSAGE_PROPERTY_TOOL_CALL_ID", "LogLevel", "ContentBlock", "Message", "isNonNullable", "SKIP_BLOCKS", "ExecutionGraph", "_commits", "_branchNames", "Set", "_lastBlockId", "_toolCallCommitIds", "Map", "_lastCommitByBranch", "_pendingToolResults", "_skipBlocks", "SKIP_BLOCKS", "addEvents", "events", "sortedEvents", "sortObjectsByCreated", "event", "Obj", "instanceOf", "Message", "_processMessage", "AgentStatus", "_processAgentStatus", "message", "messageCommits", "messageToCommits", "push", "forEach", "commit", "add", "branch", "_trackToolCalls", "length", "id", "_getToolCallBranch", "parentMessage", "toolCallId", "agentStatusCommit", "icon", "parents", "_getAgentStatusParents", "timestamp", "Date", "created", "set", "_updatePendingToolResults", "objects", "sortedObjects", "slice", "createdObjects", "obj", "idx", "sort", "a", "b", "aDate", "getTime", "bDate", "createdIdx", "map", "_idx", "getGraph", "lastRequest", "findLastIndex", "c", "tags", "includes", "commits", "branches", "Array", "from", "_isToolCallCommit", "_extractToolCallId", "_isToolResultCommit", "_handleLateToolResultUpdate", "agentStatusId", "toolResultId", "get", "toolResultCommit", "find", "toolCallCommitId", "toolCallIndex", "indexOf", "delete", "messageId", "split", "toolCallBranch", "agentStatusCommitId", "getToolCallId", "commitId", "toolCallMatch", "match", "toolResultMatch", "lastBlockId", "toolCallIds", "lastCommitByBranch", "skipBlocks", "previousBlockId", "blocks", "block", "getMessageBranch", "getBlockParents", "_tag", "createBlockCommit", "filter", "isNonNullable", "getToolCallBranchFromCommitId", "lastBlockFromToolCallBranch", "toolCallParent", "getParentId", "text", "trim", "getGenericBlockId", "sender", "role", "level", "LogLevel", "INFO", "name", "getToolResultId", "error", "ERROR", "ContentBlock", "createSummaryMessage", "statusText", "reasoningText", "stringifyRef", "reference", "getBranchName", "options", "properties", "MESSAGE_PROPERTY_TOOL_CALL_ID", "undefined", "ref", "target", "stringifyObject", "dxn", "asEchoDXN", "echoId", "asQueueDXN", "objectId", "getLabel", "getTypename", "Tool", "Context", "Effect", "Layer", "Record", "Schema", "AiToolNotFoundError", "ToolExecutionService", "ToolResolverService", "todo", "Query", "DatabaseService", "Function", "FunctionDefinition", "FunctionInvocationService", "invariant", "makeToolResolverFromFunctions", "functions", "toolkit", "effect", "gen", "dbService", "resolve", "id", "tool", "tools", "objects", "dbFunction", "runQuery", "type", "key", "functionDef", "deserialize", "find", "fn", "fail", "projectFunctionToTool", "pipe", "provideService", "makeToolExecutionServiceFromFunctions", "handlersLayer", "toolkitHandler", "provide", "isHandlerLike", "functionInvocationService", "handlersFor", "makeHandler", "name", "input", "isProviderDefined", "Error", "result", "handle", "definition", "get", "FunctionToolAnnotation", "annotations", "invokeFunction", "catchAllDefect", "defect", "of", "map", "_name", "isUserDefined", "Tag", "toolCache", "WeakMap", "has", "make", "makeToolName", "description", "parameters", "createStructFieldsFromSchema", "inputSchema", "failure", "Any", "annotate", "set", "toolName", "toLowerCase", "replace", "match", "schema", "ast", "_tag", "Object", "fromEntries", "propertySignatures", "prop", "value", "defaultsDeep", "Template", "createSystemPrompt", "options", "Template", "process", "FORMAT", "defaultsDeep", "DATETIME", "Date", "toISOString", "templates", "system", "make", "id", "source", "SYSTEM", "Schema", "DatabaseService", "DXN", "LOCAL_SPACE_TAG", "trim", "createArtifactElement", "id", "ArtifactId", "String", "annotations", "description", "trim", "examples", "toDXN", "reference", "owningSpaceId", "startsWith", "DXN", "parse", "slice", "test", "spaceId", "objectId", "split", "kind", "ECHO", "LOCAL_SPACE_TAG", "fromLocalObjectId", "Error", "resolve", "schema", "ref", "dxn", "DatabaseService"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/conversation/context.ts":{"bytes":13488,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/artifact-diff.ts":{"bytes":2594,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":939,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/session/format.ts":{"bytes":16522,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"}],"format":"esm"},"src/session/session.ts":{"bytes":32915,"imports":[{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/session/format.ts","kind":"import-statement","original":"./format"}],"format":"esm"},"src/session/version-pin.ts":{"bytes":4194,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"src/session/index.ts":{"bytes":657,"imports":[{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"},{"path":"src/session/session.ts","kind":"import-statement","original":"./session"},{"path":"src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"}],"format":"esm"},"src/conversation/conversation.ts":{"bytes":11539,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../session"},{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/conversation/index.ts":{"bytes":562,"imports":[{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"},{"path":"src/conversation/conversation.ts","kind":"import-statement","original":"./conversation"}],"format":"esm"},"src/functions/services.ts":{"bytes":14283,"imports":[{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/functions/index.ts":{"bytes":460,"imports":[{"path":"src/functions/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"},"raw-loader:./format.tpl?raw":{"bytes":1808,"imports":[]},"raw-loader:./system.tpl?raw":{"bytes":3227,"imports":[]},"src/templates/system.ts":{"bytes":2283,"imports":[{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"raw-loader:./format.tpl?raw","kind":"import-statement","original":"./format.tpl?raw"},{"path":"raw-loader:./system.tpl?raw","kind":"import-statement","original":"./system.tpl?raw"}],"format":"esm"},"src/templates/index.ts":{"bytes":458,"imports":[{"path":"src/templates/system.ts","kind":"import-statement","original":"./system"}],"format":"esm"},"src/types.ts":{"bytes":6867,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":894,"imports":[{"path":"src/conversation/index.ts","kind":"import-statement","original":"./conversation"},{"path":"src/functions/index.ts","kind":"import-statement","original":"./functions"},{"path":"src/session/index.ts","kind":"import-statement","original":"./session"},{"path":"src/templates/index.ts","kind":"import-statement","original":"./templates"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/extraction/extraction.ts":{"bytes":6822,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/quotes.ts":{"bytes":7110,"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/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"raw-loader:./instructions.tpl?raw":{"bytes":1318,"imports":[]},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytes":8710,"imports":[{"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":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../../session"},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"raw-loader:./instructions.tpl?raw","kind":"import-statement","original":"./instructions.tpl?raw"}],"format":"esm"},"src/extraction/extraction-llm-function/index.ts":{"bytes":524,"imports":[{"path":"src/extraction/extraction-llm-function/extraction-llm-function.ts","kind":"import-statement","original":"./extraction-llm-function"}],"format":"esm"},"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytes":10059,"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytes":9083,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","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":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"dynamic-import","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/extraction-ner-function/index.ts":{"bytes":652,"imports":[{"path":"src/extraction/extraction-ner-function/extraction-ner-function.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/index.ts":{"bytes":803,"imports":[{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"./extraction"},{"path":"src/extraction/extraction-llm-function/index.ts","kind":"import-statement","original":"./extraction-llm-function"},{"path":"src/extraction/extraction-ner-function/index.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"./quotes"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":30108},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-NZGGCEF3.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiContextBinder","AiConversation","AiSession","ArtifactDiffResolver","ArtifactId","Bindings","ContextBinding","GenerationObserver","VersionPin","createArtifactElement","createSystemPrompt","makeToolExecutionServiceFromFunctions","makeToolResolverFromFunctions","templates"],"entryPoint":"src/index.ts","inputs":{"src/conversation/context.ts":{"bytesInOutput":2996},"src/conversation/index.ts":{"bytesInOutput":0},"src/conversation/conversation.ts":{"bytesInOutput":2477},"src/index.ts":{"bytesInOutput":0},"src/functions/services.ts":{"bytesInOutput":3281},"src/functions/index.ts":{"bytesInOutput":0},"src/templates/system.ts":{"bytesInOutput":234},"raw-loader:./format.tpl?raw":{"bytesInOutput":1888},"raw-loader:./system.tpl?raw":{"bytesInOutput":3299},"src/templates/index.ts":{"bytesInOutput":0},"src/types.ts":{"bytesInOutput":1321}},"bytes":16218},"dist/lib/browser/extraction/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17085},"dist/lib/browser/extraction/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-NZGGCEF3.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-6WRGDEMH.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","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":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","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/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","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":"@dxos/schema","kind":"import-statement","external":true},{"path":"dist/lib/browser/named-entity-recognition-O46UTCLR.mjs","kind":"dynamic-import"}],"exports":["ExtractionInput","ExtractionOutput","ReferencedQuotes","combineNerTokens","createTokenGroups","extractFullEntities","extractionAnthropicFn","extractionNerFn","findQuotes","getNer","insertReferences","processTranscriptMessage"],"entryPoint":"src/extraction/index.ts","inputs":{"src/extraction/extraction.ts":{"bytesInOutput":1370},"src/extraction/index.ts":{"bytesInOutput":0},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytesInOutput":1819},"src/extraction/quotes.ts":{"bytesInOutput":1673},"raw-loader:./instructions.tpl?raw":{"bytesInOutput":1376},"src/extraction/extraction-llm-function/index.ts":{"bytesInOutput":0},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytesInOutput":2729},"src/extraction/extraction-ner-function/index.ts":{"bytesInOutput":0}},"bytes":9729},"dist/lib/browser/chunk-NZGGCEF3.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":28431},"dist/lib/browser/chunk-NZGGCEF3.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/ai","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiSession","ArtifactDiffResolver","GenerationObserver","VersionPin"],"inputs":{"src/session/artifact-diff.ts":{"bytesInOutput":134},"src/errors.ts":{"bytesInOutput":123},"src/session/session.ts":{"bytesInOutput":6467},"src/session/format.ts":{"bytesInOutput":3692},"src/session/version-pin.ts":{"bytesInOutput":731},"src/session/index.ts":{"bytesInOutput":0}},"bytes":11457},"dist/lib/browser/named-entity-recognition-O46UTCLR.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/named-entity-recognition-O46UTCLR.mjs":{"imports":[{"path":"dist/lib/browser/chunk-6WRGDEMH.mjs","kind":"import-statement"}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"entryPoint":"src/extraction/extraction-ner-function/named-entity-recognition.ts","inputs":{},"bytes":261},"dist/lib/browser/chunk-6WRGDEMH.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5241},"dist/lib/browser/chunk-6WRGDEMH.mjs":{"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["combineNerTokens","createTokenGroups","extractFullEntities","getNer"],"inputs":{"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytesInOutput":2265}},"bytes":2465}}}
|
|
1
|
+
{"inputs":{"src/conversation/context.ts":{"bytes":20293,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/artifact-diff.ts":{"bytes":2596,"imports":[{"path":"effect/Context","kind":"import-statement","external":true}],"format":"esm"},"src/session/observer.ts":{"bytes":5405,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":1420,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/session/format.ts":{"bytes":17102,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"}],"format":"esm"},"src/session/session.ts":{"bytes":23621,"imports":[{"path":"@effect/ai/LanguageModel","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"src/session/format.ts","kind":"import-statement","original":"./format"},{"path":"src/session/observer.ts","kind":"import-statement","original":"./observer"},{"path":"@dxos/node-std/fs","kind":"require-call","external":true}],"format":"esm"},"src/session/toolkit.ts":{"bytes":4536,"imports":[{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/session/version-pin.ts":{"bytes":4172,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true}],"format":"esm"},"src/session/GenericToolkit.ts":{"bytes":7378,"imports":[{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true}],"format":"esm"},"src/session/index.ts":{"bytes":1024,"imports":[{"path":"src/session/artifact-diff.ts","kind":"import-statement","original":"./artifact-diff"},{"path":"src/session/observer.ts","kind":"import-statement","original":"./observer"},{"path":"src/session/session.ts","kind":"import-statement","original":"./session"},{"path":"src/session/toolkit.ts","kind":"import-statement","original":"./toolkit"},{"path":"src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"},{"path":"src/session/GenericToolkit.ts","kind":"import-statement","original":"./GenericToolkit"}],"format":"esm"},"src/conversation/conversation.ts":{"bytes":12916,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"src/session/index.ts","kind":"import-statement","original":"../session"},{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/conversation/index.ts":{"bytes":562,"imports":[{"path":"src/conversation/context.ts","kind":"import-statement","original":"./context"},{"path":"src/conversation/conversation.ts","kind":"import-statement","original":"./conversation"}],"format":"esm"},"src/diff.ts":{"bytes":8784,"imports":[{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/execution-graph.ts":{"bytes":51049,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/functions/services.ts":{"bytes":20563,"imports":[{"path":"@effect/ai/Tool","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/functions/index.ts":{"bytes":460,"imports":[{"path":"src/functions/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/format.tpl?raw":{"bytes":1960,"imports":[]},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/system.tpl?raw":{"bytes":3351,"imports":[]},"src/templates/system.ts":{"bytes":3189,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/format.tpl?raw","kind":"import-statement","original":"./instructions/format.tpl?raw"},{"path":"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/system.tpl?raw","kind":"import-statement","original":"./instructions/system.tpl?raw"}],"format":"esm"},"src/templates/index.ts":{"bytes":458,"imports":[{"path":"src/templates/system.ts","kind":"import-statement","original":"./system"}],"format":"esm"},"src/types/artifact.ts":{"bytes":8455,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/types/index.ts":{"bytes":456,"imports":[{"path":"src/types/artifact.ts","kind":"import-statement","original":"./artifact"}],"format":"esm"},"src/index.ts":{"bytes":1081,"imports":[{"path":"src/conversation/index.ts","kind":"import-statement","original":"./conversation"},{"path":"src/diff.ts","kind":"import-statement","original":"./diff"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/execution-graph.ts","kind":"import-statement","original":"./execution-graph"},{"path":"src/functions/index.ts","kind":"import-statement","original":"./functions"},{"path":"src/session/index.ts","kind":"import-statement","original":"./session"},{"path":"src/templates/index.ts","kind":"import-statement","original":"./templates"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/extraction/extraction.ts":{"bytes":6876,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytes":6754,"imports":[{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"}],"format":"esm"},"src/extraction/extraction-llm-function/index.ts":{"bytes":524,"imports":[{"path":"src/extraction/extraction-llm-function/extraction-llm-function.ts","kind":"import-statement","original":"./extraction-llm-function"}],"format":"esm"},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytes":6217,"imports":[{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"}],"format":"esm"},"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytes":10067,"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/extraction-ner-function/index.ts":{"bytes":652,"imports":[{"path":"src/extraction/extraction-ner-function/extraction-ner-function.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"}],"format":"esm"},"src/extraction/quotes.ts":{"bytes":7132,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/extraction/index.ts":{"bytes":803,"imports":[{"path":"src/extraction/extraction.ts","kind":"import-statement","original":"./extraction"},{"path":"src/extraction/extraction-llm-function/index.ts","kind":"import-statement","original":"./extraction-llm-function"},{"path":"src/extraction/extraction-ner-function/index.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"src/extraction/quotes.ts","kind":"import-statement","original":"./quotes"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":101720},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@effect/ai/LanguageModel","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@effect/ai/Toolkit","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"@automerge/automerge","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect/ai/Tool","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AiAssistantError","AiContextBinder","AiContextService","AiConversation","AiModelError","AiSession","ArtifactDiffResolver","ArtifactId","Bindings","ContextBinding","ExecutionGraph","GenerationObserver","GenericToolkit","VersionPin","applyDiffs","computeDiffsWithCursors","createArtifactElement","createSystemPrompt","createToolkit","makeToolExecutionServiceFromFunctions","makeToolResolverFromFunctions","reduceDiffs","templates"],"entryPoint":"src/index.ts","inputs":{"src/conversation/context.ts":{"bytesInOutput":4967},"src/conversation/index.ts":{"bytesInOutput":0},"src/conversation/conversation.ts":{"bytesInOutput":2908},"src/session/artifact-diff.ts":{"bytesInOutput":145},"src/session/index.ts":{"bytesInOutput":0},"src/session/observer.ts":{"bytesInOutput":923},"src/session/session.ts":{"bytesInOutput":4251},"src/session/format.ts":{"bytesInOutput":3902},"src/errors.ts":{"bytesInOutput":236},"src/session/toolkit.ts":{"bytesInOutput":744},"src/session/version-pin.ts":{"bytesInOutput":744},"src/session/GenericToolkit.ts":{"bytesInOutput":733},"src/index.ts":{"bytesInOutput":0},"src/diff.ts":{"bytesInOutput":1899},"src/execution-graph.ts":{"bytesInOutput":11999},"src/functions/services.ts":{"bytesInOutput":4435},"src/functions/index.ts":{"bytesInOutput":0},"src/templates/system.ts":{"bytesInOutput":555},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/format.tpl?raw":{"bytesInOutput":2046},"raw-loader:/__w/dxos/dxos/packages/core/assistant/src/templates/instructions/system.tpl?raw":{"bytesInOutput":3424},"src/templates/index.ts":{"bytesInOutput":0},"src/types/artifact.ts":{"bytesInOutput":1641},"src/types/index.ts":{"bytesInOutput":0}},"bytes":46858},"dist/lib/browser/extraction/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17616},"dist/lib/browser/extraction/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@xenova/transformers","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/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["ExtractionInput","ExtractionOutput","ReferencedQuotes","combineNerTokens","createTokenGroups","extractFullEntities","extractionAnthropicFunction","extractionNerFunction","findQuotes","getNer","insertReferences","processTranscriptMessage"],"entryPoint":"src/extraction/index.ts","inputs":{"src/extraction/extraction.ts":{"bytesInOutput":1376},"src/extraction/index.ts":{"bytesInOutput":0},"src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytesInOutput":455},"src/extraction/extraction-llm-function/index.ts":{"bytesInOutput":0},"src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytesInOutput":431},"src/extraction/extraction-ner-function/index.ts":{"bytesInOutput":0},"src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytesInOutput":2276},"src/extraction/quotes.ts":{"bytesInOutput":1673}},"bytes":6813},"dist/lib/browser/chunk-J5LGTIGS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/chunk-J5LGTIGS.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":235}}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__export
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-HSLMI22Q.mjs.map
|