@demicodes/provider-claude-code 0.10.2 → 0.11.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/index.mjs +21 -12
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import { join } from "node:path";
14
14
  //#region src/models.ts
15
15
  const DEFAULT_MODELS_DEV_URL = "https://models.dev/api.json";
16
16
  const DEFAULT_MINIMUM_MODEL_VERSION = "4.6";
17
- const MODELS_DEV_CACHE_TTL_MS = 1440 * 60 * 1e3;
17
+ const MODELS_DEV_CACHE_TTL_MS = 864e5;
18
18
  let memoryCache = null;
19
19
  async function listClaudeCodeModels(options = {}) {
20
20
  const fetchImpl = options.fetch ?? fetch;
@@ -202,7 +202,7 @@ function reasoningEfforts(value) {
202
202
  //#endregion
203
203
  //#region src/auth.ts
204
204
  const execFileAsync = promisify(execFile);
205
- const OAUTH_EXPIRY_SKEW_MS = 300 * 1e3;
205
+ const OAUTH_EXPIRY_SKEW_MS = 3e5;
206
206
  /**
207
207
  * Resolves Claude OAuth: explicit token → oauth file → CLAUDE_CODE_OAUTH_TOKEN → keychain.
208
208
  */
@@ -217,9 +217,10 @@ var FileClaudeCodeAuthStore = class {
217
217
  }
218
218
  async status() {
219
219
  try {
220
+ const access = await this.resolveAccess();
220
221
  return {
221
222
  status: "authenticated",
222
- accountLabel: nonEmptyString((await this.resolveAccess()).subscriptionType) ?? "Claude Code"
223
+ accountLabel: nonEmptyString(access.subscriptionType) ?? "Claude Code"
223
224
  };
224
225
  } catch (error) {
225
226
  if (error instanceof ClaudeCodeAuthError && error.code === "auth_missing") return {
@@ -634,12 +635,10 @@ function coldStartInputMessages(items) {
634
635
  text: renderToolUseText(item.toolName, item.input)
635
636
  }]);
636
637
  break;
637
- case "tool_result":
638
- append("assistant", [{
639
- type: "text",
640
- text: renderToolResultText(toolNames.get(item.toolUseId), item)
641
- }]);
642
- break;
638
+ case "tool_result": append("assistant", [{
639
+ type: "text",
640
+ text: renderToolResultText(toolNames.get(item.toolUseId), item)
641
+ }]);
643
642
  }
644
643
  flush();
645
644
  return messages;
@@ -1239,7 +1238,8 @@ function createClaudeWireLog(sessionId) {
1239
1238
  } catch {
1240
1239
  return NULL_WIRE_LOG;
1241
1240
  }
1242
- const path = join(dir, `claude-${sessionId.replace(/[^a-zA-Z0-9_-]/g, "_") || "session"}.jsonl`);
1241
+ const safeSession = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_") || "session";
1242
+ const path = join(dir, `claude-${safeSession}.jsonl`);
1243
1243
  return {
1244
1244
  path,
1245
1245
  record(direction, data) {
@@ -1373,12 +1373,14 @@ function thinkingEffort(thinking) {
1373
1373
  }
1374
1374
  //#endregion
1375
1375
  //#region src/provider.ts
1376
- var ClaudeCodeProvider = class {
1376
+ var ClaudeCodeProvider = class ClaudeCodeProvider {
1377
+ cloneOptions;
1377
1378
  transportFactory;
1378
1379
  quota;
1379
1380
  getActiveCredentialId;
1380
1381
  active = null;
1381
1382
  constructor(options = {}) {
1383
+ this.cloneOptions = options;
1382
1384
  this.transportFactory = options.transportFactory ?? new ClaudeCliTransportFactory({
1383
1385
  claudePath: options.claudePath,
1384
1386
  resolveOAuthAccessToken: options.authStore ? async () => {
@@ -1392,6 +1394,12 @@ var ClaudeCodeProvider = class {
1392
1394
  this.quota = options.quota ?? null;
1393
1395
  this.getActiveCredentialId = options.getActiveCredentialId ?? null;
1394
1396
  }
1397
+ clone() {
1398
+ return new ClaudeCodeProvider({
1399
+ ...this.cloneOptions,
1400
+ transportFactory: this.transportFactory
1401
+ });
1402
+ }
1395
1403
  observeQuotaFromMessage(message) {
1396
1404
  try {
1397
1405
  this.quota?.observeResponse?.({ body: message });
@@ -1808,7 +1816,8 @@ function createClaudeCodeProvider(options = {}) {
1808
1816
  message: "Runtime is checked when a Claude Code request runs"
1809
1817
  }),
1810
1818
  listModels: async () => {
1811
- return applyModelPolicy(await listClaudeCodeModels(), id, options.models);
1819
+ const catalog = await listClaudeCodeModels();
1820
+ return applyModelPolicy(catalog, id, options.models);
1812
1821
  },
1813
1822
  createRuntime: () => new ClaudeCodeProvider(runtimeOptions)
1814
1823
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/provider-claude-code",
3
3
  "description": "Claude Code provider adapter for Demi.",
4
- "version": "0.10.2",
4
+ "version": "0.11.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -11,13 +11,13 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@demicodes/core": "^0.10.2",
15
- "@demicodes/provider": "^0.10.2",
16
- "@demicodes/utils": "^0.10.2"
14
+ "@demicodes/core": "^0.11.0",
15
+ "@demicodes/provider": "^0.11.0",
16
+ "@demicodes/utils": "^0.11.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@demicodes/agent": "^0.10.2",
20
- "@demicodes/shell": "^0.10.2"
19
+ "@demicodes/agent": "^0.11.0",
20
+ "@demicodes/shell": "^0.11.0"
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "main": "./dist/index.mjs",