@costrict/cs 2.0.2 → 2.0.3

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/bundle/gemini.js CHANGED
@@ -91151,19 +91151,19 @@ var init_debugLogger = __esm({
91151
91151
  log(...args2) {
91152
91152
  this.writeToFile("LOG", args2);
91153
91153
  if (this.debugEnabled) {
91154
- console.log(...args2);
91154
+ console.debug(...args2);
91155
91155
  }
91156
91156
  }
91157
91157
  warn(...args2) {
91158
91158
  this.writeToFile("WARN", args2);
91159
91159
  if (this.debugEnabled) {
91160
- console.warn(...args2);
91160
+ console.debug(...args2);
91161
91161
  }
91162
91162
  }
91163
91163
  error(...args2) {
91164
91164
  this.writeToFile("ERROR", args2);
91165
91165
  if (this.debugEnabled) {
91166
- console.error(...args2);
91166
+ console.debug(...args2);
91167
91167
  }
91168
91168
  }
91169
91169
  debug(...args2) {
@@ -109319,7 +109319,9 @@ var init_tools = __esm({
109319
109319
  timeoutId = void 0;
109320
109320
  }
109321
109321
  abortSignal.removeEventListener("abort", abortHandler);
109322
- this.messageBus?.unsubscribe(MessageBusType.TOOL_CONFIRMATION_RESPONSE, responseHandler);
109322
+ if (this.messageBus && typeof this.messageBus.unsubscribe === "function") {
109323
+ this.messageBus.unsubscribe(MessageBusType.TOOL_CONFIRMATION_RESPONSE, responseHandler);
109324
+ }
109323
109325
  };
109324
109326
  const abortHandler = () => {
109325
109327
  cleanup();
@@ -118583,7 +118585,7 @@ import { fileURLToPath as fileURLToPath4 } from "node:url";
118583
118585
  import path16 from "node:path";
118584
118586
  async function getVersion() {
118585
118587
  const pkgJson = await getPackageJson(__dirname3);
118586
- return "2.0.2";
118588
+ return "2.0.3";
118587
118589
  }
118588
118590
  var __filename2, __dirname3;
118589
118591
  var init_version2 = __esm({
@@ -173540,8 +173542,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
173540
173542
  var init_git_commit = __esm({
173541
173543
  "packages/core/dist/src/generated/git-commit.js"() {
173542
173544
  "use strict";
173543
- GIT_COMMIT_INFO = "5826adddd";
173544
- CLI_VERSION = "2.0.1";
173545
+ GIT_COMMIT_INFO = "dfdd00850";
173546
+ CLI_VERSION = "2.0.3";
173545
173547
  }
173546
173548
  });
173547
173549
 
@@ -261264,15 +261266,6 @@ var init_custom_llm = __esm({
261264
261266
  } catch (_e) {
261265
261267
  debugLogger.log("[CustomLLM] stream_options not supported, continuing without it");
261266
261268
  }
261267
- debugLogger.log("[CustomLLM] Sending stream request:", JSON.stringify({
261268
- model: requestParams.model,
261269
- messagesCount: messages.length,
261270
- messages,
261271
- toolsCount: tools.length,
261272
- includesTools: !!requestParams.tools,
261273
- hasStreamOptions: !!requestParams.stream_options,
261274
- allParams: Object.keys(requestParams)
261275
- }, null, 2));
261276
261269
  const stream2 = await this.model.chat.completions.create(requestParams);
261277
261270
  const map4 = /* @__PURE__ */ new Map();
261278
261271
  return async function* () {
@@ -262233,7 +262226,7 @@ var init_default2 = __esm({
262233
262226
  this.contentGeneratorConfig = contentGeneratorConfig;
262234
262227
  }
262235
262228
  buildHeaders() {
262236
- const version4 = "2.0.2";
262229
+ const version4 = "2.0.3";
262237
262230
  const userAgent = `CoStrict/${version4} (${process.platform}; ${process.arch})`;
262238
262231
  return {
262239
262232
  "User-Agent": userAgent
@@ -262267,9 +262260,13 @@ var init_costrict = __esm({
262267
262260
  "use strict";
262268
262261
  init_dist_node();
262269
262262
  init_default2();
262263
+ init_installationManager();
262270
262264
  CoStrictOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
262265
+ clientId;
262271
262266
  constructor(contentGeneratorConfig, cliConfig) {
262272
262267
  super(contentGeneratorConfig, cliConfig);
262268
+ const installationManager2 = new InstallationManager();
262269
+ this.clientId = installationManager2.getInstallationId();
262273
262270
  }
262274
262271
  /**
262275
262272
  * Check if this is a CoStrict provider based on base URL
@@ -262280,18 +262277,26 @@ var init_costrict = __esm({
262280
262277
  }
262281
262278
  /**
262282
262279
  * Build headers with CoStrict-specific requirements
262280
+ * Note: zgsm-task-id is set dynamically to capture the current session ID
262281
+ * This ensures that if the session ID changes (e.g., via /clear command),
262282
+ * the header will use the updated value in subsequent requests
262283
262283
  */
262284
262284
  buildHeaders() {
262285
262285
  const baseHeaders = super.buildHeaders();
262286
- const version4 = "2.0.2";
262286
+ const version4 = "2.0.3";
262287
262287
  const requestId = v7_default();
262288
- return {
262288
+ const headers = {
262289
262289
  ...baseHeaders,
262290
262290
  "HTTP-Referer": "https://github.com/zgsm-ai/costrict-cli",
262291
262291
  "X-Title": "CoStrict CLI",
262292
262292
  "X-Costrict-Version": `costrict-cli-${version4}`,
262293
- "X-Request-ID": requestId
262293
+ "X-Request-ID": requestId,
262294
+ "zgsm-client-id": this.clientId,
262295
+ "zgsm-client-ide": "cli",
262296
+ // Capture current session ID - this will be called each time buildHeaders is invoked
262297
+ "zgsm-task-id": this.cliConfig.getSessionId()
262294
262298
  };
262299
+ return headers;
262295
262300
  }
262296
262301
  };
262297
262302
  }
@@ -262899,7 +262904,7 @@ var init_dashscope = __esm({
262899
262904
  return baseUrl === "https://dashscope.aliyuncs.com/compatible-mode/v1" || baseUrl === "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
262900
262905
  }
262901
262906
  buildHeaders() {
262902
- const version4 = "2.0.2";
262907
+ const version4 = "2.0.3";
262903
262908
  const userAgent = `CoStrict/${version4} (${process.platform}; ${process.arch})`;
262904
262909
  const { authType } = this.contentGeneratorConfig;
262905
262910
  return {
@@ -352217,10 +352222,23 @@ var init_gitService = __esm({
352217
352222
  debugLogger.debug(`checkIsRepo failed, will initialize repository: ${error40 instanceof Error ? error40.message : String(error40)}`);
352218
352223
  }
352219
352224
  if (!isRepoDefined) {
352220
- await repo.init(false, {
352221
- "--initial-branch": "main"
352222
- });
352225
+ try {
352226
+ await repo.init(false, {
352227
+ "--initial-branch": "main"
352228
+ });
352229
+ } catch (error40) {
352230
+ debugLogger.debug(`init with --initial-branch failed, using fallback: ${error40 instanceof Error ? error40.message : String(error40)}`);
352231
+ await repo.init(false);
352232
+ }
352223
352233
  await repo.commit("Initial commit", { "--allow-empty": null });
352234
+ try {
352235
+ const currentBranch = await repo.raw(["branch", "--show-current"]);
352236
+ if (currentBranch.trim() !== "main") {
352237
+ await repo.raw(["branch", "-M", "main"]);
352238
+ }
352239
+ } catch (error40) {
352240
+ debugLogger.debug(`Failed to rename branch to main: ${error40 instanceof Error ? error40.message : String(error40)}`);
352241
+ }
352224
352242
  }
352225
352243
  const userGitIgnorePath = path45.join(this.projectRoot, ".gitignore");
352226
352244
  const shadowGitIgnorePath = path45.join(repoDir, ".gitignore");
@@ -365916,6 +365934,7 @@ var init_modelCache = __esm({
365916
365934
  "packages/core/dist/src/services/modelCache.js"() {
365917
365935
  "use strict";
365918
365936
  init_storage();
365937
+ init_debugLogger();
365919
365938
  CACHE_VERSION2 = "1.0";
365920
365939
  ModelCache = class {
365921
365940
  /**
@@ -365929,20 +365948,20 @@ var init_modelCache = __esm({
365929
365948
  const content = await fs59.readFile(cachePath, "utf-8");
365930
365949
  const cached2 = JSON.parse(content);
365931
365950
  if (cached2.version !== CACHE_VERSION2) {
365932
- console.warn(`[ModelCache] Cache version mismatch for ${cacheKey}, ignoring`);
365951
+ debugLogger.warn(`[ModelCache] Cache version mismatch for ${cacheKey}, ignoring`);
365933
365952
  return null;
365934
365953
  }
365935
365954
  if (Date.now() >= cached2.expiresAt) {
365936
- console.warn(`[ModelCache] Cache expired for ${cacheKey}`);
365955
+ debugLogger.warn(`[ModelCache] Cache expired for ${cacheKey}`);
365937
365956
  return null;
365938
365957
  }
365939
- console.log(`[ModelCache] Cache hit for ${cacheKey}`);
365958
+ debugLogger.log(`[ModelCache] Cache hit for ${cacheKey}`);
365940
365959
  return cached2.models;
365941
365960
  } catch (error40) {
365942
365961
  if (error40 && typeof error40 === "object" && "code" in error40 && error40.code === "ENOENT") {
365943
365962
  return null;
365944
365963
  }
365945
- console.warn(`[ModelCache] Failed to read cache for ${cacheKey}:`, error40);
365964
+ debugLogger.warn(`[ModelCache] Failed to read cache for ${cacheKey}:`, error40);
365946
365965
  return null;
365947
365966
  }
365948
365967
  }
@@ -365965,9 +365984,9 @@ var init_modelCache = __esm({
365965
365984
  models
365966
365985
  };
365967
365986
  await fs59.writeFile(cachePath, JSON.stringify(cached2, null, 2), "utf-8");
365968
- console.log(`[ModelCache] Cache saved for ${cacheKey}`);
365987
+ debugLogger.log(`[ModelCache] Cache saved for ${cacheKey}`);
365969
365988
  } catch (error40) {
365970
- console.warn(`[ModelCache] Failed to save cache for ${cacheKey}:`, error40);
365989
+ debugLogger.warn(`[ModelCache] Failed to save cache for ${cacheKey}:`, error40);
365971
365990
  }
365972
365991
  }
365973
365992
  /**
@@ -365978,12 +365997,12 @@ var init_modelCache = __esm({
365978
365997
  try {
365979
365998
  const cachePath = Storage.getModelCachePath(cacheKey);
365980
365999
  await fs59.unlink(cachePath);
365981
- console.log(`[ModelCache] Cache cleared for ${cacheKey}`);
366000
+ debugLogger.log(`[ModelCache] Cache cleared for ${cacheKey}`);
365982
366001
  } catch (error40) {
365983
366002
  if (error40 && typeof error40 === "object" && "code" in error40 && error40.code === "ENOENT") {
365984
366003
  return;
365985
366004
  }
365986
- console.warn(`[ModelCache] Failed to clear cache for ${cacheKey}:`, error40);
366005
+ debugLogger.warn(`[ModelCache] Failed to clear cache for ${cacheKey}:`, error40);
365987
366006
  }
365988
366007
  }
365989
366008
  /**
@@ -366003,10 +366022,10 @@ var init_modelCache = __esm({
366003
366022
  const cached2 = JSON.parse(content);
366004
366023
  if (Date.now() >= cached2.expiresAt) {
366005
366024
  await fs59.unlink(filePath);
366006
- console.log(`[ModelCache] Removed expired cache: ${cached2.authType}`);
366025
+ debugLogger.log(`[ModelCache] Removed expired cache: ${cached2.authType}`);
366007
366026
  }
366008
366027
  } catch (error40) {
366009
- console.warn(`[ModelCache] Failed to process ${file2}:`, error40);
366028
+ debugLogger.warn(`[ModelCache] Failed to process ${file2}:`, error40);
366010
366029
  }
366011
366030
  }
366012
366031
  } catch (error40) {
@@ -366016,7 +366035,7 @@ var init_modelCache = __esm({
366016
366035
  throw error40;
366017
366036
  }
366018
366037
  } catch (error40) {
366019
- console.warn("[ModelCache] Failed to clear expired caches:", error40);
366038
+ debugLogger.warn("[ModelCache] Failed to clear expired caches:", error40);
366020
366039
  }
366021
366040
  }
366022
366041
  };
@@ -366329,7 +366348,7 @@ var init_costrictModelProvider = __esm({
366329
366348
  debugLogger.warn("[CoStrictModelProvider] Failed to get auth token:", error40);
366330
366349
  throw new Error(`Failed to get CoStrict auth token: ${error40 instanceof Error ? error40.message : String(error40)}`);
366331
366350
  }
366332
- const version4 = "2.0.2";
366351
+ const version4 = "2.0.3";
366333
366352
  const requestId = v7_default();
366334
366353
  const headers = {
366335
366354
  Authorization: `Bearer ${token2}`,
@@ -376337,7 +376356,11 @@ var init_config3 = __esm({
376337
376356
  this.getFileService();
376338
376357
  if (this.getCheckpointingEnabled()) {
376339
376358
  debugLogger.log("[Config.initialize] Getting GitService...");
376340
- await this.getGitService();
376359
+ try {
376360
+ await this.getGitService();
376361
+ } catch (error40) {
376362
+ debugLogger.warn("Failed to initialize GitService, checkpointing may not work properly:", error40);
376363
+ }
376341
376364
  }
376342
376365
  debugLogger.log("[Config.initialize] Creating PromptRegistry and ResourceRegistry...");
376343
376366
  this.promptRegistry = new PromptRegistry();
@@ -376345,7 +376368,11 @@ var init_config3 = __esm({
376345
376368
  debugLogger.log("[Config.initialize] Creating AgentRegistry...");
376346
376369
  this.agentRegistry = new AgentRegistry(this);
376347
376370
  debugLogger.log("[Config.initialize] Initializing AgentRegistry...");
376348
- await this.agentRegistry.initialize();
376371
+ try {
376372
+ await this.agentRegistry.initialize();
376373
+ } catch (error40) {
376374
+ debugLogger.warn("Failed to initialize AgentRegistry:", error40);
376375
+ }
376349
376376
  if (this.enableAgents) {
376350
376377
  const { subagentManager: subagentManager2 } = await Promise.resolve().then(() => (init_manager(), manager_exports));
376351
376378
  debugLogger.log("[Config.initialize] Initializing SubagentManager...");
@@ -376364,24 +376391,40 @@ var init_config3 = __esm({
376364
376391
  this.mcpClientManager = new McpClientManager(this.toolRegistry, this, this.eventEmitter);
376365
376392
  const initMcpHandle = startupProfiler.start("initialize_mcp_clients");
376366
376393
  debugLogger.log("[Config.initialize] Starting MCP servers and extensions...");
376367
- await Promise.all([
376368
- await this.mcpClientManager.startConfiguredMcpServers(),
376369
- await this.getExtensionLoader().start(this)
376370
- ]);
376394
+ try {
376395
+ await Promise.all([
376396
+ this.mcpClientManager.startConfiguredMcpServers().catch((error40) => {
376397
+ debugLogger.warn("Failed to start some MCP servers:", error40);
376398
+ }),
376399
+ this.getExtensionLoader().start(this).catch((error40) => {
376400
+ debugLogger.warn("Failed to start extensions:", error40);
376401
+ })
376402
+ ]);
376403
+ } catch (error40) {
376404
+ debugLogger.warn("Failed to start MCP servers and extensions:", error40);
376405
+ }
376371
376406
  initMcpHandle?.end();
376372
376407
  debugLogger.log("[Config.initialize] MCP and extensions started.");
376373
376408
  if (this.skillsSupport) {
376374
376409
  debugLogger.log("[Config.initialize] Discovering skills...");
376375
- await this.getSkillManager().discoverSkills(this.storage);
376376
- this.getSkillManager().setDisabledSkills(this.disabledSkills);
376377
- if (this.getSkillManager().getSkills().length > 0) {
376378
- this.getToolRegistry().registerTool(new ActivateSkillTool(this, this.messageBus));
376410
+ try {
376411
+ await this.getSkillManager().discoverSkills(this.storage);
376412
+ this.getSkillManager().setDisabledSkills(this.disabledSkills);
376413
+ if (this.getSkillManager().getSkills().length > 0) {
376414
+ this.getToolRegistry().registerTool(new ActivateSkillTool(this, this.messageBus));
376415
+ }
376416
+ } catch (error40) {
376417
+ debugLogger.warn("Failed to discover skills:", error40);
376379
376418
  }
376380
376419
  }
376381
376420
  if (this.enableHooks) {
376382
376421
  debugLogger.log("[Config.initialize] Initializing HookSystem...");
376383
376422
  this.hookSystem = new HookSystem(this);
376384
- await this.hookSystem.initialize();
376423
+ try {
376424
+ await this.hookSystem.initialize();
376425
+ } catch (error40) {
376426
+ debugLogger.warn("Failed to initialize HookSystem, hooks may not work properly:", error40);
376427
+ }
376385
376428
  }
376386
376429
  if (this.experimentalJitContext) {
376387
376430
  debugLogger.log("[Config.initialize] Creating ContextManager...");
@@ -461525,7 +461568,7 @@ var RetryMessage = ({
461525
461568
  };
461526
461569
 
461527
461570
  // packages/cli/src/generated/git-commit.ts
461528
- var GIT_COMMIT_INFO2 = "0a733cf89";
461571
+ var GIT_COMMIT_INFO2 = "862c0eaff";
461529
461572
 
461530
461573
  // packages/cli/src/ui/components/AboutBox.tsx
461531
461574
  var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
@@ -506398,6 +506441,15 @@ async function main() {
506398
506441
  const loadSettingsHandle = startupProfiler.start("load_settings");
506399
506442
  const settings = loadSettings();
506400
506443
  loadSettingsHandle?.end();
506444
+ const earlyConsolePatcher = new ConsolePatcher({
506445
+ stderr: true,
506446
+ debugMode: false,
506447
+ // Default to false to suppress debug logs
506448
+ onNewMessage: (msg) => {
506449
+ coreEvents.emitConsoleLog(msg.type, msg.content);
506450
+ }
506451
+ });
506452
+ earlyConsolePatcher.patch();
506401
506453
  const shellDetectionHandle = startupProfiler.start("shell_detection");
506402
506454
  const detectionMode = settings.merged.tools?.shell?.detectionMode ?? "current";
506403
506455
  setShellDetectionMode(detectionMode);
@@ -506430,6 +506482,7 @@ async function main() {
506430
506482
  process.exit(ExitCodes2.FATAL_INPUT_ERROR);
506431
506483
  }
506432
506484
  const isDebugMode2 = isDebugMode(argv);
506485
+ earlyConsolePatcher.cleanup();
506433
506486
  const consolePatcher = new ConsolePatcher({
506434
506487
  stderr: true,
506435
506488
  debugMode: isDebugMode2,
@@ -40162,19 +40162,19 @@ var DebugLogger = class {
40162
40162
  log(...args2) {
40163
40163
  this.writeToFile("LOG", args2);
40164
40164
  if (this.debugEnabled) {
40165
- console.log(...args2);
40165
+ console.debug(...args2);
40166
40166
  }
40167
40167
  }
40168
40168
  warn(...args2) {
40169
40169
  this.writeToFile("WARN", args2);
40170
40170
  if (this.debugEnabled) {
40171
- console.warn(...args2);
40171
+ console.debug(...args2);
40172
40172
  }
40173
40173
  }
40174
40174
  error(...args2) {
40175
40175
  this.writeToFile("ERROR", args2);
40176
40176
  if (this.debugEnabled) {
40177
- console.error(...args2);
40177
+ console.debug(...args2);
40178
40178
  }
40179
40179
  }
40180
40180
  debug(...args2) {
@@ -40912,19 +40912,19 @@ var DebugLogger = class {
40912
40912
  log(...args2) {
40913
40913
  this.writeToFile("LOG", args2);
40914
40914
  if (this.debugEnabled) {
40915
- console.log(...args2);
40915
+ console.debug(...args2);
40916
40916
  }
40917
40917
  }
40918
40918
  warn(...args2) {
40919
40919
  this.writeToFile("WARN", args2);
40920
40920
  if (this.debugEnabled) {
40921
- console.warn(...args2);
40921
+ console.debug(...args2);
40922
40922
  }
40923
40923
  }
40924
40924
  error(...args2) {
40925
40925
  this.writeToFile("ERROR", args2);
40926
40926
  if (this.debugEnabled) {
40927
- console.error(...args2);
40927
+ console.debug(...args2);
40928
40928
  }
40929
40929
  }
40930
40930
  debug(...args2) {
@@ -40136,19 +40136,19 @@ var DebugLogger = class {
40136
40136
  log(...args2) {
40137
40137
  this.writeToFile("LOG", args2);
40138
40138
  if (this.debugEnabled) {
40139
- console.log(...args2);
40139
+ console.debug(...args2);
40140
40140
  }
40141
40141
  }
40142
40142
  warn(...args2) {
40143
40143
  this.writeToFile("WARN", args2);
40144
40144
  if (this.debugEnabled) {
40145
- console.warn(...args2);
40145
+ console.debug(...args2);
40146
40146
  }
40147
40147
  }
40148
40148
  error(...args2) {
40149
40149
  this.writeToFile("ERROR", args2);
40150
40150
  if (this.debugEnabled) {
40151
- console.error(...args2);
40151
+ console.debug(...args2);
40152
40152
  }
40153
40153
  }
40154
40154
  debug(...args2) {
@@ -41994,19 +41994,19 @@ var DebugLogger = class {
41994
41994
  log(...args2) {
41995
41995
  this.writeToFile("LOG", args2);
41996
41996
  if (this.debugEnabled) {
41997
- console.log(...args2);
41997
+ console.debug(...args2);
41998
41998
  }
41999
41999
  }
42000
42000
  warn(...args2) {
42001
42001
  this.writeToFile("WARN", args2);
42002
42002
  if (this.debugEnabled) {
42003
- console.warn(...args2);
42003
+ console.debug(...args2);
42004
42004
  }
42005
42005
  }
42006
42006
  error(...args2) {
42007
42007
  this.writeToFile("ERROR", args2);
42008
42008
  if (this.debugEnabled) {
42009
- console.error(...args2);
42009
+ console.debug(...args2);
42010
42010
  }
42011
42011
  }
42012
42012
  debug(...args2) {
@@ -42542,19 +42542,19 @@ var DebugLogger = class {
42542
42542
  log(...args2) {
42543
42543
  this.writeToFile("LOG", args2);
42544
42544
  if (this.debugEnabled) {
42545
- console.log(...args2);
42545
+ console.debug(...args2);
42546
42546
  }
42547
42547
  }
42548
42548
  warn(...args2) {
42549
42549
  this.writeToFile("WARN", args2);
42550
42550
  if (this.debugEnabled) {
42551
- console.warn(...args2);
42551
+ console.debug(...args2);
42552
42552
  }
42553
42553
  }
42554
42554
  error(...args2) {
42555
42555
  this.writeToFile("ERROR", args2);
42556
42556
  if (this.debugEnabled) {
42557
- console.error(...args2);
42557
+ console.debug(...args2);
42558
42558
  }
42559
42559
  }
42560
42560
  debug(...args2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@costrict/cs",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },