vibe-coding-master 0.7.12 → 0.7.13

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.
@@ -1,5 +1,6 @@
1
1
  import { CCR_GATEWAY_BASE_URL, CCR_GPT_MODEL_ID } from "../../shared/types/session.js";
2
2
  const DEFAULT_TIMEOUT_MS = 3_000;
3
+ const CCR_ENCODED_MODEL_PREFIX = "anthropic/claude-ccr-h";
3
4
  export function createCcrGatewayAdapter(deps = {}) {
4
5
  const baseUrl = (deps.baseUrl ?? CCR_GATEWAY_BASE_URL).replace(/\/+$/, "");
5
6
  const fetchImpl = deps.fetch ?? globalThis.fetch;
@@ -32,11 +33,11 @@ export function createCcrGatewayAdapter(deps = {}) {
32
33
  if (!models.response.ok) {
33
34
  return invalidResponse(`CCR model discovery returned HTTP ${models.response.status}.`);
34
35
  }
35
- const modelIds = readModelIds(models.payload);
36
- if (!modelIds) {
36
+ const modelDescriptors = readModelDescriptors(models.payload);
37
+ if (!modelDescriptors) {
37
38
  return invalidResponse("CCR returned an invalid /v1/models response.");
38
39
  }
39
- const modelAvailable = modelIds.includes(CCR_GPT_MODEL_ID);
40
+ const modelAvailable = modelDescriptors.some(isRequiredModel);
40
41
  return {
41
42
  connectionState: "available",
42
43
  modelAvailable,
@@ -91,18 +92,44 @@ function isCcrGateway(value) {
91
92
  || value.plugin === "claude-code-router"
92
93
  || value.core === "next-ai-gateway";
93
94
  }
94
- function readModelIds(value) {
95
+ function readModelDescriptors(value) {
95
96
  if (!isObject(value) || !Array.isArray(value.data)) {
96
97
  return undefined;
97
98
  }
98
- const ids = [];
99
+ const models = [];
99
100
  for (const item of value.data) {
100
101
  if (!isObject(item) || typeof item.id !== "string" || !item.id.trim()) {
101
102
  return undefined;
102
103
  }
103
- ids.push(item.id.trim());
104
+ models.push({
105
+ id: item.id.trim(),
106
+ ...(typeof item.display_name === "string" && item.display_name.trim()
107
+ ? { displayName: item.display_name.trim() }
108
+ : {})
109
+ });
110
+ }
111
+ return models;
112
+ }
113
+ function isRequiredModel(model) {
114
+ if (model.id === CCR_GPT_MODEL_ID) {
115
+ return true;
104
116
  }
105
- return ids;
117
+ const target = normalizeModelName(CCR_GPT_MODEL_ID);
118
+ return normalizeModelName(model.displayName) === target
119
+ || normalizeModelName(decodeCcrModelId(model.id)) === target;
120
+ }
121
+ function decodeCcrModelId(modelId) {
122
+ if (!modelId.startsWith(CCR_ENCODED_MODEL_PREFIX)) {
123
+ return undefined;
124
+ }
125
+ const encoded = modelId.slice(CCR_ENCODED_MODEL_PREFIX.length);
126
+ if (!encoded || encoded.length % 2 !== 0 || !/^[0-9a-f]+$/i.test(encoded)) {
127
+ return undefined;
128
+ }
129
+ return Buffer.from(encoded, "hex").toString("utf8");
130
+ }
131
+ function normalizeModelName(value) {
132
+ return (value ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "");
106
133
  }
107
134
  function invalidResponse(error) {
108
135
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-coding-master",
3
- "version": "0.7.12",
3
+ "version": "0.7.13",
4
4
  "description": "Local GUI session cockpit for Claude Code role sessions.",
5
5
  "type": "module",
6
6
  "files": [