aegiscode 6.7.4 → 6.7.5
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.7.
|
|
4
|
+
"version": "6.7.5",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
|
@@ -87,8 +87,28 @@ const CLASSES = [
|
|
|
87
87
|
{ class: 'ollama', label: 'Ollama (local)', kind: 'local' },
|
|
88
88
|
{ class: 'openai-compat', label: 'Custom OpenAI-compatible', kind: 'custom' },
|
|
89
89
|
{ class: 'anthropic', label: 'Anthropic-compatible', kind: 'custom' },
|
|
90
|
+
{ class: 'byok', label: 'Bring your own key', kind: 'cloud' },
|
|
90
91
|
];
|
|
91
92
|
|
|
93
|
+
/** Local settings namespace for one BYOK provider's key. A `byok:` prefix
|
|
94
|
+
* keeps this out of the 'anthropic'/'openai-compat' CUSTOM_CLASSES' own
|
|
95
|
+
* namespaces, which are a different feature (a self-hosted/compatible
|
|
96
|
+
* endpoint's base URL + key) — same store, deliberately separate rows. */
|
|
97
|
+
function byokNamespace(providerId) {
|
|
98
|
+
return `byok:${providerId}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Split a byok model id ("anthropic:claude-sonnet-5") into its provider and
|
|
102
|
+
* bare model parts. `modelId` may itself contain ':' (none of today's
|
|
103
|
+
* catalog ids do, but nothing guarantees that), so only the FIRST segment is
|
|
104
|
+
* the provider — the rest re-joins as the model. */
|
|
105
|
+
function splitByokModel(compound) {
|
|
106
|
+
const s = typeof compound === 'string' ? compound : '';
|
|
107
|
+
const i = s.indexOf(':');
|
|
108
|
+
if (i < 0) return { provider: '', model: s };
|
|
109
|
+
return { provider: s.slice(0, i), model: s.slice(i + 1) };
|
|
110
|
+
}
|
|
111
|
+
|
|
92
112
|
/**
|
|
93
113
|
* Mirrors aegiscodex-dev's src/backend.js DEEPSEEK_REASONING_MODEL_RE +
|
|
94
114
|
* EFFORT_TOKEN_BUDGET verbatim. DeepSeek's reasoning models (deepseek-flash,
|
|
@@ -657,6 +677,16 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
657
677
|
if (c.class === 'aegis') {
|
|
658
678
|
return { ...c, configured: Boolean(aegis.apiKey) };
|
|
659
679
|
}
|
|
680
|
+
if (c.class === 'byok') {
|
|
681
|
+
// Configured means "at least one provider has a locally-stored key",
|
|
682
|
+
// not a single baseURL+key pair like the CUSTOM_CLASSES below — byok
|
|
683
|
+
// holds one row per provider (byokNamespace), so customStatus's shape
|
|
684
|
+
// does not apply here.
|
|
685
|
+
const anyConfigured = (settings.list() || []).some(
|
|
686
|
+
(s) => s && typeof s.provider === 'string' && s.provider.startsWith('byok:') && s.configured
|
|
687
|
+
);
|
|
688
|
+
return { ...c, configured: anyConfigured };
|
|
689
|
+
}
|
|
660
690
|
return { ...c, ...customStatus(c.class) };
|
|
661
691
|
});
|
|
662
692
|
}
|
|
@@ -681,6 +711,41 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
681
711
|
const tags = await ollama.listTags();
|
|
682
712
|
return { class: cls, models: tags.map((t) => ({ id: t.id })) };
|
|
683
713
|
}
|
|
714
|
+
if (cls === 'byok') {
|
|
715
|
+
// The server's catalog names every provider it accepts a key for, the
|
|
716
|
+
// models each unlocks, and whether an AEGIS account key is even needed
|
|
717
|
+
// to ask (it is not — see byokProviders' own docstring). Deliberately
|
|
718
|
+
// NOT gated on aegis.apiKey the way the pooled class above is: BYOK's
|
|
719
|
+
// whole point is a caller who brings their own credential, and the
|
|
720
|
+
// catalog itself answers to an anonymous request.
|
|
721
|
+
let providers = [];
|
|
722
|
+
try {
|
|
723
|
+
const data = await aegis.byokProviders();
|
|
724
|
+
providers = (data && data.providers) || [];
|
|
725
|
+
} catch {
|
|
726
|
+
providers = [];
|
|
727
|
+
}
|
|
728
|
+
const models = [];
|
|
729
|
+
for (const p of providers) {
|
|
730
|
+
if (!p || !p.id) continue;
|
|
731
|
+
const local = settings.get(byokNamespace(p.id)) || {};
|
|
732
|
+
const rawModels = Array.isArray(p.models) ? p.models : [];
|
|
733
|
+
for (const m of rawModels) {
|
|
734
|
+
const modelId = typeof m === 'string' ? m : m && m.id;
|
|
735
|
+
if (!modelId) continue;
|
|
736
|
+
models.push({
|
|
737
|
+
id: `${p.id}:${modelId}`,
|
|
738
|
+
label: `${p.label || p.id} — ${modelId}`,
|
|
739
|
+
provider: p.id,
|
|
740
|
+
configured: Boolean(local.configured),
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
class: cls, models, providers,
|
|
746
|
+
needsProviderKey: models.length > 0 && !models.some((m) => m.configured),
|
|
747
|
+
};
|
|
748
|
+
}
|
|
684
749
|
// Custom endpoints: the model id is the *user's* choice — a provider model
|
|
685
750
|
// name, never a URL. Offering the configured base URL as an `id` meant that
|
|
686
751
|
// leaving the default selection POSTed `model: "https://api.openai.com/v1"`,
|
|
@@ -867,6 +932,29 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
867
932
|
});
|
|
868
933
|
}
|
|
869
934
|
|
|
935
|
+
if (cls === 'byok') {
|
|
936
|
+
// opts.model is still the compound "provider:model" id here — the
|
|
937
|
+
// relay wants them split (a `provider` field plus a bare `model`).
|
|
938
|
+
// opts.apiKey is the PROVIDER key resolved by chat() above (from the
|
|
939
|
+
// byokNamespace(provider) settings row), never the account's own AEGIS
|
|
940
|
+
// key — that one is baked into the `aegis` client already and attached
|
|
941
|
+
// automatically by byokChatCompletion() as X-AEGIS-Key so the account
|
|
942
|
+
// gets billed the handling fee; see client/aegis.js.
|
|
943
|
+
const { provider, model: bareModel } = splitByokModel(opts.model);
|
|
944
|
+
return aegis.byokChatCompletion({
|
|
945
|
+
provider,
|
|
946
|
+
model: bareModel,
|
|
947
|
+
providerKey: opts.apiKey,
|
|
948
|
+
prompt: opts.prompt,
|
|
949
|
+
system: opts.system,
|
|
950
|
+
messages: opts.messages,
|
|
951
|
+
maxTokens: opts.maxTokens,
|
|
952
|
+
stream: true,
|
|
953
|
+
onStream: opts.onDelta,
|
|
954
|
+
signal: opts.signal,
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
|
|
870
958
|
const common = {
|
|
871
959
|
baseURL: opts.cfg.baseURL,
|
|
872
960
|
apiKey: opts.apiKey,
|
|
@@ -887,7 +975,14 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
887
975
|
async function chat(payload, onDelta) {
|
|
888
976
|
const cls = payload && payload.class;
|
|
889
977
|
const model = payload && payload.model;
|
|
890
|
-
|
|
978
|
+
// byok's model id is "provider:model" (see splitByokModel) — strip the
|
|
979
|
+
// provider prefix before pattern-matching, or a DeepSeek reasoning model
|
|
980
|
+
// selected under byok ("byok" model "deepseek:deepseek-v4-flash") never
|
|
981
|
+
// matches DEEPSEEK_REASONING_MODEL_RE's anchored pattern and silently
|
|
982
|
+
// gets no stated budget, which is exactly the "hidden CoT ate the whole
|
|
983
|
+
// default and returned nothing" failure this budget exists to prevent.
|
|
984
|
+
const reasoningModelId = cls === 'byok' ? splitByokModel(model).model : model;
|
|
985
|
+
const maxTokens = reasoningBudget(cls, reasoningModelId, payload && payload.maxTokens, payload && payload.effort);
|
|
891
986
|
// The caller's OWN number, kept apart from `maxTokens` above. That one
|
|
892
987
|
// collapses two different facts into a single value — "the caller stated
|
|
893
988
|
// 4096" and "effort implies 32768" — and the pooled path must treat them
|
|
@@ -937,8 +1032,12 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
937
1032
|
const signal = controller.signal;
|
|
938
1033
|
|
|
939
1034
|
// A caller can opt out of the agent loop entirely (`tools: false`) and get
|
|
940
|
-
// the old single-shot turn back.
|
|
941
|
-
|
|
1035
|
+
// the old single-shot turn back. byok is ALWAYS single-shot: the
|
|
1036
|
+
// stateless relay (aegis.byokChatCompletion, /api/v1/byok/chat/completions)
|
|
1037
|
+
// has no tools/tool_choice parameter at all, so sending schemas here would
|
|
1038
|
+
// build a prompt promising tool access the transport silently drops —
|
|
1039
|
+
// the model would reason about exec/readFile and never see a result.
|
|
1040
|
+
const toolsEnabled = cls !== 'byok' && !(payload && payload.tools === false);
|
|
942
1041
|
const wire = cls === 'anthropic' ? 'anthropic' : 'openai';
|
|
943
1042
|
const toolSchemas = toolsEnabled ? T.toolsFor(wire, { includeSubagent: depth < MAX_SUBAGENT_DEPTH }) : [];
|
|
944
1043
|
const toolChoice = (payload && payload.toolChoice) || null;
|
|
@@ -965,8 +1064,35 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
965
1064
|
const turnCwd = envFor(payload).cwd;
|
|
966
1065
|
|
|
967
1066
|
try {
|
|
968
|
-
|
|
969
|
-
|
|
1067
|
+
// byok's settings row lives under the provider named IN THE MODEL id
|
|
1068
|
+
// ("anthropic:claude-sonnet-5" -> byokNamespace('anthropic')), never
|
|
1069
|
+
// under the literal class name — one flat 'byok' row could not hold
|
|
1070
|
+
// more than one provider's key at a time.
|
|
1071
|
+
const byokParts = cls === 'byok' ? splitByokModel(model) : null;
|
|
1072
|
+
const cfg =
|
|
1073
|
+
cls === 'aegis' || cls === 'ollama' ? {}
|
|
1074
|
+
: cls === 'byok' ? settings.get(byokNamespace(byokParts.provider)) || {}
|
|
1075
|
+
: settings.get(cls) || {};
|
|
1076
|
+
const apiKey =
|
|
1077
|
+
cls === 'aegis' || cls === 'ollama' ? null
|
|
1078
|
+
: cls === 'byok' ? settings.rawKey(byokNamespace(byokParts.provider))
|
|
1079
|
+
: settings.rawKey(cls);
|
|
1080
|
+
|
|
1081
|
+
if (cls === 'byok' && (!byokParts.provider || !byokParts.model)) {
|
|
1082
|
+
const err = new Error(
|
|
1083
|
+
"byok: model must be \"<provider>:<model>\" (pick one from /models) — got " +
|
|
1084
|
+
JSON.stringify(model || '')
|
|
1085
|
+
);
|
|
1086
|
+
err.status = 400;
|
|
1087
|
+
throw err;
|
|
1088
|
+
}
|
|
1089
|
+
if (cls === 'byok' && !apiKey) {
|
|
1090
|
+
const err = new Error(
|
|
1091
|
+
`byok: no key saved for "${byokParts.provider}" — add one before chatting with this model.`
|
|
1092
|
+
);
|
|
1093
|
+
err.status = 400;
|
|
1094
|
+
throw err;
|
|
1095
|
+
}
|
|
970
1096
|
|
|
971
1097
|
// Custom classes carry no enumerable model list (see listModels), so a
|
|
972
1098
|
// blank id here means the user never typed one. Fail loudly in-process
|