clawcompany 0.41.0 → 0.50.1

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.js +76 -59
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2149,7 +2149,7 @@ import { join } from "path";
2149
2149
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
2150
2150
  function banner() {
2151
2151
  console.log("");
2152
- console.log(" \u{1F99E} ClawCompany v0.41.0");
2152
+ console.log(" \u{1F99E} ClawCompany v0.50.1");
2153
2153
  console.log(" Build for OPC. Every human being is a chairman.");
2154
2154
  console.log("");
2155
2155
  }
@@ -3670,54 +3670,87 @@ Respond ONLY with JSON:
3670
3670
  const results = /* @__PURE__ */ new Map();
3671
3671
  const totalStart = Date.now();
3672
3672
  let totalCost = 0;
3673
- const order = this.topologicalSort(workStreams);
3673
+ const completed = /* @__PURE__ */ new Set();
3674
+ const remaining = new Map(workStreams.map((ws) => [ws.id, ws]));
3674
3675
  console.log(`
3675
- \u{1F4CB} Executing ${order.length} work streams...
3676
+ \u{1F4CB} Executing ${workStreams.length} work streams (batch-parallel)...
3676
3677
  `);
3677
- for (const ws of order) {
3678
- const depOutputs = {};
3679
- for (const depId of ws.dependencies) {
3680
- const dep = results.get(depId);
3681
- if (dep && dep.status === "completed") depOutputs[depId] = dep.output;
3678
+ let batch = 1;
3679
+ while (remaining.size > 0) {
3680
+ const ready = [...remaining.values()].filter(
3681
+ (ws) => (ws.dependencies ?? []).every((dep) => completed.has(dep))
3682
+ );
3683
+ if (ready.length === 0) {
3684
+ console.log(` \u26A0\uFE0F Unresolvable dependencies \u2014 forcing remaining streams`);
3685
+ ready.push(...remaining.values());
3682
3686
  }
3683
- const role2 = this.router.getRole(ws.assignTo);
3684
- const roleName = role2?.name ?? ws.assignTo;
3685
- const modelName = role2?.model ?? "unknown";
3686
- console.log(` \u26A1 ${ws.id}: ${ws.title}`);
3687
- console.log(` \u2192 ${roleName} (${modelName})`);
3688
- const startTime = Date.now();
3689
- try {
3690
- const output = await this.executeWorkStream(ws, depOutputs);
3691
- const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
3692
- results.set(ws.id, {
3693
- workStreamId: ws.id,
3694
- title: ws.title,
3695
- assignedTo: ws.assignTo,
3696
- output: output.content,
3697
- cost: output.cost,
3698
- tokensIn: output.tokensIn,
3699
- tokensOut: output.tokensOut,
3700
- model: output.model,
3701
- status: "completed"
3702
- });
3703
- totalCost += output.cost;
3704
- console.log(` \u2705 Done (${elapsed}s, $${output.cost.toFixed(4)})
3687
+ console.log(` \u{1F4E6} Batch ${batch}: ${ready.map((ws) => ws.id).join(", ")}
3705
3688
  `);
3706
- } catch (err) {
3707
- console.log(` \u274C Failed: ${err.message}
3689
+ const MAX_RETRIES = 2;
3690
+ const batchResults = await Promise.all(ready.map(async (ws) => {
3691
+ const depOutputs = {};
3692
+ for (const depId of ws.dependencies ?? []) {
3693
+ const dep = results.get(depId);
3694
+ if (dep && dep.status === "completed") depOutputs[depId] = dep.output;
3695
+ }
3696
+ const role2 = this.router.getRole(ws.assignTo);
3697
+ const roleName = role2?.name ?? ws.assignTo;
3698
+ const modelName = role2?.model ?? "unknown";
3699
+ console.log(` \u26A1 ${ws.id}: ${ws.title}`);
3700
+ console.log(` \u2192 ${roleName} (${modelName})`);
3701
+ const startTime = Date.now();
3702
+ for (let attempt = 1; attempt <= MAX_RETRIES + 1; attempt++) {
3703
+ try {
3704
+ const output = await this.executeWorkStream(ws, depOutputs);
3705
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
3706
+ totalCost += output.cost;
3707
+ console.log(` \u2705 Done (${elapsed}s, $${output.cost.toFixed(4)})${attempt > 1 ? ` [retry ${attempt - 1}]` : ""}
3708
3708
  `);
3709
- results.set(ws.id, {
3710
- workStreamId: ws.id,
3711
- title: ws.title,
3712
- assignedTo: ws.assignTo,
3713
- output: `Error: ${err.message}`,
3714
- cost: 0,
3715
- tokensIn: 0,
3716
- tokensOut: 0,
3717
- model: "none",
3718
- status: "failed"
3719
- });
3709
+ return {
3710
+ id: ws.id,
3711
+ result: {
3712
+ workStreamId: ws.id,
3713
+ title: ws.title,
3714
+ assignedTo: ws.assignTo,
3715
+ output: output.content,
3716
+ cost: output.cost,
3717
+ tokensIn: output.tokensIn,
3718
+ tokensOut: output.tokensOut,
3719
+ model: output.model,
3720
+ status: "completed"
3721
+ }
3722
+ };
3723
+ } catch (err) {
3724
+ if (attempt <= MAX_RETRIES) {
3725
+ console.log(` \u{1F504} ${ws.id}: Retry ${attempt}/${MAX_RETRIES} \u2014 ${err.message}`);
3726
+ continue;
3727
+ }
3728
+ console.log(` \u274C Failed after ${MAX_RETRIES} retries: ${err.message}
3729
+ `);
3730
+ return {
3731
+ id: ws.id,
3732
+ result: {
3733
+ workStreamId: ws.id,
3734
+ title: ws.title,
3735
+ assignedTo: ws.assignTo,
3736
+ output: `Error: ${err.message}`,
3737
+ cost: 0,
3738
+ tokensIn: 0,
3739
+ tokensOut: 0,
3740
+ model: "none",
3741
+ status: "failed"
3742
+ }
3743
+ };
3744
+ }
3745
+ }
3746
+ throw new Error(`Unexpected: ${ws.id} exited retry loop`);
3747
+ }));
3748
+ for (const { id, result } of batchResults) {
3749
+ results.set(id, result);
3750
+ completed.add(id);
3751
+ remaining.delete(id);
3720
3752
  }
3753
+ batch++;
3721
3754
  }
3722
3755
  const totalElapsed = ((Date.now() - totalStart) / 1e3).toFixed(1);
3723
3756
  console.log(` \u{1F4CA} All work streams complete: ${totalElapsed}s, $${totalCost.toFixed(4)} total
@@ -3779,22 +3812,6 @@ Today's date is ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.`,
3779
3812
  toolCallCount: result.toolCallCount
3780
3813
  };
3781
3814
  }
3782
- topologicalSort(workStreams) {
3783
- const sorted = [];
3784
- const visited = /* @__PURE__ */ new Set();
3785
- const wsMap = new Map(workStreams.map((ws) => [ws.id, ws]));
3786
- const visit = (ws) => {
3787
- if (visited.has(ws.id)) return;
3788
- visited.add(ws.id);
3789
- for (const depId of ws.dependencies) {
3790
- const dep = wsMap.get(depId);
3791
- if (dep) visit(dep);
3792
- }
3793
- sorted.push(ws);
3794
- };
3795
- for (const ws of workStreams) visit(ws);
3796
- return sorted;
3797
- }
3798
3815
  };
3799
3816
 
3800
3817
  // src/commands/mission.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawcompany",
3
- "version": "0.41.0",
3
+ "version": "0.50.1",
4
4
  "description": "Build for OPC. Every human being is a chairman. AI company infrastructure — one key, 9 roles, 4 models.",
5
5
  "type": "module",
6
6
  "bin": { "clawcompany": "dist/index.js" },