@humain/humain-code 0.8.4 → 0.8.5
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 +6 -0
- package/dist/bundle/chunks/{chunk-4BNDLR6C.js → chunk-2RXTZK2V.js} +1 -1
- package/dist/bundle/chunks/{chunk-CIAXW64K.js → chunk-3OOOEJV4.js} +5 -5
- package/dist/bundle/chunks/{chunk-J5YFXMTM.js → chunk-53DWQSBC.js} +1 -1
- package/dist/bundle/chunks/{chunk-73YX5XGR.js → chunk-7XRMMCKG.js} +267 -251
- package/dist/bundle/chunks/{chunk-HWXQCJDP.js → chunk-BDNX23GT.js} +76 -71
- package/dist/bundle/chunks/{chunk-52642TYH.js → chunk-COZTJAOY.js} +54 -51
- package/dist/bundle/chunks/{chunk-SOE25WIS.js → chunk-EWPEY4F4.js} +789 -790
- package/dist/bundle/chunks/{chunk-ARTF7ZMQ.js → chunk-FHP5BULR.js} +1 -1
- package/dist/bundle/chunks/{chunk-XGSJX23G.js → chunk-N3W4ALAM.js} +1 -1
- package/dist/bundle/chunks/{chunk-OTVHRZ67.js → chunk-SASR4VNV.js} +1 -1
- package/dist/bundle/chunks/{chunk-EVDQRT3I.js → chunk-VWUEKLRH.js} +8 -8
- package/dist/bundle/chunks/{compat-7UJJAO4E.js → compat-2RC4CJNV.js} +1 -1
- package/dist/bundle/chunks/{dist-7PCCEUQF.js → dist-3DAGUOYC.js} +1 -1
- package/dist/bundle/chunks/{dist-I53JI67E.js → dist-K4QIXV5O.js} +5 -5
- package/dist/bundle/chunks/{doctor-KJVAYG3F.js → doctor-EH7X36SK.js} +2 -2
- package/dist/bundle/chunks/{flow-implementer-GE2ARQKR.js → flow-implementer-J6QTLBTH.js} +2 -2
- package/dist/bundle/chunks/{inprocess-MGMVI6HN.js → inprocess-OHNEKTFB.js} +3 -3
- package/dist/bundle/chunks/{interactive-mode-HHWOE4FD.js → interactive-mode-ZREVRX7W.js} +2 -2
- package/dist/bundle/chunks/{virtual-modules-UXSSFNV5.js → virtual-modules-6FVRJTM3.js} +3 -3
- package/dist/bundle/cli-runtime.js +2 -2
- package/dist/bundle/index.js +6 -6
- package/dist/bundle/rpc-entry.js +2 -2
- package/dist/core/bug-report.d.ts +24 -1
- package/dist/core/bug-report.d.ts.map +1 -1
- package/dist/core/bug-report.js +216 -19
- package/dist/core/bug-report.js.map +1 -1
- package/dist/core/extensions/containment.d.ts +26 -0
- package/dist/core/extensions/containment.d.ts.map +1 -0
- package/dist/core/extensions/containment.js +66 -0
- package/dist/core/extensions/containment.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +65 -7
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +55 -10
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +4 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/humain/checklist/vendor/commands.d.ts.map +1 -1
- package/dist/humain/checklist/vendor/commands.js +20 -8
- package/dist/humain/checklist/vendor/commands.js.map +1 -1
- package/dist/humain/flow-loader.d.ts.map +1 -1
- package/dist/humain/flow-loader.js +31 -5
- package/dist/humain/flow-loader.js.map +1 -1
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +11 -1
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts.map +1 -1
- package/dist/modes/interactive/bug-report.js +48 -12
- package/dist/modes/interactive/bug-report.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +28 -46
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/extensions.md +2 -0
- package/docs/flow.md +2 -0
- package/docs/humain-code.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/humain/web-access/UPSTREAM.md +8 -0
|
@@ -6,6 +6,7 @@ import { getCurrentSystemMessage, } from "@earendil-works/pi-ai";
|
|
|
6
6
|
import { theme } from "../../modes/interactive/theme/theme.js";
|
|
7
7
|
import { buildSystemPrompt, normalizeBuildSystemPromptOptions, } from "../system-prompt.js";
|
|
8
8
|
import { SUBAGENT_PROGRESS_CAPABILITY } from "../tools/subagent-progress.js";
|
|
9
|
+
import { extensionExecution, isPromiseLike, isStaleExtensionError, reportLateExtensionError, staleExtensionError, } from "./containment.js";
|
|
9
10
|
// Extension shortcuts compete with canonical keybinding ids from keybindings.json.
|
|
10
11
|
// Only editor-global shortcuts are reserved here. Picker-specific bindings are not.
|
|
11
12
|
const RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS = [
|
|
@@ -101,11 +102,6 @@ function snapshotEventHandlers(extensions, event) {
|
|
|
101
102
|
}
|
|
102
103
|
return snapshot;
|
|
103
104
|
}
|
|
104
|
-
function isPromiseLike(value) {
|
|
105
|
-
return ((typeof value === "object" || typeof value === "function") &&
|
|
106
|
-
value !== null &&
|
|
107
|
-
typeof value.then === "function");
|
|
108
|
-
}
|
|
109
105
|
function sameMessages(left, right) {
|
|
110
106
|
return left.length === right.length && left.every((message, index) => message === right[index]);
|
|
111
107
|
}
|
|
@@ -223,9 +219,9 @@ export class ExtensionRunner {
|
|
|
223
219
|
constructor(extensions, runtime, cwd, sessionManager, modelRegistry, settingsManager) {
|
|
224
220
|
this.extensions = extensions;
|
|
225
221
|
this.runtime = runtime;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (!this.staleMessage)
|
|
222
|
+
this.runtime.reportError = (error, cause) => {
|
|
223
|
+
// Unrelated late event-bus failures must not draw into a replacement session (#11264).
|
|
224
|
+
if (!this.staleMessage || isStaleExtensionError(cause))
|
|
229
225
|
this.emitError(error);
|
|
230
226
|
};
|
|
231
227
|
this.uiContext = noOpUIContext;
|
|
@@ -388,6 +384,8 @@ export class ExtensionRunner {
|
|
|
388
384
|
wrapUIPromptContext(ui) {
|
|
389
385
|
return {
|
|
390
386
|
...ui,
|
|
387
|
+
onEditorChange: (handler) => this.subscribeExtensionCallback(handler, (callback) => ui.onEditorChange(callback)),
|
|
388
|
+
onTerminalInput: (handler) => this.subscribeExtensionCallback(handler, (callback) => ui.onTerminalInput(callback)),
|
|
391
389
|
select: (title, options, opts) => this.withUIPrompt("select", title, () => ui.select(title, options, opts)),
|
|
392
390
|
confirm: (title, message, opts) => this.withUIPrompt("confirm", title, () => ui.confirm(title, message, opts)),
|
|
393
391
|
input: (title, placeholder, opts) => this.withUIPrompt("input", title, () => ui.input(title, placeholder, opts)),
|
|
@@ -405,6 +403,49 @@ export class ExtensionRunner {
|
|
|
405
403
|
},
|
|
406
404
|
};
|
|
407
405
|
}
|
|
406
|
+
subscribeExtensionCallback(handler, subscribe) {
|
|
407
|
+
const owner = extensionExecution.getStore();
|
|
408
|
+
if (!owner)
|
|
409
|
+
return subscribe(handler);
|
|
410
|
+
let active = true;
|
|
411
|
+
let unsubscribe = () => { };
|
|
412
|
+
const stop = () => {
|
|
413
|
+
if (!active)
|
|
414
|
+
return;
|
|
415
|
+
active = false;
|
|
416
|
+
unsubscribe();
|
|
417
|
+
};
|
|
418
|
+
const fail = (error) => {
|
|
419
|
+
if (!active)
|
|
420
|
+
return;
|
|
421
|
+
stop();
|
|
422
|
+
owner.disable();
|
|
423
|
+
owner.report({
|
|
424
|
+
extensionPath: owner.extensionPath,
|
|
425
|
+
event: "ui_callback",
|
|
426
|
+
error: error instanceof Error ? error.message : String(error),
|
|
427
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
428
|
+
}, error);
|
|
429
|
+
};
|
|
430
|
+
unsubscribe = subscribe((...args) => {
|
|
431
|
+
if (!active)
|
|
432
|
+
return undefined;
|
|
433
|
+
try {
|
|
434
|
+
const result = extensionExecution.run(owner, () => handler(...args));
|
|
435
|
+
// Extension JS may return a promise even from a void UI callback.
|
|
436
|
+
if (isPromiseLike(result))
|
|
437
|
+
void Promise.resolve(result).catch(fail);
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
fail(error);
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
if (!active)
|
|
446
|
+
unsubscribe();
|
|
447
|
+
return stop;
|
|
448
|
+
}
|
|
408
449
|
withUIPrompt(kind, title, run) {
|
|
409
450
|
const outerPrompt = this.uiPromptDepth++ === 0;
|
|
410
451
|
if (outerPrompt) {
|
|
@@ -526,7 +567,7 @@ export class ExtensionRunner {
|
|
|
526
567
|
}
|
|
527
568
|
assertActive() {
|
|
528
569
|
if (this.staleMessage) {
|
|
529
|
-
throw
|
|
570
|
+
throw staleExtensionError(this.staleMessage);
|
|
530
571
|
}
|
|
531
572
|
}
|
|
532
573
|
onError(listener) {
|
|
@@ -534,6 +575,8 @@ export class ExtensionRunner {
|
|
|
534
575
|
return () => this.errorListeners.delete(listener);
|
|
535
576
|
}
|
|
536
577
|
emitError(error) {
|
|
578
|
+
if (this.staleMessage && this.errorListeners.size === 0)
|
|
579
|
+
reportLateExtensionError(error);
|
|
537
580
|
for (const listener of this.errorListeners) {
|
|
538
581
|
listener(error);
|
|
539
582
|
}
|
|
@@ -773,6 +816,8 @@ export class ExtensionRunner {
|
|
|
773
816
|
},
|
|
774
817
|
},
|
|
775
818
|
executeTool: {
|
|
819
|
+
// Attribution proxies must be allowed to wrap this action (Proxy get invariants).
|
|
820
|
+
configurable: true,
|
|
776
821
|
value: async (name, args, options = {}) => {
|
|
777
822
|
runner.assertActive();
|
|
778
823
|
if (!runner.executeToolFn) {
|
|
@@ -924,7 +969,7 @@ export class ExtensionRunner {
|
|
|
924
969
|
* `emit` for an event whose handlers' results are not used (`agent_start`, `message_update`, `tool_execution_end`,
|
|
925
970
|
* ...), without an await while handlers return synchronously. Returns undefined when every handler returned
|
|
926
971
|
* synchronously, or a promise of the rest of the dispatch from the first handler that returned a promise. Handlers
|
|
927
|
-
* run in the same order, with the same context and error reporting, as with `emit`.
|
|
972
|
+
* run in the same order, with the same underlying context and error reporting, as with `emit`.
|
|
928
973
|
*/
|
|
929
974
|
dispatch(event) {
|
|
930
975
|
if (!this.hasHandlers(event.type))
|