happy-imou-cloud 2.1.30 → 2.1.32

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 (25) hide show
  1. package/dist/{BaseReasoningProcessor-Ch9R4qmn.cjs → BaseReasoningProcessor-CQQrYyo3.cjs} +4 -3
  2. package/dist/{BaseReasoningProcessor-C1iacoJW.mjs → BaseReasoningProcessor-CfibmGoR.mjs} +4 -3
  3. package/dist/{ProviderSelectionHandler-2siFKlgs.mjs → ProviderSelectionHandler-C1q60HP6.mjs} +2 -2
  4. package/dist/{ProviderSelectionHandler-Dx6x0Nd4.cjs → ProviderSelectionHandler-D9Bd_S25.cjs} +2 -2
  5. package/dist/{api-C68U-kRs.mjs → api-DIFbsA6t.mjs} +21 -3
  6. package/dist/{api-DK1gyZAZ.cjs → api-DeDVledu.cjs} +21 -3
  7. package/dist/{command-Cb9nikZh.cjs → command-Cl7kVs7K.cjs} +2 -2
  8. package/dist/{command-D32x08k9.mjs → command-ZJ5yPOv4.mjs} +2 -2
  9. package/dist/{index-DQ76ZTNL.mjs → index-CFH8qcTw.mjs} +209 -21
  10. package/dist/{index-BLeiCte-.cjs → index-CT1dgGsX.cjs} +211 -23
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.mjs +2 -2
  13. package/dist/lib.cjs +1 -1
  14. package/dist/lib.d.cts +30 -0
  15. package/dist/lib.d.mts +30 -0
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{registerKillSessionHandler-DD9uUk4w.cjs → registerKillSessionHandler-9O3r5bEa.cjs} +18 -5
  18. package/dist/{registerKillSessionHandler-CadrzRgP.mjs → registerKillSessionHandler-DxpGgu6u.mjs} +18 -5
  19. package/dist/{runClaude-U9sxsnU-.cjs → runClaude-BmW-_Yrl.cjs} +8 -6
  20. package/dist/{runClaude-CkY6XYJa.mjs → runClaude-BvRjHUgF.mjs} +8 -6
  21. package/dist/{runCodex-C6kV0jfX.mjs → runCodex-B-B9MfOf.mjs} +21 -12
  22. package/dist/{runCodex-Beikmv-L.cjs → runCodex-dmjiaB1v.cjs} +21 -12
  23. package/dist/{runGemini-IEzJdhc-.mjs → runGemini-B9W7nfow.mjs} +4 -4
  24. package/dist/{runGemini-BTyqf5MR.cjs → runGemini-CyERhKhw.cjs} +4 -4
  25. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BLeiCte-.cjs');
4
- var persistence = require('./api-DK1gyZAZ.cjs');
3
+ var index = require('./index-CT1dgGsX.cjs');
4
+ var persistence = require('./api-DeDVledu.cjs');
5
5
  var node_events = require('node:events');
6
6
  var node_crypto = require('node:crypto');
7
7
 
@@ -85,7 +85,7 @@ function setupOfflineReconnection(opts) {
85
85
  }
86
86
 
87
87
  async function bootstrapManagedProviderSession(opts) {
88
- const { state, metadata } = index.createSessionMetadata({
88
+ const { state, metadata, happyOrgStartupBinding } = index.createSessionMetadata({
89
89
  flavor: opts.flavor,
90
90
  machineId: opts.machineId,
91
91
  startedBy: opts.startedBy,
@@ -136,6 +136,7 @@ async function bootstrapManagedProviderSession(opts) {
136
136
  return {
137
137
  state,
138
138
  metadata,
139
+ happyOrgStartupBinding,
139
140
  response,
140
141
  session,
141
142
  reconnectionHandle
@@ -1,5 +1,5 @@
1
- import { a as createSessionMetadata, p as publishSessionRegistration } from './index-DQ76ZTNL.mjs';
2
- import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-C68U-kRs.mjs';
1
+ import { a as createSessionMetadata, p as publishSessionRegistration } from './index-CFH8qcTw.mjs';
2
+ import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-DIFbsA6t.mjs';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { randomUUID } from 'node:crypto';
5
5
 
@@ -83,7 +83,7 @@ function setupOfflineReconnection(opts) {
83
83
  }
84
84
 
85
85
  async function bootstrapManagedProviderSession(opts) {
86
- const { state, metadata } = createSessionMetadata({
86
+ const { state, metadata, happyOrgStartupBinding } = createSessionMetadata({
87
87
  flavor: opts.flavor,
88
88
  machineId: opts.machineId,
89
89
  startedBy: opts.startedBy,
@@ -134,6 +134,7 @@ async function bootstrapManagedProviderSession(opts) {
134
134
  return {
135
135
  state,
136
136
  metadata,
137
+ happyOrgStartupBinding,
137
138
  response,
138
139
  session,
139
140
  reconnectionHandle
@@ -1,5 +1,5 @@
1
- import { l as logger } from './api-C68U-kRs.mjs';
2
- import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-CadrzRgP.mjs';
1
+ import { l as logger } from './api-DIFbsA6t.mjs';
2
+ import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-DxpGgu6u.mjs';
3
3
 
4
4
  async function runModeLoop(opts) {
5
5
  let currentMode = opts.startingMode;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var persistence = require('./api-DK1gyZAZ.cjs');
4
- var registerKillSessionHandler = require('./registerKillSessionHandler-DD9uUk4w.cjs');
3
+ var persistence = require('./api-DeDVledu.cjs');
4
+ var registerKillSessionHandler = require('./registerKillSessionHandler-9O3r5bEa.cjs');
5
5
 
6
6
  async function runModeLoop(opts) {
7
7
  let currentMode = opts.startingMode;
@@ -18,7 +18,7 @@ import { spawn } from 'node:child_process';
18
18
  import { Expo } from 'expo-server-sdk';
19
19
 
20
20
  var name = "happy-imou-cloud";
21
- var version = "2.1.30";
21
+ var version = "2.1.32";
22
22
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
23
23
  var author = "long.zhu";
24
24
  var license = "MIT";
@@ -1206,9 +1206,15 @@ const HappyOrgTurnStatusSchema = z$1.enum([
1206
1206
  "task_complete",
1207
1207
  "turn_aborted"
1208
1208
  ]);
1209
+ const HappyOrgAccessChannelStateSchema = z$1.enum([
1210
+ "ok",
1211
+ "reattach_required",
1212
+ "runtime_replaced"
1213
+ ]);
1209
1214
  const HappyOrgTaskContextSchema = z$1.object({
1210
1215
  taskId: z$1.string().min(1),
1211
1216
  organizationId: z$1.string().min(1),
1217
+ organizationRootPath: z$1.string().min(1).optional().nullable(),
1212
1218
  memberAgentId: z$1.string().min(1),
1213
1219
  supervisorAgentId: z$1.string().min(1),
1214
1220
  positionId: z$1.string().min(1).optional().nullable(),
@@ -1261,7 +1267,8 @@ z$1.object({
1261
1267
  interventionType: HappyOrgInterventionTypeSchema.optional().nullable(),
1262
1268
  blockerCode: z$1.string().optional().nullable(),
1263
1269
  decisionNeeded: z$1.string().optional().nullable(),
1264
- targetArtifact: z$1.string().optional().nullable()
1270
+ targetArtifact: z$1.string().optional().nullable(),
1271
+ accessChannelState: HappyOrgAccessChannelStateSchema.optional().nullable()
1265
1272
  });
1266
1273
  const HappyOrgTurnReportSchema = HappyOrgTaskContextSchema.extend({
1267
1274
  turnStatus: HappyOrgTurnStatusSchema,
@@ -1270,6 +1277,7 @@ const HappyOrgTurnReportSchema = HappyOrgTaskContextSchema.extend({
1270
1277
  blockerCode: z$1.string().nullable(),
1271
1278
  decisionNeeded: z$1.string().nullable(),
1272
1279
  targetArtifact: z$1.string().nullable(),
1280
+ accessChannelState: HappyOrgAccessChannelStateSchema.nullable(),
1273
1281
  repeatFingerprint: z$1.string().nullable(),
1274
1282
  replyContext: HappyOrgReplyContextSchema.nullish(),
1275
1283
  specialistHome: HappyOrgSpecialistHomeIdentitySchema.nullish()
@@ -2876,14 +2884,24 @@ function buildSessionRuntimeIndex(metadata) {
2876
2884
  };
2877
2885
  }
2878
2886
 
2887
+ function shouldPreserveCurrentHostPid(current, next) {
2888
+ if (typeof current?.hostPid !== "number") {
2889
+ return false;
2890
+ }
2891
+ if (current.hostPid !== process.pid) {
2892
+ return false;
2893
+ }
2894
+ return typeof next.hostPid !== "number" || next.hostPid !== current.hostPid;
2895
+ }
2879
2896
  function preserveSessionRuntimeMetadata(current, next) {
2880
2897
  if (!current) {
2881
2898
  return next;
2882
2899
  }
2900
+ const preserveCurrentHostPid = shouldPreserveCurrentHostPid(current, next);
2883
2901
  return {
2884
2902
  ...next,
2885
2903
  ...next.machineId ? {} : current.machineId ? { machineId: current.machineId } : {},
2886
- ...typeof next.hostPid === "number" ? {} : typeof current.hostPid === "number" ? { hostPid: current.hostPid } : {},
2904
+ ...typeof next.hostPid === "number" && !preserveCurrentHostPid ? {} : typeof current.hostPid === "number" ? { hostPid: current.hostPid } : {},
2887
2905
  ...typeof next.startedFromDaemon === "boolean" ? {} : typeof current.startedFromDaemon === "boolean" ? { startedFromDaemon: current.startedFromDaemon } : {},
2888
2906
  ...next.startedBy ? {} : current.startedBy ? { startedBy: current.startedBy } : {},
2889
2907
  ...next.lifecycleState ? {} : current.lifecycleState ? { lifecycleState: current.lifecycleState } : {},
@@ -38,7 +38,7 @@ function _interopNamespaceDefault(e) {
38
38
  var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
39
39
 
40
40
  var name = "happy-imou-cloud";
41
- var version = "2.1.30";
41
+ var version = "2.1.32";
42
42
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
43
43
  var author = "long.zhu";
44
44
  var license = "MIT";
@@ -1226,9 +1226,15 @@ const HappyOrgTurnStatusSchema = z.z.enum([
1226
1226
  "task_complete",
1227
1227
  "turn_aborted"
1228
1228
  ]);
1229
+ const HappyOrgAccessChannelStateSchema = z.z.enum([
1230
+ "ok",
1231
+ "reattach_required",
1232
+ "runtime_replaced"
1233
+ ]);
1229
1234
  const HappyOrgTaskContextSchema = z.z.object({
1230
1235
  taskId: z.z.string().min(1),
1231
1236
  organizationId: z.z.string().min(1),
1237
+ organizationRootPath: z.z.string().min(1).optional().nullable(),
1232
1238
  memberAgentId: z.z.string().min(1),
1233
1239
  supervisorAgentId: z.z.string().min(1),
1234
1240
  positionId: z.z.string().min(1).optional().nullable(),
@@ -1281,7 +1287,8 @@ z.z.object({
1281
1287
  interventionType: HappyOrgInterventionTypeSchema.optional().nullable(),
1282
1288
  blockerCode: z.z.string().optional().nullable(),
1283
1289
  decisionNeeded: z.z.string().optional().nullable(),
1284
- targetArtifact: z.z.string().optional().nullable()
1290
+ targetArtifact: z.z.string().optional().nullable(),
1291
+ accessChannelState: HappyOrgAccessChannelStateSchema.optional().nullable()
1285
1292
  });
1286
1293
  const HappyOrgTurnReportSchema = HappyOrgTaskContextSchema.extend({
1287
1294
  turnStatus: HappyOrgTurnStatusSchema,
@@ -1290,6 +1297,7 @@ const HappyOrgTurnReportSchema = HappyOrgTaskContextSchema.extend({
1290
1297
  blockerCode: z.z.string().nullable(),
1291
1298
  decisionNeeded: z.z.string().nullable(),
1292
1299
  targetArtifact: z.z.string().nullable(),
1300
+ accessChannelState: HappyOrgAccessChannelStateSchema.nullable(),
1293
1301
  repeatFingerprint: z.z.string().nullable(),
1294
1302
  replyContext: HappyOrgReplyContextSchema.nullish(),
1295
1303
  specialistHome: HappyOrgSpecialistHomeIdentitySchema.nullish()
@@ -2896,14 +2904,24 @@ function buildSessionRuntimeIndex(metadata) {
2896
2904
  };
2897
2905
  }
2898
2906
 
2907
+ function shouldPreserveCurrentHostPid(current, next) {
2908
+ if (typeof current?.hostPid !== "number") {
2909
+ return false;
2910
+ }
2911
+ if (current.hostPid !== process.pid) {
2912
+ return false;
2913
+ }
2914
+ return typeof next.hostPid !== "number" || next.hostPid !== current.hostPid;
2915
+ }
2899
2916
  function preserveSessionRuntimeMetadata(current, next) {
2900
2917
  if (!current) {
2901
2918
  return next;
2902
2919
  }
2920
+ const preserveCurrentHostPid = shouldPreserveCurrentHostPid(current, next);
2903
2921
  return {
2904
2922
  ...next,
2905
2923
  ...next.machineId ? {} : current.machineId ? { machineId: current.machineId } : {},
2906
- ...typeof next.hostPid === "number" ? {} : typeof current.hostPid === "number" ? { hostPid: current.hostPid } : {},
2924
+ ...typeof next.hostPid === "number" && !preserveCurrentHostPid ? {} : typeof current.hostPid === "number" ? { hostPid: current.hostPid } : {},
2907
2925
  ...typeof next.startedFromDaemon === "boolean" ? {} : typeof current.startedFromDaemon === "boolean" ? { startedFromDaemon: current.startedFromDaemon } : {},
2908
2926
  ...next.startedBy ? {} : current.startedBy ? { startedBy: current.startedBy } : {},
2909
2927
  ...next.lifecycleState ? {} : current.lifecycleState ? { lifecycleState: current.lifecycleState } : {},
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BLeiCte-.cjs');
3
+ var index = require('./index-CT1dgGsX.cjs');
4
4
  require('chalk');
5
- require('./api-DK1gyZAZ.cjs');
5
+ require('./api-DeDVledu.cjs');
6
6
  require('axios');
7
7
  require('fs');
8
8
  require('node:fs');
@@ -1,6 +1,6 @@
1
- import { c as createDefaultRuntimeShell } from './index-DQ76ZTNL.mjs';
1
+ import { c as createDefaultRuntimeShell } from './index-CFH8qcTw.mjs';
2
2
  import 'chalk';
3
- import './api-C68U-kRs.mjs';
3
+ import './api-DIFbsA6t.mjs';
4
4
  import 'axios';
5
5
  import 'fs';
6
6
  import 'node:fs';
@@ -1,5 +1,5 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
- import { l as logger, k as encodeBase64, c as configuration, m as readCredentials, n as ensureSigningCredentials, r as readSettings, u as updateSettings, o as encodeBase64Url, h as delay, q as buildClientHeaders, t as decodeBase64, w as writeCredentialsLegacy, v as writeCredentialsDataKey, x as readDaemonState, y as HAPPY_CLOUD_DAEMON_PORT, z as clearDaemonState, B as packageJson, i as isAuthenticationRequiredError, C as acquireDaemonLock, D as writeDaemonState, A as ApiClient, E as releaseDaemonLock, F as validateProfileForAgent, G as getProfileEnvironmentVariables, I as clearCredentials, J as clearMachineId, K as processHappyOrgRepoRequests, L as HappyOrgTurnReportSchema, M as recordHappyOrgTurnReport, N as MessageContentSchema, O as buildSocketAuth, P as encrypt, H as HeadTailPreviewBuffer, Q as getLatestDaemonLog } from './api-C68U-kRs.mjs';
2
+ import { l as logger, k as encodeBase64, c as configuration, m as readCredentials, n as ensureSigningCredentials, r as readSettings, u as updateSettings, o as encodeBase64Url, h as delay, q as buildClientHeaders, t as decodeBase64, w as writeCredentialsLegacy, v as writeCredentialsDataKey, x as readDaemonState, y as HAPPY_CLOUD_DAEMON_PORT, z as clearDaemonState, B as packageJson, i as isAuthenticationRequiredError, C as acquireDaemonLock, D as writeDaemonState, A as ApiClient, E as releaseDaemonLock, F as validateProfileForAgent, G as getProfileEnvironmentVariables, I as clearCredentials, J as clearMachineId, K as processHappyOrgRepoRequests, L as HappyOrgTurnReportSchema, M as recordHappyOrgTurnReport, N as MessageContentSchema, O as buildSocketAuth, P as encrypt, H as HeadTailPreviewBuffer, Q as getLatestDaemonLog } from './api-DIFbsA6t.mjs';
3
3
  import { z } from 'zod';
4
4
  import fs, { writeFile as writeFile$1, rename, unlink as unlink$1 } from 'fs/promises';
5
5
  import os$1, { homedir } from 'os';
@@ -11,7 +11,7 @@ import qrcode from 'qrcode-terminal';
11
11
  import { writeFile, unlink, readdir, readFile, mkdir } from 'node:fs/promises';
12
12
  import { createRequire } from 'node:module';
13
13
  import os, { tmpdir, homedir as homedir$1 } from 'node:os';
14
- import path, { join, resolve as resolve$1, isAbsolute, delimiter, normalize, dirname as dirname$1, basename } from 'node:path';
14
+ import path, { join, resolve as resolve$1, dirname as dirname$1, normalize, isAbsolute, delimiter, basename } from 'node:path';
15
15
  import open from 'open';
16
16
  import React, { useState } from 'react';
17
17
  import { useInput, Box, Text, render } from 'ink';
@@ -2495,14 +2495,177 @@ async function closeProviderSession(session, opts = {}) {
2495
2495
  }
2496
2496
  }
2497
2497
 
2498
+ const HOME_DOC_FILENAMES = ["IDENTITY.md", "AGENT.md", "SOUL.md", "USER.md", "TOOLS.md"];
2499
+ const MAX_HOME_DOC_CHARS = 4e3;
2500
+ function pathExists(targetPath) {
2501
+ return existsSync(targetPath);
2502
+ }
2503
+ function normalizePathKey(targetPath) {
2504
+ const normalizedPath = normalize(resolve$1(targetPath));
2505
+ return process.platform === "win32" ? normalizedPath.toLowerCase() : normalizedPath;
2506
+ }
2507
+ function readTextIfExists(targetPath) {
2508
+ if (!pathExists(targetPath)) {
2509
+ return null;
2510
+ }
2511
+ try {
2512
+ return readFileSync(targetPath, "utf8");
2513
+ } catch {
2514
+ return null;
2515
+ }
2516
+ }
2517
+ function isLegacyHappyOrgRoot(rootPath) {
2518
+ return pathExists(join(rootPath, "ORGANIZATION.md")) && pathExists(join(rootPath, "agents"));
2519
+ }
2520
+ function isLocalRepoHappyOrgRoot(rootPath) {
2521
+ return pathExists(join(rootPath, "ORGANIZATION.json")) || pathExists(join(rootPath, "MIGRATION.json"));
2522
+ }
2523
+ function isHappyOrgRoot(rootPath) {
2524
+ return isLegacyHappyOrgRoot(rootPath) || isLocalRepoHappyOrgRoot(rootPath);
2525
+ }
2526
+ function isCeoHomePath(homePath) {
2527
+ return pathExists(join(homePath, "IDENTITY.md")) || pathExists(join(homePath, "AGENT.md"));
2528
+ }
2529
+ function deriveOrganizationRootFromHomePath(homePath) {
2530
+ const resolvedHomePath = resolve$1(homePath);
2531
+ const homeDirName = resolve$1(homePath).split(/[\\/]/).pop()?.toLowerCase();
2532
+ const parentPath = dirname$1(resolvedHomePath);
2533
+ const parentDirName = parentPath.split(/[\\/]/).pop()?.toLowerCase();
2534
+ if (homeDirName !== "ceo" || parentDirName !== "positions" && parentDirName !== "agents" || !isCeoHomePath(resolvedHomePath)) {
2535
+ return null;
2536
+ }
2537
+ return dirname$1(parentPath);
2538
+ }
2539
+ function collectCandidateRoots(startPath) {
2540
+ const candidates = /* @__PURE__ */ new Map();
2541
+ const addCandidate = (candidateRootPath) => {
2542
+ if (!candidateRootPath || !isHappyOrgRoot(candidateRootPath)) {
2543
+ return;
2544
+ }
2545
+ candidates.set(normalizePathKey(candidateRootPath), resolve$1(candidateRootPath));
2546
+ };
2547
+ let currentPath = resolve$1(startPath);
2548
+ while (true) {
2549
+ addCandidate(currentPath);
2550
+ addCandidate(deriveOrganizationRootFromHomePath(currentPath));
2551
+ const parentPath = dirname$1(currentPath);
2552
+ if (parentPath === currentPath) {
2553
+ break;
2554
+ }
2555
+ currentPath = parentPath;
2556
+ }
2557
+ addCandidate(join(startPath, "happy-org", "happy_org"));
2558
+ addCandidate(join(startPath, "happy_org"));
2559
+ return [...candidates.values()];
2560
+ }
2561
+ function resolveHomeFromRoot(rootPath) {
2562
+ const positionHomePath = join(rootPath, "positions", "ceo");
2563
+ if (isCeoHomePath(positionHomePath)) {
2564
+ return {
2565
+ homePath: positionHomePath,
2566
+ source: "position-home"
2567
+ };
2568
+ }
2569
+ const legacyHomePath = join(rootPath, "agents", "ceo");
2570
+ if (isCeoHomePath(legacyHomePath)) {
2571
+ return {
2572
+ homePath: legacyHomePath,
2573
+ source: "legacy-agent-home"
2574
+ };
2575
+ }
2576
+ return null;
2577
+ }
2578
+ function readHomeDocSection(homePath, fileName) {
2579
+ const content = readTextIfExists(join(homePath, fileName))?.trim();
2580
+ if (!content) {
2581
+ return null;
2582
+ }
2583
+ const limitedContent = content.length > MAX_HOME_DOC_CHARS ? `${content.slice(0, MAX_HOME_DOC_CHARS).trimEnd()}
2584
+ [truncated]` : content;
2585
+ return [
2586
+ `<HOME_DOC name="${fileName}">`,
2587
+ limitedContent,
2588
+ "</HOME_DOC>"
2589
+ ].join("\n");
2590
+ }
2591
+ function extractIdentityField(markdown, fieldName) {
2592
+ if (!markdown) {
2593
+ return null;
2594
+ }
2595
+ const pattern = new RegExp(`(?:^|\\n)-\\s*${fieldName}:\\s*\`?([^\\n\`]+?)\`?\\s*(?:$|\\n)`, "i");
2596
+ const match = markdown.match(pattern);
2597
+ return match?.[1]?.trim() || null;
2598
+ }
2599
+ function extractHeading(markdown) {
2600
+ if (!markdown) {
2601
+ return null;
2602
+ }
2603
+ const match = markdown.match(/^#\s+(.+)$/m);
2604
+ return match?.[1]?.trim() || null;
2605
+ }
2606
+ function resolveDisplayName(identityMarkdown, agentMarkdown) {
2607
+ return extractIdentityField(identityMarkdown, "display_name") || extractHeading(agentMarkdown) || "Happy CEO";
2608
+ }
2609
+ function buildIdentityPrompt(opts) {
2610
+ const identityMarkdown = readTextIfExists(join(opts.homePath, "IDENTITY.md"));
2611
+ const homeSections = HOME_DOC_FILENAMES.map((fileName) => readHomeDocSection(opts.homePath, fileName)).filter((value) => Boolean(value));
2612
+ if (homeSections.length === 0) {
2613
+ return null;
2614
+ }
2615
+ const role = extractIdentityField(identityMarkdown, "role") || "ceo";
2616
+ return [
2617
+ "[HAPPY_LOCAL_HOME_STARTUP]",
2618
+ "You are starting inside a local Happy Org CEO home, not a generic repository session.",
2619
+ "Bind this runtime to the local CEO home below and follow these home documents as startup identity context until a more specific Happy Org task prompt overrides them.",
2620
+ `organization_root_path=${opts.organizationRootPath}`,
2621
+ `home_path=${opts.homePath}`,
2622
+ `role=${role}`,
2623
+ `display_name=${opts.displayName}`,
2624
+ `source=${opts.source}`,
2625
+ "",
2626
+ ...homeSections,
2627
+ "[/HAPPY_LOCAL_HOME_STARTUP]"
2628
+ ].join("\n");
2629
+ }
2630
+ function resolveHappyOrgStartupBinding(startPath) {
2631
+ const candidateRoots = collectCandidateRoots(startPath);
2632
+ if (candidateRoots.length !== 1) {
2633
+ return null;
2634
+ }
2635
+ const organizationRootPath = candidateRoots[0];
2636
+ const home = resolveHomeFromRoot(organizationRootPath);
2637
+ if (!home) {
2638
+ return null;
2639
+ }
2640
+ const identityMarkdown = readTextIfExists(join(home.homePath, "IDENTITY.md"));
2641
+ const agentMarkdown = readTextIfExists(join(home.homePath, "AGENT.md"));
2642
+ const displayName = resolveDisplayName(identityMarkdown, agentMarkdown);
2643
+ return {
2644
+ organizationRootPath,
2645
+ homePath: home.homePath,
2646
+ role: "ceo",
2647
+ displayName,
2648
+ source: home.source,
2649
+ identityPrompt: buildIdentityPrompt({
2650
+ organizationRootPath,
2651
+ homePath: home.homePath,
2652
+ displayName,
2653
+ source: home.source
2654
+ })
2655
+ };
2656
+ }
2657
+
2498
2658
  function createSessionMetadata(opts) {
2499
2659
  const state = {
2500
2660
  controlledByUser: false
2501
2661
  };
2502
- const metadataPath = opts.path ?? process.cwd();
2662
+ const requestedMetadataPath = opts.path ?? process.cwd();
2663
+ const happyOrgStartupBinding = resolveHappyOrgStartupBinding(requestedMetadataPath);
2664
+ const metadataPath = happyOrgStartupBinding?.homePath ?? requestedMetadataPath;
2503
2665
  const metadataHostPid = opts.hostPid === void 0 ? process.pid : opts.hostPid;
2504
2666
  const metadata = {
2505
2667
  path: metadataPath,
2668
+ ...happyOrgStartupBinding?.displayName ? { name: happyOrgStartupBinding.displayName } : {},
2506
2669
  host: os.hostname(),
2507
2670
  version: packageJson.version,
2508
2671
  os: os.platform(),
@@ -2519,7 +2682,11 @@ function createSessionMetadata(opts) {
2519
2682
  flavor: opts.flavor,
2520
2683
  ...metadataHostPid == null ? {} : { hostPid: metadataHostPid }
2521
2684
  };
2522
- return { state, metadata };
2685
+ return {
2686
+ state,
2687
+ metadata,
2688
+ happyOrgStartupBinding
2689
+ };
2523
2690
  }
2524
2691
 
2525
2692
  async function archiveManagedSessionById(opts) {
@@ -6859,21 +7026,26 @@ function appendToolOutput(existing, next) {
6859
7026
  DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_HEAD_BYTES,
6860
7027
  DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_TAIL_BYTES
6861
7028
  ) : existing.preview;
7029
+ let emittedChunk = null;
6862
7030
  if (shouldReplace) {
6863
7031
  preview.append(next);
6864
7032
  } else {
6865
7033
  const textToAppend = getToolOutputDelta(existing?.lastRawText, next);
6866
7034
  if (textToAppend.length > 0) {
6867
7035
  preview.append(textToAppend);
7036
+ emittedChunk = textToAppend;
6868
7037
  }
6869
7038
  }
6870
7039
  return {
6871
- preview,
6872
- // ACP runtimes sometimes resend the entire cumulative stdout snapshot.
6873
- // Keep only a bounded summary for dedupe so long tool runs cannot retain
6874
- // every historical snapshot in memory.
6875
- lastRawText: buildToolOutputSnapshot(next),
6876
- updateCount: (existing?.updateCount ?? 0) + 1
7040
+ accumulator: {
7041
+ preview,
7042
+ // ACP runtimes sometimes resend the entire cumulative stdout snapshot.
7043
+ // Keep only a bounded summary for dedupe so long tool runs cannot retain
7044
+ // every historical snapshot in memory.
7045
+ lastRawText: buildToolOutputSnapshot(next),
7046
+ updateCount: (existing?.updateCount ?? 0) + 1
7047
+ },
7048
+ emittedChunk
6877
7049
  };
6878
7050
  }
6879
7051
  function renderToolOutput(accumulator) {
@@ -6898,6 +7070,13 @@ function extractTerminalOutputMeta(update) {
6898
7070
  const toolCallId = typeof update.toolCallId === "string" && update.toolCallId.length > 0 ? update.toolCallId : terminalId;
6899
7071
  return toolCallId ? { toolCallId, data } : null;
6900
7072
  }
7073
+ function isTerminalLikeToolKind(toolKind) {
7074
+ if (typeof toolKind !== "string" || toolKind.length === 0) {
7075
+ return false;
7076
+ }
7077
+ const normalized = toolKind.toLowerCase();
7078
+ return normalized === "execute" || normalized.includes("bash") || normalized.includes("shell") || normalized.includes("terminal") || normalized.includes("command");
7079
+ }
6901
7080
  function formatToolCallTimeoutLimit(timeoutMs) {
6902
7081
  if (timeoutMs < 1e3) {
6903
7082
  return `${timeoutMs}ms`;
@@ -7242,11 +7421,8 @@ function handleToolCallUpdate(update, ctx, options) {
7242
7421
  }
7243
7422
  const toolKind = update.kind || ctx.toolCallIdToNameMap.get(toolCallId) || "unknown";
7244
7423
  let toolCallCountSincePrompt = ctx.toolCallCountSincePrompt;
7424
+ const hasSupplementalTerminalOutput = typeof options?.supplementalOutputChunk === "string" && options.supplementalOutputChunk.length > 0;
7245
7425
  const outputChunk = extractToolOutputChunk(update.content) ?? options?.supplementalOutputChunk ?? null;
7246
- if (outputChunk) {
7247
- const nextOutput = appendToolOutput(ctx.toolCallOutputs.get(toolCallId), outputChunk);
7248
- ctx.toolCallOutputs.set(toolCallId, nextOutput);
7249
- }
7250
7426
  if (status === "in_progress" || status === "pending") {
7251
7427
  if (!ctx.activeToolCalls.has(toolCallId)) {
7252
7428
  toolCallCountSincePrompt++;
@@ -7254,7 +7430,19 @@ function handleToolCallUpdate(update, ctx, options) {
7254
7430
  } else {
7255
7431
  logger.debug(`[AcpBackend] Tool call ${toolCallId} already tracked, status: ${status}`);
7256
7432
  }
7257
- } else if (status === "completed") {
7433
+ }
7434
+ if (outputChunk) {
7435
+ const nextOutput = appendToolOutput(ctx.toolCallOutputs.get(toolCallId), outputChunk);
7436
+ ctx.toolCallOutputs.set(toolCallId, nextOutput.accumulator);
7437
+ if (ctx.activeToolCalls.has(toolCallId) && nextOutput.emittedChunk && (hasSupplementalTerminalOutput || isTerminalLikeToolKind(toolKind))) {
7438
+ ctx.emit({
7439
+ type: "terminal-output",
7440
+ data: nextOutput.emittedChunk,
7441
+ callId: toolCallId
7442
+ });
7443
+ }
7444
+ }
7445
+ if (status === "completed") {
7258
7446
  completeToolCall(toolCallId, toolKind, update.content, ctx);
7259
7447
  } else if (status === "failed" || status === "cancelled") {
7260
7448
  failToolCall(toolCallId, status, toolKind, update.content, ctx);
@@ -11363,14 +11551,14 @@ var launch = /*#__PURE__*/Object.freeze({
11363
11551
  const unifiedProviderExecutors = {
11364
11552
  claude: async (opts) => {
11365
11553
  const claudeOptions = opts.claudeOptions ?? {};
11366
- const { runClaude } = await import('./runClaude-CkY6XYJa.mjs');
11554
+ const { runClaude } = await import('./runClaude-BvRjHUgF.mjs');
11367
11555
  await runClaude(opts.credentials, {
11368
11556
  ...claudeOptions,
11369
11557
  startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
11370
11558
  });
11371
11559
  },
11372
11560
  codex: async (opts) => {
11373
- const { runCodex } = await import('./runCodex-C6kV0jfX.mjs');
11561
+ const { runCodex } = await import('./runCodex-B-B9MfOf.mjs');
11374
11562
  await runCodex({
11375
11563
  credentials: opts.credentials,
11376
11564
  startedBy: opts.startedBy,
@@ -11379,7 +11567,7 @@ const unifiedProviderExecutors = {
11379
11567
  });
11380
11568
  },
11381
11569
  gemini: async (opts) => {
11382
- const { runGemini } = await import('./runGemini-IEzJdhc-.mjs');
11570
+ const { runGemini } = await import('./runGemini-B9W7nfow.mjs');
11383
11571
  await runGemini({
11384
11572
  credentials: opts.credentials,
11385
11573
  startedBy: opts.startedBy
@@ -11462,7 +11650,7 @@ function shouldRunMainClaudeFlow(opts) {
11462
11650
  return;
11463
11651
  } else if (subcommand === "runtime") {
11464
11652
  if (args[1] === "providers") {
11465
- const { renderRuntimeProviders } = await import('./command-D32x08k9.mjs');
11653
+ const { renderRuntimeProviders } = await import('./command-ZJ5yPOv4.mjs');
11466
11654
  console.log(renderRuntimeProviders());
11467
11655
  return;
11468
11656
  }
@@ -11668,8 +11856,8 @@ function shouldRunMainClaudeFlow(opts) {
11668
11856
  const projectId = args[3];
11669
11857
  try {
11670
11858
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
11671
- const { readCredentials: readCredentials2 } = await import('./api-C68U-kRs.mjs').then(function (n) { return n.R; });
11672
- const { ApiClient: ApiClient2 } = await import('./api-C68U-kRs.mjs').then(function (n) { return n.S; });
11859
+ const { readCredentials: readCredentials2 } = await import('./api-DIFbsA6t.mjs').then(function (n) { return n.R; });
11860
+ const { ApiClient: ApiClient2 } = await import('./api-DIFbsA6t.mjs').then(function (n) { return n.S; });
11673
11861
  let userEmail = void 0;
11674
11862
  try {
11675
11863
  const credentials = await readCredentials2();