@jive-ai/cli 0.0.33 → 0.0.35

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 +92 -40
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -185,9 +185,9 @@ async function openBrowser(url) {
185
185
  async function loginCommand() {
186
186
  console.log(chalk.bold("\nšŸ‘‹ Login to Jive\n"));
187
187
  console.log(chalk.white("Opening browser for authentication...\n"));
188
- await openBrowser(`${API_URL}/cli-auth`);
188
+ await openBrowser(`${API_URL}/app/cli-auth`);
189
189
  console.log(chalk.gray("If the browser did not open, visit:"));
190
- console.log(chalk.cyan(`${API_URL}/cli-auth\n`));
190
+ console.log(chalk.cyan(`${API_URL}/app/cli-auth\n`));
191
191
  const response = await prompts({
192
192
  type: "password",
193
193
  name: "apiKey",
@@ -2613,6 +2613,18 @@ const cliQueries = {
2613
2613
  gitDefaultBranch
2614
2614
  team {
2615
2615
  id
2616
+ settings {
2617
+ claude {
2618
+ defaultModel
2619
+ environmentVariables
2620
+ betaFlags
2621
+ }
2622
+ }
2623
+ }
2624
+ settings {
2625
+ defaultModel
2626
+ environmentVariables
2627
+ betaFlags
2616
2628
  }
2617
2629
  createdAt
2618
2630
  updatedAt
@@ -2951,16 +2963,24 @@ var ApiClient = class {
2951
2963
  };
2952
2964
  }
2953
2965
  async getSessionLines(taskId, sessionId, excludePending = false) {
2954
- return (await (await getGraphQLClient()).request(queries.GetSessionLines, {
2955
- taskId: String(taskId),
2956
- sessionId: String(sessionId),
2957
- excludePending
2958
- })).sessionLines.edges.map((edge) => ({
2959
- uuid: edge.node.uuid,
2960
- schema: edge.node.schema,
2961
- payload: edge.node.payload,
2962
- createdAt: new Date(edge.node.createdAt)
2963
- }));
2966
+ const client = await getGraphQLClient();
2967
+ const allLines = [];
2968
+ let hasNextPage = true;
2969
+ let after = void 0;
2970
+ while (hasNextPage) {
2971
+ const response = await client.request(queries.GetSessionLines, {
2972
+ taskId: String(taskId),
2973
+ sessionId: String(sessionId),
2974
+ excludePending,
2975
+ first: 100,
2976
+ after
2977
+ });
2978
+ const pageLines = response.sessionLines.edges.map((edge) => edge.node);
2979
+ allLines.push(...pageLines);
2980
+ hasNextPage = response.sessionLines.pageInfo.hasNextPage;
2981
+ after = response.sessionLines.pageInfo.endCursor ?? void 0;
2982
+ }
2983
+ return allLines;
2964
2984
  }
2965
2985
  async getTaskSessions(taskId) {
2966
2986
  return (await (await getGraphQLClient()).request(queries.GetSessions, { taskId: String(taskId) })).sessions.map((s) => ({
@@ -3337,7 +3357,10 @@ async function spawnTaskDocker(ctx, config$2, opts) {
3337
3357
  console.log(chalk.yellow("Warning: Using Docker socket mount (no isolation). Set JIVE_USE_SYSBOX=true on Linux for secure mode."));
3338
3358
  }
3339
3359
  dockerArgs.push("--network", "bridge");
3340
- if (isDevMode) dockerArgs.push("--add-host", "host.docker.internal:host-gateway");
3360
+ if (isDevMode) {
3361
+ dockerArgs.push("--add-host", "host.docker.internal:host-gateway");
3362
+ dockerArgs.push("--pull", "never");
3363
+ }
3341
3364
  dockerArgs.push("--cpus", limits.docker.cpus, "--memory", limits.docker.memory, "-v", `${ctx.directory}:/workspace`, "-w", "/workspace", ...envVars, limits.docker.image, encode(JSON.stringify(ctx)));
3342
3365
  console.log(chalk.dim(`[Task ${ctx.taskId}] Spawning Docker container with args:`, JSON.stringify(dockerArgs, null, 2)));
3343
3366
  const taskProcess = spawn("docker", dockerArgs, { cwd: ctx.directory });
@@ -3396,6 +3419,10 @@ async function createGraphQLClient() {
3396
3419
  };
3397
3420
  }
3398
3421
 
3422
+ //#endregion
3423
+ //#region package.json
3424
+ var version = "0.0.35";
3425
+
3399
3426
  //#endregion
3400
3427
  //#region src/runner/index.ts
3401
3428
  const execAsync$3 = promisify(exec);
@@ -3407,7 +3434,7 @@ function getEffectiveResourceLimits(config$2, projectLimits) {
3407
3434
  docker: {
3408
3435
  cpus: projectLimits?.dockerCpus?.toString() || process.env.JIVE_DOCKER_CPUS || config$2.resourceLimits?.docker?.cpus || "2",
3409
3436
  memory: projectLimits?.dockerMemory || process.env.JIVE_DOCKER_MEMORY || config$2.resourceLimits?.docker?.memory || "2g",
3410
- image: projectLimits?.dockerImage || process.env.JIVE_DOCKER_IMAGE || config$2.resourceLimits?.docker?.image || "jiveai/task:latest"
3437
+ image: projectLimits?.dockerImage || process.env.JIVE_DOCKER_IMAGE || config$2.resourceLimits?.docker?.image || `jiveai/task:${version}`
3411
3438
  }
3412
3439
  };
3413
3440
  }
@@ -3496,6 +3523,7 @@ var TaskRunner = class {
3496
3523
  directory
3497
3524
  repository
3498
3525
  branch
3526
+ defaultBranch
3499
3527
  gitAuth {
3500
3528
  privateKey
3501
3529
  repositoryUrl
@@ -3528,6 +3556,7 @@ var TaskRunner = class {
3528
3556
  directory: data.taskContext.directory,
3529
3557
  repository: data.taskContext.repository,
3530
3558
  branch: data.taskContext.branch,
3559
+ defaultBranch: data.taskContext.defaultBranch,
3531
3560
  gitAuth: auth || void 0,
3532
3561
  permissionMode: data.taskContext.permissionMode
3533
3562
  };
@@ -3792,27 +3821,11 @@ async function queryClaude(prompt, mcpServer, opts) {
3792
3821
  const credentials = await getCredentials();
3793
3822
  if (!credentials?.anthropicApiKey) throw new Error("Anthropic API key not found in credentials JSON");
3794
3823
  process.env.ANTHROPIC_API_KEY = credentials.anthropicApiKey;
3795
- let teamSettings;
3796
- try {
3797
- const client = await getGraphQLClient();
3798
- const projectData = await client.request(cliQueries.Project, { id: task.projectId.toString() });
3799
- if (projectData.project?.team) {
3800
- const claude = (await client.request(cliQueries.Team, { id: projectData.project.team.id })).team?.settings?.claude;
3801
- if (claude) teamSettings = {
3802
- defaultModel: claude.defaultModel,
3803
- environmentVariables: claude.environmentVariables,
3804
- betaFlags: claude.betaFlags
3805
- };
3806
- }
3807
- } catch (error$1) {
3808
- console.error("Failed to fetch team settings, using defaults:", error$1);
3809
- }
3810
- const defaultModel = teamSettings?.defaultModel || "sonnet";
3811
- const environmentVariables = teamSettings?.environmentVariables || {};
3812
- const betaFlags = teamSettings?.betaFlags || [];
3824
+ const { defaultModel, environmentVariables, betaFlags } = await getTaskClaudeSettings({ projectId: task.projectId.toString() });
3813
3825
  for (const [key, value$1] of Object.entries(environmentVariables)) process.env[key] = value$1;
3814
3826
  debugLog(`[Task ${task.id}] Querying Claude with permission mode: ${permissionMode}`);
3815
3827
  debugLog(`[Task ${task.id}] Using model: ${defaultModel}`);
3828
+ if (Object.keys(environmentVariables).length > 0) debugLog(`[Task ${task.id}] Environment variables: ${Object.keys(environmentVariables).join(", ")}`);
3816
3829
  if (betaFlags.length > 0) debugLog(`[Task ${task.id}] Beta flags: ${betaFlags.join(", ")}`);
3817
3830
  return query({
3818
3831
  prompt,
@@ -3851,6 +3864,49 @@ async function queryClaude(prompt, mcpServer, opts) {
3851
3864
  }
3852
3865
  });
3853
3866
  }
3867
+ async function getTaskClaudeSettings(opts) {
3868
+ const { projectId } = opts;
3869
+ let teamSettings;
3870
+ let projectSettings;
3871
+ try {
3872
+ const client = await getGraphQLClient();
3873
+ const projectData = await client.request(cliQueries.Project, { id: projectId });
3874
+ if (projectData.project) {
3875
+ const projectSettingsData = projectData.project?.settings;
3876
+ if (projectSettingsData) projectSettings = {
3877
+ defaultModel: projectSettingsData.defaultModel,
3878
+ environmentVariables: projectSettingsData.environmentVariables,
3879
+ betaFlags: projectSettingsData.betaFlags
3880
+ };
3881
+ if (projectData.project.team) {
3882
+ const teamClaude = (await client.request(cliQueries.Team, { id: projectData.project.team.id })).team?.settings?.claude;
3883
+ if (teamClaude) teamSettings = {
3884
+ defaultModel: teamClaude.defaultModel,
3885
+ environmentVariables: teamClaude.environmentVariables,
3886
+ betaFlags: teamClaude.betaFlags
3887
+ };
3888
+ }
3889
+ }
3890
+ } catch (error$1) {
3891
+ debugLog(`[Task] Failed to fetch settings, using defaults: ${error$1}`);
3892
+ }
3893
+ const defaultModel = projectSettings?.defaultModel || teamSettings?.defaultModel || "sonnet";
3894
+ const teamEnvVars = teamSettings?.environmentVariables || {};
3895
+ const projectEnvVars = projectSettings?.environmentVariables || {};
3896
+ const environmentVariables = {
3897
+ ...teamEnvVars,
3898
+ ...projectEnvVars
3899
+ };
3900
+ const betaFlags = [...teamSettings?.betaFlags || [], ...projectSettings?.betaFlags || []];
3901
+ debugLog(`[Task] Default model: ${defaultModel}`);
3902
+ debugLog(`[Task] Environment variables: ${Object.keys(environmentVariables).join(", ")}`);
3903
+ debugLog(`[Task] Beta flags: ${betaFlags.join(", ")}`);
3904
+ return {
3905
+ defaultModel,
3906
+ environmentVariables,
3907
+ betaFlags
3908
+ };
3909
+ }
3854
3910
  function mapPermissionMode(permissionMode) {
3855
3911
  switch (permissionMode) {
3856
3912
  case "DEFAULT": return "default";
@@ -4731,8 +4787,8 @@ Host gitlab.com
4731
4787
  this.debugLog("Branch does not exist, creating...");
4732
4788
  await execAsync$1(`git checkout -b ${this.ctx.branch}`);
4733
4789
  }
4734
- this.debugLog("Pulling from default branch (main)...");
4735
- await execAsync$1(`git pull origin main`);
4790
+ this.debugLog(`Pulling from default branch (${this.ctx.defaultBranch})...`);
4791
+ await execAsync$1(`git pull origin ${this.ctx.defaultBranch}`);
4736
4792
  this.debugLog("Pulling from task branch...");
4737
4793
  try {
4738
4794
  await execAsync$1(`git pull origin ${this.ctx.branch}`);
@@ -4753,7 +4809,7 @@ Host gitlab.com
4753
4809
  const jsonlContent = sessionLines.map((m) => JSON.stringify(m)).join("\n");
4754
4810
  await writeFile(this.claudeSessionFilePath, jsonlContent + "\n");
4755
4811
  this.debugLog(`āœ“ Saved session file to ${this.claudeSessionFilePath}`);
4756
- this.debugLog(`Contents: ${jsonlContent}`);
4812
+ this.debugLog(`Contains ${messages.length.toLocaleString()} session lines`);
4757
4813
  }
4758
4814
  async readNewSessionLines() {
4759
4815
  try {
@@ -4879,7 +4935,7 @@ Host gitlab.com
4879
4935
  }
4880
4936
  });
4881
4937
  } finally {
4882
- this.claudeAbortController.signal.removeEventListener("abort", abortHandler);
4938
+ this.claudeAbortController?.signal.removeEventListener("abort", abortHandler);
4883
4939
  this.stopSessionFileWatcher();
4884
4940
  this.claudeAbortController = null;
4885
4941
  this.sendStatusUpdate("idle");
@@ -5651,10 +5707,6 @@ async function resumeCommand(taskId) {
5651
5707
  }
5652
5708
  const taskCommands = { resume: resumeCommand };
5653
5709
 
5654
- //#endregion
5655
- //#region package.json
5656
- var version = "0.0.33";
5657
-
5658
5710
  //#endregion
5659
5711
  //#region src/index.ts
5660
5712
  const program = new Command();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@jive-ai/cli",
4
- "version": "0.0.33",
4
+ "version": "0.0.35",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "dist",
@@ -16,7 +16,7 @@
16
16
  "typecheck": "tsc --noEmit",
17
17
  "build": "tsdown && npm pack && npm install -g jive-ai-cli-*.tgz",
18
18
  "docker:build": "touch jive-ai-cli-0.0.0.tgz && docker build -t jiveai/task:latest . && rm -f jive-ai-cli-*.tgz",
19
- "docker:build:local": "bun run build && docker build --build-arg USE_LOCAL=true -t jiveai/task:latest .",
19
+ "docker:build:local": "docker rmi jiveai/task:$npm_package_version jiveai/task:latest; bun run build && docker build --build-arg USE_LOCAL=true -t jiveai/task:latest -t jiveai/task:$npm_package_version .",
20
20
  "docker:build:public": "touch jive-ai-cli-0.0.0.tgz && docker buildx build --platform linux/amd64 -t jiveai/task:latest -t jiveai/task:$npm_package_version . && rm -f jive-ai-cli-*.tgz",
21
21
  "docker:push": "docker buildx build --platform linux/amd64 --push -t jiveai/task:latest -t jiveai/task:$npm_package_version .",
22
22
  "docker:publish": "touch jive-ai-cli-0.0.0.tgz && docker buildx build --platform linux/amd64 --push -t jiveai/task:latest -t jiveai/task:$npm_package_version . && rm -f jive-ai-cli-*.tgz",