@agent-plan/pi-adapter 0.2.6 → 0.2.7
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/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,iCAAiC,CAAC;AA00BtF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqxF9D"}
|
package/dist/index.js
CHANGED
|
@@ -165,6 +165,24 @@ async function maybeHealStatuses(st) {
|
|
|
165
165
|
function normalizeLanguagePref(value) {
|
|
166
166
|
return value?.trim() ?? "";
|
|
167
167
|
}
|
|
168
|
+
// Safety net: ctx.ui.input() can hang forever when the extension is loaded from
|
|
169
|
+
// an NPM-installed package (the prompt never renders, the await never resolves,
|
|
170
|
+
// and Pi freezes). Race the prompt against a timeout; on timeout, fall back to the
|
|
171
|
+
// empty answer (treated as "no / this session only" by the gating logic) and notify
|
|
172
|
+
// the user how to enable manually. This preserves the interactive prompt for the
|
|
173
|
+
// working case while guaranteeing session_start can never block Pi permanently.
|
|
174
|
+
const PROMPT_TIMEOUT_MS = 20000;
|
|
175
|
+
async function safeInput(ctx, prompt) {
|
|
176
|
+
try {
|
|
177
|
+
return await Promise.race([
|
|
178
|
+
ctx.ui.input(prompt),
|
|
179
|
+
new Promise((resolve) => setTimeout(() => resolve("__PLANNER_PROMPT_TIMEOUT__"), PROMPT_TIMEOUT_MS)),
|
|
180
|
+
]);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return "";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
168
186
|
async function ensureProjectLanguagePreferences(st) {
|
|
169
187
|
const project = await st.loadProject();
|
|
170
188
|
const contentLanguage = normalizeLanguagePref(project.contentLanguage);
|
|
@@ -811,7 +829,7 @@ export default function planPiExtension(pi) {
|
|
|
811
829
|
}
|
|
812
830
|
else {
|
|
813
831
|
try {
|
|
814
|
-
const ans = await ctx
|
|
832
|
+
const ans = await safeInput(ctx, "Planner detected in this project. Enable the planner extension? (y)es / (n)o / (a)lways / n(e)ver)");
|
|
815
833
|
const normalized = ans?.trim().toLowerCase() ?? "";
|
|
816
834
|
if (["a", "always", "sempre"].includes(normalized)) {
|
|
817
835
|
enablePlanner = true;
|
|
@@ -898,7 +916,7 @@ export default function planPiExtension(pi) {
|
|
|
898
916
|
}
|
|
899
917
|
else if (server === null) {
|
|
900
918
|
try {
|
|
901
|
-
const ans = await ctx
|
|
919
|
+
const ans = await safeInput(ctx, "Start the planner web UI? (y)es / (n)o / (a)lways / n(e)ver)");
|
|
902
920
|
const normalized = ans?.trim().toLowerCase() ?? "";
|
|
903
921
|
if (["a", "always", "sempre"].includes(normalized)) {
|
|
904
922
|
startWeb = true;
|