@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.8
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 +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +680 -53
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +109 -35
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
- package/dist/builtin/web-access/index.bundle.mjs +109 -35
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1228 -428
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +2 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +108 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -4589,10 +4589,10 @@ function hasAssistantMessage(entries) {
|
|
|
4589
4589
|
return entries.some((entry) => entry.type === "message" && entry.message.role === "assistant");
|
|
4590
4590
|
}
|
|
4591
4591
|
function persistAppendedEntry(filePath, entries, entry, flushed) {
|
|
4592
|
-
if (!hasAssistantMessage(entries))
|
|
4593
|
-
return false;
|
|
4594
4592
|
if (flushed)
|
|
4595
4593
|
appendSessionEntry(filePath, entry);
|
|
4594
|
+
else if (!hasAssistantMessage(entries))
|
|
4595
|
+
return false;
|
|
4596
4596
|
else
|
|
4597
4597
|
appendSessionEntries(filePath, entries);
|
|
4598
4598
|
return true;
|
|
@@ -10723,6 +10723,8 @@ function appendDurableDisplayCard(session, message, delivery) {
|
|
|
10723
10723
|
const card = { ...message, excludeFromContext: true };
|
|
10724
10724
|
const admitted = message;
|
|
10725
10725
|
const intentEntryId = session.sessionManager.appendCustomMessageEntry(card.customType, card.content, card.display, card.details, true, { delivery }, admitted.stageAdmissionKey);
|
|
10726
|
+
if (admitted.stageAdmissionKey !== undefined)
|
|
10727
|
+
session.sessionManager.flush();
|
|
10726
10728
|
session.agent.state.messages.push(card);
|
|
10727
10729
|
return { card, intentEntryId };
|
|
10728
10730
|
}
|
|
@@ -10948,12 +10950,17 @@ var init_agent_session_persistent_custom_messages = __esm(() => {
|
|
|
10948
10950
|
});
|
|
10949
10951
|
|
|
10950
10952
|
// src/core/agent-session-custom-message-commit.ts
|
|
10953
|
+
function appendDurableStageAdmission(session, message) {
|
|
10954
|
+
session._appendCustomMessage(message);
|
|
10955
|
+
if (message.stageAdmissionKey !== undefined)
|
|
10956
|
+
session.sessionManager?.flush();
|
|
10957
|
+
}
|
|
10951
10958
|
async function commitAdmittedCustomMessage(session, appMessage, options) {
|
|
10952
10959
|
const owner = resolveWorkflowStageDeliveryTarget(session);
|
|
10953
10960
|
if (owner !== session)
|
|
10954
10961
|
return commitAdmittedCustomMessage(owner, appMessage, options);
|
|
10955
10962
|
const self = session;
|
|
10956
|
-
const useProtectedReconciliation = options?.persistWhenStreaming === true && options.triggerTurn === true
|
|
10963
|
+
const useProtectedReconciliation = options?.persistWhenStreaming === true && options.excludeFromContext !== true && (options.triggerTurn === true || options.stageAdmissionKey !== undefined);
|
|
10957
10964
|
if (options?.deliverAs === "nextTurn") {
|
|
10958
10965
|
self._pendingNextTurnMessages.push(appMessage);
|
|
10959
10966
|
} else if (self._queuedMessagesPaused) {
|
|
@@ -10967,20 +10974,20 @@ async function commitAdmittedCustomMessage(session, appMessage, options) {
|
|
|
10967
10974
|
} else if (self.isStreaming) {
|
|
10968
10975
|
self._pendingCustomMessages.push(appMessage);
|
|
10969
10976
|
} else {
|
|
10970
|
-
self
|
|
10977
|
+
appendDurableStageAdmission(self, appMessage);
|
|
10971
10978
|
}
|
|
10972
10979
|
} else if (options?.deliverAs === "interrupt" && options.triggerTurn) {
|
|
10973
10980
|
const interrupt = self._enqueueInterruptCustomMessage(appMessage, options);
|
|
10974
10981
|
self._workflowStageAdmission?.trackAdmittedWork(interrupt);
|
|
10975
10982
|
interrupt.catch(() => {});
|
|
10976
10983
|
} else if (self.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {
|
|
10977
|
-
self
|
|
10984
|
+
appendDurableStageAdmission(self, appMessage);
|
|
10978
10985
|
} else if (self.isStreaming && options?.triggerTurn === false) {
|
|
10979
10986
|
self._pendingCustomMessages.push(appMessage);
|
|
10980
10987
|
} else if (self.isStreaming && useProtectedReconciliation) {
|
|
10981
10988
|
await queueProtectedStreamingCustomMessage(self, appMessage, options?.deliverAs === "followUp" ? "followUp" : "steer");
|
|
10982
10989
|
} else if (self.isStreaming && options?.persistWhenStreaming === true) {
|
|
10983
|
-
self
|
|
10990
|
+
appendDurableStageAdmission(self, appMessage);
|
|
10984
10991
|
} else if (self.isStreaming && options?.triggerTurn !== false) {
|
|
10985
10992
|
self._queueAgentMessage(appMessage, options?.deliverAs === "followUp" ? "followUp" : "steer");
|
|
10986
10993
|
} else if (options?.triggerTurn) {
|
|
@@ -11003,7 +11010,7 @@ async function commitAdmittedCustomMessage(session, appMessage, options) {
|
|
|
11003
11010
|
self._continueQueuedAgentMessages().catch(() => {});
|
|
11004
11011
|
}
|
|
11005
11012
|
} else {
|
|
11006
|
-
self
|
|
11013
|
+
appendDurableStageAdmission(self, appMessage);
|
|
11007
11014
|
}
|
|
11008
11015
|
}
|
|
11009
11016
|
function _commitAdmittedCustomMessage(appMessage, options) {
|
|
@@ -19160,6 +19167,7 @@ async function loadVirtualModules() {
|
|
|
19160
19167
|
piAi,
|
|
19161
19168
|
piAiOauth,
|
|
19162
19169
|
piAiCloudflareGatewayBinding,
|
|
19170
|
+
properLockfile,
|
|
19163
19171
|
piCodingAgent
|
|
19164
19172
|
] = await Promise.all([
|
|
19165
19173
|
import("typebox"),
|
|
@@ -19171,6 +19179,7 @@ async function loadVirtualModules() {
|
|
|
19171
19179
|
import("@bastani/pi-ai/compat"),
|
|
19172
19180
|
import("@bastani/pi-ai/oauth"),
|
|
19173
19181
|
import("@bastani/pi-ai/api/cloudflare-gateway-binding"),
|
|
19182
|
+
import("proper-lockfile"),
|
|
19174
19183
|
Promise.resolve().then(() => (init_src(), exports_src))
|
|
19175
19184
|
]);
|
|
19176
19185
|
return {
|
|
@@ -19191,6 +19200,7 @@ async function loadVirtualModules() {
|
|
|
19191
19200
|
"@earendil-works/pi-ai/compat": piAi,
|
|
19192
19201
|
"@earendil-works/pi-ai/oauth": piAiOauth,
|
|
19193
19202
|
"@earendil-works/pi-ai/api/cloudflare-gateway-binding": piAiCloudflareGatewayBinding,
|
|
19203
|
+
"proper-lockfile": properLockfile,
|
|
19194
19204
|
"@bastani/atomic": piCodingAgent,
|
|
19195
19205
|
"@mariozechner/pi-agent-core": piAgentCore,
|
|
19196
19206
|
"@mariozechner/pi-tui": piTui,
|
|
@@ -26320,11 +26330,20 @@ function isCodexFastModeCandidateModelId(modelId) {
|
|
|
26320
26330
|
const provider = modelId?.split("/", 1)[0];
|
|
26321
26331
|
return provider !== undefined && isCodexFastModeSupportedProvider(provider);
|
|
26322
26332
|
}
|
|
26323
|
-
function
|
|
26324
|
-
return
|
|
26333
|
+
function isGitHubCopilotModel(model) {
|
|
26334
|
+
return model.provider === "github-copilot";
|
|
26335
|
+
}
|
|
26336
|
+
function isGitHubCopilotFastModeSupportedModel(model, credential) {
|
|
26337
|
+
if (!isGitHubCopilotModel(model) || credential?.type !== "oauth")
|
|
26338
|
+
return false;
|
|
26339
|
+
const fastModelIds = credential.fastModelIds;
|
|
26340
|
+
return Array.isArray(fastModelIds) && fastModelIds.every((modelId) => typeof modelId === "string") && fastModelIds.includes(`${model.id}-fast`);
|
|
26341
|
+
}
|
|
26342
|
+
function isCodexFastModeSupportedModel(model, copilotCredential) {
|
|
26343
|
+
return isCodexFastModeSupportedProvider(model.provider) || model.api === "openai-codex-responses" || model.id !== undefined && isGitHubCopilotFastModeSupportedModel({ provider: model.provider, id: model.id }, copilotCredential);
|
|
26325
26344
|
}
|
|
26326
|
-
function hasSupportedCodexFastModeModel(models) {
|
|
26327
|
-
return models.some(isCodexFastModeSupportedModel);
|
|
26345
|
+
function hasSupportedCodexFastModeModel(models, copilotCredential) {
|
|
26346
|
+
return models.some((model) => isCodexFastModeSupportedModel(model, copilotCredential));
|
|
26328
26347
|
}
|
|
26329
26348
|
function isWorkflowStageOrchestrationContext(context) {
|
|
26330
26349
|
return context?.kind === "workflow-stage";
|
|
@@ -26335,11 +26354,11 @@ function getCodexFastModeScope(context) {
|
|
|
26335
26354
|
function isCodexFastModeEnabledForScope(settings, scope) {
|
|
26336
26355
|
return settings[scope];
|
|
26337
26356
|
}
|
|
26338
|
-
function shouldApplyCodexFastModeForScope(model, settings, scope) {
|
|
26339
|
-
return isCodexFastModeSupportedModel(model) && isCodexFastModeEnabledForScope(settings, scope);
|
|
26357
|
+
function shouldApplyCodexFastModeForScope(model, settings, scope, copilotCredential) {
|
|
26358
|
+
return isCodexFastModeSupportedModel(model, copilotCredential) && isCodexFastModeEnabledForScope(settings, scope);
|
|
26340
26359
|
}
|
|
26341
|
-
function shouldApplyCodexFastMode(model, settings, context) {
|
|
26342
|
-
return shouldApplyCodexFastModeForScope(model, settings, getCodexFastModeScope(context));
|
|
26360
|
+
function shouldApplyCodexFastMode(model, settings, context, copilotCredential) {
|
|
26361
|
+
return shouldApplyCodexFastModeForScope(model, settings, getCodexFastModeScope(context), copilotCredential);
|
|
26343
26362
|
}
|
|
26344
26363
|
function usesFirstPartyCodexRouting(model) {
|
|
26345
26364
|
return model.provider === "openai-codex" && isFirstPartyCodexBaseUrl(model.baseUrl);
|
|
@@ -26365,8 +26384,8 @@ function withCodexFastModeHeaders(model, headers, enabled) {
|
|
|
26365
26384
|
setHeader(fastHeaders, CODEX_FAST_MODE_ROUTING_HEADER, `model=${model.id};tier=${CODEX_FAST_MODE_SERVICE_TIER}`);
|
|
26366
26385
|
return fastHeaders;
|
|
26367
26386
|
}
|
|
26368
|
-
function withCodexFastModeStreamOptions(
|
|
26369
|
-
if (!enabled) {
|
|
26387
|
+
function withCodexFastModeStreamOptions(model, options, enabled) {
|
|
26388
|
+
if (!enabled || model.provider === "github-copilot") {
|
|
26370
26389
|
return options;
|
|
26371
26390
|
}
|
|
26372
26391
|
return {
|
|
@@ -26500,10 +26519,14 @@ function streamWithCodexFastMode(model, context, options, streamers = DEFAULT_CO
|
|
|
26500
26519
|
function isObjectPayload(payload) {
|
|
26501
26520
|
return typeof payload === "object" && payload !== null && !Array.isArray(payload);
|
|
26502
26521
|
}
|
|
26503
|
-
function withCodexFastModePayload(payload, enabled) {
|
|
26504
|
-
if (!enabled || !isObjectPayload(payload)
|
|
26522
|
+
function withCodexFastModePayload(payload, enabled, model) {
|
|
26523
|
+
if (!enabled || !isObjectPayload(payload))
|
|
26505
26524
|
return payload;
|
|
26525
|
+
if (model?.provider === "github-copilot") {
|
|
26526
|
+
return payload.model === model.id ? { ...payload, model: `${model.id}-fast` } : payload;
|
|
26506
26527
|
}
|
|
26528
|
+
if (payload.service_tier !== undefined)
|
|
26529
|
+
return payload;
|
|
26507
26530
|
return {
|
|
26508
26531
|
...payload,
|
|
26509
26532
|
service_tier: CODEX_FAST_MODE_SERVICE_TIER
|
|
@@ -26653,7 +26676,7 @@ class FooterComponent {
|
|
|
26653
26676
|
pwd += ` • ${sessionName}`;
|
|
26654
26677
|
const modelName = state.model?.id || "no-model";
|
|
26655
26678
|
const fastModeSettings = this.session.settingsManager.getCodexFastModeSettings();
|
|
26656
|
-
const fastModeEnabled = state.model ? shouldApplyCodexFastMode(state.model, fastModeSettings, this.session.orchestrationContext) : false;
|
|
26679
|
+
const fastModeEnabled = state.model ? shouldApplyCodexFastMode(state.model, fastModeSettings, this.session.orchestrationContext, this.session.modelRuntime.getCredentialSnapshot?.("github-copilot")) : false;
|
|
26657
26680
|
let modelLabel2 = modelName;
|
|
26658
26681
|
if (state.model?.reasoning) {
|
|
26659
26682
|
const thinkingLevel = state.thinkingLevel || "off";
|
|
@@ -45421,14 +45444,18 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
45421
45444
|
|
|
45422
45445
|
class WorkflowStageAdmissionBoundary {
|
|
45423
45446
|
open = true;
|
|
45424
|
-
completed
|
|
45447
|
+
completed;
|
|
45425
45448
|
inFlight = new Map;
|
|
45426
45449
|
pending = new Set;
|
|
45427
45450
|
invocationContext = new AsyncLocalStorage;
|
|
45428
45451
|
closePromise;
|
|
45429
45452
|
drainAdmittedWork;
|
|
45430
|
-
constructor(drainAdmittedWork =
|
|
45431
|
-
this.drainAdmittedWork = drainAdmittedWork;
|
|
45453
|
+
constructor(drainAdmittedWork = undefined, completedKeys = []) {
|
|
45454
|
+
this.drainAdmittedWork = drainAdmittedWork ?? (async () => {});
|
|
45455
|
+
this.completed = new Set(completedKeys);
|
|
45456
|
+
}
|
|
45457
|
+
static restore(entries, drainAdmittedWork) {
|
|
45458
|
+
return new WorkflowStageAdmissionBoundary(drainAdmittedWork, Array.from(entries).flatMap((entry) => entry.type === "custom_message" && typeof entry.stageAdmissionKey === "string" ? [entry.stageAdmissionKey] : []));
|
|
45432
45459
|
}
|
|
45433
45460
|
admit(key, deliver, routeLate) {
|
|
45434
45461
|
if (key !== undefined) {
|
|
@@ -45667,7 +45694,7 @@ class AgentSessionBase {
|
|
|
45667
45694
|
this._subagentPolicy = config.subagentPolicy;
|
|
45668
45695
|
this._systemPromptTransform = config.systemPromptTransform;
|
|
45669
45696
|
const stageContext = config.orchestrationContext?.kind === "workflow-stage" ? config.orchestrationContext : undefined;
|
|
45670
|
-
this._workflowStageAdmission = stageContext?.messageAdmission?.boundary ?? (stageContext ?
|
|
45697
|
+
this._workflowStageAdmission = stageContext?.messageAdmission?.boundary ?? (stageContext ? WorkflowStageAdmissionBoundary.restore(this.sessionManager.getBranch()) : undefined);
|
|
45671
45698
|
if (this._workflowStageAdmission && stageContext && stageContext.messageAdmission === undefined) {
|
|
45672
45699
|
stageContext.messageAdmission = {
|
|
45673
45700
|
boundary: this._workflowStageAdmission,
|
|
@@ -45999,6 +46026,9 @@ class AuthStorage {
|
|
|
45999
46026
|
this.data = this.parseStorageData(content);
|
|
46000
46027
|
} catch {}
|
|
46001
46028
|
}
|
|
46029
|
+
peek(provider) {
|
|
46030
|
+
return this.data[provider];
|
|
46031
|
+
}
|
|
46002
46032
|
async read(provider) {
|
|
46003
46033
|
const credential = this.data[provider];
|
|
46004
46034
|
if (credential?.type !== "api_key")
|
|
@@ -47052,6 +47082,10 @@ function getReloadableStore(store) {
|
|
|
47052
47082
|
const reloadable = store;
|
|
47053
47083
|
return typeof reloadable.reload === "function" ? reloadable : undefined;
|
|
47054
47084
|
}
|
|
47085
|
+
function getSnapshotStore(store) {
|
|
47086
|
+
const snapshotStore = store;
|
|
47087
|
+
return typeof snapshotStore.peek === "function" ? snapshotStore : undefined;
|
|
47088
|
+
}
|
|
47055
47089
|
|
|
47056
47090
|
class RuntimeCredentials {
|
|
47057
47091
|
store;
|
|
@@ -47071,6 +47105,10 @@ class RuntimeCredentials {
|
|
|
47071
47105
|
async reload() {
|
|
47072
47106
|
await getReloadableStore(this.store)?.reload();
|
|
47073
47107
|
}
|
|
47108
|
+
peek(providerId) {
|
|
47109
|
+
const override = this.overrides.get(providerId);
|
|
47110
|
+
return override ? { type: "api_key", key: override } : getSnapshotStore(this.store)?.peek(providerId);
|
|
47111
|
+
}
|
|
47074
47112
|
async read(providerId, options) {
|
|
47075
47113
|
const override = this.overrides.get(providerId);
|
|
47076
47114
|
return override ? { type: "api_key", key: override } : this.store.read(providerId, options);
|
|
@@ -47506,6 +47544,9 @@ class ModelRuntime {
|
|
|
47506
47544
|
hasConfiguredAuth(providerId) {
|
|
47507
47545
|
return this.snapshot.configuredProviders.has(providerId);
|
|
47508
47546
|
}
|
|
47547
|
+
getCredentialSnapshot(providerId) {
|
|
47548
|
+
return this.credentials.peek(providerId);
|
|
47549
|
+
}
|
|
47509
47550
|
async getAuth(providerOrModel, overrides = {}) {
|
|
47510
47551
|
if (typeof providerOrModel === "string")
|
|
47511
47552
|
return this.models.getAuth(providerOrModel, overrides);
|
|
@@ -55461,7 +55502,7 @@ async function createAgentSession(options = {}) {
|
|
|
55461
55502
|
return filtered;
|
|
55462
55503
|
};
|
|
55463
55504
|
const extensionRunnerRef = {};
|
|
55464
|
-
const isCodexFastModeEnabled = (requestModel) => shouldApplyCodexFastMode(requestModel, settingsManager.getCodexFastModeSettings(), options.orchestrationContext);
|
|
55505
|
+
const isCodexFastModeEnabled = (requestModel) => shouldApplyCodexFastMode(requestModel, settingsManager.getCodexFastModeSettings(), options.orchestrationContext, modelRuntime.getCredentialSnapshot("github-copilot"));
|
|
55465
55506
|
agent = new Agent2({
|
|
55466
55507
|
initialState: {
|
|
55467
55508
|
systemPrompt: "",
|
|
@@ -55497,7 +55538,7 @@ async function createAgentSession(options = {}) {
|
|
|
55497
55538
|
const extensionProvider = modelRuntime.getRegisteredProviderConfig(requestModel.provider);
|
|
55498
55539
|
const usesExtensionStream = extensionProvider?.streamSimple !== undefined && requestModel.api === extensionProvider.api;
|
|
55499
55540
|
const transportHeaders = usesExtensionStream ? assembledHeaders : removeUnownedModelHeaders(assembledHeaders, model2.headers, requestHeaders);
|
|
55500
|
-
if (fastModeEnabled && !usesExtensionStream && !authResult) {
|
|
55541
|
+
if (fastModeEnabled && !isGitHubCopilotModel(model2) && !usesExtensionStream && !authResult) {
|
|
55501
55542
|
throw new Error(`No API key found for "${model2.provider}"`);
|
|
55502
55543
|
}
|
|
55503
55544
|
const codexFastModeStreamOptions = withCodexFastModeStreamOptions(requestModel, {
|
|
@@ -55514,7 +55555,7 @@ async function createAgentSession(options = {}) {
|
|
|
55514
55555
|
if (usesExtensionStream) {
|
|
55515
55556
|
return modelRuntime.streamSimple(requestModel, context, codexFastModeStreamOptions);
|
|
55516
55557
|
}
|
|
55517
|
-
if (fastModeEnabled) {
|
|
55558
|
+
if (fastModeEnabled && !isGitHubCopilotModel(requestModel)) {
|
|
55518
55559
|
return streamWithCodexFastMode(requestModel, context, codexFastModeStreamOptions);
|
|
55519
55560
|
}
|
|
55520
55561
|
const transportOptions = usesChatGptCodexTransport(requestModel) && codexFastModeStreamOptions ? withChatGptCodexTransportRouting(requestModel, codexFastModeStreamOptions, false) : codexFastModeStreamOptions;
|
|
@@ -55522,7 +55563,7 @@ async function createAgentSession(options = {}) {
|
|
|
55522
55563
|
},
|
|
55523
55564
|
onPayload: async (payload, model2) => {
|
|
55524
55565
|
const fastModeEnabled = isCodexFastModeEnabled(model2);
|
|
55525
|
-
const guardedPayload = withCodexFastModePayload(payload, fastModeEnabled);
|
|
55566
|
+
const guardedPayload = withCodexFastModePayload(payload, fastModeEnabled, model2);
|
|
55526
55567
|
const sourceMessages = lastConvertedLlmMessages;
|
|
55527
55568
|
const replayGuardedPayload = sourceMessages ? restoreAnthropicReplayThinkingBlocks(guardedPayload, sourceMessages, model2) : guardedPayload;
|
|
55528
55569
|
const runner = extensionRunnerRef.current;
|
|
@@ -59987,6 +60028,31 @@ class RemoteQueuePause {
|
|
|
59987
60028
|
var init_remote_queue_pause = () => {};
|
|
59988
60029
|
|
|
59989
60030
|
// src/modes/interactive-engine/isolated-runtime.ts
|
|
60031
|
+
import { clampThinkingLevel as clampThinkingLevel5 } from "@bastani/pi-ai/compat";
|
|
60032
|
+
function applyPersistedModelDefault(session, model, alreadyInScope) {
|
|
60033
|
+
session.settingsManager.setDefaultModelAndProvider(model.provider, model.id);
|
|
60034
|
+
if (alreadyInScope || session.scopedModels.length === 0)
|
|
60035
|
+
return;
|
|
60036
|
+
const enabledModels = session.settingsManager.getEnabledModels();
|
|
60037
|
+
if (!enabledModels?.length)
|
|
60038
|
+
return;
|
|
60039
|
+
const modelReference = `${model.provider}/${model.id}`;
|
|
60040
|
+
if (enabledModels.some((pattern) => pattern.toLowerCase() === modelReference.toLowerCase()))
|
|
60041
|
+
return;
|
|
60042
|
+
session.settingsManager.setEnabledModels([...enabledModels, modelReference]);
|
|
60043
|
+
}
|
|
60044
|
+
function thinkingPersistTarget(result) {
|
|
60045
|
+
if (!result.provider || !result.modelId)
|
|
60046
|
+
return;
|
|
60047
|
+
return { provider: result.provider, modelId: result.modelId };
|
|
60048
|
+
}
|
|
60049
|
+
function applyPersistedThinkingDefault(session, level, target) {
|
|
60050
|
+
if (target) {
|
|
60051
|
+
session.settingsManager.setModelThinkingLevel(target.provider, target.modelId, level);
|
|
60052
|
+
return;
|
|
60053
|
+
}
|
|
60054
|
+
session.settingsManager.setDefaultThinkingLevel(level);
|
|
60055
|
+
}
|
|
59990
60056
|
var IsolatedInteractiveRuntime;
|
|
59991
60057
|
var init_isolated_runtime = __esm(() => {
|
|
59992
60058
|
init_agent_session_runtime();
|
|
@@ -60005,6 +60071,7 @@ var init_isolated_runtime = __esm(() => {
|
|
|
60005
60071
|
steeringMessages = [];
|
|
60006
60072
|
followUpMessages = [];
|
|
60007
60073
|
queueUpdateGeneration = 0;
|
|
60074
|
+
thinkingEpoch = 0;
|
|
60008
60075
|
pendingQueueClear;
|
|
60009
60076
|
engineCallbackActive = false;
|
|
60010
60077
|
queuePause;
|
|
@@ -60369,43 +60436,56 @@ var init_isolated_runtime = __esm(() => {
|
|
|
60369
60436
|
},
|
|
60370
60437
|
setModel: {
|
|
60371
60438
|
configurable: true,
|
|
60372
|
-
value: async (model) => {
|
|
60373
|
-
const selected = await this.client.setModel(model.provider, model.id);
|
|
60374
|
-
|
|
60439
|
+
value: async (model, options) => {
|
|
60440
|
+
const selected = await this.client.setModel(model.provider, model.id, options);
|
|
60441
|
+
const nextModel = session.modelRuntime.getModel(selected.provider, selected.id) ?? model;
|
|
60442
|
+
session.agent.state.model = nextModel;
|
|
60375
60443
|
this.resolveModelFallback();
|
|
60444
|
+
if (options?.persist === true)
|
|
60445
|
+
await this.syncPersistedModelCatalog(session, nextModel);
|
|
60376
60446
|
}
|
|
60377
60447
|
},
|
|
60378
60448
|
setThinkingLevel: {
|
|
60379
60449
|
configurable: true,
|
|
60380
|
-
value: (level) => {
|
|
60381
|
-
|
|
60382
|
-
|
|
60450
|
+
value: (level, options) => {
|
|
60451
|
+
const availableLevels = session.getAvailableThinkingLevels();
|
|
60452
|
+
const effectiveLevel = availableLevels.includes(level) ? level : session.model ? clampThinkingLevel5(session.model, level) : "off";
|
|
60453
|
+
session.agent.state.thinkingLevel = effectiveLevel;
|
|
60454
|
+
const epoch = ++this.thinkingEpoch;
|
|
60455
|
+
this.dispatchBestEffort("set thinking level", this.client.setThinkingLevelAck(level, options).then((result) => {
|
|
60456
|
+
this.applyThinkingAck(session, epoch, result, options?.persist === true);
|
|
60457
|
+
}));
|
|
60383
60458
|
}
|
|
60384
60459
|
},
|
|
60385
60460
|
cycleModel: {
|
|
60386
60461
|
configurable: true,
|
|
60387
|
-
value: async (direction) => {
|
|
60462
|
+
value: async (direction, options) => {
|
|
60388
60463
|
const previousModel = session.model;
|
|
60389
|
-
const result = await this.client.cycleModel(direction);
|
|
60464
|
+
const result = await this.client.cycleModel(direction, options);
|
|
60390
60465
|
if (!result)
|
|
60391
60466
|
return;
|
|
60392
60467
|
const model = session.modelRuntime.getModel(result.model.provider, result.model.id) ?? result.model;
|
|
60393
60468
|
session.agent.state.model = model;
|
|
60394
60469
|
session.agent.state.thinkingLevel = result.thinkingLevel;
|
|
60395
60470
|
this.resolveModelFallbackAfterExplicitModelSelection(previousModel, model);
|
|
60471
|
+
if (options?.persist === true)
|
|
60472
|
+
await this.syncPersistedModelCatalog(session, model);
|
|
60396
60473
|
return { ...result, model };
|
|
60397
60474
|
}
|
|
60398
60475
|
},
|
|
60399
60476
|
cycleThinkingLevel: {
|
|
60400
60477
|
configurable: true,
|
|
60401
|
-
value: () => {
|
|
60478
|
+
value: (options) => {
|
|
60402
60479
|
const levels = session.getAvailableThinkingLevels();
|
|
60403
60480
|
if (levels.length <= 1)
|
|
60404
60481
|
return;
|
|
60405
60482
|
const current = levels.indexOf(session.thinkingLevel);
|
|
60406
60483
|
const level = levels[(current + 1) % levels.length];
|
|
60407
60484
|
session.agent.state.thinkingLevel = level;
|
|
60408
|
-
|
|
60485
|
+
const epoch = ++this.thinkingEpoch;
|
|
60486
|
+
this.dispatchBestEffort("cycle thinking level", this.client.setThinkingLevelAck(level, options).then((result) => {
|
|
60487
|
+
this.applyThinkingAck(session, epoch, result, options?.persist === true);
|
|
60488
|
+
}));
|
|
60409
60489
|
return level;
|
|
60410
60490
|
}
|
|
60411
60491
|
},
|
|
@@ -60449,6 +60529,14 @@ var init_isolated_runtime = __esm(() => {
|
|
|
60449
60529
|
this.engineCallbackActive = false;
|
|
60450
60530
|
}
|
|
60451
60531
|
}
|
|
60532
|
+
applyThinkingAck(session, epoch, result, persist) {
|
|
60533
|
+
if (persist) {
|
|
60534
|
+
applyPersistedThinkingDefault(session, result.level, thinkingPersistTarget(result));
|
|
60535
|
+
}
|
|
60536
|
+
if (epoch === this.thinkingEpoch) {
|
|
60537
|
+
session.agent.state.thinkingLevel = result.level;
|
|
60538
|
+
}
|
|
60539
|
+
}
|
|
60452
60540
|
dispatchBestEffort(label, operation) {
|
|
60453
60541
|
operation.catch((error) => {
|
|
60454
60542
|
if (this.health.isRecovering())
|
|
@@ -60489,6 +60577,12 @@ var init_isolated_runtime = __esm(() => {
|
|
|
60489
60577
|
}
|
|
60490
60578
|
});
|
|
60491
60579
|
}
|
|
60580
|
+
async syncPersistedModelCatalog(session, model) {
|
|
60581
|
+
const alreadyInScope = session.scopedModels.some((scoped) => scoped.model.provider === model.provider && scoped.model.id === model.id);
|
|
60582
|
+
const catalog = await this.client.requestInternal({ type: "get_available_models" });
|
|
60583
|
+
this.remoteModelCatalog.apply(catalog);
|
|
60584
|
+
applyPersistedModelDefault(session, model, alreadyInScope);
|
|
60585
|
+
}
|
|
60492
60586
|
refreshSessionView() {
|
|
60493
60587
|
const session = super.session;
|
|
60494
60588
|
const sessionFile = session.sessionFile;
|
|
@@ -60528,6 +60622,7 @@ var init_isolated_runtime = __esm(() => {
|
|
|
60528
60622
|
session.agent.state.model = event.model;
|
|
60529
60623
|
break;
|
|
60530
60624
|
case "thinking_level_changed":
|
|
60625
|
+
this.thinkingEpoch += 1;
|
|
60531
60626
|
session.agent.state.thinkingLevel = event.level;
|
|
60532
60627
|
break;
|
|
60533
60628
|
case "session_info_changed":
|
|
@@ -61741,7 +61836,7 @@ var init_slash_commands = __esm(() => {
|
|
|
61741
61836
|
{ name: "tree", description: "Navigate session tree (switch branches)" },
|
|
61742
61837
|
{ name: "thinking", description: "Set thinking level", argumentHint: "<level>" },
|
|
61743
61838
|
{ name: "scoped-models", description: "Enable/disable models for ctrl+p cycling" },
|
|
61744
|
-
{ name: "fast", description: "Configure
|
|
61839
|
+
{ name: "fast", description: "Configure OpenAI fast mode for chat and workflows in supported models" },
|
|
61745
61840
|
{ name: "export", description: "Export session (HTML default, or specify path: .html/.jsonl)" },
|
|
61746
61841
|
{ name: "import", description: "Import and resume a session from a JSONL file" },
|
|
61747
61842
|
{ name: "share", description: "Share session as a secret GitHub gist" },
|
|
@@ -63203,7 +63298,7 @@ var init_interactive_autocomplete = __esm(() => {
|
|
|
63203
63298
|
return [...this.session.modelRuntime.getAvailableSnapshot()];
|
|
63204
63299
|
};
|
|
63205
63300
|
InteractiveModeBase.prototype.hasCodexFastModeSupportedModels = function() {
|
|
63206
|
-
return hasSupportedCodexFastModeModel(this.getCodexFastModeCandidateModels());
|
|
63301
|
+
return hasSupportedCodexFastModeModel(this.getCodexFastModeCandidateModels(), this.session.modelRuntime.getCredentialSnapshot?.("github-copilot"));
|
|
63207
63302
|
};
|
|
63208
63303
|
InteractiveModeBase.prototype.buildRemoteSlashCommands = function(localCommands) {
|
|
63209
63304
|
const remote = getInteractiveEngineRemoteCommands(this.runtimeHost);
|
|
@@ -63891,7 +63986,7 @@ var init_interactive_startup = __esm(() => {
|
|
|
63891
63986
|
if (!model) {
|
|
63892
63987
|
return modelLabel2;
|
|
63893
63988
|
}
|
|
63894
|
-
const fastModeEnabled = shouldApplyCodexFastMode(model, this.session.settingsManager.getCodexFastModeSettings(), this.session.orchestrationContext);
|
|
63989
|
+
const fastModeEnabled = shouldApplyCodexFastMode(model, this.session.settingsManager.getCodexFastModeSettings(), this.session.orchestrationContext, this.session.modelRuntime.getCredentialSnapshot?.("github-copilot"));
|
|
63895
63990
|
return formatCodexFastModeModelLabel(modelLabel2, fastModeEnabled);
|
|
63896
63991
|
};
|
|
63897
63992
|
InteractiveModeBase.prototype.getStartupIdentityText = function(maxWidth, gap = 0, manifestoPhase = 4) {
|
|
@@ -68406,7 +68501,7 @@ var init_interactive_selectors = __esm(() => {
|
|
|
68406
68501
|
});
|
|
68407
68502
|
|
|
68408
68503
|
// src/modes/interactive/interactive-model-routing.ts
|
|
68409
|
-
import { clampThinkingLevel as
|
|
68504
|
+
import { clampThinkingLevel as clampThinkingLevel6 } from "@bastani/pi-ai/compat";
|
|
68410
68505
|
function resolveThinkingSelectorDefault(rawDefault, availableLevels, model) {
|
|
68411
68506
|
if (rawDefault === undefined)
|
|
68412
68507
|
return;
|
|
@@ -68414,7 +68509,7 @@ function resolveThinkingSelectorDefault(rawDefault, availableLevels, model) {
|
|
|
68414
68509
|
return rawDefault;
|
|
68415
68510
|
if (!model)
|
|
68416
68511
|
return availableLevels.includes("off") ? "off" : availableLevels[0];
|
|
68417
|
-
const clamped =
|
|
68512
|
+
const clamped = clampThinkingLevel6(model, rawDefault);
|
|
68418
68513
|
if (availableLevels.includes(clamped))
|
|
68419
68514
|
return clamped;
|
|
68420
68515
|
return availableLevels.includes("off") ? "off" : availableLevels[0];
|
|
@@ -70778,11 +70873,20 @@ class RpcClientApi {
|
|
|
70778
70873
|
async getState() {
|
|
70779
70874
|
return this.data(await this.request({ type: "get_state" }));
|
|
70780
70875
|
}
|
|
70781
|
-
async setModel(provider, modelId) {
|
|
70782
|
-
return this.data(await this.request({
|
|
70876
|
+
async setModel(provider, modelId, options) {
|
|
70877
|
+
return this.data(await this.request({
|
|
70878
|
+
type: "set_model",
|
|
70879
|
+
provider,
|
|
70880
|
+
modelId,
|
|
70881
|
+
...options?.persist === true ? { persist: true } : {}
|
|
70882
|
+
}));
|
|
70783
70883
|
}
|
|
70784
|
-
async cycleModel(direction) {
|
|
70785
|
-
return this.data(await this.request({
|
|
70884
|
+
async cycleModel(direction, options) {
|
|
70885
|
+
return this.data(await this.request({
|
|
70886
|
+
type: "cycle_model",
|
|
70887
|
+
direction,
|
|
70888
|
+
...options?.persist === true ? { persist: true } : {}
|
|
70889
|
+
}));
|
|
70786
70890
|
}
|
|
70787
70891
|
async getAvailableModels() {
|
|
70788
70892
|
return this.data(await this.request({ type: "get_available_models" })).models;
|
|
@@ -70816,6 +70920,20 @@ class RpcClientApi {
|
|
|
70816
70920
|
async setThinkingLevel(level) {
|
|
70817
70921
|
await this.request({ type: "set_thinking_level", level });
|
|
70818
70922
|
}
|
|
70923
|
+
async setThinkingLevelAck(level, options) {
|
|
70924
|
+
const response = await this.request({
|
|
70925
|
+
type: "set_thinking_level",
|
|
70926
|
+
level,
|
|
70927
|
+
...options?.persist === true ? { persist: true } : {}
|
|
70928
|
+
});
|
|
70929
|
+
if (!response.success) {
|
|
70930
|
+
return this.data(response);
|
|
70931
|
+
}
|
|
70932
|
+
if (response.command === "set_thinking_level" && "data" in response && response.data) {
|
|
70933
|
+
return response.data;
|
|
70934
|
+
}
|
|
70935
|
+
return { level };
|
|
70936
|
+
}
|
|
70819
70937
|
async cycleThinkingLevel() {
|
|
70820
70938
|
return this.data(await this.request({ type: "cycle_thinking_level" }));
|
|
70821
70939
|
}
|
|
@@ -72834,13 +72952,13 @@ function createRpcCommandHandler({
|
|
|
72834
72952
|
if (!model) {
|
|
72835
72953
|
return createRpcErrorResponse(id, "set_model", `Model not found: ${command.provider}/${command.modelId}`);
|
|
72836
72954
|
}
|
|
72837
|
-
await session.setModel(model);
|
|
72955
|
+
await session.setModel(model, command.persist === true ? { persist: true } : {});
|
|
72838
72956
|
runtimeHost.resolveModelFallback();
|
|
72839
72957
|
return createRpcSuccessResponse(id, "set_model", session.model ?? model);
|
|
72840
72958
|
}
|
|
72841
72959
|
case "cycle_model": {
|
|
72842
72960
|
const previousModel = session.model;
|
|
72843
|
-
const result = await session.cycleModel(command.direction);
|
|
72961
|
+
const result = await session.cycleModel(command.direction, command.persist === true ? { persist: true } : {});
|
|
72844
72962
|
runtimeHost.resolveModelFallbackAfterExplicitModelSelection(previousModel, result?.model);
|
|
72845
72963
|
return createRpcSuccessResponse(id, "cycle_model", result ?? null);
|
|
72846
72964
|
}
|
|
@@ -72903,8 +73021,12 @@ function createRpcCommandHandler({
|
|
|
72903
73021
|
}
|
|
72904
73022
|
}
|
|
72905
73023
|
case "set_thinking_level": {
|
|
72906
|
-
session.setThinkingLevel(command.level);
|
|
72907
|
-
|
|
73024
|
+
session.setThinkingLevel(command.level, command.persist === true ? { persist: true } : {});
|
|
73025
|
+
const model = session.model;
|
|
73026
|
+
return createRpcSuccessResponse(id, "set_thinking_level", {
|
|
73027
|
+
level: session.thinkingLevel,
|
|
73028
|
+
...model ? { provider: model.provider, modelId: model.id } : {}
|
|
73029
|
+
});
|
|
72908
73030
|
}
|
|
72909
73031
|
case "cycle_thinking_level": {
|
|
72910
73032
|
const level = session.cycleThinkingLevel();
|