@getpochi/cli 0.5.95 → 0.5.96

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/cli.js +94 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -113843,14 +113843,14 @@ var init_ShardManager = __esm(() => {
113843
113843
  unassignedShards.unsafeUpdate(stats.unassigned, []);
113844
113844
  }
113845
113845
  updateShardMetrics();
113846
- function withRetry(effect4) {
113846
+ function withRetry2(effect4) {
113847
113847
  return effect4.pipe(retry2({
113848
113848
  schedule: spaced2(config5.persistRetryCount),
113849
113849
  times: config5.persistRetryCount
113850
113850
  }), ignore2);
113851
113851
  }
113852
- const persistRunners = unsafeMakeSemaphore2(1).withPermits(1)(withRetry(suspend3(() => storage.saveRunners(map4(state3.allRunners, ([address, runner]) => [address, runner.runner])))));
113853
- const persistAssignments = unsafeMakeSemaphore2(1).withPermits(1)(withRetry(suspend3(() => storage.saveAssignments(state3.assignments))));
113852
+ const persistRunners = unsafeMakeSemaphore2(1).withPermits(1)(withRetry2(suspend3(() => storage.saveRunners(map4(state3.allRunners, ([address, runner]) => [address, runner.runner])))));
113853
+ const persistAssignments = unsafeMakeSemaphore2(1).withPermits(1)(withRetry2(suspend3(() => storage.saveAssignments(state3.assignments))));
113854
113854
  const notifyUnhealthyRunner = fnUntraced2(function* (address) {
113855
113855
  if (!has6(state3.allRunners, address))
113856
113856
  return;
@@ -391690,6 +391690,28 @@ var VendorId = "pochi";
391690
391690
 
391691
391691
  // ../vendor-pochi/src/vendor.ts
391692
391692
  var logger3 = getLogger("PochiVendor");
391693
+ async function withRetry(fn, options = {}) {
391694
+ const {
391695
+ maxRetries = 3,
391696
+ initialDelay = 1000,
391697
+ maxDelay = 1e4,
391698
+ delayMultiplier = 2
391699
+ } = options;
391700
+ let lastError;
391701
+ let delay2 = initialDelay;
391702
+ for (let attempt = 0;attempt <= maxRetries; attempt++) {
391703
+ try {
391704
+ return await fn();
391705
+ } catch (error40) {
391706
+ lastError = error40 instanceof Error ? error40 : new Error(String(error40));
391707
+ if (attempt < maxRetries) {
391708
+ await new Promise((resolve2) => setTimeout(resolve2, delay2));
391709
+ delay2 = Math.min(delay2 * delayMultiplier, maxDelay);
391710
+ }
391711
+ }
391712
+ }
391713
+ throw lastError;
391714
+ }
391693
391715
 
391694
391716
  class Pochi extends VendorBase {
391695
391717
  cachedModels;
@@ -391702,7 +391724,14 @@ class Pochi extends VendorBase {
391702
391724
  async fetchModels() {
391703
391725
  if (!this.cachedModels) {
391704
391726
  const apiClient = hc(getServerBaseUrl());
391705
- const data = await apiClient.api.models.$get().then((x) => x.json()).catch(() => {
391727
+ const data = await withRetry(async () => {
391728
+ const response = await apiClient.api.models.$get();
391729
+ return response.json();
391730
+ }, {
391731
+ maxRetries: 3,
391732
+ initialDelay: 1000
391733
+ }).catch((error40) => {
391734
+ logger3.error(`Failed to fetch models: ${error40.message}`);
391706
391735
  return [];
391707
391736
  });
391708
391737
  this.cachedModels = Object.fromEntries(data.map((x) => [
@@ -405887,7 +405916,7 @@ var {
405887
405916
  // package.json
405888
405917
  var package_default = {
405889
405918
  name: "@getpochi/cli",
405890
- version: "0.5.95",
405919
+ version: "0.5.96",
405891
405920
  type: "module",
405892
405921
  bin: {
405893
405922
  pochi: "src/cli.ts"
@@ -419134,20 +419163,43 @@ class JsonRenderer {
419134
419163
  state;
419135
419164
  outputMessageIds = new Set;
419136
419165
  lastMessageCount = 0;
419137
- constructor(store, state3) {
419166
+ mode;
419167
+ constructor(store, state3, options4 = { mode: "full" }) {
419138
419168
  this.store = store;
419139
419169
  this.state = state3;
419140
- this.state.signal.messages.subscribe((messages) => {
419141
- if (messages.length > this.lastMessageCount) {
419142
- this.outputMessages(messages.slice(0, -1));
419143
- this.lastMessageCount = messages.length;
419144
- }
419145
- });
419170
+ this.mode = options4.mode;
419171
+ if (this.mode === "full") {
419172
+ this.state.signal.messages.subscribe((messages) => {
419173
+ if (messages.length > this.lastMessageCount) {
419174
+ this.outputMessages(messages.slice(0, -1));
419175
+ this.lastMessageCount = messages.length;
419176
+ }
419177
+ });
419178
+ }
419146
419179
  }
419147
419180
  shutdown() {
419148
- this.outputMessages(this.state.signal.messages.value);
419181
+ if (this.mode === "result-only") {
419182
+ this.outputResult();
419183
+ } else {
419184
+ this.outputMessages(this.state.signal.messages.value);
419185
+ }
419149
419186
  }
419150
419187
  renderSubTask(_task) {}
419188
+ outputResult() {
419189
+ const messages = this.state.signal.messages.value;
419190
+ const lastMessage = messages.at(-1);
419191
+ if (lastMessage?.role === "assistant") {
419192
+ for (const part of lastMessage.parts || []) {
419193
+ if (isToolUIPart(part) && part.type === "tool-attemptCompletion") {
419194
+ if (part.input) {
419195
+ const result2 = part.input.result || "";
419196
+ console.log(result2);
419197
+ }
419198
+ return;
419199
+ }
419200
+ }
419201
+ }
419202
+ }
419151
419203
  outputMessages(messages) {
419152
419204
  for (const message of messages) {
419153
419205
  if (!this.outputMessageIds.has(message.id)) {
@@ -448492,6 +448544,9 @@ class LiveChatKit {
448492
448544
  store;
448493
448545
  chat;
448494
448546
  transport;
448547
+ onStreamStart;
448548
+ onStreamFinish;
448549
+ onStreamFailed;
448495
448550
  spawn;
448496
448551
  constructor({
448497
448552
  taskId,
@@ -448504,10 +448559,16 @@ class LiveChatKit {
448504
448559
  isCli,
448505
448560
  customAgent,
448506
448561
  outputSchema: outputSchema2,
448562
+ onStreamStart,
448563
+ onStreamFinish,
448564
+ onStreamFailed,
448507
448565
  ...chatInit
448508
448566
  }) {
448509
448567
  this.taskId = taskId;
448510
448568
  this.store = store;
448569
+ this.onStreamStart = onStreamStart;
448570
+ this.onStreamFinish = onStreamFinish;
448571
+ this.onStreamFailed = onStreamFailed;
448511
448572
  this.transport = new FlexibleChatTransport({
448512
448573
  store,
448513
448574
  onStart: this.onStart,
@@ -448661,6 +448722,7 @@ class LiveChatKit {
448661
448722
  updatedAt: new Date,
448662
448723
  modelId: llm.id
448663
448724
  }));
448725
+ this.onStreamStart?.();
448664
448726
  }
448665
448727
  };
448666
448728
  onFinish = ({
@@ -448679,13 +448741,20 @@ class LiveChatKit {
448679
448741
  if (message.metadata?.kind !== "assistant") {
448680
448742
  return this.onError(abortError);
448681
448743
  }
448744
+ const status3 = toTaskStatus(message, message.metadata?.finishReason);
448682
448745
  store.commit(events.chatStreamFinished({
448683
448746
  id: this.taskId,
448684
- status: toTaskStatus(message, message.metadata?.finishReason),
448747
+ status: status3,
448685
448748
  data: message,
448686
448749
  totalTokens: message.metadata.totalTokens,
448687
448750
  updatedAt: new Date
448688
448751
  }));
448752
+ this.onStreamFinish?.({
448753
+ id: this.taskId,
448754
+ cwd: this.task?.cwd ?? null,
448755
+ status: status3,
448756
+ messages: [...this.chat.messages]
448757
+ });
448689
448758
  };
448690
448759
  onError = (error46) => {
448691
448760
  logger23.error("onError", error46);
@@ -448696,6 +448765,11 @@ class LiveChatKit {
448696
448765
  data: lastMessage,
448697
448766
  updatedAt: new Date
448698
448767
  }));
448768
+ this.onStreamFailed?.({
448769
+ cwd: this.task?.cwd ?? null,
448770
+ error: error46,
448771
+ messages: [...this.chat.messages]
448772
+ });
448699
448773
  };
448700
448774
  }
448701
448775
  // src/lib/read-environment.ts
@@ -449918,7 +449992,7 @@ var parsePositiveInt = (input2) => {
449918
449992
  }
449919
449993
  return result2;
449920
449994
  };
449921
- var program5 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`. Workflows can be triggered with `/workflow-name`, like `pochi -p /create-pr`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json", "Stream the output in JSON format. This is useful for parsing the output in scripts.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "qwen/qwen3-coder").optionsGroup("MCP:").option("--no-mcp", "Disable MCP (Model Context Protocol) integration completely.").action(async (options6) => {
449995
+ var program5 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`. Workflows can be triggered with `/workflow-name`, like `pochi -p /create-pr`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json", "Stream the output in JSON format. This is useful for parsing the output in scripts.").option("-x, --output-result", "Output the result from attemptCompletion to stdout. This is useful for scripts that need to capture the final result.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "google/gemini-2.5-flash").optionsGroup("MCP:").option("--no-mcp", "Disable MCP (Model Context Protocol) integration completely.").action(async (options6) => {
449922
449996
  const customAgents = await loadAgents(process.cwd());
449923
449997
  const workflows = await loadWorkflows(process.cwd());
449924
449998
  const { uid, prompt: prompt3, attachments } = await parseTaskInput(options6, program5, {
@@ -449995,7 +450069,11 @@ ${error46}`);
449995
450069
  const renderer = new OutputRenderer(runner.state);
449996
450070
  let jsonRenderer;
449997
450071
  if (options6.streamJson) {
449998
- jsonRenderer = new JsonRenderer(store, runner.state);
450072
+ jsonRenderer = new JsonRenderer(store, runner.state, { mode: "full" });
450073
+ } else if (options6.outputResult) {
450074
+ jsonRenderer = new JsonRenderer(store, runner.state, {
450075
+ mode: "result-only"
450076
+ });
449999
450077
  }
450000
450078
  await runner.run();
450001
450079
  renderer.shutdown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpochi/cli",
3
- "version": "0.5.95",
3
+ "version": "0.5.96",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "pochi": "dist/cli.js"