@humain/terminal 0.0.7 → 0.0.10
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/CHANGELOG.md +24 -0
- package/README.md +7 -6
- package/dist/bundle/chunks/chunk-74NVHVNZ.js +16 -0
- package/dist/bundle/chunks/{chunk-M2GYSCCG.js → chunk-PSKDLDLZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-HNVPY4LZ.js → chunk-SCJNLX2E.js} +94 -103
- package/dist/bundle/chunks/{google-generative-ai-XT7NQJ2E.js → google-generative-ai-FF7M7XHT.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-IDQ6Z53W.js → google-vertex-YMUBFRBA.js} +1 -1
- package/dist/bundle/chunks/https-proxy-agent-562J2I52.js +2 -0
- package/dist/bundle/chunks/{mistral-conversations-HHDZ4FHR.js → mistral-conversations-O4M7IQML.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-6QBYTBXY.js → openai-completions-L4AHDQ5D.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +2 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +77 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +19 -5
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +44 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +18 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +4 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +8 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +6 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +3 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +27 -6
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-failure.d.ts +4 -0
- package/dist/humain/agent-execution-failure.d.ts.map +1 -0
- package/dist/humain/agent-execution-failure.js +58 -0
- package/dist/humain/agent-execution-failure.js.map +1 -0
- package/dist/humain/agent-execution-runtime.d.ts +2 -2
- package/dist/humain/agent-execution-runtime.d.ts.map +1 -1
- package/dist/humain/agent-execution-runtime.js +13 -5
- package/dist/humain/agent-execution-runtime.js.map +1 -1
- package/dist/humain/mcp-adapter/vendor/package.json +2 -2
- package/dist/humain/pi-agent-execution-host.d.ts +1 -0
- package/dist/humain/pi-agent-execution-host.d.ts.map +1 -1
- package/dist/humain/pi-agent-execution-host.js +10 -3
- package/dist/humain/pi-agent-execution-host.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +48 -24
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts +6 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +38 -11
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +7 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +99 -4
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +6 -4
- package/dist/utils/shell.js.map +1 -1
- package/docs/compaction.md +2 -0
- package/docs/custom-provider.md +7 -7
- package/docs/environment-variables.md +4 -1
- package/docs/extensions.md +18 -0
- package/docs/keybindings.md +1 -1
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +23 -0
- package/docs/settings.md +12 -4
- package/docs/terminal-setup.md +12 -0
- package/docs/usage.md +4 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +6 -6
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +27 -26
- package/package.json +8 -8
- package/dist/bundle/chunks/chunk-3D3G2X5U.js +0 -6
- package/dist/bundle/chunks/dist-7DSXV2TY.js +0 -9
|
@@ -84,6 +84,8 @@ export class AgentSession {
|
|
|
84
84
|
this._followUpMessages = [];
|
|
85
85
|
/** Messages queued to be included with the next user prompt as context ("asides"). */
|
|
86
86
|
this._pendingNextTurnMessages = [];
|
|
87
|
+
/** Context-only custom messages queued during a run, flushed once the current turn's tool results are in. */
|
|
88
|
+
this._pendingCustomMessages = [];
|
|
87
89
|
// Compaction state
|
|
88
90
|
this._compactionAbortController = undefined;
|
|
89
91
|
this._autoCompactionAbortController = undefined;
|
|
@@ -169,6 +171,14 @@ export class AgentSession {
|
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
173
|
}
|
|
174
|
+
// A turn ends after its assistant message and every tool result has been appended,
|
|
175
|
+
// so this is the first point in the run where a context-only custom message can be
|
|
176
|
+
// inserted without landing between a tool call and its result. Flushing after the
|
|
177
|
+
// extension and listener dispatch above also picks up messages that turn_end
|
|
178
|
+
// handlers queued.
|
|
179
|
+
if (event.type === "turn_end") {
|
|
180
|
+
this._flushPendingCustomMessages();
|
|
181
|
+
}
|
|
172
182
|
};
|
|
173
183
|
this.agent = config.agent;
|
|
174
184
|
this.sessionManager = config.sessionManager;
|
|
@@ -305,18 +315,33 @@ export class AgentSession {
|
|
|
305
315
|
};
|
|
306
316
|
};
|
|
307
317
|
}
|
|
318
|
+
async _compactBeforeNextAssistantResponse(context) {
|
|
319
|
+
const model = this.model;
|
|
320
|
+
const settings = this.settingsManager.getCompactionSettings();
|
|
321
|
+
if (!model ||
|
|
322
|
+
model.contextWindow <= 0 ||
|
|
323
|
+
!shouldCompact(estimateContextTokens(context.messages).tokens, model.contextWindow, settings)) {
|
|
324
|
+
return context;
|
|
325
|
+
}
|
|
326
|
+
await this._runAutoCompaction("threshold", false);
|
|
327
|
+
return {
|
|
328
|
+
...context,
|
|
329
|
+
messages: this.agent.state.messages.slice(),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
308
332
|
_installAgentNextTurnRefresh() {
|
|
309
333
|
const previousPrepareNextTurnWithContext = this.agent.prepareNextTurnWithContext ??
|
|
310
334
|
(this.agent.prepareNextTurn
|
|
311
335
|
? async (_turn, signal) => await this.agent.prepareNextTurn?.(signal)
|
|
312
336
|
: undefined);
|
|
313
337
|
this.agent.prepareNextTurnWithContext = async (turn, signal) => {
|
|
314
|
-
const
|
|
315
|
-
const
|
|
338
|
+
const context = await this._compactBeforeNextAssistantResponse(turn.context);
|
|
339
|
+
const previousSnapshot = await previousPrepareNextTurnWithContext?.({ ...turn, context }, signal);
|
|
340
|
+
const nextContext = previousSnapshot?.context ?? context;
|
|
316
341
|
return {
|
|
317
342
|
...previousSnapshot,
|
|
318
343
|
context: {
|
|
319
|
-
...
|
|
344
|
+
...nextContext,
|
|
320
345
|
systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
|
|
321
346
|
tools: this.agent.state.tools.slice(),
|
|
322
347
|
},
|
|
@@ -733,6 +758,7 @@ export class AgentSession {
|
|
|
733
758
|
finally {
|
|
734
759
|
this._systemPromptOverride = undefined;
|
|
735
760
|
this._flushPendingBashMessages();
|
|
761
|
+
this._flushPendingCustomMessages();
|
|
736
762
|
await this._emitAgentSettled();
|
|
737
763
|
}
|
|
738
764
|
}
|
|
@@ -822,8 +848,9 @@ export class AgentSession {
|
|
|
822
848
|
preflightResult?.(true);
|
|
823
849
|
return;
|
|
824
850
|
}
|
|
825
|
-
// Flush any pending bash messages before the new prompt
|
|
851
|
+
// Flush any pending bash and custom messages before the new prompt
|
|
826
852
|
this._flushPendingBashMessages();
|
|
853
|
+
this._flushPendingCustomMessages();
|
|
827
854
|
// Validate model
|
|
828
855
|
if (!this.model) {
|
|
829
856
|
throw new Error(formatNoModelSelectedMessage());
|
|
@@ -1037,8 +1064,9 @@ export class AgentSession {
|
|
|
1037
1064
|
/**
|
|
1038
1065
|
* Send a custom message to the session. Creates a CustomMessageEntry.
|
|
1039
1066
|
*
|
|
1040
|
-
* Handles
|
|
1067
|
+
* Handles four cases:
|
|
1041
1068
|
* - Streaming: queues message, processed when loop pulls from queue
|
|
1069
|
+
* - Streaming + triggerTurn false: appended to state/session once the current turn ends
|
|
1042
1070
|
* - Not streaming + triggerTurn: appends to state/session, starts new turn
|
|
1043
1071
|
* - Not streaming + no trigger: appends to state/session, no turn
|
|
1044
1072
|
*
|
|
@@ -1070,11 +1098,34 @@ export class AgentSession {
|
|
|
1070
1098
|
else if (options?.triggerTurn) {
|
|
1071
1099
|
await this._runAgentPrompt(appMessage);
|
|
1072
1100
|
}
|
|
1101
|
+
else if (this.isStreaming) {
|
|
1102
|
+
// Appending now would put the message between an assistant tool call and its
|
|
1103
|
+
// result, which providers that validate message order reject on replay. Defer
|
|
1104
|
+
// to the end of the turn. Nothing is emitted yet: message events must not
|
|
1105
|
+
// describe messages the session tree does not contain.
|
|
1106
|
+
this._pendingCustomMessages.push(appMessage);
|
|
1107
|
+
}
|
|
1073
1108
|
else {
|
|
1074
|
-
this.
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1109
|
+
this._appendCustomMessage(appMessage);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
_appendCustomMessage(appMessage) {
|
|
1113
|
+
this.agent.state.messages.push(appMessage);
|
|
1114
|
+
this.sessionManager.appendCustomMessageEntry(appMessage.customType, appMessage.content, appMessage.display, appMessage.details);
|
|
1115
|
+
this._emit({ type: "message_start", message: appMessage });
|
|
1116
|
+
this._emit({ type: "message_end", message: appMessage });
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Append custom messages queued while the agent was running.
|
|
1120
|
+
* Called once the current turn's tool results are in agent state and session history.
|
|
1121
|
+
*/
|
|
1122
|
+
_flushPendingCustomMessages() {
|
|
1123
|
+
if (this._pendingCustomMessages.length === 0)
|
|
1124
|
+
return;
|
|
1125
|
+
const pending = this._pendingCustomMessages;
|
|
1126
|
+
this._pendingCustomMessages = [];
|
|
1127
|
+
for (const appMessage of pending) {
|
|
1128
|
+
this._appendCustomMessage(appMessage);
|
|
1078
1129
|
}
|
|
1079
1130
|
}
|
|
1080
1131
|
/**
|
|
@@ -1186,6 +1237,7 @@ export class AgentSession {
|
|
|
1186
1237
|
this.sessionManager.appendModelChange(model.provider, model.id);
|
|
1187
1238
|
if (options.persist) {
|
|
1188
1239
|
this.settingsManager.setDefaultModelAndProvider(model.provider, model.id);
|
|
1240
|
+
this._addPersistedDefaultToNonEmptyScope(model);
|
|
1189
1241
|
}
|
|
1190
1242
|
// Apply thinking level for the new model.
|
|
1191
1243
|
// Per-model thinking level overrides take priority over the global default.
|
|
@@ -1193,6 +1245,20 @@ export class AgentSession {
|
|
|
1193
1245
|
this.setThinkingLevel(thinkingLevel);
|
|
1194
1246
|
await this._emitModelSelect(model, previousModel, "set");
|
|
1195
1247
|
}
|
|
1248
|
+
_addPersistedDefaultToNonEmptyScope(model) {
|
|
1249
|
+
if (this._scopedModels.length === 0)
|
|
1250
|
+
return;
|
|
1251
|
+
if (this._scopedModels.some((scoped) => modelsAreEqual(scoped.model, model)))
|
|
1252
|
+
return;
|
|
1253
|
+
this._scopedModels = [...this._scopedModels, { model }];
|
|
1254
|
+
const enabledModels = this.settingsManager.getEnabledModels();
|
|
1255
|
+
if (!enabledModels?.length)
|
|
1256
|
+
return;
|
|
1257
|
+
const modelReference = `${model.provider}/${model.id}`;
|
|
1258
|
+
if (enabledModels.some((pattern) => pattern.toLowerCase() === modelReference.toLowerCase()))
|
|
1259
|
+
return;
|
|
1260
|
+
this.settingsManager.setEnabledModels([...enabledModels, modelReference]);
|
|
1261
|
+
}
|
|
1196
1262
|
/**
|
|
1197
1263
|
* Cycle to next/previous model.
|
|
1198
1264
|
* Uses scoped models (from --models flag) if available, otherwise all available models.
|
|
@@ -1223,6 +1289,7 @@ export class AgentSession {
|
|
|
1223
1289
|
this.sessionManager.appendModelChange(next.model.provider, next.model.id);
|
|
1224
1290
|
if (options.persist) {
|
|
1225
1291
|
this.settingsManager.setDefaultModelAndProvider(next.model.provider, next.model.id);
|
|
1292
|
+
this._addPersistedDefaultToNonEmptyScope(next.model);
|
|
1226
1293
|
}
|
|
1227
1294
|
// Apply thinking level for the new model.
|
|
1228
1295
|
// - Explicit scoped model thinking level overrides defaults
|
|
@@ -1249,6 +1316,7 @@ export class AgentSession {
|
|
|
1249
1316
|
this.sessionManager.appendModelChange(nextModel.provider, nextModel.id);
|
|
1250
1317
|
if (options.persist) {
|
|
1251
1318
|
this.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);
|
|
1319
|
+
this._addPersistedDefaultToNonEmptyScope(nextModel);
|
|
1252
1320
|
}
|
|
1253
1321
|
// Apply thinking level for the new model.
|
|
1254
1322
|
// Model persistence does not implicitly rewrite the global thinking default.
|