@dxos/assistant-toolkit 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +366 -264
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +43 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +366 -264
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +44 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/blueprints/design/design-blueprint.d.ts +17 -3
- package/dist/types/src/blueprints/design/design-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/design/index.d.ts +1 -1
- package/dist/types/src/blueprints/design/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts +9 -10
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/discord/index.d.ts +1 -1
- package/dist/types/src/blueprints/discord/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/linear/index.d.ts +1 -1
- package/dist/types/src/blueprints/linear/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts +9 -10
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/planning/index.d.ts +1 -1
- package/dist/types/src/blueprints/planning/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/planning/planning-blueprint.d.ts +17 -3
- package/dist/types/src/blueprints/planning/planning-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/research/index.d.ts +1 -1
- package/dist/types/src/blueprints/research/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/research/research-blueprint.d.ts +17 -3
- package/dist/types/src/blueprints/research/research-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/testing.d.ts +2 -2
- package/dist/types/src/blueprints/testing.d.ts.map +1 -1
- package/dist/types/src/blueprints/websearch/index.d.ts +1 -1
- package/dist/types/src/blueprints/websearch/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/websearch/websearch-blueprint.d.ts +17 -3
- package/dist/types/src/blueprints/websearch/websearch-blueprint.d.ts.map +1 -1
- package/dist/types/src/crud/graph.d.ts +14 -11
- package/dist/types/src/crud/graph.d.ts.map +1 -1
- package/dist/types/src/functions/agent/prompt.d.ts +71 -4
- package/dist/types/src/functions/agent/prompt.d.ts.map +1 -1
- package/dist/types/src/functions/document/read.d.ts.map +1 -1
- package/dist/types/src/functions/document/update.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +93 -91
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +93 -91
- package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
- package/dist/types/src/functions/exa/data/exa-search-1748337321991.d.ts.map +1 -0
- package/dist/types/src/functions/exa/data/exa-search-1748337331526.d.ts.map +1 -0
- package/dist/types/src/functions/exa/data/exa-search-1748337344119.d.ts.map +1 -0
- package/dist/types/src/functions/exa/data/index.d.ts.map +1 -0
- package/dist/types/src/functions/github/fetch-prs.d.ts.map +1 -1
- package/dist/types/src/functions/linear/index.d.ts +1 -1
- package/dist/types/src/functions/linear/sync-issues.d.ts +1 -1
- package/dist/types/src/functions/linear/sync-issues.d.ts.map +1 -1
- package/dist/types/src/functions/research/document-create.d.ts.map +1 -1
- package/dist/types/src/functions/research/research-graph.d.ts +8 -7
- package/dist/types/src/functions/research/research-graph.d.ts.map +1 -1
- package/dist/types/src/functions/research/research.d.ts.map +1 -1
- package/dist/types/src/functions/tasks/read.d.ts.map +1 -1
- package/dist/types/src/functions/tasks/update.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/initiative/Initiative.d.ts +84 -0
- package/dist/types/src/initiative/Initiative.d.ts.map +1 -0
- package/dist/types/src/initiative/InitiativeSchema.d.ts +19 -0
- package/dist/types/src/initiative/InitiativeSchema.d.ts.map +1 -0
- package/dist/types/src/initiative/functions/agent.d.ts +37 -0
- package/dist/types/src/initiative/functions/agent.d.ts.map +1 -0
- package/dist/types/src/initiative/functions/getContext.d.ts +17 -0
- package/dist/types/src/initiative/functions/getContext.d.ts.map +1 -0
- package/dist/types/src/initiative/functions/index.d.ts +4 -0
- package/dist/types/src/initiative/functions/index.d.ts.map +1 -0
- package/dist/types/src/initiative/functions/update.d.ts +7 -0
- package/dist/types/src/initiative/functions/update.d.ts.map +1 -0
- package/dist/types/src/initiative/index.d.ts +1 -0
- package/dist/types/src/initiative/index.d.ts.map +1 -0
- package/dist/types/src/initiative/initiative.test.d.ts +2 -0
- package/dist/types/src/initiative/initiative.test.d.ts.map +1 -0
- package/dist/types/src/sync/sync.d.ts +3 -3
- package/dist/types/src/sync/sync.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/plugins.d.ts +19 -0
- package/dist/types/src/testing/plugins.d.ts.map +1 -0
- package/dist/types/src/toolkits/AssistantToolkit.d.ts +31 -5
- package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +1 -1
- package/dist/types/src/toolkits/SystemToolkit.d.ts +42 -10
- package/dist/types/src/toolkits/SystemToolkit.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +49 -35
- package/src/blueprints/design/design-blueprint.test.ts +10 -8
- package/src/blueprints/design/design-blueprint.ts +2 -4
- package/src/blueprints/design/index.ts +1 -1
- package/src/blueprints/discord/discord-blueprint.ts +2 -4
- package/src/blueprints/discord/index.ts +1 -1
- package/src/blueprints/linear/index.ts +1 -1
- package/src/blueprints/linear/linear-blueprint.ts +2 -4
- package/src/blueprints/planning/index.ts +1 -1
- package/src/blueprints/planning/planning-blueprint.test.ts +8 -6
- package/src/blueprints/planning/planning-blueprint.ts +2 -4
- package/src/blueprints/research/index.ts +1 -1
- package/src/blueprints/research/research-blueprint.ts +2 -4
- package/src/blueprints/testing.ts +2 -2
- package/src/blueprints/websearch/index.ts +2 -1
- package/src/blueprints/websearch/websearch-blueprint.ts +2 -4
- package/src/crud/graph.test.ts +4 -27
- package/src/crud/graph.ts +21 -23
- package/src/experimental/feed.test.ts +1 -1
- package/src/functions/agent/prompt.ts +17 -13
- package/src/functions/discord/fetch-messages.test.ts +1 -1
- package/src/functions/discord/fetch-messages.ts +1 -1
- package/src/functions/document/read.ts +4 -3
- package/src/functions/document/update.ts +7 -4
- package/src/functions/entity-extraction/entity-extraction.conversations.json +6597 -1
- package/src/functions/entity-extraction/entity-extraction.test.ts +7 -6
- package/src/functions/entity-extraction/entity-extraction.ts +38 -19
- package/src/functions/exa/mock.ts +1 -1
- package/src/functions/github/fetch-prs.ts +3 -2
- package/src/functions/linear/linear.test.ts +11 -10
- package/src/functions/linear/sync-issues.ts +7 -5
- package/src/functions/research/document-create.ts +7 -6
- package/src/functions/research/research-graph.ts +11 -11
- package/src/functions/research/research.conversations.json +1 -1
- package/src/functions/research/research.test.ts +24 -32
- package/src/functions/research/research.ts +8 -9
- package/src/functions/tasks/read.ts +4 -3
- package/src/functions/tasks/update.ts +4 -3
- package/src/index.ts +0 -1
- package/src/initiative/Initiative.ts +99 -0
- package/src/initiative/InitiativeSchema.ts +37 -0
- package/src/initiative/functions/agent.ts +57 -0
- package/src/initiative/functions/getContext.ts +74 -0
- package/src/initiative/functions/index.ts +7 -0
- package/src/initiative/functions/update.ts +63 -0
- package/src/initiative/index.ts +3 -0
- package/src/initiative/initiative.conversations.json +1 -0
- package/src/initiative/initiative.test.ts +485 -0
- package/src/sync/sync.ts +38 -30
- package/src/testing/index.ts +1 -1
- package/src/{plugins.tsx → testing/plugins.tsx} +13 -13
- package/src/toolkits/AssistantToolkit.conversations.json +1 -1
- package/src/toolkits/AssistantToolkit.test.ts +17 -11
- package/src/toolkits/AssistantToolkit.ts +31 -8
- package/src/toolkits/SystemToolkit.ts +100 -32
- package/dist/types/src/plugins.d.ts +0 -19
- package/dist/types/src/plugins.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337321991.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337331526.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337344119.d.ts.map +0 -1
- package/dist/types/src/testing/data/index.d.ts.map +0 -1
- /package/dist/types/src/{testing → functions/exa}/data/exa-search-1748337321991.d.ts +0 -0
- /package/dist/types/src/{testing → functions/exa}/data/exa-search-1748337331526.d.ts +0 -0
- /package/dist/types/src/{testing → functions/exa}/data/exa-search-1748337344119.d.ts +0 -0
- /package/dist/types/src/{testing → functions/exa}/data/index.d.ts +0 -0
- /package/src/{testing → functions/exa}/data/exa-search-1748337321991.ts +0 -0
- /package/src/{testing → functions/exa}/data/exa-search-1748337331526.ts +0 -0
- /package/src/{testing → functions/exa}/data/exa-search-1748337344119.ts +0 -0
- /package/src/{testing → functions/exa}/data/index.ts +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
6
4
|
|
|
7
5
|
// src/blueprints/design/design-blueprint.ts
|
|
8
6
|
import { ToolId } from "@dxos/ai";
|
|
9
7
|
import { Blueprint } from "@dxos/blueprints";
|
|
10
|
-
import {
|
|
8
|
+
import { Ref as Ref6 } from "@dxos/echo";
|
|
11
9
|
import { Text as Text2 } from "@dxos/schema";
|
|
12
10
|
import { trim as trim5 } from "@dxos/util";
|
|
13
11
|
|
|
@@ -22,7 +20,8 @@ import { AiService, ConsolePrinter, ModelName } from "@dxos/ai";
|
|
|
22
20
|
import { AiSession, GenerationObserver, createToolkit } from "@dxos/assistant";
|
|
23
21
|
import { Prompt, Template } from "@dxos/blueprints";
|
|
24
22
|
import { Obj, Ref, Type } from "@dxos/echo";
|
|
25
|
-
import {
|
|
23
|
+
import { Database } from "@dxos/echo";
|
|
24
|
+
import { TracingService, defineFunction } from "@dxos/functions";
|
|
26
25
|
import { log } from "@dxos/log";
|
|
27
26
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/agent/prompt.ts";
|
|
28
27
|
var DEFAULT_MODEL = "@anthropic/claude-opus-4-0";
|
|
@@ -51,19 +50,19 @@ var prompt_default = defineFunction({
|
|
|
51
50
|
input: data.input
|
|
52
51
|
}, {
|
|
53
52
|
F: __dxlog_file,
|
|
54
|
-
L:
|
|
53
|
+
L: 41,
|
|
55
54
|
S: this,
|
|
56
55
|
C: (f, a) => f(...a)
|
|
57
56
|
});
|
|
58
57
|
const input = yield* Match.value(data.input).pipe(Match.when((value2) => Ref.isRef(value2), Effect.fnUntraced(function* (ref) {
|
|
59
|
-
const object = yield*
|
|
58
|
+
const object = yield* Database.Service.load(ref);
|
|
60
59
|
return Obj.toJSON(object);
|
|
61
60
|
})), Match.orElse(() => Effect.succeed(data.input)));
|
|
62
|
-
yield*
|
|
61
|
+
yield* Database.Service.flush({
|
|
63
62
|
indexes: true
|
|
64
63
|
});
|
|
65
|
-
const prompt = yield*
|
|
66
|
-
const systemPrompt = data.systemPrompt ? yield*
|
|
64
|
+
const prompt = yield* Database.Service.load(data.prompt);
|
|
65
|
+
const systemPrompt = data.systemPrompt ? yield* Database.Service.load(data.systemPrompt) : void 0;
|
|
67
66
|
yield* TracingService.emitStatus({
|
|
68
67
|
message: `Running ${prompt.id}`
|
|
69
68
|
});
|
|
@@ -72,18 +71,18 @@ var prompt_default = defineFunction({
|
|
|
72
71
|
input
|
|
73
72
|
}, {
|
|
74
73
|
F: __dxlog_file,
|
|
75
|
-
L:
|
|
74
|
+
L: 71,
|
|
76
75
|
S: this,
|
|
77
76
|
C: (f, a) => f(...a)
|
|
78
77
|
});
|
|
79
|
-
const blueprints = yield* Function.pipe(prompt.blueprints, Array2.appendAll(systemPrompt?.blueprints ?? []), Effect.forEach(
|
|
80
|
-
const objects = yield* Function.pipe(prompt.context, Array2.appendAll(systemPrompt?.context ?? []), Effect.forEach(DatabaseService.loadOption), Effect.map(Array2.filter(Option.isSome)), Effect.map(Array2.map((option) => option.value)));
|
|
78
|
+
const blueprints = yield* Function.pipe(prompt.blueprints, Array2.appendAll(systemPrompt?.blueprints ?? []), Effect.forEach(Database.Service.loadOption), Effect.map(Array2.filter(Option.isSome)), Effect.map(Array2.map((option) => option.value)));
|
|
81
79
|
const toolkit = yield* createToolkit({
|
|
82
80
|
blueprints
|
|
83
81
|
});
|
|
84
|
-
const
|
|
82
|
+
const objects = yield* Function.pipe(prompt.context, Array2.appendAll(systemPrompt?.context ?? []), Effect.forEach(Database.Service.loadOption), Effect.map(Array2.filter(Option.isSome)), Effect.map(Array2.map((option) => option.value)));
|
|
83
|
+
const promptInstructions = yield* Database.Service.load(prompt.instructions.source);
|
|
85
84
|
const promptText = Template.process(promptInstructions.content, input);
|
|
86
|
-
const systemInstructions = systemPrompt ? yield*
|
|
85
|
+
const systemInstructions = systemPrompt ? yield* Database.Service.load(systemPrompt.instructions.source) : void 0;
|
|
87
86
|
const systemText = systemInstructions ? Template.process(systemInstructions.content, {}) : void 0;
|
|
88
87
|
const session = new AiSession();
|
|
89
88
|
const result = yield* session.run({
|
|
@@ -211,7 +210,15 @@ var fetch_messages_default = defineFunction2({
|
|
|
211
210
|
throw new Error("no channels found");
|
|
212
211
|
}
|
|
213
212
|
for (const channel of channels) {
|
|
214
|
-
|
|
213
|
+
log2.info("channel", {
|
|
214
|
+
id: channel.id,
|
|
215
|
+
name: "name" in channel ? channel.name : void 0
|
|
216
|
+
}, {
|
|
217
|
+
F: __dxlog_file2,
|
|
218
|
+
L: 136,
|
|
219
|
+
S: this,
|
|
220
|
+
C: (f, a) => f(...a)
|
|
221
|
+
});
|
|
215
222
|
}
|
|
216
223
|
yield* TracingService2.emitStatus({
|
|
217
224
|
message: `Will fetch from channels: ${channels.length}`
|
|
@@ -312,7 +319,8 @@ var Discord;
|
|
|
312
319
|
import * as Effect3 from "effect/Effect";
|
|
313
320
|
import * as Schema3 from "effect/Schema";
|
|
314
321
|
import { ArtifactId } from "@dxos/assistant";
|
|
315
|
-
import {
|
|
322
|
+
import { Database as Database2 } from "@dxos/echo";
|
|
323
|
+
import { defineFunction as defineFunction3 } from "@dxos/functions";
|
|
316
324
|
import { Markdown } from "@dxos/plugin-markdown/types";
|
|
317
325
|
var read_default = defineFunction3({
|
|
318
326
|
key: "dxos.org/function/markdown/read",
|
|
@@ -327,8 +335,8 @@ var read_default = defineFunction3({
|
|
|
327
335
|
content: Schema3.String
|
|
328
336
|
}),
|
|
329
337
|
handler: Effect3.fn(function* ({ data: { id } }) {
|
|
330
|
-
const doc = yield*
|
|
331
|
-
const { content } = yield*
|
|
338
|
+
const doc = yield* Database2.Service.resolve(ArtifactId.toDXN(id), Markdown.Document);
|
|
339
|
+
const { content } = yield* Database2.Service.load(doc.content);
|
|
332
340
|
return {
|
|
333
341
|
content
|
|
334
342
|
};
|
|
@@ -339,7 +347,8 @@ var read_default = defineFunction3({
|
|
|
339
347
|
import * as Effect4 from "effect/Effect";
|
|
340
348
|
import * as Schema4 from "effect/Schema";
|
|
341
349
|
import { ArtifactId as ArtifactId2 } from "@dxos/assistant";
|
|
342
|
-
import {
|
|
350
|
+
import { Database as Database3, Obj as Obj3 } from "@dxos/echo";
|
|
351
|
+
import { defineFunction as defineFunction4 } from "@dxos/functions";
|
|
343
352
|
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
344
353
|
var update_default = defineFunction4({
|
|
345
354
|
key: "dxos.org/function/markdown/update",
|
|
@@ -355,9 +364,11 @@ var update_default = defineFunction4({
|
|
|
355
364
|
}),
|
|
356
365
|
outputSchema: Schema4.Void,
|
|
357
366
|
handler: Effect4.fn(function* ({ data: { id, content } }) {
|
|
358
|
-
const doc = yield*
|
|
359
|
-
const text = yield*
|
|
360
|
-
text
|
|
367
|
+
const doc = yield* Database3.Service.resolve(ArtifactId2.toDXN(id), Markdown2.Document);
|
|
368
|
+
const text = yield* Database3.Service.load(doc.content);
|
|
369
|
+
Obj3.change(text, (t) => {
|
|
370
|
+
t.content = content;
|
|
371
|
+
});
|
|
361
372
|
})
|
|
362
373
|
});
|
|
363
374
|
|
|
@@ -376,8 +387,9 @@ import * as Predicate from "effect/Predicate";
|
|
|
376
387
|
import * as Schema11 from "effect/Schema";
|
|
377
388
|
import { AiService as AiService3 } from "@dxos/ai";
|
|
378
389
|
import { AiSession as AiSession3, makeToolExecutionServiceFromFunctions as makeToolExecutionServiceFromFunctions2, makeToolResolverFromFunctions as makeToolResolverFromFunctions2 } from "@dxos/assistant";
|
|
379
|
-
import { Filter as Filter2, Obj as
|
|
380
|
-
import {
|
|
390
|
+
import { Filter as Filter2, Obj as Obj8, Ref as Ref3, Type as Type4 } from "@dxos/echo";
|
|
391
|
+
import { Database as Database8 } from "@dxos/echo";
|
|
392
|
+
import { defineFunction as defineFunction9 } from "@dxos/functions";
|
|
381
393
|
import { FunctionInvocationServiceLayerTest } from "@dxos/functions-runtime/testing";
|
|
382
394
|
import { log as log5 } from "@dxos/log";
|
|
383
395
|
import { LegacyOrganization as LegacyOrganization2, Message as Message2, Organization, Person as Person2 } from "@dxos/types";
|
|
@@ -392,11 +404,12 @@ import * as Function3 from "effect/Function";
|
|
|
392
404
|
import * as Option3 from "effect/Option";
|
|
393
405
|
import * as Schema5 from "effect/Schema";
|
|
394
406
|
import * as SchemaAST from "effect/SchemaAST";
|
|
395
|
-
import { Entity, Filter, Obj as
|
|
407
|
+
import { Entity, Filter, Obj as Obj4, Query, Type as Type2 } from "@dxos/echo";
|
|
408
|
+
import { Database as Database4 } from "@dxos/echo";
|
|
396
409
|
import { ReferenceAnnotationId, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, createObject, getTypeAnnotation, getTypeIdentifierAnnotation } from "@dxos/echo/internal";
|
|
397
410
|
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
398
411
|
import { mapAst } from "@dxos/effect";
|
|
399
|
-
import { ContextQueueService
|
|
412
|
+
import { ContextQueueService } from "@dxos/functions";
|
|
400
413
|
import { DXN, ObjectId } from "@dxos/keys";
|
|
401
414
|
import { log as log3 } from "@dxos/log";
|
|
402
415
|
import { deepMapValues, isNonNullable, trim } from "@dxos/util";
|
|
@@ -406,17 +419,15 @@ var Subgraph = Schema5.Struct({
|
|
|
406
419
|
objects: Schema5.Array(Schema5.Any)
|
|
407
420
|
});
|
|
408
421
|
var findRelatedSchema = async (db, anchor) => {
|
|
409
|
-
const allSchemas =
|
|
410
|
-
...db.graph.schemaRegistry.schemas
|
|
411
|
-
];
|
|
422
|
+
const allSchemas = await db.graph.schemaRegistry.query().run();
|
|
412
423
|
return allSchemas.filter((schema) => {
|
|
413
424
|
if (getTypeAnnotation(schema)?.kind !== Entity.Kind.Relation) {
|
|
414
425
|
return false;
|
|
415
426
|
}
|
|
416
427
|
return isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).sourceSchema)) || isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).targetSchema));
|
|
417
428
|
}).map((schema) => ({
|
|
418
|
-
|
|
419
|
-
|
|
429
|
+
kind: "relation",
|
|
430
|
+
schema
|
|
420
431
|
}));
|
|
421
432
|
};
|
|
422
433
|
var isSchemaAddressableByDxn = (schema, dxn) => {
|
|
@@ -439,12 +450,12 @@ var LocalSearchToolkit = Toolkit.make(Tool.make("search_local_search", {
|
|
|
439
450
|
success: Schema5.Unknown,
|
|
440
451
|
failure: Schema5.Never,
|
|
441
452
|
dependencies: [
|
|
442
|
-
|
|
453
|
+
Database4.Service
|
|
443
454
|
]
|
|
444
455
|
}));
|
|
445
456
|
var LocalSearchHandler = LocalSearchToolkit.toLayer({
|
|
446
457
|
search_local_search: Effect5.fn(function* ({ query }) {
|
|
447
|
-
const
|
|
458
|
+
const objects = yield* Database4.Service.runQuery(Query.select(Filter.text(query, {
|
|
448
459
|
type: "vector"
|
|
449
460
|
})));
|
|
450
461
|
const results = [
|
|
@@ -471,7 +482,7 @@ var makeGraphWriterToolkit = ({ schema }) => {
|
|
|
471
482
|
success: Schema5.Unknown,
|
|
472
483
|
failure: Schema5.Never,
|
|
473
484
|
dependencies: [
|
|
474
|
-
|
|
485
|
+
Database4.Service,
|
|
475
486
|
ContextQueueService
|
|
476
487
|
]
|
|
477
488
|
}).annotateContext(Context.make(GraphWriterSchema, {
|
|
@@ -482,11 +493,11 @@ var makeGraphWriterHandler = (toolkit, { onAppend } = {}) => {
|
|
|
482
493
|
const { schema } = Context.get(toolkit.tools.graph_writer.annotations, GraphWriterSchema);
|
|
483
494
|
return toolkit.toLayer({
|
|
484
495
|
graph_writer: Effect5.fn(function* (input) {
|
|
485
|
-
const { db } = yield*
|
|
496
|
+
const { db } = yield* Database4.Service;
|
|
486
497
|
const { queue } = yield* ContextQueueService;
|
|
487
498
|
const data = yield* Effect5.promise(() => sanitizeObjects(schema, input, db, queue));
|
|
488
499
|
yield* Effect5.promise(() => queue.append(data));
|
|
489
|
-
const dxns = data.map((obj) =>
|
|
500
|
+
const dxns = data.map((obj) => Obj4.getDXN(obj));
|
|
490
501
|
onAppend?.(dxns);
|
|
491
502
|
return dxns;
|
|
492
503
|
})
|
|
@@ -555,7 +566,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
555
566
|
source: data2.source
|
|
556
567
|
}, {
|
|
557
568
|
F: __dxlog_file3,
|
|
558
|
-
L:
|
|
569
|
+
L: 273,
|
|
559
570
|
S: void 0,
|
|
560
571
|
C: (f, a) => f(...a)
|
|
561
572
|
});
|
|
@@ -566,7 +577,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
566
577
|
target: data2.target
|
|
567
578
|
}, {
|
|
568
579
|
F: __dxlog_file3,
|
|
569
|
-
L:
|
|
580
|
+
L: 277,
|
|
570
581
|
S: void 0,
|
|
571
582
|
C: (f, a) => f(...a)
|
|
572
583
|
});
|
|
@@ -581,7 +592,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
581
592
|
schema: entry.schema
|
|
582
593
|
};
|
|
583
594
|
}).filter((object) => !existingIds.has(object.data.id));
|
|
584
|
-
const
|
|
595
|
+
const dbObjects = await db.query(Query.select(Filter.id(...existingIds))).run();
|
|
585
596
|
const queueObjects = await queue?.getObjectsById([
|
|
586
597
|
...existingIds
|
|
587
598
|
]) ?? [];
|
|
@@ -595,7 +606,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
595
606
|
existingIds
|
|
596
607
|
}, {
|
|
597
608
|
F: __dxlog_file3,
|
|
598
|
-
L:
|
|
609
|
+
L: 298,
|
|
599
610
|
S: void 0,
|
|
600
611
|
C: (f, a) => f(...a)
|
|
601
612
|
});
|
|
@@ -670,8 +681,9 @@ var preprocessSchema = (schema) => {
|
|
|
670
681
|
import * as Effect6 from "effect/Effect";
|
|
671
682
|
import * as Schema6 from "effect/Schema";
|
|
672
683
|
import { ArtifactId as ArtifactId3 } from "@dxos/assistant";
|
|
673
|
-
import { Obj as
|
|
674
|
-
import {
|
|
684
|
+
import { Obj as Obj5, Relation } from "@dxos/echo";
|
|
685
|
+
import { Database as Database5 } from "@dxos/echo";
|
|
686
|
+
import { TracingService as TracingService3, defineFunction as defineFunction5 } from "@dxos/functions";
|
|
675
687
|
import { log as log4 } from "@dxos/log";
|
|
676
688
|
import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
|
|
677
689
|
import { HasSubject } from "@dxos/types";
|
|
@@ -709,27 +721,27 @@ var document_create_default = defineFunction5({
|
|
|
709
721
|
content
|
|
710
722
|
}, {
|
|
711
723
|
F: __dxlog_file4,
|
|
712
|
-
L:
|
|
724
|
+
L: 43,
|
|
713
725
|
S: this,
|
|
714
726
|
C: (f, a) => f(...a)
|
|
715
727
|
});
|
|
716
|
-
yield*
|
|
728
|
+
yield* Database5.Service.flush({
|
|
717
729
|
indexes: true
|
|
718
730
|
});
|
|
719
731
|
yield* TracingService3.emitStatus({
|
|
720
732
|
message: "Creating research document..."
|
|
721
733
|
});
|
|
722
|
-
const target = yield*
|
|
723
|
-
const object = yield*
|
|
734
|
+
const target = yield* Database5.Service.resolve(ArtifactId3.toDXN(subject));
|
|
735
|
+
const object = yield* Database5.Service.add(Markdown3.make({
|
|
724
736
|
name,
|
|
725
737
|
content
|
|
726
738
|
}));
|
|
727
|
-
yield*
|
|
739
|
+
yield* Database5.Service.add(Relation.make(HasSubject.HasSubject, {
|
|
728
740
|
[Relation.Source]: object,
|
|
729
741
|
[Relation.Target]: target,
|
|
730
742
|
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
731
743
|
}));
|
|
732
|
-
yield*
|
|
744
|
+
yield* Database5.Service.flush({
|
|
733
745
|
indexes: true
|
|
734
746
|
});
|
|
735
747
|
log4.info("Created research document", {
|
|
@@ -737,12 +749,12 @@ var document_create_default = defineFunction5({
|
|
|
737
749
|
object
|
|
738
750
|
}, {
|
|
739
751
|
F: __dxlog_file4,
|
|
740
|
-
L:
|
|
752
|
+
L: 70,
|
|
741
753
|
S: this,
|
|
742
754
|
C: (f, a) => f(...a)
|
|
743
755
|
});
|
|
744
756
|
return {
|
|
745
|
-
document:
|
|
757
|
+
document: Obj5.getDXN(object).toString()
|
|
746
758
|
};
|
|
747
759
|
})
|
|
748
760
|
});
|
|
@@ -760,8 +772,9 @@ import * as String10 from "effect/String";
|
|
|
760
772
|
import { AiService as AiService2, ConsolePrinter as ConsolePrinter2 } from "@dxos/ai";
|
|
761
773
|
import { AiSession as AiSession2, GenerationObserver as GenerationObserver2, createToolkit as createToolkit2, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
762
774
|
import { Template as Template2 } from "@dxos/blueprints";
|
|
763
|
-
import { Obj as
|
|
764
|
-
import {
|
|
775
|
+
import { Entity as Entity2, Obj as Obj7 } from "@dxos/echo";
|
|
776
|
+
import { Database as Database7 } from "@dxos/echo";
|
|
777
|
+
import { TracingService as TracingService4, defineFunction as defineFunction8 } from "@dxos/functions";
|
|
765
778
|
import { FunctionInvocationServiceLayerTestMocked } from "@dxos/functions-runtime/testing";
|
|
766
779
|
import { Person } from "@dxos/types";
|
|
767
780
|
import { trim as trim3 } from "@dxos/util";
|
|
@@ -802,7 +815,7 @@ import * as Effect8 from "effect/Effect";
|
|
|
802
815
|
import * as Schema8 from "effect/Schema";
|
|
803
816
|
import { defineFunction as defineFunction7 } from "@dxos/functions";
|
|
804
817
|
|
|
805
|
-
// src/
|
|
818
|
+
// src/functions/exa/data/exa-search-1748337321991.ts
|
|
806
819
|
var exa_search_1748337321991_default = {
|
|
807
820
|
requestId: "324936368a74f4db978982172bc18a6c",
|
|
808
821
|
autopromptString: "AI personal knowledge management tools projects 2024",
|
|
@@ -958,7 +971,7 @@ var exa_search_1748337321991_default = {
|
|
|
958
971
|
}
|
|
959
972
|
};
|
|
960
973
|
|
|
961
|
-
// src/
|
|
974
|
+
// src/functions/exa/data/exa-search-1748337331526.ts
|
|
962
975
|
var exa_search_1748337331526_default = {
|
|
963
976
|
requestId: "0dc12e344fa649884456960ca1a54954",
|
|
964
977
|
autopromptString: "PKM software artificial intelligence integration open source projects",
|
|
@@ -1181,7 +1194,7 @@ npm run tauri dev
|
|
|
1181
1194
|
}
|
|
1182
1195
|
};
|
|
1183
1196
|
|
|
1184
|
-
// src/
|
|
1197
|
+
// src/functions/exa/data/exa-search-1748337344119.ts
|
|
1185
1198
|
var exa_search_1748337344119_default = {
|
|
1186
1199
|
requestId: "32df0c541f9883180b35e04caece4374",
|
|
1187
1200
|
autopromptString: "open source AI knowledge management projects features comparison 2024",
|
|
@@ -1304,7 +1317,7 @@ var exa_search_1748337344119_default = {
|
|
|
1304
1317
|
}
|
|
1305
1318
|
};
|
|
1306
1319
|
|
|
1307
|
-
// src/
|
|
1320
|
+
// src/functions/exa/data/index.ts
|
|
1308
1321
|
var SEARCH_RESULTS = [
|
|
1309
1322
|
exa_search_1748337321991_default,
|
|
1310
1323
|
exa_search_1748337331526_default,
|
|
@@ -1361,29 +1374,30 @@ var levenshteinDistance = (str1, str2) => {
|
|
|
1361
1374
|
import * as Effect9 from "effect/Effect";
|
|
1362
1375
|
import * as Layer2 from "effect/Layer";
|
|
1363
1376
|
import * as Schema9 from "effect/Schema";
|
|
1364
|
-
import { Obj as
|
|
1377
|
+
import { Obj as Obj6, Query as Query2, Ref as Ref2, Type as Type3 } from "@dxos/echo";
|
|
1378
|
+
import { Database as Database6 } from "@dxos/echo";
|
|
1365
1379
|
import { SystemTypeAnnotation } from "@dxos/echo/internal";
|
|
1366
1380
|
import { Queue } from "@dxos/echo-db";
|
|
1367
|
-
import { ContextQueueService as ContextQueueService2,
|
|
1381
|
+
import { ContextQueueService as ContextQueueService2, QueueService } from "@dxos/functions";
|
|
1368
1382
|
var ResearchGraph = Schema9.Struct({
|
|
1369
1383
|
queue: Type3.Ref(Queue)
|
|
1370
|
-
}).pipe(Type3.
|
|
1384
|
+
}).pipe(Type3.object({
|
|
1371
1385
|
typename: "dxos.org/type/ResearchGraph",
|
|
1372
1386
|
version: "0.1.0"
|
|
1373
1387
|
}), SystemTypeAnnotation.set(true));
|
|
1374
1388
|
var queryResearchGraph = Effect9.fn("queryResearchGraph")(function* () {
|
|
1375
|
-
const
|
|
1389
|
+
const objects = yield* Database6.Service.runQuery(Query2.type(ResearchGraph));
|
|
1376
1390
|
return objects.at(0);
|
|
1377
1391
|
});
|
|
1378
1392
|
var createResearchGraph = Effect9.fn("createResearchGraph")(function* () {
|
|
1379
1393
|
const queue = yield* QueueService.createQueue();
|
|
1380
|
-
return yield*
|
|
1394
|
+
return yield* Database6.Service.add(Obj6.make(ResearchGraph, {
|
|
1381
1395
|
queue: Ref2.fromDXN(queue.dxn)
|
|
1382
1396
|
}));
|
|
1383
1397
|
});
|
|
1384
1398
|
var contextQueueLayerFromResearchGraph = Layer2.unwrapEffect(Effect9.gen(function* () {
|
|
1385
1399
|
const researchGraph = (yield* queryResearchGraph()) ?? (yield* createResearchGraph());
|
|
1386
|
-
const researchQueue = yield*
|
|
1400
|
+
const researchQueue = yield* Database6.Service.load(researchGraph.queue);
|
|
1387
1401
|
return ContextQueueService2.layer(researchQueue);
|
|
1388
1402
|
}));
|
|
1389
1403
|
|
|
@@ -1452,7 +1466,7 @@ var research_default = defineFunction8({
|
|
|
1452
1466
|
}),
|
|
1453
1467
|
handler: Effect10.fnUntraced(function* ({ data: { query, instructions: instructions6, mockSearch = false, entityExtraction = false } }) {
|
|
1454
1468
|
if (mockSearch) {
|
|
1455
|
-
const mockPerson = yield*
|
|
1469
|
+
const mockPerson = yield* Database7.Service.add(Obj7.make(Person.Person, {
|
|
1456
1470
|
preferredName: "John Doe",
|
|
1457
1471
|
emails: [
|
|
1458
1472
|
{
|
|
@@ -1468,14 +1482,14 @@ var research_default = defineFunction8({
|
|
|
1468
1482
|
return {
|
|
1469
1483
|
document: trim3`
|
|
1470
1484
|
The research ran in test-mode and was mocked. Proceed as usual.
|
|
1471
|
-
We reference John Doe to test reference: ${
|
|
1485
|
+
We reference John Doe to test reference: ${Obj7.getDXN(mockPerson)}
|
|
1472
1486
|
`,
|
|
1473
1487
|
objects: [
|
|
1474
|
-
|
|
1488
|
+
Obj7.toJSON(mockPerson)
|
|
1475
1489
|
]
|
|
1476
1490
|
};
|
|
1477
1491
|
}
|
|
1478
|
-
yield*
|
|
1492
|
+
yield* Database7.Service.flush({
|
|
1479
1493
|
indexes: true
|
|
1480
1494
|
});
|
|
1481
1495
|
yield* TracingService4.emitStatus({
|
|
@@ -1509,7 +1523,7 @@ var research_default = defineFunction8({
|
|
|
1509
1523
|
tag: "research"
|
|
1510
1524
|
}))
|
|
1511
1525
|
});
|
|
1512
|
-
const objects = yield* Effect10.forEach(objectDXNs, (dxn) =>
|
|
1526
|
+
const objects = yield* Effect10.forEach(objectDXNs, (dxn) => Database7.Service.resolve(dxn)).pipe(Effect10.map(Array6.map((obj) => Entity2.toJSON(obj))));
|
|
1513
1527
|
return {
|
|
1514
1528
|
document: extractLastTextBlock(result),
|
|
1515
1529
|
objects
|
|
@@ -1560,12 +1574,12 @@ var entity_extraction_default = defineFunction9({
|
|
|
1560
1574
|
})
|
|
1561
1575
|
}),
|
|
1562
1576
|
outputSchema: Schema11.Struct({
|
|
1563
|
-
entities: Schema11.optional(Schema11.Array(
|
|
1577
|
+
entities: Schema11.optional(Schema11.Array(Type4.Obj).annotations({
|
|
1564
1578
|
description: "Extracted entities."
|
|
1565
1579
|
}))
|
|
1566
1580
|
}),
|
|
1567
1581
|
handler: Effect11.fnUntraced(function* ({ data: { source: message, instructions: instructions6 } }) {
|
|
1568
|
-
const tags =
|
|
1582
|
+
const tags = Obj8.getMeta(message)?.tags;
|
|
1569
1583
|
const contact = yield* extractContact(message.sender, tags);
|
|
1570
1584
|
let organization = null;
|
|
1571
1585
|
if (contact && !contact.organization) {
|
|
@@ -1594,10 +1608,15 @@ var entity_extraction_default = defineFunction9({
|
|
|
1594
1608
|
if (created.length > 1) {
|
|
1595
1609
|
throw new Error("Multiple organizations created");
|
|
1596
1610
|
} else if (created.length === 1) {
|
|
1597
|
-
organization = yield*
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1611
|
+
organization = yield* Database8.Service.resolve(created[0], Organization.Organization);
|
|
1612
|
+
Obj8.change(organization, (org) => {
|
|
1613
|
+
const meta = Obj8.getMeta(org);
|
|
1614
|
+
meta.tags ??= [];
|
|
1615
|
+
meta.tags.push(...tags ?? []);
|
|
1616
|
+
});
|
|
1617
|
+
Obj8.change(contact, (c) => {
|
|
1618
|
+
c.organization = Ref3.make(organization);
|
|
1619
|
+
});
|
|
1601
1620
|
}
|
|
1602
1621
|
}
|
|
1603
1622
|
return {
|
|
@@ -1619,13 +1638,13 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1619
1638
|
actor
|
|
1620
1639
|
}, {
|
|
1621
1640
|
F: __dxlog_file5,
|
|
1622
|
-
L:
|
|
1641
|
+
L: 112,
|
|
1623
1642
|
S: this,
|
|
1624
1643
|
C: (f, a) => f(...a)
|
|
1625
1644
|
});
|
|
1626
1645
|
return void 0;
|
|
1627
1646
|
}
|
|
1628
|
-
const
|
|
1647
|
+
const existingContacts = yield* Database8.Service.runQuery(Filter2.type(Person2.Person));
|
|
1629
1648
|
const existingContact = existingContacts.find((contact) => contact.emails?.some((contactEmail) => contactEmail.value === email));
|
|
1630
1649
|
if (existingContact) {
|
|
1631
1650
|
log5.info("Contact already exists", {
|
|
@@ -1633,25 +1652,31 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1633
1652
|
existingContact
|
|
1634
1653
|
}, {
|
|
1635
1654
|
F: __dxlog_file5,
|
|
1636
|
-
L:
|
|
1655
|
+
L: 125,
|
|
1637
1656
|
S: this,
|
|
1638
1657
|
C: (f, a) => f(...a)
|
|
1639
1658
|
});
|
|
1640
1659
|
return existingContact;
|
|
1641
1660
|
}
|
|
1642
|
-
const newContact =
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1661
|
+
const newContact = Obj8.make(Person2.Person, {
|
|
1662
|
+
...tags ? {
|
|
1663
|
+
[Obj8.Meta]: {
|
|
1664
|
+
tags: [
|
|
1665
|
+
...tags
|
|
1666
|
+
]
|
|
1667
|
+
}
|
|
1668
|
+
} : {},
|
|
1646
1669
|
emails: [
|
|
1647
1670
|
{
|
|
1648
1671
|
value: email
|
|
1649
1672
|
}
|
|
1650
1673
|
]
|
|
1651
1674
|
});
|
|
1652
|
-
yield*
|
|
1675
|
+
yield* Database8.Service.add(newContact);
|
|
1653
1676
|
if (name) {
|
|
1654
|
-
newContact
|
|
1677
|
+
Obj8.change(newContact, (c) => {
|
|
1678
|
+
c.fullName = name;
|
|
1679
|
+
});
|
|
1655
1680
|
}
|
|
1656
1681
|
const emailDomain = email.split("@")[1]?.toLowerCase();
|
|
1657
1682
|
if (!emailDomain) {
|
|
@@ -1659,7 +1684,7 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1659
1684
|
email
|
|
1660
1685
|
}, {
|
|
1661
1686
|
F: __dxlog_file5,
|
|
1662
|
-
L:
|
|
1687
|
+
L: 143,
|
|
1663
1688
|
S: this,
|
|
1664
1689
|
C: (f, a) => f(...a)
|
|
1665
1690
|
});
|
|
@@ -1669,11 +1694,11 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1669
1694
|
emailDomain
|
|
1670
1695
|
}, {
|
|
1671
1696
|
F: __dxlog_file5,
|
|
1672
|
-
L:
|
|
1697
|
+
L: 147,
|
|
1673
1698
|
S: this,
|
|
1674
1699
|
C: (f, a) => f(...a)
|
|
1675
1700
|
});
|
|
1676
|
-
const
|
|
1701
|
+
const existingOrganisations = yield* Database8.Service.runQuery(Filter2.type(Organization.Organization));
|
|
1677
1702
|
const matchingOrg = existingOrganisations.find((org) => {
|
|
1678
1703
|
if (org.website) {
|
|
1679
1704
|
try {
|
|
@@ -1686,7 +1711,7 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1686
1711
|
error: e
|
|
1687
1712
|
}, {
|
|
1688
1713
|
F: __dxlog_file5,
|
|
1689
|
-
L:
|
|
1714
|
+
L: 165,
|
|
1690
1715
|
S: this,
|
|
1691
1716
|
C: (f, a) => f(...a)
|
|
1692
1717
|
});
|
|
@@ -1700,11 +1725,13 @@ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
|
1700
1725
|
organization: matchingOrg
|
|
1701
1726
|
}, {
|
|
1702
1727
|
F: __dxlog_file5,
|
|
1703
|
-
L:
|
|
1728
|
+
L: 176,
|
|
1704
1729
|
S: this,
|
|
1705
1730
|
C: (f, a) => f(...a)
|
|
1706
1731
|
});
|
|
1707
|
-
newContact
|
|
1732
|
+
Obj8.change(newContact, (c) => {
|
|
1733
|
+
c.organization = Ref3.make(matchingOrg);
|
|
1734
|
+
});
|
|
1708
1735
|
}
|
|
1709
1736
|
return newContact;
|
|
1710
1737
|
});
|
|
@@ -1722,15 +1749,16 @@ import * as Array9 from "effect/Array";
|
|
|
1722
1749
|
import * as Effect13 from "effect/Effect";
|
|
1723
1750
|
import * as Function5 from "effect/Function";
|
|
1724
1751
|
import * as Schema12 from "effect/Schema";
|
|
1725
|
-
import { Filter as Filter4, Obj as
|
|
1726
|
-
import {
|
|
1752
|
+
import { Filter as Filter4, Obj as Obj10, Query as Query4, Ref as Ref5 } from "@dxos/echo";
|
|
1753
|
+
import { Database as Database10 } from "@dxos/echo";
|
|
1754
|
+
import { CredentialsService as CredentialsService3, defineFunction as defineFunction10, withAuthorization } from "@dxos/functions";
|
|
1727
1755
|
import { log as log7 } from "@dxos/log";
|
|
1728
1756
|
import { Person as Person3, Project as Project2, Task as Task2 } from "@dxos/types";
|
|
1729
1757
|
|
|
1730
1758
|
// src/sync/sync.ts
|
|
1731
1759
|
import * as Effect12 from "effect/Effect";
|
|
1732
|
-
import { Filter as Filter3, Obj as
|
|
1733
|
-
import {
|
|
1760
|
+
import { Filter as Filter3, Obj as Obj9, Query as Query3, Ref as Ref4 } from "@dxos/echo";
|
|
1761
|
+
import { Database as Database9 } from "@dxos/echo";
|
|
1734
1762
|
import { failedInvariant } from "@dxos/invariant";
|
|
1735
1763
|
import { log as log6 } from "@dxos/log";
|
|
1736
1764
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/sync/sync.ts";
|
|
@@ -1741,7 +1769,7 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1741
1769
|
if (!Ref4.isRef(obj[key])) continue;
|
|
1742
1770
|
const ref = obj[key];
|
|
1743
1771
|
if (!ref.target) continue;
|
|
1744
|
-
if (
|
|
1772
|
+
if (Obj9.getDXN(ref.target).isLocalObjectId()) {
|
|
1745
1773
|
const [target] = yield* syncObjects([
|
|
1746
1774
|
ref.target
|
|
1747
1775
|
], {
|
|
@@ -1750,26 +1778,26 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1750
1778
|
obj[key] = Ref4.make(target);
|
|
1751
1779
|
}
|
|
1752
1780
|
}
|
|
1753
|
-
const schema =
|
|
1754
|
-
const foreignId =
|
|
1755
|
-
const
|
|
1781
|
+
const schema = Obj9.getSchema(obj) ?? failedInvariant("No schema.");
|
|
1782
|
+
const foreignId = Obj9.getKeys(obj, foreignKeyId)[0]?.id ?? failedInvariant("No foreign key.");
|
|
1783
|
+
const [existing] = yield* Database9.Service.runQuery(Query3.select(Filter3.foreignKeys(schema, [
|
|
1756
1784
|
{
|
|
1757
1785
|
source: foreignKeyId,
|
|
1758
1786
|
id: foreignId
|
|
1759
1787
|
}
|
|
1760
1788
|
])));
|
|
1761
1789
|
log6("sync object", {
|
|
1762
|
-
type:
|
|
1790
|
+
type: Obj9.getTypename(obj),
|
|
1763
1791
|
foreignId,
|
|
1764
|
-
existing: existing ?
|
|
1792
|
+
existing: existing ? Obj9.getDXN(existing) : void 0
|
|
1765
1793
|
}, {
|
|
1766
1794
|
F: __dxlog_file6,
|
|
1767
|
-
L:
|
|
1795
|
+
L: 48,
|
|
1768
1796
|
S: this,
|
|
1769
1797
|
C: (f, a) => f(...a)
|
|
1770
1798
|
});
|
|
1771
1799
|
if (!existing) {
|
|
1772
|
-
yield*
|
|
1800
|
+
yield* Database9.Service.add(obj);
|
|
1773
1801
|
return obj;
|
|
1774
1802
|
} else {
|
|
1775
1803
|
copyObjectData(existing, obj);
|
|
@@ -1780,23 +1808,25 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1780
1808
|
});
|
|
1781
1809
|
});
|
|
1782
1810
|
var copyObjectData = (existing, newObj) => {
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
for (const key of Object.keys(existing)) {
|
|
1789
|
-
if (typeof key !== "string" || key === "id") continue;
|
|
1790
|
-
if (!(key in newObj)) {
|
|
1791
|
-
delete existing[key];
|
|
1811
|
+
Obj9.change(existing, (obj) => {
|
|
1812
|
+
for (const key of Object.keys(newObj)) {
|
|
1813
|
+
if (typeof key !== "string" || key === "id") continue;
|
|
1814
|
+
if (typeof newObj[key] !== "string" && typeof newObj[key] !== "number" && typeof newObj[key] !== "boolean" && !Ref4.isRef(newObj[key])) continue;
|
|
1815
|
+
obj[key] = newObj[key];
|
|
1792
1816
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1817
|
+
for (const key of Object.keys(obj)) {
|
|
1818
|
+
if (typeof key !== "string" || key === "id") continue;
|
|
1819
|
+
if (!(key in newObj)) {
|
|
1820
|
+
delete obj[key];
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
for (const foreignKey of Obj9.getMeta(newObj).keys) {
|
|
1824
|
+
Obj9.deleteKeys(obj, foreignKey.source);
|
|
1825
|
+
Obj9.getMeta(obj).keys.push({
|
|
1826
|
+
...foreignKey
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1800
1830
|
};
|
|
1801
1831
|
|
|
1802
1832
|
// src/util/graphql.ts
|
|
@@ -1826,7 +1856,7 @@ query Issues($teamId: String!, $after: DateTimeOrDuration!) {
|
|
|
1826
1856
|
updatedAt
|
|
1827
1857
|
description
|
|
1828
1858
|
assignee { id, name }
|
|
1829
|
-
state {
|
|
1859
|
+
state {
|
|
1830
1860
|
name
|
|
1831
1861
|
}
|
|
1832
1862
|
project {
|
|
@@ -1857,15 +1887,16 @@ var sync_issues_default = defineFunction10({
|
|
|
1857
1887
|
})
|
|
1858
1888
|
}),
|
|
1859
1889
|
handler: Effect13.fnUntraced(function* ({ data }) {
|
|
1860
|
-
const
|
|
1890
|
+
const credential = yield* CredentialsService3.getCredential({
|
|
1861
1891
|
service: "linear.app"
|
|
1862
|
-
})
|
|
1892
|
+
});
|
|
1893
|
+
const client = yield* HttpClient.HttpClient.pipe(Effect13.map(withAuthorization(credential.apiKey)));
|
|
1863
1894
|
const after = yield* getLatestUpdateTimestamp(data.team, Task2.Task);
|
|
1864
1895
|
log7.info("will fetch", {
|
|
1865
1896
|
after
|
|
1866
1897
|
}, {
|
|
1867
1898
|
F: __dxlog_file7,
|
|
1868
|
-
L:
|
|
1899
|
+
L: 93,
|
|
1869
1900
|
S: this,
|
|
1870
1901
|
C: (f, a) => f(...a)
|
|
1871
1902
|
});
|
|
@@ -1883,7 +1914,7 @@ var sync_issues_default = defineFunction10({
|
|
|
1883
1914
|
count: tasks.length
|
|
1884
1915
|
}, {
|
|
1885
1916
|
F: __dxlog_file7,
|
|
1886
|
-
L:
|
|
1917
|
+
L: 106,
|
|
1887
1918
|
S: this,
|
|
1888
1919
|
C: (f, a) => f(...a)
|
|
1889
1920
|
});
|
|
@@ -1896,16 +1927,16 @@ var sync_issues_default = defineFunction10({
|
|
|
1896
1927
|
}, Effect13.provide(FetchHttpClient2.layer))
|
|
1897
1928
|
});
|
|
1898
1929
|
var getLatestUpdateTimestamp = Effect13.fnUntraced(function* (teamId, dataType) {
|
|
1899
|
-
const
|
|
1930
|
+
const existingTasks = yield* Database10.Service.runQuery(Query4.type(dataType).select(Filter4.foreignKeys(dataType, [
|
|
1900
1931
|
{
|
|
1901
1932
|
source: LINEAR_TEAM_ID_KEY,
|
|
1902
1933
|
id: teamId
|
|
1903
1934
|
}
|
|
1904
1935
|
])));
|
|
1905
|
-
return Function5.pipe(existingTasks, Array9.map((task) =>
|
|
1936
|
+
return Function5.pipe(existingTasks, Array9.map((task) => Obj10.getKeys(task, LINEAR_UPDATED_AT_KEY).at(0)?.id), Array9.filter((x) => x !== void 0), Array9.reduce("2025-01-01T00:00:00.000Z", (acc, x) => x > acc ? x : acc));
|
|
1906
1937
|
});
|
|
1907
|
-
var mapLinearPerson = (person, { teamId }) =>
|
|
1908
|
-
[
|
|
1938
|
+
var mapLinearPerson = (person, { teamId }) => Obj10.make(Person3.Person, {
|
|
1939
|
+
[Obj10.Meta]: {
|
|
1909
1940
|
keys: [
|
|
1910
1941
|
{
|
|
1911
1942
|
id: person.id,
|
|
@@ -1919,8 +1950,8 @@ var mapLinearPerson = (person, { teamId }) => Obj9.make(Person3.Person, {
|
|
|
1919
1950
|
},
|
|
1920
1951
|
nickname: person.name
|
|
1921
1952
|
});
|
|
1922
|
-
var mapLinearIssue = (issue, { teamId }) =>
|
|
1923
|
-
[
|
|
1953
|
+
var mapLinearIssue = (issue, { teamId }) => Obj10.make(Task2.Task, {
|
|
1954
|
+
[Obj10.Meta]: {
|
|
1924
1955
|
keys: [
|
|
1925
1956
|
{
|
|
1926
1957
|
id: issue.id,
|
|
@@ -1944,7 +1975,7 @@ var mapLinearIssue = (issue, { teamId }) => Obj9.make(Task2.Task, {
|
|
|
1944
1975
|
// TODO(dmaretskyi): Sync those (+ linear team as org?).
|
|
1945
1976
|
// state: issue.state.name,
|
|
1946
1977
|
project: !issue.project ? void 0 : Ref5.make(Project2.make({
|
|
1947
|
-
[
|
|
1978
|
+
[Obj10.Meta]: {
|
|
1948
1979
|
keys: [
|
|
1949
1980
|
{
|
|
1950
1981
|
id: issue.project.id,
|
|
@@ -1970,7 +2001,8 @@ var Linear;
|
|
|
1970
2001
|
import * as Effect14 from "effect/Effect";
|
|
1971
2002
|
import * as Schema13 from "effect/Schema";
|
|
1972
2003
|
import { ArtifactId as ArtifactId4 } from "@dxos/assistant";
|
|
1973
|
-
import {
|
|
2004
|
+
import { Database as Database11 } from "@dxos/echo";
|
|
2005
|
+
import { defineFunction as defineFunction11 } from "@dxos/functions";
|
|
1974
2006
|
import { Markdown as Markdown4 } from "@dxos/plugin-markdown/types";
|
|
1975
2007
|
var read_default2 = defineFunction11({
|
|
1976
2008
|
key: "dxos.org/function/markdown/read-tasks",
|
|
@@ -1985,8 +2017,8 @@ var read_default2 = defineFunction11({
|
|
|
1985
2017
|
content: Schema13.String
|
|
1986
2018
|
}),
|
|
1987
2019
|
handler: Effect14.fn(function* ({ data: { id } }) {
|
|
1988
|
-
const doc = yield*
|
|
1989
|
-
const { content } = yield*
|
|
2020
|
+
const doc = yield* Database11.Service.resolve(ArtifactId4.toDXN(id), Markdown4.Document);
|
|
2021
|
+
const { content } = yield* Database11.Service.load(doc.content);
|
|
1990
2022
|
const lines = content.split("\n");
|
|
1991
2023
|
const len = String(lines.length).length;
|
|
1992
2024
|
const numbered = lines.map((line, i) => `${String(i + 1).padStart(len, " ")}. ${line}`).join("\n");
|
|
@@ -2000,7 +2032,8 @@ var read_default2 = defineFunction11({
|
|
|
2000
2032
|
import * as Effect15 from "effect/Effect";
|
|
2001
2033
|
import * as Schema14 from "effect/Schema";
|
|
2002
2034
|
import { ArtifactId as ArtifactId5 } from "@dxos/assistant";
|
|
2003
|
-
import {
|
|
2035
|
+
import { Database as Database12 } from "@dxos/echo";
|
|
2036
|
+
import { defineFunction as defineFunction12 } from "@dxos/functions";
|
|
2004
2037
|
import { Markdown as Markdown5 } from "@dxos/plugin-markdown/types";
|
|
2005
2038
|
|
|
2006
2039
|
// src/functions/tasks/task-list.ts
|
|
@@ -2151,8 +2184,8 @@ var update_default2 = defineFunction12({
|
|
|
2151
2184
|
})
|
|
2152
2185
|
}),
|
|
2153
2186
|
handler: Effect15.fn(function* ({ data: { id, operations = [] } }) {
|
|
2154
|
-
const doc = yield*
|
|
2155
|
-
const { content } = yield*
|
|
2187
|
+
const doc = yield* Database12.Service.resolve(ArtifactId5.toDXN(id), Markdown5.Document);
|
|
2188
|
+
const { content } = yield* Database12.Service.load(doc.content);
|
|
2156
2189
|
const taskManager = new MarkdownTasks(content);
|
|
2157
2190
|
if (operations.length > 0) {
|
|
2158
2191
|
taskManager.applyOperations(operations);
|
|
@@ -2181,7 +2214,7 @@ var instructions = trim5`
|
|
|
2181
2214
|
When replying to the user, be terse with your comments about design doc handling.
|
|
2182
2215
|
Do not announce when you read or write the design spec document.
|
|
2183
2216
|
`;
|
|
2184
|
-
var blueprint =
|
|
2217
|
+
var blueprint = Blueprint.make({
|
|
2185
2218
|
key: "dxos.org/blueprint/design",
|
|
2186
2219
|
name: "Design Spec",
|
|
2187
2220
|
description: "Preserve the conversation in the design spec.",
|
|
@@ -2193,15 +2226,14 @@ var blueprint = Obj10.make(Blueprint.Blueprint, {
|
|
|
2193
2226
|
Document.update
|
|
2194
2227
|
].map((fn9) => ToolId.make(fn9.key))
|
|
2195
2228
|
});
|
|
2196
|
-
var design_blueprint_default = blueprint;
|
|
2197
2229
|
|
|
2198
2230
|
// src/blueprints/design/index.ts
|
|
2199
|
-
var design_default =
|
|
2231
|
+
var design_default = blueprint;
|
|
2200
2232
|
|
|
2201
2233
|
// src/blueprints/discord/discord-blueprint.ts
|
|
2202
2234
|
import { ToolId as ToolId2 } from "@dxos/ai";
|
|
2203
2235
|
import { Blueprint as Blueprint2 } from "@dxos/blueprints";
|
|
2204
|
-
import {
|
|
2236
|
+
import { Ref as Ref7 } from "@dxos/echo";
|
|
2205
2237
|
import { Text as Text3 } from "@dxos/schema";
|
|
2206
2238
|
import { trim as trim6 } from "@dxos/util";
|
|
2207
2239
|
var instructions2 = trim6`
|
|
@@ -2211,7 +2243,7 @@ var instructions2 = trim6`
|
|
|
2211
2243
|
|
|
2212
2244
|
DXOS serverId: 837138313172353095
|
|
2213
2245
|
`;
|
|
2214
|
-
var blueprint2 =
|
|
2246
|
+
var blueprint2 = Blueprint2.make({
|
|
2215
2247
|
key: "dxos.org/blueprint/discord",
|
|
2216
2248
|
name: "Discord",
|
|
2217
2249
|
description: "Discord integration.",
|
|
@@ -2222,15 +2254,14 @@ var blueprint2 = Obj11.make(Blueprint2.Blueprint, {
|
|
|
2222
2254
|
ToolId2.make(Discord.fetch.key)
|
|
2223
2255
|
]
|
|
2224
2256
|
});
|
|
2225
|
-
var discord_blueprint_default = blueprint2;
|
|
2226
2257
|
|
|
2227
2258
|
// src/blueprints/discord/index.ts
|
|
2228
|
-
var discord_default =
|
|
2259
|
+
var discord_default = blueprint2;
|
|
2229
2260
|
|
|
2230
2261
|
// src/blueprints/linear/linear-blueprint.ts
|
|
2231
2262
|
import { ToolId as ToolId3 } from "@dxos/ai";
|
|
2232
2263
|
import { Blueprint as Blueprint3 } from "@dxos/blueprints";
|
|
2233
|
-
import {
|
|
2264
|
+
import { Ref as Ref8 } from "@dxos/echo";
|
|
2234
2265
|
import { Text as Text4 } from "@dxos/schema";
|
|
2235
2266
|
import { trim as trim7 } from "@dxos/util";
|
|
2236
2267
|
var instructions3 = trim7`
|
|
@@ -2241,7 +2272,7 @@ var instructions3 = trim7`
|
|
|
2241
2272
|
|
|
2242
2273
|
DXOS teamId: 1127c63a-6f77-4725-9229-50f6cd47321c
|
|
2243
2274
|
`;
|
|
2244
|
-
var blueprint3 =
|
|
2275
|
+
var blueprint3 = Blueprint3.make({
|
|
2245
2276
|
key: "dxos.org/blueprint/linear",
|
|
2246
2277
|
name: "Linear",
|
|
2247
2278
|
description: "Syncs Linear workspaces.",
|
|
@@ -2252,15 +2283,14 @@ var blueprint3 = Obj12.make(Blueprint3.Blueprint, {
|
|
|
2252
2283
|
Linear.sync
|
|
2253
2284
|
].map((tool) => ToolId3.make(tool.key))
|
|
2254
2285
|
});
|
|
2255
|
-
var linear_blueprint_default = blueprint3;
|
|
2256
2286
|
|
|
2257
2287
|
// src/blueprints/linear/index.ts
|
|
2258
|
-
var linear_default =
|
|
2288
|
+
var linear_default = blueprint3;
|
|
2259
2289
|
|
|
2260
2290
|
// src/blueprints/planning/planning-blueprint.ts
|
|
2261
2291
|
import { ToolId as ToolId4 } from "@dxos/ai";
|
|
2262
2292
|
import { Blueprint as Blueprint4 } from "@dxos/blueprints";
|
|
2263
|
-
import {
|
|
2293
|
+
import { Ref as Ref9 } from "@dxos/echo";
|
|
2264
2294
|
import { Text as Text5 } from "@dxos/schema";
|
|
2265
2295
|
import { trim as trim8 } from "@dxos/util";
|
|
2266
2296
|
var instructions4 = trim8`
|
|
@@ -2334,7 +2364,7 @@ var instructions4 = trim8`
|
|
|
2334
2364
|
- When creating subtasks, consider the parent task's completion status
|
|
2335
2365
|
- Be precise with task descriptions and hierarchy levels
|
|
2336
2366
|
`;
|
|
2337
|
-
var blueprint4 =
|
|
2367
|
+
var blueprint4 = Blueprint4.make({
|
|
2338
2368
|
key: "dxos.org/blueprint/planning",
|
|
2339
2369
|
name: "Planning",
|
|
2340
2370
|
description: "Plans and tracks complex tasks with artifact management.",
|
|
@@ -2346,15 +2376,14 @@ var blueprint4 = Obj13.make(Blueprint4.Blueprint, {
|
|
|
2346
2376
|
Tasks.update
|
|
2347
2377
|
].map((fn9) => ToolId4.make(fn9.key))
|
|
2348
2378
|
});
|
|
2349
|
-
var planning_blueprint_default = blueprint4;
|
|
2350
2379
|
|
|
2351
2380
|
// src/blueprints/planning/index.ts
|
|
2352
|
-
var planning_default =
|
|
2381
|
+
var planning_default = blueprint4;
|
|
2353
2382
|
|
|
2354
2383
|
// src/blueprints/research/research-blueprint.ts
|
|
2355
2384
|
import { ToolId as ToolId5 } from "@dxos/ai";
|
|
2356
2385
|
import { Blueprint as Blueprint5 } from "@dxos/blueprints";
|
|
2357
|
-
import {
|
|
2386
|
+
import { Ref as Ref10 } from "@dxos/echo";
|
|
2358
2387
|
import { Text as Text6 } from "@dxos/schema";
|
|
2359
2388
|
import { trim as trim9 } from "@dxos/util";
|
|
2360
2389
|
var instructions5 = trim9`
|
|
@@ -2383,7 +2412,7 @@ var instructions5 = trim9`
|
|
|
2383
2412
|
Reply normally with the text mode of the result of your research.
|
|
2384
2413
|
</unstructured_mode>
|
|
2385
2414
|
`;
|
|
2386
|
-
var blueprint5 =
|
|
2415
|
+
var blueprint5 = Blueprint5.make({
|
|
2387
2416
|
key: "dxos.org/blueprint/research",
|
|
2388
2417
|
name: "Research",
|
|
2389
2418
|
description: "Researches the web and creates structured data.",
|
|
@@ -2395,17 +2424,16 @@ var blueprint5 = Obj14.make(Blueprint5.Blueprint, {
|
|
|
2395
2424
|
Research.research
|
|
2396
2425
|
].map((fn9) => ToolId5.make(fn9.key))
|
|
2397
2426
|
});
|
|
2398
|
-
var research_blueprint_default = blueprint5;
|
|
2399
2427
|
|
|
2400
2428
|
// src/blueprints/research/index.ts
|
|
2401
|
-
var research_default2 =
|
|
2429
|
+
var research_default2 = blueprint5;
|
|
2402
2430
|
|
|
2403
2431
|
// src/blueprints/websearch/websearch-blueprint.ts
|
|
2404
2432
|
import { ToolId as ToolId6 } from "@dxos/ai";
|
|
2405
2433
|
import { Blueprint as Blueprint6 } from "@dxos/blueprints";
|
|
2406
|
-
import {
|
|
2434
|
+
import { Ref as Ref11 } from "@dxos/echo";
|
|
2407
2435
|
import { Text as Text7 } from "@dxos/schema";
|
|
2408
|
-
var blueprint6 =
|
|
2436
|
+
var blueprint6 = Blueprint6.make({
|
|
2409
2437
|
key: "dxos.org/blueprint/web-search",
|
|
2410
2438
|
name: "Web Search",
|
|
2411
2439
|
description: "Search the web.",
|
|
@@ -2416,7 +2444,6 @@ var blueprint6 = Obj15.make(Blueprint6.Blueprint, {
|
|
|
2416
2444
|
ToolId6.make("AnthropicWebSearch")
|
|
2417
2445
|
]
|
|
2418
2446
|
});
|
|
2419
|
-
var websearch_blueprint_default = blueprint6;
|
|
2420
2447
|
|
|
2421
2448
|
// src/blueprints/websearch/websearch-toolkit.ts
|
|
2422
2449
|
import * as Toolkit4 from "@effect/ai/Toolkit";
|
|
@@ -2424,44 +2451,7 @@ import * as AnthropicTool2 from "@effect/ai-anthropic/AnthropicTool";
|
|
|
2424
2451
|
var WebSearchToolkit = Toolkit4.make(AnthropicTool2.WebSearch_20250305({}));
|
|
2425
2452
|
|
|
2426
2453
|
// src/blueprints/websearch/index.ts
|
|
2427
|
-
var websearch_default =
|
|
2428
|
-
|
|
2429
|
-
// src/plugins.tsx
|
|
2430
|
-
import * as Schema15 from "effect/Schema";
|
|
2431
|
-
import React from "react";
|
|
2432
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
2433
|
-
import { Format, Type as Type4 } from "@dxos/echo";
|
|
2434
|
-
import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
|
|
2435
|
-
var MapSchema = Schema15.Struct({
|
|
2436
|
-
coordinates: Format.GeoPoint
|
|
2437
|
-
}).pipe(Type4.Obj({
|
|
2438
|
-
typename: "example.com/type/Map",
|
|
2439
|
-
version: "0.1.0"
|
|
2440
|
-
}));
|
|
2441
|
-
var isImage = (data) => false;
|
|
2442
|
-
var capabilities = [
|
|
2443
|
-
contributes(Capabilities.ReactSurface, createSurface({
|
|
2444
|
-
id: "plugin-image",
|
|
2445
|
-
role: "card--extrinsic",
|
|
2446
|
-
filter: (data) => isImage(data.value),
|
|
2447
|
-
component: ({ data }) => /* @__PURE__ */ React.createElement("img", {
|
|
2448
|
-
className: "grow object-cover",
|
|
2449
|
-
src: `data:image/jpeg;base64,${data.value.source.data}`,
|
|
2450
|
-
alt: data.value.prompt ?? `Generated image [id=${data.value.id}]`
|
|
2451
|
-
})
|
|
2452
|
-
})),
|
|
2453
|
-
//
|
|
2454
|
-
// Default
|
|
2455
|
-
//
|
|
2456
|
-
contributes(Capabilities.ReactSurface, createSurface({
|
|
2457
|
-
id: "plugin-default",
|
|
2458
|
-
role: "card--extrinsic",
|
|
2459
|
-
position: "fallback",
|
|
2460
|
-
component: ({ role, data }) => /* @__PURE__ */ React.createElement(JsonFilter, {
|
|
2461
|
-
data
|
|
2462
|
-
})
|
|
2463
|
-
}))
|
|
2464
|
-
];
|
|
2454
|
+
var websearch_default = blueprint6;
|
|
2465
2455
|
|
|
2466
2456
|
// src/toolkits/AssistantToolkit.ts
|
|
2467
2457
|
var AssistantToolkit_exports = {};
|
|
@@ -2474,39 +2464,64 @@ import * as Tool2 from "@effect/ai/Tool";
|
|
|
2474
2464
|
import * as Toolkit5 from "@effect/ai/Toolkit";
|
|
2475
2465
|
import * as Effect16 from "effect/Effect";
|
|
2476
2466
|
import * as Record from "effect/Record";
|
|
2477
|
-
import * as
|
|
2467
|
+
import * as Schema15 from "effect/Schema";
|
|
2478
2468
|
import { AiContextService, ArtifactId as ArtifactId6 } from "@dxos/assistant";
|
|
2479
|
-
import {
|
|
2480
|
-
import { DatabaseService as DatabaseService13 } from "@dxos/functions";
|
|
2469
|
+
import { Database as Database13 } from "@dxos/echo";
|
|
2481
2470
|
import { trim as trim10 } from "@dxos/util";
|
|
2482
|
-
var AssistantToolkit = Toolkit5.make(Tool2.make("add
|
|
2471
|
+
var AssistantToolkit = Toolkit5.make(Tool2.make("context-add", {
|
|
2483
2472
|
description: trim10`
|
|
2484
2473
|
Adds the object to the chat context.
|
|
2485
2474
|
`,
|
|
2486
2475
|
parameters: {
|
|
2487
2476
|
id: ArtifactId6.annotations({
|
|
2488
|
-
description: "The ID of the document to
|
|
2477
|
+
description: "The ID of the document to add."
|
|
2478
|
+
})
|
|
2479
|
+
},
|
|
2480
|
+
success: Schema15.Void,
|
|
2481
|
+
failure: Schema15.Never,
|
|
2482
|
+
dependencies: [
|
|
2483
|
+
AiContextService,
|
|
2484
|
+
Database13.Service
|
|
2485
|
+
]
|
|
2486
|
+
}), Tool2.make("context-remove", {
|
|
2487
|
+
description: trim10`
|
|
2488
|
+
Removes the object from the chat context.
|
|
2489
|
+
`,
|
|
2490
|
+
parameters: {
|
|
2491
|
+
id: ArtifactId6.annotations({
|
|
2492
|
+
description: "The ID of the document to remove."
|
|
2489
2493
|
})
|
|
2490
2494
|
},
|
|
2491
|
-
success:
|
|
2492
|
-
failure:
|
|
2495
|
+
success: Schema15.Void,
|
|
2496
|
+
failure: Schema15.Never,
|
|
2493
2497
|
dependencies: [
|
|
2494
2498
|
AiContextService,
|
|
2495
|
-
|
|
2499
|
+
Database13.Service
|
|
2496
2500
|
]
|
|
2497
2501
|
}));
|
|
2498
2502
|
var tools = Record.keys(AssistantToolkit.tools);
|
|
2499
2503
|
var layer3 = () => AssistantToolkit.toLayer({
|
|
2500
|
-
"add
|
|
2504
|
+
["context-add"]: Effect16.fnUntraced(function* ({ id }) {
|
|
2501
2505
|
const { binder } = yield* AiContextService;
|
|
2502
|
-
const { db } = yield*
|
|
2503
|
-
const ref =
|
|
2506
|
+
const { db } = yield* Database13.Service;
|
|
2507
|
+
const ref = db.makeRef(ArtifactId6.toDXN(id, db.spaceId));
|
|
2504
2508
|
yield* Effect16.promise(() => binder.bind({
|
|
2505
2509
|
blueprints: [],
|
|
2506
2510
|
objects: [
|
|
2507
2511
|
ref
|
|
2508
2512
|
]
|
|
2509
2513
|
}));
|
|
2514
|
+
}),
|
|
2515
|
+
["context-remove"]: Effect16.fnUntraced(function* ({ id }) {
|
|
2516
|
+
const { binder } = yield* AiContextService;
|
|
2517
|
+
const { db } = yield* Database13.Service;
|
|
2518
|
+
const ref = db.makeRef(ArtifactId6.toDXN(id, db.spaceId));
|
|
2519
|
+
yield* Effect16.promise(() => binder.unbind({
|
|
2520
|
+
blueprints: [],
|
|
2521
|
+
objects: [
|
|
2522
|
+
ref
|
|
2523
|
+
]
|
|
2524
|
+
}));
|
|
2510
2525
|
})
|
|
2511
2526
|
});
|
|
2512
2527
|
|
|
@@ -2521,11 +2536,12 @@ import * as Tool3 from "@effect/ai/Tool";
|
|
|
2521
2536
|
import * as Toolkit6 from "@effect/ai/Toolkit";
|
|
2522
2537
|
import * as Effect17 from "effect/Effect";
|
|
2523
2538
|
import * as Record2 from "effect/Record";
|
|
2524
|
-
import * as
|
|
2539
|
+
import * as Schema16 from "effect/Schema";
|
|
2525
2540
|
import { ArtifactId as ArtifactId7 } from "@dxos/assistant";
|
|
2526
|
-
import { DXN as DXN2, Obj as
|
|
2527
|
-
import {
|
|
2541
|
+
import { DXN as DXN2, Database as Database14, Entity as Entity3, Filter as Filter5, Obj as Obj11, Relation as Relation2, Tag as Tag2, Type as Type5 } from "@dxos/echo";
|
|
2542
|
+
import { invariant } from "@dxos/invariant";
|
|
2528
2543
|
import { trim as trim11 } from "@dxos/util";
|
|
2544
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/toolkits/SystemToolkit.ts";
|
|
2529
2545
|
var SystemToolkit = Toolkit6.make(
|
|
2530
2546
|
//
|
|
2531
2547
|
// Schema
|
|
@@ -2536,13 +2552,13 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2536
2552
|
`,
|
|
2537
2553
|
parameters: {
|
|
2538
2554
|
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
2539
|
-
limit:
|
|
2555
|
+
limit: Schema16.Number
|
|
2540
2556
|
},
|
|
2541
2557
|
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
2542
|
-
success:
|
|
2543
|
-
failure:
|
|
2558
|
+
success: Schema16.Any,
|
|
2559
|
+
failure: Schema16.Never,
|
|
2544
2560
|
dependencies: [
|
|
2545
|
-
|
|
2561
|
+
Database14.Service
|
|
2546
2562
|
]
|
|
2547
2563
|
}),
|
|
2548
2564
|
Tool3.make("schema-add", {
|
|
@@ -2552,14 +2568,31 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2552
2568
|
The typename must be in the format of "example.com/type/Type".
|
|
2553
2569
|
`,
|
|
2554
2570
|
parameters: {
|
|
2555
|
-
name:
|
|
2556
|
-
typename:
|
|
2557
|
-
jsonSchema:
|
|
2571
|
+
name: Schema16.String,
|
|
2572
|
+
typename: Schema16.String,
|
|
2573
|
+
jsonSchema: Schema16.Any
|
|
2558
2574
|
},
|
|
2559
|
-
success:
|
|
2560
|
-
failure:
|
|
2575
|
+
success: Schema16.Any,
|
|
2576
|
+
failure: Schema16.Never,
|
|
2561
2577
|
dependencies: [
|
|
2562
|
-
|
|
2578
|
+
Database14.Service
|
|
2579
|
+
]
|
|
2580
|
+
}),
|
|
2581
|
+
//
|
|
2582
|
+
// Query
|
|
2583
|
+
//
|
|
2584
|
+
Tool3.make("query", {
|
|
2585
|
+
description: trim11`
|
|
2586
|
+
Queries objects in the space.
|
|
2587
|
+
Get the typename from the schema-list tool.
|
|
2588
|
+
`,
|
|
2589
|
+
parameters: {
|
|
2590
|
+
typename: Schema16.String
|
|
2591
|
+
},
|
|
2592
|
+
success: Schema16.Any,
|
|
2593
|
+
failure: Schema16.Never,
|
|
2594
|
+
dependencies: [
|
|
2595
|
+
Database14.Service
|
|
2563
2596
|
]
|
|
2564
2597
|
}),
|
|
2565
2598
|
//
|
|
@@ -2571,28 +2604,47 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2571
2604
|
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2572
2605
|
`,
|
|
2573
2606
|
parameters: {
|
|
2574
|
-
typename:
|
|
2575
|
-
data:
|
|
2607
|
+
typename: Schema16.String,
|
|
2608
|
+
data: Schema16.Any
|
|
2609
|
+
},
|
|
2610
|
+
success: Schema16.Any,
|
|
2611
|
+
failure: Schema16.Never,
|
|
2612
|
+
dependencies: [
|
|
2613
|
+
Database14.Service
|
|
2614
|
+
]
|
|
2615
|
+
}),
|
|
2616
|
+
Tool3.make("object-delete", {
|
|
2617
|
+
description: trim11`
|
|
2618
|
+
Deletes the object.
|
|
2619
|
+
`,
|
|
2620
|
+
parameters: {
|
|
2621
|
+
id: ArtifactId7.annotations({
|
|
2622
|
+
description: "The ID of the object."
|
|
2623
|
+
})
|
|
2576
2624
|
},
|
|
2577
|
-
success:
|
|
2578
|
-
failure:
|
|
2625
|
+
success: Schema16.Any,
|
|
2626
|
+
failure: Schema16.Never,
|
|
2579
2627
|
dependencies: [
|
|
2580
|
-
|
|
2628
|
+
Database14.Service
|
|
2581
2629
|
]
|
|
2582
2630
|
}),
|
|
2583
|
-
Tool3.make("object-
|
|
2631
|
+
Tool3.make("object-update", {
|
|
2584
2632
|
description: trim11`
|
|
2585
|
-
|
|
2633
|
+
Updates the object properties.
|
|
2586
2634
|
`,
|
|
2587
2635
|
parameters: {
|
|
2588
2636
|
id: ArtifactId7.annotations({
|
|
2589
2637
|
description: "The ID of the object."
|
|
2638
|
+
}),
|
|
2639
|
+
properties: Schema16.Record({
|
|
2640
|
+
key: Schema16.String,
|
|
2641
|
+
value: Schema16.Any
|
|
2590
2642
|
})
|
|
2591
2643
|
},
|
|
2592
|
-
success:
|
|
2593
|
-
failure:
|
|
2644
|
+
success: Schema16.Any,
|
|
2645
|
+
failure: Schema16.Never,
|
|
2594
2646
|
dependencies: [
|
|
2595
|
-
|
|
2647
|
+
Database14.Service
|
|
2596
2648
|
]
|
|
2597
2649
|
}),
|
|
2598
2650
|
//
|
|
@@ -2604,21 +2656,36 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2604
2656
|
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2605
2657
|
`,
|
|
2606
2658
|
parameters: {
|
|
2607
|
-
typename:
|
|
2659
|
+
typename: Schema16.String,
|
|
2608
2660
|
source: ArtifactId7.annotations({
|
|
2609
2661
|
description: "The ID of the source object."
|
|
2610
2662
|
}),
|
|
2611
2663
|
target: ArtifactId7.annotations({
|
|
2612
2664
|
description: "The ID of the target object."
|
|
2613
2665
|
}),
|
|
2614
|
-
data:
|
|
2666
|
+
data: Schema16.Any.annotations({
|
|
2615
2667
|
description: "The data to be stored in the relation."
|
|
2616
2668
|
})
|
|
2617
2669
|
},
|
|
2618
|
-
success:
|
|
2619
|
-
failure:
|
|
2670
|
+
success: Schema16.Any,
|
|
2671
|
+
failure: Schema16.Never,
|
|
2620
2672
|
dependencies: [
|
|
2621
|
-
|
|
2673
|
+
Database14.Service
|
|
2674
|
+
]
|
|
2675
|
+
}),
|
|
2676
|
+
Tool3.make("relation-delete", {
|
|
2677
|
+
description: trim11`
|
|
2678
|
+
Deletes the relation.
|
|
2679
|
+
`,
|
|
2680
|
+
parameters: {
|
|
2681
|
+
id: ArtifactId7.annotations({
|
|
2682
|
+
description: "The ID of the relation."
|
|
2683
|
+
})
|
|
2684
|
+
},
|
|
2685
|
+
success: Schema16.Any,
|
|
2686
|
+
failure: Schema16.Never,
|
|
2687
|
+
dependencies: [
|
|
2688
|
+
Database14.Service
|
|
2622
2689
|
]
|
|
2623
2690
|
}),
|
|
2624
2691
|
//
|
|
@@ -2637,10 +2704,10 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2637
2704
|
description: "The ID of the object."
|
|
2638
2705
|
})
|
|
2639
2706
|
},
|
|
2640
|
-
success:
|
|
2641
|
-
failure:
|
|
2707
|
+
success: Schema16.Any,
|
|
2708
|
+
failure: Schema16.Never,
|
|
2642
2709
|
dependencies: [
|
|
2643
|
-
|
|
2710
|
+
Database14.Service
|
|
2644
2711
|
]
|
|
2645
2712
|
}),
|
|
2646
2713
|
Tool3.make("tag-remove", {
|
|
@@ -2656,17 +2723,17 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2656
2723
|
description: "The ID of the object."
|
|
2657
2724
|
})
|
|
2658
2725
|
},
|
|
2659
|
-
success:
|
|
2660
|
-
failure:
|
|
2726
|
+
success: Schema16.Any,
|
|
2727
|
+
failure: Schema16.Never,
|
|
2661
2728
|
dependencies: [
|
|
2662
|
-
|
|
2729
|
+
Database14.Service
|
|
2663
2730
|
]
|
|
2664
2731
|
})
|
|
2665
2732
|
);
|
|
2666
2733
|
var tools2 = Record2.keys(SystemToolkit.tools);
|
|
2667
2734
|
var layer4 = () => SystemToolkit.toLayer({
|
|
2668
|
-
"schema-list": Effect17.fnUntraced(function* () {
|
|
2669
|
-
const { db } = yield*
|
|
2735
|
+
["schema-list"]: Effect17.fnUntraced(function* () {
|
|
2736
|
+
const { db } = yield* Database14.Service;
|
|
2670
2737
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2671
2738
|
location: [
|
|
2672
2739
|
"database",
|
|
@@ -2682,8 +2749,8 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2682
2749
|
};
|
|
2683
2750
|
});
|
|
2684
2751
|
}),
|
|
2685
|
-
"schema-add": Effect17.fnUntraced(function* ({ name, typename, jsonSchema }) {
|
|
2686
|
-
const { db } = yield*
|
|
2752
|
+
["schema-add"]: Effect17.fnUntraced(function* ({ name, typename, jsonSchema }) {
|
|
2753
|
+
const { db } = yield* Database14.Service;
|
|
2687
2754
|
yield* Effect17.promise(() => db.schemaRegistry.register([
|
|
2688
2755
|
{
|
|
2689
2756
|
typename,
|
|
@@ -2693,8 +2760,12 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2693
2760
|
}
|
|
2694
2761
|
]));
|
|
2695
2762
|
}),
|
|
2696
|
-
"
|
|
2697
|
-
const
|
|
2763
|
+
["query"]: Effect17.fnUntraced(function* ({ typename }) {
|
|
2764
|
+
const objects = yield* Database14.Service.runQuery(Filter5.typename(typename));
|
|
2765
|
+
return objects;
|
|
2766
|
+
}),
|
|
2767
|
+
["object-create"]: Effect17.fnUntraced(function* ({ typename, data }) {
|
|
2768
|
+
const { db } = yield* Database14.Service;
|
|
2698
2769
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2699
2770
|
typename,
|
|
2700
2771
|
location: [
|
|
@@ -2702,17 +2773,35 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2702
2773
|
"runtime"
|
|
2703
2774
|
]
|
|
2704
2775
|
}).first());
|
|
2705
|
-
|
|
2776
|
+
invariant(Type5.isObjectSchema(schema), "Schema is not an object schema", {
|
|
2777
|
+
F: __dxlog_file8,
|
|
2778
|
+
L: 238,
|
|
2779
|
+
S: this,
|
|
2780
|
+
A: [
|
|
2781
|
+
"Type.isObjectSchema(schema)",
|
|
2782
|
+
"'Schema is not an object schema'"
|
|
2783
|
+
]
|
|
2784
|
+
});
|
|
2785
|
+
const object = db.add(Obj11.make(schema, data));
|
|
2706
2786
|
return object;
|
|
2707
2787
|
}),
|
|
2708
|
-
"object-
|
|
2709
|
-
const { db } = yield*
|
|
2710
|
-
const object = yield*
|
|
2788
|
+
["object-delete"]: Effect17.fnUntraced(function* ({ id }) {
|
|
2789
|
+
const { db } = yield* Database14.Service;
|
|
2790
|
+
const object = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2711
2791
|
db.remove(object);
|
|
2712
2792
|
return object;
|
|
2713
2793
|
}),
|
|
2714
|
-
"
|
|
2715
|
-
const
|
|
2794
|
+
["object-update"]: Effect17.fnUntraced(function* ({ id, properties }) {
|
|
2795
|
+
const object = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2796
|
+
Entity3.change(object, (obj) => {
|
|
2797
|
+
for (const [key, value2] of Object.entries(properties)) {
|
|
2798
|
+
obj[key] = value2;
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2801
|
+
return object;
|
|
2802
|
+
}),
|
|
2803
|
+
["relation-create"]: Effect17.fnUntraced(function* ({ typename, source, target, data }) {
|
|
2804
|
+
const { db } = yield* Database14.Service;
|
|
2716
2805
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2717
2806
|
typename,
|
|
2718
2807
|
location: [
|
|
@@ -2720,8 +2809,17 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2720
2809
|
"runtime"
|
|
2721
2810
|
]
|
|
2722
2811
|
}).first());
|
|
2723
|
-
|
|
2724
|
-
|
|
2812
|
+
invariant(Type5.isRelationSchema(schema), "Schema is not a relation schema", {
|
|
2813
|
+
F: __dxlog_file8,
|
|
2814
|
+
L: 267,
|
|
2815
|
+
S: this,
|
|
2816
|
+
A: [
|
|
2817
|
+
"Type.isRelationSchema(schema)",
|
|
2818
|
+
"'Schema is not a relation schema'"
|
|
2819
|
+
]
|
|
2820
|
+
});
|
|
2821
|
+
const sourceObj = yield* Database14.Service.resolve(DXN2.parse(source));
|
|
2822
|
+
const targetObj = yield* Database14.Service.resolve(DXN2.parse(target));
|
|
2725
2823
|
const relation = db.add(Relation2.make(schema, {
|
|
2726
2824
|
[Relation2.Source]: sourceObj,
|
|
2727
2825
|
[Relation2.Target]: targetObj,
|
|
@@ -2729,14 +2827,20 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2729
2827
|
}));
|
|
2730
2828
|
return relation;
|
|
2731
2829
|
}),
|
|
2732
|
-
"
|
|
2733
|
-
const
|
|
2734
|
-
|
|
2830
|
+
["relation-delete"]: Effect17.fnUntraced(function* ({ id }) {
|
|
2831
|
+
const { db } = yield* Database14.Service;
|
|
2832
|
+
const relation = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2833
|
+
db.remove(relation);
|
|
2834
|
+
return relation;
|
|
2835
|
+
}),
|
|
2836
|
+
["tag-add"]: Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2837
|
+
const object = yield* Database14.Service.resolve(DXN2.parse(objectId));
|
|
2838
|
+
Entity3.change(object, (obj) => Entity3.addTag(obj, DXN2.parse(tagId).toString()));
|
|
2735
2839
|
return object;
|
|
2736
2840
|
}),
|
|
2737
|
-
"tag-remove": Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2738
|
-
const object = yield*
|
|
2739
|
-
|
|
2841
|
+
["tag-remove"]: Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2842
|
+
const object = yield* Database14.Service.resolve(DXN2.parse(objectId));
|
|
2843
|
+
Entity3.change(object, (obj) => Entity3.removeTag(obj, DXN2.parse(tagId).toString()));
|
|
2740
2844
|
return object;
|
|
2741
2845
|
})
|
|
2742
2846
|
});
|
|
@@ -2752,7 +2856,6 @@ export {
|
|
|
2752
2856
|
linear_default as LinearBlueprint,
|
|
2753
2857
|
LocalSearchHandler,
|
|
2754
2858
|
LocalSearchToolkit,
|
|
2755
|
-
MapSchema,
|
|
2756
2859
|
planning_default as PlanningBlueprint,
|
|
2757
2860
|
Research,
|
|
2758
2861
|
research_default2 as ResearchBlueprint,
|
|
@@ -2763,7 +2866,6 @@ export {
|
|
|
2763
2866
|
Tasks,
|
|
2764
2867
|
websearch_default as WebSearchBlueprint,
|
|
2765
2868
|
WebSearchToolkit,
|
|
2766
|
-
capabilities,
|
|
2767
2869
|
contextQueueLayerFromResearchGraph,
|
|
2768
2870
|
createExtractionSchema,
|
|
2769
2871
|
createResearchGraph,
|