@alexein/sdk 0.3.3 → 0.3.5
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/CHANGELOG.md +18 -0
- package/README.md +88 -5
- package/dist/ai-sdk.cjs +77 -0
- package/dist/ai-sdk.d.cts +42 -0
- package/dist/ai-sdk.d.ts +42 -0
- package/dist/ai-sdk.js +77 -0
- package/dist/{chunk-HDNKPJS2.js → chunk-C3LLPVOJ.js} +1 -1
- package/dist/chunk-DCKT6Y5B.cjs +378 -0
- package/dist/chunk-EGH35T3L.js +378 -0
- package/dist/{chunk-5YIOYX3J.js → chunk-NFVCTK7P.js} +7 -5
- package/dist/{chunk-LWBADF3F.cjs → chunk-NKBLBBGO.cjs} +4 -4
- package/dist/{chunk-34W2JJVD.cjs → chunk-WMDI4HIS.cjs} +8 -6
- package/dist/{client-Bz10lVYG.d.cts → client-76Fz2eLa.d.cts} +9 -4
- package/dist/{client-Bz10lVYG.d.ts → client-76Fz2eLa.d.ts} +9 -4
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/langgraph.cjs +15 -15
- package/dist/langgraph.d.cts +1 -1
- package/dist/langgraph.d.ts +1 -1
- package/dist/langgraph.js +2 -2
- package/dist/memory-2Gq9Fx9Z.d.cts +101 -0
- package/dist/memory-5OvV_41Q.d.ts +101 -0
- package/dist/openai-agents.cjs +18 -18
- package/dist/openai-agents.d.cts +1 -1
- package/dist/openai-agents.d.ts +1 -1
- package/dist/openai-agents.js +2 -2
- package/dist/wrap.cjs +318 -0
- package/dist/wrap.d.cts +59 -0
- package/dist/wrap.d.ts +59 -0
- package/dist/wrap.js +318 -0
- package/package.json +39 -2
package/dist/langgraph.cjs
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkNKBLBBGOcjs = require('./chunk-NKBLBBGO.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkWMDI4HIScjs = require('./chunk-WMDI4HIS.cjs');
|
|
19
19
|
|
|
20
20
|
// src/langgraph/index.ts
|
|
21
21
|
var _messages = require('@langchain/core/messages');
|
|
@@ -58,12 +58,12 @@ var AlexeinMemory = (_class = class {
|
|
|
58
58
|
#client;
|
|
59
59
|
/** `client` defaults to one made on first use: fail-open unless strict, a 10 s timeout. */
|
|
60
60
|
constructor(client, options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
|
|
61
|
-
const given =
|
|
62
|
-
const settings =
|
|
61
|
+
const given = _chunkNKBLBBGOcjs.isClient.call(void 0, client) ? client : void 0;
|
|
62
|
+
const settings = _chunkNKBLBBGOcjs.isClient.call(void 0, client) ? options : { ...client, ...options };
|
|
63
63
|
this.fast = _nullishCoalesce(settings.fast, () => ( false));
|
|
64
64
|
this.maxChars = _nullishCoalesce(settings.maxChars, () => ( 4e3));
|
|
65
65
|
this.strict = _nullishCoalesce(settings.strict, () => ( false));
|
|
66
|
-
this.#client = new (0,
|
|
66
|
+
this.#client = new (0, _chunkNKBLBBGOcjs.LazyClient)(given, "langgraph", this.strict, settings.timeout);
|
|
67
67
|
}
|
|
68
68
|
get client() {
|
|
69
69
|
return this.#client.client;
|
|
@@ -76,7 +76,7 @@ var AlexeinMemory = (_class = class {
|
|
|
76
76
|
const asked = _optionalChain([lastHuman, 'call', _16 => _16(state.messages), 'optionalAccess', _17 => _17.text, 'access', _18 => _18.trim, 'call', _19 => _19()]);
|
|
77
77
|
const user = this.user(config);
|
|
78
78
|
if (!asked) return { memory: "" };
|
|
79
|
-
const found = await
|
|
79
|
+
const found = await _chunkNKBLBBGOcjs.searchFor.call(void 0, user, asked, this.fast);
|
|
80
80
|
return { memory: _nullishCoalesce(_optionalChain([found, 'optionalAccess', _20 => _20.context, 'call', _21 => _21(this.maxChars)]), () => ( "")) };
|
|
81
81
|
}}
|
|
82
82
|
/**
|
|
@@ -96,7 +96,7 @@ var AlexeinMemory = (_class = class {
|
|
|
96
96
|
return {};
|
|
97
97
|
}}
|
|
98
98
|
/** What `recall` found, as a block for your system prompt; empty when it found nothing. */
|
|
99
|
-
__init3() {this.prompt = (state) =>
|
|
99
|
+
__init3() {this.prompt = (state) => _chunkNKBLBBGOcjs.promptBlock.call(void 0, _nullishCoalesce(state.memory, () => ( "")))}
|
|
100
100
|
/**
|
|
101
101
|
* Tools the model calls when it decides to: `memory_search` and `memory_open`, and with
|
|
102
102
|
* `write`, `memory_add`. The user comes from the run, which a model never sees.
|
|
@@ -108,8 +108,8 @@ var AlexeinMemory = (_class = class {
|
|
|
108
108
|
searchTool() {
|
|
109
109
|
return _tools.tool.call(void 0,
|
|
110
110
|
async ({ query }, config) => {
|
|
111
|
-
const found = await
|
|
112
|
-
return
|
|
111
|
+
const found = await _chunkNKBLBBGOcjs.searchFor.call(void 0, this.user(config), query, this.fast);
|
|
112
|
+
return _chunkNKBLBBGOcjs.searchAnswer.call(void 0, found, this.maxChars);
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
name: "memory_search",
|
|
@@ -123,10 +123,10 @@ var AlexeinMemory = (_class = class {
|
|
|
123
123
|
async ({ ref }, config) => {
|
|
124
124
|
const user = this.user(config);
|
|
125
125
|
try {
|
|
126
|
-
return
|
|
126
|
+
return _chunkNKBLBBGOcjs.openAnswer.call(void 0, await user.open(ref));
|
|
127
127
|
} catch (error) {
|
|
128
|
-
if (error instanceof
|
|
129
|
-
return
|
|
128
|
+
if (error instanceof _chunkWMDI4HIScjs.NotFoundError) return _chunkNKBLBBGOcjs.notFoundAnswer.call(void 0, error);
|
|
129
|
+
return _chunkNKBLBBGOcjs.outageAnswer.call(void 0, error, this.strict);
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
{
|
|
@@ -143,7 +143,7 @@ var AlexeinMemory = (_class = class {
|
|
|
143
143
|
kind: "note",
|
|
144
144
|
session: threadOf(config)
|
|
145
145
|
});
|
|
146
|
-
return saved.failed ?
|
|
146
|
+
return saved.failed ? _chunkNKBLBBGOcjs.UNAVAILABLE : _chunkNKBLBBGOcjs.SAVED;
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
name: "memory_add",
|
|
@@ -156,7 +156,7 @@ var AlexeinMemory = (_class = class {
|
|
|
156
156
|
async function item(message, role, thread) {
|
|
157
157
|
const text = _optionalChain([message, 'optionalAccess', _22 => _22.text]);
|
|
158
158
|
if (!_optionalChain([text, 'optionalAccess', _23 => _23.trim, 'call', _24 => _24()])) return void 0;
|
|
159
|
-
const id = await _asyncNullishCoalesce(await _asyncOptionalChain([message, 'optionalAccess', async _25 => _25.id]), async () => ( await
|
|
159
|
+
const id = await _asyncNullishCoalesce(await _asyncOptionalChain([message, 'optionalAccess', async _25 => _25.id]), async () => ( await _chunkNKBLBBGOcjs.stableId.call(void 0, thread, role, text)));
|
|
160
160
|
return { id, role, text };
|
|
161
161
|
}
|
|
162
162
|
var fallback;
|
|
@@ -182,4 +182,4 @@ var memoryTools = (options = {}) => defaultMemory().tools(options);
|
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
|
|
185
|
-
exports.AlexeinMemory = AlexeinMemory; exports.MemoryAnnotation = MemoryAnnotation; exports.MemoryContext = MemoryContext; exports.MemoryState = MemoryState; exports.NOTHING_FOUND =
|
|
185
|
+
exports.AlexeinMemory = AlexeinMemory; exports.MemoryAnnotation = MemoryAnnotation; exports.MemoryContext = MemoryContext; exports.MemoryState = MemoryState; exports.NOTHING_FOUND = _chunkNKBLBBGOcjs.NOTHING_FOUND; exports.NOTHING_YET = _chunkNKBLBBGOcjs.NOTHING_YET; exports.UNAVAILABLE = _chunkNKBLBBGOcjs.UNAVAILABLE; exports.defaultMemory = defaultMemory; exports.memoryPrompt = memoryPrompt; exports.memoryTools = memoryTools; exports.recall = recall; exports.remember = remember; exports.userIdOf = userIdOf;
|
package/dist/langgraph.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _langchain_langgraph from '@langchain/langgraph';
|
|
|
4
4
|
import { StateSchema } from '@langchain/langgraph';
|
|
5
5
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import {
|
|
7
|
+
import { M as Memory } from './client-76Fz2eLa.cjs';
|
|
8
8
|
import { I as IntegrationOptions } from './shared-Btg8LbKC.cjs';
|
|
9
9
|
export { N as NOTHING_FOUND, a as NOTHING_YET, U as UNAVAILABLE } from './shared-Btg8LbKC.cjs';
|
|
10
10
|
|
package/dist/langgraph.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _langchain_langgraph from '@langchain/langgraph';
|
|
|
4
4
|
import { StateSchema } from '@langchain/langgraph';
|
|
5
5
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import {
|
|
7
|
+
import { M as Memory } from './client-76Fz2eLa.js';
|
|
8
8
|
import { I as IntegrationOptions } from './shared-Btg8LbKC.js';
|
|
9
9
|
export { N as NOTHING_FOUND, a as NOTHING_YET, U as UNAVAILABLE } from './shared-Btg8LbKC.js';
|
|
10
10
|
|
package/dist/langgraph.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
searchAnswer,
|
|
13
13
|
searchFor,
|
|
14
14
|
stableId
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-C3LLPVOJ.js";
|
|
16
16
|
import {
|
|
17
17
|
NotFoundError
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NFVCTK7P.js";
|
|
19
19
|
|
|
20
20
|
// src/langgraph/index.ts
|
|
21
21
|
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { M as Memory, e as Author, I as Item, Z as SearchResult } from './client-76Fz2eLa.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the model-client wrappers and the AI SDK middleware share: one app user's memory as a
|
|
5
|
+
* wrapped model uses it - one lookup before each call, within a time budget, and the exchange
|
|
6
|
+
* saved after it - and the block of memory a system prompt is given. Built on the client alone.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** What the model is told about the memory block, above it. */
|
|
10
|
+
declare const HEADER: string;
|
|
11
|
+
/** What memory adds and saves around each model call. Every field is optional but `userId`. */
|
|
12
|
+
interface AutoMemoryOptions {
|
|
13
|
+
/** Your id for the app user whose memory this is. Never taken from a model or a request body. */
|
|
14
|
+
userId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The conversation: what is saved is grouped under it, and a retried call edits what it saved
|
|
17
|
+
* rather than copying it.
|
|
18
|
+
*/
|
|
19
|
+
session?: string;
|
|
20
|
+
/** Who the user is (`{ name, id }`); what they say is saved as theirs. */
|
|
21
|
+
author?: Author;
|
|
22
|
+
/** Look memory up before each call. Default true. */
|
|
23
|
+
recall?: boolean;
|
|
24
|
+
/** Save the user's message and the reply after each call. Default true. */
|
|
25
|
+
save?: boolean;
|
|
26
|
+
/** The longest a call waits for memory, in milliseconds. Default 1500. */
|
|
27
|
+
budget?: number;
|
|
28
|
+
/** About how many tokens of memory a call is given at most. Default 600. */
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Skip search's relevance check: quicker, a little less precise. Default true. With `false`,
|
|
32
|
+
* what memory judges not to hold the answer is left out, and a search takes longer: raise
|
|
33
|
+
* `budget` with it.
|
|
34
|
+
*/
|
|
35
|
+
fast?: boolean;
|
|
36
|
+
/** Replace phone numbers, cards, keys and the like before memory keeps any copy. */
|
|
37
|
+
redact?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Sees the items about to be saved and answers those to save: changed, fewer, or none (an
|
|
40
|
+
* empty list, null or undefined saves nothing).
|
|
41
|
+
*/
|
|
42
|
+
beforeSave?: (items: Item[]) => Item[] | null | undefined | Promise<Item[] | null | undefined>;
|
|
43
|
+
}
|
|
44
|
+
/** How the last lookup before a call went, for your metrics. */
|
|
45
|
+
interface RecallInfo {
|
|
46
|
+
/** Milliseconds the call waited. */
|
|
47
|
+
readonly ms: number;
|
|
48
|
+
/** Characters it added to the system prompt. */
|
|
49
|
+
readonly chars: number;
|
|
50
|
+
readonly timedOut: boolean;
|
|
51
|
+
readonly failed: boolean;
|
|
52
|
+
/** Served from an earlier call for the same message (a tool loop's next step). */
|
|
53
|
+
readonly reused: boolean;
|
|
54
|
+
/** Nothing was looked up: recall is off, or the call holds no message from the user. */
|
|
55
|
+
readonly skipped: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** The user's latest words in a call, the reply before them, and where they sit. */
|
|
58
|
+
interface Asked {
|
|
59
|
+
readonly text: string;
|
|
60
|
+
readonly before: string;
|
|
61
|
+
readonly at: number;
|
|
62
|
+
}
|
|
63
|
+
/** What a model answered: its words, and whether it is the turn's last answer. */
|
|
64
|
+
declare class Reply {
|
|
65
|
+
parts: string[];
|
|
66
|
+
callsTool: boolean;
|
|
67
|
+
done: boolean;
|
|
68
|
+
get text(): string;
|
|
69
|
+
get final(): boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* What `found` adds to a system prompt: the header, then its memories inside `<memory>`, one a
|
|
73
|
+
* line with when and by whom, at most four, cut at a whole memory within `maxTokens`. With
|
|
74
|
+
* `gated`, without the lines memory lists after the excerpts. Empty when nothing is left.
|
|
75
|
+
*/
|
|
76
|
+
declare function memoryBlock(found: SearchResult, maxTokens: number, gated?: boolean): string;
|
|
77
|
+
/**
|
|
78
|
+
* One app user's memory as a wrapped model uses it. `memoryOf(client)` answers it, for `last`
|
|
79
|
+
* and `flush()`.
|
|
80
|
+
*/
|
|
81
|
+
declare class AutoMemory {
|
|
82
|
+
#private;
|
|
83
|
+
readonly userId: string;
|
|
84
|
+
/** How the last lookup went; null before the first. */
|
|
85
|
+
last: RecallInfo | null;
|
|
86
|
+
constructor(memory: Memory | undefined, options: AutoMemoryOptions);
|
|
87
|
+
/**
|
|
88
|
+
* What memory adds to the system prompt for `asked`, within `budget` milliseconds; "" when it
|
|
89
|
+
* has nothing that bears on it, is down, or is late. Never throws.
|
|
90
|
+
*/
|
|
91
|
+
lookup(asked: Asked | null): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Save the user's message and the turn's final reply, in the background, the hook included: it
|
|
94
|
+
* never delays the call or throws. `flush()` waits for it.
|
|
95
|
+
*/
|
|
96
|
+
remember(asked: Asked | null, reply: Reply): void;
|
|
97
|
+
/** Wait for the saves still on their way: before a short-lived process or a serverless call ends. */
|
|
98
|
+
flush(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { AutoMemory as A, HEADER as H, type RecallInfo as R, type AutoMemoryOptions as a, memoryBlock as m };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { M as Memory, e as Author, I as Item, Z as SearchResult } from './client-76Fz2eLa.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the model-client wrappers and the AI SDK middleware share: one app user's memory as a
|
|
5
|
+
* wrapped model uses it - one lookup before each call, within a time budget, and the exchange
|
|
6
|
+
* saved after it - and the block of memory a system prompt is given. Built on the client alone.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** What the model is told about the memory block, above it. */
|
|
10
|
+
declare const HEADER: string;
|
|
11
|
+
/** What memory adds and saves around each model call. Every field is optional but `userId`. */
|
|
12
|
+
interface AutoMemoryOptions {
|
|
13
|
+
/** Your id for the app user whose memory this is. Never taken from a model or a request body. */
|
|
14
|
+
userId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The conversation: what is saved is grouped under it, and a retried call edits what it saved
|
|
17
|
+
* rather than copying it.
|
|
18
|
+
*/
|
|
19
|
+
session?: string;
|
|
20
|
+
/** Who the user is (`{ name, id }`); what they say is saved as theirs. */
|
|
21
|
+
author?: Author;
|
|
22
|
+
/** Look memory up before each call. Default true. */
|
|
23
|
+
recall?: boolean;
|
|
24
|
+
/** Save the user's message and the reply after each call. Default true. */
|
|
25
|
+
save?: boolean;
|
|
26
|
+
/** The longest a call waits for memory, in milliseconds. Default 1500. */
|
|
27
|
+
budget?: number;
|
|
28
|
+
/** About how many tokens of memory a call is given at most. Default 600. */
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Skip search's relevance check: quicker, a little less precise. Default true. With `false`,
|
|
32
|
+
* what memory judges not to hold the answer is left out, and a search takes longer: raise
|
|
33
|
+
* `budget` with it.
|
|
34
|
+
*/
|
|
35
|
+
fast?: boolean;
|
|
36
|
+
/** Replace phone numbers, cards, keys and the like before memory keeps any copy. */
|
|
37
|
+
redact?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Sees the items about to be saved and answers those to save: changed, fewer, or none (an
|
|
40
|
+
* empty list, null or undefined saves nothing).
|
|
41
|
+
*/
|
|
42
|
+
beforeSave?: (items: Item[]) => Item[] | null | undefined | Promise<Item[] | null | undefined>;
|
|
43
|
+
}
|
|
44
|
+
/** How the last lookup before a call went, for your metrics. */
|
|
45
|
+
interface RecallInfo {
|
|
46
|
+
/** Milliseconds the call waited. */
|
|
47
|
+
readonly ms: number;
|
|
48
|
+
/** Characters it added to the system prompt. */
|
|
49
|
+
readonly chars: number;
|
|
50
|
+
readonly timedOut: boolean;
|
|
51
|
+
readonly failed: boolean;
|
|
52
|
+
/** Served from an earlier call for the same message (a tool loop's next step). */
|
|
53
|
+
readonly reused: boolean;
|
|
54
|
+
/** Nothing was looked up: recall is off, or the call holds no message from the user. */
|
|
55
|
+
readonly skipped: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** The user's latest words in a call, the reply before them, and where they sit. */
|
|
58
|
+
interface Asked {
|
|
59
|
+
readonly text: string;
|
|
60
|
+
readonly before: string;
|
|
61
|
+
readonly at: number;
|
|
62
|
+
}
|
|
63
|
+
/** What a model answered: its words, and whether it is the turn's last answer. */
|
|
64
|
+
declare class Reply {
|
|
65
|
+
parts: string[];
|
|
66
|
+
callsTool: boolean;
|
|
67
|
+
done: boolean;
|
|
68
|
+
get text(): string;
|
|
69
|
+
get final(): boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* What `found` adds to a system prompt: the header, then its memories inside `<memory>`, one a
|
|
73
|
+
* line with when and by whom, at most four, cut at a whole memory within `maxTokens`. With
|
|
74
|
+
* `gated`, without the lines memory lists after the excerpts. Empty when nothing is left.
|
|
75
|
+
*/
|
|
76
|
+
declare function memoryBlock(found: SearchResult, maxTokens: number, gated?: boolean): string;
|
|
77
|
+
/**
|
|
78
|
+
* One app user's memory as a wrapped model uses it. `memoryOf(client)` answers it, for `last`
|
|
79
|
+
* and `flush()`.
|
|
80
|
+
*/
|
|
81
|
+
declare class AutoMemory {
|
|
82
|
+
#private;
|
|
83
|
+
readonly userId: string;
|
|
84
|
+
/** How the last lookup went; null before the first. */
|
|
85
|
+
last: RecallInfo | null;
|
|
86
|
+
constructor(memory: Memory | undefined, options: AutoMemoryOptions);
|
|
87
|
+
/**
|
|
88
|
+
* What memory adds to the system prompt for `asked`, within `budget` milliseconds; "" when it
|
|
89
|
+
* has nothing that bears on it, is down, or is late. Never throws.
|
|
90
|
+
*/
|
|
91
|
+
lookup(asked: Asked | null): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Save the user's message and the turn's final reply, in the background, the hook included: it
|
|
94
|
+
* never delays the call or throws. `flush()` waits for it.
|
|
95
|
+
*/
|
|
96
|
+
remember(asked: Asked | null, reply: Reply): void;
|
|
97
|
+
/** Wait for the saves still on their way: before a short-lived process or a serverless call ends. */
|
|
98
|
+
flush(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { AutoMemory as A, HEADER as H, type RecallInfo as R, type AutoMemoryOptions as a, memoryBlock as m };
|
package/dist/openai-agents.cjs
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkNKBLBBGOcjs = require('./chunk-NKBLBBGO.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkWMDI4HIScjs = require('./chunk-WMDI4HIS.cjs');
|
|
21
21
|
|
|
22
22
|
// src/openai-agents/run.ts
|
|
23
23
|
function userIdOf(context) {
|
|
@@ -53,7 +53,7 @@ function answer(output) {
|
|
|
53
53
|
}
|
|
54
54
|
async function item(said, role, turn, author) {
|
|
55
55
|
if (!said.trim()) return void 0;
|
|
56
|
-
const id = await
|
|
56
|
+
const id = await _chunkNKBLBBGOcjs.stableId.call(void 0, turn, role, said);
|
|
57
57
|
return { id, role, text: said, ...author ? { author } : {} };
|
|
58
58
|
}
|
|
59
59
|
async function turnItems(result, session) {
|
|
@@ -73,13 +73,13 @@ var _agents = require('@openai/agents');
|
|
|
73
73
|
var _zod = require('zod');
|
|
74
74
|
function failed(strict) {
|
|
75
75
|
return (run, error) => {
|
|
76
|
-
const yours = error instanceof
|
|
77
|
-
const outage = error instanceof
|
|
76
|
+
const yours = error instanceof _chunkWMDI4HIScjs.AuthenticationError || error instanceof _chunkWMDI4HIScjs.PermissionDeniedError;
|
|
77
|
+
const outage = error instanceof _chunkWMDI4HIScjs.AlexeinError && error.outage;
|
|
78
78
|
const noUser = !_optionalChain([run, 'access', _5 => _5.context, 'optionalAccess', _6 => _6.userId]);
|
|
79
79
|
if (yours || noUser || strict && outage) throw error;
|
|
80
80
|
if (outage) {
|
|
81
81
|
console.warn(`Alexein is unavailable: ${error.message}`);
|
|
82
|
-
return
|
|
82
|
+
return _chunkNKBLBBGOcjs.UNAVAILABLE;
|
|
83
83
|
}
|
|
84
84
|
return `That did not work: ${error instanceof Error ? error.message : String(error)}`;
|
|
85
85
|
};
|
|
@@ -92,8 +92,8 @@ function buildTools(memory, write) {
|
|
|
92
92
|
parameters: _zod.z.object({ query: _zod.z.string().describe("What to look for") }),
|
|
93
93
|
errorFunction,
|
|
94
94
|
async execute({ query }, run) {
|
|
95
|
-
const found = await
|
|
96
|
-
return
|
|
95
|
+
const found = await _chunkNKBLBBGOcjs.searchFor.call(void 0, memory.userOf(_optionalChain([run, 'optionalAccess', _7 => _7.context])), query, memory.fast);
|
|
96
|
+
return _chunkNKBLBBGOcjs.searchAnswer.call(void 0, found, memory.maxChars);
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
const open = _agents.tool.call(void 0, {
|
|
@@ -103,10 +103,10 @@ function buildTools(memory, write) {
|
|
|
103
103
|
errorFunction,
|
|
104
104
|
async execute({ ref }, run) {
|
|
105
105
|
try {
|
|
106
|
-
return
|
|
106
|
+
return _chunkNKBLBBGOcjs.openAnswer.call(void 0, await memory.userOf(_optionalChain([run, 'optionalAccess', _8 => _8.context])).open(ref));
|
|
107
107
|
} catch (error) {
|
|
108
|
-
if (!(error instanceof
|
|
109
|
-
return
|
|
108
|
+
if (!(error instanceof _chunkWMDI4HIScjs.NotFoundError)) throw error;
|
|
109
|
+
return _chunkNKBLBBGOcjs.notFoundAnswer.call(void 0, error);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
});
|
|
@@ -120,7 +120,7 @@ function buildTools(memory, write) {
|
|
|
120
120
|
kind: "note",
|
|
121
121
|
session: sessionIdOf(_optionalChain([run, 'optionalAccess', _10 => _10.context]))
|
|
122
122
|
});
|
|
123
|
-
return saved.failed ?
|
|
123
|
+
return saved.failed ? _chunkNKBLBBGOcjs.UNAVAILABLE : _chunkNKBLBBGOcjs.SAVED;
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
return write ? [search, open, add] : [search, open];
|
|
@@ -149,12 +149,12 @@ var AlexeinMemory = (_class = class {
|
|
|
149
149
|
#recalled = /* @__PURE__ */ new WeakMap();
|
|
150
150
|
/** `client` defaults to one made on first use: fail-open unless strict, a 10 s timeout. */
|
|
151
151
|
constructor(client, options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
152
|
-
const given =
|
|
153
|
-
const settings =
|
|
152
|
+
const given = _chunkNKBLBBGOcjs.isClient.call(void 0, client) ? client : void 0;
|
|
153
|
+
const settings = _chunkNKBLBBGOcjs.isClient.call(void 0, client) ? options : { ...client, ...options };
|
|
154
154
|
this.fast = _nullishCoalesce(settings.fast, () => ( false));
|
|
155
155
|
this.maxChars = _nullishCoalesce(settings.maxChars, () => ( 4e3));
|
|
156
156
|
this.strict = _nullishCoalesce(settings.strict, () => ( false));
|
|
157
|
-
this.#client = new (0,
|
|
157
|
+
this.#client = new (0, _chunkNKBLBBGOcjs.LazyClient)(given, "openai-agents", this.strict, settings.timeout);
|
|
158
158
|
}
|
|
159
159
|
get client() {
|
|
160
160
|
return this.#client.client;
|
|
@@ -180,8 +180,8 @@ var AlexeinMemory = (_class = class {
|
|
|
180
180
|
question = said && textOf(said).trim();
|
|
181
181
|
}
|
|
182
182
|
if (question !== void 0) {
|
|
183
|
-
const found = question ? await
|
|
184
|
-
this.#recalled.set(run,
|
|
183
|
+
const found = question ? await _chunkNKBLBBGOcjs.searchFor.call(void 0, user, question, this.fast) : void 0;
|
|
184
|
+
this.#recalled.set(run, _chunkNKBLBBGOcjs.promptBlock.call(void 0, _nullishCoalesce(_optionalChain([found, 'optionalAccess', _17 => _17.context, 'call', _18 => _18(this.maxChars)]), () => ( ""))));
|
|
185
185
|
}
|
|
186
186
|
const block = this.#recalled.get(run);
|
|
187
187
|
if (!block) return modelData;
|
|
@@ -231,4 +231,4 @@ var memoryTools = (options = {}) => defaultMemory().tools(options);
|
|
|
231
231
|
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
exports.AlexeinMemory = AlexeinMemory; exports.NOTHING_FOUND =
|
|
234
|
+
exports.AlexeinMemory = AlexeinMemory; exports.NOTHING_FOUND = _chunkNKBLBBGOcjs.NOTHING_FOUND; exports.NOTHING_YET = _chunkNKBLBBGOcjs.NOTHING_YET; exports.UNAVAILABLE = _chunkNKBLBBGOcjs.UNAVAILABLE; exports.defaultMemory = defaultMemory; exports.memoryTools = memoryTools; exports.recall = recall; exports.remember = remember; exports.sessionIdOf = sessionIdOf; exports.userIdOf = userIdOf;
|
package/dist/openai-agents.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentInputItem, CallModelInputFilterArgs, ModelInputData, FunctionTool } from '@openai/agents';
|
|
2
|
-
import {
|
|
2
|
+
import { M as Memory, a4 as User } from './client-76Fz2eLa.cjs';
|
|
3
3
|
import { I as IntegrationOptions } from './shared-Btg8LbKC.cjs';
|
|
4
4
|
export { N as NOTHING_FOUND, a as NOTHING_YET, U as UNAVAILABLE } from './shared-Btg8LbKC.cjs';
|
|
5
5
|
|
package/dist/openai-agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentInputItem, CallModelInputFilterArgs, ModelInputData, FunctionTool } from '@openai/agents';
|
|
2
|
-
import {
|
|
2
|
+
import { M as Memory, a4 as User } from './client-76Fz2eLa.js';
|
|
3
3
|
import { I as IntegrationOptions } from './shared-Btg8LbKC.js';
|
|
4
4
|
export { N as NOTHING_FOUND, a as NOTHING_YET, U as UNAVAILABLE } from './shared-Btg8LbKC.js';
|
|
5
5
|
|
package/dist/openai-agents.js
CHANGED
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
searchAnswer,
|
|
12
12
|
searchFor,
|
|
13
13
|
stableId
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-C3LLPVOJ.js";
|
|
15
15
|
import {
|
|
16
16
|
AlexeinError,
|
|
17
17
|
AuthenticationError,
|
|
18
18
|
NotFoundError,
|
|
19
19
|
PermissionDeniedError
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-NFVCTK7P.js";
|
|
21
21
|
|
|
22
22
|
// src/openai-agents/run.ts
|
|
23
23
|
function userIdOf(context) {
|