@camstack/addon-ai 0.2.21 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +41361 -2621
- package/dist/addon.mjs +41358 -2570
- package/dist/chunk-CVvi-lCc.js +50 -0
- package/dist/{ensure-llama-server-CwEkUUrD.js → ensure-llama-server-DMb1lte3.js} +0 -0
- package/dist/{ensure-llama-server-Dmh3cZ41.mjs → ensure-llama-server-v65evjK2.mjs} +0 -0
- package/dist/index.js +21 -17
- package/dist/index.mjs +4 -5
- package/dist/token-BDEeGrwn.mjs +55 -0
- package/dist/token-DFiSYbCl.js +60 -0
- package/dist/{usage-store-8hfWI98H.js → usage-store-Q34FDPSq.js} +12 -1
- package/dist/{usage-store-1FrTJdpU.mjs → usage-store-RiVXP_ma.mjs} +11 -2
- package/package.json +6 -1
- package/dist/execute-plan-KbxnOqY1.mjs +0 -41
- package/dist/execute-plan-gwFcJjeV.js +0 -51
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
//#endregion
|
|
33
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function() {
|
|
36
|
+
return __commonJSMin;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function() {
|
|
42
|
+
return __exportAll;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "__toESM", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return __toESM;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
Binary file
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -3,39 +3,43 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_addon = require("./addon.js");
|
|
6
|
-
const
|
|
7
|
-
const require_usage_store = require("./usage-store-
|
|
8
|
-
const require_ensure_llama_server = require("./ensure-llama-server-CwEkUUrD.js");
|
|
6
|
+
const require_ensure_llama_server = require("./ensure-llama-server-DMb1lte3.js");
|
|
7
|
+
const require_usage_store = require("./usage-store-Q34FDPSq.js");
|
|
9
8
|
exports.AI_ADDON_ID = require_addon.AI_ADDON_ID;
|
|
10
9
|
exports.AiAddon = require_addon.AiAddon;
|
|
11
10
|
exports.BUDGETS_COLLECTION = require_usage_store.BUDGETS_COLLECTION;
|
|
12
|
-
exports.
|
|
11
|
+
exports.CONSUMER_RETRY_POLICY = require_addon.CONSUMER_RETRY_POLICY;
|
|
13
12
|
exports.LLAMA_SERVER_VERSION = require_ensure_llama_server.LLAMA_SERVER_VERSION;
|
|
14
13
|
exports.LLM_MODEL_CATALOG = require_addon.LLM_MODEL_CATALOG;
|
|
15
14
|
exports.LlamaSupervisor = require_addon.LlamaSupervisor;
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
15
|
+
exports.TEST_CHAT_CONNECT_TIMEOUT_MS = require_addon.TEST_CHAT_CONNECT_TIMEOUT_MS;
|
|
16
|
+
exports.TEST_CHAT_CONSUMER = require_addon.TEST_CHAT_CONSUMER;
|
|
17
|
+
exports.TEST_CHAT_DEFAULT_FIRST_TOKEN_TIMEOUT_MS = require_addon.TEST_CHAT_DEFAULT_FIRST_TOKEN_TIMEOUT_MS;
|
|
18
|
+
exports.TEST_CHAT_IDLE_TIMEOUT_MS = require_addon.TEST_CHAT_IDLE_TIMEOUT_MS;
|
|
19
|
+
exports.TEST_CHAT_MAX_FIRST_TOKEN_TIMEOUT_MS = require_addon.TEST_CHAT_MAX_FIRST_TOKEN_TIMEOUT_MS;
|
|
20
|
+
exports.TEST_CHAT_MIN_VISION_INPUT_TOKENS = require_addon.TEST_CHAT_MIN_VISION_INPUT_TOKENS;
|
|
21
|
+
exports.TEST_CHAT_PREFIX = require_addon.TEST_CHAT_PREFIX;
|
|
22
|
+
exports.TRACK_MEDIA_PREFERENCE = require_addon.TRACK_MEDIA_PREFERENCE;
|
|
23
|
+
exports.TestChatEventSchema = require_addon.TestChatEventSchema;
|
|
24
|
+
exports.TestChatRequestSchema = require_addon.TestChatRequestSchema;
|
|
20
25
|
exports.USAGE_COLLECTION = require_usage_store.USAGE_COLLECTION;
|
|
21
26
|
exports.UsageStore = require_usage_store.UsageStore;
|
|
22
|
-
exports.anthropicAdapter = require_addon.anthropicAdapter;
|
|
23
|
-
exports.assembleAi = require_addon.assembleAi;
|
|
24
27
|
exports.catalogById = require_addon.catalogById;
|
|
25
28
|
exports.createApiSettingsStorePort = require_addon.createApiSettingsStorePort;
|
|
26
29
|
exports.createDefaultModelOps = require_addon.createDefaultModelOps;
|
|
27
|
-
exports.
|
|
30
|
+
exports.createLlmClient = require_addon.createLlmClient;
|
|
28
31
|
exports.createLlmProvider = require_addon.createLlmProvider;
|
|
29
32
|
exports.createLlmRuntimeProvider = require_addon.createLlmRuntimeProvider;
|
|
30
33
|
exports.createMemorySettingsStorePort = require_addon.createMemorySettingsStorePort;
|
|
31
34
|
exports.createRuntimeClient = require_addon.createRuntimeClient;
|
|
35
|
+
exports.createTestChatPlaneHandler = require_addon.createTestChatPlaneHandler;
|
|
32
36
|
exports.default = require_addon.AiAddon;
|
|
37
|
+
exports.encodeEvent = require_addon.encodeEvent;
|
|
33
38
|
exports.ensureLlamaServer = require_ensure_llama_server.ensureLlamaServer;
|
|
34
39
|
exports.entryForRef = require_addon.entryForRef;
|
|
35
|
-
exports.googleAdapter = require_addon.googleAdapter;
|
|
36
40
|
exports.llamaServerAsset = require_ensure_llama_server.llamaServerAsset;
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.
|
|
41
|
+
exports.pickTrackMedia = require_addon.pickTrackMedia;
|
|
42
|
+
exports.renderTranscript = require_addon.renderTranscript;
|
|
43
|
+
exports.resolveImage = require_addon.resolveImage;
|
|
44
|
+
exports.resolveRetryPolicy = require_addon.resolveRetryPolicy;
|
|
45
|
+
exports.runTestChatStream = require_addon.runTestChatStream;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AiAddon, C as
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as USAGE_COLLECTION, r as UsageStore, t as BUDGETS_COLLECTION } from "./usage-store-
|
|
4
|
-
|
|
5
|
-
export { AI_ADDON_ID, AiAddon, AiAddon as default, BUDGETS_COLLECTION, DefaultsStore, LLAMA_SERVER_VERSION, LLM_MODEL_CATALOG, LlamaSupervisor, PROFILES_COLLECTION, ProfileStore, REDACTED_MARKER, SEED_PROFILE_ID, USAGE_COLLECTION, UsageStore, anthropicAdapter, assembleAi, catalogById, createApiSettingsStorePort, createDefaultModelOps, createFetchExecutor, createLlmProvider, createLlmRuntimeProvider, createMemorySettingsStorePort, createRuntimeClient, ensureLlamaServer, entryForRef, googleAdapter, llamaServerAsset, mergeProfileSecrets, openAiAdapter, openAiCompatibleAdapter, redactProfileForRead, resolveProfile };
|
|
1
|
+
import { A as resolveRetryPolicy, AiAddon, C as createDefaultModelOps, D as AI_ADDON_ID, E as entryForRef, O as createLlmProvider, T as catalogById, _ as createApiSettingsStorePort, a as renderTranscript, b as createRuntimeClient, c as TEST_CHAT_CONSUMER, d as TEST_CHAT_MAX_FIRST_TOKEN_TIMEOUT_MS, f as TEST_CHAT_MIN_VISION_INPUT_TOKENS, g as encodeEvent, h as TestChatRequestSchema, i as pickTrackMedia, j as createLlmClient, k as CONSUMER_RETRY_POLICY, l as TEST_CHAT_DEFAULT_FIRST_TOKEN_TIMEOUT_MS, m as TestChatEventSchema, n as runTestChatStream, o as resolveImage, p as TEST_CHAT_PREFIX, r as TRACK_MEDIA_PREFERENCE, s as TEST_CHAT_CONNECT_TIMEOUT_MS, t as createTestChatPlaneHandler, u as TEST_CHAT_IDLE_TIMEOUT_MS, v as createMemorySettingsStorePort, w as LLM_MODEL_CATALOG, x as createLlmRuntimeProvider, y as LlamaSupervisor } from "./addon.mjs";
|
|
2
|
+
import { i as llamaServerAsset, n as ensureLlamaServer, t as LLAMA_SERVER_VERSION } from "./ensure-llama-server-v65evjK2.mjs";
|
|
3
|
+
import { n as USAGE_COLLECTION, r as UsageStore, t as BUDGETS_COLLECTION } from "./usage-store-RiVXP_ma.mjs";
|
|
4
|
+
export { AI_ADDON_ID, AiAddon, AiAddon as default, BUDGETS_COLLECTION, CONSUMER_RETRY_POLICY, LLAMA_SERVER_VERSION, LLM_MODEL_CATALOG, LlamaSupervisor, TEST_CHAT_CONNECT_TIMEOUT_MS, TEST_CHAT_CONSUMER, TEST_CHAT_DEFAULT_FIRST_TOKEN_TIMEOUT_MS, TEST_CHAT_IDLE_TIMEOUT_MS, TEST_CHAT_MAX_FIRST_TOKEN_TIMEOUT_MS, TEST_CHAT_MIN_VISION_INPUT_TOKENS, TEST_CHAT_PREFIX, TRACK_MEDIA_PREFERENCE, TestChatEventSchema, TestChatRequestSchema, USAGE_COLLECTION, UsageStore, catalogById, createApiSettingsStorePort, createDefaultModelOps, createLlmClient, createLlmProvider, createLlmRuntimeProvider, createMemorySettingsStorePort, createRuntimeClient, createTestChatPlaneHandler, encodeEvent, ensureLlamaServer, entryForRef, llamaServerAsset, pickTrackMedia, renderTranscript, resolveImage, resolveRetryPolicy, runTestChatStream };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { B as __commonJSMin, M as require_token_util, N as require_token_error } from "./addon.mjs";
|
|
2
|
+
//#region ../../node_modules/@vercel/oidc/dist/token.js
|
|
3
|
+
var require_token = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var token_exports = {};
|
|
25
|
+
__export(token_exports, { refreshToken: () => refreshToken });
|
|
26
|
+
module.exports = __toCommonJS(token_exports);
|
|
27
|
+
var import_token_error = require_token_error();
|
|
28
|
+
var import_token_util = require_token_util();
|
|
29
|
+
async function refreshToken(options) {
|
|
30
|
+
let projectId = options?.project;
|
|
31
|
+
let teamId = options?.team;
|
|
32
|
+
if (!projectId && !teamId) {
|
|
33
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
34
|
+
projectId = projectInfo.projectId;
|
|
35
|
+
teamId = projectInfo.teamId;
|
|
36
|
+
} else if (!projectId || !teamId) {
|
|
37
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
38
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
39
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
40
|
+
}
|
|
41
|
+
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
42
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
43
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
44
|
+
const authToken = await (0, import_token_util.getVercelToken)({ expirationBufferMs: options?.expirationBufferMs });
|
|
45
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
46
|
+
if (!maybeToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
47
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
48
|
+
}
|
|
49
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
50
|
+
}
|
|
51
|
+
0 && (module.exports = { refreshToken });
|
|
52
|
+
}));
|
|
53
|
+
//#endregion
|
|
54
|
+
export default require_token();
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-CVvi-lCc.js");
|
|
2
|
+
const require_addon = require("./addon.js");
|
|
3
|
+
//#region ../../node_modules/@vercel/oidc/dist/token.js
|
|
4
|
+
var require_token = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var token_exports = {};
|
|
26
|
+
__export(token_exports, { refreshToken: () => refreshToken });
|
|
27
|
+
module.exports = __toCommonJS(token_exports);
|
|
28
|
+
var import_token_error = require_addon.require_token_error();
|
|
29
|
+
var import_token_util = require_addon.require_token_util();
|
|
30
|
+
async function refreshToken(options) {
|
|
31
|
+
let projectId = options?.project;
|
|
32
|
+
let teamId = options?.team;
|
|
33
|
+
if (!projectId && !teamId) {
|
|
34
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
35
|
+
projectId = projectInfo.projectId;
|
|
36
|
+
teamId = projectInfo.teamId;
|
|
37
|
+
} else if (!projectId || !teamId) {
|
|
38
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
39
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
40
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
41
|
+
}
|
|
42
|
+
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
43
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
44
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
45
|
+
const authToken = await (0, import_token_util.getVercelToken)({ expirationBufferMs: options?.expirationBufferMs });
|
|
46
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
47
|
+
if (!maybeToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
48
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
49
|
+
}
|
|
50
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
51
|
+
}
|
|
52
|
+
0 && (module.exports = { refreshToken });
|
|
53
|
+
}));
|
|
54
|
+
//#endregion
|
|
55
|
+
Object.defineProperty(exports, "default", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function() {
|
|
58
|
+
return require_token();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-CVvi-lCc.js");
|
|
1
2
|
const require_addon = require("./addon.js");
|
|
2
3
|
let node_crypto = require("node:crypto");
|
|
3
4
|
//#region src/usage/usage-store.ts
|
|
@@ -8,12 +9,22 @@ let node_crypto = require("node:crypto");
|
|
|
8
9
|
* schema only). Query-then-filter/group in JS is deliberate: LLM call volume is
|
|
9
10
|
* low and rows are pruned at 90d.
|
|
10
11
|
*/
|
|
11
|
-
var usage_store_exports = /* @__PURE__ */
|
|
12
|
+
var usage_store_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
12
13
|
BUDGETS_COLLECTION: () => BUDGETS_COLLECTION,
|
|
13
14
|
USAGE_COLLECTION: () => USAGE_COLLECTION,
|
|
14
15
|
UsageStore: () => UsageStore
|
|
15
16
|
});
|
|
17
|
+
/**
|
|
18
|
+
* @durable class=audit owner=ai
|
|
19
|
+
* write="one row per completed LLM call — consumer, profile, kind, token counts, latency and error code"
|
|
20
|
+
* retention="pruned at 90 days (USAGE_RETENTION_DAYS), 15s after boot and every 24h thereafter — the one collection here that actually ages out. Losing it loses cost history, nothing the system reads back."
|
|
21
|
+
*/
|
|
16
22
|
var USAGE_COLLECTION = "ai:usage";
|
|
23
|
+
/**
|
|
24
|
+
* @durable class=config owner=ai
|
|
25
|
+
* write="NOTHING writes it today — the collection is declared and its columns exist, but budget enforcement is unimplemented and no call site inserts or updates a row"
|
|
26
|
+
* retention="none — an empty table cannot be pruned. It is listed here so its emptiness is a RECORDED decision: a zero-row store is the highest-risk annotation candidate, not a removal candidate (both cold-start bugs D132 closed were found in state that was empty and unexamined)."
|
|
27
|
+
*/
|
|
17
28
|
var BUDGETS_COLLECTION = "ai:budgets";
|
|
18
29
|
var USAGE_COLUMNS = [
|
|
19
30
|
{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as object, D as LlmProfileKindSchema, E as LlmErrorCodeSchema, O as boolean, j as string, k as number } from "./addon.mjs";
|
|
1
|
+
import { F as LlmProfileKindSchema, I as boolean, L as number, P as LlmErrorCodeSchema, R as object, V as __exportAll, z as string } from "./addon.mjs";
|
|
3
2
|
import { randomUUID } from "node:crypto";
|
|
4
3
|
//#region src/usage/usage-store.ts
|
|
5
4
|
/**
|
|
@@ -14,7 +13,17 @@ var usage_store_exports = /* @__PURE__ */ __exportAll({
|
|
|
14
13
|
USAGE_COLLECTION: () => USAGE_COLLECTION,
|
|
15
14
|
UsageStore: () => UsageStore
|
|
16
15
|
});
|
|
16
|
+
/**
|
|
17
|
+
* @durable class=audit owner=ai
|
|
18
|
+
* write="one row per completed LLM call — consumer, profile, kind, token counts, latency and error code"
|
|
19
|
+
* retention="pruned at 90 days (USAGE_RETENTION_DAYS), 15s after boot and every 24h thereafter — the one collection here that actually ages out. Losing it loses cost history, nothing the system reads back."
|
|
20
|
+
*/
|
|
17
21
|
var USAGE_COLLECTION = "ai:usage";
|
|
22
|
+
/**
|
|
23
|
+
* @durable class=config owner=ai
|
|
24
|
+
* write="NOTHING writes it today — the collection is declared and its columns exist, but budget enforcement is unimplemented and no call site inserts or updates a row"
|
|
25
|
+
* retention="none — an empty table cannot be pruned. It is listed here so its emptiness is a RECORDED decision: a zero-row store is the highest-risk annotation candidate, not a removal candidate (both cold-start bugs D132 closed were found in state that was empty and unexamined)."
|
|
26
|
+
*/
|
|
18
27
|
var BUDGETS_COLLECTION = "ai:budgets";
|
|
19
28
|
var USAGE_COLUMNS = [
|
|
20
29
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-ai",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "AI addon for CamStack — the `llm` collection provider (cloud, LAN, and camstack-managed local llama.cpp profiles) plus the per-node `llm-runtime` managed executor.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|
|
@@ -63,7 +63,12 @@
|
|
|
63
63
|
"@camstack/types": "*"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"@ai-sdk/anthropic": "4.0.38",
|
|
67
|
+
"@ai-sdk/google": "4.0.44",
|
|
68
|
+
"@ai-sdk/openai": "4.0.41",
|
|
69
|
+
"@ai-sdk/openai-compatible": "3.0.30",
|
|
66
70
|
"@camstack/system": "*",
|
|
71
|
+
"ai": "7.0.65",
|
|
67
72
|
"zod": "^4.3.6"
|
|
68
73
|
},
|
|
69
74
|
"devDependencies": {
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
//#region src/http/execute-plan.ts
|
|
3
|
-
var execute_plan_exports = /* @__PURE__ */ __exportAll({ createFetchExecutor: () => createFetchExecutor });
|
|
4
|
-
var MAX_RESPONSE_BODY_CHARS = 4 * 1024 * 1024;
|
|
5
|
-
function createFetchExecutor(fetchImpl = fetch) {
|
|
6
|
-
return async (plan, timeoutMs) => {
|
|
7
|
-
const controller = new AbortController();
|
|
8
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
9
|
-
try {
|
|
10
|
-
const res = await fetchImpl(plan.url, {
|
|
11
|
-
method: plan.method ?? "POST",
|
|
12
|
-
headers: plan.headers,
|
|
13
|
-
body: plan.body === void 0 ? void 0 : JSON.stringify(plan.body),
|
|
14
|
-
signal: controller.signal
|
|
15
|
-
});
|
|
16
|
-
const bodyText = (await res.text()).slice(0, MAX_RESPONSE_BODY_CHARS);
|
|
17
|
-
const headers = {};
|
|
18
|
-
res.headers.forEach((value, key) => {
|
|
19
|
-
headers[key.toLowerCase()] = value;
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
kind: "response",
|
|
23
|
-
response: {
|
|
24
|
-
status: res.status,
|
|
25
|
-
headers,
|
|
26
|
-
bodyText
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
} catch (err) {
|
|
30
|
-
if (err instanceof Error && err.name === "AbortError") return { kind: "timeout" };
|
|
31
|
-
return {
|
|
32
|
-
kind: "network",
|
|
33
|
-
message: err instanceof Error ? err.message : String(err)
|
|
34
|
-
};
|
|
35
|
-
} finally {
|
|
36
|
-
clearTimeout(timer);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
export { execute_plan_exports as n, createFetchExecutor as t };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//#region src/http/execute-plan.ts
|
|
2
|
-
var execute_plan_exports = /* @__PURE__ */ require("./addon.js").__exportAll({ createFetchExecutor: () => createFetchExecutor });
|
|
3
|
-
var MAX_RESPONSE_BODY_CHARS = 4 * 1024 * 1024;
|
|
4
|
-
function createFetchExecutor(fetchImpl = fetch) {
|
|
5
|
-
return async (plan, timeoutMs) => {
|
|
6
|
-
const controller = new AbortController();
|
|
7
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
8
|
-
try {
|
|
9
|
-
const res = await fetchImpl(plan.url, {
|
|
10
|
-
method: plan.method ?? "POST",
|
|
11
|
-
headers: plan.headers,
|
|
12
|
-
body: plan.body === void 0 ? void 0 : JSON.stringify(plan.body),
|
|
13
|
-
signal: controller.signal
|
|
14
|
-
});
|
|
15
|
-
const bodyText = (await res.text()).slice(0, MAX_RESPONSE_BODY_CHARS);
|
|
16
|
-
const headers = {};
|
|
17
|
-
res.headers.forEach((value, key) => {
|
|
18
|
-
headers[key.toLowerCase()] = value;
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
kind: "response",
|
|
22
|
-
response: {
|
|
23
|
-
status: res.status,
|
|
24
|
-
headers,
|
|
25
|
-
bodyText
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
} catch (err) {
|
|
29
|
-
if (err instanceof Error && err.name === "AbortError") return { kind: "timeout" };
|
|
30
|
-
return {
|
|
31
|
-
kind: "network",
|
|
32
|
-
message: err instanceof Error ? err.message : String(err)
|
|
33
|
-
};
|
|
34
|
-
} finally {
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
Object.defineProperty(exports, "createFetchExecutor", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function() {
|
|
43
|
-
return createFetchExecutor;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, "execute_plan_exports", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function() {
|
|
49
|
-
return execute_plan_exports;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) __defProp(target, name, {
|
|
6
|
-
get: all[name],
|
|
7
|
-
enumerable: true
|
|
8
|
-
});
|
|
9
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
-
return target;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { __exportAll as t };
|