johns-harness 2026.10.19 → 2026.10.20
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 +7 -0
- package/README.md +1 -1
- package/dist/compact-B247y5Qt.js +9 -2
- package/dist/gateway-cli-B7fBU7gD.js +13 -8
- package/dist/gateway-cli-BCNMwzNq.js +13 -8
- package/dist/pi-embedded-C6ITuRXf.js +9 -2
- package/dist/pi-embedded-DoQsYfIY.js +9 -2
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +9 -2
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +9 -2
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +9 -2
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +9 -2
- package/dist/plugin-sdk/dispatch-UogiJYul.js +9 -2
- package/dist/plugin-sdk/reply-DbZnH8-h.js +9 -2
- package/dist/reply-C5LKjXcC.js +9 -2
- package/dist/subscription-login.js +19 -2
- package/docs/PATCHES.md +19 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026.10.20
|
|
4
|
+
|
|
5
|
+
- **A subscription login takes effect on the very next turn.** After `/login claude` or `/login chatgpt` (chat or CLI), the matching subscription serves the next turn of every existing session with no `johnness secrets reload`, no `/new` and no restart. Root cause: the gateway serves turns from an in-memory auth snapshot taken at start, and a login wrote `auth-profiles.json` without replacing it, so the picker never saw the new profile until a reload. The login now refreshes that snapshot: in process when the login runs inside the gateway, over the `secrets.reload` RPC when it runs from the CLI; no gateway running is fine.
|
|
6
|
+
- **`/status` names the profile that actually served the last turn** (`authProfileServed`), ahead of any stale override, so the card says "oauth (anthropic:subscription)" when the subscription ran and "api-key" when the API key did.
|
|
7
|
+
- **Validation:** Family 89 exact replay from a clean checkout (13 files byte-identical), picker trigger across all ten reply bundles, refresh paths, status label, strip and re-layer with Families 86 to 88, and an end-to-end test against an isolated gateway: API key on turn one, a control save without the refresh still on the API key, then the real save and the next turn of the same session on the subscription bearer token. 557 verifier checks, full suite.
|
|
8
|
+
- **Rollback:** `npm i -g johns-harness@2026.10.19`.
|
|
9
|
+
|
|
3
10
|
## 2026.10.19
|
|
4
11
|
|
|
5
12
|
- **Claude subscription turns now draw from the plan's included limits, not extra usage.** John's requirement: "I don't want it to use extra usage, I want it to use the real subscription. Make it emulate Claude code if necessary." Anthropic decides per request, from content, whether a subscription turn is first party (plan limits) or third party (the organization's Extra usage). The harness prompt plus its tool list scored as third party, so with Extra usage off every turn was HTTP 400 and fell back to the API key. Real Claude Code 2.1.292 was captured on the wire and 2.1.304 was read from the binary: Claude Code sends an attribution system block first, `x-anthropic-billing-header: cc_version=<version>.<hash>; cc_entrypoint=sdk-cli; cch=00000;`, then its identity line. With that block first, the full harness prompt and 28 tools are served from plan limits.
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Send `/login` to list subscription choices. Use `/login chatgpt` (or `/login gpt
|
|
|
51
51
|
|
|
52
52
|
For **ChatGPT**, open the link, sign in, enter the device code on that page and tap Approve. In Telegram, tap the code to copy it. Enable "Device code authorization for Codex" once in chatgpt.com > Settings > Security; then send `/login chatgpt` for a fresh code. The existing device flow is unchanged.
|
|
53
53
|
|
|
54
|
-
For **Claude**, open the link, sign in to your subscription account, approve, then copy the complete code (including `#state`) from the callback page. Send `/login claude <complete code>` in the same chat. This uses the Claude Code OAuth client and request envelope, not a new third-party Anthropic client. Eligible Pro, Max and Team accounts use subscription limits first, with your existing Anthropic API-key profile as fallback on rate limits, authentication failures or quota exhaustion. Subscription turns record $0; API fallback turns keep normal API pricing. Tokens refresh automatically. Sign-in does not edit gateway configuration. Subscription turns are served from your plan's included limits: the adapter sends Claude Code's own request attribution (the same first system block and Agent SDK identity line Claude Code sends), so the full harness prompt and tools are not billed as third-party extra usage. If Anthropic ever answers "Third-party apps now draw from extra usage", the harness falls back to the API key on that turn.
|
|
54
|
+
For **Claude**, open the link, sign in to your subscription account, approve, then copy the complete code (including `#state`) from the callback page. Send `/login claude <complete code>` in the same chat. This uses the Claude Code OAuth client and request envelope, not a new third-party Anthropic client. Eligible Pro, Max and Team accounts use subscription limits first, with your existing Anthropic API-key profile as fallback on rate limits, authentication failures or quota exhaustion. Subscription turns record $0; API fallback turns keep normal API pricing. Tokens refresh automatically. Sign-in does not edit gateway configuration. Subscription turns are served from your plan's included limits: the adapter sends Claude Code's own request attribution (the same first system block and Agent SDK identity line Claude Code sends), so the full harness prompt and tools are not billed as third-party extra usage. If Anthropic ever answers "Third-party apps now draw from extra usage", the harness falls back to the API key on that turn. A login takes effect on the very next turn of every existing session; `/status` shows the profile that served the last turn.
|
|
55
55
|
|
|
56
56
|
In a terminal, run `johnness login` to list choices, `johnness login chatgpt` or `johnness login claude`. Claude opens the browser and asks for the complete code; use `--no-browser` on a remote host to print the link instead. The equivalent commands are `johnness models auth login chatgpt` and `johnness models auth login claude`. Existing `johnness models auth login --device` remains a ChatGPT shortcut.
|
|
57
57
|
|
package/dist/compact-B247y5Qt.js
CHANGED
|
@@ -19078,7 +19078,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
19078
19078
|
usage,
|
|
19079
19079
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
19080
19080
|
promptTokens,
|
|
19081
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
19081
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
19082
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
19082
19083
|
};
|
|
19083
19084
|
const payloads = buildEmbeddedRunPayloads({
|
|
19084
19085
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -35895,7 +35896,9 @@ function resolveModelAuthLabel(params) {
|
|
|
35895
35896
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
35896
35897
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
35897
35898
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
35898
|
-
|
|
35899
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
35900
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
35901
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
35899
35902
|
cfg: params.cfg,
|
|
35900
35903
|
store,
|
|
35901
35904
|
provider: providerKey,
|
|
@@ -58645,6 +58648,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
58645
58648
|
const patch = {
|
|
58646
58649
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
58647
58650
|
model: params.modelUsed ?? entry.model,
|
|
58651
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
58648
58652
|
contextTokens: resolvedContextTokens,
|
|
58649
58653
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
58650
58654
|
updatedAt: Date.now()
|
|
@@ -58924,6 +58928,7 @@ function createFollowupRunner(params) {
|
|
|
58924
58928
|
promptTokens,
|
|
58925
58929
|
modelUsed,
|
|
58926
58930
|
providerUsed: fallbackProvider,
|
|
58931
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
58927
58932
|
contextTokensUsed,
|
|
58928
58933
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
58929
58934
|
logLabel: "followup"
|
|
@@ -59261,6 +59266,7 @@ async function runReplyAgent(params) {
|
|
|
59261
59266
|
promptTokens,
|
|
59262
59267
|
modelUsed,
|
|
59263
59268
|
providerUsed,
|
|
59269
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
59264
59270
|
contextTokensUsed,
|
|
59265
59271
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
59266
59272
|
cliSessionId
|
|
@@ -72254,6 +72260,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
72254
72260
|
provider: providerUsed,
|
|
72255
72261
|
model: modelUsed
|
|
72256
72262
|
});
|
|
72263
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
72257
72264
|
if (isCliProvider(providerUsed, cfg)) {
|
|
72258
72265
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
72259
72266
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -23859,15 +23859,19 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23859
23859
|
})().catch((err) => log.error(`Delivery recovery failed: ${String(err)}`));
|
|
23860
23860
|
const execApprovalManager = new ExecApprovalManager();
|
|
23861
23861
|
const execApprovalHandlers = createExecApprovalHandlers(execApprovalManager, { forwarder: createExecApprovalForwarder() });
|
|
23862
|
+
const reloadRuntimeSecrets = async () => {
|
|
23863
|
+
const active = getActiveSecretsRuntimeSnapshot();
|
|
23864
|
+
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23865
|
+
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23866
|
+
reason: "reload",
|
|
23867
|
+
activate: true
|
|
23868
|
+
})).warnings.length };
|
|
23869
|
+
};
|
|
23870
|
+
/* JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: a subscription login inside this process (chat /login) refreshes the
|
|
23871
|
+
runtime auth snapshot through this hook, the same path as the secrets.reload RPC. */
|
|
23872
|
+
globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] = reloadRuntimeSecrets;
|
|
23862
23873
|
const secretsHandlers = createSecretsHandlers({
|
|
23863
|
-
reloadSecrets:
|
|
23864
|
-
const active = getActiveSecretsRuntimeSnapshot();
|
|
23865
|
-
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23866
|
-
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23867
|
-
reason: "reload",
|
|
23868
|
-
activate: true
|
|
23869
|
-
})).warnings.length };
|
|
23870
|
-
},
|
|
23874
|
+
reloadSecrets: reloadRuntimeSecrets,
|
|
23871
23875
|
resolveSecrets: async ({ commandName, targetIds }) => {
|
|
23872
23876
|
const { assignments, diagnostics, inactiveRefPaths } = resolveCommandSecretsFromActiveRuntimeSnapshot({
|
|
23873
23877
|
commandName,
|
|
@@ -24107,6 +24111,7 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
24107
24111
|
browserAuthRateLimiter.dispose();
|
|
24108
24112
|
channelHealthMonitor?.stop();
|
|
24109
24113
|
clearSecretsRuntimeSnapshot();
|
|
24114
|
+
if (globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] === reloadRuntimeSecrets) delete globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')];
|
|
24110
24115
|
await close(opts);
|
|
24111
24116
|
} };
|
|
24112
24117
|
}
|
|
@@ -23861,15 +23861,19 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23861
23861
|
})().catch((err) => log.error(`Delivery recovery failed: ${String(err)}`));
|
|
23862
23862
|
const execApprovalManager = new ExecApprovalManager();
|
|
23863
23863
|
const execApprovalHandlers = createExecApprovalHandlers(execApprovalManager, { forwarder: createExecApprovalForwarder() });
|
|
23864
|
+
const reloadRuntimeSecrets = async () => {
|
|
23865
|
+
const active = getActiveSecretsRuntimeSnapshot();
|
|
23866
|
+
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23867
|
+
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23868
|
+
reason: "reload",
|
|
23869
|
+
activate: true
|
|
23870
|
+
})).warnings.length };
|
|
23871
|
+
};
|
|
23872
|
+
/* JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: a subscription login inside this process (chat /login) refreshes the
|
|
23873
|
+
runtime auth snapshot through this hook, the same path as the secrets.reload RPC. */
|
|
23874
|
+
globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] = reloadRuntimeSecrets;
|
|
23864
23875
|
const secretsHandlers = createSecretsHandlers({
|
|
23865
|
-
reloadSecrets:
|
|
23866
|
-
const active = getActiveSecretsRuntimeSnapshot();
|
|
23867
|
-
if (!active) throw new Error("Secrets runtime snapshot is not active.");
|
|
23868
|
-
return { warningCount: (await activateRuntimeSecrets(active.sourceConfig, {
|
|
23869
|
-
reason: "reload",
|
|
23870
|
-
activate: true
|
|
23871
|
-
})).warnings.length };
|
|
23872
|
-
},
|
|
23876
|
+
reloadSecrets: reloadRuntimeSecrets,
|
|
23873
23877
|
resolveSecrets: async ({ commandName, targetIds }) => {
|
|
23874
23878
|
const { assignments, diagnostics, inactiveRefPaths } = resolveCommandSecretsFromActiveRuntimeSnapshot({
|
|
23875
23879
|
commandName,
|
|
@@ -24109,6 +24113,7 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
24109
24113
|
browserAuthRateLimiter.dispose();
|
|
24110
24114
|
channelHealthMonitor?.stop();
|
|
24111
24115
|
clearSecretsRuntimeSnapshot();
|
|
24116
|
+
if (globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')] === reloadRuntimeSecrets) delete globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')];
|
|
24112
24117
|
await close(opts);
|
|
24113
24118
|
} };
|
|
24114
24119
|
}
|
|
@@ -27953,7 +27953,9 @@ function resolveModelAuthLabel(params) {
|
|
|
27953
27953
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
27954
27954
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
27955
27955
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
27956
|
-
|
|
27956
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
27957
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
27958
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
27957
27959
|
cfg: params.cfg,
|
|
27958
27960
|
store,
|
|
27959
27961
|
provider: providerKey,
|
|
@@ -52919,6 +52921,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
52919
52921
|
const patch = {
|
|
52920
52922
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
52921
52923
|
model: params.modelUsed ?? entry.model,
|
|
52924
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
52922
52925
|
contextTokens: resolvedContextTokens,
|
|
52923
52926
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
52924
52927
|
updatedAt: Date.now()
|
|
@@ -53198,6 +53201,7 @@ function createFollowupRunner(params) {
|
|
|
53198
53201
|
promptTokens,
|
|
53199
53202
|
modelUsed,
|
|
53200
53203
|
providerUsed: fallbackProvider,
|
|
53204
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53201
53205
|
contextTokensUsed,
|
|
53202
53206
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53203
53207
|
logLabel: "followup"
|
|
@@ -53662,6 +53666,7 @@ async function runReplyAgent(params) {
|
|
|
53662
53666
|
promptTokens,
|
|
53663
53667
|
modelUsed,
|
|
53664
53668
|
providerUsed,
|
|
53669
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53665
53670
|
contextTokensUsed,
|
|
53666
53671
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53667
53672
|
cliSessionId
|
|
@@ -69832,6 +69837,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
69832
69837
|
provider: providerUsed,
|
|
69833
69838
|
model: modelUsed
|
|
69834
69839
|
});
|
|
69840
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
69835
69841
|
if (isCliProvider(providerUsed, cfg)) {
|
|
69836
69842
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
69837
69843
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -104750,7 +104756,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
104750
104756
|
usage,
|
|
104751
104757
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
104752
104758
|
promptTokens,
|
|
104753
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
104759
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
104760
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
104754
104761
|
};
|
|
104755
104762
|
const payloads = buildEmbeddedRunPayloads({
|
|
104756
104763
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -27949,7 +27949,9 @@ function resolveModelAuthLabel(params) {
|
|
|
27949
27949
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
27950
27950
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
27951
27951
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
27952
|
-
|
|
27952
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
27953
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
27954
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
27953
27955
|
cfg: params.cfg,
|
|
27954
27956
|
store,
|
|
27955
27957
|
provider: providerKey,
|
|
@@ -52915,6 +52917,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
52915
52917
|
const patch = {
|
|
52916
52918
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
52917
52919
|
model: params.modelUsed ?? entry.model,
|
|
52920
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
52918
52921
|
contextTokens: resolvedContextTokens,
|
|
52919
52922
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
52920
52923
|
updatedAt: Date.now()
|
|
@@ -53194,6 +53197,7 @@ function createFollowupRunner(params) {
|
|
|
53194
53197
|
promptTokens,
|
|
53195
53198
|
modelUsed,
|
|
53196
53199
|
providerUsed: fallbackProvider,
|
|
53200
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53197
53201
|
contextTokensUsed,
|
|
53198
53202
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53199
53203
|
logLabel: "followup"
|
|
@@ -53658,6 +53662,7 @@ async function runReplyAgent(params) {
|
|
|
53658
53662
|
promptTokens,
|
|
53659
53663
|
modelUsed,
|
|
53660
53664
|
providerUsed,
|
|
53665
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
53661
53666
|
contextTokensUsed,
|
|
53662
53667
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
53663
53668
|
cliSessionId
|
|
@@ -69828,6 +69833,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
69828
69833
|
provider: providerUsed,
|
|
69829
69834
|
model: modelUsed
|
|
69830
69835
|
});
|
|
69836
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
69831
69837
|
if (isCliProvider(providerUsed, cfg)) {
|
|
69832
69838
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
69833
69839
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -104718,7 +104724,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
104718
104724
|
usage,
|
|
104719
104725
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
104720
104726
|
promptTokens,
|
|
104721
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
104727
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
104728
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
104722
104729
|
};
|
|
104723
104730
|
const payloads = buildEmbeddedRunPayloads({
|
|
104724
104731
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -24292,7 +24292,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24292
24292
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24293
24293
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24294
24294
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24295
|
-
|
|
24295
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24296
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24297
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24296
24298
|
cfg: params.cfg,
|
|
24297
24299
|
store,
|
|
24298
24300
|
provider: providerKey,
|
|
@@ -34026,6 +34028,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34026
34028
|
provider: providerUsed,
|
|
34027
34029
|
model: modelUsed
|
|
34028
34030
|
});
|
|
34031
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34029
34032
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34030
34033
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34031
34034
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -88962,7 +88965,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88965
|
usage,
|
|
88963
88966
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88967
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88968
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88969
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88970
|
};
|
|
88967
88971
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88972
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100359,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100359
|
const patch = {
|
|
100356
100360
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100361
|
model: params.modelUsed ?? entry.model,
|
|
100362
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100363
|
contextTokens: resolvedContextTokens,
|
|
100359
100364
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100365
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100639,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100639
|
promptTokens,
|
|
100635
100640
|
modelUsed,
|
|
100636
100641
|
providerUsed: fallbackProvider,
|
|
100642
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100643
|
contextTokensUsed,
|
|
100638
100644
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100645
|
logLabel: "followup"
|
|
@@ -100971,6 +100977,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100977
|
promptTokens,
|
|
100972
100978
|
modelUsed,
|
|
100973
100979
|
providerUsed,
|
|
100980
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100981
|
contextTokensUsed,
|
|
100975
100982
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100983
|
cliSessionId
|
|
@@ -24401,7 +24401,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24401
24401
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24402
24402
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24403
24403
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24404
|
-
|
|
24404
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24405
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24406
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24405
24407
|
cfg: params.cfg,
|
|
24406
24408
|
store,
|
|
24407
24409
|
provider: providerKey,
|
|
@@ -34125,6 +34127,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34125
34127
|
provider: providerUsed,
|
|
34126
34128
|
model: modelUsed
|
|
34127
34129
|
});
|
|
34130
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34128
34131
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34129
34132
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34130
34133
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -88962,7 +88965,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88965
|
usage,
|
|
88963
88966
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88967
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88968
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88969
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88970
|
};
|
|
88967
88971
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88972
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100359,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100359
|
const patch = {
|
|
100356
100360
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100361
|
model: params.modelUsed ?? entry.model,
|
|
100362
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100363
|
contextTokens: resolvedContextTokens,
|
|
100359
100364
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100365
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100639,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100639
|
promptTokens,
|
|
100635
100640
|
modelUsed,
|
|
100636
100641
|
providerUsed: fallbackProvider,
|
|
100642
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100643
|
contextTokensUsed,
|
|
100638
100644
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100645
|
logLabel: "followup"
|
|
@@ -100971,6 +100977,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100977
|
promptTokens,
|
|
100972
100978
|
modelUsed,
|
|
100973
100979
|
providerUsed,
|
|
100980
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100981
|
contextTokensUsed,
|
|
100975
100982
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100983
|
cliSessionId
|
|
@@ -24985,7 +24985,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24985
24985
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24986
24986
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24987
24987
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24988
|
-
|
|
24988
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24989
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24990
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24989
24991
|
cfg: params.cfg,
|
|
24990
24992
|
store,
|
|
24991
24993
|
provider: providerKey,
|
|
@@ -34719,6 +34721,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34719
34721
|
provider: providerUsed,
|
|
34720
34722
|
model: modelUsed
|
|
34721
34723
|
});
|
|
34724
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34722
34725
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34723
34726
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34724
34727
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -89276,7 +89279,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
89276
89279
|
usage,
|
|
89277
89280
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
89278
89281
|
promptTokens,
|
|
89279
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
89282
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
89283
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
89280
89284
|
};
|
|
89281
89285
|
const payloads = buildEmbeddedRunPayloads({
|
|
89282
89286
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100669,6 +100673,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100669
100673
|
const patch = {
|
|
100670
100674
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100671
100675
|
model: params.modelUsed ?? entry.model,
|
|
100676
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100672
100677
|
contextTokens: resolvedContextTokens,
|
|
100673
100678
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100674
100679
|
updatedAt: Date.now()
|
|
@@ -100948,6 +100953,7 @@ function createFollowupRunner(params) {
|
|
|
100948
100953
|
promptTokens,
|
|
100949
100954
|
modelUsed,
|
|
100950
100955
|
providerUsed: fallbackProvider,
|
|
100956
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100951
100957
|
contextTokensUsed,
|
|
100952
100958
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100953
100959
|
logLabel: "followup"
|
|
@@ -101285,6 +101291,7 @@ async function runReplyAgent(params) {
|
|
|
101285
101291
|
promptTokens,
|
|
101286
101292
|
modelUsed,
|
|
101287
101293
|
providerUsed,
|
|
101294
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101288
101295
|
contextTokensUsed,
|
|
101289
101296
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
101290
101297
|
cliSessionId
|
|
@@ -24666,7 +24666,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24666
24666
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24667
24667
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24668
24668
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24669
|
-
|
|
24669
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24670
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24671
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24670
24672
|
cfg: params.cfg,
|
|
24671
24673
|
store,
|
|
24672
24674
|
provider: providerKey,
|
|
@@ -34390,6 +34392,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34390
34392
|
provider: providerUsed,
|
|
34391
34393
|
model: modelUsed
|
|
34392
34394
|
});
|
|
34395
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34393
34396
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34394
34397
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34395
34398
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -89003,7 +89006,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
89003
89006
|
usage,
|
|
89004
89007
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
89005
89008
|
promptTokens,
|
|
89006
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
89009
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
89010
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
89007
89011
|
};
|
|
89008
89012
|
const payloads = buildEmbeddedRunPayloads({
|
|
89009
89013
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100396,6 +100400,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100396
100400
|
const patch = {
|
|
100397
100401
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100398
100402
|
model: params.modelUsed ?? entry.model,
|
|
100403
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100399
100404
|
contextTokens: resolvedContextTokens,
|
|
100400
100405
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100401
100406
|
updatedAt: Date.now()
|
|
@@ -100675,6 +100680,7 @@ function createFollowupRunner(params) {
|
|
|
100675
100680
|
promptTokens,
|
|
100676
100681
|
modelUsed,
|
|
100677
100682
|
providerUsed: fallbackProvider,
|
|
100683
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100678
100684
|
contextTokensUsed,
|
|
100679
100685
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100680
100686
|
logLabel: "followup"
|
|
@@ -101012,6 +101018,7 @@ async function runReplyAgent(params) {
|
|
|
101012
101018
|
promptTokens,
|
|
101013
101019
|
modelUsed,
|
|
101014
101020
|
providerUsed,
|
|
101021
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101015
101022
|
contextTokensUsed,
|
|
101016
101023
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
101017
101024
|
cliSessionId
|
|
@@ -24579,7 +24579,9 @@ function resolveModelAuthLabel(params) {
|
|
|
24579
24579
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
24580
24580
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
24581
24581
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
24582
|
-
|
|
24582
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
24583
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
24584
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
24583
24585
|
cfg: params.cfg,
|
|
24584
24586
|
store,
|
|
24585
24587
|
provider: providerKey,
|
|
@@ -34313,6 +34315,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
34313
34315
|
provider: providerUsed,
|
|
34314
34316
|
model: modelUsed
|
|
34315
34317
|
});
|
|
34318
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
34316
34319
|
if (isCliProvider(providerUsed, cfg)) {
|
|
34317
34320
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
34318
34321
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -88962,7 +88965,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
88962
88965
|
usage,
|
|
88963
88966
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
88964
88967
|
promptTokens,
|
|
88965
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
88968
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
88969
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
88966
88970
|
};
|
|
88967
88971
|
const payloads = buildEmbeddedRunPayloads({
|
|
88968
88972
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -100355,6 +100359,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
100355
100359
|
const patch = {
|
|
100356
100360
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
100357
100361
|
model: params.modelUsed ?? entry.model,
|
|
100362
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100358
100363
|
contextTokens: resolvedContextTokens,
|
|
100359
100364
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
100360
100365
|
updatedAt: Date.now()
|
|
@@ -100634,6 +100639,7 @@ function createFollowupRunner(params) {
|
|
|
100634
100639
|
promptTokens,
|
|
100635
100640
|
modelUsed,
|
|
100636
100641
|
providerUsed: fallbackProvider,
|
|
100642
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100637
100643
|
contextTokensUsed,
|
|
100638
100644
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100639
100645
|
logLabel: "followup"
|
|
@@ -100971,6 +100977,7 @@ async function runReplyAgent(params) {
|
|
|
100971
100977
|
promptTokens,
|
|
100972
100978
|
modelUsed,
|
|
100973
100979
|
providerUsed,
|
|
100980
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
100974
100981
|
contextTokensUsed,
|
|
100975
100982
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
100976
100983
|
cliSessionId
|
|
@@ -29358,7 +29358,9 @@ function resolveModelAuthLabel(params) {
|
|
|
29358
29358
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
29359
29359
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
29360
29360
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
29361
|
-
|
|
29361
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
29362
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
29363
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
29362
29364
|
cfg: params.cfg,
|
|
29363
29365
|
store,
|
|
29364
29366
|
provider: providerKey,
|
|
@@ -38367,6 +38369,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
38367
38369
|
provider: providerUsed,
|
|
38368
38370
|
model: modelUsed
|
|
38369
38371
|
});
|
|
38372
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
38370
38373
|
if (isCliProvider(providerUsed, cfg)) {
|
|
38371
38374
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
38372
38375
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -90552,7 +90555,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
90552
90555
|
usage,
|
|
90553
90556
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
90554
90557
|
promptTokens,
|
|
90555
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
90558
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
90559
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
90556
90560
|
};
|
|
90557
90561
|
const payloads = buildEmbeddedRunPayloads({
|
|
90558
90562
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -101489,6 +101493,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
101489
101493
|
const patch = {
|
|
101490
101494
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
101491
101495
|
model: params.modelUsed ?? entry.model,
|
|
101496
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101492
101497
|
contextTokens: resolvedContextTokens,
|
|
101493
101498
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
101494
101499
|
updatedAt: Date.now()
|
|
@@ -101768,6 +101773,7 @@ function createFollowupRunner(params) {
|
|
|
101768
101773
|
promptTokens,
|
|
101769
101774
|
modelUsed,
|
|
101770
101775
|
providerUsed: fallbackProvider,
|
|
101776
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
101771
101777
|
contextTokensUsed,
|
|
101772
101778
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
101773
101779
|
logLabel: "followup"
|
|
@@ -102105,6 +102111,7 @@ async function runReplyAgent(params) {
|
|
|
102105
102111
|
promptTokens,
|
|
102106
102112
|
modelUsed,
|
|
102107
102113
|
providerUsed,
|
|
102114
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
102108
102115
|
contextTokensUsed,
|
|
102109
102116
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
102110
102117
|
cliSessionId
|
package/dist/reply-C5LKjXcC.js
CHANGED
|
@@ -25814,7 +25814,9 @@ function resolveModelAuthLabel(params) {
|
|
|
25814
25814
|
const providerKey = normalizeProviderId(resolvedProvider);
|
|
25815
25815
|
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
25816
25816
|
const profileOverride = params.sessionEntry?.authProfileOverride?.trim();
|
|
25817
|
-
|
|
25817
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the profile that served the last turn comes first, so /status shows what ran.
|
|
25818
|
+
const profileServed = params.sessionEntry?.authProfileServed?.trim();
|
|
25819
|
+
const candidates = [profileServed, profileOverride, ...resolveAuthProfileOrder({
|
|
25818
25820
|
cfg: params.cfg,
|
|
25819
25821
|
store,
|
|
25820
25822
|
provider: providerKey,
|
|
@@ -32088,6 +32090,7 @@ async function updateSessionStoreAfterAgentRun(params) {
|
|
|
32088
32090
|
provider: providerUsed,
|
|
32089
32091
|
model: modelUsed
|
|
32090
32092
|
});
|
|
32093
|
+
if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
32091
32094
|
if (isCliProvider(providerUsed, cfg)) {
|
|
32092
32095
|
const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
|
|
32093
32096
|
if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
|
|
@@ -82729,7 +82732,8 @@ async function runEmbeddedPiAgent(params) {
|
|
|
82729
82732
|
usage,
|
|
82730
82733
|
lastCallUsage: lastCallUsage ?? void 0,
|
|
82731
82734
|
promptTokens,
|
|
82732
|
-
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0
|
|
82735
|
+
compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
|
|
82736
|
+
authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
|
|
82733
82737
|
};
|
|
82734
82738
|
const payloads = buildEmbeddedRunPayloads({
|
|
82735
82739
|
assistantTexts: attempt.assistantTexts,
|
|
@@ -93374,6 +93378,7 @@ async function persistSessionUsageUpdate(params) {
|
|
|
93374
93378
|
const patch = {
|
|
93375
93379
|
modelProvider: params.providerUsed ?? entry.modelProvider,
|
|
93376
93380
|
model: params.modelUsed ?? entry.model,
|
|
93381
|
+
authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
93377
93382
|
contextTokens: resolvedContextTokens,
|
|
93378
93383
|
systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
|
|
93379
93384
|
updatedAt: Date.now()
|
|
@@ -93653,6 +93658,7 @@ function createFollowupRunner(params) {
|
|
|
93653
93658
|
promptTokens,
|
|
93654
93659
|
modelUsed,
|
|
93655
93660
|
providerUsed: fallbackProvider,
|
|
93661
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
93656
93662
|
contextTokensUsed,
|
|
93657
93663
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
93658
93664
|
logLabel: "followup"
|
|
@@ -93990,6 +93996,7 @@ async function runReplyAgent(params) {
|
|
|
93990
93996
|
promptTokens,
|
|
93991
93997
|
modelUsed,
|
|
93992
93998
|
providerUsed,
|
|
93999
|
+
authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
|
|
93993
94000
|
contextTokensUsed,
|
|
93994
94001
|
systemPromptReport: runResult.meta?.systemPromptReport,
|
|
93995
94002
|
cliSessionId
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// JOHNNESS_PATCH_SUBSCRIPTION_LOGIN_86
|
|
2
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: a successful login refreshes the running gateway's auth snapshot.
|
|
2
3
|
// Native subscription dispatch. Credentials never go through the model or the config file.
|
|
3
4
|
import os from 'node:os';
|
|
4
5
|
import path from 'node:path';
|
|
@@ -40,8 +41,24 @@ export async function saveClaudeCredential(credential, options = {}) {
|
|
|
40
41
|
store.order ??= {};
|
|
41
42
|
store.order.anthropic = [...new Set([CLAUDE_PROFILE_ID, ...(store.order.anthropic ?? []), ...Object.keys(store.profiles).filter(id => store.profiles[id].provider === 'anthropic')])];
|
|
42
43
|
});
|
|
44
|
+
await refreshRuntimeAuthStores(options);
|
|
43
45
|
return { profileId: CLAUDE_PROFILE_ID };
|
|
44
46
|
}
|
|
47
|
+
// JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: the gateway serves turns from an in-memory auth snapshot taken at start, so a
|
|
48
|
+
// credential written to disk is invisible until that snapshot is replaced. In process (chat login)
|
|
49
|
+
// call the refresh the gateway registers; from the CLI ask the running gateway over secrets.reload.
|
|
50
|
+
// No gateway running is normal: the next start loads the store from disk.
|
|
51
|
+
export const AUTH_RUNTIME_REFRESH = Symbol.for('johnness.authRuntimeRefresh.v1');
|
|
52
|
+
export async function refreshRuntimeAuthStores(options = {}) {
|
|
53
|
+
const inProcess = options.refreshRuntime ?? globalThis[AUTH_RUNTIME_REFRESH];
|
|
54
|
+
try {
|
|
55
|
+
if (typeof inProcess === 'function') { await inProcess(); return 'in-process'; }
|
|
56
|
+
if (options.rpc === false) return 'skipped';
|
|
57
|
+
const call = options.callGateway ?? (await import('./gateway-rpc-DB8opYdF.js')).n;
|
|
58
|
+
await call('secrets.reload', { timeout: options.rpcTimeoutMs ?? 5000 }, undefined, { expectFinal: false, progress: false });
|
|
59
|
+
return 'rpc';
|
|
60
|
+
} catch { return 'unavailable'; }
|
|
61
|
+
}
|
|
45
62
|
|
|
46
63
|
export async function startClaudeLogin(options = {}) {
|
|
47
64
|
const login = options.login ?? (await import('@mariozechner/pi-ai/dist/utils/oauth/anthropic.js')).loginAnthropic;
|
|
@@ -81,7 +98,7 @@ export async function handleSubscriptionLoginCommand(params, allowTextCommands,
|
|
|
81
98
|
if (!provider) return reply(LOGIN_OPTIONS);
|
|
82
99
|
if (provider === 'chatgpt') {
|
|
83
100
|
if (match[2]) return reply('Use /login chatgpt to get a ChatGPT device code.');
|
|
84
|
-
const result = await (options.handleChatgpt ?? handleDeviceLoginCommand)({ ...params, command: { ...params.command, commandBodyNormalized: '/login' } }, allowTextCommands, options);
|
|
101
|
+
const result = await (options.handleChatgpt ?? handleDeviceLoginCommand)({ ...params, command: { ...params.command, commandBodyNormalized: '/login' } }, allowTextCommands, { hooks: { publish: () => refreshRuntimeAuthStores(options) }, ...options });
|
|
85
102
|
if (result?.reply?.text) result.reply.text = result.reply.text.replace(/Send \/login\b/g, 'Send /login chatgpt');
|
|
86
103
|
return result;
|
|
87
104
|
}
|
|
@@ -122,7 +139,7 @@ export function openLoginBrowser(url) {
|
|
|
122
139
|
export async function runSubscriptionLoginCli(provider, opts = {}, runtime = console, options = {}) {
|
|
123
140
|
const selected = normalizeLoginProvider(provider);
|
|
124
141
|
if (!selected) { runtime.log(LOGIN_OPTIONS.replaceAll('/login', 'johnness login')); return; }
|
|
125
|
-
if (selected === 'chatgpt') return (options.runChatgpt ?? runDeviceLoginCli)({ ...opts, provider: 'openai-codex' }, runtime, options);
|
|
142
|
+
if (selected === 'chatgpt') return (options.runChatgpt ?? runDeviceLoginCli)({ ...opts, provider: 'openai-codex' }, runtime, { hooks: { publish: () => refreshRuntimeAuthStores(options) }, ...options });
|
|
126
143
|
if (selected !== 'claude') throw new Error('Unknown subscription. Choose chatgpt (or gpt) or claude.');
|
|
127
144
|
const session = await (options.startClaude ?? startClaudeLogin)(options);
|
|
128
145
|
runtime.log(`Open this URL and sign in to your Claude subscription:\n${session.url}`);
|
package/docs/PATCHES.md
CHANGED
|
@@ -17,7 +17,7 @@ they predate ~2026-06-06).
|
|
|
17
17
|
|
|
18
18
|
## Index
|
|
19
19
|
|
|
20
|
-
Current addition: [
|
|
20
|
+
Current addition: [89 - Subscription activates on the next turn](#89---subscription-activates-on-the-next-turn-2026-10-20).
|
|
21
21
|
|
|
22
22
|
Family 01 is retired. Families 02 through 41, 43 through 81, including the 65.1 amendment, are live on `main`; the `latest` and `extended` release lines converged at 2026.9.24. Family 42 is omitted; native Codex OAuth ownership is Family 58.
|
|
23
23
|
|
|
@@ -114,6 +114,7 @@ Family 01 is retired. Families 02 through 41, 43 through 81, including the 65.1
|
|
|
114
114
|
86. **86, named subscription login:** `/login chatgpt` preserves ChatGPT device sign-in; `/login claude` adds current Claude Code OAuth, subscription-first auth, API fallback and credential-specific $0 accounting. [Details](#86---named-subscription-login-2026-10-20)
|
|
115
115
|
87. **87, subscription failover:** current Claude Code user-agent floor (`claude-cli/2.1.304`) for subscription tokens, and Anthropic's extra-usage and version rejections rotate the subscription profile to the paid API key instead of ending the turn. [Details](#87---subscription-failover-2026-10-20)
|
|
116
116
|
88. **88, subscription plan limits:** subscription turns carry Claude Code's attribution system block (first, uncached, `cc_entrypoint=sdk-cli`, Claude Code's own `cc_version` hash) and the Agent SDK identity line, so Anthropic serves the full harness prompt and tools from the plan's included limits instead of billing third-party extra usage. API-key requests are unchanged. [Details](#88---subscription-plan-limits-2026-10-20)
|
|
117
|
+
89. **89, subscription activates on the next turn:** a subscription login (chat or CLI, Claude or ChatGPT) refreshes the gateway's in-memory runtime auth snapshot, in process or over `secrets.reload`, so the matching subscription serves the very next turn of every existing session with no reload, `/new` or restart. `/status` names the profile that actually served the last turn. [Details](#89---subscription-activates-on-the-next-turn-2026-10-20)
|
|
117
118
|
|
|
118
119
|
---
|
|
119
120
|
|
|
@@ -2999,3 +3000,20 @@ NO_REPLY, failed sends, block streaming, exact replay, idempotence and drift ref
|
|
|
2999
3000
|
**Replay:** `patches/subscription-plan-limits-88/changes.json`, `scripts/patch-subscription-plan-limits-88.py` (`--check`, `--present-only`, `--dependency-only`, `--record`). `scripts/subscription_login_layer.py` and `tests/helpers/subscription-login-layer.mjs` strip and re-layer Family 88 with 86 and 87 so Families 67, 78, 81 and 82 keep exact replay. Verifier checks 88.1 to 88.6.
|
|
3000
3001
|
|
|
3001
3002
|
**Tests:** `tests/subscription-plan-limits-88.test.mjs` (manifest coverage, hash algorithm against the captured real request, block order and cache placement through the real adapter's SSE path, hash follows the first user message, API-key request unchanged, idempotent replay and drift refusal, strip/re-layer), Family 36 and 87 tests updated for the new first block and user-agent. Rollback: `npm i -g johns-harness@2026.10.18`.
|
|
3003
|
+
|
|
3004
|
+
## 89 - Subscription activates on the next turn (2026-10-20)
|
|
3005
|
+
|
|
3006
|
+
**Intent:** John's requirement: after `/login claude` or `/login chatgpt`, the matching subscription is used by default on the very next turn, in existing sessions too, with no manual step (no `johnness secrets reload`, no `/new`, no restart).
|
|
3007
|
+
|
|
3008
|
+
**Root cause:** the gateway serves turns from an in-memory runtime auth snapshot taken at start (Family 58's secrets runtime). A login writes `auth-profiles.json` atomically and correctly, but nothing replaced that snapshot, so the Family 86 picker never saw `anthropic:subscription` in the order and every turn kept running on the API key until a reload or restart. Reproduced in isolated state: save the credential, next turn still `x-api-key`; `secrets.reload`, next turn `Authorization: Bearer sk-ant-oat...`. The picker branch itself was never the problem.
|
|
3009
|
+
|
|
3010
|
+
**Change:**
|
|
3011
|
+
- `dist/subscription-login.js` exports `refreshRuntimeAuthStores(options)`. Inside the gateway (chat `/login`) it calls the hook the gateway registers on `globalThis[Symbol.for('johnness.authRuntimeRefresh.v1')]`; from a CLI process it dynamic-imports the gateway RPC client and sends `secrets.reload` with a 5-second deadline (`rpcTimeoutMs`); `rpc: false` skips it. It never throws: no gateway running is normal, the next start reads the store from disk. Return values `in-process`, `rpc`, `skipped`, `unavailable` are for tests and logs only.
|
|
3012
|
+
- `saveClaudeCredential` calls it after the store transaction commits. Both ChatGPT paths (chat `handleDeviceLoginCommand`, CLI `runDeviceLoginCli`) receive `hooks.publish`, which the Family 58 credential owner invokes after it writes, so the device login refreshes the same way in chat and from the CLI.
|
|
3013
|
+
- Both gateway bundles hoist the `createSecretsHandlers` reload closure to `reloadRuntimeSecrets`, register it on the global symbol at start and delete it on close.
|
|
3014
|
+
- Ten reply bundles: `agentMeta.authProfileId` carries the profile that served the run (`lastProfileId`), `persistSessionUsageUpdate` and `updateSessionStoreAfterAgentRun` store it as `authProfileServed`, and `resolveModelAuthLabel` (the `/status` card) reads `authProfileServed` first, then the override, then the order, so the card names what actually ran.
|
|
3015
|
+
- Picker (Family 86 `claudeSubscriptionOrder`): unchanged. The test proves the subscription-first branch fires once the snapshot is fresh and that an explicit user profile lock still wins.
|
|
3016
|
+
|
|
3017
|
+
**Replay:** `patches/subscription-activate-89/changes.json`, `scripts/patch-subscription-activate-89.py` (`--check` read-only, `--present-only`, `--record`), 13 files: login module (4 hunks), 2 gateway bundles (2 hunks each, identical), 10 reply bundles (6 hunks each, identical). Replayed from a clean checkout of c4c017b in a scratch worktree: all 13 files byte-identical to the shipped tree. `scripts/subscription_login_layer.py` and `tests/helpers/subscription-login-layer.mjs` strip and re-layer Family 89 with 86, 87 and 88; `scripts/patch-subscription-login-86.py` strips the 89 layer before comparing its pinned `dist/subscription-login.js` content and re-layers after a write, so 86 `--check` keeps passing; `tests/helpers/replay-family-67.mjs` replays 89 after 86, and the 65.1 historical reconstruction of the two gateway bundles replays 89 after 76 and 79. Verifier checks 89.1 to 89.8 (557 checks).
|
|
3018
|
+
|
|
3019
|
+
**Tests:** `tests/subscription-activate-89.test.mjs` (19 tests): manifest coverage and uniform hunks; picker trigger in all ten copies (auto override re-picks the subscription once the snapshot has it, user override never does); in-process, RPC and unavailable refresh paths never throw; Claude save refreshes after commit; both ChatGPT paths hand `hooks.publish` to the owner; status label prefers the served profile across all ten copies; idempotent replay, drift refusal before any writes, read-only check; strip and re-layer with 86, 87, 88; and an end-to-end run: an isolated gateway on a free port (never 18789) in a `/tmp` state dir with a mock Anthropic SSE endpoint, turn one on `agent:main:main` served with `x-api-key`, then a control save with the refresh off (next turn still `x-api-key`, the live bug), then the real save in a separate process (the CLI shape), and the very next turn of the same session id served with `Authorization: Bearer sk-ant-oat-...` and `authProfileServed: anthropic:subscription` in `sessions.json`. Rollback: `npm i -g johns-harness@2026.10.19`.
|