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