@co0ontty/wand 1.18.12 → 1.21.4

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 (39) hide show
  1. package/dist/claude-pty-bridge.d.ts +8 -0
  2. package/dist/claude-pty-bridge.js +34 -11
  3. package/dist/cli.js +72 -5
  4. package/dist/ensure-node-pty-helper.d.ts +1 -0
  5. package/dist/ensure-node-pty-helper.js +51 -0
  6. package/dist/git-quick-commit.d.ts +18 -0
  7. package/dist/git-quick-commit.js +381 -0
  8. package/dist/models.d.ts +3 -1
  9. package/dist/models.js +45 -7
  10. package/dist/process-manager.d.ts +6 -8
  11. package/dist/process-manager.js +90 -176
  12. package/dist/prompt-optimizer.d.ts +5 -0
  13. package/dist/prompt-optimizer.js +72 -0
  14. package/dist/pty-text-utils.d.ts +25 -1
  15. package/dist/pty-text-utils.js +158 -2
  16. package/dist/server-session-routes.d.ts +2 -2
  17. package/dist/server-session-routes.js +94 -8
  18. package/dist/server.d.ts +22 -1
  19. package/dist/server.js +138 -16
  20. package/dist/session-logger.d.ts +15 -4
  21. package/dist/session-logger.js +52 -4
  22. package/dist/structured-session-manager.d.ts +12 -2
  23. package/dist/structured-session-manager.js +465 -22
  24. package/dist/tui/index.d.ts +24 -0
  25. package/dist/tui/index.js +138 -0
  26. package/dist/tui/layout.d.ts +25 -0
  27. package/dist/tui/layout.js +198 -0
  28. package/dist/tui/log-bus.d.ts +23 -0
  29. package/dist/tui/log-bus.js +111 -0
  30. package/dist/tui/relative-time.d.ts +4 -0
  31. package/dist/tui/relative-time.js +27 -0
  32. package/dist/tui/session-formatter.d.ts +17 -0
  33. package/dist/tui/session-formatter.js +111 -0
  34. package/dist/types.d.ts +55 -2
  35. package/dist/web-ui/content/scripts.js +1371 -261
  36. package/dist/web-ui/content/styles.css +436 -9
  37. package/dist/web-ui/content/vendor/wterm/wterm.bundle.js +1 -1
  38. package/dist/ws-broadcast.js +74 -12
  39. package/package.json +3 -1
@@ -24,10 +24,13 @@ export interface ShortcutLogContext {
24
24
  * SessionLogger saves raw session content to local files for debugging and analysis.
25
25
  *
26
26
  * Directory structure: .wand/sessions/{sessionId}/
27
- * - pty-output.log Raw PTY output (current, rotated when > 50 MB)
28
- * - pty-output.log.1..3 Rotated PTY output backups
29
- * - stream-events.jsonl NDJSON events from native mode (append-only)
30
- * - messages.json Final structured messages (overwritten on each update)
27
+ * - pty-output.log Raw PTY output (current, rotated when > 50 MB)
28
+ * - pty-output.log.1..3 Rotated PTY output backups
29
+ * - stream-events.jsonl NDJSON events from native mode (append-only)
30
+ * - messages.json Final structured messages (overwritten on each update)
31
+ * - structured-stdout.log Raw stdout from `codex exec` / `claude -p` child (append-only)
32
+ * - structured-stderr.log Raw stderr from the same child (append-only)
33
+ * - structured-spawns.jsonl One line per spawn: args/pid/cwd/exit/error metadata
31
34
  */
32
35
  export declare class SessionLogger {
33
36
  private readonly baseDir;
@@ -48,6 +51,14 @@ export declare class SessionLogger {
48
51
  readPtyOutput(sessionId: string): string | null;
49
52
  /** Append a native mode NDJSON event */
50
53
  appendStreamEvent(sessionId: string, event: unknown): void;
54
+ /** Append raw stdout chunk from a structured-mode child process. */
55
+ appendStructuredStdout(sessionId: string, chunk: string): void;
56
+ /** Append raw stderr chunk from a structured-mode child process. */
57
+ appendStructuredStderr(sessionId: string, chunk: string): void;
58
+ /** Append a spawn metadata record (args, pid, cwd, exit, errors, …) for a structured run. */
59
+ appendStructuredSpawn(sessionId: string, meta: Record<string, unknown>): void;
60
+ /** Read recent stderr tail (for surfacing in failure messages). */
61
+ readStructuredStderrTail(sessionId: string, maxBytes?: number): string;
51
62
  /** Save the current structured messages snapshot */
52
63
  saveMessages(sessionId: string, messages: ConversationTurn[]): void;
53
64
  /** Save session metadata */
@@ -12,10 +12,13 @@ const DEFAULT_SHORTCUT_LOG_MAX_BYTES = 10 * 1024 * 1024;
12
12
  * SessionLogger saves raw session content to local files for debugging and analysis.
13
13
  *
14
14
  * Directory structure: .wand/sessions/{sessionId}/
15
- * - pty-output.log Raw PTY output (current, rotated when > 50 MB)
16
- * - pty-output.log.1..3 Rotated PTY output backups
17
- * - stream-events.jsonl NDJSON events from native mode (append-only)
18
- * - messages.json Final structured messages (overwritten on each update)
15
+ * - pty-output.log Raw PTY output (current, rotated when > 50 MB)
16
+ * - pty-output.log.1..3 Rotated PTY output backups
17
+ * - stream-events.jsonl NDJSON events from native mode (append-only)
18
+ * - messages.json Final structured messages (overwritten on each update)
19
+ * - structured-stdout.log Raw stdout from `codex exec` / `claude -p` child (append-only)
20
+ * - structured-stderr.log Raw stderr from the same child (append-only)
21
+ * - structured-spawns.jsonl One line per spawn: args/pid/cwd/exit/error metadata
19
22
  */
20
23
  export class SessionLogger {
21
24
  baseDir;
@@ -122,6 +125,51 @@ export class SessionLogger {
122
125
  // Non-critical
123
126
  }
124
127
  }
128
+ /** Append raw stdout chunk from a structured-mode child process. */
129
+ appendStructuredStdout(sessionId, chunk) {
130
+ try {
131
+ const dir = this.ensureDir(sessionId);
132
+ appendFileSync(path.join(dir, "structured-stdout.log"), chunk);
133
+ }
134
+ catch {
135
+ // Non-critical
136
+ }
137
+ }
138
+ /** Append raw stderr chunk from a structured-mode child process. */
139
+ appendStructuredStderr(sessionId, chunk) {
140
+ try {
141
+ const dir = this.ensureDir(sessionId);
142
+ appendFileSync(path.join(dir, "structured-stderr.log"), chunk);
143
+ }
144
+ catch {
145
+ // Non-critical
146
+ }
147
+ }
148
+ /** Append a spawn metadata record (args, pid, cwd, exit, errors, …) for a structured run. */
149
+ appendStructuredSpawn(sessionId, meta) {
150
+ try {
151
+ const dir = this.ensureDir(sessionId);
152
+ const entry = JSON.stringify({ ts: new Date().toISOString(), ...meta }) + "\n";
153
+ appendFileSync(path.join(dir, "structured-spawns.jsonl"), entry);
154
+ }
155
+ catch {
156
+ // Non-critical
157
+ }
158
+ }
159
+ /** Read recent stderr tail (for surfacing in failure messages). */
160
+ readStructuredStderrTail(sessionId, maxBytes = 4096) {
161
+ try {
162
+ const dir = this.ensureDir(sessionId);
163
+ const filePath = path.join(dir, "structured-stderr.log");
164
+ if (!existsSync(filePath))
165
+ return "";
166
+ const content = readFileSync(filePath, "utf8");
167
+ return content.length <= maxBytes ? content : content.slice(content.length - maxBytes);
168
+ }
169
+ catch {
170
+ return "";
171
+ }
172
+ }
125
173
  /** Save the current structured messages snapshot */
126
174
  saveMessages(sessionId, messages) {
127
175
  try {
@@ -1,9 +1,11 @@
1
+ import { SessionLogger } from "./session-logger.js";
1
2
  import { WandStorage } from "./storage.js";
2
- import { ExecutionMode, ProcessEvent, SessionRunner, SessionSnapshot, WandConfig } from "./types.js";
3
+ import { ExecutionMode, ProcessEvent, SessionProvider, SessionRunner, SessionSnapshot, WandConfig } from "./types.js";
3
4
  interface CreateStructuredSessionOptions {
4
5
  cwd: string;
5
6
  mode: ExecutionMode;
6
7
  prompt?: string;
8
+ provider?: SessionProvider;
7
9
  runner?: SessionRunner;
8
10
  worktreeEnabled?: boolean;
9
11
  /** 用户指定的 Claude 模型(别名或完整 ID)。留空则 spawn 时不加 --model。 */
@@ -12,12 +14,13 @@ interface CreateStructuredSessionOptions {
12
14
  export declare class StructuredSessionManager {
13
15
  private readonly storage;
14
16
  private readonly config;
17
+ private readonly logger;
15
18
  private readonly sessions;
16
19
  private readonly pendingChildren;
17
20
  private readonly interruptedWith;
18
21
  private emitEvent;
19
22
  private archiveTimer;
20
- constructor(storage: WandStorage, config: WandConfig);
23
+ constructor(storage: WandStorage, config: WandConfig, logger?: SessionLogger | null);
21
24
  private archiveExpiredSessions;
22
25
  setEventEmitter(emitEvent: (event: ProcessEvent) => void): void;
23
26
  list(): SessionSnapshot[];
@@ -49,6 +52,8 @@ export declare class StructuredSessionManager {
49
52
  private resolvePermission;
50
53
  private incrementApprovalStats;
51
54
  private buildPermissionArgs;
55
+ private buildCodexArgs;
56
+ private runCodexStreaming;
52
57
  /**
53
58
  * Spawn `claude -p --output-format stream-json` and parse NDJSON lines as
54
59
  * they arrive, emitting incremental WebSocket events so the UI can render
@@ -65,7 +70,12 @@ export declare class StructuredSessionManager {
65
70
  private compactContentBlocks;
66
71
  private normalizeToolInput;
67
72
  private normalizeToolResultContent;
73
+ private extractCodexText;
74
+ private extractCodexItemBlock;
75
+ private upsertCodexBlock;
76
+ private finishStructuredFailure;
68
77
  private extractModelName;
69
78
  private extractUsage;
79
+ private extractCodexUsage;
70
80
  }
71
81
  export {};