pi2dsh 0.22.0 → 0.23.0

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/dist/host.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { s as registerVisionCompanions, t as applyPiPackage } from "./runtime-BVrvJuiO.mjs";
2
+ import { s as registerVisionCompanions, t as applyPiPackage } from "./runtime-Dnk9mhrc.mjs";
3
3
  import { t as resolvePiPackage } from "./source-0sA5z08z.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { readFile } from "node:fs/promises";
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
2
  import { ot as providePiExtensionDiscovery } from "./pi-coding-agent-CPXFo0UO.mjs";
3
- import { c as runtimeInternals, n as getSharedChildExtensionCatalog, o as registerChildExtensionCatalog, s as registerVisionCompanions } from "./runtime-BVrvJuiO.mjs";
3
+ import { c as runtimeInternals, n as getSharedChildExtensionCatalog, o as registerChildExtensionCatalog, s as registerVisionCompanions } from "./runtime-Dnk9mhrc.mjs";
4
4
  import { i as renderMcpPatch, n as convertPiMcpConfig, t as collectPiMcpServers } from "./mcp-config-C1K-IzzB.mjs";
5
5
  import { t as resolvePiPackage } from "./source-0sA5z08z.mjs";
6
6
  import { applyPiHost, applyPreparedPiHost, manifestForInstalled, preparePiHost } from "./host.mjs";
7
- import { a as PI_AI_PACKAGES, c as UI_CONTEXT_RULES, d as ruleForEvent, f as ruleForHostImport, i as HOST_IMPORT_RULES, l as ruleForApi, n as CONTEXT_RULES, o as PI_CODING_AGENT_PACKAGES, p as ruleForUiContextProperty, r as EVENT_RULES, s as PI_TUI_PACKAGES, t as API_RULES, u as ruleForContextProperty } from "./compatibility-PfLsrQPc.mjs";
7
+ import { a as PI_AI_PACKAGES, c as UI_CONTEXT_RULES, d as ruleForEvent, f as ruleForHostImport, i as HOST_IMPORT_RULES, l as ruleForApi, n as CONTEXT_RULES, o as PI_CODING_AGENT_PACKAGES, p as ruleForUiContextProperty, r as EVENT_RULES, s as PI_TUI_PACKAGES, t as API_RULES, u as ruleForContextProperty } from "./compatibility-CZs3LwYn.mjs";
8
8
  import { readFile } from "node:fs/promises";
9
9
  import { existsSync, realpathSync } from "node:fs";
10
10
  import { dirname, join, resolve } from "node:path";
@@ -407,7 +407,7 @@ async function apply(ctx, config = {}) {
407
407
  * @returns the compatibility report.
408
408
  */
409
409
  async function analyzePackage(pkg) {
410
- const { analyzePackage: run } = await import("./analyzer-LD53mBKa.mjs");
410
+ const { analyzePackage: run } = await import("./analyzer-C139Y2S7.mjs");
411
411
  return run(pkg);
412
412
  }
413
413
  //#endregion
@@ -1139,6 +1139,8 @@ function messageText(message) {
1139
1139
  * is one surface, however many Pi packages contribute threads to it.
1140
1140
  */
1141
1141
  var BrowserSurfaces = class {
1142
+ /** Last time a browser client touched the /pi2dsh route (ms epoch). */
1143
+ lastClientContactMs;
1142
1144
  #byParent = /* @__PURE__ */ new Map();
1143
1145
  #commandRunners = /* @__PURE__ */ new Map();
1144
1146
  #surfaces = /* @__PURE__ */ new Map();
@@ -1659,6 +1661,7 @@ function registerBrowserSurfaceRoute(ctx, registry, hooks) {
1659
1661
  const response = res;
1660
1662
  const method = String(req.method ?? "GET");
1661
1663
  const url = new URL(String(req.url ?? "/"), "http://pi2dsh.invalid");
1664
+ registry.lastClientContactMs = Date.now();
1662
1665
  if (method === "POST" && url.pathname === "/pi2dsh/editor-draft") {
1663
1666
  const chunks = [];
1664
1667
  const body = await new Promise((settle) => {
@@ -3060,6 +3063,9 @@ const DSH_COMPAT_FIELD_PROTOCOLS = {
3060
3063
  supportsDeveloperRole: COMPLETIONS_AND_RESPONSES,
3061
3064
  supportsReasoningEffort: COMPLETIONS,
3062
3065
  supportsUsageInStreaming: COMPLETIONS,
3066
+ supportsFinishReason: COMPLETIONS,
3067
+ chatTemplateArgs: COMPLETIONS,
3068
+ supportsThinkingTokenBudget: COMPLETIONS,
3063
3069
  maxTokensField: COMPLETIONS,
3064
3070
  requiresToolResultName: COMPLETIONS,
3065
3071
  requiresAssistantAfterToolResult: COMPLETIONS,
@@ -4554,7 +4560,7 @@ function contextFor(ctx, state, agent, signal, command = false, sessionOverride,
4554
4560
  return state.shared.browserSurfaces !== void 0 && state.shared.browserSurfacesRouted === true ? "tui" : "rpc";
4555
4561
  },
4556
4562
  get hasUI() {
4557
- return state.tuiSurfaces?.available === true || humanAnswererAvailable(userQuestions, agent);
4563
+ return state.tuiSurfaces?.available === true || humanAnswererAvailable(userQuestions, agent, state.shared);
4558
4564
  },
4559
4565
  cwd: contextCwd,
4560
4566
  sessionManager: session === void 0 ? state.bridge.readonlySessionManager({
@@ -6855,11 +6861,18 @@ function sessionNameOf(ctx, state, session) {
6855
6861
  * @param userQuestions - the mounted question service, if any.
6856
6862
  * @param agent - the agent whose turn this context belongs to.
6857
6863
  */
6858
- function humanAnswererAvailable(userQuestions, agent) {
6864
+ function humanAnswererAvailable(userQuestions, agent, shared) {
6859
6865
  if (userQuestions === void 0) return false;
6860
6866
  if (isSubagentOrigin(agent)) return false;
6861
6867
  const service = userQuestions;
6862
- if (typeof service.registerProvider !== "function") return false;
6868
+ if (typeof service.registerProvider !== "function") {
6869
+ const events = service.ctx?.events;
6870
+ if (typeof events?.dispatch === "function") try {
6871
+ if (events.dispatch("pi2dsh:hasui-probe", ["user-questions/request"]).length > 0) return true;
6872
+ } catch {}
6873
+ const last = shared?.browserSurfaces?.lastClientContactMs;
6874
+ return typeof last === "number" && Date.now() - last < 15e3;
6875
+ }
6863
6876
  let dispose;
6864
6877
  try {
6865
6878
  dispose = service.registerProvider({ ask: async () => {
@@ -7658,4 +7671,4 @@ const runtimeInternals = {
7658
7671
  //#endregion
7659
7672
  export { overlayProviderConfig as a, runtimeInternals as c, normalizeToolSchema as i, getSharedChildExtensionCatalog as n, registerChildExtensionCatalog as o, mergeProviderRegistration as r, registerVisionCompanions as s, applyPiPackage as t };
7660
7673
 
7661
- //# sourceMappingURL=runtime-BVrvJuiO.mjs.map
7674
+ //# sourceMappingURL=runtime-Dnk9mhrc.mjs.map