portable-agent-layer 0.97.0 → 0.99.0

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 (38) hide show
  1. package/README.md +1 -0
  2. package/package.json +2 -2
  3. package/src/cli/cost.ts +18 -0
  4. package/src/cli/events.ts +22 -0
  5. package/src/cli/tree.ts +2 -0
  6. package/src/hooks/lib/commitment-events.ts +3 -3
  7. package/src/hooks/lib/entity-events.ts +18 -5
  8. package/src/hooks/lib/events.ts +54 -4
  9. package/src/hooks/lib/interaction.ts +25 -5
  10. package/src/hooks/lib/ledger.ts +61 -2
  11. package/src/hooks/lib/models.ts +42 -10
  12. package/src/hooks/lib/remote.ts +3 -0
  13. package/src/hooks/lib/signals.ts +54 -4
  14. package/src/hooks/lib/work-tracking.ts +39 -2
  15. package/src/targets/lib.ts +1 -3
  16. package/src/tools/agent/project.ts +7 -2
  17. package/src/tools/knowledge/lib.ts +11 -2
  18. package/src/tools/lib/backfill/entities.ts +31 -0
  19. package/src/tools/lib/backfill/git.ts +184 -0
  20. package/src/tools/lib/backfill/index.ts +38 -0
  21. package/src/tools/lib/backfill/ledger.ts +28 -0
  22. package/src/tools/lib/backfill/projects.ts +40 -0
  23. package/src/tools/lib/backfill/promises.ts +91 -0
  24. package/src/tools/lib/backfill/ratings.ts +21 -0
  25. package/src/tools/lib/backfill/rows.ts +33 -0
  26. package/src/tools/lib/backfill/sessions.ts +56 -0
  27. package/src/tools/lib/backfill/turns.ts +32 -0
  28. package/src/tools/lib/collectors/billing.ts +105 -0
  29. package/src/tools/lib/collectors/claude.ts +61 -21
  30. package/src/tools/lib/collectors/codex.ts +6 -3
  31. package/src/tools/lib/collectors/copilot.ts +2 -0
  32. package/src/tools/lib/collectors/index.ts +8 -1
  33. package/src/tools/lib/collectors/opencode.ts +10 -2
  34. package/src/tools/lib/cost-report.ts +134 -0
  35. package/src/tools/lib/plan-prices.ts +24 -0
  36. package/src/tools/lib/project-history.ts +100 -0
  37. package/src/tools/lib/session-usage.ts +11 -7
  38. package/src/tools/lib/usage-buckets.ts +10 -5
@@ -90,8 +90,13 @@ function addCall(bucket: Bucket, tokens: Tokens, cost: number | null, calls = 1)
90
90
  if (cost === null) bucket.unpriced += calls;
91
91
  }
92
92
 
93
- export function addToBucket(bucket: Bucket, model: string, tokens: Tokens): void {
94
- addCall(bucket, tokens, costOfUsage(model, tokens));
93
+ export function addToBucket(
94
+ bucket: Bucket,
95
+ model: string,
96
+ tokens: Tokens,
97
+ ts: string
98
+ ): void {
99
+ addCall(bucket, tokens, costOfUsage(model, tokens, ts));
95
100
  }
96
101
 
97
102
  /**
@@ -117,7 +122,7 @@ export function addToTimeBuckets(
117
122
  tokens: Tokens,
118
123
  horizons: Horizons
119
124
  ): void {
120
- addToWindows(buckets, ts, horizons, (bucket) => addToBucket(bucket, model, tokens));
125
+ addToWindows(buckets, ts, horizons, (bucket) => addToBucket(bucket, model, tokens, ts));
121
126
  }
122
127
 
123
128
  export function totalTokens(bucket: Bucket): number {
@@ -290,7 +295,7 @@ export function readClaudeCode(
290
295
  model: call.model,
291
296
  tokens: call.tokens,
292
297
  project: call.project,
293
- cost: costOfUsage(call.model, call.tokens),
298
+ cost: costOfUsage(call.model, call.tokens, call.ts),
294
299
  });
295
300
  }
296
301
  return tally.usage;
@@ -357,7 +362,7 @@ export function readPalInference(
357
362
  );
358
363
 
359
364
  result.byCaller[entry.caller] ??= emptyBucket();
360
- addToBucket(result.byCaller[entry.caller], entry.model, tokens);
365
+ addToBucket(result.byCaller[entry.caller], entry.model, tokens, entry.ts);
361
366
  }
362
367
 
363
368
  return result;