@codelia/runtime 0.1.40 → 0.1.42

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/index.cjs CHANGED
@@ -1737,10 +1737,18 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
1737
1737
  return null;
1738
1738
  }
1739
1739
  const normalized = stripProviderPrefix(provider, model);
1740
+ const providerModelId = (0, import_core2.resolveProviderModelId)(import_core2.DEFAULT_MODEL_REGISTRY, model, provider) ?? normalized;
1741
+ const providerModelNormalized = stripProviderPrefix(
1742
+ provider,
1743
+ providerModelId
1744
+ );
1740
1745
  const directCandidates = [
1741
1746
  model,
1742
1747
  normalized,
1743
- `${provider}/${normalized}`
1748
+ `${provider}/${normalized}`,
1749
+ providerModelId,
1750
+ providerModelNormalized,
1751
+ `${provider}/${providerModelNormalized}`
1744
1752
  ].filter((value, index, array) => array.indexOf(value) === index);
1745
1753
  for (const candidate of directCandidates) {
1746
1754
  const entry = providerEntries[candidate];
@@ -4852,10 +4860,7 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
4852
4860
  const clippedByBytes = clipLineToByteBudget(line, budget);
4853
4861
  if (clippedByBytes.length > 0) {
4854
4862
  outputLines.push(clippedByBytes);
4855
- bytes = Buffer.byteLength(
4856
- `${prefix}${clippedByBytes}`,
4857
- "utf8"
4858
- );
4863
+ bytes = Buffer.byteLength(`${prefix}${clippedByBytes}`, "utf8");
4859
4864
  truncatedLineNumbers.push(index + 1);
4860
4865
  if (firstClippedLineNumber === null) {
4861
4866
  firstClippedLineNumber = index + 1;
@@ -6243,8 +6248,13 @@ var createAgentFactory = (state, options = {}) => {
6243
6248
  switch (provider) {
6244
6249
  case "openai": {
6245
6250
  const modelName = modelConfig.name ?? import_core19.OPENAI_DEFAULT_MODEL;
6251
+ const providerModelName = (0, import_core19.resolveProviderModelId)(
6252
+ import_core19.DEFAULT_MODEL_REGISTRY,
6253
+ modelName,
6254
+ "openai"
6255
+ ) ?? modelName;
6246
6256
  const reasoning = resolveResponsesReasoning({
6247
- model: modelName,
6257
+ model: providerModelName,
6248
6258
  requested: requestedReasoning
6249
6259
  });
6250
6260
  const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
@@ -6252,6 +6262,7 @@ var createAgentFactory = (state, options = {}) => {
6252
6262
  llm = new import_core19.ChatOpenAI({
6253
6263
  clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
6254
6264
  model: modelName,
6265
+ providerModel: providerModelName,
6255
6266
  reasoningEffort: reasoning.effort,
6256
6267
  reasoningLevelRequested: reasoning.requested,
6257
6268
  reasoningLevelApplied: reasoning.applied,
@@ -8083,8 +8094,23 @@ var import_model_metadata3 = require("@codelia/model-metadata");
8083
8094
  var import_protocol4 = require("@codelia/protocol");
8084
8095
  var isSupportedProvider = (provider) => provider === "openai" || provider === "anthropic" || provider === "openrouter";
8085
8096
  var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
8086
- if (!providerEntries) return null;
8087
- return providerEntries[model] ?? providerEntries[`${provider}/${model}`] ?? null;
8097
+ if (!providerEntries) {
8098
+ return null;
8099
+ }
8100
+ const providerModelId = (0, import_core20.resolveProviderModelId)(import_core20.DEFAULT_MODEL_REGISTRY, model, provider) ?? model;
8101
+ const candidates = [
8102
+ model,
8103
+ `${provider}/${model}`,
8104
+ providerModelId,
8105
+ `${provider}/${providerModelId}`
8106
+ ].filter((value, index, array) => array.indexOf(value) === index);
8107
+ for (const candidate of candidates) {
8108
+ const entry = providerEntries[candidate];
8109
+ if (entry) {
8110
+ return entry;
8111
+ }
8112
+ }
8113
+ return null;
8088
8114
  };
8089
8115
  var parseReleaseTimestamp = (entry) => {
8090
8116
  const releaseDate = entry?.releaseDate?.trim();
@@ -8935,12 +8961,12 @@ var createRunHandlers = ({
8935
8961
  }) => {
8936
8962
  let activeRunAbort = null;
8937
8963
  let runStartQueue = Promise.resolve();
8938
- const normalizeRunHistoryAfterCancel = (runId, runtimeAgent) => {
8964
+ const normalizeRuntimeAgentHistory = (label, runtimeAgent) => {
8939
8965
  const currentMessages = runtimeAgent.getHistoryMessages();
8940
8966
  const normalizedMessages = normalizeToolCallHistory(currentMessages);
8941
8967
  if (normalizedMessages !== currentMessages) {
8942
8968
  runtimeAgent.replaceHistoryMessages(normalizedMessages);
8943
- log2(`run.cancel normalized history ${runId}`);
8969
+ log2(`${label} normalized history`);
8944
8970
  }
8945
8971
  };
8946
8972
  const normalizeRestoredSessionMessages = (messages, sessionId) => {
@@ -9011,6 +9037,7 @@ var createRunHandlers = ({
9011
9037
  });
9012
9038
  return;
9013
9039
  }
9040
+ normalizeRuntimeAgentHistory("run.start preflight", runtimeAgent);
9014
9041
  const requestedSessionId = params.session_id?.trim() || void 0;
9015
9042
  let resumeState = null;
9016
9043
  const previousSessionId = state.sessionId;
@@ -9317,7 +9344,7 @@ var createRunHandlers = ({
9317
9344
  maybeDebouncedSessionSave();
9318
9345
  }
9319
9346
  if (state.cancelRequested) {
9320
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9347
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9321
9348
  }
9322
9349
  await queueSessionSave("terminal");
9323
9350
  emitRunSummaryDiagnostics();
@@ -9331,7 +9358,7 @@ var createRunHandlers = ({
9331
9358
  } catch (error) {
9332
9359
  const err = error instanceof Error ? error : new Error(String(error));
9333
9360
  if (state.cancelRequested || isAbortLikeError(err)) {
9334
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9361
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9335
9362
  await queueSessionSave("cancelled");
9336
9363
  emitRunSummaryDiagnostics();
9337
9364
  emitRunStatus(runId, "cancelled", err.message || "cancelled");
@@ -9360,7 +9387,7 @@ var createRunHandlers = ({
9360
9387
  } finally {
9361
9388
  logRunDebug(log2, runId, "stream.finally");
9362
9389
  if (state.cancelRequested) {
9363
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9390
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9364
9391
  }
9365
9392
  await queueSessionSave("finally");
9366
9393
  if (activeRunAbort?.runId === runId) {
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ import {
11
11
  ChatOpenAI,
12
12
  ChatOpenRouter,
13
13
  DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY2,
14
- OPENAI_DEFAULT_MODEL
14
+ OPENAI_DEFAULT_MODEL,
15
+ resolveProviderModelId as resolveProviderModelId2
15
16
  } from "@codelia/core";
16
17
  import { ModelMetadataServiceImpl as ModelMetadataServiceImpl2 } from "@codelia/model-metadata";
17
18
  import { parseApprovalMode as parseApprovalMode2 } from "@codelia/shared-types";
@@ -1724,6 +1725,7 @@ import {
1724
1725
  applyModelMetadata,
1725
1726
  DEFAULT_MODEL_REGISTRY,
1726
1727
  resolveModel,
1728
+ resolveProviderModelId,
1727
1729
  registerModels
1728
1730
  } from "@codelia/core";
1729
1731
  import { ModelMetadataServiceImpl } from "@codelia/model-metadata";
@@ -1737,10 +1739,18 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
1737
1739
  return null;
1738
1740
  }
1739
1741
  const normalized = stripProviderPrefix(provider, model);
1742
+ const providerModelId = resolveProviderModelId(DEFAULT_MODEL_REGISTRY, model, provider) ?? normalized;
1743
+ const providerModelNormalized = stripProviderPrefix(
1744
+ provider,
1745
+ providerModelId
1746
+ );
1740
1747
  const directCandidates = [
1741
1748
  model,
1742
1749
  normalized,
1743
- `${provider}/${normalized}`
1750
+ `${provider}/${normalized}`,
1751
+ providerModelId,
1752
+ providerModelNormalized,
1753
+ `${provider}/${providerModelNormalized}`
1744
1754
  ].filter((value, index, array) => array.indexOf(value) === index);
1745
1755
  for (const candidate of directCandidates) {
1746
1756
  const entry = providerEntries[candidate];
@@ -4852,10 +4862,7 @@ var createReadTool = (sandboxKey) => defineTool8({
4852
4862
  const clippedByBytes = clipLineToByteBudget(line, budget);
4853
4863
  if (clippedByBytes.length > 0) {
4854
4864
  outputLines.push(clippedByBytes);
4855
- bytes = Buffer.byteLength(
4856
- `${prefix}${clippedByBytes}`,
4857
- "utf8"
4858
- );
4865
+ bytes = Buffer.byteLength(`${prefix}${clippedByBytes}`, "utf8");
4859
4866
  truncatedLineNumbers.push(index + 1);
4860
4867
  if (firstClippedLineNumber === null) {
4861
4868
  firstClippedLineNumber = index + 1;
@@ -6243,8 +6250,13 @@ var createAgentFactory = (state, options = {}) => {
6243
6250
  switch (provider) {
6244
6251
  case "openai": {
6245
6252
  const modelName = modelConfig.name ?? OPENAI_DEFAULT_MODEL;
6253
+ const providerModelName = resolveProviderModelId2(
6254
+ DEFAULT_MODEL_REGISTRY2,
6255
+ modelName,
6256
+ "openai"
6257
+ ) ?? modelName;
6246
6258
  const reasoning = resolveResponsesReasoning({
6247
- model: modelName,
6259
+ model: providerModelName,
6248
6260
  requested: requestedReasoning
6249
6261
  });
6250
6262
  const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
@@ -6252,6 +6264,7 @@ var createAgentFactory = (state, options = {}) => {
6252
6264
  llm = new ChatOpenAI({
6253
6265
  clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
6254
6266
  model: modelName,
6267
+ providerModel: providerModelName,
6255
6268
  reasoningEffort: reasoning.effort,
6256
6269
  reasoningLevelRequested: reasoning.requested,
6257
6270
  reasoningLevelApplied: reasoning.applied,
@@ -8100,7 +8113,8 @@ import {
8100
8113
  applyModelMetadata as applyModelMetadata2,
8101
8114
  DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY3,
8102
8115
  listModels,
8103
- resolveModel as resolveModel2
8116
+ resolveModel as resolveModel2,
8117
+ resolveProviderModelId as resolveProviderModelId3
8104
8118
  } from "@codelia/core";
8105
8119
  import { ModelMetadataServiceImpl as ModelMetadataServiceImpl3 } from "@codelia/model-metadata";
8106
8120
  import {
@@ -8108,8 +8122,23 @@ import {
8108
8122
  } from "@codelia/protocol";
8109
8123
  var isSupportedProvider = (provider) => provider === "openai" || provider === "anthropic" || provider === "openrouter";
8110
8124
  var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
8111
- if (!providerEntries) return null;
8112
- return providerEntries[model] ?? providerEntries[`${provider}/${model}`] ?? null;
8125
+ if (!providerEntries) {
8126
+ return null;
8127
+ }
8128
+ const providerModelId = resolveProviderModelId3(DEFAULT_MODEL_REGISTRY3, model, provider) ?? model;
8129
+ const candidates = [
8130
+ model,
8131
+ `${provider}/${model}`,
8132
+ providerModelId,
8133
+ `${provider}/${providerModelId}`
8134
+ ].filter((value, index, array) => array.indexOf(value) === index);
8135
+ for (const candidate of candidates) {
8136
+ const entry = providerEntries[candidate];
8137
+ if (entry) {
8138
+ return entry;
8139
+ }
8140
+ }
8141
+ return null;
8113
8142
  };
8114
8143
  var parseReleaseTimestamp = (entry) => {
8115
8144
  const releaseDate = entry?.releaseDate?.trim();
@@ -8962,12 +8991,12 @@ var createRunHandlers = ({
8962
8991
  }) => {
8963
8992
  let activeRunAbort = null;
8964
8993
  let runStartQueue = Promise.resolve();
8965
- const normalizeRunHistoryAfterCancel = (runId, runtimeAgent) => {
8994
+ const normalizeRuntimeAgentHistory = (label, runtimeAgent) => {
8966
8995
  const currentMessages = runtimeAgent.getHistoryMessages();
8967
8996
  const normalizedMessages = normalizeToolCallHistory(currentMessages);
8968
8997
  if (normalizedMessages !== currentMessages) {
8969
8998
  runtimeAgent.replaceHistoryMessages(normalizedMessages);
8970
- log2(`run.cancel normalized history ${runId}`);
8999
+ log2(`${label} normalized history`);
8971
9000
  }
8972
9001
  };
8973
9002
  const normalizeRestoredSessionMessages = (messages, sessionId) => {
@@ -9038,6 +9067,7 @@ var createRunHandlers = ({
9038
9067
  });
9039
9068
  return;
9040
9069
  }
9070
+ normalizeRuntimeAgentHistory("run.start preflight", runtimeAgent);
9041
9071
  const requestedSessionId = params.session_id?.trim() || void 0;
9042
9072
  let resumeState = null;
9043
9073
  const previousSessionId = state.sessionId;
@@ -9344,7 +9374,7 @@ var createRunHandlers = ({
9344
9374
  maybeDebouncedSessionSave();
9345
9375
  }
9346
9376
  if (state.cancelRequested) {
9347
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9377
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9348
9378
  }
9349
9379
  await queueSessionSave("terminal");
9350
9380
  emitRunSummaryDiagnostics();
@@ -9358,7 +9388,7 @@ var createRunHandlers = ({
9358
9388
  } catch (error) {
9359
9389
  const err = error instanceof Error ? error : new Error(String(error));
9360
9390
  if (state.cancelRequested || isAbortLikeError(err)) {
9361
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9391
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9362
9392
  await queueSessionSave("cancelled");
9363
9393
  emitRunSummaryDiagnostics();
9364
9394
  emitRunStatus(runId, "cancelled", err.message || "cancelled");
@@ -9387,7 +9417,7 @@ var createRunHandlers = ({
9387
9417
  } finally {
9388
9418
  logRunDebug(log2, runId, "stream.finally");
9389
9419
  if (state.cancelRequested) {
9390
- normalizeRunHistoryAfterCancel(runId, runtimeAgent);
9420
+ normalizeRuntimeAgentHistory(`run.cancel ${runId}`, runtimeAgent);
9391
9421
  }
9392
9422
  await queueSessionSave("finally");
9393
9423
  if (activeRunAbort?.runId === runId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codelia/runtime",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20 <25"
@@ -23,14 +23,14 @@
23
23
  "typecheck": "tsc --noEmit"
24
24
  },
25
25
  "dependencies": {
26
- "@codelia/config": "0.1.40",
27
- "@codelia/config-loader": "0.1.40",
28
- "@codelia/core": "0.1.40",
29
- "@codelia/logger": "0.1.40",
30
- "@codelia/model-metadata": "0.1.40",
31
- "@codelia/protocol": "0.1.40",
32
- "@codelia/shared-types": "0.1.40",
33
- "@codelia/storage": "0.1.40",
26
+ "@codelia/config": "0.1.42",
27
+ "@codelia/config-loader": "0.1.42",
28
+ "@codelia/core": "0.1.42",
29
+ "@codelia/logger": "0.1.42",
30
+ "@codelia/model-metadata": "0.1.42",
31
+ "@codelia/protocol": "0.1.42",
32
+ "@codelia/shared-types": "0.1.42",
33
+ "@codelia/storage": "0.1.42",
34
34
  "eventsource-parser": "^3.0.6",
35
35
  "oauth4webapi": "^3.8.4",
36
36
  "zod": "^4.3.5"