@dxos/assistant 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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 (189) hide show
  1. package/dist/lib/browser/chunk-7CDDG6LL.mjs +578 -0
  2. package/dist/lib/browser/chunk-7CDDG6LL.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  5. package/dist/lib/browser/extraction/index.mjs +225 -0
  6. package/dist/lib/browser/extraction/index.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +723 -1704
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/testing/index.mjs +32 -0
  11. package/dist/lib/browser/testing/index.mjs.map +7 -0
  12. package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs +579 -0
  13. package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs.map +7 -0
  14. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  15. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  16. package/dist/lib/node-esm/extraction/index.mjs +226 -0
  17. package/dist/lib/node-esm/extraction/index.mjs.map +7 -0
  18. package/dist/lib/node-esm/index.mjs +723 -1705
  19. package/dist/lib/node-esm/index.mjs.map +4 -4
  20. package/dist/lib/node-esm/meta.json +1 -1
  21. package/dist/lib/node-esm/testing/index.mjs +33 -0
  22. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  23. package/dist/types/src/conversation/context.d.ts +129 -0
  24. package/dist/types/src/conversation/context.d.ts.map +1 -0
  25. package/dist/types/src/conversation/context.test.d.ts +2 -0
  26. package/dist/types/src/conversation/context.test.d.ts.map +1 -0
  27. package/dist/types/src/conversation/conversation.d.ts +29 -26
  28. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  29. package/dist/types/src/conversation/conversation.test.d.ts +2 -0
  30. package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
  31. package/dist/types/src/conversation/index.d.ts +1 -0
  32. package/dist/types/src/conversation/index.d.ts.map +1 -1
  33. package/dist/types/src/diff.d.ts +15 -0
  34. package/dist/types/src/diff.d.ts.map +1 -0
  35. package/dist/types/src/diff.test.d.ts +2 -0
  36. package/dist/types/src/diff.test.d.ts.map +1 -0
  37. package/dist/types/src/errors.d.ts +47 -18
  38. package/dist/types/src/errors.d.ts.map +1 -1
  39. package/dist/types/src/execution-graph.d.ts +85 -0
  40. package/dist/types/src/execution-graph.d.ts.map +1 -0
  41. package/dist/types/src/execution-graph.test.d.ts +2 -0
  42. package/dist/types/src/execution-graph.test.d.ts.map +1 -0
  43. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
  44. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
  45. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +258 -213
  46. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
  47. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
  48. package/dist/types/src/extraction/extraction.d.ts +345 -270
  49. package/dist/types/src/extraction/extraction.d.ts.map +1 -1
  50. package/dist/types/src/extraction/quotes.d.ts +3 -3
  51. package/dist/types/src/extraction/quotes.d.ts.map +1 -1
  52. package/dist/types/src/functions/services.d.ts +18 -4
  53. package/dist/types/src/functions/services.d.ts.map +1 -1
  54. package/dist/types/src/functions.test.d.ts +2 -0
  55. package/dist/types/src/functions.test.d.ts.map +1 -0
  56. package/dist/types/src/index.d.ts +3 -3
  57. package/dist/types/src/index.d.ts.map +1 -1
  58. package/dist/types/src/session/GenericToolkit.d.ts +85 -0
  59. package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
  60. package/dist/types/src/session/artifact-diff.d.ts +27 -0
  61. package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
  62. package/dist/types/src/session/error-handling.d.ts +4 -0
  63. package/dist/types/src/session/error-handling.d.ts.map +1 -0
  64. package/dist/types/src/session/format.d.ts +12 -0
  65. package/dist/types/src/session/format.d.ts.map +1 -0
  66. package/dist/types/src/session/format.test.d.ts +2 -0
  67. package/dist/types/src/session/format.test.d.ts.map +1 -0
  68. package/dist/types/src/session/index.d.ts +4 -0
  69. package/dist/types/src/session/index.d.ts.map +1 -1
  70. package/dist/types/src/session/observer.d.ts +23 -0
  71. package/dist/types/src/session/observer.d.ts.map +1 -0
  72. package/dist/types/src/session/session.d.ts +33 -237
  73. package/dist/types/src/session/session.d.ts.map +1 -1
  74. package/dist/types/src/session/toolkit.d.ts +14 -0
  75. package/dist/types/src/session/toolkit.d.ts.map +1 -0
  76. package/dist/types/src/session/version-pin.d.ts +4 -4
  77. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  78. package/dist/types/src/templates/index.d.ts +1 -1
  79. package/dist/types/src/templates/system.d.ts +18 -0
  80. package/dist/types/src/templates/system.d.ts.map +1 -0
  81. package/dist/types/src/testing/index.d.ts +1 -2
  82. package/dist/types/src/testing/index.d.ts.map +1 -1
  83. package/dist/types/src/testing/layer.d.ts +21 -0
  84. package/dist/types/src/testing/layer.d.ts.map +1 -0
  85. package/dist/types/src/types/artifact.d.ts +28 -0
  86. package/dist/types/src/types/artifact.d.ts.map +1 -0
  87. package/dist/types/src/types/index.d.ts +2 -0
  88. package/dist/types/src/types/index.d.ts.map +1 -0
  89. package/dist/types/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +56 -33
  91. package/src/conversation/context.test.ts +46 -0
  92. package/src/conversation/context.ts +303 -0
  93. package/src/conversation/conversation.test.ts +65 -0
  94. package/src/conversation/conversation.ts +93 -64
  95. package/src/conversation/index.ts +1 -0
  96. package/src/diff.test.ts +43 -0
  97. package/src/diff.ts +84 -0
  98. package/src/errors.ts +6 -1
  99. package/src/execution-graph.test.ts +740 -0
  100. package/src/execution-graph.ts +509 -0
  101. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +10 -9
  102. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +48 -56
  103. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +22 -21
  104. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +42 -43
  105. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
  106. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
  107. package/src/extraction/extraction.ts +10 -9
  108. package/src/extraction/quotes.test.ts +3 -3
  109. package/src/extraction/quotes.ts +6 -7
  110. package/src/functions/services.ts +138 -97
  111. package/src/functions.conversations.json +1 -0
  112. package/src/functions.test.ts +74 -0
  113. package/src/index.ts +3 -3
  114. package/src/session/GenericToolkit.ts +131 -0
  115. package/src/session/artifact-diff.ts +41 -0
  116. package/src/session/error-handling.ts +41 -0
  117. package/src/session/format.test.ts +124 -0
  118. package/src/session/format.ts +143 -0
  119. package/src/session/index.ts +5 -0
  120. package/src/session/observer.ts +61 -0
  121. package/src/session/session.conversations.json +1 -0
  122. package/src/session/session.test.ts +34 -201
  123. package/src/session/session.ts +146 -248
  124. package/src/session/toolkit.ts +39 -0
  125. package/src/session/version-pin.ts +8 -8
  126. package/src/templates/index.ts +1 -1
  127. package/src/templates/instructions/format.tpl +61 -0
  128. package/src/templates/instructions/system.tpl +48 -0
  129. package/src/templates/system.ts +41 -0
  130. package/src/testing/index.ts +2 -8
  131. package/src/testing/layer.ts +78 -0
  132. package/src/types/artifact.ts +82 -0
  133. package/src/types/index.ts +5 -0
  134. package/src/typings.d.ts +5 -0
  135. package/dist/types/bin/chat.d.ts +0 -2
  136. package/dist/types/bin/chat.d.ts.map +0 -1
  137. package/dist/types/src/context/binder.d.ts +0 -34
  138. package/dist/types/src/context/binder.d.ts.map +0 -1
  139. package/dist/types/src/context/binding.d.ts +0 -56
  140. package/dist/types/src/context/binding.d.ts.map +0 -1
  141. package/dist/types/src/context/index.d.ts +0 -3
  142. package/dist/types/src/context/index.d.ts.map +0 -1
  143. package/dist/types/src/research/exa.d.ts +0 -12
  144. package/dist/types/src/research/exa.d.ts.map +0 -1
  145. package/dist/types/src/research/graph.d.ts +0 -51
  146. package/dist/types/src/research/graph.d.ts.map +0 -1
  147. package/dist/types/src/research/graph.test.d.ts +0 -2
  148. package/dist/types/src/research/graph.test.d.ts.map +0 -1
  149. package/dist/types/src/research/index.d.ts +0 -4
  150. package/dist/types/src/research/index.d.ts.map +0 -1
  151. package/dist/types/src/research/research.d.ts +0 -10
  152. package/dist/types/src/research/research.d.ts.map +0 -1
  153. package/dist/types/src/research/research.test.d.ts +0 -2
  154. package/dist/types/src/research/research.test.d.ts.map +0 -1
  155. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  156. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  157. package/dist/types/src/summarization/summarization.test.d.ts +0 -2
  158. package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
  159. package/dist/types/src/templates/prompt.d.ts +0 -30
  160. package/dist/types/src/templates/prompt.d.ts.map +0 -1
  161. package/dist/types/src/testing/exa-search-1748337321991.d.ts +0 -38
  162. package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
  163. package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
  164. package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
  165. package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
  166. package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
  167. package/dist/types/src/types.d.ts +0 -13
  168. package/dist/types/src/types.d.ts.map +0 -1
  169. package/src/context/binder.ts +0 -103
  170. package/src/context/binding.ts +0 -32
  171. package/src/context/index.ts +0 -6
  172. package/src/research/exa.ts +0 -97
  173. package/src/research/graph.test.ts +0 -64
  174. package/src/research/graph.ts +0 -369
  175. package/src/research/index.ts +0 -7
  176. package/src/research/instructions-research.tpl +0 -98
  177. package/src/research/research.test.ts +0 -190
  178. package/src/research/research.ts +0 -87
  179. package/src/session/__snapshots__/session.test.ts.snap +0 -32
  180. package/src/session/version-pin.test.ts +0 -7
  181. package/src/summarization/summarization.test.ts +0 -208
  182. package/src/templates/assistant.tpl +0 -111
  183. package/src/templates/prompt.ts +0 -45
  184. package/src/testing/exa-search-1748337321991.ts +0 -131
  185. package/src/testing/exa-search-1748337331526.ts +0 -144
  186. package/src/testing/exa-search-1748337344119.ts +0 -133
  187. package/src/typedefs.d.ts +0 -8
  188. package/src/types.ts +0 -47
  189. /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,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
- });