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