@dxos/assistant-toolkit 0.8.4-main.72ec0f3 → 0.8.4-main.7ace549
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/index.mjs +41 -40
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +41 -40
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts +4 -3
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts +4 -3
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts.map +1 -1
- package/dist/types/src/crud/graph.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +12 -13
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +12 -13
- package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
- package/dist/types/src/functions/research/research-graph.d.ts +2 -2
- package/dist/types/src/functions/research/research-graph.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/plugins.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/crud/graph.ts +11 -17
- package/src/functions/entity-extraction/entity-extraction.ts +11 -12
- package/src/functions/research/research-graph.ts +2 -0
- package/src/functions/research/types.ts +1 -1
- package/src/plugins.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/assistant-toolkit",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.7ace549",
|
|
4
4
|
"description": "Assistant toolkit, definitions, and utilities.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,28 +30,28 @@
|
|
|
30
30
|
"@effect/platform": "^0.92.1",
|
|
31
31
|
"dfx": "^0.126.0",
|
|
32
32
|
"exa-js": "^1.5.12",
|
|
33
|
-
"@dxos/ai": "0.8.4-main.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/context": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/echo-
|
|
41
|
-
"@dxos/echo-
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/keys": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/plugin-markdown": "0.8.4-main.
|
|
51
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.
|
|
52
|
-
"@dxos/schema": "0.8.4-main.
|
|
53
|
-
"@dxos/types": "0.8.4-main.
|
|
54
|
-
"@dxos/util": "0.8.4-main.
|
|
33
|
+
"@dxos/ai": "0.8.4-main.7ace549",
|
|
34
|
+
"@dxos/app-framework": "0.8.4-main.7ace549",
|
|
35
|
+
"@dxos/blueprints": "0.8.4-main.7ace549",
|
|
36
|
+
"@dxos/conductor": "0.8.4-main.7ace549",
|
|
37
|
+
"@dxos/context": "0.8.4-main.7ace549",
|
|
38
|
+
"@dxos/echo": "0.8.4-main.7ace549",
|
|
39
|
+
"@dxos/assistant": "0.8.4-main.7ace549",
|
|
40
|
+
"@dxos/echo-protocol": "0.8.4-main.7ace549",
|
|
41
|
+
"@dxos/echo-db": "0.8.4-main.7ace549",
|
|
42
|
+
"@dxos/edge-client": "0.8.4-main.7ace549",
|
|
43
|
+
"@dxos/functions": "0.8.4-main.7ace549",
|
|
44
|
+
"@dxos/functions-runtime": "0.8.4-main.7ace549",
|
|
45
|
+
"@dxos/errors": "0.8.4-main.7ace549",
|
|
46
|
+
"@dxos/effect": "0.8.4-main.7ace549",
|
|
47
|
+
"@dxos/keys": "0.8.4-main.7ace549",
|
|
48
|
+
"@dxos/invariant": "0.8.4-main.7ace549",
|
|
49
|
+
"@dxos/log": "0.8.4-main.7ace549",
|
|
50
|
+
"@dxos/plugin-markdown": "0.8.4-main.7ace549",
|
|
51
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.7ace549",
|
|
52
|
+
"@dxos/schema": "0.8.4-main.7ace549",
|
|
53
|
+
"@dxos/types": "0.8.4-main.7ace549",
|
|
54
|
+
"@dxos/util": "0.8.4-main.7ace549"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"effect": "3.18.3",
|
package/src/crud/graph.ts
CHANGED
|
@@ -11,20 +11,14 @@ import * as Option from 'effect/Option';
|
|
|
11
11
|
import * as Schema from 'effect/Schema';
|
|
12
12
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
13
13
|
|
|
14
|
-
import { Obj,
|
|
15
|
-
import { Filter, Query } from '@dxos/echo';
|
|
14
|
+
import { Entity, Filter, Obj, Query, Type } from '@dxos/echo';
|
|
16
15
|
import {
|
|
17
|
-
EntityKind,
|
|
18
|
-
ObjectId,
|
|
19
16
|
ReferenceAnnotationId,
|
|
20
17
|
RelationSourceDXNId,
|
|
21
18
|
RelationSourceId,
|
|
22
19
|
RelationTargetDXNId,
|
|
23
20
|
RelationTargetId,
|
|
24
|
-
|
|
25
|
-
getEntityKind,
|
|
26
|
-
getSchemaDXN,
|
|
27
|
-
getSchemaTypename,
|
|
21
|
+
createObject,
|
|
28
22
|
getTypeAnnotation,
|
|
29
23
|
getTypeIdentifierAnnotation,
|
|
30
24
|
} from '@dxos/echo/internal';
|
|
@@ -32,7 +26,7 @@ import { type EchoDatabase, type Queue } from '@dxos/echo-db';
|
|
|
32
26
|
import { isEncodedReference } from '@dxos/echo-protocol';
|
|
33
27
|
import { mapAst } from '@dxos/effect';
|
|
34
28
|
import { ContextQueueService, DatabaseService } from '@dxos/functions';
|
|
35
|
-
import { DXN } from '@dxos/keys';
|
|
29
|
+
import { DXN, ObjectId } from '@dxos/keys';
|
|
36
30
|
import { log } from '@dxos/log';
|
|
37
31
|
import { deepMapValues, isNonNullable, trim } from '@dxos/util';
|
|
38
32
|
|
|
@@ -66,7 +60,7 @@ export const findRelatedSchema = async (
|
|
|
66
60
|
// TODO(dmaretskyi): Also do references.
|
|
67
61
|
return allSchemas
|
|
68
62
|
.filter((schema) => {
|
|
69
|
-
if (getTypeAnnotation(schema)?.kind !==
|
|
63
|
+
if (getTypeAnnotation(schema)?.kind !== Entity.Kind.Relation) {
|
|
70
64
|
return false;
|
|
71
65
|
}
|
|
72
66
|
|
|
@@ -94,7 +88,7 @@ const isSchemaAddressableByDxn = (schema: Schema.Schema.AnyNoContext, dxn: DXN):
|
|
|
94
88
|
|
|
95
89
|
const t = dxn.asTypeDXN();
|
|
96
90
|
if (t) {
|
|
97
|
-
return t.type ===
|
|
91
|
+
return t.type === Type.getTypename(schema);
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
return false;
|
|
@@ -199,7 +193,7 @@ export const createExtractionSchema = (types: Schema.Schema.AnyNoContext[]) => {
|
|
|
199
193
|
types.map(preprocessSchema).map((schema, index) => [
|
|
200
194
|
`objects_${getSanitizedSchemaName(types[index])}`,
|
|
201
195
|
Schema.optional(Schema.Array(schema)).annotations({
|
|
202
|
-
description: `The objects of type: ${
|
|
196
|
+
description: `The objects of type: ${Type.getDXN(types[index])?.asTypeDXN()!.type}. ${SchemaAST.getDescriptionAnnotation(types[index].ast).pipe(Option.getOrElse(() => ''))}`,
|
|
203
197
|
}),
|
|
204
198
|
]),
|
|
205
199
|
),
|
|
@@ -207,7 +201,7 @@ export const createExtractionSchema = (types: Schema.Schema.AnyNoContext[]) => {
|
|
|
207
201
|
};
|
|
208
202
|
|
|
209
203
|
export const getSanitizedSchemaName = (schema: Schema.Schema.AnyNoContext) => {
|
|
210
|
-
return
|
|
204
|
+
return Type.getDXN(schema)!
|
|
211
205
|
.asTypeDXN()!
|
|
212
206
|
.type.replaceAll(/[^a-zA-Z0-9]+/g, '_');
|
|
213
207
|
};
|
|
@@ -230,7 +224,7 @@ export const sanitizeObjects = async (
|
|
|
230
224
|
|
|
231
225
|
const idMap = new Map<string, string>();
|
|
232
226
|
const existingIds = new Set<ObjectId>();
|
|
233
|
-
const enitties = new Map<ObjectId,
|
|
227
|
+
const enitties = new Map<ObjectId, Entity.Unknown>();
|
|
234
228
|
|
|
235
229
|
const resolveId = (id: string): DXN | undefined => {
|
|
236
230
|
if (ObjectId.isValid(id)) {
|
|
@@ -275,7 +269,7 @@ export const sanitizeObjects = async (
|
|
|
275
269
|
return recurse(value);
|
|
276
270
|
});
|
|
277
271
|
|
|
278
|
-
if (
|
|
272
|
+
if (Entity.getKind(entry.schema) === 'relation') {
|
|
279
273
|
const sourceDxn = resolveId(data.source);
|
|
280
274
|
if (!sourceDxn) {
|
|
281
275
|
log.warn('source not found', { source: data.source });
|
|
@@ -332,7 +326,7 @@ export const sanitizeObjects = async (
|
|
|
332
326
|
}
|
|
333
327
|
}
|
|
334
328
|
if (!skip) {
|
|
335
|
-
const obj =
|
|
329
|
+
const obj = createObject(schema, data);
|
|
336
330
|
enitties.set(obj.id, obj);
|
|
337
331
|
return [obj];
|
|
338
332
|
}
|
|
@@ -347,7 +341,7 @@ const SoftRef = Schema.Struct({
|
|
|
347
341
|
});
|
|
348
342
|
|
|
349
343
|
const preprocessSchema = (schema: Schema.Schema.AnyNoContext) => {
|
|
350
|
-
const isRelationSchema =
|
|
344
|
+
const isRelationSchema = Entity.getKind(schema) === 'relation';
|
|
351
345
|
|
|
352
346
|
const go = (ast: SchemaAST.AST, visited = new Set<SchemaAST.AST>()): SchemaAST.AST => {
|
|
353
347
|
if (visited.has(ast)) {
|
|
@@ -15,7 +15,7 @@ import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
|
15
15
|
import { FunctionInvocationServiceLayerTest } from '@dxos/functions-runtime/testing';
|
|
16
16
|
import { type DXN } from '@dxos/keys';
|
|
17
17
|
import { log } from '@dxos/log';
|
|
18
|
-
import { LegacyOrganization, Message, Organization, Person } from '@dxos/types';
|
|
18
|
+
import { type Actor, LegacyOrganization, Message, Organization, Person } from '@dxos/types';
|
|
19
19
|
import { trim } from '@dxos/util';
|
|
20
20
|
|
|
21
21
|
import { makeGraphWriterHandler, makeGraphWriterToolkit } from '../../crud';
|
|
@@ -39,8 +39,9 @@ export default defineFunction({
|
|
|
39
39
|
),
|
|
40
40
|
}),
|
|
41
41
|
handler: Effect.fnUntraced(
|
|
42
|
-
function* ({ data: { source, instructions } }) {
|
|
43
|
-
const
|
|
42
|
+
function* ({ data: { source: message, instructions } }) {
|
|
43
|
+
const tags = Obj.getMeta(message)?.tags;
|
|
44
|
+
const contact = yield* extractContact(message.sender, tags);
|
|
44
45
|
let organization: Organization.Organization | null = null;
|
|
45
46
|
|
|
46
47
|
if (contact && !contact.organization) {
|
|
@@ -59,7 +60,7 @@ export default defineFunction({
|
|
|
59
60
|
The extracted organization URL must match the sender's email domain.
|
|
60
61
|
${instructions ? '<user_intructions>' + instructions + '</user_intructions>' : ''},
|
|
61
62
|
`,
|
|
62
|
-
prompt: JSON.stringify({ source, contact }),
|
|
63
|
+
prompt: JSON.stringify({ source: message, contact }),
|
|
63
64
|
toolkit,
|
|
64
65
|
});
|
|
65
66
|
|
|
@@ -68,7 +69,7 @@ export default defineFunction({
|
|
|
68
69
|
} else if (created.length === 1) {
|
|
69
70
|
organization = yield* DatabaseService.resolve(created[0], Organization.Organization);
|
|
70
71
|
Obj.getMeta(organization).tags ??= [];
|
|
71
|
-
Obj.getMeta(organization).tags!.push(...(
|
|
72
|
+
Obj.getMeta(organization).tags!.push(...(tags ?? []));
|
|
72
73
|
contact.organization = Ref.make(organization);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -92,11 +93,11 @@ export default defineFunction({
|
|
|
92
93
|
),
|
|
93
94
|
});
|
|
94
95
|
|
|
95
|
-
const extractContact = Effect.fn('extractContact')(function* (
|
|
96
|
-
const name =
|
|
97
|
-
const email =
|
|
96
|
+
const extractContact = Effect.fn('extractContact')(function* (actor: Actor.Actor, tags?: string[]) {
|
|
97
|
+
const name = actor.name;
|
|
98
|
+
const email = actor.email;
|
|
98
99
|
if (!email) {
|
|
99
|
-
log.warn('email is required for contact extraction', {
|
|
100
|
+
log.warn('email is required for contact extraction', { actor });
|
|
100
101
|
return undefined;
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -114,9 +115,7 @@ const extractContact = Effect.fn('extractContact')(function* (message: Message.M
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
const newContact = Obj.make(Person.Person, {
|
|
117
|
-
[Obj.Meta]: {
|
|
118
|
-
tags: Obj.getMeta(message)?.tags,
|
|
119
|
-
},
|
|
118
|
+
[Obj.Meta]: { tags },
|
|
120
119
|
emails: [{ value: email }],
|
|
121
120
|
});
|
|
122
121
|
yield* DatabaseService.add(newContact);
|
|
@@ -7,6 +7,7 @@ import * as Layer from 'effect/Layer';
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
9
|
import { Obj, Query, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { SystemTypeAnnotation } from '@dxos/echo/internal';
|
|
10
11
|
import { Queue } from '@dxos/echo-db';
|
|
11
12
|
import { ContextQueueService, DatabaseService, QueueService } from '@dxos/functions';
|
|
12
13
|
|
|
@@ -20,6 +21,7 @@ export const ResearchGraph = Schema.Struct({
|
|
|
20
21
|
typename: 'dxos.org/type/ResearchGraph',
|
|
21
22
|
version: '0.1.0',
|
|
22
23
|
}),
|
|
24
|
+
SystemTypeAnnotation.set(true),
|
|
23
25
|
);
|
|
24
26
|
|
|
25
27
|
export interface ResearchGraph extends Schema.Schema.Type<typeof ResearchGraph> {}
|
|
@@ -9,7 +9,7 @@ import { Event, HasConnection, HasRelationship, LegacyOrganization, LegacyPerson
|
|
|
9
9
|
/**
|
|
10
10
|
* Data types for research.
|
|
11
11
|
*/
|
|
12
|
-
export const ResearchDataTypes:
|
|
12
|
+
export const ResearchDataTypes: Type.Entity.Any[] = [
|
|
13
13
|
// Objects
|
|
14
14
|
Event.Event,
|
|
15
15
|
LegacyOrganization,
|
package/src/plugins.tsx
CHANGED
|
@@ -6,11 +6,11 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { type AnyCapability, Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
9
|
-
import { type Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { Format, type Obj, Type } from '@dxos/echo';
|
|
10
10
|
import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
|
|
11
11
|
|
|
12
12
|
export const MapSchema = Schema.Struct({
|
|
13
|
-
coordinates:
|
|
13
|
+
coordinates: Format.GeoPoint,
|
|
14
14
|
}).pipe(
|
|
15
15
|
Type.Obj({
|
|
16
16
|
typename: 'example.com/type/Map',
|