@co0ontty/wand 0.2.0 → 0.3.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.
@@ -2,16 +2,28 @@ import { EventEmitter } from "node:events";
2
2
  import { WandStorage } from "./storage.js";
3
3
  import { ExecutionMode, SessionSnapshot, WandConfig } from "./types.js";
4
4
  export interface ProcessEvent {
5
- type: "output" | "status" | "started" | "ended";
5
+ type: "output" | "status" | "started" | "ended" | "usage" | "task";
6
6
  sessionId: string;
7
7
  data?: unknown;
8
8
  }
9
+ /** Human-readable task information for the UI */
10
+ export interface TaskInfo {
11
+ title: string;
12
+ tool?: string;
13
+ }
14
+ export declare class SessionInputError extends Error {
15
+ readonly code: "SESSION_NOT_FOUND" | "SESSION_NOT_RUNNING" | "SESSION_NO_PTY";
16
+ readonly sessionId: string;
17
+ readonly sessionStatus?: SessionSnapshot["status"] | undefined;
18
+ constructor(message: string, code: "SESSION_NOT_FOUND" | "SESSION_NOT_RUNNING" | "SESSION_NO_PTY", sessionId: string, sessionStatus?: SessionSnapshot["status"] | undefined);
19
+ }
9
20
  export type ProcessEventHandler = (event: ProcessEvent) => void;
10
21
  export declare class ProcessManager extends EventEmitter {
11
22
  private readonly config;
12
23
  private readonly storage;
13
24
  private readonly sessions;
14
25
  private readonly logger;
26
+ private readonly lifecycleManager;
15
27
  constructor(config: WandConfig, storage: WandStorage, configDir?: string);
16
28
  on(event: "process", listener: ProcessEventHandler): this;
17
29
  private emitEvent;
@@ -20,40 +32,35 @@ export declare class ProcessManager extends EventEmitter {
20
32
  list(): SessionSnapshot[];
21
33
  get(id: string): SessionSnapshot | null;
22
34
  sendInput(id: string, input: string, view?: "chat" | "terminal"): SessionSnapshot;
23
- private runJsonChatTurn;
24
- /**
25
- * Wrap user message with autonomous completion instructions for managed mode.
26
- * The AI is told to complete the task in one shot without asking questions.
27
- */
28
- private wrapManagedPrompt;
29
- private processJsonEvent;
30
- private appendBlockToOutput;
31
- private buildContentBlocks;
32
- private buildAssistantTurn;
33
- /** Determine if input looks like a real chat message (not control characters) */
34
- private isRealChatInput;
35
- /** Check if a command is a Claude CLI command */
36
- private isClaudeCommand;
37
- /** Strip ANSI escape sequences from raw PTY output */
38
- private stripAnsiSequences;
39
- /** Track and update assistant response from PTY output */
40
- private trackPtyAssistantResponse;
41
- /** Update the assistant placeholder message with cleaned PTY content */
42
- private updatePtyAssistantContent;
43
- /** Finalize the assistant message when ❯ prompt is detected */
44
- private finalizePtyAssistantMessage;
45
- /** Clean raw PTY output into readable chat content */
46
- private cleanPtyOutputForChat;
35
+ /** Emit a task event for a session, debounced to avoid flooding */
36
+ private emitTask;
47
37
  resize(id: string, cols: number, rows: number): SessionSnapshot;
48
38
  stop(id: string): SessionSnapshot;
49
39
  delete(id: string): void;
50
40
  runStartupCommands(): Promise<SessionSnapshot[]>;
51
41
  private snapshot;
42
+ private isPermissionBlocked;
43
+ private defaultAutonomyPolicy;
44
+ resolveEscalation(id: string, requestId: string, resolution?: "approve_once" | "approve_turn" | "deny"): SessionSnapshot;
45
+ approvePermission(id: string): SessionSnapshot;
46
+ denyPermission(id: string): SessionSnapshot;
47
+ /**
48
+ * Resolve permission with specific resolution type.
49
+ * @param resolution - "approve_once", "approve_turn", or "deny"
50
+ */
51
+ resolvePermission(id: string, resolution: "approve_once" | "approve_turn" | "deny"): SessionSnapshot;
52
52
  private persist;
53
53
  private archiveExpiredSessions;
54
54
  private assertCommandAllowed;
55
55
  private autoConfirmWithRecord;
56
+ /**
57
+ * Handle events from ClaudePtyBridge
58
+ */
59
+ private handleBridgeEvent;
60
+ /** Check if a command is a Claude CLI command */
61
+ private isClaudeCommand;
56
62
  private mustGet;
57
63
  private buildShellArgs;
64
+ private shouldAutoApprovePermissions;
58
65
  private processCommandForMode;
59
66
  }