aegiscode 7.0.14 → 7.0.16
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.
- package/SOURCE-OFFER.txt +9 -0
- package/package.json +4 -7
- package/scripts/check.mjs +1 -52
- package/scripts/demo.mjs +1 -94
- package/scripts/predist.mjs +1 -75
- package/scripts/runtests.mjs +1 -56
- package/scripts/seal-gate.mjs +1 -74
- package/src/agents.js +1 -139
- package/src/app.js +1 -2932
- package/src/art.js +1 -289
- package/src/chatflow.js +1 -3020
- package/src/checkpoint.js +1 -90
- package/src/clipboard.js +1 -424
- package/src/cloudsync.js +1 -528
- package/src/commands.js +1 -4003
- package/src/config.js +1 -581
- package/src/connect.js +1 -349
- package/src/credentials.js +1 -33
- package/src/deps.js +1 -232
- package/src/devrun.js +1 -187
- package/src/diff.js +1 -333
- package/src/diffview.js +1 -296
- package/src/engine.js +1 -297
- package/src/entitlement.js +1 -355
- package/src/events.js +1 -707
- package/src/export.js +1 -67
- package/src/fingerprint.js +1 -592
- package/src/format.js +1 -259
- package/src/fuzzy.js +1 -119
- package/src/history.js +1 -401
- package/src/init.js +1 -175
- package/src/input.js +1 -139
- package/src/keys.js +1 -183
- package/src/markdown.js +1 -306
- package/src/models.js +1 -487
- package/src/naming.js +1 -229
- package/src/overlays.js +1 -461
- package/src/panels.js +1 -1418
- package/src/ping.js +1 -226
- package/src/presence.js +1 -238
- package/src/render.js +1 -515
- package/src/screen.js +1 -518
- package/src/screens.js +1 -896
- package/src/secret.js +1 -59
- package/src/securefs.js +1 -359
- package/src/settings.js +1 -155
- package/src/shared.js +1 -52
- package/src/sharedpaths.js +1 -53
- package/src/signup.js +1 -156
- package/src/summarize.js +1 -95
- package/src/sysdiag.js +1 -585
- package/src/system.js +1 -40
- package/src/theme.js +1 -570
- package/src/title.js +1 -220
- package/src/todos.js +1 -115
- package/src/tokens.js +1 -263
- package/src/topup.js +1 -210
- package/src/update.js +1 -181
- package/vendor/client/aegis.js +1 -2179
- package/vendor/client/attest.js +1 -442
- package/vendor/client/authorship-key.js +1 -410
- package/vendor/client/auto-provision.js +1 -134
- package/vendor/client/brain-catalog.js +1 -268
- package/vendor/client/byok-catalog.js +1 -230
- package/vendor/client/credentials.js +1 -494
- package/vendor/client/device-fingerprint.js +1 -141
- package/vendor/client/drive-connect.js +1 -110
- package/vendor/client/drive-upload.js +1 -174
- package/vendor/client/env-file.js +1 -1273
- package/vendor/client/fingerprint.js +1 -1064
- package/vendor/client/foreign-memory.js +1 -669
- package/vendor/client/google-signin.js +1 -133
- package/vendor/client/hooks.js +1 -430
- package/vendor/client/model-discovery.js +1 -373
- package/vendor/client/platform.js +1 -937
- package/vendor/client/prefs.js +1 -351
- package/vendor/client/presence-constants.js +1 -107
- package/vendor/client/presence.js +1 -438
- package/vendor/client/record-vault.js +3 -1055
- package/vendor/client/session-store.js +1 -548
- package/vendor/client/topup.js +1 -297
- package/vendor/client/touch.js +1 -458
- package/vendor/client/update.js +1 -704
- package/vendor/client/user-models.js +1 -381
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/desktop/lib/settings.js +1 -890
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/hosts/install.js +1 -638
- package/vendor/hosts/openai-shim.js +1 -515
- package/vendor/hosts/spec.js +1 -164
- package/vendor/hosts/targets.js +1 -346
- package/vendor/mcp/server.js +1 -221
- package/vendor/mcp/tools.js +1 -408
- package/vendor/one/src/child.js +1 -285
- package/vendor/one/src/permissions.js +1 -369
|
@@ -1,97 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
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
|
-
* context.js — token-budget trimmer for very large inputs (plan P1 §5.1 /
|
|
10
|
-
* P2 §6.4).
|
|
11
|
-
*
|
|
12
|
-
* Pure Node, no Electron imports. Estimates tokens with a ~4 chars/token
|
|
13
|
-
* heuristic, keeps the system message plus the newest turns, and drops the
|
|
14
|
-
* oldest turns that exceed the budget. The full transcript always stays in
|
|
15
|
-
* the local session record — this only trims what is sent to the wire.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const CHARS_PER_TOKEN = 4;
|
|
19
|
-
const MESSAGE_OVERHEAD = 4; // per-message framing + role overhead
|
|
20
|
-
|
|
21
|
-
/** Rough token count for a string (no tokenizer in a zero-dep shell). */
|
|
22
|
-
function estimateTokens(text) {
|
|
23
|
-
if (text == null) return 0;
|
|
24
|
-
const s = typeof text === 'string' ? text : String(text);
|
|
25
|
-
return Math.max(0, Math.ceil(s.length / CHARS_PER_TOKEN));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Rough token cost of one { role, content } message. */
|
|
29
|
-
function messageTokens(message) {
|
|
30
|
-
if (!message) return 0;
|
|
31
|
-
const content =
|
|
32
|
-
message.content != null
|
|
33
|
-
? message.content
|
|
34
|
-
: message.text != null
|
|
35
|
-
? message.text
|
|
36
|
-
: '';
|
|
37
|
-
return MESSAGE_OVERHEAD + estimateTokens(content);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Trim a message list to fit a token budget, keeping the newest turns.
|
|
42
|
-
*
|
|
43
|
-
* @param {object} opts
|
|
44
|
-
* @param {Array<{role:string,content:string}>} [opts.messages=[]]
|
|
45
|
-
* @param {string} [opts.system='']
|
|
46
|
-
* @param {number} [opts.budgetTokens=8192] total tokens allowed on the wire
|
|
47
|
-
* @param {number} [opts.reserveTokens=0] tokens reserved for the reply
|
|
48
|
-
* @param {number} [opts.fixedTokens=0] wire cost that is NOT a message and
|
|
49
|
-
* cannot be dropped (the tool schemas), counted before any turn is kept
|
|
50
|
-
* @returns {{messages:Array, system:string, dropped:number, estimatedTokens:number, fixedTokens:number}}
|
|
51
|
-
*/
|
|
52
|
-
function trimContext({
|
|
53
|
-
messages = [],
|
|
54
|
-
system = '',
|
|
55
|
-
budgetTokens = 8192,
|
|
56
|
-
reserveTokens = 0,
|
|
57
|
-
fixedTokens = 0,
|
|
58
|
-
} = {}) {
|
|
59
|
-
const limit = Math.max(0, budgetTokens - reserveTokens);
|
|
60
|
-
const kept = [];
|
|
61
|
-
// Tool schemas go on the wire every round and cannot be trimmed away, so they
|
|
62
|
-
// are charged against the budget FIRST. Without this the trimmer believed a
|
|
63
|
-
// 4096-token window had 4096 tokens for history when the schemas had already
|
|
64
|
-
// spent ~1971 of them (measured: 10 schemas, 7882 chars) — and the daemon,
|
|
65
|
-
// run with `--context-shift`, discarded the SYSTEM row to make room instead
|
|
66
|
-
// of erroring. Counting them here is what keeps the system row alive.
|
|
67
|
-
const fixed = Math.max(0, Number(fixedTokens) || 0);
|
|
68
|
-
let used = fixed;
|
|
69
|
-
|
|
70
|
-
if (system) used += MESSAGE_OVERHEAD + estimateTokens(system);
|
|
71
|
-
|
|
72
|
-
// Walk newest -> oldest; keep a turn if it fits, else stop (older turns are
|
|
73
|
-
// even less relevant). Always keep at least the newest turn so a single
|
|
74
|
-
// oversized message is still sent rather than silently emptied.
|
|
75
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
76
|
-
const cost = messageTokens(messages[i]);
|
|
77
|
-
if (used + cost > limit && kept.length > 0) break;
|
|
78
|
-
kept.unshift(messages[i]);
|
|
79
|
-
used += cost;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
messages: kept,
|
|
84
|
-
system,
|
|
85
|
-
dropped: messages.length - kept.length,
|
|
86
|
-
estimatedTokens: used,
|
|
87
|
-
fixedTokens: fixed,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = {
|
|
92
|
-
CHARS_PER_TOKEN,
|
|
93
|
-
MESSAGE_OVERHEAD,
|
|
94
|
-
estimateTokens,
|
|
95
|
-
messageTokens,
|
|
96
|
-
trimContext,
|
|
97
|
-
};
|
|
3
|
+
"use strict";const CHARS_PER_TOKEN=4,MESSAGE_OVERHEAD=4;function estimateTokens(e){if(null==e)return 0;const t="string"==typeof e?e:String(e);return Math.max(0,Math.ceil(t.length/CHARS_PER_TOKEN))}function messageTokens(e){if(!e)return 0;const t=null!=e.content?e.content:null!=e.text?e.text:"";return MESSAGE_OVERHEAD+estimateTokens(t)}function trimContext({messages:e=[],system:t="",budgetTokens:s=8192,reserveTokens:n=0,fixedTokens:o=0}={}){const E=Math.max(0,s-n),r=[],i=Math.max(0,Number(o)||0);let m=i;t&&(m+=MESSAGE_OVERHEAD+estimateTokens(t));for(let t=e.length-1;t>=0;t--){const s=messageTokens(e[t]);if(m+s>E&&r.length>0)break;r.unshift(e[t]),m+=s}return{messages:r,system:t,dropped:e.length-r.length,estimatedTokens:m,fixedTokens:i}}module.exports={CHARS_PER_TOKEN:CHARS_PER_TOKEN,MESSAGE_OVERHEAD:MESSAGE_OVERHEAD,estimateTokens:estimateTokens,messageTokens:messageTokens,trimContext:trimContext};
|