@zhigang1992/happy-cli 0.12.1 → 0.12.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 (37) hide show
  1. package/dist/{index-DsHtmQqP.mjs → index-BERBU6rR.mjs} +201 -23
  2. package/dist/{index-BOBrKhX5.cjs → index-CHEjP0zg.cjs} +215 -37
  3. package/dist/index.cjs +6 -6
  4. package/dist/index.mjs +6 -6
  5. package/dist/lib.cjs +1 -2
  6. package/dist/lib.d.cts +118 -4
  7. package/dist/lib.d.mts +118 -4
  8. package/dist/lib.mjs +1 -2
  9. package/dist/{list-hET5tyMc.mjs → list-BvtUKVTq.mjs} +1 -1
  10. package/dist/{list-BW6QBLa1.cjs → list-DOsBjFRJ.cjs} +1 -1
  11. package/dist/{prompt-Dz7G8yGx.mjs → prompt-BbMNN7fl.mjs} +1 -2
  12. package/dist/{prompt-DXkgjktW.cjs → prompt-Dh_trad0.cjs} +1 -2
  13. package/dist/{runCodex-CLGYMNs2.mjs → runCodex-CYkmZphO.mjs} +20 -4
  14. package/dist/{runCodex-CylcX5Ug.cjs → runCodex-DUqqO-m8.cjs} +20 -4
  15. package/dist/{types-CGco5Y-r.mjs → types-Cw6y7GyQ.mjs} +156 -20
  16. package/dist/{types-BsjUgWOx.cjs → types-Q-euvEmG.cjs} +154 -18
  17. package/package.json +2 -4
  18. package/scripts/download-tool.cjs +187 -0
  19. package/scripts/ripgrep_launcher.cjs +53 -2
  20. package/scripts/tools-config.cjs +119 -0
  21. package/tools/archives/difftastic-LICENSE +0 -21
  22. package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
  23. package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
  24. package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
  25. package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
  26. package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
  27. package/tools/archives/ripgrep-LICENSE +0 -3
  28. package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
  29. package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
  30. package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
  31. package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
  32. package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
  33. package/tools/licenses/difftastic-LICENSE +0 -21
  34. package/tools/licenses/ripgrep-LICENSE +0 -3
  35. package/tools/unpacked/difft +0 -0
  36. package/tools/unpacked/rg +0 -0
  37. package/tools/unpacked/ripgrep.node +0 -0
package/dist/lib.d.cts CHANGED
@@ -291,6 +291,16 @@ type RawJSONLines = z.infer<typeof RawJSONLinesSchema>;
291
291
  /**
292
292
  * Common RPC types and interfaces for both session and machine clients
293
293
  */
294
+ /**
295
+ * Session context for RPC handlers
296
+ * Contains environment and path information for the current session
297
+ */
298
+ interface RpcSessionContext {
299
+ /** Working directory path for the session */
300
+ path: string;
301
+ /** Environment variables (includes direnv if available) */
302
+ env: Record<string, string>;
303
+ }
294
304
  /**
295
305
  * Generic RPC handler function type
296
306
  * @template TRequest - The request data type
@@ -326,7 +336,19 @@ declare class RpcHandlerManager {
326
336
  private readonly encryptionVariant;
327
337
  private readonly logger;
328
338
  private socket;
339
+ private sessionContext;
329
340
  constructor(config: RpcHandlerConfig);
341
+ /**
342
+ * Set the session context (path and environment)
343
+ * This should be called after direnv environment is loaded
344
+ * @param context - The session context with path and environment
345
+ */
346
+ setSessionContext(context: RpcSessionContext): void;
347
+ /**
348
+ * Get the current session context
349
+ * @returns The session context or null if not set
350
+ */
351
+ getSessionContext(): RpcSessionContext | null;
330
352
  /**
331
353
  * Register an RPC handler for a specific method
332
354
  * @param method - The method name (without prefix)
@@ -423,6 +445,30 @@ declare class ApiSessionClient extends EventEmitter {
423
445
  */
424
446
  flush(): Promise<void>;
425
447
  close(): Promise<void>;
448
+ /**
449
+ * Download and decrypt a blob from the server
450
+ * @param blobId - The blob ID to download
451
+ * @returns The decrypted binary data and metadata, or null if download/decryption fails
452
+ */
453
+ downloadBlob(blobId: string): Promise<{
454
+ data: Uint8Array;
455
+ mimeType: string;
456
+ size: number;
457
+ } | null>;
458
+ /**
459
+ * Convert an image_ref content block to a Claude API image content block
460
+ * Downloads, decrypts, and base64 encodes the image
461
+ * @param imageRef - The image reference content block
462
+ * @returns Claude API image content block, or null if conversion fails
463
+ */
464
+ resolveImageRef(imageRef: ImageRefContent): Promise<{
465
+ type: 'image';
466
+ source: {
467
+ type: 'base64';
468
+ media_type: string;
469
+ data: string;
470
+ };
471
+ } | null>;
426
472
  }
427
473
 
428
474
  type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
@@ -505,9 +551,32 @@ type Machine = {
505
551
  daemonState: DaemonState | null;
506
552
  daemonStateVersion: number;
507
553
  };
554
+ /**
555
+ * Image reference content block for user messages (E2E encrypted images)
556
+ */
557
+ declare const ImageRefContentSchema: z.ZodObject<{
558
+ type: z.ZodLiteral<"image_ref">;
559
+ blobId: z.ZodString;
560
+ mimeType: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/webp"]>;
561
+ width: z.ZodOptional<z.ZodNumber>;
562
+ height: z.ZodOptional<z.ZodNumber>;
563
+ }, "strip", z.ZodTypeAny, {
564
+ type: "image_ref";
565
+ blobId: string;
566
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
567
+ width?: number | undefined;
568
+ height?: number | undefined;
569
+ }, {
570
+ type: "image_ref";
571
+ blobId: string;
572
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
573
+ width?: number | undefined;
574
+ height?: number | undefined;
575
+ }>;
576
+ type ImageRefContent = z.infer<typeof ImageRefContentSchema>;
508
577
  declare const UserMessageSchema: z.ZodObject<{
509
578
  role: z.ZodLiteral<"user">;
510
- content: z.ZodObject<{
579
+ content: z.ZodUnion<[z.ZodObject<{
511
580
  type: z.ZodLiteral<"text">;
512
581
  text: z.ZodString;
513
582
  }, "strip", z.ZodTypeAny, {
@@ -516,7 +585,34 @@ declare const UserMessageSchema: z.ZodObject<{
516
585
  }, {
517
586
  type: "text";
518
587
  text: string;
519
- }>;
588
+ }>, z.ZodArray<z.ZodUnion<[z.ZodObject<{
589
+ type: z.ZodLiteral<"text">;
590
+ text: z.ZodString;
591
+ }, "strip", z.ZodTypeAny, {
592
+ type: "text";
593
+ text: string;
594
+ }, {
595
+ type: "text";
596
+ text: string;
597
+ }>, z.ZodObject<{
598
+ type: z.ZodLiteral<"image_ref">;
599
+ blobId: z.ZodString;
600
+ mimeType: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/webp"]>;
601
+ width: z.ZodOptional<z.ZodNumber>;
602
+ height: z.ZodOptional<z.ZodNumber>;
603
+ }, "strip", z.ZodTypeAny, {
604
+ type: "image_ref";
605
+ blobId: string;
606
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
607
+ width?: number | undefined;
608
+ height?: number | undefined;
609
+ }, {
610
+ type: "image_ref";
611
+ blobId: string;
612
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
613
+ width?: number | undefined;
614
+ height?: number | undefined;
615
+ }>]>, "many">]>;
520
616
  localKey: z.ZodOptional<z.ZodString>;
521
617
  meta: z.ZodOptional<z.ZodObject<{
522
618
  sentFrom: z.ZodOptional<z.ZodString>;
@@ -550,7 +646,16 @@ declare const UserMessageSchema: z.ZodObject<{
550
646
  content: {
551
647
  type: "text";
552
648
  text: string;
553
- };
649
+ } | ({
650
+ type: "text";
651
+ text: string;
652
+ } | {
653
+ type: "image_ref";
654
+ blobId: string;
655
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
656
+ width?: number | undefined;
657
+ height?: number | undefined;
658
+ })[];
554
659
  role: "user";
555
660
  localKey?: string | undefined;
556
661
  meta?: {
@@ -567,7 +672,16 @@ declare const UserMessageSchema: z.ZodObject<{
567
672
  content: {
568
673
  type: "text";
569
674
  text: string;
570
- };
675
+ } | ({
676
+ type: "text";
677
+ text: string;
678
+ } | {
679
+ type: "image_ref";
680
+ blobId: string;
681
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
682
+ width?: number | undefined;
683
+ height?: number | undefined;
684
+ })[];
571
685
  role: "user";
572
686
  localKey?: string | undefined;
573
687
  meta?: {
package/dist/lib.d.mts CHANGED
@@ -291,6 +291,16 @@ type RawJSONLines = z.infer<typeof RawJSONLinesSchema>;
291
291
  /**
292
292
  * Common RPC types and interfaces for both session and machine clients
293
293
  */
294
+ /**
295
+ * Session context for RPC handlers
296
+ * Contains environment and path information for the current session
297
+ */
298
+ interface RpcSessionContext {
299
+ /** Working directory path for the session */
300
+ path: string;
301
+ /** Environment variables (includes direnv if available) */
302
+ env: Record<string, string>;
303
+ }
294
304
  /**
295
305
  * Generic RPC handler function type
296
306
  * @template TRequest - The request data type
@@ -326,7 +336,19 @@ declare class RpcHandlerManager {
326
336
  private readonly encryptionVariant;
327
337
  private readonly logger;
328
338
  private socket;
339
+ private sessionContext;
329
340
  constructor(config: RpcHandlerConfig);
341
+ /**
342
+ * Set the session context (path and environment)
343
+ * This should be called after direnv environment is loaded
344
+ * @param context - The session context with path and environment
345
+ */
346
+ setSessionContext(context: RpcSessionContext): void;
347
+ /**
348
+ * Get the current session context
349
+ * @returns The session context or null if not set
350
+ */
351
+ getSessionContext(): RpcSessionContext | null;
330
352
  /**
331
353
  * Register an RPC handler for a specific method
332
354
  * @param method - The method name (without prefix)
@@ -423,6 +445,30 @@ declare class ApiSessionClient extends EventEmitter {
423
445
  */
424
446
  flush(): Promise<void>;
425
447
  close(): Promise<void>;
448
+ /**
449
+ * Download and decrypt a blob from the server
450
+ * @param blobId - The blob ID to download
451
+ * @returns The decrypted binary data and metadata, or null if download/decryption fails
452
+ */
453
+ downloadBlob(blobId: string): Promise<{
454
+ data: Uint8Array;
455
+ mimeType: string;
456
+ size: number;
457
+ } | null>;
458
+ /**
459
+ * Convert an image_ref content block to a Claude API image content block
460
+ * Downloads, decrypts, and base64 encodes the image
461
+ * @param imageRef - The image reference content block
462
+ * @returns Claude API image content block, or null if conversion fails
463
+ */
464
+ resolveImageRef(imageRef: ImageRefContent): Promise<{
465
+ type: 'image';
466
+ source: {
467
+ type: 'base64';
468
+ media_type: string;
469
+ data: string;
470
+ };
471
+ } | null>;
426
472
  }
427
473
 
428
474
  type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
@@ -505,9 +551,32 @@ type Machine = {
505
551
  daemonState: DaemonState | null;
506
552
  daemonStateVersion: number;
507
553
  };
554
+ /**
555
+ * Image reference content block for user messages (E2E encrypted images)
556
+ */
557
+ declare const ImageRefContentSchema: z.ZodObject<{
558
+ type: z.ZodLiteral<"image_ref">;
559
+ blobId: z.ZodString;
560
+ mimeType: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/webp"]>;
561
+ width: z.ZodOptional<z.ZodNumber>;
562
+ height: z.ZodOptional<z.ZodNumber>;
563
+ }, "strip", z.ZodTypeAny, {
564
+ type: "image_ref";
565
+ blobId: string;
566
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
567
+ width?: number | undefined;
568
+ height?: number | undefined;
569
+ }, {
570
+ type: "image_ref";
571
+ blobId: string;
572
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
573
+ width?: number | undefined;
574
+ height?: number | undefined;
575
+ }>;
576
+ type ImageRefContent = z.infer<typeof ImageRefContentSchema>;
508
577
  declare const UserMessageSchema: z.ZodObject<{
509
578
  role: z.ZodLiteral<"user">;
510
- content: z.ZodObject<{
579
+ content: z.ZodUnion<[z.ZodObject<{
511
580
  type: z.ZodLiteral<"text">;
512
581
  text: z.ZodString;
513
582
  }, "strip", z.ZodTypeAny, {
@@ -516,7 +585,34 @@ declare const UserMessageSchema: z.ZodObject<{
516
585
  }, {
517
586
  type: "text";
518
587
  text: string;
519
- }>;
588
+ }>, z.ZodArray<z.ZodUnion<[z.ZodObject<{
589
+ type: z.ZodLiteral<"text">;
590
+ text: z.ZodString;
591
+ }, "strip", z.ZodTypeAny, {
592
+ type: "text";
593
+ text: string;
594
+ }, {
595
+ type: "text";
596
+ text: string;
597
+ }>, z.ZodObject<{
598
+ type: z.ZodLiteral<"image_ref">;
599
+ blobId: z.ZodString;
600
+ mimeType: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/webp"]>;
601
+ width: z.ZodOptional<z.ZodNumber>;
602
+ height: z.ZodOptional<z.ZodNumber>;
603
+ }, "strip", z.ZodTypeAny, {
604
+ type: "image_ref";
605
+ blobId: string;
606
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
607
+ width?: number | undefined;
608
+ height?: number | undefined;
609
+ }, {
610
+ type: "image_ref";
611
+ blobId: string;
612
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
613
+ width?: number | undefined;
614
+ height?: number | undefined;
615
+ }>]>, "many">]>;
520
616
  localKey: z.ZodOptional<z.ZodString>;
521
617
  meta: z.ZodOptional<z.ZodObject<{
522
618
  sentFrom: z.ZodOptional<z.ZodString>;
@@ -550,7 +646,16 @@ declare const UserMessageSchema: z.ZodObject<{
550
646
  content: {
551
647
  type: "text";
552
648
  text: string;
553
- };
649
+ } | ({
650
+ type: "text";
651
+ text: string;
652
+ } | {
653
+ type: "image_ref";
654
+ blobId: string;
655
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
656
+ width?: number | undefined;
657
+ height?: number | undefined;
658
+ })[];
554
659
  role: "user";
555
660
  localKey?: string | undefined;
556
661
  meta?: {
@@ -567,7 +672,16 @@ declare const UserMessageSchema: z.ZodObject<{
567
672
  content: {
568
673
  type: "text";
569
674
  text: string;
570
- };
675
+ } | ({
676
+ type: "text";
677
+ text: string;
678
+ } | {
679
+ type: "image_ref";
680
+ blobId: string;
681
+ mimeType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
682
+ width?: number | undefined;
683
+ height?: number | undefined;
684
+ })[];
571
685
  role: "user";
572
686
  localKey?: string | undefined;
573
687
  meta?: {
package/dist/lib.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-CGco5Y-r.mjs';
1
+ export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-Cw6y7GyQ.mjs';
2
2
  import 'axios';
3
3
  import 'chalk';
4
4
  import 'fs';
@@ -17,5 +17,4 @@ import 'fs/promises';
17
17
  import 'crypto';
18
18
  import 'path';
19
19
  import 'url';
20
- import 'os';
21
20
  import 'expo-server-sdk';
@@ -1,4 +1,4 @@
1
- import { c as configuration, l as logger, d as decodeBase64, b as decrypt, f as formatTimeAgo, e as libsodiumDecryptFromPublicKey } from './types-CGco5Y-r.mjs';
1
+ import { c as configuration, l as logger, d as decodeBase64, b as decrypt, f as formatTimeAgo, e as libsodiumDecryptFromPublicKey } from './types-Cw6y7GyQ.mjs';
2
2
  import axios from 'axios';
3
3
  import { existsSync, readdirSync, statSync, readFileSync } from 'fs';
4
4
  import { join } from 'path';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var types = require('./types-BsjUgWOx.cjs');
3
+ var types = require('./types-Q-euvEmG.cjs');
4
4
  var axios = require('axios');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
@@ -1,4 +1,4 @@
1
- import { c as configuration, b as decrypt, d as decodeBase64, l as logger, g as encodeBase64, h as encrypt } from './types-CGco5Y-r.mjs';
1
+ import { c as configuration, b as decrypt, d as decodeBase64, l as logger, g as encodeBase64, h as encrypt } from './types-Cw6y7GyQ.mjs';
2
2
  import axios from 'axios';
3
3
  import { io } from 'socket.io-client';
4
4
  import 'chalk';
@@ -17,7 +17,6 @@ import 'fs/promises';
17
17
  import 'crypto';
18
18
  import 'path';
19
19
  import 'url';
20
- import 'os';
21
20
  import 'expo-server-sdk';
22
21
 
23
22
  const DEFAULT_TIMEOUT_MINUTES = 20;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var types = require('./types-BsjUgWOx.cjs');
3
+ var types = require('./types-Q-euvEmG.cjs');
4
4
  var axios = require('axios');
5
5
  var socket_ioClient = require('socket.io-client');
6
6
  require('chalk');
@@ -19,7 +19,6 @@ require('fs/promises');
19
19
  require('crypto');
20
20
  require('path');
21
21
  require('url');
22
- require('os');
23
22
  require('expo-server-sdk');
24
23
 
25
24
  const DEFAULT_TIMEOUT_MINUTES = 20;
@@ -1,13 +1,13 @@
1
1
  import { useStdout, useInput, Box, Text, render } from 'ink';
2
2
  import React, { useState, useRef, useEffect, useCallback } from 'react';
3
- import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, i as packageJson } from './types-CGco5Y-r.mjs';
3
+ import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, i as packageJson } from './types-Cw6y7GyQ.mjs';
4
4
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
5
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
6
6
  import { z } from 'zod';
7
7
  import { ElicitRequestSchema } from '@modelcontextprotocol/sdk/types.js';
8
8
  import { execSync } from 'child_process';
9
9
  import { randomUUID } from 'node:crypto';
10
- import { i as initialMachineMetadata, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler, a as MessageBuffer, s as startHappyServer, t as trimIdent, b as stopCaffeinate } from './index-DsHtmQqP.mjs';
10
+ import { i as initialMachineMetadata, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler, a as MessageBuffer, s as startHappyServer, t as trimIdent, b as stopCaffeinate } from './index-BERBU6rR.mjs';
11
11
  import os from 'node:os';
12
12
  import { resolve, join } from 'node:path';
13
13
  import fs from 'node:fs';
@@ -23,13 +23,13 @@ import 'fs/promises';
23
23
  import 'crypto';
24
24
  import 'path';
25
25
  import 'url';
26
- import 'os';
27
26
  import 'expo-server-sdk';
28
27
  import 'node:child_process';
29
28
  import 'node:readline';
30
29
  import 'node:url';
31
30
  import 'ps-list';
32
31
  import 'cross-spawn';
32
+ import 'os';
33
33
  import 'tmp';
34
34
  import 'qrcode-terminal';
35
35
  import 'open';
@@ -752,6 +752,21 @@ const CodexDisplay = ({ messageBuffer, logPath, onExit }) => {
752
752
  ));
753
753
  };
754
754
 
755
+ function extractTextFromContent(content) {
756
+ if (!Array.isArray(content)) {
757
+ if (content.type === "text") {
758
+ return content.text;
759
+ }
760
+ return "";
761
+ }
762
+ const textParts = [];
763
+ for (const block of content) {
764
+ if (block.type === "text") {
765
+ textParts.push(block.text);
766
+ }
767
+ }
768
+ return textParts.join("\n");
769
+ }
755
770
  function emitReadyIfIdle({ pending, queueSize, shouldExit, sendReady, notify }) {
756
771
  if (shouldExit) {
757
772
  return false;
@@ -847,7 +862,8 @@ async function runCodex(opts) {
847
862
  permissionMode: messagePermissionMode || "default",
848
863
  model: messageModel
849
864
  };
850
- messageQueue.push(message.content.text, enhancedMode);
865
+ const textContent = extractTextFromContent(message.content);
866
+ messageQueue.push(textContent, enhancedMode);
851
867
  });
852
868
  let thinking = false;
853
869
  session.keepAlive(thinking, "remote");
@@ -2,14 +2,14 @@
2
2
 
3
3
  var ink = require('ink');
4
4
  var React = require('react');
5
- var types = require('./types-BsjUgWOx.cjs');
5
+ var types = require('./types-Q-euvEmG.cjs');
6
6
  var index_js = require('@modelcontextprotocol/sdk/client/index.js');
7
7
  var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
8
8
  var z = require('zod');
9
9
  var types_js = require('@modelcontextprotocol/sdk/types.js');
10
10
  var child_process = require('child_process');
11
11
  var node_crypto = require('node:crypto');
12
- var index = require('./index-BOBrKhX5.cjs');
12
+ var index = require('./index-CHEjP0zg.cjs');
13
13
  var os = require('node:os');
14
14
  var node_path = require('node:path');
15
15
  var fs = require('node:fs');
@@ -25,13 +25,13 @@ require('fs/promises');
25
25
  require('crypto');
26
26
  require('path');
27
27
  require('url');
28
- require('os');
29
28
  require('expo-server-sdk');
30
29
  require('node:child_process');
31
30
  require('node:readline');
32
31
  require('node:url');
33
32
  require('ps-list');
34
33
  require('cross-spawn');
34
+ require('os');
35
35
  require('tmp');
36
36
  require('qrcode-terminal');
37
37
  require('open');
@@ -754,6 +754,21 @@ const CodexDisplay = ({ messageBuffer, logPath, onExit }) => {
754
754
  ));
755
755
  };
756
756
 
757
+ function extractTextFromContent(content) {
758
+ if (!Array.isArray(content)) {
759
+ if (content.type === "text") {
760
+ return content.text;
761
+ }
762
+ return "";
763
+ }
764
+ const textParts = [];
765
+ for (const block of content) {
766
+ if (block.type === "text") {
767
+ textParts.push(block.text);
768
+ }
769
+ }
770
+ return textParts.join("\n");
771
+ }
757
772
  function emitReadyIfIdle({ pending, queueSize, shouldExit, sendReady, notify }) {
758
773
  if (shouldExit) {
759
774
  return false;
@@ -849,7 +864,8 @@ async function runCodex(opts) {
849
864
  permissionMode: messagePermissionMode || "default",
850
865
  model: messageModel
851
866
  };
852
- messageQueue.push(message.content.text, enhancedMode);
867
+ const textContent = extractTextFromContent(message.content);
868
+ messageQueue.push(textContent, enhancedMode);
853
869
  });
854
870
  let thinking = false;
855
871
  session.keepAlive(thinking, "remote");