@intelligo-dev/chat 1.0.0-beta.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/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/body.d.ts +41 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +113 -0
- package/dist/body.js.map +1 -0
- package/dist/client.d.ts +56 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +62 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +195 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +20 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/handler.d.ts +30 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +544 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +19 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +34 -0
- package/dist/messages.js.map +1 -0
- package/dist/quota.d.ts +24 -0
- package/dist/quota.d.ts.map +1 -0
- package/dist/quota.js +41 -0
- package/dist/quota.js.map +1 -0
- package/dist/testing.d.ts +43 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +89 -0
- package/dist/testing.js.map +1 -0
- package/dist/title.d.ts +7 -0
- package/dist/title.d.ts.map +1 -0
- package/dist/title.js +15 -0
- package/dist/title.js.map +1 -0
- package/dist/usage.d.ts +19 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +26 -0
- package/dist/usage.js.map +1 -0
- package/dist/windowing.d.ts +39 -0
- package/dist/windowing.d.ts.map +1 -0
- package/dist/windowing.js +80 -0
- package/dist/windowing.js.map +1 -0
- package/package.json +63 -0
package/dist/messages.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Between the rows core stores and the transcript the AI SDK renders.
|
|
3
|
+
*/
|
|
4
|
+
function isChatRole(role) {
|
|
5
|
+
return role === "system" || role === "user" || role === "assistant";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Stored `messages.parts` is a JSON string (ADR-0009's schema note); a
|
|
9
|
+
* row that fails to parse is dropped rather than failing the whole
|
|
10
|
+
* conversation. Tool-role rows are not part of the UI transcript.
|
|
11
|
+
*/
|
|
12
|
+
export function toUIMessages(rows) {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const row of rows) {
|
|
15
|
+
if (!isChatRole(row.role))
|
|
16
|
+
continue;
|
|
17
|
+
try {
|
|
18
|
+
const parts = JSON.parse(row.parts);
|
|
19
|
+
if (!Array.isArray(parts))
|
|
20
|
+
continue;
|
|
21
|
+
out.push({ id: row.id, role: row.role, parts });
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// A corrupt row costs one message, not the conversation.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/** The last message when it is the user's turn, else null. */
|
|
30
|
+
export function lastUserMessage(messages) {
|
|
31
|
+
const last = messages[messages.length - 1];
|
|
32
|
+
return last?.role === "user" ? last : null;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,WAAW,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAA+B;IAC1D,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACpC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAY,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAS;YACpC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;QAC3D,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,eAAe,CAC7B,QAAkC;IAElC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,OAAO,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC"}
|
package/dist/quota.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the chat page knows about the caller's credit before they type.
|
|
3
|
+
*
|
|
4
|
+
* The transport already refuses a turn it cannot fund — admission runs
|
|
5
|
+
* inside `executions.begin()` and answers 402. That is the correct
|
|
6
|
+
* enforcement point and the wrong place to *tell someone*: by then
|
|
7
|
+
* they have written a message and watched it fail. This is the read
|
|
8
|
+
* that lets the page say so first. An estimate, never a reservation:
|
|
9
|
+
* rendering a page cannot consume credit.
|
|
10
|
+
*/
|
|
11
|
+
import type { ChatQuotaState } from "./client.js";
|
|
12
|
+
/**
|
|
13
|
+
* Never throws: the page renders with or without this. A quota read
|
|
14
|
+
* that fails should cost the reader a banner, not the conversation.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getChatQuotaState(options: {
|
|
17
|
+
/** The model a turn would run on — what the estimate is priced against. */
|
|
18
|
+
modelId: string;
|
|
19
|
+
/** Where "upgrade" and "top up" should go. */
|
|
20
|
+
upgradeHref: string;
|
|
21
|
+
/** Defaults to the request's workspace. */
|
|
22
|
+
workspaceId?: string;
|
|
23
|
+
}): Promise<ChatQuotaState | null>;
|
|
24
|
+
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../src/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAqBjC"}
|
package/dist/quota.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the chat page knows about the caller's credit before they type.
|
|
3
|
+
*
|
|
4
|
+
* The transport already refuses a turn it cannot fund — admission runs
|
|
5
|
+
* inside `executions.begin()` and answers 402. That is the correct
|
|
6
|
+
* enforcement point and the wrong place to *tell someone*: by then
|
|
7
|
+
* they have written a message and watched it fail. This is the read
|
|
8
|
+
* that lets the page say so first. An estimate, never a reservation:
|
|
9
|
+
* rendering a page cannot consume credit.
|
|
10
|
+
*/
|
|
11
|
+
import { requireWorkspace } from "@intelligo-dev/auth";
|
|
12
|
+
import { estimateQuota } from "@intelligo-dev/billing";
|
|
13
|
+
import { createLogger } from "@intelligo-dev/core/logger";
|
|
14
|
+
const log = createLogger("ChatQuota");
|
|
15
|
+
/**
|
|
16
|
+
* Never throws: the page renders with or without this. A quota read
|
|
17
|
+
* that fails should cost the reader a banner, not the conversation.
|
|
18
|
+
*/
|
|
19
|
+
export async function getChatQuotaState(options) {
|
|
20
|
+
try {
|
|
21
|
+
const workspaceId = options.workspaceId ?? (await requireWorkspace()).workspace.id;
|
|
22
|
+
const quota = await estimateQuota(workspaceId, {
|
|
23
|
+
modelId: options.modelId,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
allowed: quota.allowed,
|
|
27
|
+
reason: quota.reason ?? null,
|
|
28
|
+
code: quota.code ?? null,
|
|
29
|
+
remaining: quota.remainingMnt ?? 0,
|
|
30
|
+
estimated: quota.estimatedMnt ?? 0,
|
|
31
|
+
upgradeHref: options.upgradeHref,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
log.warn("quota state unavailable", {
|
|
36
|
+
error: error instanceof Error ? error.message : String(error),
|
|
37
|
+
});
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../src/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAOvC;IACC,IAAI,CAAC;QACH,MAAM,WAAW,GACf,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,gBAAgB,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;QACjE,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE;YAC7C,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;YAC5B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;YACxB,SAAS,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC;YAClC,SAAS,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC;YAClC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE;YAClC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deterministic language model, for a chat that has no API key yet.
|
|
3
|
+
*
|
|
4
|
+
* A fresh install streams end to end — a real `createUIMessageStream`
|
|
5
|
+
* response, token by token — before any provider is configured, and the
|
|
6
|
+
* transport's own tests run against the same thing. Built on the AI
|
|
7
|
+
* SDK's own testing surface (`ai/test`), so it is a real
|
|
8
|
+
* `LanguageModel` as far as `streamText` is concerned.
|
|
9
|
+
*
|
|
10
|
+
* `modelId` is a parameter, never a literal: the execution boundary
|
|
11
|
+
* bills whatever id the transport settles with, and the id has to be
|
|
12
|
+
* one `@intelligo-dev/executions/pricing` knows.
|
|
13
|
+
*/
|
|
14
|
+
import type { LanguageModel } from "ai";
|
|
15
|
+
/** A model prompt as the stub sees it: the AI SDK's provider-level shape. */
|
|
16
|
+
export type StubPrompt = ReadonlyArray<{
|
|
17
|
+
role: string;
|
|
18
|
+
content: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
export type StubToolCall = {
|
|
21
|
+
toolName: string;
|
|
22
|
+
/** Must satisfy the tool's input schema. */
|
|
23
|
+
input: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export type StubLanguageModelOptions = {
|
|
26
|
+
/** Reported to the boundary; must be a registered model id. */
|
|
27
|
+
modelId: string;
|
|
28
|
+
/** The reply, from the last user message's text. */
|
|
29
|
+
reply: (lastUserText: string, prompt: StubPrompt) => string | Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* A tool call to emit alongside the reply, or null for none. Lets a
|
|
32
|
+
* stub exercise the whole tool path — call, execute, render — with
|
|
33
|
+
* no provider. Called once per step; return null on the follow-up
|
|
34
|
+
* step (the prompt then carries the earlier call) to end the turn.
|
|
35
|
+
*/
|
|
36
|
+
toolCall?: (lastUserText: string, prompt: StubPrompt) => StubToolCall | null | Promise<StubToolCall | null>;
|
|
37
|
+
/** Delay between tokens, in ms. Default 15; 0 in tests. */
|
|
38
|
+
chunkDelayInMs?: number;
|
|
39
|
+
};
|
|
40
|
+
/** The last user message's text, from a provider-level prompt. */
|
|
41
|
+
export declare function lastUserTextOf(prompt: StubPrompt): string;
|
|
42
|
+
export declare function createStubLanguageModel(options: StubLanguageModelOptions): LanguageModel;
|
|
43
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGxC,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE3E,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CACT,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,UAAU,KACf,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACxD,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAiCF,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAgBzD;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,aAAa,CA2Df"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deterministic language model, for a chat that has no API key yet.
|
|
3
|
+
*
|
|
4
|
+
* A fresh install streams end to end — a real `createUIMessageStream`
|
|
5
|
+
* response, token by token — before any provider is configured, and the
|
|
6
|
+
* transport's own tests run against the same thing. Built on the AI
|
|
7
|
+
* SDK's own testing surface (`ai/test`), so it is a real
|
|
8
|
+
* `LanguageModel` as far as `streamText` is concerned.
|
|
9
|
+
*
|
|
10
|
+
* `modelId` is a parameter, never a literal: the execution boundary
|
|
11
|
+
* bills whatever id the transport settles with, and the id has to be
|
|
12
|
+
* one `@intelligo-dev/executions/pricing` knows.
|
|
13
|
+
*/
|
|
14
|
+
import { MockLanguageModelV3, simulateReadableStream } from "ai/test";
|
|
15
|
+
/** The last user message's text, from a provider-level prompt. */
|
|
16
|
+
export function lastUserTextOf(prompt) {
|
|
17
|
+
for (let i = prompt.length - 1; i >= 0; i--) {
|
|
18
|
+
const message = prompt[i];
|
|
19
|
+
if (message?.role !== "user")
|
|
20
|
+
continue;
|
|
21
|
+
const parts = Array.isArray(message.content) ? message.content : [];
|
|
22
|
+
return parts
|
|
23
|
+
.filter((part) => typeof part === "object" &&
|
|
24
|
+
part !== null &&
|
|
25
|
+
part.type === "text")
|
|
26
|
+
.map((part) => part.text)
|
|
27
|
+
.join(" ");
|
|
28
|
+
}
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
export function createStubLanguageModel(options) {
|
|
32
|
+
const delay = options.chunkDelayInMs ?? 15;
|
|
33
|
+
return new MockLanguageModelV3({
|
|
34
|
+
provider: "stub",
|
|
35
|
+
modelId: options.modelId,
|
|
36
|
+
doStream: async ({ prompt }) => {
|
|
37
|
+
const userText = lastUserTextOf(prompt);
|
|
38
|
+
const reply = await options.reply(userText, prompt);
|
|
39
|
+
const call = options.toolCall
|
|
40
|
+
? await options.toolCall(userText, prompt)
|
|
41
|
+
: null;
|
|
42
|
+
const words = reply.split(" ");
|
|
43
|
+
const chunks = [
|
|
44
|
+
{ type: "stream-start", warnings: [] },
|
|
45
|
+
{ type: "text-start", id: "1" },
|
|
46
|
+
...words.map((word, index) => ({
|
|
47
|
+
type: "text-delta",
|
|
48
|
+
id: "1",
|
|
49
|
+
delta: index === 0 ? word : ` ${word}`,
|
|
50
|
+
})),
|
|
51
|
+
{ type: "text-end", id: "1" },
|
|
52
|
+
...(call
|
|
53
|
+
? [
|
|
54
|
+
{
|
|
55
|
+
type: "tool-call",
|
|
56
|
+
toolCallId: `stub-${Date.now()}`,
|
|
57
|
+
toolName: call.toolName,
|
|
58
|
+
input: JSON.stringify(call.input),
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
{
|
|
63
|
+
type: "finish",
|
|
64
|
+
finishReason: {
|
|
65
|
+
unified: call ? "tool-calls" : "stop",
|
|
66
|
+
raw: undefined,
|
|
67
|
+
},
|
|
68
|
+
usage: {
|
|
69
|
+
inputTokens: {
|
|
70
|
+
total: Math.max(1, Math.ceil(JSON.stringify(prompt).length / 4)),
|
|
71
|
+
noCache: undefined,
|
|
72
|
+
cacheRead: undefined,
|
|
73
|
+
cacheWrite: undefined,
|
|
74
|
+
},
|
|
75
|
+
outputTokens: {
|
|
76
|
+
total: words.length,
|
|
77
|
+
text: words.length,
|
|
78
|
+
reasoning: undefined,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
return {
|
|
84
|
+
stream: simulateReadableStream({ chunkDelayInMs: delay, chunks }),
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"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"}
|
package/dist/title.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default conversation title: the first line of the opening
|
|
3
|
+
* message, truncated to something a sidebar can list.
|
|
4
|
+
*/
|
|
5
|
+
/** First line, trimmed, truncated — enough to tell history rows apart. */
|
|
6
|
+
export declare function truncateTitle(firstUserText: string): string | null;
|
|
7
|
+
//# sourceMappingURL=title.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../src/title.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMlE"}
|
package/dist/title.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default conversation title: the first line of the opening
|
|
3
|
+
* message, truncated to something a sidebar can list.
|
|
4
|
+
*/
|
|
5
|
+
const MAX_TITLE_LENGTH = 60;
|
|
6
|
+
/** First line, trimmed, truncated — enough to tell history rows apart. */
|
|
7
|
+
export function truncateTitle(firstUserText) {
|
|
8
|
+
const line = firstUserText.trim().split("\n")[0]?.trim();
|
|
9
|
+
if (!line)
|
|
10
|
+
return null;
|
|
11
|
+
return line.length <= MAX_TITLE_LENGTH
|
|
12
|
+
? line
|
|
13
|
+
: `${line.slice(0, MAX_TITLE_LENGTH - 1).trimEnd()}…`;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["../src/title.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IACzD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC,MAAM,IAAI,gBAAgB;QACpC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC;AAC1D,CAAC"}
|
package/dist/usage.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token usage, in the one shape the execution boundary settles.
|
|
3
|
+
*/
|
|
4
|
+
export type TokenUsage = {
|
|
5
|
+
inputTokens?: number;
|
|
6
|
+
outputTokens?: number;
|
|
7
|
+
totalTokens?: number;
|
|
8
|
+
};
|
|
9
|
+
/** The three fields settlement reads, and nothing else a provider adds. */
|
|
10
|
+
export declare function pickUsage(usage: TokenUsage | undefined): TokenUsage;
|
|
11
|
+
/**
|
|
12
|
+
* Whole-run usage from the steps that completed before an abort. A
|
|
13
|
+
* step still in flight is missed — under-counting by at most one step
|
|
14
|
+
* beats charging nothing and leaving the hold to expire.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sumStepUsage(steps: ReadonlyArray<{
|
|
17
|
+
usage?: TokenUsage;
|
|
18
|
+
}>): TokenUsage;
|
|
19
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAMnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,CAAC;IAAE,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC,GAC3C,UAAU,CAQZ"}
|
package/dist/usage.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token usage, in the one shape the execution boundary settles.
|
|
3
|
+
*/
|
|
4
|
+
/** The three fields settlement reads, and nothing else a provider adds. */
|
|
5
|
+
export function pickUsage(usage) {
|
|
6
|
+
return {
|
|
7
|
+
inputTokens: usage?.inputTokens,
|
|
8
|
+
outputTokens: usage?.outputTokens,
|
|
9
|
+
totalTokens: usage?.totalTokens,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whole-run usage from the steps that completed before an abort. A
|
|
14
|
+
* step still in flight is missed — under-counting by at most one step
|
|
15
|
+
* beats charging nothing and leaving the hold to expire.
|
|
16
|
+
*/
|
|
17
|
+
export function sumStepUsage(steps) {
|
|
18
|
+
let inputTokens = 0;
|
|
19
|
+
let outputTokens = 0;
|
|
20
|
+
for (const step of steps) {
|
|
21
|
+
inputTokens += step.usage?.inputTokens ?? 0;
|
|
22
|
+
outputTokens += step.usage?.outputTokens ?? 0;
|
|
23
|
+
}
|
|
24
|
+
return { inputTokens, outputTokens, totalTokens: inputTokens + outputTokens };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,KAA6B;IACrD,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,WAAW;QAC/B,YAAY,EAAE,KAAK,EAAE,YAAY;QACjC,WAAW,EAAE,KAAK,EAAE,WAAW;KAChC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,KAA4C;IAE5C,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,WAAW,IAAI,IAAI,CAAC,KAAK,EAAE,WAAW,IAAI,CAAC,CAAC;QAC5C,YAAY,IAAI,IAAI,CAAC,KAAK,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,GAAG,YAAY,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation windowing: what the model is shown of a long history.
|
|
3
|
+
*
|
|
4
|
+
* `UIMessage`-shaped on purpose — this is the AI SDK's transcript, not
|
|
5
|
+
* persistence (ADR-0009 keeps windowing out of core for that reason).
|
|
6
|
+
* The default `prepareMessages` applies it; an application that wants
|
|
7
|
+
* to summarise what was pruned does so in its own `prepareMessages`,
|
|
8
|
+
* with its own model, and hands the summary back as `system`.
|
|
9
|
+
*/
|
|
10
|
+
import type { UIMessage } from "ai";
|
|
11
|
+
/** The text parts of a message, joined. Tool and file parts contribute nothing. */
|
|
12
|
+
export declare function extractText(parts: ReadonlyArray<unknown>): string;
|
|
13
|
+
/**
|
|
14
|
+
* A cheap token estimate that does not need a tokenizer.
|
|
15
|
+
*
|
|
16
|
+
* Latin text runs about four characters per token; Cyrillic — and
|
|
17
|
+
* most non-Latin scripts — closer to two, because their byte-pair
|
|
18
|
+
* vocabularies are smaller. A single divisor would under-count a
|
|
19
|
+
* Cyrillic transcript by half and window it far too late.
|
|
20
|
+
*/
|
|
21
|
+
export declare function estimateTokenCount(text: string): number;
|
|
22
|
+
export declare function estimateConversationTokens(messages: ReadonlyArray<UIMessage>): number;
|
|
23
|
+
export type ConversationWindowOptions = {
|
|
24
|
+
/** Keep at most this many non-system messages. */
|
|
25
|
+
maxMessages: number;
|
|
26
|
+
/** Also drop from the front until the estimate fits, when set. */
|
|
27
|
+
maxTokens?: number;
|
|
28
|
+
};
|
|
29
|
+
export type ConversationWindow = {
|
|
30
|
+
windowed: UIMessage[];
|
|
31
|
+
pruned: UIMessage[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Keep the most recent messages, always starting the window on a user
|
|
35
|
+
* turn so the model never sees an assistant reply without the message
|
|
36
|
+
* it answered. System messages are never pruned.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyConversationWindow(messages: ReadonlyArray<UIMessage>, options: ConversationWindowOptions): ConversationWindow;
|
|
39
|
+
//# sourceMappingURL=windowing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windowing.d.ts","sourceRoot":"","sources":["../src/windowing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAapC,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,MAAM,CAKjE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASvD;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,GACjC,MAAM,CAYR;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,EAClC,OAAO,EAAE,yBAAyB,GACjC,kBAAkB,CAqBpB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation windowing: what the model is shown of a long history.
|
|
3
|
+
*
|
|
4
|
+
* `UIMessage`-shaped on purpose — this is the AI SDK's transcript, not
|
|
5
|
+
* persistence (ADR-0009 keeps windowing out of core for that reason).
|
|
6
|
+
* The default `prepareMessages` applies it; an application that wants
|
|
7
|
+
* to summarise what was pruned does so in its own `prepareMessages`,
|
|
8
|
+
* with its own model, and hands the summary back as `system`.
|
|
9
|
+
*/
|
|
10
|
+
function isTextPart(part) {
|
|
11
|
+
return (typeof part === "object" &&
|
|
12
|
+
part !== null &&
|
|
13
|
+
part.type === "text" &&
|
|
14
|
+
typeof part.text === "string");
|
|
15
|
+
}
|
|
16
|
+
/** The text parts of a message, joined. Tool and file parts contribute nothing. */
|
|
17
|
+
export function extractText(parts) {
|
|
18
|
+
return parts
|
|
19
|
+
.filter(isTextPart)
|
|
20
|
+
.map((part) => part.text)
|
|
21
|
+
.join(" ");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A cheap token estimate that does not need a tokenizer.
|
|
25
|
+
*
|
|
26
|
+
* Latin text runs about four characters per token; Cyrillic — and
|
|
27
|
+
* most non-Latin scripts — closer to two, because their byte-pair
|
|
28
|
+
* vocabularies are smaller. A single divisor would under-count a
|
|
29
|
+
* Cyrillic transcript by half and window it far too late.
|
|
30
|
+
*/
|
|
31
|
+
export function estimateTokenCount(text) {
|
|
32
|
+
if (!text)
|
|
33
|
+
return 0;
|
|
34
|
+
let nonLatin = 0;
|
|
35
|
+
for (const char of text) {
|
|
36
|
+
const code = char.codePointAt(0) ?? 0;
|
|
37
|
+
if (code > 0x024f)
|
|
38
|
+
nonLatin++;
|
|
39
|
+
}
|
|
40
|
+
const latin = text.length - nonLatin;
|
|
41
|
+
return Math.ceil(latin / 4 + nonLatin / 2);
|
|
42
|
+
}
|
|
43
|
+
export function estimateConversationTokens(messages) {
|
|
44
|
+
let total = 0;
|
|
45
|
+
for (const message of messages) {
|
|
46
|
+
// Tool payloads are not text but still cost tokens; count their
|
|
47
|
+
// serialised size at the Latin rate.
|
|
48
|
+
for (const part of message.parts) {
|
|
49
|
+
total += isTextPart(part)
|
|
50
|
+
? estimateTokenCount(part.text)
|
|
51
|
+
: Math.ceil(JSON.stringify(part).length / 4);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return total;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Keep the most recent messages, always starting the window on a user
|
|
58
|
+
* turn so the model never sees an assistant reply without the message
|
|
59
|
+
* it answered. System messages are never pruned.
|
|
60
|
+
*/
|
|
61
|
+
export function applyConversationWindow(messages, options) {
|
|
62
|
+
const system = messages.filter((message) => message.role === "system");
|
|
63
|
+
const turns = messages.filter((message) => message.role !== "system");
|
|
64
|
+
let start = Math.max(0, turns.length - options.maxMessages);
|
|
65
|
+
if (options.maxTokens !== undefined) {
|
|
66
|
+
while (start < turns.length - 1 &&
|
|
67
|
+
estimateConversationTokens(turns.slice(start)) > options.maxTokens) {
|
|
68
|
+
start++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Open on a user message. If none follows, keep the last turn: a
|
|
72
|
+
// window of nothing is worse than one that opens mid-exchange.
|
|
73
|
+
while (start < turns.length - 1 && turns[start]?.role !== "user")
|
|
74
|
+
start++;
|
|
75
|
+
return {
|
|
76
|
+
windowed: [...system, ...turns.slice(start)],
|
|
77
|
+
pruned: turns.slice(0, start),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=windowing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windowing.js","sourceRoot":"","sources":["../src/windowing.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intelligo-dev/chat",
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/intelligo-mn/framework.git",
|
|
8
|
+
"directory": "packages/chat"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/intelligo-mn/framework#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/intelligo-mn/framework/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./client": {
|
|
21
|
+
"types": "./dist/client.d.ts",
|
|
22
|
+
"default": "./dist/client.js"
|
|
23
|
+
},
|
|
24
|
+
"./testing": {
|
|
25
|
+
"types": "./dist/testing.d.ts",
|
|
26
|
+
"default": "./dist/testing.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@intelligo-dev/auth": "1.0.0-beta.5",
|
|
31
|
+
"@intelligo-dev/core": "1.0.0-beta.5",
|
|
32
|
+
"@intelligo-dev/executions": "1.0.0-beta.5",
|
|
33
|
+
"@intelligo-dev/billing": "1.0.0-beta.5"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.0.0",
|
|
37
|
+
"ai": "^6.0.77",
|
|
38
|
+
"typescript": "^5.7.2",
|
|
39
|
+
"zod": "^3.24.1"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"README.md",
|
|
45
|
+
"!dist/**/*.tsbuildinfo"
|
|
46
|
+
],
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"ai": "^6.0.0",
|
|
52
|
+
"zod": "^3.24.1"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=22"
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": false,
|
|
58
|
+
"scripts": {
|
|
59
|
+
"type-check": "tsc --noEmit",
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/fix-esm-extensions.mjs dist"
|
|
62
|
+
}
|
|
63
|
+
}
|