@herbertgao/pi-extensions 2026.9.10 → 2026.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/node_modules/@herbertgao/pi-bark/package.json +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -2
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +2 -2
- package/node_modules/@herbertgao/resume-from/package.json +1 -1
- package/node_modules/@herbertgao/sol-pi/README.md +3 -3
- package/node_modules/@herbertgao/sol-pi/THIRD_PARTY_NOTICES.md +4 -4
- package/node_modules/@herbertgao/sol-pi/agents-install.md +4 -4
- package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +6 -6
- package/node_modules/@herbertgao/sol-pi/package.json +2 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/dist/index.ts +39 -89
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/btw.ts +28 -87
- package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +8 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +40 -37
- package/node_modules/@narumitw/pi-caffeinate/README.md +21 -66
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +10 -41
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-caffeinate/package.json +50 -51
- package/node_modules/@narumitw/pi-caffeinate/src/caffeinate.ts +637 -663
- package/node_modules/@narumitw/pi-caffeinate/src/dbus-inhibit.ts +114 -120
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +29 -29
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitors.ts +108 -126
- package/node_modules/@narumitw/pi-caffeinate/src/settings.ts +124 -128
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +62 -0
- package/node_modules/pi-mcp-adapter/README.md +75 -7
- package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +193 -0
- package/node_modules/pi-mcp-adapter/cli.js +56 -5
- package/node_modules/pi-mcp-adapter/commands.ts +96 -5
- package/node_modules/pi-mcp-adapter/config.ts +73 -6
- package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +22 -28
- package/node_modules/pi-mcp-adapter/direct-tools.ts +13 -5
- package/node_modules/pi-mcp-adapter/dist/abort.d.ts +2 -0
- package/node_modules/pi-mcp-adapter/dist/abort.js +36 -0
- package/node_modules/pi-mcp-adapter/dist/abort.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +194 -0
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.d.ts +5 -0
- package/node_modules/pi-mcp-adapter/dist/config.js +75 -6
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +18 -0
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js +88 -0
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +316 -0
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/errors.d.ts +131 -0
- package/node_modules/pi-mcp-adapter/dist/errors.js +278 -0
- package/node_modules/pi-mcp-adapter/dist/errors.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +8 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.js +88 -0
- package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +15 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.js +340 -0
- package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +77 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +2 -0
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +22 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +85 -0
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +2 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +55 -0
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +56 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js +410 -0
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/logger.d.ts +51 -0
- package/node_modules/pi-mcp-adapter/dist/logger.js +131 -0
- package/node_modules/pi-mcp-adapter/dist/logger.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +26 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +103 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +118 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +1098 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +168 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +1117 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +7 -140
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +53 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +441 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +148 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +689 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +166 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +102 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +369 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +95 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +242 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +2 -11
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +505 -0
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +10 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +312 -0
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +13 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +97 -0
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +203 -0
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +11 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +172 -0
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +157 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.js +1743 -0
- package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +34 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js +140 -0
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +26 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js +142 -0
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/state.d.ts +73 -0
- package/node_modules/pi-mcp-adapter/dist/state.js +2 -0
- package/node_modules/pi-mcp-adapter/dist/state.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +36 -0
- package/node_modules/pi-mcp-adapter/dist/types.js +18 -0
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +17 -0
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +219 -0
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +15 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +85 -0
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/utils.d.ts +1 -0
- package/node_modules/pi-mcp-adapter/dist/utils.js +13 -0
- package/node_modules/pi-mcp-adapter/dist/utils.js.map +1 -1
- package/node_modules/pi-mcp-adapter/elicitation-handler.ts +29 -19
- package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +85 -0
- package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +34 -0
- package/node_modules/pi-mcp-adapter/index.ts +129 -6
- package/node_modules/pi-mcp-adapter/init.ts +6 -19
- package/node_modules/pi-mcp-adapter/jev-client.ts +273 -0
- package/node_modules/pi-mcp-adapter/jev-contracts.ts +53 -0
- package/node_modules/pi-mcp-adapter/jev-key-store.ts +79 -0
- package/node_modules/pi-mcp-adapter/lifecycle.ts +14 -3
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +7 -142
- package/node_modules/pi-mcp-adapter/mcp-code.ts +119 -11
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +4 -0
- package/node_modules/pi-mcp-adapter/mcp-references.ts +5 -3
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +5 -0
- package/node_modules/pi-mcp-adapter/mcp-tasks.ts +467 -0
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +2 -13
- package/node_modules/pi-mcp-adapter/namespace-tools.ts +1 -1
- package/node_modules/pi-mcp-adapter/package.json +17 -9
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +319 -166
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +6 -3
- package/node_modules/pi-mcp-adapter/search-ranking.ts +38 -7
- package/node_modules/pi-mcp-adapter/secure-keyring.ts +170 -0
- package/node_modules/pi-mcp-adapter/semantic-search.ts +186 -0
- package/node_modules/pi-mcp-adapter/server-manager.ts +293 -50
- package/node_modules/pi-mcp-adapter/session-approvals.ts +14 -0
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +2 -0
- package/node_modules/pi-mcp-adapter/state.ts +3 -1
- package/node_modules/pi-mcp-adapter/tool-approval.ts +26 -4
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +6 -14
- package/node_modules/pi-mcp-adapter/tool-registrar.ts +8 -6
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +4 -1
- package/node_modules/pi-mcp-adapter/types.ts +53 -0
- package/node_modules/pi-mcp-adapter/ui-server.ts +17 -9
- package/node_modules/pi-mcp-adapter/utils.ts +16 -0
- package/node_modules/pi-multi-account/CHANGELOG.md +1209 -0
- package/node_modules/pi-multi-account/CONTRIBUTING.md +61 -0
- package/node_modules/pi-multi-account/LICENSE +21 -0
- package/node_modules/pi-multi-account/README.md +197 -0
- package/node_modules/pi-multi-account/SECURITY.md +27 -0
- package/node_modules/pi-multi-account/auth-file-transaction.ts +56 -0
- package/node_modules/pi-multi-account/child-usability.ts +233 -0
- package/node_modules/pi-multi-account/compaction-summary.ts +32 -0
- package/node_modules/pi-multi-account/completion-route-planner.ts +224 -0
- package/node_modules/pi-multi-account/context-guard.ts +420 -0
- package/node_modules/pi-multi-account/cursor/LICENSE +21 -0
- package/node_modules/pi-multi-account/cursor/NOTICE +2 -0
- package/node_modules/pi-multi-account/cursor/auth.ts +165 -0
- package/node_modules/pi-multi-account/cursor/bridge-handle.ts +155 -0
- package/node_modules/pi-multi-account/cursor/conversation-registry.ts +104 -0
- package/node_modules/pi-multi-account/cursor/cursor-models-raw.json +611 -0
- package/node_modules/pi-multi-account/cursor/cursor-shared.ts +192 -0
- package/node_modules/pi-multi-account/cursor/h2-bridge.mjs +175 -0
- package/node_modules/pi-multi-account/cursor/index.ts +572 -0
- package/node_modules/pi-multi-account/cursor/message-parsing.ts +323 -0
- package/node_modules/pi-multi-account/cursor/prompt-usage.ts +53 -0
- package/node_modules/pi-multi-account/cursor/proto/agent_pb.ts +15294 -0
- package/node_modules/pi-multi-account/cursor/proxy.ts +2510 -0
- package/node_modules/pi-multi-account/cursor/session-lifecycle.ts +40 -0
- package/node_modules/pi-multi-account/cursor/sse-keepalive.ts +24 -0
- package/node_modules/pi-multi-account/cursor/stream-lifecycle.ts +193 -0
- package/node_modules/pi-multi-account/cursor/upstream-watchdog.ts +88 -0
- package/node_modules/pi-multi-account/cursor-bridge.ts +240 -0
- package/node_modules/pi-multi-account/cursor-model-name.ts +12 -0
- package/node_modules/pi-multi-account/index.ts +11825 -0
- package/node_modules/pi-multi-account/model-catalog.ts +354 -0
- package/node_modules/pi-multi-account/package.json +101 -0
- package/node_modules/pi-multi-account/pi-contract.ts +281 -0
- package/node_modules/pi-multi-account/provider-payload-stream.ts +44 -0
- package/node_modules/pi-multi-account/provider-priority.ts +189 -0
- package/node_modules/pi-multi-account/slot-proxy-auth.ts +167 -0
- package/node_modules/pi-multi-account/slot-proxy.ts +344 -0
- package/node_modules/pi-multi-account/state-file-transaction.ts +67 -0
- package/node_modules/pi-multi-account/usage.ts +1099 -0
- package/node_modules/pi-typesafe/README.md +6 -2
- package/node_modules/pi-typesafe/dist/client.d.ts +11 -0
- package/node_modules/pi-typesafe/dist/client.js +45 -10
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/package.json +2 -2
- package/node_modules/pi-web-access/CHANGELOG.md +36 -0
- package/node_modules/pi-web-access/README.md +75 -18
- package/node_modules/pi-web-access/anysearch.ts +4 -15
- package/node_modules/pi-web-access/bocha.ts +3 -22
- package/node_modules/pi-web-access/brave.ts +3 -21
- package/node_modules/pi-web-access/brightdata.ts +5 -32
- package/node_modules/pi-web-access/content-find.ts +168 -53
- package/node_modules/pi-web-access/curator-page.ts +4 -1
- package/node_modules/pi-web-access/curator-run.ts +2 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/dist/index.js +24620 -0
- package/node_modules/pi-web-access/domain-filter-normalization.ts +14 -0
- package/node_modules/pi-web-access/duckduckgo.ts +3 -21
- package/node_modules/pi-web-access/extract.ts +3 -1
- package/node_modules/pi-web-access/firecrawl.ts +5 -29
- package/node_modules/pi-web-access/gemini-search.ts +81 -32
- package/node_modules/pi-web-access/index.ts +149 -148
- package/node_modules/pi-web-access/jina-search.ts +4 -15
- package/node_modules/pi-web-access/kagi.ts +4 -13
- package/node_modules/pi-web-access/kimi-search.ts +5 -30
- package/node_modules/pi-web-access/mistral-search.ts +1 -15
- package/node_modules/pi-web-access/ollama.ts +2 -7
- package/node_modules/pi-web-access/openai-search.ts +174 -36
- package/node_modules/pi-web-access/opencode-session-headers.ts +24 -0
- package/node_modules/pi-web-access/package.json +10 -4
- package/node_modules/pi-web-access/page-query.ts +10 -2
- package/node_modules/pi-web-access/parallel.ts +1 -15
- package/node_modules/pi-web-access/pdf-extract.ts +3 -0
- package/node_modules/pi-web-access/querit.ts +5 -29
- package/node_modules/pi-web-access/search-answer-formatting.ts +11 -0
- package/node_modules/pi-web-access/search-result-count-normalization.ts +4 -0
- package/node_modules/pi-web-access/search1api.ts +5 -29
- package/node_modules/pi-web-access/searchinfinity.ts +5 -29
- package/node_modules/pi-web-access/searxng.ts +3 -21
- package/node_modules/pi-web-access/serpapi.ts +5 -28
- package/node_modules/pi-web-access/serpbase.ts +3 -22
- package/node_modules/pi-web-access/serpdive.ts +3 -21
- package/node_modules/pi-web-access/serper.ts +5 -28
- package/node_modules/pi-web-access/serply.ts +197 -0
- package/node_modules/pi-web-access/source-check.ts +11 -47
- package/node_modules/pi-web-access/summary-review.ts +7 -3
- package/node_modules/pi-web-access/tavily.ts +3 -21
- package/node_modules/pi-web-access/tinyfish.ts +5 -29
- package/node_modules/pi-web-access/utils.ts +9 -1
- package/node_modules/pi-web-access/valyu.ts +5 -28
- package/node_modules/pi-web-access/xai-search.ts +1 -15
- package/node_modules/pi-web-access/xcrawl.ts +5 -32
- package/package.json +23 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-btw",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.3",
|
|
4
4
|
"description": "Pi extension that adds a /btw side-question command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@earendil-works/pi-ai": "0.
|
|
36
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
37
|
-
"@earendil-works/pi-tui": "0.
|
|
35
|
+
"@earendil-works/pi-ai": "0.86.0",
|
|
36
|
+
"@earendil-works/pi-coding-agent": "0.86.0",
|
|
37
|
+
"@earendil-works/pi-tui": "0.86.0",
|
|
38
38
|
"esbuild": "0.28.2",
|
|
39
39
|
"typescript": "7.0.2"
|
|
40
40
|
},
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
clampThinkingLevel,
|
|
4
|
-
getSupportedThinkingLevels,
|
|
5
|
-
type Model,
|
|
6
|
-
type ProviderHeaders,
|
|
7
|
-
} from "@earendil-works/pi-ai";
|
|
8
|
-
import { BorderedLoader, type ExtensionAPI, type ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { type Api, clampThinkingLevel, getSupportedThinkingLevels, type Model } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
9
3
|
import type { MenuContext, RunMenuResult } from "@narumitw/pi-tui-kit";
|
|
10
4
|
import {
|
|
11
5
|
type BtwBringToMainSegment,
|
|
@@ -76,16 +70,15 @@ interface LoadBtwThinkingLevelOptions {
|
|
|
76
70
|
warn?: (message: string) => void;
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
type BtwModelRegistry = Pick<ExtensionCommandContext["modelRegistry"], "find" | "
|
|
73
|
+
type BtwModelRegistry = Pick<ExtensionCommandContext["modelRegistry"], "find" | "getAvailable">;
|
|
80
74
|
|
|
81
|
-
type
|
|
75
|
+
type BtwCompletionRegistry = Pick<ExtensionCommandContext["modelRegistry"], "streamSimple">;
|
|
82
76
|
|
|
83
|
-
export function createModelRegistryCompleteSimple(modelRegistry:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
77
|
+
export function createModelRegistryCompleteSimple(modelRegistry: BtwCompletionRegistry): CompleteSimpleFunction {
|
|
78
|
+
const completeSimple: CompleteSimpleFunction = async (model, context, options) =>
|
|
79
|
+
modelRegistry.streamSimple(model, context, options).result();
|
|
80
|
+
completeSimple.appliesRequestHeaderTransforms = true;
|
|
81
|
+
return completeSimple;
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
interface ResolveBtwModelOptions {
|
|
@@ -97,7 +90,8 @@ interface ResolveBtwModelOptions {
|
|
|
97
90
|
|
|
98
91
|
export interface ResolvedBtwModel {
|
|
99
92
|
model: Model<Api>;
|
|
100
|
-
|
|
93
|
+
/** @deprecated Pi resolves request authentication through modelRegistry.streamSimple(). */
|
|
94
|
+
auth?: SideQuestionAuth;
|
|
101
95
|
}
|
|
102
96
|
|
|
103
97
|
export interface BtwThreadState {
|
|
@@ -116,6 +110,10 @@ export async function resolveBtwModel({
|
|
|
116
110
|
warn,
|
|
117
111
|
}: ResolveBtwModelOptions): Promise<ResolvedBtwModel | undefined> {
|
|
118
112
|
const reportWarning = (message: string) => warn?.(sanitizeSingleLine(message));
|
|
113
|
+
const availableModels = modelRegistry.getAvailable();
|
|
114
|
+
const isAvailable = (model: Model<Api>): boolean =>
|
|
115
|
+
availableModels.some((candidate) => candidate.provider === model.provider && candidate.id === model.id);
|
|
116
|
+
|
|
119
117
|
if (settings.model) {
|
|
120
118
|
const fallback = currentModel ? `${currentModel.provider}/${currentModel.id}` : "the current model";
|
|
121
119
|
const reference = parseBtwModelReference(settings.model);
|
|
@@ -126,52 +124,19 @@ export async function resolveBtwModel({
|
|
|
126
124
|
const configuredModel = modelRegistry.find(reference.provider, reference.modelId);
|
|
127
125
|
if (!configuredModel) {
|
|
128
126
|
reportWarning(`pi-btw model ${settings.model} was not found; falling back to ${fallback}.`);
|
|
127
|
+
} else if (isAvailable(configuredModel)) {
|
|
128
|
+
return { model: configuredModel };
|
|
129
129
|
} else {
|
|
130
130
|
const sameAsCurrent =
|
|
131
131
|
configuredModel === currentModel ||
|
|
132
132
|
(configuredModel.provider === currentModel?.provider && configuredModel.id === currentModel.id);
|
|
133
133
|
const fallbackAction = sameAsCurrent ? "no distinct current model is available" : `falling back to ${fallback}`;
|
|
134
|
-
|
|
135
|
-
const auth = await modelRegistry.getApiKeyAndHeaders(configuredModel);
|
|
136
|
-
if (auth.ok && hasRequestAuth(auth)) {
|
|
137
|
-
return {
|
|
138
|
-
model: auth.baseUrl ? { ...configuredModel, baseUrl: auth.baseUrl } : configuredModel,
|
|
139
|
-
auth,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const reason = auth.ok ? "has no request credentials" : auth.error;
|
|
143
|
-
reportWarning(`pi-btw model ${settings.model} is unavailable (${reason}); ${fallbackAction}.`);
|
|
144
|
-
} catch (error: unknown) {
|
|
145
|
-
reportWarning(`pi-btw model ${settings.model} credentials failed (${formatError(error)}); ${fallbackAction}.`);
|
|
146
|
-
}
|
|
134
|
+
reportWarning(`pi-btw model ${settings.model} is unavailable; ${fallbackAction}.`);
|
|
147
135
|
if (sameAsCurrent) return undefined;
|
|
148
136
|
}
|
|
149
137
|
}
|
|
150
138
|
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
const auth = await modelRegistry.getApiKeyAndHeaders(currentModel);
|
|
154
|
-
if (auth.ok && hasRequestAuth(auth)) {
|
|
155
|
-
// Direct provider streams bypass Pi's request preparation, including OAuth routing.
|
|
156
|
-
return {
|
|
157
|
-
model: auth.baseUrl ? { ...currentModel, baseUrl: auth.baseUrl } : currentModel,
|
|
158
|
-
auth,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
} catch {
|
|
162
|
-
// The caller reports the final lack of an available model.
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function hasRequestAuth(auth: SideQuestionAuth): boolean {
|
|
168
|
-
return Boolean(
|
|
169
|
-
auth.apiKey || providerHeadersHaveValue(auth.headers) || (auth.env && Object.keys(auth.env).length > 0),
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function providerHeadersHaveValue(headers: ProviderHeaders | undefined): boolean {
|
|
174
|
-
return headers !== undefined && Object.values(headers).some((value) => value !== null);
|
|
139
|
+
return currentModel && isAvailable(currentModel) ? { model: currentModel } : undefined;
|
|
175
140
|
}
|
|
176
141
|
|
|
177
142
|
export async function loadBtwThinkingLevel(
|
|
@@ -226,7 +191,7 @@ export interface BtwExtensionDependencies {
|
|
|
226
191
|
) => Promise<BtwCommandMenuResult>;
|
|
227
192
|
pickMainEntry?: typeof pickMainEntry;
|
|
228
193
|
loadSettings?: typeof loadSettingsForCommand;
|
|
229
|
-
resolveModel?: typeof
|
|
194
|
+
resolveModel?: typeof resolveBtwModelForCommand;
|
|
230
195
|
runThread?: typeof runBtwThread;
|
|
231
196
|
runFullscreen?: RunBtwFullscreen;
|
|
232
197
|
}
|
|
@@ -235,7 +200,7 @@ export default function btw(pi: ExtensionAPI, dependencies: BtwExtensionDependen
|
|
|
235
200
|
const showCommandMenu = dependencies.showCommandMenu ?? showCommandMenuForBtw;
|
|
236
201
|
const pickEntry = dependencies.pickMainEntry ?? pickMainEntry;
|
|
237
202
|
const loadSettings = dependencies.loadSettings ?? loadSettingsForCommand;
|
|
238
|
-
const resolveModel = dependencies.resolveModel ??
|
|
203
|
+
const resolveModel = dependencies.resolveModel ?? resolveBtwModelForCommand;
|
|
239
204
|
const runThread = dependencies.runThread ?? runBtwThread;
|
|
240
205
|
const runFullscreen = dependencies.runFullscreen ?? runBtwFullscreen;
|
|
241
206
|
// Pi creates a fresh extension instance after session replacement or reload.
|
|
@@ -377,40 +342,17 @@ type ModelResolutionOutcome =
|
|
|
377
342
|
| { kind: "unavailable" }
|
|
378
343
|
| { kind: "selected"; selected: ResolvedBtwModel };
|
|
379
344
|
|
|
380
|
-
async function
|
|
345
|
+
async function resolveBtwModelForCommand(
|
|
381
346
|
settings: BtwSettings,
|
|
382
347
|
ctx: ExtensionCommandContext,
|
|
383
348
|
): Promise<ModelResolutionOutcome> {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
settled = true;
|
|
390
|
-
done({ kind: "cancelled" });
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
resolveBtwModel({
|
|
394
|
-
settings,
|
|
395
|
-
currentModel: ctx.model,
|
|
396
|
-
modelRegistry: ctx.modelRegistry,
|
|
397
|
-
warn: (message) => {
|
|
398
|
-
if (!settled) notifySafely(ctx, message, "warning");
|
|
399
|
-
},
|
|
400
|
-
})
|
|
401
|
-
.then((selected) => {
|
|
402
|
-
if (settled) return;
|
|
403
|
-
settled = true;
|
|
404
|
-
done(selected ? { kind: "selected", selected } : { kind: "unavailable" });
|
|
405
|
-
})
|
|
406
|
-
.catch(() => {
|
|
407
|
-
if (settled) return;
|
|
408
|
-
settled = true;
|
|
409
|
-
done({ kind: "unavailable" });
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
return loader;
|
|
349
|
+
const selected = await resolveBtwModel({
|
|
350
|
+
settings,
|
|
351
|
+
currentModel: ctx.model,
|
|
352
|
+
modelRegistry: ctx.modelRegistry,
|
|
353
|
+
warn: (message) => notifySafely(ctx, message, "warning"),
|
|
413
354
|
});
|
|
355
|
+
return selected ? { kind: "selected", selected } : { kind: "unavailable" };
|
|
414
356
|
}
|
|
415
357
|
|
|
416
358
|
interface RunBtwThreadDependencies {
|
|
@@ -863,7 +805,6 @@ async function askThreadQuestion(
|
|
|
863
805
|
question,
|
|
864
806
|
model: selected.model,
|
|
865
807
|
thinkingLevel,
|
|
866
|
-
auth: selected.auth,
|
|
867
808
|
signal: view.signal,
|
|
868
809
|
completeSimple: createModelRegistryCompleteSimple(ctx.modelRegistry),
|
|
869
810
|
sessionId: readBtwSessionId(ctx),
|
|
@@ -255,6 +255,14 @@ function sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {
|
|
|
255
255
|
...entry,
|
|
256
256
|
name: entry.name === undefined ? undefined : sanitizeSingleLine(entry.name),
|
|
257
257
|
};
|
|
258
|
+
case "usage":
|
|
259
|
+
return {
|
|
260
|
+
...entry,
|
|
261
|
+
kind: sanitizeSingleLine(entry.kind),
|
|
262
|
+
provider: sanitizeSingleLine(entry.provider),
|
|
263
|
+
model: sanitizeSingleLine(entry.model),
|
|
264
|
+
note: entry.note === undefined ? undefined : sanitizeSingleLine(entry.note),
|
|
265
|
+
};
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
Context,
|
|
5
5
|
Message,
|
|
6
6
|
Model,
|
|
7
|
+
ModelsSimpleStreamOptions,
|
|
7
8
|
ProviderHeaders,
|
|
8
|
-
SimpleStreamOptions,
|
|
9
9
|
UserMessage,
|
|
10
10
|
} from "@earendil-works/pi-ai";
|
|
11
11
|
|
|
@@ -19,11 +19,15 @@ export interface SideQuestionAuth {
|
|
|
19
19
|
env?: Record<string, string>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
export interface CompleteSimpleFunction {
|
|
23
|
+
<TApi extends Api>(
|
|
24
|
+
model: Model<TApi>,
|
|
25
|
+
context: Context,
|
|
26
|
+
options?: ModelsSimpleStreamOptions,
|
|
27
|
+
): Promise<AssistantMessage>;
|
|
28
|
+
/** True when the callback applies Models-only header transforms after request-time authentication. */
|
|
29
|
+
appliesRequestHeaderTransforms?: boolean;
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
export type SideThreadTurn =
|
|
29
33
|
| {
|
|
@@ -72,7 +76,7 @@ export interface CompleteSideThreadTurnOptions {
|
|
|
72
76
|
model: Model<Api>;
|
|
73
77
|
question: string;
|
|
74
78
|
thinkingLevel: BtwThinkingLevel;
|
|
75
|
-
auth
|
|
79
|
+
auth?: SideQuestionAuth;
|
|
76
80
|
signal?: AbortSignal;
|
|
77
81
|
completeSimple: CompleteSimpleFunction;
|
|
78
82
|
sessionId?: string;
|
|
@@ -98,7 +102,11 @@ export async function completeSideThreadTurn({
|
|
|
98
102
|
const response = await completeSimple(
|
|
99
103
|
model,
|
|
100
104
|
{ systemPrompt: SYSTEM_PROMPT, messages: buildSideThreadMessages(thread, question) },
|
|
101
|
-
buildStreamOptions(
|
|
105
|
+
buildStreamOptions(
|
|
106
|
+
auth,
|
|
107
|
+
{ thinkingLevel, signal, model, sessionId },
|
|
108
|
+
completeSimple.appliesRequestHeaderTransforms === true,
|
|
109
|
+
),
|
|
102
110
|
);
|
|
103
111
|
if (signal?.aborted || response?.stopReason === "aborted") return { kind: "aborted" };
|
|
104
112
|
if (!isAssistantMessage(response)) {
|
|
@@ -125,7 +133,7 @@ export interface CompleteSideQuestionOptions {
|
|
|
125
133
|
question: string;
|
|
126
134
|
conversationContext: string;
|
|
127
135
|
thinkingLevel: BtwThinkingLevel;
|
|
128
|
-
auth
|
|
136
|
+
auth?: SideQuestionAuth;
|
|
129
137
|
signal?: AbortSignal;
|
|
130
138
|
completeSimple: CompleteSimpleFunction;
|
|
131
139
|
sessionId?: string;
|
|
@@ -147,7 +155,11 @@ export async function completeSideQuestion({
|
|
|
147
155
|
systemPrompt: SYSTEM_PROMPT,
|
|
148
156
|
messages: [createUserMessage(buildUserPrompt(question, conversationContext))],
|
|
149
157
|
},
|
|
150
|
-
buildStreamOptions(
|
|
158
|
+
buildStreamOptions(
|
|
159
|
+
auth,
|
|
160
|
+
{ thinkingLevel, signal, model, sessionId },
|
|
161
|
+
completeSimple.appliesRequestHeaderTransforms === true,
|
|
162
|
+
),
|
|
151
163
|
);
|
|
152
164
|
}
|
|
153
165
|
|
|
@@ -194,31 +206,18 @@ function createUserMessage(text: string): UserMessage {
|
|
|
194
206
|
};
|
|
195
207
|
}
|
|
196
208
|
|
|
197
|
-
// Minimal session-
|
|
198
|
-
// (pinned to @earendil-works/pi-coding-agent@0.85.0 src/core/provider-attribution.ts:getSessionHeaders).
|
|
209
|
+
// Minimal session-header mirror of Pi core provider attribution.
|
|
199
210
|
// Core does not export this helper and extensions have no SettingsManager, so only session
|
|
200
211
|
// headers are mirrored here. Default attribution headers are intentionally out of scope.
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
function matchesOpencodeHost(baseUrl: string | undefined): boolean {
|
|
206
|
-
if (!baseUrl) return false;
|
|
207
|
-
try {
|
|
208
|
-
return new URL(baseUrl).hostname === OPENCODE_HOST;
|
|
209
|
-
} catch {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
212
|
+
// Request-time auth can replace a custom provider's base URL after these options are built,
|
|
213
|
+
// so only canonical provider IDs are safe attribution signals. Keep merge semantics
|
|
214
|
+
// bug-compatible with core: case-sensitive Object.assign, explicit request headers win on
|
|
215
|
+
// exact-case match.
|
|
214
216
|
function getOpencodeSessionHeaders(
|
|
215
|
-
model: Pick<Model<Api>, "provider"
|
|
217
|
+
model: Pick<Model<Api>, "provider">,
|
|
216
218
|
sessionId?: string,
|
|
217
219
|
): ProviderHeaders | undefined {
|
|
218
|
-
if (!sessionId) return undefined;
|
|
219
|
-
if (model.provider !== "opencode" && model.provider !== "opencode-go" && !matchesOpencodeHost(model.baseUrl)) {
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
220
|
+
if (!sessionId || (model.provider !== "opencode" && model.provider !== "opencode-go")) return undefined;
|
|
222
221
|
return { "x-opencode-session": sessionId, "x-opencode-client": "pi" };
|
|
223
222
|
}
|
|
224
223
|
|
|
@@ -234,21 +233,25 @@ function mergeSessionHeaders(
|
|
|
234
233
|
interface BuildSideThreadStreamOptions {
|
|
235
234
|
thinkingLevel: BtwThinkingLevel;
|
|
236
235
|
signal?: AbortSignal;
|
|
237
|
-
model?: Pick<Model<Api>, "provider"
|
|
236
|
+
model?: Pick<Model<Api>, "provider">;
|
|
238
237
|
sessionId?: string;
|
|
239
238
|
}
|
|
240
239
|
|
|
241
240
|
function buildStreamOptions(
|
|
242
|
-
auth: SideQuestionAuth,
|
|
241
|
+
auth: SideQuestionAuth | undefined,
|
|
243
242
|
{ thinkingLevel, signal, model, sessionId }: BuildSideThreadStreamOptions,
|
|
244
|
-
|
|
243
|
+
applyRequestHeaderTransforms: boolean,
|
|
244
|
+
): ModelsSimpleStreamOptions {
|
|
245
245
|
const sessionHeaders = model ? getOpencodeSessionHeaders(model, sessionId) : undefined;
|
|
246
|
-
const options:
|
|
247
|
-
apiKey: auth
|
|
248
|
-
headers: mergeSessionHeaders(auth
|
|
249
|
-
env: auth
|
|
246
|
+
const options: ModelsSimpleStreamOptions = {
|
|
247
|
+
apiKey: auth?.apiKey,
|
|
248
|
+
headers: applyRequestHeaderTransforms ? auth?.headers : mergeSessionHeaders(auth?.headers, sessionHeaders),
|
|
249
|
+
env: auth?.env,
|
|
250
250
|
signal,
|
|
251
251
|
};
|
|
252
|
+
if (applyRequestHeaderTransforms && sessionHeaders) {
|
|
253
|
+
options.transformHeaders = (headers) => mergeSessionHeaders(headers, sessionHeaders) ?? {};
|
|
254
|
+
}
|
|
252
255
|
if (thinkingLevel !== "off") options.reasoning = thinkingLevel;
|
|
253
256
|
return options;
|
|
254
257
|
}
|
|
@@ -65,55 +65,19 @@ If no supported inhibitor is available, the extension stays loaded and reports t
|
|
|
65
65
|
|
|
66
66
|
## 💬 Commands
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
If an inhibitor is currently active, it is restarted so the new mode applies immediately.
|
|
82
|
-
|
|
83
|
-
```text
|
|
84
|
-
/caffeinate sleep
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Keeps the system awake while allowing normal display sleep.
|
|
88
|
-
If an inhibitor is currently active, it is restarted so the new mode applies immediately.
|
|
89
|
-
|
|
90
|
-
```text
|
|
91
|
-
/caffeinate status
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Shows whether the inhibitor is active, unavailable, disabled, or idle.
|
|
95
|
-
The result includes the mode, quiet-mode state, and settings path.
|
|
96
|
-
|
|
97
|
-
```text
|
|
98
|
-
/caffeinate mode
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Opens the keep-awake mode selector in TUI or RPC mode.
|
|
102
|
-
Escape closes it.
|
|
103
|
-
|
|
104
|
-
```text
|
|
105
|
-
/caffeinate stop
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Releases the active inhibitor until Pi starts another agent run.
|
|
109
|
-
|
|
110
|
-
```text
|
|
111
|
-
/caffeinate help
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Shows the canonical command routes.
|
|
115
|
-
In TUI and RPC mode, unknown commands and trailing text show a rejection with the command guide.
|
|
116
|
-
Compatibility aliases are `screen` for `display`, `system` for `sleep`, `off` for `stop`, and `config` or `settings` for `mode`.
|
|
68
|
+
| Command | Purpose |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `/caffeinate` | Open keep-awake controls. |
|
|
71
|
+
| `/caffeinate display` (alias: `screen`) | Keep the system and display awake. |
|
|
72
|
+
| `/caffeinate sleep` (alias: `system`) | Keep the system awake while allowing display sleep. |
|
|
73
|
+
| `/caffeinate status` | Show inhibitor state, mode, quiet mode, and settings path. |
|
|
74
|
+
| `/caffeinate mode` (aliases: `config`, `settings`) | Choose the keep-awake mode. |
|
|
75
|
+
| `/caffeinate stop` (alias: `off`) | Release the inhibitor until the next agent run. |
|
|
76
|
+
| `/caffeinate help` | Show command usage. |
|
|
77
|
+
|
|
78
|
+
All routes support TUI and RPC and reject unknown or trailing arguments.
|
|
79
|
+
Print and JSON modes reject the menu and mode selector; other direct routes run but do not display notification feedback.
|
|
80
|
+
Changing to `display` or `sleep` restarts an active inhibitor immediately.
|
|
117
81
|
|
|
118
82
|
## ⚙️ Settings
|
|
119
83
|
|
|
@@ -193,26 +157,17 @@ On Linux, `display` mode uses the pure-JavaScript `dbus-native` package to call
|
|
|
193
157
|
|
|
194
158
|
## 🗂️ Package layout
|
|
195
159
|
|
|
196
|
-
```
|
|
160
|
+
```text
|
|
197
161
|
packages/pi-caffeinate/
|
|
198
|
-
├── src/
|
|
199
|
-
│ ├── index.ts
|
|
200
|
-
│
|
|
201
|
-
|
|
202
|
-
├──
|
|
203
|
-
|
|
204
|
-
│ └── build-runtime.mjs
|
|
205
|
-
├── test/
|
|
206
|
-
│ ├── build-runtime.test.ts
|
|
207
|
-
│ └── caffeinate.test.ts
|
|
208
|
-
├── README.md
|
|
209
|
-
├── LICENSE
|
|
210
|
-
├── tsconfig.json
|
|
211
|
-
└── package.json
|
|
162
|
+
├── src/ # Authoritative implementation and helpers
|
|
163
|
+
│ ├── index.ts # Thin Pi entrypoint
|
|
164
|
+
│ └── caffeinate.ts # Sleep inhibitors and lifecycle
|
|
165
|
+
├── dist/ # Generated Jiti runtime
|
|
166
|
+
├── scripts/build-runtime.mjs # Runtime builder
|
|
167
|
+
└── test/ # Behavior and lifecycle coverage
|
|
212
168
|
```
|
|
213
169
|
|
|
214
|
-
`src/index.ts`
|
|
215
|
-
The other source modules are internal.
|
|
170
|
+
The generated runtime is built from `src/index.ts` and does not import back into `src`.
|
|
216
171
|
|
|
217
172
|
## 🔎 Keywords
|
|
218
173
|
|
|
@@ -34,9 +34,7 @@ var NativeScreenSaverClient = class {
|
|
|
34
34
|
};
|
|
35
35
|
handleConnectionClose = (error) => {
|
|
36
36
|
if (this.closing || this.cookie === void 0) return;
|
|
37
|
-
this.reportFailure(
|
|
38
|
-
toError(error, this.lastConnectionError?.message ?? "D-Bus session connection closed")
|
|
39
|
-
);
|
|
37
|
+
this.reportFailure(toError(error, this.lastConnectionError?.message ?? "D-Bus session connection closed"));
|
|
40
38
|
};
|
|
41
39
|
setFailureHandler(handler) {
|
|
42
40
|
this.failureHandler = handler;
|
|
@@ -176,11 +174,7 @@ function getInhibitorCommand(mode) {
|
|
|
176
174
|
if (command) return { command, args, description: `custom command (${command})`, custom: true };
|
|
177
175
|
}
|
|
178
176
|
if (process2.platform === "darwin") {
|
|
179
|
-
return parentBoundUnixCommand(
|
|
180
|
-
"caffeinate",
|
|
181
|
-
macCaffeinateArgs(mode),
|
|
182
|
-
caffeinateDescription(mode)
|
|
183
|
-
);
|
|
177
|
+
return parentBoundUnixCommand("caffeinate", macCaffeinateArgs(mode), caffeinateDescription(mode));
|
|
184
178
|
}
|
|
185
179
|
if (process2.platform === "linux") {
|
|
186
180
|
if (isWsl() && commandExists("powershell.exe")) {
|
|
@@ -190,14 +184,7 @@ function getInhibitorCommand(mode) {
|
|
|
190
184
|
const what = mode === "display" ? "idle:sleep" : "sleep";
|
|
191
185
|
return parentBoundUnixCommand(
|
|
192
186
|
"systemd-inhibit",
|
|
193
|
-
[
|
|
194
|
-
`--what=${what}`,
|
|
195
|
-
"--who=pi-caffeinate",
|
|
196
|
-
"--why=Pi agent is running",
|
|
197
|
-
"--mode=block",
|
|
198
|
-
"sleep",
|
|
199
|
-
"infinity"
|
|
200
|
-
],
|
|
187
|
+
[`--what=${what}`, "--who=pi-caffeinate", "--why=Pi agent is running", "--mode=block", "sleep", "infinity"],
|
|
201
188
|
`systemd-inhibit (${formatMode(mode)})`,
|
|
202
189
|
mode === "display"
|
|
203
190
|
);
|
|
@@ -223,14 +210,7 @@ function caffeinateDescription(mode) {
|
|
|
223
210
|
function parentBoundUnixCommand(command, args, description, addDbusIdleInhibit = false) {
|
|
224
211
|
return {
|
|
225
212
|
command: "sh",
|
|
226
|
-
args: [
|
|
227
|
-
"-c",
|
|
228
|
-
unixParentBoundScript(),
|
|
229
|
-
"pi-caffeinate-watch",
|
|
230
|
-
String(process2.pid),
|
|
231
|
-
command,
|
|
232
|
-
...args
|
|
233
|
-
],
|
|
213
|
+
args: ["-c", unixParentBoundScript(), "pi-caffeinate-watch", String(process2.pid), command, ...args],
|
|
234
214
|
description,
|
|
235
215
|
...addDbusIdleInhibit ? { addDbusIdleInhibit: true } : {}
|
|
236
216
|
};
|
|
@@ -431,11 +411,8 @@ async function saveSettingsNow(settings, operations) {
|
|
|
431
411
|
await mkdir(dirname(filePath), { recursive: true });
|
|
432
412
|
const tempFile = `${filePath}.${process3.pid}.${randomUUID()}.tmp`;
|
|
433
413
|
try {
|
|
434
|
-
await (operations.write ?? DEFAULT_FILE_OPERATIONS.write)(
|
|
435
|
-
|
|
436
|
-
`${JSON.stringify(nextDocument, null, 2)}
|
|
437
|
-
`
|
|
438
|
-
);
|
|
414
|
+
await (operations.write ?? DEFAULT_FILE_OPERATIONS.write)(tempFile, `${JSON.stringify(nextDocument, null, 2)}
|
|
415
|
+
`);
|
|
439
416
|
if (!replaceCanonical && await pathEntryExists(filePath)) {
|
|
440
417
|
throw new Error(`${NEW_SETTINGS_FILE} was created concurrently; reopen settings and retry.`);
|
|
441
418
|
}
|
|
@@ -681,9 +658,7 @@ async function setModeNow(ctx, mode, generation) {
|
|
|
681
658
|
if (generation !== state.sessionGeneration) return;
|
|
682
659
|
const previousMode = state.mode;
|
|
683
660
|
const previousQuiet = state.quiet;
|
|
684
|
-
const restartRequired = Boolean(
|
|
685
|
-
hasActiveInhibitor() && previousMode !== mode && !state.command?.custom
|
|
686
|
-
);
|
|
661
|
+
const restartRequired = Boolean(hasActiveInhibitor() && previousMode !== mode && !state.command?.custom);
|
|
687
662
|
state.settingsError = void 0;
|
|
688
663
|
if (restartRequired) {
|
|
689
664
|
state.mode = mode;
|
|
@@ -758,9 +733,7 @@ function parseCommand(args) {
|
|
|
758
733
|
function commandCompletions(prefix) {
|
|
759
734
|
const normalized = prefix.trimStart().toLowerCase();
|
|
760
735
|
if (/\s/.test(normalized)) return null;
|
|
761
|
-
const matches = COMMAND_COMPLETIONS.filter(
|
|
762
|
-
(completion) => completion.value.startsWith(normalized)
|
|
763
|
-
);
|
|
736
|
+
const matches = COMMAND_COMPLETIONS.filter((completion) => completion.value.startsWith(normalized));
|
|
764
737
|
return matches.length > 0 ? matches : null;
|
|
765
738
|
}
|
|
766
739
|
function buildCommandGuide() {
|
|
@@ -1028,9 +1001,7 @@ function describeState() {
|
|
|
1028
1001
|
const activeParts = [];
|
|
1029
1002
|
if (state.dbus) activeParts.push(`D-Bus idle inhibit (${SCREENSAVER_BUS_NAME})`);
|
|
1030
1003
|
if (state.process && state.command) activeParts.push(state.command.description);
|
|
1031
|
-
lines.unshift(
|
|
1032
|
-
`pi-caffeinate is active using ${activeParts.join(" + ") || "an inhibitor"} for ${seconds}s.`
|
|
1033
|
-
);
|
|
1004
|
+
lines.unshift(`pi-caffeinate is active using ${activeParts.join(" + ") || "an inhibitor"} for ${seconds}s.`);
|
|
1034
1005
|
if (state.inhibitWarning) lines.push(`Inhibitor warning: ${state.inhibitWarning}`);
|
|
1035
1006
|
return lines.join("\n");
|
|
1036
1007
|
}
|
|
@@ -1038,9 +1009,7 @@ function describeState() {
|
|
|
1038
1009
|
lines.unshift(`pi-caffeinate is unavailable: ${state.lastError ?? "unknown reason"}`);
|
|
1039
1010
|
return lines.join("\n");
|
|
1040
1011
|
}
|
|
1041
|
-
lines.unshift(
|
|
1042
|
-
"pi-caffeinate is idle and will keep the computer awake during the next agent run."
|
|
1043
|
-
);
|
|
1012
|
+
lines.unshift("pi-caffeinate is idle and will keep the computer awake during the next agent run.");
|
|
1044
1013
|
return lines.join("\n");
|
|
1045
1014
|
}
|
|
1046
1015
|
function statusLevel() {
|