@mondaydotcomorg/atp-runtime 0.17.14
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/README.md +389 -0
- package/dist/approval/handler.d.ts +12 -0
- package/dist/approval/handler.d.ts.map +1 -0
- package/dist/approval/handler.js +17 -0
- package/dist/approval/handler.js.map +1 -0
- package/dist/approval/index.d.ts +17 -0
- package/dist/approval/index.d.ts.map +1 -0
- package/dist/approval/index.js +94 -0
- package/dist/approval/index.js.map +1 -0
- package/dist/approval/types.d.ts +21 -0
- package/dist/approval/types.d.ts.map +1 -0
- package/dist/approval/types.js +5 -0
- package/dist/approval/types.js.map +1 -0
- package/dist/cache/backends.d.ts +39 -0
- package/dist/cache/backends.d.ts.map +1 -0
- package/dist/cache/backends.js +167 -0
- package/dist/cache/backends.js.map +1 -0
- package/dist/cache/index.d.ts +32 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +103 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types.d.ts +20 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +2 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/embedding/index.d.ts +39 -0
- package/dist/embedding/index.d.ts.map +1 -0
- package/dist/embedding/index.js +162 -0
- package/dist/embedding/index.js.map +1 -0
- package/dist/embedding/types.d.ts +28 -0
- package/dist/embedding/types.d.ts.map +1 -0
- package/dist/embedding/types.js +5 -0
- package/dist/embedding/types.js.map +1 -0
- package/dist/embedding/utils.d.ts +11 -0
- package/dist/embedding/utils.d.ts.map +1 -0
- package/dist/embedding/utils.js +30 -0
- package/dist/embedding/utils.js.map +1 -0
- package/dist/embedding/vector-store.d.ts +64 -0
- package/dist/embedding/vector-store.d.ts.map +1 -0
- package/dist/embedding/vector-store.js +142 -0
- package/dist/embedding/vector-store.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/callback.d.ts +13 -0
- package/dist/llm/callback.d.ts.map +1 -0
- package/dist/llm/callback.js +19 -0
- package/dist/llm/callback.js.map +1 -0
- package/dist/llm/index.d.ts +29 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +118 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/replay.d.ts +47 -0
- package/dist/llm/replay.d.ts.map +1 -0
- package/dist/llm/replay.js +114 -0
- package/dist/llm/replay.js.map +1 -0
- package/dist/llm/types.d.ts +24 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/log/index.d.ts +12 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/index.js +166 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/types.d.ts +19 -0
- package/dist/log/types.d.ts.map +1 -0
- package/dist/log/types.js +5 -0
- package/dist/log/types.js.map +1 -0
- package/dist/metadata/decorators.d.ts +27 -0
- package/dist/metadata/decorators.d.ts.map +1 -0
- package/dist/metadata/decorators.js +38 -0
- package/dist/metadata/decorators.js.map +1 -0
- package/dist/metadata/generated.d.ts +18 -0
- package/dist/metadata/generated.d.ts.map +1 -0
- package/dist/metadata/generated.js +290 -0
- package/dist/metadata/generated.js.map +1 -0
- package/dist/metadata/index.d.ts +11 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +45 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/metadata/types.d.ts +22 -0
- package/dist/metadata/types.d.ts.map +1 -0
- package/dist/metadata/types.js +6 -0
- package/dist/metadata/types.js.map +1 -0
- package/dist/pause/index.d.ts +11 -0
- package/dist/pause/index.d.ts.map +1 -0
- package/dist/pause/index.js +15 -0
- package/dist/pause/index.js.map +1 -0
- package/dist/pause/types.d.ts +46 -0
- package/dist/pause/types.d.ts.map +1 -0
- package/dist/pause/types.js +57 -0
- package/dist/pause/types.js.map +1 -0
- package/dist/progress/index.d.ts +19 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/index.js +61 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/types.d.ts +7 -0
- package/dist/progress/types.d.ts.map +1 -0
- package/dist/progress/types.js +2 -0
- package/dist/progress/types.js.map +1 -0
- package/dist/registry.d.ts +16 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +16 -0
- package/dist/registry.js.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +31 -0
- package/dist/utils.js.map +1 -0
- package/package.json +51 -0
- package/src/approval/handler.ts +26 -0
- package/src/approval/index.ts +95 -0
- package/src/approval/types.ts +23 -0
- package/src/cache/backends.ts +196 -0
- package/src/cache/index.ts +74 -0
- package/src/cache/types.ts +20 -0
- package/src/embedding/index.ts +153 -0
- package/src/embedding/types.ts +31 -0
- package/src/embedding/utils.ts +34 -0
- package/src/embedding/vector-store.ts +164 -0
- package/src/index.ts +35 -0
- package/src/llm/callback.ts +24 -0
- package/src/llm/index.ts +121 -0
- package/src/llm/replay.ts +141 -0
- package/src/llm/types.ts +29 -0
- package/src/log/index.ts +167 -0
- package/src/log/types.ts +21 -0
- package/src/metadata/decorators.ts +44 -0
- package/src/metadata/generated.ts +293 -0
- package/src/metadata/index.ts +61 -0
- package/src/metadata/types.ts +24 -0
- package/src/pause/index.ts +28 -0
- package/src/pause/types.ts +57 -0
- package/src/progress/index.ts +50 -0
- package/src/progress/types.ts +6 -0
- package/src/registry.ts +22 -0
- package/src/utils.ts +37 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/embedding/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc,EAAE,IAAc;IAC9D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QAClC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QAC7B,KAAK,IAAI,IAAI,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;IAC9B,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,UAAU,GAAG,WAAW,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB,CAAC;IACpD,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*/
|
|
3
|
+
import type { EmbeddingRecord, SearchOptions, SearchResult } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* In-memory vector store for the current execution
|
|
6
|
+
* Cleared after each execution completes
|
|
7
|
+
*/
|
|
8
|
+
export declare class VectorStore {
|
|
9
|
+
private records;
|
|
10
|
+
private queryEmbedding;
|
|
11
|
+
/**
|
|
12
|
+
* Store embeddings from client response
|
|
13
|
+
*/
|
|
14
|
+
store(id: string, text: string, embedding: number[], metadata?: Record<string, unknown>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Store multiple embeddings
|
|
17
|
+
*/
|
|
18
|
+
storeBatch(records: EmbeddingRecord[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Set the query embedding for search
|
|
21
|
+
*/
|
|
22
|
+
setQueryEmbedding(embedding: number[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Search stored embeddings by similarity to query
|
|
25
|
+
*/
|
|
26
|
+
search(options: SearchOptions): SearchResult[];
|
|
27
|
+
/**
|
|
28
|
+
* Get all stored embeddings
|
|
29
|
+
*/
|
|
30
|
+
getAll(): EmbeddingRecord[];
|
|
31
|
+
/**
|
|
32
|
+
* Get embedding by ID
|
|
33
|
+
*/
|
|
34
|
+
get(id: string): EmbeddingRecord | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Clear all stored embeddings
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get count of stored embeddings
|
|
41
|
+
*/
|
|
42
|
+
count(): number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Set the current execution ID for vector store operations
|
|
46
|
+
*/
|
|
47
|
+
export declare function setVectorStoreExecutionId(executionId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clear the current execution ID
|
|
50
|
+
*/
|
|
51
|
+
export declare function clearVectorStoreExecutionId(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Initialize a new vector store for a new execution
|
|
54
|
+
*/
|
|
55
|
+
export declare function initializeVectorStore(executionId?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Clear the vector store after execution completes
|
|
58
|
+
*/
|
|
59
|
+
export declare function clearVectorStore(executionId?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current vector store (for executor to manage)
|
|
62
|
+
*/
|
|
63
|
+
export declare function getVectorStore(executionId?: string): VectorStore;
|
|
64
|
+
//# sourceMappingURL=vector-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../src/embedding/vector-store.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/E;;;GAGG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,cAAc,CAAyB;IAE/C;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9F;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;IAM5C;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAI5C;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,EAAE;IAoC9C;;OAEG;IACH,MAAM,IAAI,eAAe,EAAE;IAI3B;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI5C;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,KAAK,IAAI,MAAM;CAGf;AAMD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAEnE;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAMhE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAS3D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAYhE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { cosineSimilarity } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory vector store for the current execution
|
|
4
|
+
* Cleared after each execution completes
|
|
5
|
+
*/
|
|
6
|
+
export class VectorStore {
|
|
7
|
+
records = new Map();
|
|
8
|
+
queryEmbedding = null;
|
|
9
|
+
/**
|
|
10
|
+
* Store embeddings from client response
|
|
11
|
+
*/
|
|
12
|
+
store(id, text, embedding, metadata) {
|
|
13
|
+
this.records.set(id, { id, text, embedding, metadata });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Store multiple embeddings
|
|
17
|
+
*/
|
|
18
|
+
storeBatch(records) {
|
|
19
|
+
for (const record of records) {
|
|
20
|
+
this.records.set(record.id, record);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Set the query embedding for search
|
|
25
|
+
*/
|
|
26
|
+
setQueryEmbedding(embedding) {
|
|
27
|
+
this.queryEmbedding = embedding;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Search stored embeddings by similarity to query
|
|
31
|
+
*/
|
|
32
|
+
search(options) {
|
|
33
|
+
if (!this.queryEmbedding) {
|
|
34
|
+
throw new Error('No query embedding set. Call embed() with query first.');
|
|
35
|
+
}
|
|
36
|
+
const topK = options.topK ?? 5;
|
|
37
|
+
const minSimilarity = options.minSimilarity ?? 0;
|
|
38
|
+
const results = [];
|
|
39
|
+
for (const record of this.records.values()) {
|
|
40
|
+
if (options.filter && record.metadata) {
|
|
41
|
+
let matches = true;
|
|
42
|
+
for (const [key, value] of Object.entries(options.filter)) {
|
|
43
|
+
if (record.metadata[key] !== value) {
|
|
44
|
+
matches = false;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!matches)
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const similarity = cosineSimilarity(this.queryEmbedding, record.embedding);
|
|
52
|
+
if (similarity >= minSimilarity) {
|
|
53
|
+
results.push({
|
|
54
|
+
id: record.id,
|
|
55
|
+
text: record.text,
|
|
56
|
+
similarity,
|
|
57
|
+
metadata: record.metadata,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
results.sort((a, b) => b.similarity - a.similarity);
|
|
62
|
+
return results.slice(0, topK);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get all stored embeddings
|
|
66
|
+
*/
|
|
67
|
+
getAll() {
|
|
68
|
+
return Array.from(this.records.values());
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get embedding by ID
|
|
72
|
+
*/
|
|
73
|
+
get(id) {
|
|
74
|
+
return this.records.get(id);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Clear all stored embeddings
|
|
78
|
+
*/
|
|
79
|
+
clear() {
|
|
80
|
+
this.records.clear();
|
|
81
|
+
this.queryEmbedding = null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get count of stored embeddings
|
|
85
|
+
*/
|
|
86
|
+
count() {
|
|
87
|
+
return this.records.size;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const vectorStores = new Map();
|
|
91
|
+
let currentVectorStoreExecutionId = null;
|
|
92
|
+
/**
|
|
93
|
+
* Set the current execution ID for vector store operations
|
|
94
|
+
*/
|
|
95
|
+
export function setVectorStoreExecutionId(executionId) {
|
|
96
|
+
currentVectorStoreExecutionId = executionId;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Clear the current execution ID
|
|
100
|
+
*/
|
|
101
|
+
export function clearVectorStoreExecutionId() {
|
|
102
|
+
currentVectorStoreExecutionId = null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Initialize a new vector store for a new execution
|
|
106
|
+
*/
|
|
107
|
+
export function initializeVectorStore(executionId) {
|
|
108
|
+
const id = executionId || currentVectorStoreExecutionId;
|
|
109
|
+
if (!id) {
|
|
110
|
+
throw new Error('No execution ID set for vector store');
|
|
111
|
+
}
|
|
112
|
+
vectorStores.set(id, new VectorStore());
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Clear the vector store after execution completes
|
|
116
|
+
*/
|
|
117
|
+
export function clearVectorStore(executionId) {
|
|
118
|
+
const id = executionId || currentVectorStoreExecutionId;
|
|
119
|
+
if (!id)
|
|
120
|
+
return;
|
|
121
|
+
const store = vectorStores.get(id);
|
|
122
|
+
if (store) {
|
|
123
|
+
store.clear();
|
|
124
|
+
vectorStores.delete(id);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the current vector store (for executor to manage)
|
|
129
|
+
*/
|
|
130
|
+
export function getVectorStore(executionId) {
|
|
131
|
+
const id = executionId || currentVectorStoreExecutionId;
|
|
132
|
+
if (!id) {
|
|
133
|
+
throw new Error('No execution ID set for vector store');
|
|
134
|
+
}
|
|
135
|
+
let store = vectorStores.get(id);
|
|
136
|
+
if (!store) {
|
|
137
|
+
store = new VectorStore();
|
|
138
|
+
vectorStores.set(id, store);
|
|
139
|
+
}
|
|
140
|
+
return store;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=vector-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-store.js","sourceRoot":"","sources":["../../src/embedding/vector-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,WAAW;IACf,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAClD,cAAc,GAAoB,IAAI,CAAC;IAE/C;;OAEG;IACH,KAAK,CAAC,EAAU,EAAE,IAAY,EAAE,S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B,GAAG,IAAI,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAoB;IACzD,MAAM,EAAE,GAAG,WAAW,IAAI,6BAA6B,CAAC;IACxD,IAAI,CAAC,EAAE,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IACD,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,WAAW,EAAE,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAoB;IACpD,MAAM,EAAE,GAAG,WAAW,IAAI,6BAA6B,CAAC;IACxD,IAAI,CAAC,EAAE;QAAE,OAAO;IAEhB,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnC,IAAI,KAAK,EAAE,CAAC;QACX,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,WAAoB;IAClD,MAAM,EAAE,GAAG,WAAW,IAAI,6BAA6B,CAAC;IACxD,IAAI,CAAC,EAAE,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;QAC1B,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './llm/index.js';
|
|
2
|
+
export * from './progress/index.js';
|
|
3
|
+
export * from './cache/index.js';
|
|
4
|
+
export * from './utils.js';
|
|
5
|
+
export * from './approval/index.js';
|
|
6
|
+
export * from './embedding/index.js';
|
|
7
|
+
export * from './registry.js';
|
|
8
|
+
export * from './metadata/index.js';
|
|
9
|
+
export { log, initializeLogger, shutdownLogger } from './log/index.js';
|
|
10
|
+
export type { LogLevel, LoggerConfig, Logger } from './log/index.js';
|
|
11
|
+
export { GENERATED_METADATA } from './metadata/generated.js';
|
|
12
|
+
export { setClientLLMCallback, setPauseForClient, setReplayMode, getCallSequenceNumber, } from './llm/index.js';
|
|
13
|
+
export { initializeCache } from './cache/index.js';
|
|
14
|
+
export { initializeApproval } from './approval/index.js';
|
|
15
|
+
export { setProgressCallback } from './progress/index.js';
|
|
16
|
+
export { initializeVectorStore, clearVectorStore, getVectorStore } from './embedding/index.js';
|
|
17
|
+
export { PauseExecutionError, isPauseError, pauseForCallback, CallbackType, LLMOperation, EmbeddingOperation, ApprovalOperation, ToolOperation, } from './pause/index.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EACN,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACb,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './llm/index.js';
|
|
2
|
+
export * from './progress/index.js';
|
|
3
|
+
export * from './cache/index.js';
|
|
4
|
+
export * from './utils.js';
|
|
5
|
+
export * from './approval/index.js';
|
|
6
|
+
export * from './embedding/index.js';
|
|
7
|
+
export * from './registry.js';
|
|
8
|
+
export * from './metadata/index.js';
|
|
9
|
+
export { log, initializeLogger, shutdownLogger } from './log/index.js';
|
|
10
|
+
export { GENERATED_METADATA } from './metadata/generated.js';
|
|
11
|
+
export { setClientLLMCallback, setPauseForClient, setReplayMode, getCallSequenceNumber, } from './llm/index.js';
|
|
12
|
+
export { initializeCache } from './cache/index.js';
|
|
13
|
+
export { initializeApproval } from './approval/index.js';
|
|
14
|
+
export { setProgressCallback } from './progress/index.js';
|
|
15
|
+
export { initializeVectorStore, clearVectorStore, getVectorStore } from './embedding/index.js';
|
|
16
|
+
export { PauseExecutionError, isPauseError, pauseForCallback, CallbackType, LLMOperation, EmbeddingOperation, ApprovalOperation, ToolOperation, } from './pause/index.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EACN,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EACN,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACb,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*/
|
|
3
|
+
import type { ClientLLMCallback } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Sets a client callback handler for LLM operations
|
|
6
|
+
* @param callback - Client callback handler
|
|
7
|
+
*/
|
|
8
|
+
export declare function setClientLLMCallback(callback: ClientLLMCallback | undefined): void;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the current client callback handler
|
|
11
|
+
*/
|
|
12
|
+
export declare function getClientLLMCallback(): ClientLLMCallback | undefined;
|
|
13
|
+
//# sourceMappingURL=callback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/llm/callback.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQjD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAElF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,SAAS,CAEpE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client callback handler for LLM operations
|
|
3
|
+
* When set, LLM calls will be routed to client instead of server LLM
|
|
4
|
+
*/
|
|
5
|
+
let clientLLMCallback;
|
|
6
|
+
/**
|
|
7
|
+
* Sets a client callback handler for LLM operations
|
|
8
|
+
* @param callback - Client callback handler
|
|
9
|
+
*/
|
|
10
|
+
export function setClientLLMCallback(callback) {
|
|
11
|
+
clientLLMCallback = callback;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gets the current client callback handler
|
|
15
|
+
*/
|
|
16
|
+
export function getClientLLMCallback() {
|
|
17
|
+
return clientLLMCallback;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=callback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../src/llm/callback.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,IAAI,iBAAgD,CAAC;AAErD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAuC;IAC3E,iBAAiB,GAAG,QAAQ,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,iBAAiB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LLMCallOptions, LLMExtractOptions, LLMClassifyOptions } from './types';
|
|
2
|
+
export type { LLMCallOptions, LLMExtractOptions, LLMClassifyOptions, ClientLLMCallback, } from './types';
|
|
3
|
+
export { setClientLLMCallback, getClientLLMCallback } from './callback.js';
|
|
4
|
+
export { setPauseForClient, setReplayMode, getCallSequenceNumber, nextSequenceNumber, getCachedResult, runInExecutionContext, setCurrentExecutionId, clearCurrentExecutionId, } from './replay.js';
|
|
5
|
+
/**
|
|
6
|
+
* LLM Runtime API
|
|
7
|
+
*
|
|
8
|
+
* Provides client-side LLM operations with pause/resume support.
|
|
9
|
+
* All calls pause execution and route to client-provided LLM.
|
|
10
|
+
*/
|
|
11
|
+
declare class LLMAPI {
|
|
12
|
+
/**
|
|
13
|
+
* Makes a standard LLM call
|
|
14
|
+
* Always pauses execution and routes to client-provided LLM
|
|
15
|
+
*/
|
|
16
|
+
call(options: LLMCallOptions): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts structured data using LLM
|
|
19
|
+
* Always pauses execution and routes to client-provided LLM
|
|
20
|
+
*/
|
|
21
|
+
extract<T>(options: LLMExtractOptions): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Classifies text into one of the provided categories
|
|
24
|
+
* Always pauses execution and routes to client-provided LLM
|
|
25
|
+
*/
|
|
26
|
+
classify(options: LLMClassifyOptions): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
export declare const llm: LLMAPI;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAErF,YAAY,EACX,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,cAIM,MAAM;IACX;;;OAGG;IAOG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAepD;;;OAGG;IAOG,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;IAgBxD;;;OAGG;IAOG,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;CAe5D;AAED,eAAO,MAAM,GAAG,QAAe,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* LLM API - Clean refactored version with decorators and extracted modules
|
|
12
|
+
*
|
|
13
|
+
* Benefits:
|
|
14
|
+
* - No duplication between implementation and metadata
|
|
15
|
+
* - Types auto-detected from TypeScript signatures
|
|
16
|
+
* - Clean separation of concerns (replay, callback, API)
|
|
17
|
+
*/
|
|
18
|
+
import { pauseForCallback, CallbackType, LLMOperation } from '../pause/index.js';
|
|
19
|
+
import { RuntimeAPI, RuntimeMethod } from '../metadata/decorators.js';
|
|
20
|
+
import { nextSequenceNumber, getCachedResult } from './replay.js';
|
|
21
|
+
export { setClientLLMCallback, getClientLLMCallback } from './callback.js';
|
|
22
|
+
export { setPauseForClient, setReplayMode, getCallSequenceNumber, nextSequenceNumber, getCachedResult, runInExecutionContext, setCurrentExecutionId, clearCurrentExecutionId, } from './replay.js';
|
|
23
|
+
/**
|
|
24
|
+
* LLM Runtime API
|
|
25
|
+
*
|
|
26
|
+
* Provides client-side LLM operations with pause/resume support.
|
|
27
|
+
* All calls pause execution and route to client-provided LLM.
|
|
28
|
+
*/
|
|
29
|
+
let LLMAPI = class LLMAPI {
|
|
30
|
+
/**
|
|
31
|
+
* Makes a standard LLM call
|
|
32
|
+
* Always pauses execution and routes to client-provided LLM
|
|
33
|
+
*/
|
|
34
|
+
async call(options) {
|
|
35
|
+
const currentSequence = nextSequenceNumber();
|
|
36
|
+
const cachedResult = getCachedResult(currentSequence);
|
|
37
|
+
if (cachedResult !== undefined) {
|
|
38
|
+
return cachedResult;
|
|
39
|
+
}
|
|
40
|
+
pauseForCallback(CallbackType.LLM, LLMOperation.CALL, {
|
|
41
|
+
prompt: options.prompt,
|
|
42
|
+
options,
|
|
43
|
+
sequenceNumber: currentSequence,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extracts structured data using LLM
|
|
48
|
+
* Always pauses execution and routes to client-provided LLM
|
|
49
|
+
*/
|
|
50
|
+
async extract(options) {
|
|
51
|
+
const currentSequence = nextSequenceNumber();
|
|
52
|
+
const cachedResult = getCachedResult(currentSequence);
|
|
53
|
+
if (cachedResult !== undefined) {
|
|
54
|
+
return cachedResult;
|
|
55
|
+
}
|
|
56
|
+
pauseForCallback(CallbackType.LLM, LLMOperation.EXTRACT, {
|
|
57
|
+
prompt: options.prompt,
|
|
58
|
+
schema: options.schema,
|
|
59
|
+
options,
|
|
60
|
+
sequenceNumber: currentSequence,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Classifies text into one of the provided categories
|
|
65
|
+
* Always pauses execution and routes to client-provided LLM
|
|
66
|
+
*/
|
|
67
|
+
async classify(options) {
|
|
68
|
+
const currentSequence = nextSequenceNumber();
|
|
69
|
+
const cachedResult = getCachedResult(currentSequence);
|
|
70
|
+
if (cachedResult !== undefined) {
|
|
71
|
+
return cachedResult;
|
|
72
|
+
}
|
|
73
|
+
pauseForCallback(CallbackType.LLM, LLMOperation.CLASSIFY, {
|
|
74
|
+
text: options.text,
|
|
75
|
+
categories: options.categories,
|
|
76
|
+
options,
|
|
77
|
+
sequenceNumber: currentSequence,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
__decorate([
|
|
82
|
+
RuntimeMethod('Make an LLM call with a prompt', {
|
|
83
|
+
options: {
|
|
84
|
+
description: 'LLM call options including prompt',
|
|
85
|
+
type: 'LLMCallOptions',
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Object]),
|
|
90
|
+
__metadata("design:returntype", Promise)
|
|
91
|
+
], LLMAPI.prototype, "call", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
RuntimeMethod('Extract structured data from text using an LLM', {
|
|
94
|
+
options: {
|
|
95
|
+
description: 'Extraction options with JSON schema',
|
|
96
|
+
type: 'LLMExtractOptions',
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [Object]),
|
|
101
|
+
__metadata("design:returntype", Promise)
|
|
102
|
+
], LLMAPI.prototype, "extract", null);
|
|
103
|
+
__decorate([
|
|
104
|
+
RuntimeMethod('Classify text into one of the provided categories', {
|
|
105
|
+
options: {
|
|
106
|
+
description: 'Classification options with categories',
|
|
107
|
+
type: 'LLMClassifyOptions',
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
__metadata("design:type", Function),
|
|
111
|
+
__metadata("design:paramtypes", [Object]),
|
|
112
|
+
__metadata("design:returntype", Promise)
|
|
113
|
+
], LLMAPI.prototype, "classify", null);
|
|
114
|
+
LLMAPI = __decorate([
|
|
115
|
+
RuntimeAPI('llm', 'LLM API - Large Language Model calls using client-provided LLM (requires client.provideLLM())')
|
|
116
|
+
], LLMAPI);
|
|
117
|
+
export const llm = new LLMAPI();
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAgB,MAAM,aAAa,CAAC;AAShF,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AAKH,IAAM,MAAM,GAAZ,MAAM,MAAM;IACX;;;OAGG;IAOG,AAAN,KAAK,CAAC,IAAI,CAAC,OAAuB;QACjC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;QAE7C,MAAM,YAAY,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,YAAsB,CAAC;QAC/B,CAAC;QAED,gBAAgB,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,EAAE;YACrD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO;YACP,cAAc,EAAE,eAAe;SAC/B,CAAC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E,OAAO,EAAE;YACR,WAAW,EAAE,wCAAwC;YACrD,IAAI,EAAE,oBAAoB;SAC1B;KACD,CAAC;;;;sCAeD;AA5EI,MAAM;IAJX,UAAU,CACV,KAAK,EACL,+FAA+F,CAC/F;GACK,MAAM,CA6EX;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the current execution ID for this call
|
|
3
|
+
* Called by executor before each runtime API invocation
|
|
4
|
+
*/
|
|
5
|
+
export declare function setCurrentExecutionId(executionId: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Clears the current execution ID after a call
|
|
8
|
+
* Called by executor after each runtime API invocation
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearCurrentExecutionId(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Runs a function within an execution context
|
|
13
|
+
* @param executionId - Unique ID for this execution
|
|
14
|
+
* @param fn - Function to run within the context
|
|
15
|
+
*/
|
|
16
|
+
export declare function runInExecutionContext<T>(executionId: string, fn: () => T): T;
|
|
17
|
+
/**
|
|
18
|
+
* Configures whether to pause execution for client services
|
|
19
|
+
* @param pause - If true, throws PauseExecutionError instead of calling callback
|
|
20
|
+
*/
|
|
21
|
+
export declare function setPauseForClient(pause: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if should pause for client
|
|
24
|
+
*/
|
|
25
|
+
export declare function shouldPauseForClient(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Sets up replay mode for resumption
|
|
28
|
+
* @param results - Map of sequence number to result for replaying callbacks
|
|
29
|
+
*/
|
|
30
|
+
export declare function setReplayMode(results: Map<number, unknown> | undefined): void;
|
|
31
|
+
/**
|
|
32
|
+
* Gets current call sequence number
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCallSequenceNumber(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Increments and returns the next sequence number
|
|
37
|
+
*/
|
|
38
|
+
export declare function nextSequenceNumber(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Check if we have a cached result for the current sequence
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCachedResult(sequenceNumber: number): unknown | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Check if we're in replay mode
|
|
45
|
+
*/
|
|
46
|
+
export declare function isReplayMode(): boolean;
|
|
47
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/llm/replay.ts"],"names":[],"mappings":"AA8BA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AA8BD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAE5E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAI7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAO3E;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Map of executionId -> ExecutionState
|
|
4
|
+
* Each execution has its own isolated state
|
|
5
|
+
*/
|
|
6
|
+
const executionStates = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* AsyncLocalStorage for execution ID - provides proper async context isolation
|
|
9
|
+
* This ensures each async execution chain has its own isolated execution ID
|
|
10
|
+
*/
|
|
11
|
+
const executionContext = new AsyncLocalStorage();
|
|
12
|
+
/**
|
|
13
|
+
* Current execution ID - set by runtime API wrappers
|
|
14
|
+
* This is a thread-local variable that's set before each runtime API call
|
|
15
|
+
* and cleared after, providing isolation even when AsyncLocalStorage fails
|
|
16
|
+
*/
|
|
17
|
+
let currentExecutionId = null;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the current execution ID for this call
|
|
20
|
+
* Called by executor before each runtime API invocation
|
|
21
|
+
*/
|
|
22
|
+
export function setCurrentExecutionId(executionId) {
|
|
23
|
+
currentExecutionId = executionId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Clears the current execution ID after a call
|
|
27
|
+
* Called by executor after each runtime API invocation
|
|
28
|
+
*/
|
|
29
|
+
export function clearCurrentExecutionId() {
|
|
30
|
+
currentExecutionId = null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current execution state, creating it if needed
|
|
34
|
+
*/
|
|
35
|
+
function getCurrentState() {
|
|
36
|
+
let executionId = currentExecutionId;
|
|
37
|
+
if (!executionId) {
|
|
38
|
+
executionId = executionContext.getStore() || null;
|
|
39
|
+
}
|
|
40
|
+
if (!executionId) {
|
|
41
|
+
throw new Error('No execution context set. Executor must call setCurrentExecutionId() before runtime API calls.');
|
|
42
|
+
}
|
|
43
|
+
let state = executionStates.get(executionId);
|
|
44
|
+
if (!state) {
|
|
45
|
+
state = {
|
|
46
|
+
shouldPauseForClient: false,
|
|
47
|
+
replayResults: undefined,
|
|
48
|
+
callSequenceNumber: 0,
|
|
49
|
+
};
|
|
50
|
+
executionStates.set(executionId, state);
|
|
51
|
+
}
|
|
52
|
+
return state;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Runs a function within an execution context
|
|
56
|
+
* @param executionId - Unique ID for this execution
|
|
57
|
+
* @param fn - Function to run within the context
|
|
58
|
+
*/
|
|
59
|
+
export function runInExecutionContext(executionId, fn) {
|
|
60
|
+
return executionContext.run(executionId, fn);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Configures whether to pause execution for client services
|
|
64
|
+
* @param pause - If true, throws PauseExecutionError instead of calling callback
|
|
65
|
+
*/
|
|
66
|
+
export function setPauseForClient(pause) {
|
|
67
|
+
getCurrentState().shouldPauseForClient = pause;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if should pause for client
|
|
71
|
+
*/
|
|
72
|
+
export function shouldPauseForClient() {
|
|
73
|
+
return getCurrentState().shouldPauseForClient;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Sets up replay mode for resumption
|
|
77
|
+
* @param results - Map of sequence number to result for replaying callbacks
|
|
78
|
+
*/
|
|
79
|
+
export function setReplayMode(results) {
|
|
80
|
+
const state = getCurrentState();
|
|
81
|
+
state.replayResults = results;
|
|
82
|
+
state.callSequenceNumber = 0;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets current call sequence number
|
|
86
|
+
*/
|
|
87
|
+
export function getCallSequenceNumber() {
|
|
88
|
+
return getCurrentState().callSequenceNumber;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Increments and returns the next sequence number
|
|
92
|
+
*/
|
|
93
|
+
export function nextSequenceNumber() {
|
|
94
|
+
const state = getCurrentState();
|
|
95
|
+
return state.callSequenceNumber++;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if we have a cached result for the current sequence
|
|
99
|
+
*/
|
|
100
|
+
export function getCachedResult(sequenceNumber) {
|
|
101
|
+
const state = getCurrentState();
|
|
102
|
+
if (state.replayResults && state.replayResults.has(sequenceNumber)) {
|
|
103
|
+
const result = state.replayResults.get(sequenceNumber);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if we're in replay mode
|
|
110
|
+
*/
|
|
111
|
+
export function isReplayMode() {
|
|
112
|
+
return getCurrentState().replayResults !== undefined;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/llm/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAWhD;;;GAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,EAAU,CAAC;AAEzD;;;;GAIG;AACH,IAAI,kBAAkB,GAAkB,IAAI,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACxD,kBAAkB,GAAG,WAAW,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACtC,kBAAkB,GAAG,IAAI,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACvB,IAAI,WAAW,GAAG,kBAAkB,CAAC;IAErC,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,WAAW,GAAG,gBAAgB,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACd,gGAAgG,CAChG,CAAC;IACH,CAAC;IAED,IAAI,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,GAAG;YACP,oBAAoB,EAAE,KAAK;YAC3B,aAAa,EAAE,SAAS;YACxB,kBAAk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