aegiscode 7.0.13 → 7.0.15

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 (109) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +3 -2
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2932
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3008
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -3987
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/fingerprint.js +1 -592
  28. package/src/format.js +1 -259
  29. package/src/fuzzy.js +1 -119
  30. package/src/history.js +1 -401
  31. package/src/init.js +1 -175
  32. package/src/input.js +1 -139
  33. package/src/keys.js +1 -183
  34. package/src/markdown.js +1 -306
  35. package/src/models.js +1 -487
  36. package/src/naming.js +1 -229
  37. package/src/overlays.js +1 -461
  38. package/src/panels.js +1 -1418
  39. package/src/ping.js +1 -226
  40. package/src/presence.js +1 -238
  41. package/src/render.js +1 -515
  42. package/src/screen.js +1 -518
  43. package/src/screens.js +1 -896
  44. package/src/secret.js +1 -59
  45. package/src/securefs.js +1 -359
  46. package/src/settings.js +1 -155
  47. package/src/shared.js +1 -52
  48. package/src/sharedpaths.js +1 -53
  49. package/src/signup.js +1 -156
  50. package/src/summarize.js +1 -95
  51. package/src/sysdiag.js +1 -585
  52. package/src/system.js +1 -40
  53. package/src/theme.js +1 -570
  54. package/src/title.js +1 -220
  55. package/src/todos.js +1 -115
  56. package/src/tokens.js +1 -263
  57. package/src/topup.js +1 -210
  58. package/src/update.js +1 -181
  59. package/vendor/client/aegis.js +1 -2054
  60. package/vendor/client/attest.js +1 -442
  61. package/vendor/client/authorship-key.js +1 -410
  62. package/vendor/client/auto-provision.js +1 -134
  63. package/vendor/client/brain-catalog.js +1 -268
  64. package/vendor/client/byok-catalog.js +1 -230
  65. package/vendor/client/credentials.js +1 -494
  66. package/vendor/client/device-fingerprint.js +1 -141
  67. package/vendor/client/drive-connect.js +1 -85
  68. package/vendor/client/drive-upload.js +1 -174
  69. package/vendor/client/env-file.js +1 -1273
  70. package/vendor/client/fingerprint.js +1 -1064
  71. package/vendor/client/foreign-memory.js +1 -669
  72. package/vendor/client/google-signin.js +1 -125
  73. package/vendor/client/hooks.js +1 -430
  74. package/vendor/client/model-discovery.js +1 -330
  75. package/vendor/client/platform.js +1 -937
  76. package/vendor/client/prefs.js +1 -351
  77. package/vendor/client/presence-constants.js +1 -107
  78. package/vendor/client/presence.js +1 -438
  79. package/vendor/client/record-vault.js +3 -1055
  80. package/vendor/client/session-store.js +1 -548
  81. package/vendor/client/topup.js +1 -297
  82. package/vendor/client/touch.js +1 -458
  83. package/vendor/client/update.js +1 -704
  84. package/vendor/client/user-models.js +1 -381
  85. package/vendor/desktop/lib/local/agents.js +1 -105
  86. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  87. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  88. package/vendor/desktop/lib/local/context.js +1 -95
  89. package/vendor/desktop/lib/local/engine.js +1 -3228
  90. package/vendor/desktop/lib/local/entitlement.js +1 -654
  91. package/vendor/desktop/lib/local/git-scope.js +1 -228
  92. package/vendor/desktop/lib/local/local.js +1 -2135
  93. package/vendor/desktop/lib/local/prompt.js +1 -275
  94. package/vendor/desktop/lib/local/queue.js +1 -560
  95. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  96. package/vendor/desktop/lib/local/shell.js +1 -680
  97. package/vendor/desktop/lib/local/tools.js +1 -1238
  98. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  99. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  100. package/vendor/desktop/lib/settings.js +1 -890
  101. package/vendor/desktop/renderer/usage.js +1 -1239
  102. package/vendor/hosts/install.js +1 -638
  103. package/vendor/hosts/openai-shim.js +1 -515
  104. package/vendor/hosts/spec.js +1 -164
  105. package/vendor/hosts/targets.js +1 -346
  106. package/vendor/mcp/server.js +1 -221
  107. package/vendor/mcp/tools.js +1 -408
  108. package/vendor/one/src/child.js +1 -285
  109. package/vendor/one/src/permissions.js +1 -369
@@ -1,210 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Session-scoped tool-round ledger.
10
- *
11
- * The engine's tool-round cap used to be a wall. A turn that reached it ended
12
- * mid-investigation with `[stopped at 24 tool rounds…]`, and because the
13
- * accounting lived only for the duration of that call, the next turn in the
14
- * same conversation started from zero: it knew nothing about the horizon that
15
- * had just cut it off, so a long job could be truncated by the cap forever
16
- * without ever being finished.
17
- *
18
- * This makes the cap *session* state instead of turn state:
19
- *
20
- * - a turn that reaches its horizon records the unfinished work against the
21
- * session key (rounds spent, tokens, the note the user saw, and the
22
- * tool-call transcript itself — see `record`'s `messages`);
23
- * - the next turn in that session takes the record — consuming it, so one
24
- * resume per interruption and a chain of interruptions is a chain of
25
- * deliberate asks, never an automatic loop — and gets a continuation
26
- * preamble plus a small round bonus, so re-orientation does not eat the
27
- * new horizon before any work happens;
28
- * - an entry nobody comes back for expires after TTL_MS.
29
- *
30
- * State is module-level, so it outlives a turn, a `send()` and whichever
31
- * engine instance the desktop happens to be using. It never leaves the
32
- * process and is never written to disk.
33
- */
34
-
35
- /** How long an unclaimed interruption stays resumable (30 min). */
36
- const TTL_MS = 30 * 60 * 1000;
37
- /** Bound on live entries: a long-lived app must not grow without limit. */
38
- const MAX_ENTRIES = 64;
39
-
40
- const entries = new Map(); // key -> { rounds, tokens, note, at, interruptions }
41
- const historyKeys = new WeakMap(); // history[] -> key
42
- let historyKeySeq = 0;
43
-
44
- /** Drop expired entries, then the oldest ones past the bound. */
45
- function prune(now = Date.now()) {
46
- for (const [key, entry] of entries) {
47
- if (now - entry.at > TTL_MS) entries.delete(key);
48
- }
49
- while (entries.size > MAX_ENTRIES) {
50
- // Map iteration is insertion-ordered and `record` re-inserts on write, so
51
- // the first key is the oldest.
52
- const oldest = entries.keys().next();
53
- if (oldest.done) break;
54
- entries.delete(oldest.value);
55
- }
56
- return entries.size;
57
- }
58
-
59
- /**
60
- * The key an interruption is filed under. A caller that states its session
61
- * (desktop payloads carry an id) gets an exact match; otherwise the working
62
- * directory, then the identity of the history array, then a single shared
63
- * bucket. `adopt` covers the remaining case — a caller that mints a fresh key
64
- * every turn.
65
- */
66
- function keyFor(payload, history) {
67
- const p = payload && typeof payload === 'object' ? payload : {};
68
- const stated = p.sessionKey || p.sessionId || p.chatId || p.threadId || p.conversationId;
69
- if (typeof stated === 'string' && stated.trim()) return `s:${stated.trim()}`;
70
- if (typeof p.cwd === 'string' && p.cwd.trim()) return `cwd:${p.cwd.trim()}`;
71
- if (history && typeof history === 'object') {
72
- let key = historyKeys.get(history);
73
- if (!key) {
74
- historyKeySeq += 1;
75
- key = `hist-${historyKeySeq}`;
76
- historyKeys.set(history, key);
77
- }
78
- return key;
79
- }
80
- return 'default';
81
- }
82
-
83
- /**
84
- * Extra rounds granted to a resuming turn. Deliberately small and bounded: the
85
- * point of resuming is to *continue* work that already exists, not to hand out
86
- * a second full horizon (every round re-sends the whole conversation, so this
87
- * is the cheapest way to make the cap non-fatal).
88
- */
89
- function bonus(base) {
90
- const n = Number.isFinite(base) && base > 0 ? base : 0;
91
- return Math.max(4, Math.ceil(n / 4));
92
- }
93
-
94
- /** Peek without consuming — the entry stays resumable. */
95
- function peek(key, now = Date.now()) {
96
- prune(now);
97
- return entries.get(key) || null;
98
- }
99
-
100
- /** Claim the interruption for `key`, if any. Consuming: a second call gets null. */
101
- function take(key, now = Date.now()) {
102
- prune(now);
103
- const entry = entries.get(key);
104
- if (!entry) return null;
105
- entries.delete(key);
106
- return entry;
107
- }
108
-
109
- /**
110
- * Claim the most recent interruption filed under ANY key. This is the bridge
111
- * for a caller whose key does not survive between turns: the next turn on this
112
- * process adopts the held work rather than losing it. Bounded by `maxAgeMs` so
113
- * an unrelated new conversation is not handed yesterday's job.
114
- */
115
- function adopt({ now = Date.now(), maxAgeMs = 10 * 60 * 1000 } = {}) {
116
- prune(now);
117
- let bestKey = null;
118
- let best = null;
119
- for (const [key, entry] of entries) {
120
- if (now - entry.at > maxAgeMs) continue;
121
- if (!best || entry.at > best.at) {
122
- best = entry;
123
- bestKey = key;
124
- }
125
- }
126
- if (!best) return null;
127
- entries.delete(bestKey);
128
- return { key: bestKey, entry: best };
129
- }
130
-
131
- /**
132
- * File an interruption. `chain` carries the count forward from the entry this
133
- * turn resumed, so `interruptions` reports how many times one job has been cut
134
- * off — visible in the note and useful when deciding to raise the horizon.
135
- *
136
- * `messages` is the interrupted turn's own tool-call transcript (its live
137
- * `history` array at the moment it hit the horizon) — real memory of what was
138
- * already done, not just a rounds/tokens count of it. Without it a caller
139
- * that supplies no conversation of its own (a queue task's fresh dispatch)
140
- * resumes with an empty history: the model is told "continue, don't restart"
141
- * with nothing to continue FROM, which is a cold start wearing a note.
142
- * Stored as a defensive copy — the caller's `history` array keeps being
143
- * mutated by the turn that is returning it.
144
- */
145
- function record(key, { rounds, tokens, note, chain, messages, added } = {}, now = Date.now()) {
146
- prune(now);
147
- const prior = entries.get(key);
148
- const entry = {
149
- rounds: Number.isFinite(rounds) ? rounds : 0,
150
- tokens: Number.isFinite(tokens) ? tokens : 0,
151
- note: typeof note === 'string' ? note : '',
152
- at: now,
153
- interruptions: (Number.isFinite(chain) ? chain : prior && prior.interruptions) || 0,
154
- messages: Array.isArray(messages) ? messages.slice() : [],
155
- // And what the interrupted turn added on TOP of what its caller already
156
- // had. A resuming caller who brings its own conversation (an interactive
157
- // chat) must get this half, not `messages` — pushing the full transcript
158
- // into a history that already holds its first half duplicates the user's
159
- // own turns back to the model.
160
- added: Array.isArray(added) ? added.slice() : [],
161
- };
162
- entry.interruptions += 1;
163
- entries.delete(key);
164
- entries.set(key, entry); // re-insert so Map order stays age order
165
- prune(now);
166
- return entry;
167
- }
168
-
169
- /** The instruction that turns a cold start into a continuation. */
170
- function resumePreamble(entry) {
171
- const rounds = entry && entry.rounds ? entry.rounds : 'the previous turn\'s';
172
- const tokens = entry && entry.tokens ? ` (${entry.tokens.toLocaleString()} tokens)` : '';
173
- return (
174
- `[session resume] The previous turn in this conversation was cut off at ${rounds} tool rounds${tokens} ` +
175
- 'because it reached the round horizon, so the work it started is unfinished. Continue that work now: ' +
176
- 'do not restart, do not re-do steps that already completed, and do not treat the interruption as a ' +
177
- 'failure to report. Pick up the next unfinished step and finish with a written answer.'
178
- );
179
- }
180
-
181
- /** Read-only snapshot for the UI (and for tests). */
182
- function state(now = Date.now()) {
183
- prune(now);
184
- return {
185
- size: entries.size,
186
- ttlMs: TTL_MS,
187
- maxEntries: MAX_ENTRIES,
188
- entries: [...entries].map(([key, entry]) => ({ key, ...entry })),
189
- };
190
- }
191
-
192
- /** Test hook: forget everything. */
193
- function reset() {
194
- entries.clear();
195
- return entries.size;
196
- }
197
-
198
- module.exports = {
199
- TTL_MS,
200
- MAX_ENTRIES,
201
- keyFor,
202
- bonus,
203
- peek,
204
- take,
205
- adopt,
206
- record,
207
- resumePreamble,
208
- state,
209
- reset,
210
- };
3
+ "use strict";const TTL_MS=18e5,MAX_ENTRIES=64,entries=new Map,historyKeys=new WeakMap;let historyKeySeq=0;function prune(e=Date.now()){for(const[t,n]of entries)e-n.at>TTL_MS&&entries.delete(t);for(;entries.size>MAX_ENTRIES;){const e=entries.keys().next();if(e.done)break;entries.delete(e.value)}return entries.size}function keyFor(e,t){const n=e&&"object"==typeof e?e:{},r=n.sessionKey||n.sessionId||n.chatId||n.threadId||n.conversationId;if("string"==typeof r&&r.trim())return`s:${r.trim()}`;if("string"==typeof n.cwd&&n.cwd.trim())return`cwd:${n.cwd.trim()}`;if(t&&"object"==typeof t){let e=historyKeys.get(t);return e||(historyKeySeq+=1,e=`hist-${historyKeySeq}`,historyKeys.set(t,e)),e}return"default"}function bonus(e){const t=Number.isFinite(e)&&e>0?e:0;return Math.max(4,Math.ceil(t/4))}function peek(e,t=Date.now()){return prune(t),entries.get(e)||null}function take(e,t=Date.now()){prune(t);const n=entries.get(e);return n?(entries.delete(e),n):null}function adopt({now:e=Date.now(),maxAgeMs:t=6e5}={}){prune(e);let n=null,r=null;for(const[s,i]of entries)e-i.at>t||(!r||i.at>r.at)&&(r=i,n=s);return r?(entries.delete(n),{key:n,entry:r}):null}function record(e,{rounds:t,tokens:n,note:r,chain:s,messages:i,added:o}={},u=Date.now()){prune(u);const a=entries.get(e),d={rounds:Number.isFinite(t)?t:0,tokens:Number.isFinite(n)?n:0,note:"string"==typeof r?r:"",at:u,interruptions:(Number.isFinite(s)?s:a&&a.interruptions)||0,messages:Array.isArray(i)?i.slice():[],added:Array.isArray(o)?o.slice():[]};return d.interruptions+=1,entries.delete(e),entries.set(e,d),prune(u),d}function resumePreamble(e){return`[session resume] The previous turn in this conversation was cut off at ${e&&e.rounds?e.rounds:"the previous turn's"} tool rounds${e&&e.tokens?` (${e.tokens.toLocaleString()} tokens)`:""} because it reached the round horizon, so the work it started is unfinished. Continue that work now: do not restart, do not re-do steps that already completed, and do not treat the interruption as a failure to report. Pick up the next unfinished step and finish with a written answer.`}function state(e=Date.now()){return prune(e),{size:entries.size,ttlMs:TTL_MS,maxEntries:MAX_ENTRIES,entries:[...entries].map((([e,t])=>({key:e,...t})))}}function reset(){return entries.clear(),entries.size}module.exports={TTL_MS:TTL_MS,MAX_ENTRIES:MAX_ENTRIES,keyFor:keyFor,bonus:bonus,peek:peek,take:take,adopt:adopt,record:record,resumePreamble:resumePreamble,state:state,reset:reset};