aegiscode 6.8.4 → 6.8.6

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 (50) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -6
  3. package/scripts/predist.mjs +7 -0
  4. package/src/agents.js +1 -1
  5. package/src/app.js +2 -2
  6. package/src/autonomous.js +93 -3
  7. package/src/caps.js +1 -1
  8. package/src/chatflow.js +1 -1
  9. package/src/checkpoint.js +1 -1
  10. package/src/clipboard.js +1 -1
  11. package/src/commands.js +5 -5
  12. package/src/config.js +2 -2
  13. package/src/devrun.js +1 -1
  14. package/src/diff.js +1 -1
  15. package/src/entitlement.js +108 -0
  16. package/src/events.js +2 -2
  17. package/src/export.js +1 -1
  18. package/src/fuzzy.js +1 -1
  19. package/src/history.js +3 -3
  20. package/src/init.js +1 -1
  21. package/src/input.js +1 -1
  22. package/src/keys.js +1 -1
  23. package/src/markdown.js +2 -2
  24. package/src/overlays.js +2 -2
  25. package/src/panels.js +6 -6
  26. package/src/permissions.js +2 -2
  27. package/src/render.js +2 -2
  28. package/src/screen.js +4 -4
  29. package/src/screens.js +1 -1
  30. package/src/summarize.js +1 -1
  31. package/src/system.js +2 -2
  32. package/src/theme.js +6 -6
  33. package/src/tokens.js +2 -2
  34. package/src/update.js +1 -1
  35. package/vendor/client/aegis.js +146 -2
  36. package/vendor/client/credentials.js +4 -0
  37. package/vendor/desktop/lib/local/agents.js +1 -1
  38. package/vendor/desktop/lib/local/autonomous.js +70 -3
  39. package/vendor/desktop/lib/local/engine.js +19 -9
  40. package/vendor/desktop/lib/local/entitlement.js +487 -0
  41. package/vendor/desktop/lib/local/git-scope.js +1 -1
  42. package/vendor/desktop/lib/local/prompt.js +3 -3
  43. package/vendor/desktop/lib/local/queue.js +2 -2
  44. package/vendor/desktop/lib/local/shell.js +1 -1
  45. package/vendor/desktop/lib/local/tools.js +2 -2
  46. package/vendor/desktop/lib/local/turn-guard.js +1 -1
  47. package/vendor/desktop/lib/local/worktree-lock.js +1 -1
  48. package/vendor/desktop/lib/settings.js +36 -3
  49. package/vendor/desktop/renderer/usage.js +6 -6
  50. package/vendor/mcp/tools.js +9 -1
@@ -68,11 +68,11 @@ function usageTokens(usage) {
68
68
 
69
69
  /**
70
70
  * Rough token count for text the wire never measured — a direct port of the
71
- * CLI's own estimator (`aegiscodex-dev/src/tokens.js estimateTokens`), and the
71
+ * CLI's own estimator (the upstream engine's estimateTokens), and the
72
72
  * reason its session total is MONOTONIC.
73
73
  *
74
74
  * This is the whole difference being fixed. The CLI's `appendHistory`
75
- * (aegiscodex-dev/src/history.js) writes a `tokens` object for EVERY finished
75
+ * (the upstream engine's history module) writes a `tokens` object for EVERY finished
76
76
  * exchange: `{input, output, cacheRead, cacheWrite, real: true}` when the wire
77
77
  * reported usage, and `{input: estimateTokens(prompt), output:
78
78
  * estimateTokens(reply), real: false}` when it did not. `real` is a FLAG, not a
@@ -477,7 +477,7 @@ function usageBuckets(usage) {
477
477
  * Cache hit rate for a usage record: the share of prompt tokens the provider
478
478
  * actually served from its cache rather than billing at miss price.
479
479
  *
480
- * Ported from `aegiscodex-dev/src/tokens.js`. It reads through `usageBuckets`
480
+ * Ported from the upstream engine reference. It reads through `usageBuckets`
481
481
  * rather than off the raw object, which is the one deliberate difference: the
482
482
  * engine's copy is handed an already-normalised record, while this module is
483
483
  * also handed WIRE usage (a provider's raw response body) and ledger rows. A
@@ -588,7 +588,7 @@ function turnAccounting(usage, model, opts = {}) {
588
588
  const tokens = usageTokens(usage);
589
589
  const u = usage && typeof usage === 'object' ? usage : {};
590
590
  // The settled charge can arrive either on the response or folded into the
591
- // usage object — aegiscodex-dev/src/main.js does the latter
591
+ // usage object — the upstream engine does the latter
592
592
  // (`{ ...result.usage, costUsd: result.costUsd }`), so both are accepted.
593
593
  const settled = typeof opts.costUsd === 'number'
594
594
  ? opts.costUsd
@@ -703,7 +703,7 @@ function rollTurn(roll, usage, opts = {}) {
703
703
  if (turn.tokens == null) {
704
704
  // No reported usage. The CLI does not let such a turn vanish from the
705
705
  // total: `appendHistory` estimates it from the text and marks it
706
- // `real: false` (aegiscodex-dev/src/history.js), and
706
+ // `real: false` (the upstream engine's history module), and
707
707
  // `aggregateSessionUsage` then adds it like any other row. Folding the same
708
708
  // estimate here is what makes the live roll and the rebuilt roll the same
709
709
  // number, and what stops the total standing still on exactly the turns the
@@ -772,7 +772,7 @@ function rollMessages(messages) {
772
772
  * The ledger row one finished dispatch must carry into the shared session
773
773
  * store, so the rolling total can be REBUILT when the thread is reopened —
774
774
  * the desktop's counterpart of the CLI's `appendHistory`
775
- * (aegiscodex-dev/src/history.js:36).
775
+ * (the upstream engine's history module).
776
776
  *
777
777
  * One authority for the row, on purpose. The CLI writes a `tokens` object for
778
778
  * EVERY exchange and skips none:
@@ -37,6 +37,14 @@ function createTools(client) {
37
37
  // other module state.
38
38
  const aegis = client;
39
39
 
40
+ // Attribution for money prompts. A stub client (tests pass one) may not carry
41
+ // `promptUrl`, and a throw here would kill the tool body mid-message — so the
42
+ // guard degrades to an untagged link rather than to no link at all.
43
+ const promptUrl = (page, campaign) =>
44
+ typeof aegis.promptUrl === 'function'
45
+ ? aegis.promptUrl(page, campaign)
46
+ : `https://aegiscloud.org/go/${page}`;
47
+
40
48
  const TOOLS = {
41
49
  aegis_status: {
42
50
  description:
@@ -161,7 +169,7 @@ function createTools(client) {
161
169
  if ((data.balance_eur || 0) <= 0) {
162
170
  lines.push(
163
171
  '',
164
- 'Balance is empty — top up at https://aegiscloud.org/subscribe, or set your own ' +
172
+ `Balance is empty — top up at ${promptUrl('topup', 'topup_bank')}, or set your own ` +
165
173
  'provider key with aegis_byok_set to use aegis_ask for free at cost.'
166
174
  );
167
175
  }