@humain/humain-code 0.4.9 → 0.4.11
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 +35 -0
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +39 -45
- package/dist/bundle/chunks/{chunk-KRMTBTWU.js → chunk-77EWF2NW.js} +1 -1
- package/dist/bundle/chunks/{chunk-RBKDBF5G.js → chunk-AS2Y2MO6.js} +36 -36
- package/dist/bundle/chunks/{chunk-P4YMUUSK.js → chunk-DX3OMELJ.js} +741 -733
- package/dist/bundle/chunks/{chunk-W2QRCQBX.js → chunk-FF26YENK.js} +3 -4
- package/dist/bundle/chunks/{chunk-UZ5FVVCP.js → chunk-HMWAH7ZY.js} +1 -1
- package/dist/bundle/chunks/{chunk-F7UMX5BV.js → chunk-HSDTSUZE.js} +13 -2
- package/dist/bundle/chunks/chunk-I2ZWZAIV.js +751 -0
- package/dist/bundle/chunks/{chunk-GUUAEK6G.js → chunk-LCOHFEZZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-6FVNSW6B.js → chunk-PIX6AAU6.js} +3354 -3939
- package/dist/bundle/chunks/{chunk-Z5LYSSTY.js → chunk-QSPDLT2R.js} +2 -2
- package/dist/bundle/chunks/{chunk-UBQSONVR.js → chunk-R5VIAWGA.js} +103 -145
- package/dist/bundle/chunks/{chunk-4LAKI5IL.js → chunk-SZRZXVVZ.js} +9 -9
- package/dist/bundle/chunks/{chunk-EMYNPLY5.js → chunk-V5ZF7Q7L.js} +1 -1
- package/dist/bundle/chunks/{chunk-LQ4S7CRR.js → chunk-VYIIPF57.js} +1 -1
- package/dist/bundle/chunks/chunk-WBJN6PEI.js +43 -0
- package/dist/bundle/chunks/{chunk-SWRU4BOC.js → chunk-XGO43DKL.js} +1 -1
- package/dist/bundle/chunks/chunk-XKSDVBMN.js +28 -0
- package/dist/bundle/chunks/{chunk-PMISFIBM.js → chunk-XMHLSV3I.js} +1 -1
- package/dist/bundle/chunks/{chunk-3E4SMILM.js → chunk-YJBE3IGR.js} +14 -14
- package/dist/bundle/chunks/{cli-ZKT34WPW.js → cli-5ACW3WND.js} +2 -2
- package/dist/bundle/chunks/{compat-HEUVP6UJ.js → compat-KXKKCXPQ.js} +1 -1
- package/dist/bundle/chunks/{dist-NU2EIVT6.js → dist-7DVXM77G.js} +742 -615
- package/dist/bundle/chunks/dist-cjs-RL2OCAP2.js +179 -0
- package/dist/bundle/chunks/{easter-egg-3d-5KKDWEIA.js → easter-egg-3d-3L3IKAT6.js} +1 -1
- package/dist/bundle/chunks/{esm-NCUV2DF7.js → esm-763X2IA7.js} +1 -1
- package/dist/bundle/chunks/event-streams-R5OECII4.js +2 -0
- package/dist/bundle/chunks/{execute-OSBDNQU5.js → execute-4X6G65NZ.js} +1 -1
- package/dist/bundle/chunks/{extract-PYRMDATF.js → extract-DLZ425VI.js} +4 -4
- package/dist/bundle/chunks/github-copilot.js +32 -31
- package/dist/bundle/chunks/{google-generative-ai-H2F5Y5H2.js → google-generative-ai-JD2FVOIX.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-LFWD2AOO.js → google-vertex-PFBMDCBW.js} +1 -1
- package/dist/bundle/chunks/{host-6ZA6LK4C.js → host-4J7H7KDS.js} +1 -1
- package/dist/bundle/chunks/{node-XGNY74WT.js → node-W47VUEGE.js} +1 -1
- package/dist/bundle/chunks/{runtime-JFLZUNYP.js → runtime-SI76JZNE.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-E3FQAR5T.js +5 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/flow/package.json +1 -1
- package/dist/bundle/index.js +17 -17
- package/dist/bundle/rpc-entry.js +3 -2
- package/dist/core/account-reporting.d.ts +109 -0
- package/dist/core/account-reporting.d.ts.map +1 -0
- package/dist/core/account-reporting.js +328 -0
- package/dist/core/account-reporting.js.map +1 -0
- package/dist/core/agent-session.d.ts +22 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +131 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-account-reporting.d.ts +76 -0
- package/dist/core/anthropic-account-reporting.d.ts.map +1 -0
- package/dist/core/anthropic-account-reporting.js +380 -0
- package/dist/core/anthropic-account-reporting.js.map +1 -0
- package/dist/core/bedrock-account-reporting.d.ts +82 -0
- package/dist/core/bedrock-account-reporting.d.ts.map +1 -0
- package/dist/core/bedrock-account-reporting.js +402 -0
- package/dist/core/bedrock-account-reporting.js.map +1 -0
- package/dist/core/model-runtime.d.ts +17 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +64 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +4 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +10 -3
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/humain/flow-accounts-host.d.ts +120 -0
- package/dist/humain/flow-accounts-host.d.ts.map +1 -0
- package/dist/humain/flow-accounts-host.js +346 -0
- package/dist/humain/flow-accounts-host.js.map +1 -0
- package/dist/humain/flow-command.d.ts +28 -0
- package/dist/humain/flow-command.d.ts.map +1 -0
- package/dist/humain/flow-command.js +226 -0
- package/dist/humain/flow-command.js.map +1 -0
- package/dist/humain/flow-loader.d.ts +4 -2
- package/dist/humain/flow-loader.d.ts.map +1 -1
- package/dist/humain/flow-loader.js +120 -91
- package/dist/humain/flow-loader.js.map +1 -1
- package/dist/humain/node-account-failure.d.ts +18 -0
- package/dist/humain/node-account-failure.d.ts.map +1 -0
- package/dist/humain/node-account-failure.js +73 -0
- package/dist/humain/node-account-failure.js.map +1 -0
- package/dist/humain/node-account-fallback.d.ts +85 -0
- package/dist/humain/node-account-fallback.d.ts.map +1 -0
- package/dist/humain/node-account-fallback.js +175 -0
- package/dist/humain/node-account-fallback.js.map +1 -0
- package/dist/humain/node-http.d.ts.map +1 -1
- package/dist/humain/node-http.js +11 -0
- package/dist/humain/node-http.js.map +1 -1
- package/dist/humain/node-provider.d.ts +4 -0
- package/dist/humain/node-provider.d.ts.map +1 -1
- package/dist/humain/node-provider.js +11 -0
- package/dist/humain/node-provider.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +2 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +5 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +26 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +242 -19
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/flow-profiles.md +57 -5
- package/docs/flow.md +119 -37
- package/docs/providers.md +37 -0
- package/npm-shrinkwrap.json +48 -6
- package/package.json +3 -2
- package/dist/bundle/chunks/chunk-JOKJ3CEL.js +0 -27
- package/dist/bundle/chunks/event-streams-CGCQQL5M.js +0 -2
- package/dist/bundle/chunks/virtual-modules-NPWQ6NBS.js +0 -5
|
@@ -106,12 +106,20 @@ export declare class InteractiveMode {
|
|
|
106
106
|
private retryEscapeHandler?;
|
|
107
107
|
private compactionQueuedMessages;
|
|
108
108
|
private shutdownRequested;
|
|
109
|
+
/** Releases the Flow accounts host bound to the current session's registry. */
|
|
110
|
+
private flowAccountsRelease?;
|
|
111
|
+
/** Set while a Flow account interaction is open; cancels its login dialogs when the host aborts. */
|
|
112
|
+
private activeFlowAccountsSignal?;
|
|
113
|
+
/** Session-bound usage reporter; created lazily and cancelled when the host is released. */
|
|
114
|
+
private flowAccountReporter?;
|
|
109
115
|
/** Reports working, blocked, done, and error states to terminals that support OSC 7501. */
|
|
110
116
|
private readonly programStatus;
|
|
111
117
|
/** The `/bug` hint is shown at most once per session so error output stays readable. */
|
|
112
118
|
private bugReportHintShown;
|
|
113
119
|
private installChangeWarningShown;
|
|
114
120
|
private extensionSelector;
|
|
121
|
+
/** Resolves the open extension selector's promise; hiding the selector settles it so callers never hang. */
|
|
122
|
+
private extensionSelectorSettle;
|
|
115
123
|
private extensionInput;
|
|
116
124
|
private extensionEditor;
|
|
117
125
|
private extensionTerminalInputSubscriptions;
|
|
@@ -446,8 +454,26 @@ export declare class InteractiveMode {
|
|
|
446
454
|
/** One group per provider, independent of credential type. */
|
|
447
455
|
private getAccountProviderOptions;
|
|
448
456
|
private handleAccountsCommand;
|
|
457
|
+
private bindFlowAccountsHostToSession;
|
|
458
|
+
private releaseFlowAccountsHost;
|
|
459
|
+
private getFlowAccountReporter;
|
|
460
|
+
/**
|
|
461
|
+
* Explicit "Refresh usage" for one provider. Cancel, the host signal, or leaving the dialog aborts in-flight
|
|
462
|
+
* lookups. Returns undefined when cancelled; reports are labelled with source, scope, period and update time.
|
|
463
|
+
*/
|
|
464
|
+
private refreshFlowUsage;
|
|
465
|
+
/**
|
|
466
|
+
* Awaited account setup for Flow. Resolves when the user continues or the signal aborts; sign-ins, account
|
|
467
|
+
* switches and removals completed before cancellation stay in effect. Opening it reads stored metadata only.
|
|
468
|
+
*/
|
|
469
|
+
private runFlowAccountsInteraction;
|
|
470
|
+
private showFlowProviderList;
|
|
471
|
+
private showFlowProviderMenu;
|
|
472
|
+
/** Sign in through the host-owned dialogs; secrets stay in them and never reach Flow. */
|
|
473
|
+
private connectFlowProvider;
|
|
449
474
|
private showOAuthAccountSelector;
|
|
450
475
|
private showAccountPolicy;
|
|
476
|
+
/** `flow` runs the actions inside the awaited Flow setup, where Back and Add another account stay in that flow. */
|
|
451
477
|
private showOAuthAccountActions;
|
|
452
478
|
private removeOAuthAccount;
|
|
453
479
|
private removeUnidentifiedCredential;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA;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9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,oBAAoB;YAuHd,kBAAkB;IAehC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,oBAAoB;YAMd,iBAAiB;YA6FjB,oBAAoB;IAUlC,IAAI,CAAC,oBAAoB,uBAAiD,GAAG,IAAI,CAmBhF;CACD"}
|
|
@@ -13,6 +13,7 @@ import chalk from "chalk";
|
|
|
13
13
|
import { spawn } from "child_process";
|
|
14
14
|
import { trackUserWait } from "../../agent-monitor/user-wait.js";
|
|
15
15
|
import { APP_COMMAND, APP_TITLE, CONFIG_DIR_NAME, detectInstallChange, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, VERSION, } from "../../config.js";
|
|
16
|
+
import { formatAccountUsageReport } from "../../core/account-reporting.js";
|
|
16
17
|
import { parseSkillBlock } from "../../core/agent-session.js";
|
|
17
18
|
import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
|
|
18
19
|
import { AccountSourceReplacementError } from "../../core/auth-storage.js";
|
|
@@ -39,6 +40,7 @@ import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core
|
|
|
39
40
|
import { getUsageCostBreakdown } from "../../core/usage-totals.js";
|
|
40
41
|
import { loadMcpConfig } from "../../extensions/mcp/config.js";
|
|
41
42
|
import { renderHumainCodeIcon } from "../../humain/brand-logo.js";
|
|
43
|
+
import { bindFlowAccountsHost, createFlowAccountReporter, FLOW_ACCOUNT_PERSISTENCE_NOTICE, flowUsageTargets, formatFlowAccountAdvanced, listFlowAccountMetadata, nodeLabelContainsStoredKey, readFlowNodeFallbackState, refreshFlowCatalog, updateFlowNodeFallback, } from "../../humain/flow-accounts-host.js";
|
|
42
44
|
import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
|
|
43
45
|
import { copyToClipboard, readClipboardFilePaths, readClipboardText } from "../../utils/clipboard.js";
|
|
44
46
|
import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
|
|
@@ -189,6 +191,7 @@ function llamaCppPostLoginGuidance(actionLabel, loadedModelCount) {
|
|
|
189
191
|
: `${actionLabel}. Use /model to select a loaded llama.cpp model, or /llama to manage models.`;
|
|
190
192
|
}
|
|
191
193
|
const RADIUS_LOGIN_INTRO = "Radius is a service by Earendil Works";
|
|
194
|
+
const EXTERNAL_SOURCE_NOTICE = "External sources are read-only in /accounts. Change the runtime, environment or configuration outside /accounts. Runtime overrides stored selection; stored credentials block models.json; models.json precedes ambient credentials. Selection is global. Stored configuration references cannot be replaced here; use /logout to explicitly remove the stored credential before selecting an account.";
|
|
192
195
|
const AUTH_TYPE_ORDER = { oauth: 0, api_key: 1 };
|
|
193
196
|
function createFuzzyAutocompleteItems(items, prefix, getSearchText, toAutocompleteItem) {
|
|
194
197
|
const filtered = fuzzyFilter(items, prefix, getSearchText);
|
|
@@ -313,6 +316,12 @@ export class InteractiveMode {
|
|
|
313
316
|
compactionQueuedMessages = [];
|
|
314
317
|
// Shutdown state
|
|
315
318
|
shutdownRequested = false;
|
|
319
|
+
/** Releases the Flow accounts host bound to the current session's registry. */
|
|
320
|
+
flowAccountsRelease;
|
|
321
|
+
/** Set while a Flow account interaction is open; cancels its login dialogs when the host aborts. */
|
|
322
|
+
activeFlowAccountsSignal;
|
|
323
|
+
/** Session-bound usage reporter; created lazily and cancelled when the host is released. */
|
|
324
|
+
flowAccountReporter;
|
|
316
325
|
/** Reports working, blocked, done, and error states to terminals that support OSC 7501. */
|
|
317
326
|
programStatus = new ProgramStatusReporter(() => this.ui.terminal, () => this.sessionManager.getSessionName());
|
|
318
327
|
/** The `/bug` hint is shown at most once per session so error output stays readable. */
|
|
@@ -320,6 +329,8 @@ export class InteractiveMode {
|
|
|
320
329
|
installChangeWarningShown = false;
|
|
321
330
|
// Extension UI state
|
|
322
331
|
extensionSelector = undefined;
|
|
332
|
+
/** Resolves the open extension selector's promise; hiding the selector settles it so callers never hang. */
|
|
333
|
+
extensionSelectorSettle = undefined;
|
|
323
334
|
extensionInput = undefined;
|
|
324
335
|
extensionEditor = undefined;
|
|
325
336
|
extensionTerminalInputSubscriptions = new Set();
|
|
@@ -1550,6 +1561,7 @@ export class InteractiveMode {
|
|
|
1550
1561
|
this.showExtensionError(error.extensionPath, error.error, error.stack);
|
|
1551
1562
|
},
|
|
1552
1563
|
});
|
|
1564
|
+
this.bindFlowAccountsHostToSession();
|
|
1553
1565
|
setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
|
|
1554
1566
|
this.setupAutocompleteProvider();
|
|
1555
1567
|
const extensionRunner = this.session.extensionRunner;
|
|
@@ -1913,6 +1925,8 @@ export class InteractiveMode {
|
|
|
1913
1925
|
this.renderWidgets();
|
|
1914
1926
|
}
|
|
1915
1927
|
resetExtensionUI() {
|
|
1928
|
+
// Release first: aborting resolves pending account dialogs before their UI is hidden.
|
|
1929
|
+
this.releaseFlowAccountsHost();
|
|
1916
1930
|
if (this.extensionSelector) {
|
|
1917
1931
|
this.hideExtensionSelector();
|
|
1918
1932
|
}
|
|
@@ -2144,10 +2158,14 @@ export class InteractiveMode {
|
|
|
2144
2158
|
resolve(undefined);
|
|
2145
2159
|
};
|
|
2146
2160
|
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2161
|
+
this.extensionSelectorSettle = () => {
|
|
2162
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2163
|
+
resolve(undefined);
|
|
2164
|
+
};
|
|
2147
2165
|
this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
|
|
2148
2166
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2149
|
-
this.hideExtensionSelector();
|
|
2150
2167
|
resolve(option);
|
|
2168
|
+
this.hideExtensionSelector();
|
|
2151
2169
|
}, () => {
|
|
2152
2170
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2153
2171
|
this.hideExtensionSelector();
|
|
@@ -2166,6 +2184,9 @@ export class InteractiveMode {
|
|
|
2166
2184
|
* Hide the extension selector.
|
|
2167
2185
|
*/
|
|
2168
2186
|
hideExtensionSelector() {
|
|
2187
|
+
const settle = this.extensionSelectorSettle;
|
|
2188
|
+
this.extensionSelectorSettle = undefined;
|
|
2189
|
+
settle?.();
|
|
2169
2190
|
this.extensionSelector?.dispose();
|
|
2170
2191
|
this.editorContainer.clear();
|
|
2171
2192
|
this.editorContainer.addChild(this.editor);
|
|
@@ -3103,9 +3124,10 @@ export class InteractiveMode {
|
|
|
3103
3124
|
}
|
|
3104
3125
|
case "oauth_account_switched": {
|
|
3105
3126
|
const providerName = this.session.modelRuntime.getProvider(event.provider)?.name ?? event.provider;
|
|
3106
|
-
this.showStatus(event.
|
|
3107
|
-
|
|
3108
|
-
|
|
3127
|
+
this.showStatus(event.notice ??
|
|
3128
|
+
(event.reason === "credits"
|
|
3129
|
+
? `${providerName} usage limit reached for ${event.fromLabel}; switched to ${event.toLabel} to avoid using credits`
|
|
3130
|
+
: `${providerName} usage limit reached for ${event.fromLabel}; switched to ${event.toLabel} and retrying`));
|
|
3109
3131
|
void this.refreshOAuthAccountFooter();
|
|
3110
3132
|
break;
|
|
3111
3133
|
}
|
|
@@ -3128,7 +3150,8 @@ export class InteractiveMode {
|
|
|
3128
3150
|
const reset = event.earliestResetAt === undefined
|
|
3129
3151
|
? ""
|
|
3130
3152
|
: `; earliest reset ${formatOAuthAccountResetTime(event.earliestResetAt)}`;
|
|
3131
|
-
this.showStatus(
|
|
3153
|
+
this.showStatus(event.notice ??
|
|
3154
|
+
`All ${event.total} ${providerName} account${event.total === 1 ? "" : "s"} ${event.total === 1 ? "has" : "have"} hit the usage limit${reset}. Use /login ${event.provider} to add another account.`);
|
|
3132
3155
|
void this.refreshOAuthAccountFooter();
|
|
3133
3156
|
break;
|
|
3134
3157
|
}
|
|
@@ -3558,6 +3581,7 @@ export class InteractiveMode {
|
|
|
3558
3581
|
if (this.isShuttingDown)
|
|
3559
3582
|
return;
|
|
3560
3583
|
this.isShuttingDown = true;
|
|
3584
|
+
this.releaseFlowAccountsHost();
|
|
3561
3585
|
const termination = killTrackedDetachedChildrenAsync();
|
|
3562
3586
|
// Keep signal handlers registered until terminal cleanup has completed.
|
|
3563
3587
|
// `signal-exit` checks the listener list during the same SIGTERM/SIGHUP
|
|
@@ -3603,6 +3627,7 @@ export class InteractiveMode {
|
|
|
3603
3627
|
}
|
|
3604
3628
|
emergencyTerminalExit() {
|
|
3605
3629
|
this.isShuttingDown = true;
|
|
3630
|
+
this.releaseFlowAccountsHost();
|
|
3606
3631
|
this.unregisterSignalHandlers();
|
|
3607
3632
|
killTrackedDetachedChildren();
|
|
3608
3633
|
// The terminal is gone. Do not run normal shutdown because TUI and
|
|
@@ -3630,6 +3655,7 @@ export class InteractiveMode {
|
|
|
3630
3655
|
process.exit(1);
|
|
3631
3656
|
}
|
|
3632
3657
|
this.isShuttingDown = true;
|
|
3658
|
+
this.releaseFlowAccountsHost();
|
|
3633
3659
|
try {
|
|
3634
3660
|
this.unregisterSignalHandlers();
|
|
3635
3661
|
}
|
|
@@ -5069,6 +5095,178 @@ export class InteractiveMode {
|
|
|
5069
5095
|
return { component: selector, focus: selector };
|
|
5070
5096
|
});
|
|
5071
5097
|
}
|
|
5098
|
+
bindFlowAccountsHostToSession() {
|
|
5099
|
+
this.releaseFlowAccountsHost();
|
|
5100
|
+
const runtime = this.session.modelRuntime;
|
|
5101
|
+
const reporter = this.getFlowAccountReporter();
|
|
5102
|
+
this.flowAccountsRelease = bindFlowAccountsHost(this.session.extensionRunner.getModelRegistry(), {
|
|
5103
|
+
openAccounts: (signal) => this.runFlowAccountsInteraction(signal),
|
|
5104
|
+
refreshCatalog: (providerId, signal) => refreshFlowCatalog(runtime, providerId, signal),
|
|
5105
|
+
refreshAccountUsage: (target, signal) => reporter.refreshAccountUsage(target, signal),
|
|
5106
|
+
getNodeFallback: (signal) => readFlowNodeFallbackState(runtime, signal),
|
|
5107
|
+
updateNodeFallback: (update, signal) => updateFlowNodeFallback(runtime, update, signal),
|
|
5108
|
+
labelContainsStoredKey: (text, signal) => nodeLabelContainsStoredKey(runtime, text, signal),
|
|
5109
|
+
});
|
|
5110
|
+
}
|
|
5111
|
+
releaseFlowAccountsHost() {
|
|
5112
|
+
this.flowAccountsRelease?.();
|
|
5113
|
+
this.flowAccountsRelease = undefined;
|
|
5114
|
+
this.flowAccountReporter?.cancelAll();
|
|
5115
|
+
this.flowAccountReporter = undefined;
|
|
5116
|
+
}
|
|
5117
|
+
getFlowAccountReporter() {
|
|
5118
|
+
this.flowAccountReporter ??= createFlowAccountReporter(this.session.modelRuntime);
|
|
5119
|
+
return this.flowAccountReporter;
|
|
5120
|
+
}
|
|
5121
|
+
/**
|
|
5122
|
+
* Explicit "Refresh usage" for one provider. Cancel, the host signal, or leaving the dialog aborts in-flight
|
|
5123
|
+
* lookups. Returns undefined when cancelled; reports are labelled with source, scope, period and update time.
|
|
5124
|
+
*/
|
|
5125
|
+
async refreshFlowUsage(targets, signal) {
|
|
5126
|
+
const reporter = this.getFlowAccountReporter();
|
|
5127
|
+
const controller = new AbortController();
|
|
5128
|
+
const combined = AbortSignal.any([signal, controller.signal]);
|
|
5129
|
+
const cancel = this.showExtensionSelector("Refreshing usage…", ["Cancel"], { signal: combined }).then(() => controller.abort());
|
|
5130
|
+
try {
|
|
5131
|
+
const lines = [];
|
|
5132
|
+
for (const target of targets) {
|
|
5133
|
+
const report = await reporter.refreshAccountUsage(target, combined);
|
|
5134
|
+
lines.push(...formatAccountUsageReport(report, Date.now()), "");
|
|
5135
|
+
}
|
|
5136
|
+
return combined.aborted ? undefined : lines;
|
|
5137
|
+
}
|
|
5138
|
+
finally {
|
|
5139
|
+
controller.abort();
|
|
5140
|
+
await cancel;
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
/**
|
|
5144
|
+
* Awaited account setup for Flow. Resolves when the user continues or the signal aborts; sign-ins, account
|
|
5145
|
+
* switches and removals completed before cancellation stay in effect. Opening it reads stored metadata only.
|
|
5146
|
+
*/
|
|
5147
|
+
async runFlowAccountsInteraction(signal) {
|
|
5148
|
+
if (this.activeFlowAccountsSignal)
|
|
5149
|
+
throw new Error("Account interaction is already open");
|
|
5150
|
+
this.activeFlowAccountsSignal = signal;
|
|
5151
|
+
const aborted = new Promise((resolve) => {
|
|
5152
|
+
if (signal.aborted)
|
|
5153
|
+
resolve();
|
|
5154
|
+
else
|
|
5155
|
+
signal.addEventListener("abort", () => resolve(), { once: true });
|
|
5156
|
+
});
|
|
5157
|
+
try {
|
|
5158
|
+
await Promise.race([this.showFlowProviderList(signal), aborted]);
|
|
5159
|
+
}
|
|
5160
|
+
finally {
|
|
5161
|
+
this.activeFlowAccountsSignal = undefined;
|
|
5162
|
+
if (signal.aborted && this.extensionSelector)
|
|
5163
|
+
this.hideExtensionSelector();
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
async showFlowProviderList(signal) {
|
|
5167
|
+
const runtime = this.session.modelRuntime;
|
|
5168
|
+
while (!signal.aborted) {
|
|
5169
|
+
const providers = this.getAccountProviderOptions();
|
|
5170
|
+
const names = providers.map((provider) => provider.name);
|
|
5171
|
+
const labels = providers.map((provider) => {
|
|
5172
|
+
const name = names.filter((entry) => entry === provider.name).length > 1
|
|
5173
|
+
? `${provider.name} [${provider.id}]`
|
|
5174
|
+
: provider.name;
|
|
5175
|
+
return `${name} (${runtime.getProviderAuthStatus(provider.id).configured ? "Configured — not verified" : "Not configured"})`;
|
|
5176
|
+
});
|
|
5177
|
+
const choice = await this.showExtensionSelector(`Connect providers\nChoose the providers you want Flow to use. You can connect more than one.\n${FLOW_ACCOUNT_PERSISTENCE_NOTICE}`, [...labels, "Continue"], { signal });
|
|
5178
|
+
const provider = choice === undefined ? undefined : providers[labels.indexOf(choice)];
|
|
5179
|
+
if (!provider)
|
|
5180
|
+
return;
|
|
5181
|
+
await this.showFlowProviderMenu(provider, signal);
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
async showFlowProviderMenu(provider, signal) {
|
|
5185
|
+
const runtime = this.session.modelRuntime;
|
|
5186
|
+
let usageLines = [];
|
|
5187
|
+
while (!signal.aborted) {
|
|
5188
|
+
let metadata;
|
|
5189
|
+
try {
|
|
5190
|
+
metadata = await listFlowAccountMetadata(runtime, provider.id, signal);
|
|
5191
|
+
}
|
|
5192
|
+
catch {
|
|
5193
|
+
if (!signal.aborted)
|
|
5194
|
+
this.showError("Could not read accounts. Reopen account setup to retry.");
|
|
5195
|
+
return;
|
|
5196
|
+
}
|
|
5197
|
+
const duplicate = (label) => metadata.accounts.filter((account) => account.label === label).length > 1;
|
|
5198
|
+
const accountOptions = metadata.accounts.map((account) => {
|
|
5199
|
+
const markers = [account.type === "oauth" ? "OAuth" : "API key"];
|
|
5200
|
+
if (account.active)
|
|
5201
|
+
markers.push("active");
|
|
5202
|
+
if (account.effective)
|
|
5203
|
+
markers.push("effective");
|
|
5204
|
+
return `${duplicate(account.label) ? `${account.label} [${account.key}]` : account.label} (${markers.join(", ")})`;
|
|
5205
|
+
});
|
|
5206
|
+
const sourceOptions = metadata.sources.map((source) => `${source.label} [read-only] (${source.effective ? "effective" : "shadowed"})`);
|
|
5207
|
+
const connect = metadata.accounts.length === 0 ? "Connect" : "Add another account…";
|
|
5208
|
+
const usageTargets = flowUsageTargets(provider.id, metadata, Date.now());
|
|
5209
|
+
const refreshUsage = "Refresh usage";
|
|
5210
|
+
const options = [
|
|
5211
|
+
...accountOptions,
|
|
5212
|
+
...sourceOptions,
|
|
5213
|
+
...(usageTargets.length > 0 ? [refreshUsage] : []),
|
|
5214
|
+
connect,
|
|
5215
|
+
"Back",
|
|
5216
|
+
];
|
|
5217
|
+
const choice = await this.showExtensionSelector([
|
|
5218
|
+
`HUMAIN Code / Accounts — ${provider.name}`,
|
|
5219
|
+
...formatFlowAccountAdvanced(provider.id, provider.name, metadata),
|
|
5220
|
+
...usageLines,
|
|
5221
|
+
FLOW_ACCOUNT_PERSISTENCE_NOTICE,
|
|
5222
|
+
].join("\n"), options, { signal });
|
|
5223
|
+
if (choice === undefined || choice === "Back")
|
|
5224
|
+
return;
|
|
5225
|
+
if (choice === connect) {
|
|
5226
|
+
usageLines = [];
|
|
5227
|
+
await this.connectFlowProvider(provider, signal);
|
|
5228
|
+
continue;
|
|
5229
|
+
}
|
|
5230
|
+
if (choice === refreshUsage && usageTargets.length > 0) {
|
|
5231
|
+
usageLines = (await this.refreshFlowUsage(usageTargets, signal)) ?? usageLines;
|
|
5232
|
+
continue;
|
|
5233
|
+
}
|
|
5234
|
+
const index = options.indexOf(choice);
|
|
5235
|
+
const account = metadata.accounts[index];
|
|
5236
|
+
if (account) {
|
|
5237
|
+
// Account actions can switch or remove accounts: reports shown so far describe the previous selection.
|
|
5238
|
+
usageLines = [];
|
|
5239
|
+
await this.showOAuthAccountActions(provider, account, {
|
|
5240
|
+
connect: () => this.connectFlowProvider(provider, signal),
|
|
5241
|
+
signal,
|
|
5242
|
+
});
|
|
5243
|
+
}
|
|
5244
|
+
else if (index >= 0 && index < accountOptions.length + sourceOptions.length) {
|
|
5245
|
+
await this.showExtensionSelector(`${choice}\n${EXTERNAL_SOURCE_NOTICE}`, ["Back"], { signal });
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
/** Sign in through the host-owned dialogs; secrets stay in them and never reach Flow. */
|
|
5250
|
+
async connectFlowProvider(provider, signal) {
|
|
5251
|
+
const methods = this.getLoginProviderOptions().filter((option) => option.id === provider.id);
|
|
5252
|
+
let method = methods[0];
|
|
5253
|
+
if (methods.length > 1) {
|
|
5254
|
+
const labels = methods.map((option) => option.authType === "oauth" ? "Sign in with an account" : "Sign in with an API key");
|
|
5255
|
+
const choice = await this.showExtensionSelector(`Connect ${provider.name}\n${FLOW_ACCOUNT_PERSISTENCE_NOTICE}`, labels, { signal });
|
|
5256
|
+
method = choice === undefined ? undefined : methods[labels.indexOf(choice)];
|
|
5257
|
+
}
|
|
5258
|
+
if (!method) {
|
|
5259
|
+
if (methods.length === 0)
|
|
5260
|
+
this.showError("Login method is no longer available.");
|
|
5261
|
+
return;
|
|
5262
|
+
}
|
|
5263
|
+
if (method.authType === "api_key" && !method.method?.login) {
|
|
5264
|
+
const chosen = method;
|
|
5265
|
+
await new Promise((resolve) => this.showAmbientAuthDialog(chosen, resolve, signal));
|
|
5266
|
+
return;
|
|
5267
|
+
}
|
|
5268
|
+
await this.startProviderLogin(method);
|
|
5269
|
+
}
|
|
5072
5270
|
async showOAuthAccountSelector(provider, mode = "manage") {
|
|
5073
5271
|
const runtime = this.session.modelRuntime;
|
|
5074
5272
|
const pool = runtime.oauthAccounts;
|
|
@@ -5144,7 +5342,7 @@ export class InteractiveMode {
|
|
|
5144
5342
|
return;
|
|
5145
5343
|
}
|
|
5146
5344
|
if (sourceOptions.includes(option)) {
|
|
5147
|
-
void this.showExtensionSelector(`${option}\
|
|
5345
|
+
void this.showExtensionSelector(`${option}\n${EXTERNAL_SOURCE_NOTICE}`, ["Back"]).then(() => this.showOAuthAccountSelector(provider));
|
|
5148
5346
|
return;
|
|
5149
5347
|
}
|
|
5150
5348
|
const index = currentOptions.indexOf(option);
|
|
@@ -5241,21 +5439,29 @@ export class InteractiveMode {
|
|
|
5241
5439
|
this.showError("Could not read or save account policy. Reopen /accounts to check current state.");
|
|
5242
5440
|
}
|
|
5243
5441
|
}
|
|
5244
|
-
|
|
5245
|
-
|
|
5442
|
+
/** `flow` runs the actions inside the awaited Flow setup, where Back and Add another account stay in that flow. */
|
|
5443
|
+
async showOAuthAccountActions(provider, account, flow) {
|
|
5444
|
+
const signal = flow?.signal;
|
|
5445
|
+
const action = await this.showExtensionSelector(`HUMAIN Code / Accounts — ${provider.name}: ${account.label}\nSelection is global. OAuth plans may bill extra usage at the provider. OAuth logins without provider identity cannot detect duplicates; use Reauthenticate to keep the same entry.${flow ? `\n${FLOW_ACCOUNT_PERSISTENCE_NOTICE}` : ""}`, [
|
|
5246
5446
|
"Use for future requests",
|
|
5247
5447
|
"Rename…",
|
|
5248
5448
|
"Add another account…",
|
|
5249
5449
|
"Reauthenticate…",
|
|
5250
5450
|
"Remove from HUMAIN Code…",
|
|
5251
5451
|
"Back",
|
|
5252
|
-
]);
|
|
5253
|
-
if (action === "Back")
|
|
5254
|
-
|
|
5452
|
+
], { signal });
|
|
5453
|
+
if (action === "Back") {
|
|
5454
|
+
if (!flow)
|
|
5455
|
+
await this.showOAuthAccountSelector(provider);
|
|
5456
|
+
}
|
|
5255
5457
|
else if (action === "Remove from HUMAIN Code…")
|
|
5256
|
-
await this.removeOAuthAccount(provider, account.key);
|
|
5257
|
-
else if (action === "Add another account…")
|
|
5258
|
-
|
|
5458
|
+
await this.removeOAuthAccount(provider, account.key, signal);
|
|
5459
|
+
else if (action === "Add another account…") {
|
|
5460
|
+
if (flow)
|
|
5461
|
+
await flow.connect();
|
|
5462
|
+
else
|
|
5463
|
+
await this.handleLoginCommand(provider.id);
|
|
5464
|
+
}
|
|
5259
5465
|
else if (action === "Reauthenticate…") {
|
|
5260
5466
|
const method = this.getLoginProviderOptions(account.type).find((entry) => entry.id === provider.id);
|
|
5261
5467
|
if (method)
|
|
@@ -5266,7 +5472,9 @@ export class InteractiveMode {
|
|
|
5266
5472
|
else if (action === "Rename…" || action === "Use for future requests") {
|
|
5267
5473
|
try {
|
|
5268
5474
|
const options = { signal: AbortSignal.timeout(15_000) };
|
|
5269
|
-
const label = action === "Rename…"
|
|
5475
|
+
const label = action === "Rename…"
|
|
5476
|
+
? await this.showExtensionInput("Rename account", account.label, { signal })
|
|
5477
|
+
: undefined;
|
|
5270
5478
|
if (action === "Rename…" && label === undefined)
|
|
5271
5479
|
return;
|
|
5272
5480
|
const changed = action === "Rename…"
|
|
@@ -5291,7 +5499,7 @@ export class InteractiveMode {
|
|
|
5291
5499
|
}
|
|
5292
5500
|
}
|
|
5293
5501
|
}
|
|
5294
|
-
async removeOAuthAccount(provider, accountKey) {
|
|
5502
|
+
async removeOAuthAccount(provider, accountKey, signal) {
|
|
5295
5503
|
try {
|
|
5296
5504
|
const pool = this.session.modelRuntime.oauthAccounts;
|
|
5297
5505
|
const accounts = await pool.listAccounts(provider.id, { signal: AbortSignal.timeout(15_000) });
|
|
@@ -5306,7 +5514,7 @@ export class InteractiveMode {
|
|
|
5306
5514
|
? ` ${successor.label} will become active.`
|
|
5307
5515
|
: ` ${provider.name} will be signed out.`
|
|
5308
5516
|
: "";
|
|
5309
|
-
const confirmed = await this.showExtensionSelector(`Remove ${provider.name} account ${account.label} from HUMAIN Code?\nThis removes the account from HUMAIN Code only; it does not revoke access at the provider.${activeChange}`, ["Keep account", "Remove account"]);
|
|
5517
|
+
const confirmed = await this.showExtensionSelector(`Remove ${provider.name} account ${account.label} from HUMAIN Code?\nThis removes the account from HUMAIN Code only; it does not revoke access at the provider.${activeChange}`, ["Keep account", "Remove account"], { signal });
|
|
5310
5518
|
if (confirmed !== "Remove account")
|
|
5311
5519
|
return;
|
|
5312
5520
|
const status = await this.session.modelRuntime.logoutWithStatus(provider.id, {
|
|
@@ -5621,7 +5829,7 @@ export class InteractiveMode {
|
|
|
5621
5829
|
})
|
|
5622
5830
|
.finally(() => clearTimeout(timeout));
|
|
5623
5831
|
}
|
|
5624
|
-
showAmbientAuthDialog(providerOption, onBack) {
|
|
5832
|
+
showAmbientAuthDialog(providerOption, onBack, signal) {
|
|
5625
5833
|
const restoreEditor = () => {
|
|
5626
5834
|
this.editorContainer.clear();
|
|
5627
5835
|
this.editorContainer.addChild(this.editor);
|
|
@@ -5629,14 +5837,20 @@ export class InteractiveMode {
|
|
|
5629
5837
|
this.ui.requestRender();
|
|
5630
5838
|
};
|
|
5631
5839
|
const dialog = new LoginDialogComponent(this.ui, providerOption.id, () => {
|
|
5840
|
+
signal?.removeEventListener("abort", dismiss);
|
|
5632
5841
|
restoreEditor();
|
|
5633
5842
|
onBack?.();
|
|
5634
5843
|
}, providerOption.name, `${providerOption.name} setup`);
|
|
5844
|
+
const dismiss = () => dialog.dismiss();
|
|
5635
5845
|
dialog.showInfo(`${providerOption.method?.name ?? "Authentication"} is configured outside ${APP_TITLE}.`, [], true);
|
|
5636
5846
|
this.editorContainer.clear();
|
|
5637
5847
|
this.editorContainer.addChild(dialog);
|
|
5638
5848
|
this.ui.setFocus(dialog);
|
|
5639
5849
|
this.ui.requestRender();
|
|
5850
|
+
if (signal?.aborted)
|
|
5851
|
+
dismiss();
|
|
5852
|
+
else
|
|
5853
|
+
signal?.addEventListener("abort", dismiss, { once: true });
|
|
5640
5854
|
}
|
|
5641
5855
|
async showApiKeyLoginDialog(providerId, providerName, onBack, accountKey) {
|
|
5642
5856
|
const previousModel = this.session.model;
|
|
@@ -5645,7 +5859,7 @@ export class InteractiveMode {
|
|
|
5645
5859
|
}, providerName);
|
|
5646
5860
|
if (providerId === "amazon-bedrock") {
|
|
5647
5861
|
dialog.showDetails([
|
|
5648
|
-
theme.fg("text", "
|
|
5862
|
+
theme.fg("text", "Choose a Bedrock API key or AWS credentials (profile, SSO, role, or environment), then a region."),
|
|
5649
5863
|
theme.fg("muted", "See:"),
|
|
5650
5864
|
theme.fg("accent", ` ${path.join(getDocsPath(), "providers.md")}`),
|
|
5651
5865
|
]);
|
|
@@ -5747,6 +5961,12 @@ export class InteractiveMode {
|
|
|
5747
5961
|
}
|
|
5748
5962
|
async loginProvider(dialog, providerId, providerName, method, accountKey) {
|
|
5749
5963
|
this.programStatus.setBlocked("login", { kind: "auth", message: `Log in to ${providerName}` });
|
|
5964
|
+
const hostSignal = this.activeFlowAccountsSignal;
|
|
5965
|
+
const dismiss = () => dialog.dismiss();
|
|
5966
|
+
if (hostSignal?.aborted)
|
|
5967
|
+
dismiss();
|
|
5968
|
+
else
|
|
5969
|
+
hostSignal?.addEventListener("abort", dismiss, { once: true });
|
|
5750
5970
|
try {
|
|
5751
5971
|
await this.session.modelRuntime.login(providerId, method, {
|
|
5752
5972
|
signal: dialog.signal,
|
|
@@ -5755,6 +5975,7 @@ export class InteractiveMode {
|
|
|
5755
5975
|
}, { getDeviceId: () => this.settingsManager.getOrCreateDeviceId(), accountKey });
|
|
5756
5976
|
}
|
|
5757
5977
|
finally {
|
|
5978
|
+
hostSignal?.removeEventListener("abort", dismiss);
|
|
5758
5979
|
this.programStatus.setBlocked("login", undefined);
|
|
5759
5980
|
}
|
|
5760
5981
|
}
|
|
@@ -5907,6 +6128,8 @@ export class InteractiveMode {
|
|
|
5907
6128
|
}
|
|
5908
6129
|
this.showError(`Reload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5909
6130
|
}
|
|
6131
|
+
// Reload builds a new extension runner and registry, so the previous host generation is stale.
|
|
6132
|
+
this.bindFlowAccountsHostToSession();
|
|
5910
6133
|
}
|
|
5911
6134
|
async handleExportCommand(text) {
|
|
5912
6135
|
const outputPath = this.getPathCommandArgument(text, "/export");
|