@dxos/assistant-toolkit 0.8.4-main.548089c → 0.8.4-main.70d3990

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.
Files changed (49) hide show
  1. package/dist/lib/browser/index.mjs +41 -40
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +41 -40
  5. package/dist/lib/node-esm/index.mjs.map +3 -3
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/blueprints/discord/discord-blueprint.d.ts +4 -3
  8. package/dist/types/src/blueprints/discord/discord-blueprint.d.ts.map +1 -1
  9. package/dist/types/src/blueprints/linear/linear-blueprint.d.ts +4 -3
  10. package/dist/types/src/blueprints/linear/linear-blueprint.d.ts.map +1 -1
  11. package/dist/types/src/crud/graph.d.ts.map +1 -1
  12. package/dist/types/src/functions/agent/prompt.d.ts +1 -1
  13. package/dist/types/src/functions/discord/fetch-messages.d.ts +1 -1
  14. package/dist/types/src/functions/discord/index.d.ts +1 -1
  15. package/dist/types/src/functions/discord/index.d.ts.map +1 -1
  16. package/dist/types/src/functions/document/index.d.ts +2 -2
  17. package/dist/types/src/functions/document/index.d.ts.map +1 -1
  18. package/dist/types/src/functions/document/read.d.ts +1 -1
  19. package/dist/types/src/functions/document/update.d.ts +1 -1
  20. package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +13 -14
  21. package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
  22. package/dist/types/src/functions/entity-extraction/index.d.ts +13 -14
  23. package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
  24. package/dist/types/src/functions/exa/exa.d.ts +1 -1
  25. package/dist/types/src/functions/exa/mock.d.ts +1 -1
  26. package/dist/types/src/functions/github/fetch-prs.d.ts +1 -1
  27. package/dist/types/src/functions/linear/index.d.ts +1 -1
  28. package/dist/types/src/functions/linear/index.d.ts.map +1 -1
  29. package/dist/types/src/functions/linear/sync-issues.d.ts +1 -1
  30. package/dist/types/src/functions/research/document-create.d.ts +1 -1
  31. package/dist/types/src/functions/research/index.d.ts +2 -2
  32. package/dist/types/src/functions/research/index.d.ts.map +1 -1
  33. package/dist/types/src/functions/research/research-graph.d.ts +2 -2
  34. package/dist/types/src/functions/research/research-graph.d.ts.map +1 -1
  35. package/dist/types/src/functions/research/research.d.ts +1 -1
  36. package/dist/types/src/functions/research/types.d.ts +1 -1
  37. package/dist/types/src/functions/research/types.d.ts.map +1 -1
  38. package/dist/types/src/functions/tasks/index.d.ts +2 -2
  39. package/dist/types/src/functions/tasks/index.d.ts.map +1 -1
  40. package/dist/types/src/functions/tasks/read.d.ts +1 -1
  41. package/dist/types/src/functions/tasks/update.d.ts +1 -1
  42. package/dist/types/src/plugins.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +23 -23
  45. package/src/crud/graph.ts +11 -17
  46. package/src/functions/entity-extraction/entity-extraction.ts +11 -12
  47. package/src/functions/research/research-graph.ts +2 -0
  48. package/src/functions/research/types.ts +1 -1
  49. package/src/plugins.tsx +2 -2
@@ -392,13 +392,12 @@ import * as Function3 from "effect/Function";
392
392
  import * as Option3 from "effect/Option";
393
393
  import * as Schema5 from "effect/Schema";
394
394
  import * as SchemaAST from "effect/SchemaAST";
395
- import { Obj as Obj3 } from "@dxos/echo";
396
- import { Filter, Query } from "@dxos/echo";
397
- import { EntityKind, ObjectId, ReferenceAnnotationId, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, create, getEntityKind, getSchemaDXN, getSchemaTypename, getTypeAnnotation, getTypeIdentifierAnnotation } from "@dxos/echo/internal";
395
+ import { Entity, Filter, Obj as Obj3, Query, Type as Type2 } from "@dxos/echo";
396
+ import { ReferenceAnnotationId, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, createObject, getTypeAnnotation, getTypeIdentifierAnnotation } from "@dxos/echo/internal";
398
397
  import { isEncodedReference } from "@dxos/echo-protocol";
399
398
  import { mapAst } from "@dxos/effect";
400
399
  import { ContextQueueService, DatabaseService as DatabaseService4 } from "@dxos/functions";
401
- import { DXN } from "@dxos/keys";
400
+ import { DXN, ObjectId } from "@dxos/keys";
402
401
  import { log as log3 } from "@dxos/log";
403
402
  import { deepMapValues, isNonNullable, trim } from "@dxos/util";
404
403
  var __dxlog_file3 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/crud/graph.ts";
@@ -411,7 +410,7 @@ var findRelatedSchema = async (db, anchor) => {
411
410
  ...db.graph.schemaRegistry.schemas
412
411
  ];
413
412
  return allSchemas.filter((schema) => {
414
- if (getTypeAnnotation(schema)?.kind !== EntityKind.Relation) {
413
+ if (getTypeAnnotation(schema)?.kind !== Entity.Kind.Relation) {
415
414
  return false;
416
415
  }
417
416
  return isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).sourceSchema)) || isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).targetSchema));
@@ -426,7 +425,7 @@ var isSchemaAddressableByDxn = (schema, dxn) => {
426
425
  }
427
426
  const t = dxn.asTypeDXN();
428
427
  if (t) {
429
- return t.type === getSchemaTypename(schema);
428
+ return t.type === Type2.getTypename(schema);
430
429
  }
431
430
  return false;
432
431
  };
@@ -498,13 +497,13 @@ var createExtractionSchema = (types) => {
498
497
  ...Object.fromEntries(types.map(preprocessSchema).map((schema, index) => [
499
498
  `objects_${getSanitizedSchemaName(types[index])}`,
500
499
  Schema5.optional(Schema5.Array(schema)).annotations({
501
- description: `The objects of type: ${getSchemaDXN(types[index])?.asTypeDXN().type}. ${SchemaAST.getDescriptionAnnotation(types[index].ast).pipe(Option3.getOrElse(() => ""))}`
500
+ description: `The objects of type: ${Type2.getDXN(types[index])?.asTypeDXN().type}. ${SchemaAST.getDescriptionAnnotation(types[index].ast).pipe(Option3.getOrElse(() => ""))}`
502
501
  })
503
502
  ]))
504
503
  });
505
504
  };
506
505
  var getSanitizedSchemaName = (schema) => {
507
- return getSchemaDXN(schema).asTypeDXN().type.replaceAll(/[^a-zA-Z0-9]+/g, "_");
506
+ return Type2.getDXN(schema).asTypeDXN().type.replaceAll(/[^a-zA-Z0-9]+/g, "_");
508
507
  };
509
508
  var sanitizeObjects = async (types, data, db, queue) => {
510
509
  const entries = types.map((type) => data[`objects_${getSanitizedSchemaName(type)}`]?.map((object) => ({
@@ -549,14 +548,14 @@ var sanitizeObjects = async (types, data, db, queue) => {
549
548
  }
550
549
  return recurse(value2);
551
550
  });
552
- if (getEntityKind(entry.schema) === "relation") {
551
+ if (Entity.getKind(entry.schema) === "relation") {
553
552
  const sourceDxn = resolveId(data2.source);
554
553
  if (!sourceDxn) {
555
554
  log3.warn("source not found", {
556
555
  source: data2.source
557
556
  }, {
558
557
  F: __dxlog_file3,
559
- L: 281,
558
+ L: 275,
560
559
  S: void 0,
561
560
  C: (f, a) => f(...a)
562
561
  });
@@ -567,7 +566,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
567
566
  target: data2.target
568
567
  }, {
569
568
  F: __dxlog_file3,
570
- L: 285,
569
+ L: 279,
571
570
  S: void 0,
572
571
  C: (f, a) => f(...a)
573
572
  });
@@ -596,7 +595,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
596
595
  existingIds
597
596
  }, {
598
597
  F: __dxlog_file3,
599
- L: 306,
598
+ L: 300,
600
599
  S: void 0,
601
600
  C: (f, a) => f(...a)
602
601
  });
@@ -627,7 +626,7 @@ var sanitizeObjects = async (types, data, db, queue) => {
627
626
  }
628
627
  }
629
628
  if (!skip) {
630
- const obj = create(schema, data2);
629
+ const obj = createObject(schema, data2);
631
630
  enitties.set(obj.id, obj);
632
631
  return [
633
632
  obj
@@ -642,7 +641,7 @@ var SoftRef = Schema5.Struct({
642
641
  description: "Reference to another object."
643
642
  });
644
643
  var preprocessSchema = (schema) => {
645
- const isRelationSchema = getEntityKind(schema) === "relation";
644
+ const isRelationSchema = Entity.getKind(schema) === "relation";
646
645
  const go = (ast, visited = /* @__PURE__ */ new Set()) => {
647
646
  if (visited.has(ast)) {
648
647
  return ast;
@@ -1362,15 +1361,16 @@ var levenshteinDistance = (str1, str2) => {
1362
1361
  import * as Effect9 from "effect/Effect";
1363
1362
  import * as Layer2 from "effect/Layer";
1364
1363
  import * as Schema9 from "effect/Schema";
1365
- import { Obj as Obj5, Query as Query2, Ref as Ref2, Type as Type2 } from "@dxos/echo";
1364
+ import { Obj as Obj5, Query as Query2, Ref as Ref2, Type as Type3 } from "@dxos/echo";
1365
+ import { SystemTypeAnnotation } from "@dxos/echo/internal";
1366
1366
  import { Queue } from "@dxos/echo-db";
1367
1367
  import { ContextQueueService as ContextQueueService2, DatabaseService as DatabaseService6, QueueService } from "@dxos/functions";
1368
1368
  var ResearchGraph = Schema9.Struct({
1369
- queue: Type2.Ref(Queue)
1370
- }).pipe(Type2.Obj({
1369
+ queue: Type3.Ref(Queue)
1370
+ }).pipe(Type3.Obj({
1371
1371
  typename: "dxos.org/type/ResearchGraph",
1372
1372
  version: "0.1.0"
1373
- }));
1373
+ }), SystemTypeAnnotation.set(true));
1374
1374
  var queryResearchGraph = Effect9.fn("queryResearchGraph")(function* () {
1375
1375
  const { objects } = yield* DatabaseService6.runQuery(Query2.type(ResearchGraph));
1376
1376
  return objects.at(0);
@@ -1564,8 +1564,9 @@ var entity_extraction_default = defineFunction9({
1564
1564
  description: "Extracted entities."
1565
1565
  }))
1566
1566
  }),
1567
- handler: Effect11.fnUntraced(function* ({ data: { source, instructions: instructions6 } }) {
1568
- const contact = yield* extractContact(source);
1567
+ handler: Effect11.fnUntraced(function* ({ data: { source: message, instructions: instructions6 } }) {
1568
+ const tags = Obj7.getMeta(message)?.tags;
1569
+ const contact = yield* extractContact(message.sender, tags);
1569
1570
  let organization = null;
1570
1571
  if (contact && !contact.organization) {
1571
1572
  const created = [];
@@ -1585,7 +1586,7 @@ var entity_extraction_default = defineFunction9({
1585
1586
  ${instructions6 ? "<user_intructions>" + instructions6 + "</user_intructions>" : ""},
1586
1587
  `,
1587
1588
  prompt: JSON.stringify({
1588
- source,
1589
+ source: message,
1589
1590
  contact
1590
1591
  }),
1591
1592
  toolkit
@@ -1595,7 +1596,7 @@ var entity_extraction_default = defineFunction9({
1595
1596
  } else if (created.length === 1) {
1596
1597
  organization = yield* DatabaseService8.resolve(created[0], Organization.Organization);
1597
1598
  Obj7.getMeta(organization).tags ??= [];
1598
- Obj7.getMeta(organization).tags.push(...Obj7.getMeta(source)?.tags ?? []);
1599
+ Obj7.getMeta(organization).tags.push(...tags ?? []);
1599
1600
  contact.organization = Ref3.make(organization);
1600
1601
  }
1601
1602
  }
@@ -1610,15 +1611,15 @@ var entity_extraction_default = defineFunction9({
1610
1611
  Layer4.mergeAll(FunctionInvocationServiceLayerTest())
1611
1612
  ))))
1612
1613
  });
1613
- var extractContact = Effect11.fn("extractContact")(function* (message) {
1614
- const name = message.sender.name;
1615
- const email = message.sender.email;
1614
+ var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
1615
+ const name = actor.name;
1616
+ const email = actor.email;
1616
1617
  if (!email) {
1617
1618
  log5.warn("email is required for contact extraction", {
1618
- sender: message.sender
1619
+ actor
1619
1620
  }, {
1620
1621
  F: __dxlog_file5,
1621
- L: 99,
1622
+ L: 100,
1622
1623
  S: this,
1623
1624
  C: (f, a) => f(...a)
1624
1625
  });
@@ -1632,7 +1633,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1632
1633
  existingContact
1633
1634
  }, {
1634
1635
  F: __dxlog_file5,
1635
- L: 112,
1636
+ L: 113,
1636
1637
  S: this,
1637
1638
  C: (f, a) => f(...a)
1638
1639
  });
@@ -1640,7 +1641,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1640
1641
  }
1641
1642
  const newContact = Obj7.make(Person2.Person, {
1642
1643
  [Obj7.Meta]: {
1643
- tags: Obj7.getMeta(message)?.tags
1644
+ tags
1644
1645
  },
1645
1646
  emails: [
1646
1647
  {
@@ -1658,7 +1659,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1658
1659
  email
1659
1660
  }, {
1660
1661
  F: __dxlog_file5,
1661
- L: 130,
1662
+ L: 129,
1662
1663
  S: this,
1663
1664
  C: (f, a) => f(...a)
1664
1665
  });
@@ -1668,7 +1669,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1668
1669
  emailDomain
1669
1670
  }, {
1670
1671
  F: __dxlog_file5,
1671
- L: 134,
1672
+ L: 133,
1672
1673
  S: this,
1673
1674
  C: (f, a) => f(...a)
1674
1675
  });
@@ -1685,7 +1686,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1685
1686
  error: e
1686
1687
  }, {
1687
1688
  F: __dxlog_file5,
1688
- L: 152,
1689
+ L: 151,
1689
1690
  S: this,
1690
1691
  C: (f, a) => f(...a)
1691
1692
  });
@@ -1699,7 +1700,7 @@ var extractContact = Effect11.fn("extractContact")(function* (message) {
1699
1700
  organization: matchingOrg
1700
1701
  }, {
1701
1702
  F: __dxlog_file5,
1702
- L: 160,
1703
+ L: 159,
1703
1704
  S: this,
1704
1705
  C: (f, a) => f(...a)
1705
1706
  });
@@ -2429,11 +2430,11 @@ var websearch_default = websearch_blueprint_default;
2429
2430
  import * as Schema15 from "effect/Schema";
2430
2431
  import React from "react";
2431
2432
  import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
2432
- import { Type as Type3 } from "@dxos/echo";
2433
+ import { Format, Type as Type4 } from "@dxos/echo";
2433
2434
  import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
2434
2435
  var MapSchema = Schema15.Struct({
2435
- coordinates: Type3.Format.GeoPoint
2436
- }).pipe(Type3.Obj({
2436
+ coordinates: Format.GeoPoint
2437
+ }).pipe(Type4.Obj({
2437
2438
  typename: "example.com/type/Map",
2438
2439
  version: "0.1.0"
2439
2440
  }));
@@ -2522,7 +2523,7 @@ import * as Effect17 from "effect/Effect";
2522
2523
  import * as Record2 from "effect/Record";
2523
2524
  import * as Schema17 from "effect/Schema";
2524
2525
  import { ArtifactId as ArtifactId7 } from "@dxos/assistant";
2525
- import { DXN as DXN2, Obj as Obj16, Relation as Relation2, Tag as Tag2, Type as Type4 } from "@dxos/echo";
2526
+ import { DXN as DXN2, Obj as Obj16, Relation as Relation2, Tag as Tag2, Type as Type5 } from "@dxos/echo";
2526
2527
  import { DatabaseService as DatabaseService14 } from "@dxos/functions";
2527
2528
  import { trim as trim11 } from "@dxos/util";
2528
2529
  var SystemToolkit = Toolkit6.make(
@@ -2673,10 +2674,10 @@ var layer4 = () => SystemToolkit.toLayer({
2673
2674
  ]
2674
2675
  }).run());
2675
2676
  return schema.map((schema2) => {
2676
- const meta = Type4.getMeta(schema2);
2677
+ const meta = Type5.getMeta(schema2);
2677
2678
  return {
2678
- typename: Type4.getTypename(schema2),
2679
- jsonSchema: Type4.toJsonSchema(schema2),
2679
+ typename: Type5.getTypename(schema2),
2680
+ jsonSchema: Type5.toJsonSchema(schema2),
2680
2681
  kind: meta?.sourceSchema ? "relation" : "record"
2681
2682
  };
2682
2683
  });