@howaboua/pi-ask 0.0.4 → 0.0.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.
Files changed (3) hide show
  1. package/ask/tool.ts +7 -1
  2. package/index.ts +13 -1
  3. package/package.json +3 -3
package/ask/tool.ts CHANGED
@@ -16,8 +16,10 @@ type AskInComposer = (
16
16
  ) => Promise<unknown>;
17
17
 
18
18
  interface BlockedState {
19
+ id: string;
19
20
  active: boolean;
20
21
  label: string;
22
+ prompt: string;
21
23
  }
22
24
 
23
25
  type OnBlockedChange = (state: BlockedState) => void;
@@ -42,7 +44,7 @@ export function createAskTool({
42
44
  "ask: Do not add Other/rephrase; it is automatic.",
43
45
  ],
44
46
  executionMode: "sequential",
45
- async execute(_toolCallId, params, signal, _onUpdate, ctx) {
47
+ async execute(toolCallId, params, signal, _onUpdate, ctx) {
46
48
  const { handoff, prompts } = normalizeAskInput(params);
47
49
  if (prompts.length === 0) {
48
50
  throw new Error(
@@ -53,8 +55,12 @@ export function createAskTool({
53
55
  throw new Error("ask requires an interactive UI.");
54
56
 
55
57
  const blockedState = {
58
+ id: toolCallId,
56
59
  active: true,
57
60
  label: handoff ? "Human action needed" : "Waiting for input",
61
+ prompt: handoff
62
+ ? "The user needs to complete an action before the active work can continue. Please announce this briefly in your natural voice."
63
+ : "User input is required before the active work can continue. Please announce this briefly in your natural voice.",
58
64
  };
59
65
  onBlockedChange?.(blockedState);
60
66
  let rawResponses: unknown;
package/index.ts CHANGED
@@ -7,11 +7,23 @@ import { createAskTool } from "./ask/tool.js";
7
7
  export { createAskTool } from "./ask/tool.js";
8
8
 
9
9
  const PROMPTS_DIR = join(dirname(fileURLToPath(import.meta.url)), "prompts");
10
+ const REALTIME_VOICE_PROMPT_CHANNEL =
11
+ "@howaboua/pi-codex-conversion/realtime-voice-prompt/v1";
10
12
 
11
13
  export default function humanInTheLoop(pi: ExtensionAPI): void {
12
14
  pi.registerTool(
13
15
  createAskTool({
14
- onBlockedChange: (state) => pi.events.emit("herdr:blocked", state),
16
+ onBlockedChange: (state) => {
17
+ pi.events.emit(REALTIME_VOICE_PROMPT_CHANNEL, {
18
+ id: state.id,
19
+ active: state.active,
20
+ prompt: state.prompt,
21
+ });
22
+ pi.events.emit("herdr:blocked", {
23
+ active: state.active,
24
+ label: state.label,
25
+ });
26
+ },
15
27
  }),
16
28
  );
17
29
  pi.on("resources_discover", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-ask",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Interactive decisions, review triage, and human handoffs for Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@biomejs/biome": "^2.4.16",
52
- "@earendil-works/pi-coding-agent": "0.80.8",
53
- "@earendil-works/pi-tui": "0.80.8",
52
+ "@earendil-works/pi-coding-agent": "0.82.0",
53
+ "@earendil-works/pi-tui": "0.82.0",
54
54
  "typebox": "1.1.38",
55
55
  "typescript": "^6.0.3"
56
56
  },