@dxos/assistant 0.8.3 → 0.8.4-main.f9ba587
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 +456 -595
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +456 -595
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +33 -47
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/index.d.ts +1 -2
- package/dist/types/src/blueprint/index.d.ts.map +1 -1
- package/dist/types/src/blueprint/registry.d.ts +7 -0
- package/dist/types/src/blueprint/registry.d.ts.map +1 -0
- package/dist/types/src/context/binder.d.ts +34 -0
- package/dist/types/src/context/binder.d.ts.map +1 -0
- package/dist/types/src/context/binding.d.ts +38 -0
- package/dist/types/src/context/binding.d.ts.map +1 -0
- package/dist/types/src/context/index.d.ts +3 -0
- package/dist/types/src/context/index.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.d.ts +44 -0
- package/dist/types/src/conversation/conversation.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts +2 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +10 -10
- package/dist/types/src/index.d.ts +4 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/research/research.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +25 -3
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -30
- package/src/blueprint/blueprint.ts +57 -57
- package/src/blueprint/index.ts +1 -2
- package/src/blueprint/registry.ts +15 -0
- package/src/context/binder.ts +101 -0
- package/src/context/binding.ts +31 -0
- package/src/context/index.ts +6 -0
- package/src/conversation/conversation.ts +103 -0
- package/src/conversation/index.ts +5 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +2 -1
- package/src/index.ts +4 -1
- package/src/research/research.ts +3 -2
- package/src/session/session.test.ts +48 -2
- package/src/session/session.ts +51 -18
- package/dist/lib/node/index.cjs +0 -2178
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/blueprint/ai.test.d.ts +0 -2
- package/dist/types/src/blueprint/ai.test.d.ts.map +0 -1
- package/dist/types/src/blueprint/blueprint.test.d.ts +0 -2
- package/dist/types/src/blueprint/blueprint.test.d.ts.map +0 -1
- package/dist/types/src/blueprint/logger.d.ts +0 -25
- package/dist/types/src/blueprint/logger.d.ts.map +0 -1
- package/dist/types/src/blueprint/machine.d.ts +0 -143
- package/dist/types/src/blueprint/machine.d.ts.map +0 -1
- package/dist/types/src/blueprint/test-data.d.ts +0 -3
- package/dist/types/src/blueprint/test-data.d.ts.map +0 -1
- package/src/blueprint/ai.test.ts +0 -156
- package/src/blueprint/blueprint.test.ts +0 -151
- package/src/blueprint/logger.ts +0 -155
- package/src/blueprint/machine.ts +0 -251
- package/src/blueprint/test-data.ts +0 -55
package/dist/lib/node/meta.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"packages/core/assistant/src/extraction/extraction.ts":{"bytes":6835,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"raw-loader:./instructions.tpl?raw":{"bytes":1318,"imports":[]},"packages/core/assistant/src/session/version-pin.ts":{"bytes":4222,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/assistant/src/session/session.ts":{"bytes":59501,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/assistant/src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"}],"format":"esm"},"packages/core/assistant/src/session/index.ts":{"bytes":569,"imports":[{"path":"packages/core/assistant/src/session/session.ts","kind":"import-statement","original":"./session"},{"path":"packages/core/assistant/src/session/version-pin.ts","kind":"import-statement","original":"./version-pin"}],"format":"esm"},"packages/core/assistant/src/extraction/quotes.ts":{"bytes":7123,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/assistant/src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytes":7821,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"raw-loader:./instructions.tpl?raw","kind":"import-statement","original":"./instructions.tpl?raw"},{"path":"packages/core/assistant/src/session/index.ts","kind":"import-statement","original":"../../session"},{"path":"packages/core/assistant/src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"packages/core/assistant/src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"}],"format":"esm"},"packages/core/assistant/src/extraction/extraction-llm-function/index.ts":{"bytes":537,"imports":[{"path":"packages/core/assistant/src/extraction/extraction-llm-function/extraction-llm-function.ts","kind":"import-statement","original":"./extraction-llm-function"}],"format":"esm"},"packages/core/assistant/src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytes":10072,"imports":[{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/assistant/src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytes":8910,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"packages/core/assistant/src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"},{"path":"packages/core/assistant/src/extraction/extraction.ts","kind":"import-statement","original":"../extraction"},{"path":"packages/core/assistant/src/extraction/quotes.ts","kind":"import-statement","original":"../quotes"}],"format":"esm"},"packages/core/assistant/src/extraction/extraction-ner-function/index.ts":{"bytes":665,"imports":[{"path":"packages/core/assistant/src/extraction/extraction-ner-function/extraction-ner-function.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"packages/core/assistant/src/extraction/extraction-ner-function/named-entity-recognition.ts","kind":"import-statement","original":"./named-entity-recognition"}],"format":"esm"},"packages/core/assistant/src/extraction/index.ts":{"bytes":816,"imports":[{"path":"packages/core/assistant/src/extraction/extraction.ts","kind":"import-statement","original":"./extraction"},{"path":"packages/core/assistant/src/extraction/extraction-llm-function/index.ts","kind":"import-statement","original":"./extraction-llm-function"},{"path":"packages/core/assistant/src/extraction/extraction-ner-function/index.ts","kind":"import-statement","original":"./extraction-ner-function"},{"path":"packages/core/assistant/src/extraction/quotes.ts","kind":"import-statement","original":"./quotes"}],"format":"esm"},"packages/core/assistant/src/testing/exa-search-1748337321991.ts":{"bytes":75521,"imports":[],"format":"esm"},"packages/core/assistant/src/testing/exa-search-1748337331526.ts":{"bytes":90591,"imports":[],"format":"esm"},"packages/core/assistant/src/testing/exa-search-1748337344119.ts":{"bytes":69963,"imports":[],"format":"esm"},"packages/core/assistant/src/testing/index.ts":{"bytes":1218,"imports":[{"path":"packages/core/assistant/src/testing/exa-search-1748337321991.ts","kind":"import-statement","original":"./exa-search-1748337321991"},{"path":"packages/core/assistant/src/testing/exa-search-1748337331526.ts","kind":"import-statement","original":"./exa-search-1748337331526"},{"path":"packages/core/assistant/src/testing/exa-search-1748337344119.ts","kind":"import-statement","original":"./exa-search-1748337344119"}],"format":"esm"},"packages/core/assistant/src/research/exa.ts":{"bytes":10703,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"exa-js","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/assistant/src/testing/index.ts","kind":"import-statement","original":"../testing"}],"format":"esm"},"packages/core/assistant/src/research/graph.ts":{"bytes":34603,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"raw-loader:./instructions-research.tpl?raw":{"bytes":5065,"imports":[]},"packages/core/assistant/src/research/research.ts":{"bytes":12315,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"packages/core/assistant/src/research/exa.ts","kind":"import-statement","original":"./exa"},{"path":"packages/core/assistant/src/research/graph.ts","kind":"import-statement","original":"./graph"},{"path":"raw-loader:./instructions-research.tpl?raw","kind":"import-statement","original":"./instructions-research.tpl?raw"},{"path":"packages/core/assistant/src/session/index.ts","kind":"import-statement","original":"../session"}],"format":"esm"},"packages/core/assistant/src/research/index.ts":{"bytes":632,"imports":[{"path":"packages/core/assistant/src/research/exa.ts","kind":"import-statement","original":"./exa"},{"path":"packages/core/assistant/src/research/research.ts","kind":"import-statement","original":"./research"},{"path":"packages/core/assistant/src/research/graph.ts","kind":"import-statement","original":"./graph"}],"format":"esm"},"packages/core/assistant/src/types.ts":{"bytes":858,"imports":[],"format":"esm"},"packages/core/assistant/src/blueprint/blueprint.ts":{"bytes":6426,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"packages/core/assistant/src/blueprint/machine.ts":{"bytes":25722,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/assistant/src/session/index.ts","kind":"import-statement","original":"../session"}],"format":"esm"},"packages/core/assistant/src/blueprint/logger.ts":{"bytes":16321,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/assistant/src/blueprint/index.ts":{"bytes":647,"imports":[{"path":"packages/core/assistant/src/blueprint/blueprint.ts","kind":"import-statement","original":"./blueprint"},{"path":"packages/core/assistant/src/blueprint/machine.ts","kind":"import-statement","original":"./machine"},{"path":"packages/core/assistant/src/blueprint/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"},"packages/core/assistant/src/index.ts":{"bytes":814,"imports":[{"path":"packages/core/assistant/src/extraction/index.ts","kind":"import-statement","original":"./extraction"},{"path":"packages/core/assistant/src/research/index.ts","kind":"import-statement","original":"./research"},{"path":"packages/core/assistant/src/session/index.ts","kind":"import-statement","original":"./session"},{"path":"packages/core/assistant/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/assistant/src/blueprint/index.ts","kind":"import-statement","original":"./blueprint"}],"format":"esm"}},"outputs":{"packages/core/assistant/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":215521},"packages/core/assistant/dist/lib/node/index.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"@xenova/transformers","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"exa-js","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["AIServiecOverloadedError","AISession","Blueprint","BlueprintBuilder","BlueprintDefinition","BlueprintLoggerAdapter","BlueprintMachine","BlueprintParser","BlueprintStep","BufferedLogger","ExtractionInput","ExtractionOutput","ReferencedQuotes","Subgraph","VersionPin","combineNerTokens","createArtifactElement","createExaTool","createExtractionSchema","createGraphWriterTool","createLocalSearchTool","createMockExaTool","createTokenGroups","extractFullEntities","extractionAnthropicFn","extractionNerFn","findQuotes","findRelatedSchema","getNer","getSanitizedSchemaName","insertReferences","processTranscriptMessage","researchFn","sanitizeObjects","setConsolePrinter","setLogger"],"entryPoint":"packages/core/assistant/src/index.ts","inputs":{"packages/core/assistant/src/extraction/extraction.ts":{"bytesInOutput":1383},"packages/core/assistant/src/extraction/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/extraction/extraction-llm-function/extraction-llm-function.ts":{"bytesInOutput":1693},"raw-loader:./instructions.tpl?raw":{"bytesInOutput":1376},"packages/core/assistant/src/session/session.ts":{"bytesInOutput":15806},"packages/core/assistant/src/session/version-pin.ts":{"bytesInOutput":758},"packages/core/assistant/src/session/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/extraction/quotes.ts":{"bytesInOutput":1700},"packages/core/assistant/src/extraction/extraction-llm-function/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/extraction/extraction-ner-function/extraction-ner-function.ts":{"bytesInOutput":2653},"packages/core/assistant/src/extraction/extraction-ner-function/named-entity-recognition.ts":{"bytesInOutput":2289},"packages/core/assistant/src/extraction/extraction-ner-function/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/research/exa.ts":{"bytesInOutput":2550},"packages/core/assistant/src/testing/exa-search-1748337321991.ts":{"bytesInOutput":31265},"packages/core/assistant/src/testing/exa-search-1748337331526.ts":{"bytesInOutput":43952},"packages/core/assistant/src/testing/exa-search-1748337344119.ts":{"bytesInOutput":28760},"packages/core/assistant/src/testing/index.ts":{"bytesInOutput":133},"packages/core/assistant/src/research/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/research/research.ts":{"bytesInOutput":2910},"packages/core/assistant/src/research/graph.ts":{"bytesInOutput":8246},"raw-loader:./instructions-research.tpl?raw":{"bytesInOutput":5201},"packages/core/assistant/src/types.ts":{"bytesInOutput":61},"packages/core/assistant/src/blueprint/blueprint.ts":{"bytesInOutput":1461},"packages/core/assistant/src/blueprint/index.ts":{"bytesInOutput":0},"packages/core/assistant/src/blueprint/machine.ts":{"bytesInOutput":6264},"packages/core/assistant/src/blueprint/logger.ts":{"bytesInOutput":3703}},"bytes":164453}}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai.test.d.ts","sourceRoot":"","sources":["../../../../src/blueprint/ai.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blueprint.test.d.ts","sourceRoot":"","sources":["../../../../src/blueprint/blueprint.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type ReadonlySignal } from '@preact/signals-core';
|
|
2
|
-
import { type CleanupFn } from '@dxos/async';
|
|
3
|
-
import { type BlueprintEvent, type BlueprintLogger, type BlueprintMachine } from './machine';
|
|
4
|
-
type ConsoleLogSignature = (message: string, arg?: any) => void;
|
|
5
|
-
interface Logger {
|
|
6
|
-
log: ConsoleLogSignature;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Reactive bufferedlogger.
|
|
10
|
-
*/
|
|
11
|
-
export declare class BufferedLogger implements Logger {
|
|
12
|
-
private _messages;
|
|
13
|
-
get messages(): ReadonlySignal<string[]>;
|
|
14
|
-
clear(): void;
|
|
15
|
-
log(message: string): void;
|
|
16
|
-
}
|
|
17
|
-
export declare class BlueprintLoggerAdapter implements BlueprintLogger {
|
|
18
|
-
private readonly logger;
|
|
19
|
-
constructor(logger?: Logger);
|
|
20
|
-
log(event: BlueprintEvent): void;
|
|
21
|
-
}
|
|
22
|
-
export declare const setLogger: (machine: BlueprintMachine, logger: BufferedLogger) => CleanupFn;
|
|
23
|
-
export declare const setConsolePrinter: (machine: BlueprintMachine, verbose?: boolean) => CleanupFn;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/blueprint/logger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAU,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,aAAa,CAAC;AAItD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,KAAK,mBAAmB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;AAEhE,UAAU,MAAM;IACd,GAAG,EAAE,mBAAmB,CAAC;CAC1B;AAID;;GAEG;AACH,qBAAa,cAAe,YAAW,MAAM;IAC3C,OAAO,CAAC,SAAS,CAAwB;IAEzC,IAAI,QAAQ,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAEvC;IAED,KAAK;IAIL,GAAG,CAAC,OAAO,EAAE,MAAM;CAGpB;AAGD,qBAAa,sBAAuB,YAAW,eAAe;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,GAAE,MAAuB;IAE5D,GAAG,CAAC,KAAK,EAAE,cAAc;CAsB1B;AAED,eAAO,MAAM,SAAS,GAAI,SAAS,gBAAgB,EAAE,QAAQ,cAAc,KAAG,SAkB7E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,gBAAgB,EAAE,iBAAe,KAAG,SAkB9E,CAAC"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { type AiServiceClient, Message, type MessageContentBlock, type ToolRegistry } from '@dxos/ai';
|
|
2
|
-
import { Event } from '@dxos/async';
|
|
3
|
-
import { type ObjectId } from '@dxos/keys';
|
|
4
|
-
import type { Blueprint, BlueprintStep } from './blueprint';
|
|
5
|
-
export type BlueprintTraceStep = {
|
|
6
|
-
status: 'done' | 'bailed' | 'skipped';
|
|
7
|
-
stepId: ObjectId;
|
|
8
|
-
comment: string;
|
|
9
|
-
};
|
|
10
|
-
export type BlueprintMachineState = {
|
|
11
|
-
history: Message[];
|
|
12
|
-
trace: BlueprintTraceStep[];
|
|
13
|
-
state: 'working' | 'bail' | 'done';
|
|
14
|
-
};
|
|
15
|
-
type ExecutionOptions = {
|
|
16
|
-
aiClient: AiServiceClient;
|
|
17
|
-
/**
|
|
18
|
-
* Input to the blueprint.
|
|
19
|
-
*/
|
|
20
|
-
input?: unknown;
|
|
21
|
-
};
|
|
22
|
-
export type BlueprintEvent = {
|
|
23
|
-
type: 'begin';
|
|
24
|
-
invocationId: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: 'end';
|
|
27
|
-
invocationId: string;
|
|
28
|
-
} | {
|
|
29
|
-
type: 'step-start';
|
|
30
|
-
invocationId: string;
|
|
31
|
-
step: BlueprintStep;
|
|
32
|
-
} | {
|
|
33
|
-
type: 'step-complete';
|
|
34
|
-
invocationId: string;
|
|
35
|
-
step: BlueprintStep;
|
|
36
|
-
} | {
|
|
37
|
-
type: 'message';
|
|
38
|
-
invocationId: string;
|
|
39
|
-
message: Message;
|
|
40
|
-
} | {
|
|
41
|
-
type: 'block';
|
|
42
|
-
invocationId: string;
|
|
43
|
-
block: MessageContentBlock;
|
|
44
|
-
};
|
|
45
|
-
export interface BlueprintLogger {
|
|
46
|
-
log(event: BlueprintEvent): void;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Blueprint state machine.
|
|
50
|
-
*/
|
|
51
|
-
export declare class BlueprintMachine {
|
|
52
|
-
readonly registry: ToolRegistry;
|
|
53
|
-
readonly blueprint: Blueprint;
|
|
54
|
-
readonly begin: Event<void>;
|
|
55
|
-
readonly end: Event<void>;
|
|
56
|
-
readonly stepStart: Event<BlueprintStep>;
|
|
57
|
-
readonly stepComplete: Event<BlueprintStep>;
|
|
58
|
-
readonly message: Event<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
|
|
59
|
-
id: string;
|
|
60
|
-
role: "user" | "assistant";
|
|
61
|
-
content: ({
|
|
62
|
-
pending?: boolean | undefined;
|
|
63
|
-
type: "text";
|
|
64
|
-
disposition?: string | undefined;
|
|
65
|
-
text: string;
|
|
66
|
-
} | {
|
|
67
|
-
pending?: boolean | undefined;
|
|
68
|
-
type: "json";
|
|
69
|
-
disposition?: string | undefined;
|
|
70
|
-
json: string;
|
|
71
|
-
} | {
|
|
72
|
-
pending?: boolean | undefined;
|
|
73
|
-
id?: string | undefined;
|
|
74
|
-
type: "image";
|
|
75
|
-
source?: {
|
|
76
|
-
type: "base64";
|
|
77
|
-
mediaType: string;
|
|
78
|
-
data: string;
|
|
79
|
-
} | undefined;
|
|
80
|
-
} | {
|
|
81
|
-
pending?: boolean | undefined;
|
|
82
|
-
id: string;
|
|
83
|
-
name: string;
|
|
84
|
-
type: "tool_use";
|
|
85
|
-
input: unknown;
|
|
86
|
-
currentStatus?: {
|
|
87
|
-
readonly id: string;
|
|
88
|
-
message: string;
|
|
89
|
-
} | undefined;
|
|
90
|
-
} | {
|
|
91
|
-
pending?: boolean | undefined;
|
|
92
|
-
type: "tool_result";
|
|
93
|
-
content: string;
|
|
94
|
-
toolUseId: string;
|
|
95
|
-
isError?: boolean | undefined;
|
|
96
|
-
})[];
|
|
97
|
-
}>;
|
|
98
|
-
readonly block: Event<{
|
|
99
|
-
pending?: boolean | undefined;
|
|
100
|
-
type: "text";
|
|
101
|
-
disposition?: string | undefined;
|
|
102
|
-
text: string;
|
|
103
|
-
} | {
|
|
104
|
-
pending?: boolean | undefined;
|
|
105
|
-
type: "json";
|
|
106
|
-
disposition?: string | undefined;
|
|
107
|
-
json: string;
|
|
108
|
-
} | {
|
|
109
|
-
pending?: boolean | undefined;
|
|
110
|
-
id?: string | undefined;
|
|
111
|
-
type: "image";
|
|
112
|
-
source?: {
|
|
113
|
-
type: "base64";
|
|
114
|
-
mediaType: string;
|
|
115
|
-
data: string;
|
|
116
|
-
} | undefined;
|
|
117
|
-
} | {
|
|
118
|
-
pending?: boolean | undefined;
|
|
119
|
-
id: string;
|
|
120
|
-
name: string;
|
|
121
|
-
type: "tool_use";
|
|
122
|
-
input: unknown;
|
|
123
|
-
currentStatus?: {
|
|
124
|
-
readonly id: string;
|
|
125
|
-
message: string;
|
|
126
|
-
} | undefined;
|
|
127
|
-
} | {
|
|
128
|
-
pending?: boolean | undefined;
|
|
129
|
-
type: "tool_result";
|
|
130
|
-
content: string;
|
|
131
|
-
toolUseId: string;
|
|
132
|
-
isError?: boolean | undefined;
|
|
133
|
-
}>;
|
|
134
|
-
private logger?;
|
|
135
|
-
private _state;
|
|
136
|
-
constructor(registry: ToolRegistry, blueprint: Blueprint);
|
|
137
|
-
get state(): BlueprintMachineState;
|
|
138
|
-
setLogger(logger: BlueprintLogger): this;
|
|
139
|
-
runToCompletion(options: ExecutionOptions): Promise<void>;
|
|
140
|
-
private _execStep;
|
|
141
|
-
}
|
|
142
|
-
export {};
|
|
143
|
-
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../../src/blueprint/machine.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,eAAe,EACpB,OAAO,EACP,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAc5D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;CACpC,CAAC;AAQF,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,eAAe,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAczB,QAAQ,CAAC,QAAQ,EAAE,YAAY;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS;IAd/B,SAAgB,KAAK,cAAqB;IAC1C,SAAgB,GAAG,cAAqB;IACxC,SAAgB,SAAS,uBAA8B;IACvD,SAAgB,YAAY,uBAA8B;IAC1D,SAAgB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAwB;IAC/C,SAAgB,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAoC;IAGzD,OAAO,CAAC,MAAM,CAAC,CAAkB;IAEjC,OAAO,CAAC,MAAM,CAAyD;gBAG5D,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,SAAS;IAG/B,IAAI,KAAK,IAAI,qBAAqB,CAEjC;IAED,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAKlC,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;YA2BjD,SAAS;CA4FxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-data.d.ts","sourceRoot":"","sources":["../../../../src/blueprint/test-data.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,OAAO,EA8CzC,CAAC"}
|
package/src/blueprint/ai.test.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { AiChat, AiInput, AiLanguageModel, AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
-
import { AnthropicClient, AnthropicLanguageModel } from '@effect/ai-anthropic';
|
|
7
|
-
import { OpenAiClient, OpenAiLanguageModel } from '@effect/ai-openai';
|
|
8
|
-
import { NodeHttpClient } from '@effect/platform-node';
|
|
9
|
-
import { Config, Console, Effect, Layer, pipe, Schedule, Schema } from 'effect';
|
|
10
|
-
import { describe, it } from 'vitest';
|
|
11
|
-
|
|
12
|
-
import { log } from '@dxos/log';
|
|
13
|
-
|
|
14
|
-
// https://effect.website/docs/ai/tool-use/#5-bring-it-all-together
|
|
15
|
-
// https://github.com/Effect-TS/effect/blob/main/packages/ai/ai/CHANGELOG.md
|
|
16
|
-
// https://discord.com/channels/795981131316985866/1338871274398679130
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Rationale:
|
|
20
|
-
* - Separation of concerns: config, execution pipline, error handling/retry, tool dispatch, async.
|
|
21
|
-
* - Uncouple tool definitions from tool implementation (late binding, composition).
|
|
22
|
-
* - Affinity with effect schema.
|
|
23
|
-
* - Leverage existing effect based conductor pipline.
|
|
24
|
-
* - Simple API for plugins/artifacts.
|
|
25
|
-
* - Ecosystem and design partner.
|
|
26
|
-
*/
|
|
27
|
-
describe.runIf(!process.env.CI)('AiLanguageModel', () => {
|
|
28
|
-
it.runIf(process.env.OPENAI_API_KEY)('Debug: Verify API configuration', async ({ expect }) => {
|
|
29
|
-
const program = Effect.gen(function* () {
|
|
30
|
-
yield* Console.log('Testing API connectivity...');
|
|
31
|
-
const response = yield* AiLanguageModel.generateText({ prompt: 'Hello, respond with "API is working"' });
|
|
32
|
-
yield* Console.log('API Response received:', response.text);
|
|
33
|
-
return response.text;
|
|
34
|
-
}).pipe(
|
|
35
|
-
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
36
|
-
Effect.timeout('10 seconds'),
|
|
37
|
-
Effect.retry({ times: 1 }),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const result = await program.pipe(
|
|
41
|
-
Effect.provide([
|
|
42
|
-
OpenAiClient.layerConfig({
|
|
43
|
-
apiKey: Config.redacted('OPENAI_API_KEY'),
|
|
44
|
-
}).pipe(Layer.provide(NodeHttpClient.layerUndici)),
|
|
45
|
-
]),
|
|
46
|
-
Effect.runPromise,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
expect(result).to.contain('working');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Tool definitions.
|
|
53
|
-
class Toolkit extends AiToolkit.make(
|
|
54
|
-
AiTool.make('Calculator', {
|
|
55
|
-
description: 'Test tool',
|
|
56
|
-
parameters: {
|
|
57
|
-
input: Schema.String.annotations({
|
|
58
|
-
description: 'The calculation to perform.',
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
|
-
success: Schema.Struct({
|
|
62
|
-
result: Schema.Number,
|
|
63
|
-
}),
|
|
64
|
-
failure: Schema.Never,
|
|
65
|
-
}),
|
|
66
|
-
) {}
|
|
67
|
-
|
|
68
|
-
// Tool handlers.
|
|
69
|
-
const ToolkitLayer = Toolkit.toLayer({
|
|
70
|
-
Calculator: ({ input }) =>
|
|
71
|
-
Effect.gen(function* () {
|
|
72
|
-
const result = (() => {
|
|
73
|
-
// Only allow basic arithmetic operations for safety.
|
|
74
|
-
const sanitizedInput = input.replace(/[^0-9+\-*/().\s]/g, '');
|
|
75
|
-
// eslint-disable-next-line no-new-func
|
|
76
|
-
return Function(`"use strict"; return (${sanitizedInput})`)();
|
|
77
|
-
})();
|
|
78
|
-
|
|
79
|
-
yield* Console.log(`Executing calculation: ${input} = ${result}`);
|
|
80
|
-
return { result };
|
|
81
|
-
}),
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Providers.
|
|
85
|
-
const OpenAiLayer = OpenAiClient.layerConfig({
|
|
86
|
-
apiKey: Config.redacted('OPENAI_API_KEY'),
|
|
87
|
-
}).pipe(Layer.provide(NodeHttpClient.layerUndici));
|
|
88
|
-
|
|
89
|
-
const AnthropicLayer = AnthropicClient.layerConfig({
|
|
90
|
-
apiKey: Config.redacted('ANTHROPIC_API_KEY'),
|
|
91
|
-
}).pipe(Layer.provide(NodeHttpClient.layerUndici));
|
|
92
|
-
|
|
93
|
-
it.runIf(process.env.OPENAI_API_KEY)('should make a tool call', async ({ expect }) => {
|
|
94
|
-
const createProgram = (prompt: string) =>
|
|
95
|
-
AiLanguageModel.generateText({
|
|
96
|
-
toolkit: Toolkit,
|
|
97
|
-
prompt,
|
|
98
|
-
}).pipe(
|
|
99
|
-
Effect.tap((response) => Console.log(response)),
|
|
100
|
-
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
101
|
-
Effect.retry(pipe(Schedule.exponential('1 second'), Schedule.intersect(Schedule.recurs(2)))),
|
|
102
|
-
Effect.timeout('30 seconds'),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const program = createProgram('What is six times seven? Use appropriate tools and just answer with the number.');
|
|
106
|
-
const result = await program.pipe(Effect.provide([ToolkitLayer, OpenAiLayer]), Effect.runPromise);
|
|
107
|
-
expect(result).toBeDefined();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// TODO(burdon): Is this the effectful way to do this?
|
|
111
|
-
const createChat = (prompt: string) =>
|
|
112
|
-
Effect.gen(function* () {
|
|
113
|
-
const chat = yield* AiChat.empty;
|
|
114
|
-
const toolkit = yield* Toolkit;
|
|
115
|
-
|
|
116
|
-
// Initial request.
|
|
117
|
-
let response = yield* chat.generateText({ toolkit, prompt });
|
|
118
|
-
|
|
119
|
-
// Agentic loop.
|
|
120
|
-
while (response.results.size > 0) {
|
|
121
|
-
response = yield* chat.generateText({ toolkit, prompt: AiInput.empty });
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Done.
|
|
125
|
-
return response.text;
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it.runIf(process.env.OPENAI_API_KEY)('should process an agentic loop using OpenAI', async ({ expect }) => {
|
|
129
|
-
const chat = createChat('What is six times seven?');
|
|
130
|
-
const result = await chat.pipe(
|
|
131
|
-
Effect.provide(OpenAiLanguageModel.model('gpt-4o')),
|
|
132
|
-
Effect.provide(OpenAiLayer),
|
|
133
|
-
Effect.provide(ToolkitLayer),
|
|
134
|
-
Effect.runPromise,
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
log.info('result', { result });
|
|
138
|
-
expect(result).toContain('42');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// TODO(burdon): Fix Anthropic.
|
|
142
|
-
it.runIf(process.env.ANTHROPIC_API_KEY).skip('should process an agentic loop using Anthropic', async ({ expect }) => {
|
|
143
|
-
const chat = createChat('What is six times seven?');
|
|
144
|
-
const result = await chat.pipe(
|
|
145
|
-
Effect.provide(AnthropicLanguageModel.model('claude-3-5-sonnet-latest')),
|
|
146
|
-
Effect.provide(AnthropicLayer),
|
|
147
|
-
Effect.provide(ToolkitLayer),
|
|
148
|
-
Effect.runPromise,
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
log.info('result', { result });
|
|
152
|
-
expect(result).toContain('42');
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// TODO(burdon): Implement MCP server for ECHO on CF.
|
|
156
|
-
});
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
import { describe, test } from 'vitest';
|
|
7
|
-
|
|
8
|
-
import { EdgeAiServiceClient, ToolRegistry, ToolResult, createTool } from '@dxos/ai';
|
|
9
|
-
import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
|
|
10
|
-
import { ArtifactId } from '@dxos/artifact';
|
|
11
|
-
import { Obj } from '@dxos/echo';
|
|
12
|
-
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
13
|
-
import { DataType, DataTypes } from '@dxos/schema';
|
|
14
|
-
|
|
15
|
-
import { BlueprintBuilder } from './blueprint';
|
|
16
|
-
import { setConsolePrinter } from './logger';
|
|
17
|
-
import { BlueprintMachine } from './machine';
|
|
18
|
-
import { TEST_EMAILS } from './test-data';
|
|
19
|
-
import { createGraphWriterTool, createLocalSearchTool } from '../research';
|
|
20
|
-
import { createExaTool } from '../research/exa';
|
|
21
|
-
|
|
22
|
-
// TODO(burdon): Conslidate with existing artifact definition and create JSON DSL.
|
|
23
|
-
|
|
24
|
-
// TODO(burdon): Don't run on CI.
|
|
25
|
-
describe.skip('Blueprint', () => {
|
|
26
|
-
const aiClient = new EdgeAiServiceClient({
|
|
27
|
-
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
28
|
-
defaultGenerationOptions: {
|
|
29
|
-
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
30
|
-
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('follows a simple blueprint', { timeout: 60_000 }, async () => {
|
|
35
|
-
const blueprint = BlueprintBuilder.create()
|
|
36
|
-
.step('Generate an idea for a new product. Do not use any external tools for this.')
|
|
37
|
-
.step('Write a short description of the product.')
|
|
38
|
-
.step('Run a market research to see if the product is viable. Do not use any external tools for this.')
|
|
39
|
-
.step('Write a pitch deck for the product')
|
|
40
|
-
.build();
|
|
41
|
-
|
|
42
|
-
const tools = new ToolRegistry([]);
|
|
43
|
-
const machine = new BlueprintMachine(tools, blueprint);
|
|
44
|
-
setConsolePrinter(machine, true);
|
|
45
|
-
await machine.runToCompletion({ aiClient });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('email bot', { timeout: 60_000 }, async () => {
|
|
49
|
-
const replyTool = createTool('email', {
|
|
50
|
-
name: 'reply',
|
|
51
|
-
description: 'Reply to the email',
|
|
52
|
-
schema: Schema.Struct({
|
|
53
|
-
toEmail: ArtifactId,
|
|
54
|
-
subject: Schema.String.annotations({
|
|
55
|
-
description: 'The subject of the reply',
|
|
56
|
-
}),
|
|
57
|
-
body: Schema.String.annotations({
|
|
58
|
-
description: 'The body of the reply',
|
|
59
|
-
}),
|
|
60
|
-
}),
|
|
61
|
-
execute: async (params) => {
|
|
62
|
-
console.log('reply', params);
|
|
63
|
-
return ToolResult.Success('Sent!');
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const labelTool = createTool('email', {
|
|
68
|
-
name: 'label',
|
|
69
|
-
description: 'Apply a label to the email',
|
|
70
|
-
schema: Schema.Struct({
|
|
71
|
-
toEmail: ArtifactId,
|
|
72
|
-
label: Schema.String.annotations({
|
|
73
|
-
description: 'The label to apply to the email',
|
|
74
|
-
}),
|
|
75
|
-
}),
|
|
76
|
-
execute: async (params) => {
|
|
77
|
-
return ToolResult.Success('Labeled!');
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const blueprint = BlueprintBuilder.create()
|
|
82
|
-
.step(
|
|
83
|
-
'Determine if the email is introduction, question, or spam. Bail if email does not fit into one of these categories.',
|
|
84
|
-
)
|
|
85
|
-
.step('If the email is spam, label it as spam and do not respond.', {
|
|
86
|
-
tools: [labelTool.id],
|
|
87
|
-
})
|
|
88
|
-
.step(
|
|
89
|
-
'If the email is an introduction, respond with a short introduction of yourself and ask for more information.',
|
|
90
|
-
{
|
|
91
|
-
tools: [replyTool.id],
|
|
92
|
-
},
|
|
93
|
-
)
|
|
94
|
-
.step('If the email is a question, respond with a short answer and ask for more information.', {
|
|
95
|
-
tools: [replyTool.id],
|
|
96
|
-
})
|
|
97
|
-
.build();
|
|
98
|
-
|
|
99
|
-
const tools = new ToolRegistry([replyTool, labelTool]);
|
|
100
|
-
const machine = new BlueprintMachine(tools, blueprint);
|
|
101
|
-
setConsolePrinter(machine);
|
|
102
|
-
await machine.runToCompletion({ aiClient, input: TEST_EMAILS[0] });
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test.only('research', { timeout: 120_000 }, async () => {
|
|
106
|
-
const builder = await new EchoTestBuilder().open();
|
|
107
|
-
const { db } = await builder.createDatabase({ indexing: { vector: true }, types: DataTypes });
|
|
108
|
-
|
|
109
|
-
const [org1] = [
|
|
110
|
-
db.add(
|
|
111
|
-
Obj.make(DataType.Organization, {
|
|
112
|
-
name: 'Exa',
|
|
113
|
-
website: 'https://exa.ai',
|
|
114
|
-
description: 'An AI-powered search engine company building search infrastructure for AI agents',
|
|
115
|
-
}),
|
|
116
|
-
),
|
|
117
|
-
db.add(
|
|
118
|
-
Obj.make(DataType.Organization, {
|
|
119
|
-
name: 'Cresta',
|
|
120
|
-
website: 'https://cresta.ai',
|
|
121
|
-
description: 'A company that builds AI agents',
|
|
122
|
-
}),
|
|
123
|
-
),
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
await db.flush({ indexes: true });
|
|
127
|
-
|
|
128
|
-
const [exa, localSearch, graphWriter] = [
|
|
129
|
-
createExaTool({ apiKey: EXA_API_KEY }),
|
|
130
|
-
createLocalSearchTool(db),
|
|
131
|
-
createGraphWriterTool({ db, schema: DataTypes }),
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
const blueprint = BlueprintBuilder.create()
|
|
135
|
-
.step('Research founders of the organization. Do deep research.', {
|
|
136
|
-
tools: [exa.id],
|
|
137
|
-
})
|
|
138
|
-
.step('Based on your research select matching entires that are already in the graph', {
|
|
139
|
-
tools: [localSearch.id],
|
|
140
|
-
})
|
|
141
|
-
.step('Add researched data to the graph', {
|
|
142
|
-
tools: [localSearch.id, graphWriter.id],
|
|
143
|
-
})
|
|
144
|
-
.build();
|
|
145
|
-
|
|
146
|
-
const tools = new ToolRegistry([exa, localSearch, graphWriter]);
|
|
147
|
-
const machine = new BlueprintMachine(tools, blueprint);
|
|
148
|
-
setConsolePrinter(machine, true);
|
|
149
|
-
await machine.runToCompletion({ aiClient, input: org1 });
|
|
150
|
-
});
|
|
151
|
-
});
|