@rogatio/cli 6.2.0 → 6.3.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.
Files changed (2) hide show
  1. package/dist/node/index.js +53 -5
  2. package/package.json +1 -1
@@ -21706,7 +21706,8 @@ var ENVELOPE_MESSAGE_TYPES = /* @__PURE__ */ new Set([
21706
21706
  "mock.response",
21707
21707
  "ai.complete",
21708
21708
  "ai.stream.chunk",
21709
- "ai.error"
21709
+ "ai.error",
21710
+ "ai.status"
21710
21711
  ]);
21711
21712
  var EnvelopeError = class extends Error {
21712
21713
  constructor(message) {
@@ -23313,9 +23314,36 @@ function createNativeRuntimeController(options) {
23313
23314
  let capability;
23314
23315
  let activePolicy = null;
23315
23316
  const mockTokens = /* @__PURE__ */ new Map();
23317
+ let aiConfigInForce = options.aiProviderConfig ?? null;
23316
23318
  let aiClient;
23317
- if (options.aiProviderConfig) {
23318
- aiClient = createAIClient(options.aiProviderConfig);
23319
+ if (aiConfigInForce) {
23320
+ aiClient = createAIClient(aiConfigInForce);
23321
+ }
23322
+ function isUsableAIProviderConfig(value) {
23323
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
23324
+ return false;
23325
+ }
23326
+ const record = value;
23327
+ return typeof record.providerUrl === "string" && record.providerUrl.length > 0 && typeof record.model === "string" && record.model.length > 0 && typeof record.apiKey === "string" && record.apiKey.length > 0;
23328
+ }
23329
+ function canonicalAIConfig(config) {
23330
+ return config === null ? "null" : JSON.stringify([config.providerUrl, config.model, config.apiKey]);
23331
+ }
23332
+ async function refreshAIProviderConfig() {
23333
+ const reader = options.aiConfigReader;
23334
+ if (!reader) return aiConfigInForce;
23335
+ let next = null;
23336
+ try {
23337
+ const read = await reader();
23338
+ next = isUsableAIProviderConfig(read) ? read : null;
23339
+ } catch {
23340
+ next = null;
23341
+ }
23342
+ if (canonicalAIConfig(next) !== canonicalAIConfig(aiConfigInForce)) {
23343
+ aiConfigInForce = next;
23344
+ aiClient = next ? createAIClient(next) : void 0;
23345
+ }
23346
+ return aiConfigInForce;
23319
23347
  }
23320
23348
  async function bindInterception(current, sessionConfig) {
23321
23349
  if (sessionConfig.pacRoutes.length === 0) {
@@ -23747,7 +23775,23 @@ function createNativeRuntimeController(options) {
23747
23775
  metadata: { state, presetDigest: preset.digest }
23748
23776
  };
23749
23777
  }
23778
+ case "ai.status": {
23779
+ const config = await refreshAIProviderConfig();
23780
+ const metadata = config !== null ? {
23781
+ configured: true,
23782
+ providerUrl: config.providerUrl,
23783
+ model: config.model
23784
+ } : { configured: false };
23785
+ return {
23786
+ protocol: "v1",
23787
+ type: "ai.status",
23788
+ ...requestId !== void 0 ? { requestId } : {},
23789
+ timestamp,
23790
+ metadata
23791
+ };
23792
+ }
23750
23793
  case "ai.complete": {
23794
+ await refreshAIProviderConfig();
23751
23795
  if (!aiClient) {
23752
23796
  return {
23753
23797
  protocol: "v1",
@@ -23765,7 +23809,7 @@ function createNativeRuntimeController(options) {
23765
23809
  try {
23766
23810
  const result = await aiClient.complete({
23767
23811
  messages: [...meta.messages],
23768
- model: meta.model || options.aiProviderConfig?.model || "",
23812
+ model: meta.model || aiConfigInForce?.model || "",
23769
23813
  temperature: meta.temperature,
23770
23814
  responseFormat: meta.responseFormat
23771
23815
  });
@@ -23794,6 +23838,7 @@ function createNativeRuntimeController(options) {
23794
23838
  }
23795
23839
  }
23796
23840
  case "ai.stream.chunk": {
23841
+ await refreshAIProviderConfig();
23797
23842
  if (!aiClient) {
23798
23843
  return {
23799
23844
  protocol: "v1",
@@ -23811,7 +23856,7 @@ function createNativeRuntimeController(options) {
23811
23856
  try {
23812
23857
  for await (const chunk of aiClient.stream({
23813
23858
  messages: [...meta.messages],
23814
- model: meta.model || options.aiProviderConfig?.model || "",
23859
+ model: meta.model || aiConfigInForce?.model || "",
23815
23860
  temperature: meta.temperature
23816
23861
  })) {
23817
23862
  return {
@@ -24331,6 +24376,7 @@ function createNativeHost(options) {
24331
24376
  fileRoot: options.fileRoot,
24332
24377
  ...options.mockPort !== void 0 ? { mockPort: options.mockPort } : {},
24333
24378
  ...options.aiProviderConfig !== void 0 ? { aiProviderConfig: options.aiProviderConfig } : {},
24379
+ ...options.aiConfigReader !== void 0 ? { aiConfigReader: options.aiConfigReader } : {},
24334
24380
  ...options.clock ? { clock: options.clock } : {}
24335
24381
  });
24336
24382
  let faucet = null;
@@ -27262,6 +27308,7 @@ async function runtimeHostCommand(args, options = {}) {
27262
27308
  fileRoot: root,
27263
27309
  ...mockPort !== void 0 ? { mockPort } : {},
27264
27310
  ...aiProviderConfig2 !== null ? { aiProviderConfig: aiProviderConfig2 } : {},
27311
+ aiConfigReader: readProviderConfig,
27265
27312
  onReady: () => console.error(
27266
27313
  "rogatio runtime-host active (deferred, waiting for project)"
27267
27314
  )
@@ -27323,6 +27370,7 @@ async function runtimeHostCommand(args, options = {}) {
27323
27370
  fileRoot: rootDir,
27324
27371
  ...mockPort !== void 0 ? { mockPort } : {},
27325
27372
  ...aiProviderConfig !== null ? { aiProviderConfig } : {},
27373
+ aiConfigReader: readProviderConfig,
27326
27374
  onReady: () => console.error("rogatio runtime-host active")
27327
27375
  });
27328
27376
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first browser request and response rules — editor host, file verification, test runner, and runtime dispatch.",