@testchimp/cli 0.1.41 → 0.1.43

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.
@@ -45,6 +45,17 @@ function normalizeUserMessage(content) {
45
45
  function sleep(ms) {
46
46
  return new Promise((resolve) => setTimeout(resolve, ms));
47
47
  }
48
+ /** Protobuf JsonFormat uses camelCase; accept snake_case too for resilience. */
49
+ function bootStr(boot, snake, camel) {
50
+ const raw = boot;
51
+ const v = raw[snake] ?? raw[camel];
52
+ return typeof v === "string" ? v.trim() : "";
53
+ }
54
+ function bootNum(boot, snake, camel) {
55
+ const raw = boot;
56
+ const v = raw[snake] ?? raw[camel];
57
+ return typeof v === "number" && Number.isFinite(v) ? v : undefined;
58
+ }
48
59
  /** Agent/CLI hook: persist the conversation working branch (+ optional PR) for UI + later turns. */
49
60
  export async function reportWorkingBranch(opts) {
50
61
  const apiKey = requireApiKey();
@@ -147,8 +158,8 @@ class AgentEventPoster {
147
158
  }
148
159
  const TESTCHIMP_PROVIDER_ID = "testchimp";
149
160
  function resolveOpencodeModelId(boot) {
150
- const raw = (boot.llm_model || "gpt-4o-mini").trim();
151
- const modelId = raw.includes("/") ? raw.split("/").pop() || "gpt-4o-mini" : raw;
161
+ const raw = bootStr(boot, "llm_model", "llmModel") || "gpt-5.6-luna";
162
+ const modelId = raw.includes("/") ? raw.split("/").pop() || "gpt-5.6-luna" : raw;
152
163
  return modelId;
153
164
  }
154
165
  function resolveOpencodeModel(boot) {
@@ -271,19 +282,30 @@ function detectWorkingBranchFromToolOutput(output) {
271
282
  };
272
283
  }
273
284
  function writeOpencodeConfig(backend, apiKey, boot) {
274
- const llmBase = (boot.llm_base_url || `${backend}/v1`).replace(/\/$/, "");
275
- const llmKey = apiKey || boot.llm_api_key || "";
285
+ const llmBase = (bootStr(boot, "llm_base_url", "llmBaseUrl") || `${backend}/v1`).replace(/\/$/, "");
286
+ const llmKey = apiKey || bootStr(boot, "llm_api_key", "llmApiKey");
276
287
  const modelId = resolveOpencodeModelId(boot);
277
288
  const model = `${TESTCHIMP_PROVIDER_ID}/${modelId}`;
289
+ const sessionId = bootStr(boot, "session_id", "sessionId");
278
290
  const mcpEnv = {
279
291
  TESTCHIMP_API_KEY: apiKey,
280
292
  TESTCHIMP_BACKEND_URL: backend,
281
293
  TESTCHIMP_EXECUTION_SOURCE: "CLOUD_AGENT",
282
294
  };
283
- const serviceUserId = boot.chimphands_service_account_user_id?.trim();
295
+ const serviceUserId = bootStr(boot, "chimphands_service_account_user_id", "chimphandsServiceAccountUserId");
284
296
  if (serviceUserId) {
285
297
  mcpEnv.TESTCHIMP_USER_ID = serviceUserId;
286
298
  }
299
+ const providerOptions = {
300
+ apiKey: llmKey,
301
+ baseURL: llmBase,
302
+ };
303
+ if (sessionId) {
304
+ providerOptions.headers = {
305
+ "X-TestChimp-ChimpHands-Session-Id": sessionId,
306
+ };
307
+ }
308
+ // @ai-sdk/openai uses /v1/responses (tools + reasoning). openai-compatible is chat-only.
287
309
  writeFileSync("opencode.json", JSON.stringify({
288
310
  $schema: "https://opencode.ai/config.json",
289
311
  model,
@@ -291,12 +313,9 @@ function writeOpencodeConfig(backend, apiKey, boot) {
291
313
  autoupdate: false,
292
314
  provider: {
293
315
  [TESTCHIMP_PROVIDER_ID]: {
294
- npm: "@ai-sdk/openai-compatible",
316
+ npm: "@ai-sdk/openai",
295
317
  name: "TestChimp",
296
- options: {
297
- apiKey: llmKey,
298
- baseURL: llmBase,
299
- },
318
+ options: providerOptions,
300
319
  models: {
301
320
  [modelId]: {
302
321
  name: modelId,
@@ -572,17 +591,17 @@ export async function runChimphands(opts) {
572
591
  console.error(`ChimpHands link run failed: ${err instanceof Error ? err.message : String(err)}`);
573
592
  });
574
593
  }
575
- const userId = boot.chimphands_service_account_user_id || "";
594
+ const userId = bootStr(boot, "chimphands_service_account_user_id", "chimphandsServiceAccountUserId");
576
595
  if (userId) {
577
596
  process.env.TESTCHIMP_USER_ID = userId;
578
597
  }
579
598
  mkdirSync(".opencode", { recursive: true });
580
599
  const opencodeModel = writeOpencodeConfig(backend, apiKey, boot);
581
600
  console.error(`ChimpHands OpenCode model: ${opencodeModel}`);
582
- let opencodeSessionId = boot.opencode_session_id?.trim() || undefined;
583
- const conversationSummary = boot.conversation_summary || "";
584
- let workingBranch = boot.working_branch?.trim() || undefined;
585
- let pullRequestUrl = boot.pull_request_url?.trim() || undefined;
601
+ let opencodeSessionId = bootStr(boot, "opencode_session_id", "opencodeSessionId") || undefined;
602
+ const conversationSummary = bootStr(boot, "conversation_summary", "conversationSummary");
603
+ let workingBranch = bootStr(boot, "working_branch", "workingBranch") || undefined;
604
+ let pullRequestUrl = bootStr(boot, "pull_request_url", "pullRequestUrl") || undefined;
586
605
  const noteWorkingBranch = (branch, prUrl) => {
587
606
  const normalizedBranch = branch.trim();
588
607
  if (!normalizedBranch)
@@ -599,7 +618,7 @@ export async function runChimphands(opts) {
599
618
  poster.reportWorkingBranch(normalizedBranch, nextPr);
600
619
  }
601
620
  };
602
- const idleMs = (Number(boot.idle_timeout_seconds) || 600) * 1000;
621
+ const idleMs = (bootNum(boot, "idle_timeout_seconds", "idleTimeoutSeconds") || 600) * 1000;
603
622
  const queue = [];
604
623
  const seenUserMessageIds = new Set();
605
624
  let idle = false;
@@ -669,8 +688,9 @@ export async function runChimphands(opts) {
669
688
  shouldRun: () => sessionActive,
670
689
  });
671
690
  poster.fireAndForget(ROLE_STATUS, "Agent ready", { status: STATUS_RUNNING });
672
- let prompt = normalizeUserMessage(promptInput || boot.initial_prompt || "");
673
- for (const m of boot.pending_user_messages || []) {
691
+ let prompt = normalizeUserMessage(promptInput || bootStr(boot, "initial_prompt", "initialPrompt"));
692
+ const pending = boot.pending_user_messages || boot.pendingUserMessages || [];
693
+ for (const m of pending) {
674
694
  if (m?.content)
675
695
  enqueueUserMessage({ content: m.content });
676
696
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testchimp/cli",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "TestChimp CLI and MCP server — coverage, plans, EaaS, TrueCoverage, API operations (calls /api/mcp/*)",
5
5
  "type": "module",
6
6
  "main": "dist/bin/testchimp.js",