longer-agent 0.1.0 → 0.1.2
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/README.md +84 -43
- package/README.zh-CN.md +83 -42
- package/agent_templates/main/agent.yaml +1 -0
- package/dist/auth/openai-oauth.d.ts.map +1 -1
- package/dist/auth/openai-oauth.js +6 -10
- package/dist/auth/openai-oauth.js.map +1 -1
- package/dist/cli.d.ts +1 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +81 -60
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts +6 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +115 -26
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +19 -26
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +80 -120
- package/dist/config.js.map +1 -1
- package/dist/dotenv.d.ts +18 -0
- package/dist/dotenv.d.ts.map +1 -0
- package/dist/dotenv.js +91 -0
- package/dist/dotenv.js.map +1 -0
- package/dist/home-path.d.ts +3 -0
- package/dist/home-path.d.ts.map +1 -0
- package/dist/home-path.js +7 -0
- package/dist/home-path.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/init-wizard.d.ts +2 -3
- package/dist/init-wizard.d.ts.map +1 -1
- package/dist/init-wizard.js +349 -145
- package/dist/init-wizard.js.map +1 -1
- package/dist/managed-provider-credentials.d.ts +23 -0
- package/dist/managed-provider-credentials.d.ts.map +1 -0
- package/dist/managed-provider-credentials.js +56 -0
- package/dist/managed-provider-credentials.js.map +1 -0
- package/dist/mcp-client.d.ts.map +1 -1
- package/dist/mcp-client.js +2 -1
- package/dist/mcp-client.js.map +1 -1
- package/dist/mcp-config.d.ts +13 -0
- package/dist/mcp-config.d.ts.map +1 -0
- package/dist/mcp-config.js +64 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/model-discovery.d.ts +20 -0
- package/dist/model-discovery.d.ts.map +1 -0
- package/dist/model-discovery.js +47 -0
- package/dist/model-discovery.js.map +1 -0
- package/dist/model-selection.d.ts +1 -1
- package/dist/model-selection.d.ts.map +1 -1
- package/dist/model-selection.js +20 -10
- package/dist/model-selection.js.map +1 -1
- package/dist/persistence.d.ts +12 -0
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +8 -6
- package/dist/persistence.js.map +1 -1
- package/dist/provider-credential-flow.d.ts +28 -0
- package/dist/provider-credential-flow.d.ts.map +1 -0
- package/dist/provider-credential-flow.js +112 -0
- package/dist/provider-credential-flow.js.map +1 -0
- package/dist/provider-presets.d.ts +4 -0
- package/dist/provider-presets.d.ts.map +1 -1
- package/dist/provider-presets.js +26 -9
- package/dist/provider-presets.js.map +1 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +3 -2
- package/dist/providers/registry.js.map +1 -1
- package/dist/session.d.ts +6 -15
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +34 -60
- package/dist/session.js.map +1 -1
- package/dist/settings.d.ts +8 -27
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -108
- package/dist/settings.js.map +1 -1
- package/dist/tui/app.d.ts.map +1 -1
- package/dist/tui/app.js +116 -2
- package/dist/tui/app.js.map +1 -1
- package/dist/tui/components/command-prompt-panel.d.ts +22 -0
- package/dist/tui/components/command-prompt-panel.d.ts.map +1 -0
- package/dist/tui/components/command-prompt-panel.js +26 -0
- package/dist/tui/components/command-prompt-panel.js.map +1 -0
- package/dist/tui/components/logo-panel.d.ts.map +1 -1
- package/dist/tui/components/logo-panel.js +2 -4
- package/dist/tui/components/logo-panel.js.map +1 -1
- package/dist/update-check.d.ts +19 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +116 -0
- package/dist/update-check.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +7 -3
- package/configExample.yaml +0 -83
package/dist/session.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Agent, isNoReply, NO_REPLY_MARKER } from "./agents/agent.js";
|
|
|
16
16
|
import { createEphemeralLogState } from "./ephemeral-log.js";
|
|
17
17
|
import { allocateContextId, stripContextTags, ContextTagStripBuffer } from "./context-rendering.js";
|
|
18
18
|
import { generateShowContext } from "./show-context.js";
|
|
19
|
-
import { getThinkingLevels
|
|
19
|
+
import { getThinkingLevels } from "./config.js";
|
|
20
20
|
import { ToolResult } from "./providers/base.js";
|
|
21
21
|
import { SPAWN_AGENT_TOOL, KILL_AGENT_TOOL, CHECK_STATUS_TOOL, WAIT_TOOL, SHOW_CONTEXT_TOOL, SUMMARIZE_CONTEXT_TOOL, ASK_TOOL, PLAN_TOOL, } from "./tools/comm.js";
|
|
22
22
|
import { buildBashEnv, executeTool, } from "./tools/basic.js";
|
|
@@ -30,7 +30,7 @@ import { LogIdAllocator, createSystemPrompt, createTurnStart, createUserMessage
|
|
|
30
30
|
import { projectToApiMessages } from "./log-projection.js";
|
|
31
31
|
import { archiveWindow, createGlobalTuiPreferences, createLogSessionMeta, } from "./persistence.js";
|
|
32
32
|
import { resolvePersistedModelSelection, } from "./model-selection.js";
|
|
33
|
-
import { DEFAULT_THRESHOLDS,
|
|
33
|
+
import { DEFAULT_THRESHOLDS, } from "./settings.js";
|
|
34
34
|
// ------------------------------------------------------------------
|
|
35
35
|
// Constants
|
|
36
36
|
// ------------------------------------------------------------------
|
|
@@ -211,8 +211,8 @@ export class Session {
|
|
|
211
211
|
_thresholds = { ...DEFAULT_THRESHOLDS };
|
|
212
212
|
_hintResetNone = DEFAULT_THRESHOLDS.summarize_hint_level1 / 100 - 0.20;
|
|
213
213
|
_hintResetLevel1 = (DEFAULT_THRESHOLDS.summarize_hint_level1 + DEFAULT_THRESHOLDS.summarize_hint_level2) / 200;
|
|
214
|
-
//
|
|
215
|
-
|
|
214
|
+
// Context window multiplier (0.0–1.0). Effective context = contextLength × _contextRatio.
|
|
215
|
+
_contextRatio = 1.0;
|
|
216
216
|
// Hint compression (two-tier state machine)
|
|
217
217
|
_hintState = "none";
|
|
218
218
|
// show_context: number of remaining rounds where annotations are active
|
|
@@ -275,19 +275,18 @@ export class Session {
|
|
|
275
275
|
this._progress = opts.progress;
|
|
276
276
|
this._mcpManager = opts.mcpManager;
|
|
277
277
|
this._promptsDirs = opts.promptsDirs;
|
|
278
|
-
// Apply
|
|
279
|
-
if (opts.
|
|
280
|
-
this.
|
|
278
|
+
// Apply context ratio
|
|
279
|
+
if (opts.contextRatio !== undefined) {
|
|
280
|
+
this._contextRatio = Math.max(0.01, Math.min(1.0, opts.contextRatio));
|
|
281
281
|
}
|
|
282
282
|
// Attach store if provided (must be set before _initConversation)
|
|
283
283
|
if (opts.store) {
|
|
284
284
|
this._store = opts.store;
|
|
285
285
|
}
|
|
286
286
|
// Resolve path variables
|
|
287
|
-
|
|
288
|
-
this.
|
|
289
|
-
this.
|
|
290
|
-
this._systemData = pathOverrides.systemData ?? "";
|
|
287
|
+
this._projectRoot = process.cwd();
|
|
288
|
+
this._sessionArtifactsOverride = "";
|
|
289
|
+
this._systemData = "";
|
|
291
290
|
this._createdAt = new Date().toISOString();
|
|
292
291
|
this._initConversation();
|
|
293
292
|
this._toolExecutors = this._buildToolExecutors();
|
|
@@ -318,26 +317,10 @@ export class Session {
|
|
|
318
317
|
this._appendEntry(createSystemPrompt(this._nextLogId("system_prompt"), systemPrompt), false);
|
|
319
318
|
}
|
|
320
319
|
/**
|
|
321
|
-
*
|
|
320
|
+
* Effective context length for a given ModelConfig, scaled by context ratio.
|
|
322
321
|
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const hysteresis = computeHysteresisThresholds(s.thresholds);
|
|
326
|
-
this._hintResetNone = hysteresis.hintResetNone / 100;
|
|
327
|
-
this._hintResetLevel1 = hysteresis.hintResetLevel1 / 100;
|
|
328
|
-
this._settingsMaxOutputTokens = s.maxOutputTokens;
|
|
329
|
-
// Apply to current primary agent's model config
|
|
330
|
-
this._applyMaxOutputTokensOverride(this.primaryAgent.modelConfig);
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Effective maxTokens for a given ModelConfig, taking settings override into account.
|
|
334
|
-
* Clamps to [4096, modelMaxOutputTokens].
|
|
335
|
-
*/
|
|
336
|
-
_effectiveMaxTokens(mc) {
|
|
337
|
-
if (this._settingsMaxOutputTokens === undefined)
|
|
338
|
-
return mc.maxTokens;
|
|
339
|
-
const modelMax = getModelMaxOutputTokens(mc.model);
|
|
340
|
-
return Math.max(4096, Math.min(this._settingsMaxOutputTokens, modelMax ?? mc.maxTokens));
|
|
322
|
+
_effectiveContextLength(mc) {
|
|
323
|
+
return Math.round(mc.contextLength * this._contextRatio);
|
|
341
324
|
}
|
|
342
325
|
// ==================================================================
|
|
343
326
|
// Message infrastructure
|
|
@@ -790,7 +773,6 @@ export class Session {
|
|
|
790
773
|
const restoredThinkingPreference = meta.thinkingLevel ?? "default";
|
|
791
774
|
const restoredCachePreference = meta.cacheHitEnabled ?? true;
|
|
792
775
|
this._resetTransientState();
|
|
793
|
-
this._applyMaxOutputTokensOverride(restoredModelConfig);
|
|
794
776
|
this.primaryAgent.replaceModelConfig(restoredModelConfig);
|
|
795
777
|
this._persistedModelSelection = this._buildPersistedModelSelection({
|
|
796
778
|
modelConfigName: restoredSelection.selectedConfigName,
|
|
@@ -969,6 +951,12 @@ export class Session {
|
|
|
969
951
|
get skills() {
|
|
970
952
|
return this._skills;
|
|
971
953
|
}
|
|
954
|
+
get mcpManager() {
|
|
955
|
+
return this._mcpManager;
|
|
956
|
+
}
|
|
957
|
+
async ensureMcpReady() {
|
|
958
|
+
await this._ensureMcp();
|
|
959
|
+
}
|
|
972
960
|
/** Read-only access to disabled skill names. */
|
|
973
961
|
get disabledSkills() {
|
|
974
962
|
return this._disabledSkills;
|
|
@@ -1145,7 +1133,6 @@ export class Session {
|
|
|
1145
1133
|
*/
|
|
1146
1134
|
switchModel(modelConfigName) {
|
|
1147
1135
|
const newModelConfig = this.config.getModel(modelConfigName);
|
|
1148
|
-
this._applyMaxOutputTokensOverride(newModelConfig);
|
|
1149
1136
|
this.primaryAgent.replaceModelConfig(newModelConfig);
|
|
1150
1137
|
this._persistedModelSelection = this._buildPersistedModelSelection({
|
|
1151
1138
|
modelConfigName,
|
|
@@ -1156,16 +1143,6 @@ export class Session {
|
|
|
1156
1143
|
this._thinkingLevel = this._resolveThinkingLevelForModel(newModelConfig.model, this._preferredThinkingLevel);
|
|
1157
1144
|
this._cacheHitEnabled = this._preferredCacheHitEnabled;
|
|
1158
1145
|
}
|
|
1159
|
-
/**
|
|
1160
|
-
* If settings.json specifies max_output_tokens, clamp the ModelConfig.maxTokens
|
|
1161
|
-
* to [4096, modelMaxOutputTokens]. This mutates the ModelConfig in place.
|
|
1162
|
-
*/
|
|
1163
|
-
_applyMaxOutputTokensOverride(mc) {
|
|
1164
|
-
if (this._settingsMaxOutputTokens === undefined)
|
|
1165
|
-
return;
|
|
1166
|
-
const modelMax = getModelMaxOutputTokens(mc.model) ?? mc.maxTokens;
|
|
1167
|
-
mc.maxTokens = Math.max(4096, Math.min(this._settingsMaxOutputTokens, modelMax));
|
|
1168
|
-
}
|
|
1169
1146
|
applyGlobalPreferences(preferences) {
|
|
1170
1147
|
const prefs = createGlobalTuiPreferences(preferences);
|
|
1171
1148
|
this._preferredThinkingLevel = prefs.thinkingLevel;
|
|
@@ -1258,10 +1235,10 @@ export class Session {
|
|
|
1258
1235
|
_armShowContextAnnotations() {
|
|
1259
1236
|
const mc = this.primaryAgent.modelConfig;
|
|
1260
1237
|
const provider = this.primaryAgent._provider;
|
|
1261
|
-
const effectiveMax =
|
|
1238
|
+
const effectiveMax = mc.maxTokens;
|
|
1262
1239
|
const budget = provider.budgetCalcMode === "full_context"
|
|
1263
|
-
? mc
|
|
1264
|
-
: mc
|
|
1240
|
+
? this._effectiveContextLength(mc)
|
|
1241
|
+
: this._effectiveContextLength(mc) - effectiveMax;
|
|
1265
1242
|
const result = generateShowContext(this._log, this._lastInputTokens, budget);
|
|
1266
1243
|
this._showContextRoundsRemaining = 1;
|
|
1267
1244
|
this._showContextAnnotations = result.annotations;
|
|
@@ -2269,9 +2246,9 @@ export class Session {
|
|
|
2269
2246
|
}
|
|
2270
2247
|
const mc = this.primaryAgent.modelConfig;
|
|
2271
2248
|
const provider = this.primaryAgent._provider;
|
|
2272
|
-
const effectiveMax =
|
|
2249
|
+
const effectiveMax = mc.maxTokens;
|
|
2273
2250
|
const budget = provider.budgetCalcMode === "full_context"
|
|
2274
|
-
? mc
|
|
2251
|
+
? this._effectiveContextLength(mc) : this._effectiveContextLength(mc) - effectiveMax;
|
|
2275
2252
|
const result = generateShowContext(this._log, this._lastInputTokens, budget);
|
|
2276
2253
|
this._showContextRoundsRemaining = 1;
|
|
2277
2254
|
this._showContextAnnotations = result.annotations;
|
|
@@ -2875,10 +2852,10 @@ export class Session {
|
|
|
2875
2852
|
return undefined;
|
|
2876
2853
|
const mc = this.primaryAgent.modelConfig;
|
|
2877
2854
|
const provider = this.primaryAgent._provider;
|
|
2878
|
-
const effectiveMax =
|
|
2855
|
+
const effectiveMax = mc.maxTokens;
|
|
2879
2856
|
const budget = provider.budgetCalcMode === "full_context"
|
|
2880
|
-
? mc
|
|
2881
|
-
: mc
|
|
2857
|
+
? this._effectiveContextLength(mc)
|
|
2858
|
+
: this._effectiveContextLength(mc) - effectiveMax;
|
|
2882
2859
|
if (budget <= 0)
|
|
2883
2860
|
return undefined;
|
|
2884
2861
|
const compactOutputRatio = this._thresholds.compact_output / 100;
|
|
@@ -2992,9 +2969,9 @@ export class Session {
|
|
|
2992
2969
|
return;
|
|
2993
2970
|
const mc = this.primaryAgent.modelConfig;
|
|
2994
2971
|
const provider = this.primaryAgent._provider;
|
|
2995
|
-
const effectiveMax =
|
|
2972
|
+
const effectiveMax = mc.maxTokens;
|
|
2996
2973
|
const budget = provider.budgetCalcMode === "full_context"
|
|
2997
|
-
? mc
|
|
2974
|
+
? this._effectiveContextLength(mc) : this._effectiveContextLength(mc) - effectiveMax;
|
|
2998
2975
|
if (budget <= 0)
|
|
2999
2976
|
return;
|
|
3000
2977
|
const ratio = this._lastInputTokens / budget;
|
|
@@ -3018,9 +2995,9 @@ export class Session {
|
|
|
3018
2995
|
_updateHintStateAfterApiCall() {
|
|
3019
2996
|
const mc = this.primaryAgent.modelConfig;
|
|
3020
2997
|
const provider = this.primaryAgent._provider;
|
|
3021
|
-
const effectiveMax =
|
|
2998
|
+
const effectiveMax = mc.maxTokens;
|
|
3022
2999
|
const budget = provider.budgetCalcMode === "full_context"
|
|
3023
|
-
? mc
|
|
3000
|
+
? this._effectiveContextLength(mc) : this._effectiveContextLength(mc) - effectiveMax;
|
|
3024
3001
|
if (budget <= 0)
|
|
3025
3002
|
return;
|
|
3026
3003
|
const ratio = this._lastInputTokens / budget;
|
|
@@ -3914,9 +3891,6 @@ export class Session {
|
|
|
3914
3891
|
"and conclusions.";
|
|
3915
3892
|
}
|
|
3916
3893
|
_getSubAgentModelConfig() {
|
|
3917
|
-
const name = this.config.subAgentModelName;
|
|
3918
|
-
if (name)
|
|
3919
|
-
return this.config.getModel(name);
|
|
3920
3894
|
return this.primaryAgent.modelConfig;
|
|
3921
3895
|
}
|
|
3922
3896
|
_buildSubAgentContext(includeImportantLog) {
|
|
@@ -4203,10 +4177,10 @@ export class Session {
|
|
|
4203
4177
|
_buildSubAgentCompactCheck(agent) {
|
|
4204
4178
|
const mc = agent.modelConfig;
|
|
4205
4179
|
const provider = agent._provider;
|
|
4206
|
-
const effectiveMax =
|
|
4180
|
+
const effectiveMax = mc.maxTokens;
|
|
4207
4181
|
const budget = provider.budgetCalcMode === "full_context"
|
|
4208
|
-
? mc
|
|
4209
|
-
: mc
|
|
4182
|
+
? this._effectiveContextLength(mc)
|
|
4183
|
+
: this._effectiveContextLength(mc) - effectiveMax;
|
|
4210
4184
|
if (budget <= 0)
|
|
4211
4185
|
return undefined;
|
|
4212
4186
|
const compactOutputRatio = this._thresholds.compact_output / 100;
|