@dxos/assistant 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3

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 (176) hide show
  1. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  2. package/dist/lib/browser/extraction/index.mjs +121 -165
  3. package/dist/lib/browser/extraction/index.mjs.map +4 -4
  4. package/dist/lib/browser/index.mjs +1110 -1034
  5. package/dist/lib/browser/index.mjs.map +4 -4
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  8. package/dist/lib/node-esm/extraction/index.mjs +121 -165
  9. package/dist/lib/node-esm/extraction/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/index.mjs +1110 -1034
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/types/src/{context/binding.d.ts → conversation/context.d.ts} +54 -5
  14. package/dist/types/src/conversation/context.d.ts.map +1 -0
  15. package/dist/types/src/conversation/conversation.d.ts +29 -26
  16. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  17. package/dist/types/src/conversation/index.d.ts +1 -0
  18. package/dist/types/src/conversation/index.d.ts.map +1 -1
  19. package/dist/types/src/diff.d.ts +15 -0
  20. package/dist/types/src/diff.d.ts.map +1 -0
  21. package/dist/types/src/diff.test.d.ts +2 -0
  22. package/dist/types/src/diff.test.d.ts.map +1 -0
  23. package/dist/types/src/errors.d.ts +46 -13
  24. package/dist/types/src/errors.d.ts.map +1 -1
  25. package/dist/types/src/execution-graph.d.ts +85 -0
  26. package/dist/types/src/execution-graph.d.ts.map +1 -0
  27. package/dist/types/src/execution-graph.test.d.ts +2 -0
  28. package/dist/types/src/execution-graph.test.d.ts.map +1 -0
  29. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
  30. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
  31. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +100 -57
  32. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
  33. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  34. package/dist/types/src/extraction/extraction.d.ts +262 -221
  35. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  36. package/dist/types/src/extraction/quotes.d.ts +1 -1
  37. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  38. package/dist/types/src/functions/services.d.ts +18 -4
  39. package/dist/types/src/functions/services.d.ts.map +1 -1
  40. package/dist/types/src/index.d.ts +3 -2
  41. package/dist/types/src/index.d.ts.map +1 -1
  42. package/dist/types/src/session/GenericToolkit.d.ts +84 -0
  43. package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
  44. package/dist/types/src/session/artifact-diff.d.ts +27 -0
  45. package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
  46. package/dist/types/src/session/error-handling.d.ts +4 -0
  47. package/dist/types/src/session/error-handling.d.ts.map +1 -0
  48. package/dist/types/src/session/format.d.ts +12 -0
  49. package/dist/types/src/session/format.d.ts.map +1 -0
  50. package/dist/types/src/session/format.test.d.ts +2 -0
  51. package/dist/types/src/session/format.test.d.ts.map +1 -0
  52. package/dist/types/src/session/index.d.ts +4 -0
  53. package/dist/types/src/session/index.d.ts.map +1 -1
  54. package/dist/types/src/session/observer.d.ts +22 -0
  55. package/dist/types/src/session/observer.d.ts.map +1 -0
  56. package/dist/types/src/session/session.d.ts +28 -237
  57. package/dist/types/src/session/session.d.ts.map +1 -1
  58. package/dist/types/src/session/toolkit.d.ts +15 -0
  59. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  60. package/dist/types/src/session/version-pin.d.ts +4 -4
  61. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  62. package/dist/types/src/templates/index.d.ts +1 -1
  63. package/dist/types/src/templates/system.d.ts +18 -0
  64. package/dist/types/src/templates/system.d.ts.map +1 -0
  65. package/dist/types/src/types/artifact.d.ts +20 -0
  66. package/dist/types/src/types/artifact.d.ts.map +1 -0
  67. package/dist/types/src/types/index.d.ts +2 -0
  68. package/dist/types/src/types/index.d.ts.map +1 -0
  69. package/dist/types/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +33 -36
  71. package/src/conversation/context.ts +186 -0
  72. package/src/conversation/conversation.ts +93 -61
  73. package/src/conversation/index.ts +1 -0
  74. package/src/diff.test.ts +43 -0
  75. package/src/diff.ts +84 -0
  76. package/src/errors.ts +6 -1
  77. package/src/execution-graph.test.ts +740 -0
  78. package/src/execution-graph.ts +509 -0
  79. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +10 -9
  80. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +48 -56
  81. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +18 -17
  82. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +42 -43
  83. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  84. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
  85. package/src/extraction/extraction.ts +7 -6
  86. package/src/extraction/quotes.test.ts +3 -3
  87. package/src/extraction/quotes.ts +4 -4
  88. package/src/functions/services.ts +108 -45
  89. package/src/index.ts +3 -2
  90. package/src/session/GenericToolkit.ts +130 -0
  91. package/src/session/artifact-diff.ts +41 -0
  92. package/src/session/error-handling.ts +41 -0
  93. package/src/session/format.test.ts +61 -0
  94. package/src/session/format.ts +144 -0
  95. package/src/session/index.ts +5 -0
  96. package/src/session/observer.ts +59 -0
  97. package/src/session/session.conversations.json +1 -0
  98. package/src/session/session.test.ts +38 -199
  99. package/src/session/session.ts +128 -251
  100. package/src/session/toolkit.ts +48 -0
  101. package/src/session/version-pin.ts +7 -8
  102. package/src/templates/index.ts +1 -1
  103. package/src/templates/instructions/format.tpl +61 -0
  104. package/src/templates/instructions/system.tpl +48 -0
  105. package/src/templates/system.ts +41 -0
  106. package/src/{types.ts → types/artifact.ts} +31 -7
  107. package/src/types/index.ts +5 -0
  108. package/src/typings.d.ts +5 -0
  109. package/dist/lib/browser/chunk-6WRGDEMH.mjs +0 -89
  110. package/dist/lib/browser/chunk-6WRGDEMH.mjs.map +0 -7
  111. package/dist/lib/browser/chunk-SIXTNSGV.mjs +0 -250
  112. package/dist/lib/browser/chunk-SIXTNSGV.mjs.map +0 -7
  113. package/dist/lib/browser/named-entity-recognition-O46UTCLR.mjs +0 -13
  114. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs +0 -91
  115. package/dist/lib/node-esm/chunk-3UU5V4FS.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-FD5NXKDP.mjs +0 -252
  117. package/dist/lib/node-esm/chunk-FD5NXKDP.mjs.map +0 -7
  118. package/dist/lib/node-esm/named-entity-recognition-W4VMRCH6.mjs +0 -14
  119. package/dist/types/bin/chat.d.ts +0 -2
  120. package/dist/types/bin/chat.d.ts.map +0 -1
  121. package/dist/types/src/context/binder.d.ts +0 -34
  122. package/dist/types/src/context/binder.d.ts.map +0 -1
  123. package/dist/types/src/context/binding.d.ts.map +0 -1
  124. package/dist/types/src/context/index.d.ts +0 -3
  125. package/dist/types/src/context/index.d.ts.map +0 -1
  126. package/dist/types/src/research/exa.d.ts +0 -12
  127. package/dist/types/src/research/exa.d.ts.map +0 -1
  128. package/dist/types/src/research/graph.d.ts +0 -51
  129. package/dist/types/src/research/graph.d.ts.map +0 -1
  130. package/dist/types/src/research/graph.test.d.ts +0 -2
  131. package/dist/types/src/research/graph.test.d.ts.map +0 -1
  132. package/dist/types/src/research/index.d.ts +0 -4
  133. package/dist/types/src/research/index.d.ts.map +0 -1
  134. package/dist/types/src/research/research.d.ts +0 -10
  135. package/dist/types/src/research/research.d.ts.map +0 -1
  136. package/dist/types/src/research/research.test.d.ts +0 -2
  137. package/dist/types/src/research/research.test.d.ts.map +0 -1
  138. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  139. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  140. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  141. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  142. package/dist/types/src/templates/prompt.d.ts +0 -30
  143. package/dist/types/src/templates/prompt.d.ts.map +0 -1
  144. package/dist/types/src/testing/exa-search-1748337321991.d.ts +0 -38
  145. package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
  146. package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
  147. package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
  148. package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
  149. package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
  150. package/dist/types/src/testing/index.d.ts +0 -3
  151. package/dist/types/src/testing/index.d.ts.map +0 -1
  152. package/dist/types/src/types.d.ts +0 -13
  153. package/dist/types/src/types.d.ts.map +0 -1
  154. package/src/context/binder.ts +0 -103
  155. package/src/context/binding.ts +0 -32
  156. package/src/context/index.ts +0 -6
  157. package/src/research/exa.ts +0 -97
  158. package/src/research/graph.test.ts +0 -64
  159. package/src/research/graph.ts +0 -369
  160. package/src/research/index.ts +0 -7
  161. package/src/research/instructions-research.tpl +0 -98
  162. package/src/research/research.test.ts +0 -190
  163. package/src/research/research.ts +0 -87
  164. package/src/session/__snapshots__/session.test.ts.snap +0 -32
  165. package/src/session/version-pin.test.ts +0 -7
  166. package/src/summarization/summarization.test.ts +0 -199
  167. package/src/templates/assistant.tpl +0 -111
  168. package/src/templates/prompt.ts +0 -45
  169. package/src/testing/exa-search-1748337321991.ts +0 -131
  170. package/src/testing/exa-search-1748337331526.ts +0 -144
  171. package/src/testing/exa-search-1748337344119.ts +0 -133
  172. package/src/testing/index.ts +0 -11
  173. package/src/typedefs.d.ts +0 -8
  174. /package/dist/lib/browser/{named-entity-recognition-O46UTCLR.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
  175. /package/dist/lib/node-esm/{named-entity-recognition-W4VMRCH6.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
  176. /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
@@ -1,58 +0,0 @@
1
- declare const _default: {
2
- requestId: string;
3
- autopromptString: string;
4
- autoDate: string;
5
- resolvedSearchType: string;
6
- results: ({
7
- id: string;
8
- title: string;
9
- url: string;
10
- publishedDate: string;
11
- author: string;
12
- score: number;
13
- text: string;
14
- favicon: string;
15
- image?: undefined;
16
- } | {
17
- id: string;
18
- title: string;
19
- url: string;
20
- publishedDate: string;
21
- author: string;
22
- score: number;
23
- text: string;
24
- favicon?: undefined;
25
- image?: undefined;
26
- } | {
27
- id: string;
28
- title: string;
29
- url: string;
30
- publishedDate: string;
31
- author: string;
32
- score: number;
33
- text: string;
34
- image: string;
35
- favicon: string;
36
- } | {
37
- id: string;
38
- title: string;
39
- url: string;
40
- author: string;
41
- text: string;
42
- image: string;
43
- favicon: string;
44
- publishedDate?: undefined;
45
- score?: undefined;
46
- })[];
47
- costDollars: {
48
- total: number;
49
- search: {
50
- neural: number;
51
- };
52
- contents: {
53
- text: number;
54
- };
55
- };
56
- };
57
- export default _default;
58
- //# sourceMappingURL=exa-search-1748337344119.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exa-search-1748337344119.d.ts","sourceRoot":"","sources":["../../../../src/testing/exa-search-1748337344119.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAgIE"}
@@ -1,3 +0,0 @@
1
- import type { SearchResponse } from 'exa-js';
2
- export declare const SEARCH_RESULTS: SearchResponse<any>[];
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAM7C,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,EAAgC,CAAC"}
@@ -1,13 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { type ObjectId } from '@dxos/echo-schema';
3
- import { DXN, type SpaceId } from '@dxos/keys';
4
- export declare const createArtifactElement: (id: ObjectId) => string;
5
- /**
6
- * A model-friendly way to reference an object.
7
- * Supports vairous formats that will be normalized to a DXN.
8
- */
9
- export declare const ArtifactId: Schema.Schema<string> & {
10
- toDXN: (reference: ArtifactId, owningSpaceId?: SpaceId) => DXN;
11
- };
12
- export type ArtifactId = Schema.Schema.Type<typeof ArtifactId>;
13
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAmB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,qBAAqB,GAAI,IAAI,QAAQ,WAA4B,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;IAC/C,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC;CA4BhE,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,103 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { computed, type ReadonlySignal } from '@preact/signals-core';
6
- import { Array, pipe } from 'effect';
7
-
8
- import { type Blueprint } from '@dxos/blueprints';
9
- import { Obj, type Type, type Ref, type Relation } from '@dxos/echo';
10
- import { type Queue } from '@dxos/echo-db';
11
- import { ComplexSet } from '@dxos/util';
12
-
13
- import { ContextBinding } from './binding';
14
-
15
- /**
16
- * Manages bindings of blueprints and objects to a conversation.
17
- */
18
- export class ContextBinder {
19
- constructor(private readonly _queue: Queue) {}
20
-
21
- /**
22
- * Reactive query of all bindings.
23
- */
24
- // TODO(burdon): Cache value?
25
- readonly bindings: ReadonlySignal<Bindings> = computed(() => this._reduce(this._queue.objects));
26
-
27
- // TODO(burdon): load refs?
28
- readonly blueprints: ReadonlySignal<Ref.Ref<Blueprint.Blueprint>[]> = computed(() => [
29
- ...this.bindings.value.blueprints,
30
- ]);
31
- readonly objects: ReadonlySignal<Ref.Ref<Type.Expando>[]> = computed(() => [...this.bindings.value.objects]);
32
-
33
- /**
34
- * Asynchronous query of all bindings.
35
- */
36
- async query(): Promise<Bindings> {
37
- const queueItems = await this._queue.queryObjects();
38
- return this._reduce(queueItems);
39
- }
40
-
41
- // TODO(burdon): Pass in Blueprint obj (from registry?) and create reference.
42
- async bind(props: BindingProps): Promise<void> {
43
- if (!props.blueprints?.length && !props.objects?.length) {
44
- return;
45
- }
46
-
47
- await this._queue.append([
48
- Obj.make(ContextBinding, {
49
- blueprints: {
50
- added: props.blueprints ?? [],
51
- removed: [],
52
- },
53
- objects: {
54
- added: props.objects ?? [],
55
- removed: [],
56
- },
57
- }),
58
- ]);
59
- }
60
-
61
- async unbind(props: BindingProps): Promise<void> {
62
- if (!props.blueprints?.length && !props.objects?.length) {
63
- return;
64
- }
65
-
66
- await this._queue.append([
67
- Obj.make(ContextBinding, {
68
- blueprints: {
69
- added: [],
70
- removed: props.blueprints ?? [],
71
- },
72
- objects: {
73
- added: [],
74
- removed: props.objects ?? [],
75
- },
76
- }),
77
- ]);
78
- }
79
-
80
- private _reduce(items: (Obj.Any | Relation.Any)[]): Bindings {
81
- return pipe(
82
- items,
83
- Array.filter(Obj.instanceOf(ContextBinding)),
84
- Array.reduce(new Bindings(), (context, item) => {
85
- item.blueprints.removed.forEach((item) => context.blueprints.delete(item));
86
- item.blueprints.added.forEach((item) => context.blueprints.add(item));
87
- item.objects.removed.forEach((item) => context.objects.delete(item));
88
- item.objects.added.forEach((item) => context.objects.add(item));
89
- return context;
90
- }),
91
- );
92
- }
93
- }
94
-
95
- export type BindingProps = Partial<{
96
- blueprints: Ref.Ref<Blueprint.Blueprint>[];
97
- objects: Ref.Ref<Type.Expando>[];
98
- }>;
99
-
100
- export class Bindings {
101
- blueprints = new ComplexSet<Ref.Ref<Blueprint.Blueprint>>((ref) => ref.dxn.toString());
102
- objects = new ComplexSet<Ref.Ref<Type.Expando>>((ref) => ref.dxn.toString());
103
- }
@@ -1,32 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { Blueprint } from '@dxos/blueprints';
8
- import { Type } from '@dxos/echo';
9
-
10
- /**
11
- * Thread message that binds or unbinds contextual objects to a conversation.
12
- */
13
- // TODO(burdon): Make ContentBlock.
14
- export const ContextBinding = Schema.Struct({
15
- blueprints: Schema.Struct({
16
- added: Schema.Array(Type.Ref(Blueprint.Blueprint)),
17
- removed: Schema.Array(Type.Ref(Blueprint.Blueprint)),
18
- }),
19
-
20
- // TODO(burdon): Type.Expando => Type.Obj (or Obj.Any?)
21
- objects: Schema.Struct({
22
- added: Schema.Array(Type.Ref(Type.Expando)),
23
- removed: Schema.Array(Type.Ref(Type.Expando)),
24
- }),
25
- }).pipe(
26
- Type.Obj({
27
- typename: 'dxos.org/type/ContextBinding',
28
- version: '0.1.0',
29
- }),
30
- );
31
-
32
- export interface ContextBinding extends Schema.Schema.Type<typeof ContextBinding> {}
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export * from './binder';
6
- export * from './binding';
@@ -1,97 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { AiTool, AiToolkit } from '@effect/ai';
6
- import { Effect, Schema } from 'effect';
7
- import Exa from 'exa-js';
8
-
9
- import { CredentialsService } from '@dxos/functions';
10
- import { log } from '@dxos/log';
11
-
12
- import { SEARCH_RESULTS } from '../testing';
13
-
14
- export class ExaToolkit extends AiToolkit.make(
15
- AiTool.make('exa_search', {
16
- description: 'Search the web for information',
17
- parameters: {
18
- query: Schema.String.annotations({ description: 'The query to search for' }),
19
- },
20
- success: Schema.Unknown,
21
- failure: Schema.Never,
22
- }).addRequirement<CredentialsService>(),
23
- ) {}
24
-
25
- export const LiveExaHandler = ExaToolkit.toLayer({
26
- exa_search: Effect.fn(function* ({ query }) {
27
- const credential = yield* CredentialsService.getCredential({ service: 'exa.ai' });
28
- const exa = new Exa(credential.apiKey);
29
-
30
- const context = yield* Effect.promise(async () =>
31
- exa.searchAndContents(query, {
32
- type: 'auto',
33
- text: {
34
- maxCharacters: 3_000,
35
- },
36
- livecrawl: 'always',
37
- }),
38
- );
39
-
40
- log.info('exa search', { query, costDollars: context.costDollars });
41
-
42
- return context;
43
- }),
44
- });
45
-
46
- export const MockExaHandler = ExaToolkit.toLayer({
47
- exa_search: Effect.fn(function* ({ query }) {
48
- // Find result with closest matching autoprompt using weighted Levenshtein distance
49
- const result = SEARCH_RESULTS.reduce(
50
- (closest, current) => {
51
- if (!current.autopromptString) {
52
- return closest;
53
- }
54
- if (!closest) {
55
- return current;
56
- }
57
-
58
- // Calculate Levenshtein distance
59
- const dist1 = levenshteinDistance(query, current.autopromptString);
60
- const dist2 = levenshteinDistance(query, closest.autopromptString || '');
61
-
62
- // Weight by length of the longer string to normalize
63
- const weight1 = dist1 / Math.max(query.length, current.autopromptString.length);
64
- const weight2 = dist2 / Math.max(query.length, closest.autopromptString?.length || 0);
65
-
66
- return weight1 < weight2 ? current : closest;
67
- },
68
- null as (typeof SEARCH_RESULTS)[0] | null,
69
- );
70
-
71
- return result;
72
- }),
73
- });
74
-
75
- const levenshteinDistance = (str1: string, str2: string): number => {
76
- const m = str1.length;
77
- const n = str2.length;
78
- const dp: number[][] = Array(m + 1)
79
- .fill(null)
80
- .map(() => Array(n + 1).fill(0));
81
-
82
- for (let i = 0; i <= m; i++) {
83
- dp[i][0] = i;
84
- }
85
- for (let j = 0; j <= n; j++) {
86
- dp[0][j] = j;
87
- }
88
-
89
- for (let i = 1; i <= m; i++) {
90
- for (let j = 1; j <= n; j++) {
91
- dp[i][j] =
92
- str1[i - 1] === str2[j - 1] ? dp[i - 1][j - 1] : Math.min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1;
93
- }
94
- }
95
-
96
- return dp[m][n];
97
- };
@@ -1,64 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { AnthropicClient } from '@effect/ai-anthropic';
6
- import { FetchHttpClient } from '@effect/platform';
7
- import { describe, it } from '@effect/vitest';
8
- import { Config, Effect, Layer, pipe } from 'effect';
9
-
10
- import { AiService, AiServiceRouter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
11
- import { tapHttpErrors } from '@dxos/ai/testing';
12
- import { TestHelpers } from '@dxos/effect';
13
- import { DatabaseService } from '@dxos/functions';
14
- import { log } from '@dxos/log';
15
- import { DataType } from '@dxos/schema';
16
-
17
- import { makeGraphWriterHandler, makeGraphWriterToolkit } from './graph';
18
- import { AiSession } from '../session';
19
-
20
- // import { type EchoTestBuilder } from '@dxos/echo-db/testing';
21
-
22
- const TestLayer = pipe(
23
- AiService.model('@anthropic/claude-3-5-sonnet-20241022'),
24
- Layer.provideMerge(DatabaseService.notAvailable),
25
- Layer.provideMerge(ToolResolverService.layerEmpty),
26
- Layer.provideMerge(ToolExecutionService.layerEmpty),
27
- Layer.provide(AiServiceRouter.AiServiceRouter),
28
- Layer.provide(
29
- AnthropicClient.layerConfig({
30
- apiKey: Config.redacted('ANTHROPIC_API_KEY'),
31
- transformClient: tapHttpErrors,
32
- }),
33
- ),
34
- Layer.provide(FetchHttpClient.layer),
35
- );
36
-
37
- describe('graph', () => {
38
- // let builder: EchoTestBuilder;
39
- // test('findRelatedSchema', async () => {
40
- // const db = await createEchoDatabase();
41
- // const relatedSchemas = await findRelatedSchema(db, Schema.Struct({}));
42
- // });
43
-
44
- it.effect.skip(
45
- 'calculator',
46
- Effect.fn(
47
- function* ({ expect }) {
48
- const graphWriteToolkit = makeGraphWriterToolkit({ schema: [DataType.Project] });
49
-
50
- const session = new AiSession();
51
- const response = yield* session
52
- .run({
53
- prompt: 'What is 10 + 20?',
54
- history: [],
55
- toolkit: graphWriteToolkit,
56
- })
57
- .pipe(Effect.provide(makeGraphWriterHandler(graphWriteToolkit)));
58
- log.info('response', { response });
59
- },
60
- Effect.provide(TestLayer),
61
- TestHelpers.runIf(process.env.ANTHROPIC_API_KEY),
62
- ),
63
- );
64
- });