@minpeter/pss-runtime 0.0.4 → 0.0.6
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 +89 -101
- package/dist/agent-loop.d.ts +20 -12
- package/dist/agent-loop.js +45 -48
- package/dist/agent-loop.js.map +1 -1
- package/dist/agent.d.ts +34 -17
- package/dist/agent.js +50 -31
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +4 -5
- package/dist/llm.d.ts +29 -23
- package/dist/llm.js +15 -11
- package/dist/llm.js.map +1 -1
- package/dist/session/events.d.ts +76 -61
- package/dist/session/history.js +32 -30
- package/dist/session/history.js.map +1 -1
- package/dist/session/mapping.js +92 -52
- package/dist/session/mapping.js.map +1 -1
- package/dist/session/run.d.ts +9 -0
- package/dist/session/run.js +78 -0
- package/dist/session/run.js.map +1 -0
- package/dist/session/session.d.ts +9 -16
- package/dist/session/session.js +193 -320
- package/dist/session/session.js.map +1 -1
- package/dist/session/snapshot.js +20 -0
- package/dist/session/snapshot.js.map +1 -0
- package/dist/session/store/file.d.ts +14 -0
- package/dist/session/store/file.js +106 -0
- package/dist/session/store/file.js.map +1 -0
- package/dist/session/store/memory.d.ts +13 -0
- package/dist/session/store/memory.js +31 -0
- package/dist/session/store/memory.js.map +1 -0
- package/dist/session/store/types.d.ts +22 -0
- package/package.json +16 -2
- package/dist/agent-loop.d.ts.map +0 -1
- package/dist/agent.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/llm.d.ts.map +0 -1
- package/dist/session/events.d.ts.map +0 -1
- package/dist/session/events.js +0 -2
- package/dist/session/events.js.map +0 -1
- package/dist/session/history.d.ts +0 -11
- package/dist/session/history.d.ts.map +0 -1
- package/dist/session/mapping.d.ts +0 -7
- package/dist/session/mapping.d.ts.map +0 -1
- package/dist/session/session.d.ts.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { setTimeout } from "node:timers/promises";
|
|
5
|
+
//#region src/session/store/file.ts
|
|
6
|
+
const LOCK_POLL_INTERVAL_MS = 10;
|
|
7
|
+
const LOCK_STALE_AFTER_MS = 3e4;
|
|
8
|
+
const LOCK_TIMEOUT_MS = 5e3;
|
|
9
|
+
var FileSessionStore = class {
|
|
10
|
+
#directory;
|
|
11
|
+
constructor(directory) {
|
|
12
|
+
this.#directory = directory;
|
|
13
|
+
}
|
|
14
|
+
async load(key) {
|
|
15
|
+
const file = this.#fileForKey(key);
|
|
16
|
+
try {
|
|
17
|
+
return parseStoredFileSession(JSON.parse(await readFile(file, "utf8")), file);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (isNodeError(error) && error.code === "ENOENT") return null;
|
|
20
|
+
if (error instanceof SyntaxError) throw new Error(`Invalid FileSessionStore file ${JSON.stringify(file)}: invalid JSON (${error.message})`);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async commit(key, next, options) {
|
|
25
|
+
const file = this.#fileForKey(key);
|
|
26
|
+
const lockDirectory = `${file}.lock`;
|
|
27
|
+
await mkdir(dirname(file), { recursive: true });
|
|
28
|
+
await acquireFileLock(lockDirectory);
|
|
29
|
+
try {
|
|
30
|
+
const current = await this.load(key);
|
|
31
|
+
const currentVersion = current?.version ?? null;
|
|
32
|
+
if (options?.expectedVersion !== void 0 && options.expectedVersion !== currentVersion) return {
|
|
33
|
+
ok: false,
|
|
34
|
+
reason: "conflict"
|
|
35
|
+
};
|
|
36
|
+
const version = String((Number(current?.version ?? "0") || 0) + 1);
|
|
37
|
+
const payload = structuredClone({
|
|
38
|
+
state: next.state,
|
|
39
|
+
version
|
|
40
|
+
});
|
|
41
|
+
const tempFile = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
42
|
+
try {
|
|
43
|
+
await writeFile(tempFile, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
44
|
+
await rename(tempFile, file);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
await rm(tempFile, { force: true }).catch(() => void 0);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
version
|
|
52
|
+
};
|
|
53
|
+
} finally {
|
|
54
|
+
await rm(lockDirectory, {
|
|
55
|
+
force: true,
|
|
56
|
+
recursive: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
#fileForKey(key) {
|
|
61
|
+
return join(this.#directory, `${Buffer.from(key).toString("base64url")}.json`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function parseStoredFileSession(value, file) {
|
|
65
|
+
if (value === null || typeof value !== "object") throw new Error(`Invalid FileSessionStore file ${JSON.stringify(file)}: expected an object`);
|
|
66
|
+
const candidate = value;
|
|
67
|
+
if (typeof candidate.version !== "string" || !("state" in candidate)) throw new Error(`Invalid FileSessionStore file ${JSON.stringify(file)}: expected state and string version`);
|
|
68
|
+
return structuredClone({
|
|
69
|
+
state: candidate.state,
|
|
70
|
+
version: candidate.version
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function isNodeError(error) {
|
|
74
|
+
return error instanceof Error && "code" in error;
|
|
75
|
+
}
|
|
76
|
+
async function acquireFileLock(lockDirectory) {
|
|
77
|
+
const startedAt = Date.now();
|
|
78
|
+
while (Date.now() - startedAt < LOCK_TIMEOUT_MS) {
|
|
79
|
+
try {
|
|
80
|
+
await mkdir(lockDirectory);
|
|
81
|
+
return;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (!(isNodeError(error) && error.code === "EEXIST")) throw error;
|
|
84
|
+
await removeStaleLock(lockDirectory);
|
|
85
|
+
}
|
|
86
|
+
await setTimeout(LOCK_POLL_INTERVAL_MS);
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Timed out waiting for FileSessionStore lock ${JSON.stringify(lockDirectory)}`);
|
|
89
|
+
}
|
|
90
|
+
async function removeStaleLock(lockDirectory) {
|
|
91
|
+
try {
|
|
92
|
+
const stats = await stat(lockDirectory);
|
|
93
|
+
if (Date.now() - stats.mtimeMs < LOCK_STALE_AFTER_MS) return;
|
|
94
|
+
await rm(lockDirectory, {
|
|
95
|
+
force: true,
|
|
96
|
+
recursive: true
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (isNodeError(error) && error.code === "ENOENT") return;
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { FileSessionStore };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","names":["#directory","#fileForKey"],"sources":["../../../src/session/store/file.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { setTimeout } from \"node:timers/promises\";\nimport type { CommitResult, SessionStore, StoredSession } from \"./types\";\n\nconst LOCK_POLL_INTERVAL_MS = 10;\nconst LOCK_STALE_AFTER_MS = 30_000;\nconst LOCK_TIMEOUT_MS = 5000;\n\nexport class FileSessionStore implements SessionStore {\n readonly #directory: string;\n\n constructor(directory: string) {\n this.#directory = directory;\n }\n\n async load(key: string): Promise<StoredSession | null> {\n const file = this.#fileForKey(key);\n\n try {\n const parsed = JSON.parse(await readFile(file, \"utf8\")) as unknown;\n return parseStoredFileSession(parsed, file);\n } catch (error) {\n if (isNodeError(error) && error.code === \"ENOENT\") {\n return null;\n }\n if (error instanceof SyntaxError) {\n throw new Error(\n `Invalid FileSessionStore file ${JSON.stringify(\n file\n )}: invalid JSON (${error.message})`\n );\n }\n throw error;\n }\n }\n\n async commit(\n key: string,\n next: StoredSession,\n options?: { expectedVersion?: string | null }\n ): Promise<CommitResult> {\n const file = this.#fileForKey(key);\n const lockDirectory = `${file}.lock`;\n await mkdir(dirname(file), { recursive: true });\n await acquireFileLock(lockDirectory);\n try {\n const current = await this.load(key);\n const currentVersion = current?.version ?? null;\n\n if (\n options?.expectedVersion !== undefined &&\n options.expectedVersion !== currentVersion\n ) {\n return { ok: false, reason: \"conflict\" };\n }\n\n const version = String((Number(current?.version ?? \"0\") || 0) + 1);\n const payload: StoredSession = structuredClone({\n state: next.state,\n version,\n });\n const tempFile = `${file}.${process.pid}.${randomUUID()}.tmp`;\n\n try {\n await writeFile(\n tempFile,\n `${JSON.stringify(payload, null, 2)}\\n`,\n \"utf8\"\n );\n await rename(tempFile, file);\n } catch (error) {\n await rm(tempFile, { force: true }).catch(() => undefined);\n throw error;\n }\n\n return { ok: true, version };\n } finally {\n await rm(lockDirectory, { force: true, recursive: true });\n }\n }\n\n #fileForKey(key: string): string {\n return join(\n this.#directory,\n `${Buffer.from(key).toString(\"base64url\")}.json`\n );\n }\n}\n\nfunction parseStoredFileSession(value: unknown, file: string): StoredSession {\n if (value === null || typeof value !== \"object\") {\n throw new Error(\n `Invalid FileSessionStore file ${JSON.stringify(\n file\n )}: expected an object`\n );\n }\n\n const candidate = value as Partial<StoredSession>;\n if (typeof candidate.version !== \"string\" || !(\"state\" in candidate)) {\n throw new Error(\n `Invalid FileSessionStore file ${JSON.stringify(\n file\n )}: expected state and string version`\n );\n }\n\n return structuredClone({\n state: candidate.state,\n version: candidate.version,\n });\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n return error instanceof Error && \"code\" in error;\n}\n\nasync function acquireFileLock(lockDirectory: string): Promise<void> {\n const startedAt = Date.now();\n while (Date.now() - startedAt < LOCK_TIMEOUT_MS) {\n try {\n await mkdir(lockDirectory);\n return;\n } catch (error) {\n if (!(isNodeError(error) && error.code === \"EEXIST\")) {\n throw error;\n }\n await removeStaleLock(lockDirectory);\n }\n\n await setTimeout(LOCK_POLL_INTERVAL_MS);\n }\n\n throw new Error(\n `Timed out waiting for FileSessionStore lock ${JSON.stringify(\n lockDirectory\n )}`\n );\n}\n\nasync function removeStaleLock(lockDirectory: string): Promise<void> {\n try {\n const stats = await stat(lockDirectory);\n if (Date.now() - stats.mtimeMs < LOCK_STALE_AFTER_MS) {\n return;\n }\n await rm(lockDirectory, { force: true, recursive: true });\n } catch (error) {\n if (isNodeError(error) && error.code === \"ENOENT\") {\n return;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;AAMA,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AAExB,IAAa,mBAAb,MAAsD;CACpD;CAEA,YAAY,WAAmB;EAC7B,KAAKA,aAAa;CACpB;CAEA,MAAM,KAAK,KAA4C;EACrD,MAAM,OAAO,KAAKC,YAAY,GAAG;EAEjC,IAAI;GAEF,OAAO,uBADQ,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAClB,GAAG,IAAI;EAC5C,SAAS,OAAO;GACd,IAAI,YAAY,KAAK,KAAK,MAAM,SAAS,UACvC,OAAO;GAET,IAAI,iBAAiB,aACnB,MAAM,IAAI,MACR,iCAAiC,KAAK,UACpC,IACF,EAAE,kBAAkB,MAAM,QAAQ,EACpC;GAEF,MAAM;EACR;CACF;CAEA,MAAM,OACJ,KACA,MACA,SACuB;EACvB,MAAM,OAAO,KAAKA,YAAY,GAAG;EACjC,MAAM,gBAAgB,GAAG,KAAK;EAC9B,MAAM,MAAM,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EAC9C,MAAM,gBAAgB,aAAa;EACnC,IAAI;GACF,MAAM,UAAU,MAAM,KAAK,KAAK,GAAG;GACnC,MAAM,iBAAiB,SAAS,WAAW;GAE3C,IACE,SAAS,oBAAoB,KAAA,KAC7B,QAAQ,oBAAoB,gBAE5B,OAAO;IAAE,IAAI;IAAO,QAAQ;GAAW;GAGzC,MAAM,UAAU,QAAQ,OAAO,S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,WACzC,MAAM;GAER,MAAM,gBAAgB,aAAa;EACrC;EAEA,MAAM,WAAW,qBAAqB;CACxC;CAEA,MAAM,IAAI,MACR,+CAA+C,KAAK,UAClD,aACF,GACF;AACF;AAEA,eAAe,gBAAgB,eAAsC;CACnE,IAAI;EACF,MAAM,QAAQ,MAAM,KAAK,aAAa;EACtC,IAAI,KAAK,IAAI,IAAI,MAAM,UAAU,qBAC/B;EAEF,MAAM,GAAG,eAAe;GAAE,OAAO;GAAM,WAAW;EAAK,CAAC;CAC1D,SAAS,OAAO;EACd,IAAI,YAAY,KAAK,KAAK,MAAM,SAAS,UACvC;EAEF,MAAM;CACR;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommitResult, SessionStore, StoredSession } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/session/store/memory.d.ts
|
|
4
|
+
declare class MemorySessionStore implements SessionStore {
|
|
5
|
+
#private;
|
|
6
|
+
load(key: string): Promise<StoredSession | null>;
|
|
7
|
+
commit(key: string, next: StoredSession, options?: {
|
|
8
|
+
expectedVersion?: string | null;
|
|
9
|
+
}): Promise<CommitResult>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { MemorySessionStore };
|
|
13
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/session/store/memory.ts
|
|
2
|
+
var MemorySessionStore = class {
|
|
3
|
+
#sessions = /* @__PURE__ */ new Map();
|
|
4
|
+
#versions = /* @__PURE__ */ new Map();
|
|
5
|
+
load(key) {
|
|
6
|
+
const stored = this.#sessions.get(key);
|
|
7
|
+
return Promise.resolve(stored ? structuredClone(stored) : null);
|
|
8
|
+
}
|
|
9
|
+
commit(key, next, options) {
|
|
10
|
+
const currentVersion = this.#sessions.get(key)?.version ?? null;
|
|
11
|
+
if (options?.expectedVersion !== void 0 && options.expectedVersion !== currentVersion) return Promise.resolve({
|
|
12
|
+
ok: false,
|
|
13
|
+
reason: "conflict"
|
|
14
|
+
});
|
|
15
|
+
const versionNumber = (this.#versions.get(key) ?? 0) + 1;
|
|
16
|
+
const version = String(versionNumber);
|
|
17
|
+
this.#versions.set(key, versionNumber);
|
|
18
|
+
this.#sessions.set(key, structuredClone({
|
|
19
|
+
...next,
|
|
20
|
+
version
|
|
21
|
+
}));
|
|
22
|
+
return Promise.resolve({
|
|
23
|
+
ok: true,
|
|
24
|
+
version
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { MemorySessionStore };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","names":["#sessions","#versions"],"sources":["../../../src/session/store/memory.ts"],"sourcesContent":["import type { CommitResult, SessionStore, StoredSession } from \"./types\";\n\nexport class MemorySessionStore implements SessionStore {\n readonly #sessions = new Map<string, StoredSession>();\n readonly #versions = new Map<string, number>();\n\n load(key: string): Promise<StoredSession | null> {\n const stored = this.#sessions.get(key);\n return Promise.resolve(stored ? structuredClone(stored) : null);\n }\n\n commit(\n key: string,\n next: StoredSession,\n options?: { expectedVersion?: string | null }\n ): Promise<CommitResult> {\n const current = this.#sessions.get(key);\n const currentVersion = current?.version ?? null;\n\n if (\n options?.expectedVersion !== undefined &&\n options.expectedVersion !== currentVersion\n ) {\n return Promise.resolve({ ok: false, reason: \"conflict\" });\n }\n\n const versionNumber = (this.#versions.get(key) ?? 0) + 1;\n const version = String(versionNumber);\n this.#versions.set(key, versionNumber);\n this.#sessions.set(key, structuredClone({ ...next, version }));\n return Promise.resolve({ ok: true, version });\n }\n}\n"],"mappings":";AAEA,IAAa,qBAAb,MAAwD;CACtD,4BAAqB,IAAI,IAA2B;CACpD,4BAAqB,IAAI,IAAoB;CAE7C,KAAK,KAA4C;EAC/C,MAAM,SAAS,KAAKA,UAAU,IAAI,GAAG;EACrC,OAAO,QAAQ,QAAQ,SAAS,gBAAgB,MAAM,IAAI,IAAI;CAChE;CAEA,OACE,KACA,MACA,SACuB;EAEvB,MAAM,iBADU,KAAKA,UAAU,IAAI,GACN,GAAG,WAAW;EAE3C,IACE,SAAS,oBAAoB,KAAA,KAC7B,QAAQ,oBAAoB,gBAE5B,OAAO,QAAQ,QAAQ;GAAE,IAAI;GAAO,QAAQ;EAAW,CAAC;EAG1D,MAAM,iBAAiB,KAAKC,UAAU,IAAI,GAAG,KAAK,KAAK;EACvD,MAAM,UAAU,OAAO,aAAa;EACpC,KAAKA,UAAU,IAAI,KAAK,aAAa;EACrC,KAAKD,UAAU,IAAI,KAAK,gBAAgB;GAAE,GAAG;GAAM;EAAQ,CAAC,CAAC;EAC7D,OAAO,QAAQ,QAAQ;GAAE,IAAI;GAAM;EAAQ,CAAC;CAC9C;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/session/store/types.d.ts
|
|
2
|
+
interface StoredSession {
|
|
3
|
+
state: unknown;
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
type CommitResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
version: string;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: "conflict";
|
|
12
|
+
};
|
|
13
|
+
type ExpectedSessionVersion = string | null;
|
|
14
|
+
interface SessionStore {
|
|
15
|
+
commit(key: string, next: StoredSession, options?: {
|
|
16
|
+
expectedVersion?: ExpectedSessionVersion;
|
|
17
|
+
}): Promise<CommitResult>;
|
|
18
|
+
load(key: string): Promise<StoredSession | null>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CommitResult, ExpectedSessionVersion, SessionStore, StoredSession };
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minpeter/pss-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Generic agent runtime for sessions, model loops, and event streams.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
"@minpeter/pss-source": "./src/index.ts",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./session-store/memory": {
|
|
15
|
+
"@minpeter/pss-source": "./src/session/store/memory.ts",
|
|
16
|
+
"types": "./dist/session/store/memory.d.ts",
|
|
17
|
+
"import": "./dist/session/store/memory.js"
|
|
18
|
+
},
|
|
19
|
+
"./session-store/file": {
|
|
20
|
+
"@minpeter/pss-source": "./src/session/store/file.ts",
|
|
21
|
+
"types": "./dist/session/store/file.d.ts",
|
|
22
|
+
"import": "./dist/session/store/file.js"
|
|
13
23
|
}
|
|
14
24
|
},
|
|
15
25
|
"files": [
|
|
@@ -28,8 +38,12 @@
|
|
|
28
38
|
"dependencies": {
|
|
29
39
|
"ai": "7.0.0-canary.142"
|
|
30
40
|
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"tsdown": "^0.22.0",
|
|
43
|
+
"vitest": "^4.1.6"
|
|
44
|
+
},
|
|
31
45
|
"scripts": {
|
|
32
|
-
"build": "
|
|
46
|
+
"build": "tsdown",
|
|
33
47
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
34
48
|
"test": "vitest run",
|
|
35
49
|
"lint": "ultracite check ."
|
package/dist/agent-loop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../src/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAA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O,CAAC,EAAE,cAAc,GAAG,YAAY;CAGtD"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,SAAS,CAAC;AACnD,OAAO,EAAwB,YAAY,EAAE,MAAM,cAAc,CAAC;AAclE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAWlC,OAAO,EACL,YAAY,GAGb,MAAM,mBAAmB,CAAC"}
|
package/dist/llm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,oB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;AAEzB,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC"}
|
package/dist/session/events.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/session/events.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ModelMessage } from "ai";
|
|
2
|
-
import type { UserText } from "./events";
|
|
3
|
-
export declare class AgentModelHistory {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(history?: ModelMessage[], onChange?: (snapshot: ModelMessage[]) => void);
|
|
6
|
-
modelSnapshot(): ModelMessage[];
|
|
7
|
-
appendUserInput(input: UserText): void;
|
|
8
|
-
appendModelMessage(message: ModelMessage): void;
|
|
9
|
-
rollback(snapshot: ModelMessage[]): void;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=history.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/session/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,qBAAa,iBAAiB;;gBAK1B,OAAO,CAAC,EAAE,YAAY,EAAE,EACxB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,IAAI;IAQ/C,aAAa,IAAI,YAAY,EAAE;IAI/B,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAKtC,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAK/C,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI;CASzC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ModelMessage, UserModelMessage } from "ai";
|
|
2
|
-
import type { AssistantReasoning, AssistantText, ToolCall, ToolResult, UserText } from "./events";
|
|
3
|
-
type ModelEvent = AssistantReasoning | AssistantText | ToolCall | ToolResult;
|
|
4
|
-
export declare function userTextToModelMessage(input: UserText): UserModelMessage;
|
|
5
|
-
export declare function modelMessageToAgentEvents(message: ModelMessage): ModelEvent[];
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/session/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,YAAY,EAEZ,gBAAgB,EACjB,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,UAAU,EACV,QAAQ,EAET,MAAM,UAAU,CAAC;AAIlB,KAAK,UAAU,GAAG,kBAAkB,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAC;AAG7E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,GAAG,gBAAgB,CAExE;AAaD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,EAAE,CAY7E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAc,kBAAkB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAUD,qBAAa,YAAY;;gBAgBX,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc;IAY9C,UAAU,IAAI,YAAY,EAAE;IAI5B,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAKnD,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B1C,SAAS,IAAI,IAAI;IASjB,IAAI,IAAI,IAAI;CAiQb"}
|