@howaboua/pi-ask 0.0.1 → 0.0.3

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 CHANGED
@@ -20,6 +20,8 @@ The agent can present several independently decidable prompts in one tabbed pane
20
20
 
21
21
  For work only you can complete—sign-in, authorization, hardware access, or another manual step—the agent can open a handoff and wait until you mark it done or unable to complete.
22
22
 
23
+ When Pi runs inside Herdr with its Pi integration installed, an open ask panel marks the pane as blocked until you submit, dismiss, or abort it.
24
+
23
25
  `Other/rephrase` is always available. Submit it blank when the prompt needs to be rephrased, split, or followed up instead of answered as written.
24
26
 
25
27
  ## Prompt commands
package/ask/tool.ts CHANGED
@@ -15,10 +15,19 @@ type AskInComposer = (
15
15
  signal: AbortSignal | undefined,
16
16
  ) => Promise<unknown>;
17
17
 
18
+ interface BlockedState {
19
+ active: boolean;
20
+ label: string;
21
+ }
22
+
23
+ type OnBlockedChange = (state: BlockedState) => void;
24
+
18
25
  export function createAskTool({
19
26
  askInComposer,
27
+ onBlockedChange,
20
28
  }: {
21
29
  askInComposer?: AskInComposer;
30
+ onBlockedChange?: OnBlockedChange;
22
31
  } = {}) {
23
32
  return defineTool({
24
33
  name: "ask",
@@ -26,7 +35,7 @@ export function createAskTool({
26
35
  description:
27
36
  "Request user input or action and return the response. Requires interactive UI.",
28
37
  parameters: AskParameters,
29
- promptSnippet: "ask: Request human input or action.",
38
+ promptSnippet: "Request human input or action.",
30
39
  promptGuidelines: [
31
40
  "ask: Use for needed user decisions or input; set handoff true for a user-only action and state its completion signal.",
32
41
  "ask: For reviews, make each finding a prompt with disposition choices; do not report first.",
@@ -43,17 +52,27 @@ export function createAskTool({
43
52
  if (!askInComposer && !ctx.hasUI)
44
53
  throw new Error("ask requires an interactive UI.");
45
54
 
46
- const rawResponses = askInComposer
47
- ? await askInComposer(prompts, signal)
48
- : ctx.mode === "tui"
49
- ? await askInTui(ctx, prompts, {
50
- handoff,
51
- ...(signal ? { signal } : {}),
52
- })
53
- : await askWithPiUi(ctx, prompts, {
54
- handoff,
55
- ...(signal ? { signal } : {}),
56
- });
55
+ const blockedState = {
56
+ active: true,
57
+ label: handoff ? "Human action needed" : "Waiting for input",
58
+ };
59
+ onBlockedChange?.(blockedState);
60
+ let rawResponses: unknown;
61
+ try {
62
+ rawResponses = askInComposer
63
+ ? await askInComposer(prompts, signal)
64
+ : ctx.mode === "tui"
65
+ ? await askInTui(ctx, prompts, {
66
+ handoff,
67
+ ...(signal ? { signal } : {}),
68
+ })
69
+ : await askWithPiUi(ctx, prompts, {
70
+ handoff,
71
+ ...(signal ? { signal } : {}),
72
+ });
73
+ } finally {
74
+ onBlockedChange?.({ ...blockedState, active: false });
75
+ }
57
76
  const responses = normalizeResponses(prompts, rawResponses);
58
77
  if (!responses) {
59
78
  return {
package/index.ts CHANGED
@@ -9,7 +9,11 @@ export { createAskTool } from "./ask/tool.js";
9
9
  const PROMPTS_DIR = join(dirname(fileURLToPath(import.meta.url)), "prompts");
10
10
 
11
11
  export default function humanInTheLoop(pi: ExtensionAPI): void {
12
- pi.registerTool(createAskTool());
12
+ pi.registerTool(
13
+ createAskTool({
14
+ onBlockedChange: (state) => pi.events.emit("herdr:blocked", state),
15
+ }),
16
+ );
13
17
  pi.on("resources_discover", () => {
14
18
  const config = loadAskConfig();
15
19
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-ask",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Interactive decisions, review triage, and human handoffs for Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",