@dxos/assistant-toolkit 0.8.4-main.72ec0f3 → 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 +388 -285
- 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 +388 -285
- 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 +10 -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 +10 -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 +100 -99
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +100 -99
- 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 +9 -8
- 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/research/types.d.ts +1 -1
- package/dist/types/src/functions/research/types.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 +32 -40
- 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 +46 -28
- 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 +13 -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/research/types.ts +1 -1
- 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} +15 -15
- 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,13 +404,13 @@ 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 { Obj as
|
|
396
|
-
import {
|
|
397
|
-
import {
|
|
407
|
+
import { Entity, Filter, Obj as Obj4, Query, Type as Type2 } from "@dxos/echo";
|
|
408
|
+
import { Database as Database4 } from "@dxos/echo";
|
|
409
|
+
import { ReferenceAnnotationId, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, createObject, getTypeAnnotation, getTypeIdentifierAnnotation } from "@dxos/echo/internal";
|
|
398
410
|
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
399
411
|
import { mapAst } from "@dxos/effect";
|
|
400
|
-
import { ContextQueueService
|
|
401
|
-
import { DXN } from "@dxos/keys";
|
|
412
|
+
import { ContextQueueService } from "@dxos/functions";
|
|
413
|
+
import { DXN, ObjectId } from "@dxos/keys";
|
|
402
414
|
import { log as log3 } from "@dxos/log";
|
|
403
415
|
import { deepMapValues, isNonNullable, trim } from "@dxos/util";
|
|
404
416
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/crud/graph.ts";
|
|
@@ -407,17 +419,15 @@ var Subgraph = Schema5.Struct({
|
|
|
407
419
|
objects: Schema5.Array(Schema5.Any)
|
|
408
420
|
});
|
|
409
421
|
var findRelatedSchema = async (db, anchor) => {
|
|
410
|
-
const allSchemas =
|
|
411
|
-
...db.graph.schemaRegistry.schemas
|
|
412
|
-
];
|
|
422
|
+
const allSchemas = await db.graph.schemaRegistry.query().run();
|
|
413
423
|
return allSchemas.filter((schema) => {
|
|
414
|
-
if (getTypeAnnotation(schema)?.kind !==
|
|
424
|
+
if (getTypeAnnotation(schema)?.kind !== Entity.Kind.Relation) {
|
|
415
425
|
return false;
|
|
416
426
|
}
|
|
417
427
|
return isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).sourceSchema)) || isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).targetSchema));
|
|
418
428
|
}).map((schema) => ({
|
|
419
|
-
|
|
420
|
-
|
|
429
|
+
kind: "relation",
|
|
430
|
+
schema
|
|
421
431
|
}));
|
|
422
432
|
};
|
|
423
433
|
var isSchemaAddressableByDxn = (schema, dxn) => {
|
|
@@ -426,7 +436,7 @@ var isSchemaAddressableByDxn = (schema, dxn) => {
|
|
|
426
436
|
}
|
|
427
437
|
const t = dxn.asTypeDXN();
|
|
428
438
|
if (t) {
|
|
429
|
-
return t.type ===
|
|
439
|
+
return t.type === Type2.getTypename(schema);
|
|
430
440
|
}
|
|
431
441
|
return false;
|
|
432
442
|
};
|
|
@@ -440,12 +450,12 @@ var LocalSearchToolkit = Toolkit.make(Tool.make("search_local_search", {
|
|
|
440
450
|
success: Schema5.Unknown,
|
|
441
451
|
failure: Schema5.Never,
|
|
442
452
|
dependencies: [
|
|
443
|
-
|
|
453
|
+
Database4.Service
|
|
444
454
|
]
|
|
445
455
|
}));
|
|
446
456
|
var LocalSearchHandler = LocalSearchToolkit.toLayer({
|
|
447
457
|
search_local_search: Effect5.fn(function* ({ query }) {
|
|
448
|
-
const
|
|
458
|
+
const objects = yield* Database4.Service.runQuery(Query.select(Filter.text(query, {
|
|
449
459
|
type: "vector"
|
|
450
460
|
})));
|
|
451
461
|
const results = [
|
|
@@ -472,7 +482,7 @@ var makeGraphWriterToolkit = ({ schema }) => {
|
|
|
472
482
|
success: Schema5.Unknown,
|
|
473
483
|
failure: Schema5.Never,
|
|
474
484
|
dependencies: [
|
|
475
|
-
|
|
485
|
+
Database4.Service,
|
|
476
486
|
ContextQueueService
|
|
477
487
|
]
|
|
478
488
|
}).annotateContext(Context.make(GraphWriterSchema, {
|
|
@@ -483,11 +493,11 @@ var makeGraphWriterHandler = (toolkit, { onAppend } = {}) => {
|
|
|
483
493
|
const { schema } = Context.get(toolkit.tools.graph_writer.annotations, GraphWriterSchema);
|
|
484
494
|
return toolkit.toLayer({
|
|
485
495
|
graph_writer: Effect5.fn(function* (input) {
|
|
486
|
-
const { db } = yield*
|
|
496
|
+
const { db } = yield* Database4.Service;
|
|
487
497
|
const { queue } = yield* ContextQueueService;
|
|
488
498
|
const data = yield* Effect5.promise(() => sanitizeObjects(schema, input, db, queue));
|
|
489
499
|
yield* Effect5.promise(() => queue.append(data));
|
|
490
|
-
const dxns = data.map((obj) =>
|
|
500
|
+
const dxns = data.map((obj) => Obj4.getDXN(obj));
|
|
491
501
|
onAppend?.(dxns);
|
|
492
502
|
return dxns;
|
|
493
503
|
})
|
|
@@ -498,13 +508,13 @@ var createExtractionSchema = (types) => {
|
|
|
498
508
|
...Object.fromEntries(types.map(preprocessSchema).map((schema, index) => [
|
|
499
509
|
`objects_${getSanitizedSchemaName(types[index])}`,
|
|
500
510
|
Schema5.optional(Schema5.Array(schema)).annotations({
|
|
501
|
-
description: `The objects of type: ${
|
|
511
|
+
description: `The objects of type: ${Type2.getDXN(types[index])?.asTypeDXN().type}. ${SchemaAST.getDescriptionAnnotation(types[index].ast).pipe(Option3.getOrElse(() => ""))}`
|
|
502
512
|
})
|
|
503
513
|
]))
|
|
504
514
|
});
|
|
505
515
|
};
|
|
506
516
|
var getSanitizedSchemaName = (schema) => {
|
|
507
|
-
return
|
|
517
|
+
return Type2.getDXN(schema).asTypeDXN().type.replaceAll(/[^a-zA-Z0-9]+/g, "_");
|
|
508
518
|
};
|
|
509
519
|
var sanitizeObjects = async (types, data, db, queue) => {
|
|
510
520
|
const entries = types.map((type) => data[`objects_${getSanitizedSchemaName(type)}`]?.map((object) => ({
|
|
@@ -549,14 +559,14 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
549
559
|
}
|
|
550
560
|
return recurse(value2);
|
|
551
561
|
});
|
|
552
|
-
if (
|
|
562
|
+
if (Entity.getKind(entry.schema) === "relation") {
|
|
553
563
|
const sourceDxn = resolveId(data2.source);
|
|
554
564
|
if (!sourceDxn) {
|
|
555
565
|
log3.warn("source not found", {
|
|
556
566
|
source: data2.source
|
|
557
567
|
}, {
|
|
558
568
|
F: __dxlog_file3,
|
|
559
|
-
L:
|
|
569
|
+
L: 273,
|
|
560
570
|
S: void 0,
|
|
561
571
|
C: (f, a) => f(...a)
|
|
562
572
|
});
|
|
@@ -567,7 +577,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
567
577
|
target: data2.target
|
|
568
578
|
}, {
|
|
569
579
|
F: __dxlog_file3,
|
|
570
|
-
L:
|
|
580
|
+
L: 277,
|
|
571
581
|
S: void 0,
|
|
572
582
|
C: (f, a) => f(...a)
|
|
573
583
|
});
|
|
@@ -582,7 +592,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
582
592
|
schema: entry.schema
|
|
583
593
|
};
|
|
584
594
|
}).filter((object) => !existingIds.has(object.data.id));
|
|
585
|
-
const
|
|
595
|
+
const dbObjects = await db.query(Query.select(Filter.id(...existingIds))).run();
|
|
586
596
|
const queueObjects = await queue?.getObjectsById([
|
|
587
597
|
...existingIds
|
|
588
598
|
]) ?? [];
|
|
@@ -596,7 +606,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
596
606
|
existingIds
|
|
597
607
|
}, {
|
|
598
608
|
F: __dxlog_file3,
|
|
599
|
-
L:
|
|
609
|
+
L: 298,
|
|
600
610
|
S: void 0,
|
|
601
611
|
C: (f, a) => f(...a)
|
|
602
612
|
});
|
|
@@ -627,7 +637,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
|
|
|
627
637
|
}
|
|
628
638
|
}
|
|
629
639
|
if (!skip) {
|
|
630
|
-
const obj =
|
|
640
|
+
const obj = createObject(schema, data2);
|
|
631
641
|
enitties.set(obj.id, obj);
|
|
632
642
|
return [
|
|
633
643
|
obj
|
|
@@ -642,7 +652,7 @@ var SoftRef = Schema5.Struct({
|
|
|
642
652
|
description: "Reference to another object."
|
|
643
653
|
});
|
|
644
654
|
var preprocessSchema = (schema) => {
|
|
645
|
-
const isRelationSchema =
|
|
655
|
+
const isRelationSchema = Entity.getKind(schema) === "relation";
|
|
646
656
|
const go = (ast, visited = /* @__PURE__ */ new Set()) => {
|
|
647
657
|
if (visited.has(ast)) {
|
|
648
658
|
return ast;
|
|
@@ -671,8 +681,9 @@ var preprocessSchema = (schema) => {
|
|
|
671
681
|
import * as Effect6 from "effect/Effect";
|
|
672
682
|
import * as Schema6 from "effect/Schema";
|
|
673
683
|
import { ArtifactId as ArtifactId3 } from "@dxos/assistant";
|
|
674
|
-
import { Obj as
|
|
675
|
-
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";
|
|
676
687
|
import { log as log4 } from "@dxos/log";
|
|
677
688
|
import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
|
|
678
689
|
import { HasSubject } from "@dxos/types";
|
|
@@ -710,27 +721,27 @@ var document_create_default = defineFunction5({
|
|
|
710
721
|
content
|
|
711
722
|
}, {
|
|
712
723
|
F: __dxlog_file4,
|
|
713
|
-
L:
|
|
724
|
+
L: 43,
|
|
714
725
|
S: this,
|
|
715
726
|
C: (f, a) => f(...a)
|
|
716
727
|
});
|
|
717
|
-
yield*
|
|
728
|
+
yield* Database5.Service.flush({
|
|
718
729
|
indexes: true
|
|
719
730
|
});
|
|
720
731
|
yield* TracingService3.emitStatus({
|
|
721
732
|
message: "Creating research document..."
|
|
722
733
|
});
|
|
723
|
-
const target = yield*
|
|
724
|
-
const object = yield*
|
|
734
|
+
const target = yield* Database5.Service.resolve(ArtifactId3.toDXN(subject));
|
|
735
|
+
const object = yield* Database5.Service.add(Markdown3.make({
|
|
725
736
|
name,
|
|
726
737
|
content
|
|
727
738
|
}));
|
|
728
|
-
yield*
|
|
739
|
+
yield* Database5.Service.add(Relation.make(HasSubject.HasSubject, {
|
|
729
740
|
[Relation.Source]: object,
|
|
730
741
|
[Relation.Target]: target,
|
|
731
742
|
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
732
743
|
}));
|
|
733
|
-
yield*
|
|
744
|
+
yield* Database5.Service.flush({
|
|
734
745
|
indexes: true
|
|
735
746
|
});
|
|
736
747
|
log4.info("Created research document", {
|
|
@@ -738,12 +749,12 @@ var document_create_default = defineFunction5({
|
|
|
738
749
|
object
|
|
739
750
|
}, {
|
|
740
751
|
F: __dxlog_file4,
|
|
741
|
-
L:
|
|
752
|
+
L: 70,
|
|
742
753
|
S: this,
|
|
743
754
|
C: (f, a) => f(...a)
|
|
744
755
|
});
|
|
745
756
|
return {
|
|
746
|
-
document:
|
|
757
|
+
document: Obj5.getDXN(object).toString()
|
|
747
758
|
};
|
|
748
759
|
})
|
|
749
760
|
});
|
|
@@ -761,8 +772,9 @@ import * as String10 from "effect/String";
|
|
|
761
772
|
import { AiService as AiService2, ConsolePrinter as ConsolePrinter2 } from "@dxos/ai";
|
|
762
773
|
import { AiSession as AiSession2, GenerationObserver as GenerationObserver2, createToolkit as createToolkit2, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
763
774
|
import { Template as Template2 } from "@dxos/blueprints";
|
|
764
|
-
import { Obj as
|
|
765
|
-
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";
|
|
766
778
|
import { FunctionInvocationServiceLayerTestMocked } from "@dxos/functions-runtime/testing";
|
|
767
779
|
import { Person } from "@dxos/types";
|
|
768
780
|
import { trim as trim3 } from "@dxos/util";
|
|
@@ -803,7 +815,7 @@ import * as Effect8 from "effect/Effect";
|
|
|
803
815
|
import * as Schema8 from "effect/Schema";
|
|
804
816
|
import { defineFunction as defineFunction7 } from "@dxos/functions";
|
|
805
817
|
|
|
806
|
-
// src/
|
|
818
|
+
// src/functions/exa/data/exa-search-1748337321991.ts
|
|
807
819
|
var exa_search_1748337321991_default = {
|
|
808
820
|
requestId: "324936368a74f4db978982172bc18a6c",
|
|
809
821
|
autopromptString: "AI personal knowledge management tools projects 2024",
|
|
@@ -959,7 +971,7 @@ var exa_search_1748337321991_default = {
|
|
|
959
971
|
}
|
|
960
972
|
};
|
|
961
973
|
|
|
962
|
-
// src/
|
|
974
|
+
// src/functions/exa/data/exa-search-1748337331526.ts
|
|
963
975
|
var exa_search_1748337331526_default = {
|
|
964
976
|
requestId: "0dc12e344fa649884456960ca1a54954",
|
|
965
977
|
autopromptString: "PKM software artificial intelligence integration open source projects",
|
|
@@ -1182,7 +1194,7 @@ npm run tauri dev
|
|
|
1182
1194
|
}
|
|
1183
1195
|
};
|
|
1184
1196
|
|
|
1185
|
-
// src/
|
|
1197
|
+
// src/functions/exa/data/exa-search-1748337344119.ts
|
|
1186
1198
|
var exa_search_1748337344119_default = {
|
|
1187
1199
|
requestId: "32df0c541f9883180b35e04caece4374",
|
|
1188
1200
|
autopromptString: "open source AI knowledge management projects features comparison 2024",
|
|
@@ -1305,7 +1317,7 @@ var exa_search_1748337344119_default = {
|
|
|
1305
1317
|
}
|
|
1306
1318
|
};
|
|
1307
1319
|
|
|
1308
|
-
// src/
|
|
1320
|
+
// src/functions/exa/data/index.ts
|
|
1309
1321
|
var SEARCH_RESULTS = [
|
|
1310
1322
|
exa_search_1748337321991_default,
|
|
1311
1323
|
exa_search_1748337331526_default,
|
|
@@ -1362,28 +1374,30 @@ var levenshteinDistance = (str1, str2) => {
|
|
|
1362
1374
|
import * as Effect9 from "effect/Effect";
|
|
1363
1375
|
import * as Layer2 from "effect/Layer";
|
|
1364
1376
|
import * as Schema9 from "effect/Schema";
|
|
1365
|
-
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";
|
|
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
|
-
queue:
|
|
1370
|
-
}).pipe(
|
|
1383
|
+
queue: Type3.Ref(Queue)
|
|
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,13 @@ 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
|
-
handler: Effect11.fnUntraced(function* ({ data: { source, instructions: instructions6 } }) {
|
|
1568
|
-
const
|
|
1581
|
+
handler: Effect11.fnUntraced(function* ({ data: { source: message, instructions: instructions6 } }) {
|
|
1582
|
+
const tags = Obj8.getMeta(message)?.tags;
|
|
1583
|
+
const contact = yield* extractContact(message.sender, tags);
|
|
1569
1584
|
let organization = null;
|
|
1570
1585
|
if (contact && !contact.organization) {
|
|
1571
1586
|
const created = [];
|
|
@@ -1585,7 +1600,7 @@ var entity_extraction_default = defineFunction9({
|
|
|
1585
1600
|
${instructions6 ? "<user_intructions>" + instructions6 + "</user_intructions>" : ""},
|
|
1586
1601
|
`,
|
|
1587
1602
|
prompt: JSON.stringify({
|
|
1588
|
-
source,
|
|
1603
|
+
source: message,
|
|
1589
1604
|
contact
|
|
1590
1605
|
}),
|
|
1591
1606
|
toolkit
|
|
@@ -1593,10 +1608,15 @@ var entity_extraction_default = defineFunction9({
|
|
|
1593
1608
|
if (created.length > 1) {
|
|
1594
1609
|
throw new Error("Multiple organizations created");
|
|
1595
1610
|
} else if (created.length === 1) {
|
|
1596
|
-
organization = yield*
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
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
|
+
});
|
|
1600
1620
|
}
|
|
1601
1621
|
}
|
|
1602
1622
|
return {
|
|
@@ -1610,21 +1630,21 @@ var entity_extraction_default = defineFunction9({
|
|
|
1610
1630
|
Layer4.mergeAll(FunctionInvocationServiceLayerTest())
|
|
1611
1631
|
))))
|
|
1612
1632
|
});
|
|
1613
|
-
var extractContact = Effect11.fn("extractContact")(function* (
|
|
1614
|
-
const name =
|
|
1615
|
-
const email =
|
|
1633
|
+
var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
1634
|
+
const name = actor.name;
|
|
1635
|
+
const email = actor.email;
|
|
1616
1636
|
if (!email) {
|
|
1617
1637
|
log5.warn("email is required for contact extraction", {
|
|
1618
|
-
|
|
1638
|
+
actor
|
|
1619
1639
|
}, {
|
|
1620
1640
|
F: __dxlog_file5,
|
|
1621
|
-
L:
|
|
1641
|
+
L: 112,
|
|
1622
1642
|
S: this,
|
|
1623
1643
|
C: (f, a) => f(...a)
|
|
1624
1644
|
});
|
|
1625
1645
|
return void 0;
|
|
1626
1646
|
}
|
|
1627
|
-
const
|
|
1647
|
+
const existingContacts = yield* Database8.Service.runQuery(Filter2.type(Person2.Person));
|
|
1628
1648
|
const existingContact = existingContacts.find((contact) => contact.emails?.some((contactEmail) => contactEmail.value === email));
|
|
1629
1649
|
if (existingContact) {
|
|
1630
1650
|
log5.info("Contact already exists", {
|
|
@@ -1632,25 +1652,31 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
|
|
|
1632
1652
|
existingContact
|
|
1633
1653
|
}, {
|
|
1634
1654
|
F: __dxlog_file5,
|
|
1635
|
-
L:
|
|
1655
|
+
L: 125,
|
|
1636
1656
|
S: this,
|
|
1637
1657
|
C: (f, a) => f(...a)
|
|
1638
1658
|
});
|
|
1639
1659
|
return existingContact;
|
|
1640
1660
|
}
|
|
1641
|
-
const newContact =
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1661
|
+
const newContact = Obj8.make(Person2.Person, {
|
|
1662
|
+
...tags ? {
|
|
1663
|
+
[Obj8.Meta]: {
|
|
1664
|
+
tags: [
|
|
1665
|
+
...tags
|
|
1666
|
+
]
|
|
1667
|
+
}
|
|
1668
|
+
} : {},
|
|
1645
1669
|
emails: [
|
|
1646
1670
|
{
|
|
1647
1671
|
value: email
|
|
1648
1672
|
}
|
|
1649
1673
|
]
|
|
1650
1674
|
});
|
|
1651
|
-
yield*
|
|
1675
|
+
yield* Database8.Service.add(newContact);
|
|
1652
1676
|
if (name) {
|
|
1653
|
-
newContact
|
|
1677
|
+
Obj8.change(newContact, (c) => {
|
|
1678
|
+
c.fullName = name;
|
|
1679
|
+
});
|
|
1654
1680
|
}
|
|
1655
1681
|
const emailDomain = email.split("@")[1]?.toLowerCase();
|
|
1656
1682
|
if (!emailDomain) {
|
|
@@ -1658,7 +1684,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
|
|
|
1658
1684
|
email
|
|
1659
1685
|
}, {
|
|
1660
1686
|
F: __dxlog_file5,
|
|
1661
|
-
L:
|
|
1687
|
+
L: 143,
|
|
1662
1688
|
S: this,
|
|
1663
1689
|
C: (f, a) => f(...a)
|
|
1664
1690
|
});
|
|
@@ -1668,11 +1694,11 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
|
|
|
1668
1694
|
emailDomain
|
|
1669
1695
|
}, {
|
|
1670
1696
|
F: __dxlog_file5,
|
|
1671
|
-
L:
|
|
1697
|
+
L: 147,
|
|
1672
1698
|
S: this,
|
|
1673
1699
|
C: (f, a) => f(...a)
|
|
1674
1700
|
});
|
|
1675
|
-
const
|
|
1701
|
+
const existingOrganisations = yield* Database8.Service.runQuery(Filter2.type(Organization.Organization));
|
|
1676
1702
|
const matchingOrg = existingOrganisations.find((org) => {
|
|
1677
1703
|
if (org.website) {
|
|
1678
1704
|
try {
|
|
@@ -1685,7 +1711,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
|
|
|
1685
1711
|
error: e
|
|
1686
1712
|
}, {
|
|
1687
1713
|
F: __dxlog_file5,
|
|
1688
|
-
L:
|
|
1714
|
+
L: 165,
|
|
1689
1715
|
S: this,
|
|
1690
1716
|
C: (f, a) => f(...a)
|
|
1691
1717
|
});
|
|
@@ -1699,11 +1725,13 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
|
|
|
1699
1725
|
organization: matchingOrg
|
|
1700
1726
|
}, {
|
|
1701
1727
|
F: __dxlog_file5,
|
|
1702
|
-
L:
|
|
1728
|
+
L: 176,
|
|
1703
1729
|
S: this,
|
|
1704
1730
|
C: (f, a) => f(...a)
|
|
1705
1731
|
});
|
|
1706
|
-
newContact
|
|
1732
|
+
Obj8.change(newContact, (c) => {
|
|
1733
|
+
c.organization = Ref3.make(matchingOrg);
|
|
1734
|
+
});
|
|
1707
1735
|
}
|
|
1708
1736
|
return newContact;
|
|
1709
1737
|
});
|
|
@@ -1721,15 +1749,16 @@ import * as Array9 from "effect/Array";
|
|
|
1721
1749
|
import * as Effect13 from "effect/Effect";
|
|
1722
1750
|
import * as Function5 from "effect/Function";
|
|
1723
1751
|
import * as Schema12 from "effect/Schema";
|
|
1724
|
-
import { Filter as Filter4, Obj as
|
|
1725
|
-
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";
|
|
1726
1755
|
import { log as log7 } from "@dxos/log";
|
|
1727
1756
|
import { Person as Person3, Project as Project2, Task as Task2 } from "@dxos/types";
|
|
1728
1757
|
|
|
1729
1758
|
// src/sync/sync.ts
|
|
1730
1759
|
import * as Effect12 from "effect/Effect";
|
|
1731
|
-
import { Filter as Filter3, Obj as
|
|
1732
|
-
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";
|
|
1733
1762
|
import { failedInvariant } from "@dxos/invariant";
|
|
1734
1763
|
import { log as log6 } from "@dxos/log";
|
|
1735
1764
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/sync/sync.ts";
|
|
@@ -1740,7 +1769,7 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1740
1769
|
if (!Ref4.isRef(obj[key])) continue;
|
|
1741
1770
|
const ref = obj[key];
|
|
1742
1771
|
if (!ref.target) continue;
|
|
1743
|
-
if (
|
|
1772
|
+
if (Obj9.getDXN(ref.target).isLocalObjectId()) {
|
|
1744
1773
|
const [target] = yield* syncObjects([
|
|
1745
1774
|
ref.target
|
|
1746
1775
|
], {
|
|
@@ -1749,26 +1778,26 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1749
1778
|
obj[key] = Ref4.make(target);
|
|
1750
1779
|
}
|
|
1751
1780
|
}
|
|
1752
|
-
const schema =
|
|
1753
|
-
const foreignId =
|
|
1754
|
-
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, [
|
|
1755
1784
|
{
|
|
1756
1785
|
source: foreignKeyId,
|
|
1757
1786
|
id: foreignId
|
|
1758
1787
|
}
|
|
1759
1788
|
])));
|
|
1760
1789
|
log6("sync object", {
|
|
1761
|
-
type:
|
|
1790
|
+
type: Obj9.getTypename(obj),
|
|
1762
1791
|
foreignId,
|
|
1763
|
-
existing: existing ?
|
|
1792
|
+
existing: existing ? Obj9.getDXN(existing) : void 0
|
|
1764
1793
|
}, {
|
|
1765
1794
|
F: __dxlog_file6,
|
|
1766
|
-
L:
|
|
1795
|
+
L: 48,
|
|
1767
1796
|
S: this,
|
|
1768
1797
|
C: (f, a) => f(...a)
|
|
1769
1798
|
});
|
|
1770
1799
|
if (!existing) {
|
|
1771
|
-
yield*
|
|
1800
|
+
yield* Database9.Service.add(obj);
|
|
1772
1801
|
return obj;
|
|
1773
1802
|
} else {
|
|
1774
1803
|
copyObjectData(existing, obj);
|
|
@@ -1779,23 +1808,25 @@ var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId })
|
|
|
1779
1808
|
});
|
|
1780
1809
|
});
|
|
1781
1810
|
var copyObjectData = (existing, newObj) => {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
for (const key of Object.keys(existing)) {
|
|
1788
|
-
if (typeof key !== "string" || key === "id") continue;
|
|
1789
|
-
if (!(key in newObj)) {
|
|
1790
|
-
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];
|
|
1791
1816
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
|
|
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
|
+
});
|
|
1799
1830
|
};
|
|
1800
1831
|
|
|
1801
1832
|
// src/util/graphql.ts
|
|
@@ -1825,7 +1856,7 @@ query Issues($teamId: String!, $after: DateTimeOrDuration!) {
|
|
|
1825
1856
|
updatedAt
|
|
1826
1857
|
description
|
|
1827
1858
|
assignee { id, name }
|
|
1828
|
-
state {
|
|
1859
|
+
state {
|
|
1829
1860
|
name
|
|
1830
1861
|
}
|
|
1831
1862
|
project {
|
|
@@ -1856,15 +1887,16 @@ var sync_issues_default = defineFunction10({
|
|
|
1856
1887
|
})
|
|
1857
1888
|
}),
|
|
1858
1889
|
handler: Effect13.fnUntraced(function* ({ data }) {
|
|
1859
|
-
const
|
|
1890
|
+
const credential = yield* CredentialsService3.getCredential({
|
|
1860
1891
|
service: "linear.app"
|
|
1861
|
-
})
|
|
1892
|
+
});
|
|
1893
|
+
const client = yield* HttpClient.HttpClient.pipe(Effect13.map(withAuthorization(credential.apiKey)));
|
|
1862
1894
|
const after = yield* getLatestUpdateTimestamp(data.team, Task2.Task);
|
|
1863
1895
|
log7.info("will fetch", {
|
|
1864
1896
|
after
|
|
1865
1897
|
}, {
|
|
1866
1898
|
F: __dxlog_file7,
|
|
1867
|
-
L:
|
|
1899
|
+
L: 93,
|
|
1868
1900
|
S: this,
|
|
1869
1901
|
C: (f, a) => f(...a)
|
|
1870
1902
|
});
|
|
@@ -1882,7 +1914,7 @@ var sync_issues_default = defineFunction10({
|
|
|
1882
1914
|
count: tasks.length
|
|
1883
1915
|
}, {
|
|
1884
1916
|
F: __dxlog_file7,
|
|
1885
|
-
L:
|
|
1917
|
+
L: 106,
|
|
1886
1918
|
S: this,
|
|
1887
1919
|
C: (f, a) => f(...a)
|
|
1888
1920
|
});
|
|
@@ -1895,16 +1927,16 @@ var sync_issues_default = defineFunction10({
|
|
|
1895
1927
|
}, Effect13.provide(FetchHttpClient2.layer))
|
|
1896
1928
|
});
|
|
1897
1929
|
var getLatestUpdateTimestamp = Effect13.fnUntraced(function* (teamId, dataType) {
|
|
1898
|
-
const
|
|
1930
|
+
const existingTasks = yield* Database10.Service.runQuery(Query4.type(dataType).select(Filter4.foreignKeys(dataType, [
|
|
1899
1931
|
{
|
|
1900
1932
|
source: LINEAR_TEAM_ID_KEY,
|
|
1901
1933
|
id: teamId
|
|
1902
1934
|
}
|
|
1903
1935
|
])));
|
|
1904
|
-
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));
|
|
1905
1937
|
});
|
|
1906
|
-
var mapLinearPerson = (person, { teamId }) =>
|
|
1907
|
-
[
|
|
1938
|
+
var mapLinearPerson = (person, { teamId }) => Obj10.make(Person3.Person, {
|
|
1939
|
+
[Obj10.Meta]: {
|
|
1908
1940
|
keys: [
|
|
1909
1941
|
{
|
|
1910
1942
|
id: person.id,
|
|
@@ -1918,8 +1950,8 @@ var mapLinearPerson = (person, { teamId }) => Obj9.make(Person3.Person, {
|
|
|
1918
1950
|
},
|
|
1919
1951
|
nickname: person.name
|
|
1920
1952
|
});
|
|
1921
|
-
var mapLinearIssue = (issue, { teamId }) =>
|
|
1922
|
-
[
|
|
1953
|
+
var mapLinearIssue = (issue, { teamId }) => Obj10.make(Task2.Task, {
|
|
1954
|
+
[Obj10.Meta]: {
|
|
1923
1955
|
keys: [
|
|
1924
1956
|
{
|
|
1925
1957
|
id: issue.id,
|
|
@@ -1943,7 +1975,7 @@ var mapLinearIssue = (issue, { teamId }) => Obj9.make(Task2.Task, {
|
|
|
1943
1975
|
// TODO(dmaretskyi): Sync those (+ linear team as org?).
|
|
1944
1976
|
// state: issue.state.name,
|
|
1945
1977
|
project: !issue.project ? void 0 : Ref5.make(Project2.make({
|
|
1946
|
-
[
|
|
1978
|
+
[Obj10.Meta]: {
|
|
1947
1979
|
keys: [
|
|
1948
1980
|
{
|
|
1949
1981
|
id: issue.project.id,
|
|
@@ -1969,7 +2001,8 @@ var Linear;
|
|
|
1969
2001
|
import * as Effect14 from "effect/Effect";
|
|
1970
2002
|
import * as Schema13 from "effect/Schema";
|
|
1971
2003
|
import { ArtifactId as ArtifactId4 } from "@dxos/assistant";
|
|
1972
|
-
import {
|
|
2004
|
+
import { Database as Database11 } from "@dxos/echo";
|
|
2005
|
+
import { defineFunction as defineFunction11 } from "@dxos/functions";
|
|
1973
2006
|
import { Markdown as Markdown4 } from "@dxos/plugin-markdown/types";
|
|
1974
2007
|
var read_default2 = defineFunction11({
|
|
1975
2008
|
key: "dxos.org/function/markdown/read-tasks",
|
|
@@ -1984,8 +2017,8 @@ var read_default2 = defineFunction11({
|
|
|
1984
2017
|
content: Schema13.String
|
|
1985
2018
|
}),
|
|
1986
2019
|
handler: Effect14.fn(function* ({ data: { id } }) {
|
|
1987
|
-
const doc = yield*
|
|
1988
|
-
const { content } = yield*
|
|
2020
|
+
const doc = yield* Database11.Service.resolve(ArtifactId4.toDXN(id), Markdown4.Document);
|
|
2021
|
+
const { content } = yield* Database11.Service.load(doc.content);
|
|
1989
2022
|
const lines = content.split("\n");
|
|
1990
2023
|
const len = String(lines.length).length;
|
|
1991
2024
|
const numbered = lines.map((line, i) => `${String(i + 1).padStart(len, " ")}. ${line}`).join("\n");
|
|
@@ -1999,7 +2032,8 @@ var read_default2 = defineFunction11({
|
|
|
1999
2032
|
import * as Effect15 from "effect/Effect";
|
|
2000
2033
|
import * as Schema14 from "effect/Schema";
|
|
2001
2034
|
import { ArtifactId as ArtifactId5 } from "@dxos/assistant";
|
|
2002
|
-
import {
|
|
2035
|
+
import { Database as Database12 } from "@dxos/echo";
|
|
2036
|
+
import { defineFunction as defineFunction12 } from "@dxos/functions";
|
|
2003
2037
|
import { Markdown as Markdown5 } from "@dxos/plugin-markdown/types";
|
|
2004
2038
|
|
|
2005
2039
|
// src/functions/tasks/task-list.ts
|
|
@@ -2150,8 +2184,8 @@ var update_default2 = defineFunction12({
|
|
|
2150
2184
|
})
|
|
2151
2185
|
}),
|
|
2152
2186
|
handler: Effect15.fn(function* ({ data: { id, operations = [] } }) {
|
|
2153
|
-
const doc = yield*
|
|
2154
|
-
const { content } = yield*
|
|
2187
|
+
const doc = yield* Database12.Service.resolve(ArtifactId5.toDXN(id), Markdown5.Document);
|
|
2188
|
+
const { content } = yield* Database12.Service.load(doc.content);
|
|
2155
2189
|
const taskManager = new MarkdownTasks(content);
|
|
2156
2190
|
if (operations.length > 0) {
|
|
2157
2191
|
taskManager.applyOperations(operations);
|
|
@@ -2180,7 +2214,7 @@ var instructions = trim5`
|
|
|
2180
2214
|
When replying to the user, be terse with your comments about design doc handling.
|
|
2181
2215
|
Do not announce when you read or write the design spec document.
|
|
2182
2216
|
`;
|
|
2183
|
-
var blueprint =
|
|
2217
|
+
var blueprint = Blueprint.make({
|
|
2184
2218
|
key: "dxos.org/blueprint/design",
|
|
2185
2219
|
name: "Design Spec",
|
|
2186
2220
|
description: "Preserve the conversation in the design spec.",
|
|
@@ -2192,15 +2226,14 @@ var blueprint = Obj10.make(Blueprint.Blueprint, {
|
|
|
2192
2226
|
Document.update
|
|
2193
2227
|
].map((fn9) => ToolId.make(fn9.key))
|
|
2194
2228
|
});
|
|
2195
|
-
var design_blueprint_default = blueprint;
|
|
2196
2229
|
|
|
2197
2230
|
// src/blueprints/design/index.ts
|
|
2198
|
-
var design_default =
|
|
2231
|
+
var design_default = blueprint;
|
|
2199
2232
|
|
|
2200
2233
|
// src/blueprints/discord/discord-blueprint.ts
|
|
2201
2234
|
import { ToolId as ToolId2 } from "@dxos/ai";
|
|
2202
2235
|
import { Blueprint as Blueprint2 } from "@dxos/blueprints";
|
|
2203
|
-
import {
|
|
2236
|
+
import { Ref as Ref7 } from "@dxos/echo";
|
|
2204
2237
|
import { Text as Text3 } from "@dxos/schema";
|
|
2205
2238
|
import { trim as trim6 } from "@dxos/util";
|
|
2206
2239
|
var instructions2 = trim6`
|
|
@@ -2210,7 +2243,7 @@ var instructions2 = trim6`
|
|
|
2210
2243
|
|
|
2211
2244
|
DXOS serverId: 837138313172353095
|
|
2212
2245
|
`;
|
|
2213
|
-
var blueprint2 =
|
|
2246
|
+
var blueprint2 = Blueprint2.make({
|
|
2214
2247
|
key: "dxos.org/blueprint/discord",
|
|
2215
2248
|
name: "Discord",
|
|
2216
2249
|
description: "Discord integration.",
|
|
@@ -2221,15 +2254,14 @@ var blueprint2 = Obj11.make(Blueprint2.Blueprint, {
|
|
|
2221
2254
|
ToolId2.make(Discord.fetch.key)
|
|
2222
2255
|
]
|
|
2223
2256
|
});
|
|
2224
|
-
var discord_blueprint_default = blueprint2;
|
|
2225
2257
|
|
|
2226
2258
|
// src/blueprints/discord/index.ts
|
|
2227
|
-
var discord_default =
|
|
2259
|
+
var discord_default = blueprint2;
|
|
2228
2260
|
|
|
2229
2261
|
// src/blueprints/linear/linear-blueprint.ts
|
|
2230
2262
|
import { ToolId as ToolId3 } from "@dxos/ai";
|
|
2231
2263
|
import { Blueprint as Blueprint3 } from "@dxos/blueprints";
|
|
2232
|
-
import {
|
|
2264
|
+
import { Ref as Ref8 } from "@dxos/echo";
|
|
2233
2265
|
import { Text as Text4 } from "@dxos/schema";
|
|
2234
2266
|
import { trim as trim7 } from "@dxos/util";
|
|
2235
2267
|
var instructions3 = trim7`
|
|
@@ -2240,7 +2272,7 @@ var instructions3 = trim7`
|
|
|
2240
2272
|
|
|
2241
2273
|
DXOS teamId: 1127c63a-6f77-4725-9229-50f6cd47321c
|
|
2242
2274
|
`;
|
|
2243
|
-
var blueprint3 =
|
|
2275
|
+
var blueprint3 = Blueprint3.make({
|
|
2244
2276
|
key: "dxos.org/blueprint/linear",
|
|
2245
2277
|
name: "Linear",
|
|
2246
2278
|
description: "Syncs Linear workspaces.",
|
|
@@ -2251,15 +2283,14 @@ var blueprint3 = Obj12.make(Blueprint3.Blueprint, {
|
|
|
2251
2283
|
Linear.sync
|
|
2252
2284
|
].map((tool) => ToolId3.make(tool.key))
|
|
2253
2285
|
});
|
|
2254
|
-
var linear_blueprint_default = blueprint3;
|
|
2255
2286
|
|
|
2256
2287
|
// src/blueprints/linear/index.ts
|
|
2257
|
-
var linear_default =
|
|
2288
|
+
var linear_default = blueprint3;
|
|
2258
2289
|
|
|
2259
2290
|
// src/blueprints/planning/planning-blueprint.ts
|
|
2260
2291
|
import { ToolId as ToolId4 } from "@dxos/ai";
|
|
2261
2292
|
import { Blueprint as Blueprint4 } from "@dxos/blueprints";
|
|
2262
|
-
import {
|
|
2293
|
+
import { Ref as Ref9 } from "@dxos/echo";
|
|
2263
2294
|
import { Text as Text5 } from "@dxos/schema";
|
|
2264
2295
|
import { trim as trim8 } from "@dxos/util";
|
|
2265
2296
|
var instructions4 = trim8`
|
|
@@ -2333,7 +2364,7 @@ var instructions4 = trim8`
|
|
|
2333
2364
|
- When creating subtasks, consider the parent task's completion status
|
|
2334
2365
|
- Be precise with task descriptions and hierarchy levels
|
|
2335
2366
|
`;
|
|
2336
|
-
var blueprint4 =
|
|
2367
|
+
var blueprint4 = Blueprint4.make({
|
|
2337
2368
|
key: "dxos.org/blueprint/planning",
|
|
2338
2369
|
name: "Planning",
|
|
2339
2370
|
description: "Plans and tracks complex tasks with artifact management.",
|
|
@@ -2345,15 +2376,14 @@ var blueprint4 = Obj13.make(Blueprint4.Blueprint, {
|
|
|
2345
2376
|
Tasks.update
|
|
2346
2377
|
].map((fn9) => ToolId4.make(fn9.key))
|
|
2347
2378
|
});
|
|
2348
|
-
var planning_blueprint_default = blueprint4;
|
|
2349
2379
|
|
|
2350
2380
|
// src/blueprints/planning/index.ts
|
|
2351
|
-
var planning_default =
|
|
2381
|
+
var planning_default = blueprint4;
|
|
2352
2382
|
|
|
2353
2383
|
// src/blueprints/research/research-blueprint.ts
|
|
2354
2384
|
import { ToolId as ToolId5 } from "@dxos/ai";
|
|
2355
2385
|
import { Blueprint as Blueprint5 } from "@dxos/blueprints";
|
|
2356
|
-
import {
|
|
2386
|
+
import { Ref as Ref10 } from "@dxos/echo";
|
|
2357
2387
|
import { Text as Text6 } from "@dxos/schema";
|
|
2358
2388
|
import { trim as trim9 } from "@dxos/util";
|
|
2359
2389
|
var instructions5 = trim9`
|
|
@@ -2382,7 +2412,7 @@ var instructions5 = trim9`
|
|
|
2382
2412
|
Reply normally with the text mode of the result of your research.
|
|
2383
2413
|
</unstructured_mode>
|
|
2384
2414
|
`;
|
|
2385
|
-
var blueprint5 =
|
|
2415
|
+
var blueprint5 = Blueprint5.make({
|
|
2386
2416
|
key: "dxos.org/blueprint/research",
|
|
2387
2417
|
name: "Research",
|
|
2388
2418
|
description: "Researches the web and creates structured data.",
|
|
@@ -2394,17 +2424,16 @@ var blueprint5 = Obj14.make(Blueprint5.Blueprint, {
|
|
|
2394
2424
|
Research.research
|
|
2395
2425
|
].map((fn9) => ToolId5.make(fn9.key))
|
|
2396
2426
|
});
|
|
2397
|
-
var research_blueprint_default = blueprint5;
|
|
2398
2427
|
|
|
2399
2428
|
// src/blueprints/research/index.ts
|
|
2400
|
-
var research_default2 =
|
|
2429
|
+
var research_default2 = blueprint5;
|
|
2401
2430
|
|
|
2402
2431
|
// src/blueprints/websearch/websearch-blueprint.ts
|
|
2403
2432
|
import { ToolId as ToolId6 } from "@dxos/ai";
|
|
2404
2433
|
import { Blueprint as Blueprint6 } from "@dxos/blueprints";
|
|
2405
|
-
import {
|
|
2434
|
+
import { Ref as Ref11 } from "@dxos/echo";
|
|
2406
2435
|
import { Text as Text7 } from "@dxos/schema";
|
|
2407
|
-
var blueprint6 =
|
|
2436
|
+
var blueprint6 = Blueprint6.make({
|
|
2408
2437
|
key: "dxos.org/blueprint/web-search",
|
|
2409
2438
|
name: "Web Search",
|
|
2410
2439
|
description: "Search the web.",
|
|
@@ -2415,7 +2444,6 @@ var blueprint6 = Obj15.make(Blueprint6.Blueprint, {
|
|
|
2415
2444
|
ToolId6.make("AnthropicWebSearch")
|
|
2416
2445
|
]
|
|
2417
2446
|
});
|
|
2418
|
-
var websearch_blueprint_default = blueprint6;
|
|
2419
2447
|
|
|
2420
2448
|
// src/blueprints/websearch/websearch-toolkit.ts
|
|
2421
2449
|
import * as Toolkit4 from "@effect/ai/Toolkit";
|
|
@@ -2423,44 +2451,7 @@ import * as AnthropicTool2 from "@effect/ai-anthropic/AnthropicTool";
|
|
|
2423
2451
|
var WebSearchToolkit = Toolkit4.make(AnthropicTool2.WebSearch_20250305({}));
|
|
2424
2452
|
|
|
2425
2453
|
// src/blueprints/websearch/index.ts
|
|
2426
|
-
var websearch_default =
|
|
2427
|
-
|
|
2428
|
-
// src/plugins.tsx
|
|
2429
|
-
import * as Schema15 from "effect/Schema";
|
|
2430
|
-
import React from "react";
|
|
2431
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
2432
|
-
import { Type as Type3 } from "@dxos/echo";
|
|
2433
|
-
import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
|
|
2434
|
-
var MapSchema = Schema15.Struct({
|
|
2435
|
-
coordinates: Type3.Format.GeoPoint
|
|
2436
|
-
}).pipe(Type3.Obj({
|
|
2437
|
-
typename: "example.com/type/Map",
|
|
2438
|
-
version: "0.1.0"
|
|
2439
|
-
}));
|
|
2440
|
-
var isImage = (data) => false;
|
|
2441
|
-
var capabilities = [
|
|
2442
|
-
contributes(Capabilities.ReactSurface, createSurface({
|
|
2443
|
-
id: "plugin-image",
|
|
2444
|
-
role: "card--extrinsic",
|
|
2445
|
-
filter: (data) => isImage(data.value),
|
|
2446
|
-
component: ({ data }) => /* @__PURE__ */ React.createElement("img", {
|
|
2447
|
-
className: "grow object-cover",
|
|
2448
|
-
src: `data:image/jpeg;base64,${data.value.source.data}`,
|
|
2449
|
-
alt: data.value.prompt ?? `Generated image [id=${data.value.id}]`
|
|
2450
|
-
})
|
|
2451
|
-
})),
|
|
2452
|
-
//
|
|
2453
|
-
// Default
|
|
2454
|
-
//
|
|
2455
|
-
contributes(Capabilities.ReactSurface, createSurface({
|
|
2456
|
-
id: "plugin-default",
|
|
2457
|
-
role: "card--extrinsic",
|
|
2458
|
-
position: "fallback",
|
|
2459
|
-
component: ({ role, data }) => /* @__PURE__ */ React.createElement(JsonFilter, {
|
|
2460
|
-
data
|
|
2461
|
-
})
|
|
2462
|
-
}))
|
|
2463
|
-
];
|
|
2454
|
+
var websearch_default = blueprint6;
|
|
2464
2455
|
|
|
2465
2456
|
// src/toolkits/AssistantToolkit.ts
|
|
2466
2457
|
var AssistantToolkit_exports = {};
|
|
@@ -2473,39 +2464,64 @@ import * as Tool2 from "@effect/ai/Tool";
|
|
|
2473
2464
|
import * as Toolkit5 from "@effect/ai/Toolkit";
|
|
2474
2465
|
import * as Effect16 from "effect/Effect";
|
|
2475
2466
|
import * as Record from "effect/Record";
|
|
2476
|
-
import * as
|
|
2467
|
+
import * as Schema15 from "effect/Schema";
|
|
2477
2468
|
import { AiContextService, ArtifactId as ArtifactId6 } from "@dxos/assistant";
|
|
2478
|
-
import {
|
|
2479
|
-
import { DatabaseService as DatabaseService13 } from "@dxos/functions";
|
|
2469
|
+
import { Database as Database13 } from "@dxos/echo";
|
|
2480
2470
|
import { trim as trim10 } from "@dxos/util";
|
|
2481
|
-
var AssistantToolkit = Toolkit5.make(Tool2.make("add
|
|
2471
|
+
var AssistantToolkit = Toolkit5.make(Tool2.make("context-add", {
|
|
2482
2472
|
description: trim10`
|
|
2483
2473
|
Adds the object to the chat context.
|
|
2484
2474
|
`,
|
|
2485
2475
|
parameters: {
|
|
2486
2476
|
id: ArtifactId6.annotations({
|
|
2487
|
-
description: "The ID of the document to
|
|
2477
|
+
description: "The ID of the document to add."
|
|
2488
2478
|
})
|
|
2489
2479
|
},
|
|
2490
|
-
success:
|
|
2491
|
-
failure:
|
|
2480
|
+
success: Schema15.Void,
|
|
2481
|
+
failure: Schema15.Never,
|
|
2492
2482
|
dependencies: [
|
|
2493
2483
|
AiContextService,
|
|
2494
|
-
|
|
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."
|
|
2493
|
+
})
|
|
2494
|
+
},
|
|
2495
|
+
success: Schema15.Void,
|
|
2496
|
+
failure: Schema15.Never,
|
|
2497
|
+
dependencies: [
|
|
2498
|
+
AiContextService,
|
|
2499
|
+
Database13.Service
|
|
2495
2500
|
]
|
|
2496
2501
|
}));
|
|
2497
2502
|
var tools = Record.keys(AssistantToolkit.tools);
|
|
2498
2503
|
var layer3 = () => AssistantToolkit.toLayer({
|
|
2499
|
-
"add
|
|
2504
|
+
["context-add"]: Effect16.fnUntraced(function* ({ id }) {
|
|
2500
2505
|
const { binder } = yield* AiContextService;
|
|
2501
|
-
const { db } = yield*
|
|
2502
|
-
const ref =
|
|
2506
|
+
const { db } = yield* Database13.Service;
|
|
2507
|
+
const ref = db.makeRef(ArtifactId6.toDXN(id, db.spaceId));
|
|
2503
2508
|
yield* Effect16.promise(() => binder.bind({
|
|
2504
2509
|
blueprints: [],
|
|
2505
2510
|
objects: [
|
|
2506
2511
|
ref
|
|
2507
2512
|
]
|
|
2508
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
|
+
}));
|
|
2509
2525
|
})
|
|
2510
2526
|
});
|
|
2511
2527
|
|
|
@@ -2520,11 +2536,12 @@ import * as Tool3 from "@effect/ai/Tool";
|
|
|
2520
2536
|
import * as Toolkit6 from "@effect/ai/Toolkit";
|
|
2521
2537
|
import * as Effect17 from "effect/Effect";
|
|
2522
2538
|
import * as Record2 from "effect/Record";
|
|
2523
|
-
import * as
|
|
2539
|
+
import * as Schema16 from "effect/Schema";
|
|
2524
2540
|
import { ArtifactId as ArtifactId7 } from "@dxos/assistant";
|
|
2525
|
-
import { DXN as DXN2, Obj as
|
|
2526
|
-
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";
|
|
2527
2543
|
import { trim as trim11 } from "@dxos/util";
|
|
2544
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/toolkits/SystemToolkit.ts";
|
|
2528
2545
|
var SystemToolkit = Toolkit6.make(
|
|
2529
2546
|
//
|
|
2530
2547
|
// Schema
|
|
@@ -2535,13 +2552,13 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2535
2552
|
`,
|
|
2536
2553
|
parameters: {
|
|
2537
2554
|
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
2538
|
-
limit:
|
|
2555
|
+
limit: Schema16.Number
|
|
2539
2556
|
},
|
|
2540
2557
|
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
2541
|
-
success:
|
|
2542
|
-
failure:
|
|
2558
|
+
success: Schema16.Any,
|
|
2559
|
+
failure: Schema16.Never,
|
|
2543
2560
|
dependencies: [
|
|
2544
|
-
|
|
2561
|
+
Database14.Service
|
|
2545
2562
|
]
|
|
2546
2563
|
}),
|
|
2547
2564
|
Tool3.make("schema-add", {
|
|
@@ -2551,14 +2568,31 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2551
2568
|
The typename must be in the format of "example.com/type/Type".
|
|
2552
2569
|
`,
|
|
2553
2570
|
parameters: {
|
|
2554
|
-
name:
|
|
2555
|
-
typename:
|
|
2556
|
-
jsonSchema:
|
|
2571
|
+
name: Schema16.String,
|
|
2572
|
+
typename: Schema16.String,
|
|
2573
|
+
jsonSchema: Schema16.Any
|
|
2574
|
+
},
|
|
2575
|
+
success: Schema16.Any,
|
|
2576
|
+
failure: Schema16.Never,
|
|
2577
|
+
dependencies: [
|
|
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
|
|
2557
2591
|
},
|
|
2558
|
-
success:
|
|
2559
|
-
failure:
|
|
2592
|
+
success: Schema16.Any,
|
|
2593
|
+
failure: Schema16.Never,
|
|
2560
2594
|
dependencies: [
|
|
2561
|
-
|
|
2595
|
+
Database14.Service
|
|
2562
2596
|
]
|
|
2563
2597
|
}),
|
|
2564
2598
|
//
|
|
@@ -2570,28 +2604,47 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2570
2604
|
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2571
2605
|
`,
|
|
2572
2606
|
parameters: {
|
|
2573
|
-
typename:
|
|
2574
|
-
data:
|
|
2607
|
+
typename: Schema16.String,
|
|
2608
|
+
data: Schema16.Any
|
|
2575
2609
|
},
|
|
2576
|
-
success:
|
|
2577
|
-
failure:
|
|
2610
|
+
success: Schema16.Any,
|
|
2611
|
+
failure: Schema16.Never,
|
|
2578
2612
|
dependencies: [
|
|
2579
|
-
|
|
2613
|
+
Database14.Service
|
|
2580
2614
|
]
|
|
2581
2615
|
}),
|
|
2582
|
-
Tool3.make("object-
|
|
2616
|
+
Tool3.make("object-delete", {
|
|
2583
2617
|
description: trim11`
|
|
2584
|
-
|
|
2618
|
+
Deletes the object.
|
|
2585
2619
|
`,
|
|
2586
2620
|
parameters: {
|
|
2587
2621
|
id: ArtifactId7.annotations({
|
|
2588
2622
|
description: "The ID of the object."
|
|
2589
2623
|
})
|
|
2590
2624
|
},
|
|
2591
|
-
success:
|
|
2592
|
-
failure:
|
|
2625
|
+
success: Schema16.Any,
|
|
2626
|
+
failure: Schema16.Never,
|
|
2593
2627
|
dependencies: [
|
|
2594
|
-
|
|
2628
|
+
Database14.Service
|
|
2629
|
+
]
|
|
2630
|
+
}),
|
|
2631
|
+
Tool3.make("object-update", {
|
|
2632
|
+
description: trim11`
|
|
2633
|
+
Updates the object properties.
|
|
2634
|
+
`,
|
|
2635
|
+
parameters: {
|
|
2636
|
+
id: ArtifactId7.annotations({
|
|
2637
|
+
description: "The ID of the object."
|
|
2638
|
+
}),
|
|
2639
|
+
properties: Schema16.Record({
|
|
2640
|
+
key: Schema16.String,
|
|
2641
|
+
value: Schema16.Any
|
|
2642
|
+
})
|
|
2643
|
+
},
|
|
2644
|
+
success: Schema16.Any,
|
|
2645
|
+
failure: Schema16.Never,
|
|
2646
|
+
dependencies: [
|
|
2647
|
+
Database14.Service
|
|
2595
2648
|
]
|
|
2596
2649
|
}),
|
|
2597
2650
|
//
|
|
@@ -2603,21 +2656,36 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2603
2656
|
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2604
2657
|
`,
|
|
2605
2658
|
parameters: {
|
|
2606
|
-
typename:
|
|
2659
|
+
typename: Schema16.String,
|
|
2607
2660
|
source: ArtifactId7.annotations({
|
|
2608
2661
|
description: "The ID of the source object."
|
|
2609
2662
|
}),
|
|
2610
2663
|
target: ArtifactId7.annotations({
|
|
2611
2664
|
description: "The ID of the target object."
|
|
2612
2665
|
}),
|
|
2613
|
-
data:
|
|
2666
|
+
data: Schema16.Any.annotations({
|
|
2614
2667
|
description: "The data to be stored in the relation."
|
|
2615
2668
|
})
|
|
2616
2669
|
},
|
|
2617
|
-
success:
|
|
2618
|
-
failure:
|
|
2670
|
+
success: Schema16.Any,
|
|
2671
|
+
failure: Schema16.Never,
|
|
2619
2672
|
dependencies: [
|
|
2620
|
-
|
|
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
|
|
2621
2689
|
]
|
|
2622
2690
|
}),
|
|
2623
2691
|
//
|
|
@@ -2636,10 +2704,10 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2636
2704
|
description: "The ID of the object."
|
|
2637
2705
|
})
|
|
2638
2706
|
},
|
|
2639
|
-
success:
|
|
2640
|
-
failure:
|
|
2707
|
+
success: Schema16.Any,
|
|
2708
|
+
failure: Schema16.Never,
|
|
2641
2709
|
dependencies: [
|
|
2642
|
-
|
|
2710
|
+
Database14.Service
|
|
2643
2711
|
]
|
|
2644
2712
|
}),
|
|
2645
2713
|
Tool3.make("tag-remove", {
|
|
@@ -2655,17 +2723,17 @@ var SystemToolkit = Toolkit6.make(
|
|
|
2655
2723
|
description: "The ID of the object."
|
|
2656
2724
|
})
|
|
2657
2725
|
},
|
|
2658
|
-
success:
|
|
2659
|
-
failure:
|
|
2726
|
+
success: Schema16.Any,
|
|
2727
|
+
failure: Schema16.Never,
|
|
2660
2728
|
dependencies: [
|
|
2661
|
-
|
|
2729
|
+
Database14.Service
|
|
2662
2730
|
]
|
|
2663
2731
|
})
|
|
2664
2732
|
);
|
|
2665
2733
|
var tools2 = Record2.keys(SystemToolkit.tools);
|
|
2666
2734
|
var layer4 = () => SystemToolkit.toLayer({
|
|
2667
|
-
"schema-list": Effect17.fnUntraced(function* () {
|
|
2668
|
-
const { db } = yield*
|
|
2735
|
+
["schema-list"]: Effect17.fnUntraced(function* () {
|
|
2736
|
+
const { db } = yield* Database14.Service;
|
|
2669
2737
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2670
2738
|
location: [
|
|
2671
2739
|
"database",
|
|
@@ -2673,16 +2741,16 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2673
2741
|
]
|
|
2674
2742
|
}).run());
|
|
2675
2743
|
return schema.map((schema2) => {
|
|
2676
|
-
const meta =
|
|
2744
|
+
const meta = Type5.getMeta(schema2);
|
|
2677
2745
|
return {
|
|
2678
|
-
typename:
|
|
2679
|
-
jsonSchema:
|
|
2746
|
+
typename: Type5.getTypename(schema2),
|
|
2747
|
+
jsonSchema: Type5.toJsonSchema(schema2),
|
|
2680
2748
|
kind: meta?.sourceSchema ? "relation" : "record"
|
|
2681
2749
|
};
|
|
2682
2750
|
});
|
|
2683
2751
|
}),
|
|
2684
|
-
"schema-add": Effect17.fnUntraced(function* ({ name, typename, jsonSchema }) {
|
|
2685
|
-
const { db } = yield*
|
|
2752
|
+
["schema-add"]: Effect17.fnUntraced(function* ({ name, typename, jsonSchema }) {
|
|
2753
|
+
const { db } = yield* Database14.Service;
|
|
2686
2754
|
yield* Effect17.promise(() => db.schemaRegistry.register([
|
|
2687
2755
|
{
|
|
2688
2756
|
typename,
|
|
@@ -2692,8 +2760,12 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2692
2760
|
}
|
|
2693
2761
|
]));
|
|
2694
2762
|
}),
|
|
2695
|
-
"
|
|
2696
|
-
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;
|
|
2697
2769
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2698
2770
|
typename,
|
|
2699
2771
|
location: [
|
|
@@ -2701,17 +2773,35 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2701
2773
|
"runtime"
|
|
2702
2774
|
]
|
|
2703
2775
|
}).first());
|
|
2704
|
-
|
|
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));
|
|
2705
2786
|
return object;
|
|
2706
2787
|
}),
|
|
2707
|
-
"object-
|
|
2708
|
-
const { db } = yield*
|
|
2709
|
-
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));
|
|
2710
2791
|
db.remove(object);
|
|
2711
2792
|
return object;
|
|
2712
2793
|
}),
|
|
2713
|
-
"
|
|
2714
|
-
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;
|
|
2715
2805
|
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2716
2806
|
typename,
|
|
2717
2807
|
location: [
|
|
@@ -2719,8 +2809,17 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2719
2809
|
"runtime"
|
|
2720
2810
|
]
|
|
2721
2811
|
}).first());
|
|
2722
|
-
|
|
2723
|
-
|
|
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));
|
|
2724
2823
|
const relation = db.add(Relation2.make(schema, {
|
|
2725
2824
|
[Relation2.Source]: sourceObj,
|
|
2726
2825
|
[Relation2.Target]: targetObj,
|
|
@@ -2728,14 +2827,20 @@ var layer4 = () => SystemToolkit.toLayer({
|
|
|
2728
2827
|
}));
|
|
2729
2828
|
return relation;
|
|
2730
2829
|
}),
|
|
2731
|
-
"
|
|
2732
|
-
const
|
|
2733
|
-
|
|
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()));
|
|
2734
2839
|
return object;
|
|
2735
2840
|
}),
|
|
2736
|
-
"tag-remove": Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2737
|
-
const object = yield*
|
|
2738
|
-
|
|
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()));
|
|
2739
2844
|
return object;
|
|
2740
2845
|
})
|
|
2741
2846
|
});
|
|
@@ -2751,7 +2856,6 @@ export {
|
|
|
2751
2856
|
linear_default as LinearBlueprint,
|
|
2752
2857
|
LocalSearchHandler,
|
|
2753
2858
|
LocalSearchToolkit,
|
|
2754
|
-
MapSchema,
|
|
2755
2859
|
planning_default as PlanningBlueprint,
|
|
2756
2860
|
Research,
|
|
2757
2861
|
research_default2 as ResearchBlueprint,
|
|
@@ -2762,7 +2866,6 @@ export {
|
|
|
2762
2866
|
Tasks,
|
|
2763
2867
|
websearch_default as WebSearchBlueprint,
|
|
2764
2868
|
WebSearchToolkit,
|
|
2765
|
-
capabilities,
|
|
2766
2869
|
contextQueueLayerFromResearchGraph,
|
|
2767
2870
|
createExtractionSchema,
|
|
2768
2871
|
createResearchGraph,
|