agentic-server 0.4.0 → 0.5.0

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 CHANGED
@@ -130,6 +130,21 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
130
130
  * [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
131
131
  * [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
132
132
 
133
+ ### 📚 Documentation & Skills
134
+
135
+ * [constructive-skills](https://github.com/constructive-io/constructive-skills): **📖 Platform documentation and AI agent skills** — feature catalog, blueprint reference, SDK guides (i18n, billing, limits, events, uploads, security, entities, search, AI), and deployment guides.
136
+
137
+ Install skills for AI coding agents:
138
+
139
+ ```bash
140
+ # All platform skills (security, blueprints, codegen, billing, etc.)
141
+ npx skills add constructive-io/constructive-skills
142
+
143
+ # Individual repo skills (pgpm, testing, CLI, search, etc.)
144
+ npx skills add https://github.com/constructive-io/constructive --skill pgpm
145
+ npx skills add https://github.com/constructive-io/constructive --skill constructive-testing
146
+ ```
147
+
133
148
  ## Credits
134
149
 
135
150
  **🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
package/esm/index.js CHANGED
@@ -5,6 +5,11 @@
5
5
  * billing metering, and inference logging. Uses @constructive-io/express-context
6
6
  * for tenant-scoped database access.
7
7
  *
8
+ * LLM provider config is resolved per-database via `ctx.useLlm()` (from the
9
+ * llm_module table), falling back to env vars from @constructive-io/llm-env when the module
10
+ * is not provisioned. Discovery and billing are handled by the shared loaders
11
+ * in express-context — no custom caching here.
12
+ *
8
13
  * @example
9
14
  * ```typescript
10
15
  * import express from 'express';
@@ -18,7 +23,4 @@
18
23
  * ```
19
24
  */
20
25
  export { createAgenticRouter } from './router';
21
- export { getEnvOptions } from './env';
22
- export { getAgentDiscovery, getDatabaseConfig, clearAgentCache, clearConfigCache } from './discovery';
23
- export { checkQuota, recordUsage, logInference } from './billing';
24
- export { TtlCache } from './cache';
26
+ export { getEnvVars as getLlmEnvVars, getEnvOptions as getLlmEnvOptions, llmDefaults } from '@constructive-io/llm-env';
package/esm/router.js CHANGED
@@ -12,32 +12,31 @@
12
12
  * All routes require `req.constructive` (from @constructive-io/express-context).
13
13
  * Billing (check_quota + record_usage) and inference logging are automatic
14
14
  * when the billing/inference_log modules are provisioned.
15
+ *
16
+ * LLM provider config is resolved per-database via `ctx.useLlm()` from the
17
+ * llm_module table, falling back to env vars (EMBEDDER_*, CHAT_*) when the
18
+ * module is not provisioned.
15
19
  */
16
- import express, { Router } from 'express';
17
- import { Logger } from '@pgpmjs/logger';
18
20
  import { OllamaAdapter } from '@agentic-kit/ollama';
19
- import { checkQuota, logInference, recordUsage } from './billing';
20
- import { getEnvOptions } from './env';
21
+ import { Logger } from '@pgpmjs/logger';
22
+ import express, { Router } from 'express';
23
+ import { getEnvOptions as getLlmEnvOptions } from '@constructive-io/llm-env';
21
24
  const log = new Logger('agentic-server');
22
- // ─── Helpers ────────────────────────────────────────────────────────────────
23
- function resolveOllamaAdapter() {
24
- const { chat } = getEnvOptions();
25
- if (chat.provider === 'ollama') {
26
- return {
27
- adapter: new OllamaAdapter(chat.baseUrl),
28
- model: chat.model,
29
- baseUrl: chat.baseUrl,
30
- };
25
+ function resolveChatAdapter(llm) {
26
+ const provider = llm?.chatProvider ?? getLlmEnvOptions().chat.provider;
27
+ const model = llm?.chatModel ?? getLlmEnvOptions().chat.model;
28
+ const baseUrl = llm?.chatBaseUrl ?? getLlmEnvOptions().chat.baseUrl;
29
+ if (provider === 'ollama') {
30
+ return { adapter: new OllamaAdapter(baseUrl), model, baseUrl, provider };
31
31
  }
32
32
  return null;
33
33
  }
34
- function resolveEmbeddingAdapter() {
35
- const { embedding } = getEnvOptions();
36
- if (embedding.provider === 'ollama') {
37
- return {
38
- adapter: new OllamaAdapter(embedding.baseUrl),
39
- model: embedding.model,
40
- };
34
+ function resolveEmbeddingAdapter(llm) {
35
+ const provider = llm?.embeddingProvider ?? getLlmEnvOptions().embedding.provider;
36
+ const model = llm?.embeddingModel ?? getLlmEnvOptions().embedding.model;
37
+ const baseUrl = llm?.embeddingBaseUrl ?? getLlmEnvOptions().embedding.baseUrl;
38
+ if (provider === 'ollama') {
39
+ return { adapter: new OllamaAdapter(baseUrl), model, provider };
41
40
  }
42
41
  return null;
43
42
  }
@@ -65,7 +64,7 @@ async function handleCreateThread(req, res, entityId) {
65
64
  body.mode ?? 'ask',
66
65
  body.model ?? null,
67
66
  body.system_prompt ?? null,
68
- body.title ?? null,
67
+ body.title ?? null
69
68
  ]);
70
69
  return rows[0];
71
70
  });
@@ -75,7 +74,7 @@ async function handleCreateThread(req, res, entityId) {
75
74
  model: result.model,
76
75
  system_prompt: result.system_prompt,
77
76
  status: result.status,
78
- created_at: result.created_at,
77
+ created_at: result.created_at
79
78
  });
80
79
  }
81
80
  async function handleSendMessage(req, res, entityId) {
@@ -108,27 +107,23 @@ async function handleSendMessage(req, res, entityId) {
108
107
  res.status(404).json({ error: 'Thread not found' });
109
108
  return;
110
109
  }
111
- // Resolve billing + inference log config via loaders
112
- const [billing, inferenceLog] = await Promise.all([
113
- ctx.useModule('billing'),
114
- ctx.useModule('inferenceLog'),
115
- ]);
116
- const dbConfig = { billing: billing ?? null, inferenceLog: inferenceLog ?? null };
117
- const ollama = resolveOllamaAdapter();
118
- if (!ollama) {
110
+ // Resolve shared billing client and LLM config (lazy, cached per request)
111
+ const [billing, llm] = await Promise.all([ctx.useBilling(), ctx.useLlm()]);
112
+ const chatAdapter = resolveChatAdapter(llm);
113
+ if (!chatAdapter) {
119
114
  res.status(503).json({ error: 'No LLM provider configured' });
120
115
  return;
121
116
  }
122
- const model = body.model ?? threadRow.model ?? ollama.model;
117
+ const model = body.model ?? threadRow.model ?? chatAdapter.model;
123
118
  const meterSlug = model;
124
119
  // Quota check
125
- if (dbConfig.billing) {
126
- const allowed = await checkQuota(ctx, dbConfig.billing, entityId, meterSlug);
120
+ if (billing) {
121
+ const allowed = await billing.checkQuota(meterSlug);
127
122
  if (!allowed) {
128
123
  res.status(429).json({
129
124
  error: 'Token quota exceeded',
130
125
  meter: meterSlug,
131
- entity_id: entityId,
126
+ entity_id: entityId
132
127
  });
133
128
  return;
134
129
  }
@@ -164,7 +159,7 @@ async function handleSendMessage(req, res, entityId) {
164
159
  if (textContent) {
165
160
  llmMessages.push({
166
161
  role: row.author_role === 'user' ? 'user' : 'assistant',
167
- content: textContent,
162
+ content: textContent
168
163
  });
169
164
  }
170
165
  }
@@ -172,44 +167,44 @@ async function handleSendMessage(req, res, entityId) {
172
167
  const shouldStream = body.stream !== false;
173
168
  if (shouldStream) {
174
169
  await handleStreamingResponse(req, res, {
175
- ctx, ollama, model, llmMessages, body,
170
+ ctx, chatAdapter, model, llmMessages, body,
176
171
  entityId, userId, threadId,
177
172
  schemaName, threadTableName, messageTableName,
178
- dbConfig, startTime, meterSlug,
173
+ billing, startTime, meterSlug
179
174
  });
180
175
  }
181
176
  else {
182
177
  await handleBatchResponse(req, res, {
183
- ctx, ollama, model, llmMessages, body,
178
+ ctx, chatAdapter, model, llmMessages, body,
184
179
  entityId, userId, threadId,
185
180
  schemaName, threadTableName, messageTableName,
186
- dbConfig, startTime, meterSlug,
181
+ billing, startTime, meterSlug
187
182
  });
188
183
  }
189
184
  }
190
185
  async function handleStreamingResponse(_req, res, mc) {
191
- const { ctx, ollama, model, llmMessages, body, entityId, userId, threadId, schemaName, threadTableName, messageTableName, dbConfig, startTime, meterSlug } = mc;
186
+ const { ctx, chatAdapter, model, llmMessages, body, entityId, userId, threadId, schemaName, threadTableName, messageTableName, billing, startTime, meterSlug } = mc;
192
187
  res.writeHead(200, {
193
188
  'Content-Type': 'text/event-stream',
194
189
  'Cache-Control': 'no-cache',
195
- 'Connection': 'keep-alive',
196
- 'X-Accel-Buffering': 'no',
190
+ Connection: 'keep-alive',
191
+ 'X-Accel-Buffering': 'no'
197
192
  });
198
193
  const messageId = `msg_${Date.now()}`;
199
194
  try {
200
195
  const systemMsg = llmMessages.find(m => m.role === 'system');
201
196
  const nonSystem = llmMessages.filter(m => m.role !== 'system');
202
- const modelDesc = ollama.adapter.createModel(model, { maxOutputTokens: undefined });
197
+ const modelDesc = chatAdapter.adapter.createModel(model, { maxOutputTokens: undefined });
203
198
  const context = {
204
199
  systemPrompt: systemMsg?.content,
205
200
  messages: nonSystem.map((m) => ({
206
201
  role: m.role,
207
202
  content: m.content,
208
- timestamp: Date.now(),
209
- })),
203
+ timestamp: Date.now()
204
+ }))
210
205
  };
211
- const stream = ollama.adapter.stream(modelDesc, context, {
212
- temperature: body.temperature,
206
+ const stream = chatAdapter.adapter.stream(modelDesc, context, {
207
+ temperature: body.temperature
213
208
  });
214
209
  let streamedContent = '';
215
210
  for await (const event of stream) {
@@ -220,9 +215,9 @@ async function handleStreamingResponse(_req, res, mc) {
220
215
  choices: [{
221
216
  index: 0,
222
217
  delta: { content: event.delta, role: 'assistant' },
223
- finish_reason: null,
218
+ finish_reason: null
224
219
  }],
225
- model,
220
+ model
226
221
  };
227
222
  res.write(`data: ${JSON.stringify(sseEvent)}\n\n`);
228
223
  }
@@ -236,7 +231,7 @@ async function handleStreamingResponse(_req, res, mc) {
236
231
  reasoning: result.usage.reasoning,
237
232
  cacheRead: result.usage.cacheRead,
238
233
  cacheWrite: result.usage.cacheWrite,
239
- totalTokens: result.usage.totalTokens,
234
+ totalTokens: result.usage.totalTokens
240
235
  };
241
236
  res.write('data: [DONE]\n\n');
242
237
  res.end();
@@ -248,25 +243,22 @@ async function handleStreamingResponse(_req, res, mc) {
248
243
  VALUES ($1, $2, (SELECT entity_id FROM "${schemaName}"."${threadTableName}" WHERE id = $1), $3, $4, $5)`, [threadId, userId, 'assistant', JSON.stringify([{ type: 'text', text: content }]), model]);
249
244
  }).catch((err) => log.error('Failed to persist assistant message:', err));
250
245
  }
251
- // Record billing usage (fire-and-forget)
252
- if (dbConfig.billing && usage.totalTokens > 0) {
253
- recordUsage(ctx, dbConfig.billing, entityId, meterSlug, usage.totalTokens, {
246
+ // Record billing usage + inference log (fire-and-forget)
247
+ if (billing && usage.totalTokens > 0) {
248
+ billing.recordUsage(meterSlug, usage.totalTokens, {
254
249
  input_tokens: usage.input,
255
250
  output_tokens: usage.output,
256
251
  cache_read_tokens: usage.cacheRead,
257
252
  cache_write_tokens: usage.cacheWrite,
258
253
  model,
259
254
  latency_ms: latencyMs,
260
- stream: true,
255
+ stream: true
261
256
  }).catch(() => { });
262
- }
263
- // Inference log (fire-and-forget)
264
- if (dbConfig.inferenceLog) {
265
- logInference(ctx, dbConfig.inferenceLog, {
266
- entityId, actorId: userId, model, provider: 'ollama',
257
+ billing.logInference({
258
+ entityId, actorId: userId, model, provider: chatAdapter.provider,
267
259
  service: 'llm', operation: 'chat',
268
260
  inputTokens: usage.input, outputTokens: usage.output,
269
- totalTokens: usage.totalTokens, latencyMs, status: 'ok',
261
+ totalTokens: usage.totalTokens, latencyMs, status: 'ok'
270
262
  }).catch(() => { });
271
263
  }
272
264
  }
@@ -279,20 +271,20 @@ async function handleStreamingResponse(_req, res, mc) {
279
271
  }
280
272
  }
281
273
  async function handleBatchResponse(_req, res, mc) {
282
- const { ctx, ollama, model, llmMessages, body, entityId, userId, threadId, schemaName, threadTableName, messageTableName, dbConfig, startTime, meterSlug } = mc;
274
+ const { ctx, chatAdapter, model, llmMessages, body, entityId, userId, threadId, schemaName, threadTableName, messageTableName, billing, startTime, meterSlug } = mc;
283
275
  const systemMsg = llmMessages.find(m => m.role === 'system');
284
276
  const nonSystem = llmMessages.filter(m => m.role !== 'system');
285
- const modelDesc = ollama.adapter.createModel(model, { maxOutputTokens: undefined });
277
+ const modelDesc = chatAdapter.adapter.createModel(model, { maxOutputTokens: undefined });
286
278
  const context = {
287
279
  systemPrompt: systemMsg?.content,
288
280
  messages: nonSystem.map((m) => ({
289
281
  role: m.role,
290
282
  content: m.content,
291
- timestamp: Date.now(),
292
- })),
283
+ timestamp: Date.now()
284
+ }))
293
285
  };
294
- const stream = ollama.adapter.stream(modelDesc, context, {
295
- temperature: body.temperature,
286
+ const stream = chatAdapter.adapter.stream(modelDesc, context, {
287
+ temperature: body.temperature
296
288
  });
297
289
  const result = await stream.result();
298
290
  const content = result.content
@@ -306,7 +298,7 @@ async function handleBatchResponse(_req, res, mc) {
306
298
  reasoning: result.usage.reasoning,
307
299
  cacheRead: result.usage.cacheRead,
308
300
  cacheWrite: result.usage.cacheWrite,
309
- totalTokens: result.usage.totalTokens,
301
+ totalTokens: result.usage.totalTokens
310
302
  };
311
303
  // Persist assistant message
312
304
  await ctx.withPgClient(async (client) => {
@@ -315,23 +307,21 @@ async function handleBatchResponse(_req, res, mc) {
315
307
  VALUES ($1, $2, (SELECT entity_id FROM "${schemaName}"."${threadTableName}" WHERE id = $1), $3, $4, $5)`, [threadId, userId, 'assistant', JSON.stringify([{ type: 'text', text: content }]), model]);
316
308
  });
317
309
  // Record billing + inference log (fire-and-forget)
318
- if (dbConfig.billing && usage.totalTokens > 0) {
319
- recordUsage(ctx, dbConfig.billing, entityId, meterSlug, usage.totalTokens, {
310
+ if (billing && usage.totalTokens > 0) {
311
+ billing.recordUsage(meterSlug, usage.totalTokens, {
320
312
  input_tokens: usage.input,
321
313
  output_tokens: usage.output,
322
314
  cache_read_tokens: usage.cacheRead,
323
315
  cache_write_tokens: usage.cacheWrite,
324
316
  model,
325
317
  latency_ms: latencyMs,
326
- stream: false,
318
+ stream: false
327
319
  }).catch(() => { });
328
- }
329
- if (dbConfig.inferenceLog) {
330
- logInference(ctx, dbConfig.inferenceLog, {
331
- entityId, actorId: userId, model, provider: 'ollama',
320
+ billing.logInference({
321
+ entityId, actorId: userId, model, provider: chatAdapter.provider,
332
322
  service: 'llm', operation: 'chat',
333
323
  inputTokens: usage.input, outputTokens: usage.output,
334
- totalTokens: usage.totalTokens, latencyMs, status: 'ok',
324
+ totalTokens: usage.totalTokens, latencyMs, status: 'ok'
335
325
  }).catch(() => { });
336
326
  }
337
327
  res.json({
@@ -339,14 +329,14 @@ async function handleBatchResponse(_req, res, mc) {
339
329
  choices: [{
340
330
  index: 0,
341
331
  message: { role: 'assistant', content },
342
- finish_reason: 'stop',
332
+ finish_reason: 'stop'
343
333
  }],
344
334
  model,
345
335
  usage: {
346
336
  prompt_tokens: usage.input,
347
337
  completion_tokens: usage.output,
348
- total_tokens: usage.totalTokens,
349
- },
338
+ total_tokens: usage.totalTokens
339
+ }
350
340
  });
351
341
  }
352
342
  // ─── Embedding Handler ──────────────────────────────────────────────────────
@@ -361,22 +351,19 @@ async function handleEmbed(req, res) {
361
351
  res.status(400).json({ error: 'input is required' });
362
352
  return;
363
353
  }
364
- const embedder = resolveEmbeddingAdapter();
365
- if (!embedder) {
354
+ const llm = await ctx.useLlm();
355
+ const embedAdapter = resolveEmbeddingAdapter(llm);
356
+ if (!embedAdapter) {
366
357
  res.status(503).json({ error: 'No embedding provider configured' });
367
358
  return;
368
359
  }
369
- const model = body.model ?? embedder.model;
360
+ const model = body.model ?? embedAdapter.model;
370
361
  const inputs = Array.isArray(body.input) ? body.input : [body.input];
371
- // Resolve billing + inference log config via loaders
372
- const [billing, inferenceLog] = await Promise.all([
373
- ctx.useModule('billing'),
374
- ctx.useModule('inferenceLog'),
375
- ]);
376
- const dbConfig = { billing: billing ?? null, inferenceLog: inferenceLog ?? null };
362
+ // Resolve shared billing client
363
+ const billing = await ctx.useBilling();
377
364
  // Quota check
378
- if (dbConfig.billing) {
379
- const allowed = await checkQuota(ctx, dbConfig.billing, ctx.userId, model);
365
+ if (billing) {
366
+ const allowed = await billing.checkQuota(model);
380
367
  if (!allowed) {
381
368
  res.status(429).json({ error: 'Embedding quota exceeded', meter: model });
382
369
  return;
@@ -384,31 +371,29 @@ async function handleEmbed(req, res) {
384
371
  }
385
372
  const startTime = Date.now();
386
373
  try {
387
- const results = await Promise.all(inputs.map((text) => embedder.adapter.embed(text, model)));
374
+ const results = await Promise.all(inputs.map((text) => embedAdapter.adapter.embed(text, model)));
388
375
  const latencyMs = Date.now() - startTime;
389
376
  const totalTokens = results.reduce((sum, r) => sum + r.promptTokens, 0);
390
- // Record usage (fire-and-forget)
391
- if (dbConfig.billing && totalTokens > 0) {
392
- recordUsage(ctx, dbConfig.billing, ctx.userId, model, totalTokens, {
377
+ // Record usage + inference log (fire-and-forget)
378
+ if (billing && totalTokens > 0) {
379
+ billing.recordUsage(model, totalTokens, {
393
380
  input_tokens: totalTokens,
394
381
  model,
395
382
  latency_ms: latencyMs,
396
- batch_size: inputs.length,
383
+ batch_size: inputs.length
397
384
  }).catch(() => { });
398
- }
399
- if (dbConfig.inferenceLog) {
400
- logInference(ctx, dbConfig.inferenceLog, {
385
+ billing.logInference({
401
386
  entityId: ctx.userId,
402
387
  actorId: ctx.userId,
403
388
  model,
404
- provider: 'ollama',
389
+ provider: embedAdapter.provider,
405
390
  service: 'embedding',
406
391
  operation: 'embed',
407
392
  inputTokens: totalTokens,
408
393
  outputTokens: 0,
409
394
  totalTokens,
410
395
  latencyMs,
411
- status: 'ok',
396
+ status: 'ok'
412
397
  }).catch(() => { });
413
398
  }
414
399
  res.json({
@@ -416,13 +401,13 @@ async function handleEmbed(req, res) {
416
401
  data: results.map((r, i) => ({
417
402
  object: 'embedding',
418
403
  index: i,
419
- embedding: r.embedding,
404
+ embedding: r.embedding
420
405
  })),
421
406
  model,
422
407
  usage: {
423
408
  prompt_tokens: totalTokens,
424
- total_tokens: totalTokens,
425
- },
409
+ total_tokens: totalTokens
410
+ }
426
411
  });
427
412
  }
428
413
  catch (err) {
package/index.d.ts CHANGED
@@ -5,6 +5,11 @@
5
5
  * billing metering, and inference logging. Uses @constructive-io/express-context
6
6
  * for tenant-scoped database access.
7
7
  *
8
+ * LLM provider config is resolved per-database via `ctx.useLlm()` (from the
9
+ * llm_module table), falling back to env vars from @constructive-io/llm-env when the module
10
+ * is not provisioned. Discovery and billing are handled by the shared loaders
11
+ * in express-context — no custom caching here.
12
+ *
8
13
  * @example
9
14
  * ```typescript
10
15
  * import express from 'express';
@@ -18,10 +23,6 @@
18
23
  * ```
19
24
  */
20
25
  export { createAgenticRouter } from './router';
21
- export { getEnvOptions } from './env';
22
- export type { EnvOptions, ProviderConfig } from './env';
23
- export { getAgentDiscovery, getDatabaseConfig, clearAgentCache, clearConfigCache } from './discovery';
24
- export type { AgentDiscovery, AgentTableInfo, BillingConfig, DatabaseConfig, InferenceLogConfig, } from './discovery';
25
- export { checkQuota, recordUsage, logInference } from './billing';
26
- export type { InferenceLogEntry } from './billing';
27
- export { TtlCache } from './cache';
26
+ export type { BillingClient, InferenceLogEntry, LlmConfig, } from '@constructive-io/express-context';
27
+ export type { LlmEnvOptions, LlmProviderConfig, ResolvedLlmEnvOptions } from '@constructive-io/llm-env';
28
+ export { getEnvVars as getLlmEnvVars, getEnvOptions as getLlmEnvOptions, llmDefaults } from '@constructive-io/llm-env';
package/index.js CHANGED
@@ -6,6 +6,11 @@
6
6
  * billing metering, and inference logging. Uses @constructive-io/express-context
7
7
  * for tenant-scoped database access.
8
8
  *
9
+ * LLM provider config is resolved per-database via `ctx.useLlm()` (from the
10
+ * llm_module table), falling back to env vars from @constructive-io/llm-env when the module
11
+ * is not provisioned. Discovery and billing are handled by the shared loaders
12
+ * in express-context — no custom caching here.
13
+ *
9
14
  * @example
10
15
  * ```typescript
11
16
  * import express from 'express';
@@ -19,19 +24,10 @@
19
24
  * ```
20
25
  */
21
26
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.TtlCache = exports.logInference = exports.recordUsage = exports.checkQuota = exports.clearConfigCache = exports.clearAgentCache = exports.getDatabaseConfig = exports.getAgentDiscovery = exports.getEnvOptions = exports.createAgenticRouter = void 0;
27
+ exports.llmDefaults = exports.getLlmEnvOptions = exports.getLlmEnvVars = exports.createAgenticRouter = void 0;
23
28
  var router_1 = require("./router");
24
29
  Object.defineProperty(exports, "createAgenticRouter", { enumerable: true, get: function () { return router_1.createAgenticRouter; } });
25
- var env_1 = require("./env");
26
- Object.defineProperty(exports, "getEnvOptions", { enumerable: true, get: function () { return env_1.getEnvOptions; } });
27
- var discovery_1 = require("./discovery");
28
- Object.defineProperty(exports, "getAgentDiscovery", { enumerable: true, get: function () { return discovery_1.getAgentDiscovery; } });
29
- Object.defineProperty(exports, "getDatabaseConfig", { enumerable: true, get: function () { return discovery_1.getDatabaseConfig; } });
30
- Object.defineProperty(exports, "clearAgentCache", { enumerable: true, get: function () { return discovery_1.clearAgentCache; } });
31
- Object.defineProperty(exports, "clearConfigCache", { enumerable: true, get: function () { return discovery_1.clearConfigCache; } });
32
- var billing_1 = require("./billing");
33
- Object.defineProperty(exports, "checkQuota", { enumerable: true, get: function () { return billing_1.checkQuota; } });
34
- Object.defineProperty(exports, "recordUsage", { enumerable: true, get: function () { return billing_1.recordUsage; } });
35
- Object.defineProperty(exports, "logInference", { enumerable: true, get: function () { return billing_1.logInference; } });
36
- var cache_1 = require("./cache");
37
- Object.defineProperty(exports, "TtlCache", { enumerable: true, get: function () { return cache_1.TtlCache; } });
30
+ var llm_env_1 = require("@constructive-io/llm-env");
31
+ Object.defineProperty(exports, "getLlmEnvVars", { enumerable: true, get: function () { return llm_env_1.getEnvVars; } });
32
+ Object.defineProperty(exports, "getLlmEnvOptions", { enumerable: true, get: function () { return llm_env_1.getEnvOptions; } });
33
+ Object.defineProperty(exports, "llmDefaults", { enumerable: true, get: function () { return llm_env_1.llmDefaults; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-server",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Standalone Express LLM service — agent threads, chat streaming, billing metering, and inference logging via express-context",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "homepage": "https://github.com/constructive-io/constructive",
@@ -30,7 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@agentic-kit/ollama": "^2.0.0",
33
- "@constructive-io/express-context": "^0.4.0",
33
+ "@constructive-io/express-context": "^0.6.0",
34
+ "@constructive-io/llm-env": "^0.1.1",
34
35
  "@pgpmjs/logger": "^2.12.0",
35
36
  "pg": "^8.21.0",
36
37
  "pg-cache": "^3.12.0"
@@ -57,5 +58,5 @@
57
58
  "metering",
58
59
  "constructive"
59
60
  ],
60
- "gitHead": "0503916f414a3b8a6f6cbe46e03a59988b2f3cb5"
61
+ "gitHead": "16c2ae1c30850db1d71c021346c9d34361361d8e"
61
62
  }
package/router.d.ts CHANGED
@@ -12,6 +12,10 @@
12
12
  * All routes require `req.constructive` (from @constructive-io/express-context).
13
13
  * Billing (check_quota + record_usage) and inference logging are automatic
14
14
  * when the billing/inference_log modules are provisioned.
15
+ *
16
+ * LLM provider config is resolved per-database via `ctx.useLlm()` from the
17
+ * llm_module table, falling back to env vars (EMBEDDER_*, CHAT_*) when the
18
+ * module is not provisioned.
15
19
  */
16
20
  import { Router } from 'express';
17
21
  export declare function createAgenticRouter(): Router;