happy-imou-cloud 2.1.31 → 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.
- package/dist/{BaseReasoningProcessor-JFdT7HPG.cjs → BaseReasoningProcessor-CQQrYyo3.cjs} +4 -3
- package/dist/{BaseReasoningProcessor-CaFHRe9H.mjs → BaseReasoningProcessor-CfibmGoR.mjs} +4 -3
- package/dist/{ProviderSelectionHandler-Cjfd17Lp.mjs → ProviderSelectionHandler-C1q60HP6.mjs} +2 -2
- package/dist/{ProviderSelectionHandler-ql1Ikkru.cjs → ProviderSelectionHandler-D9Bd_S25.cjs} +2 -2
- package/dist/{api-Baxp1gAn.mjs → api-DIFbsA6t.mjs} +1 -1
- package/dist/{api-Har_Kn3X.cjs → api-DeDVledu.cjs} +1 -1
- package/dist/{command-vvaFH5Xx.cjs → command-Cl7kVs7K.cjs} +2 -2
- package/dist/{command-CyfoYUmk.mjs → command-ZJ5yPOv4.mjs} +2 -2
- package/dist/{index-BmOq3bu1.mjs → index-CFH8qcTw.mjs} +209 -21
- package/dist/{index-B_8-tkL4.cjs → index-CT1dgGsX.cjs} +211 -23
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-D1QR0rK1.cjs → registerKillSessionHandler-9O3r5bEa.cjs} +2 -2
- package/dist/{registerKillSessionHandler-WMXTq_kr.mjs → registerKillSessionHandler-DxpGgu6u.mjs} +2 -2
- package/dist/{runClaude-DhfpW9XR.cjs → runClaude-BmW-_Yrl.cjs} +8 -6
- package/dist/{runClaude-TrzlAhzh.mjs → runClaude-BvRjHUgF.mjs} +8 -6
- package/dist/{runCodex-GpBK90D2.mjs → runCodex-B-B9MfOf.mjs} +21 -12
- package/dist/{runCodex-D4EIHtfX.cjs → runCodex-dmjiaB1v.cjs} +21 -12
- package/dist/{runGemini-D15RH8Iq.mjs → runGemini-B9W7nfow.mjs} +4 -4
- package/dist/{runGemini-CR5MW3P-.cjs → runGemini-CyERhKhw.cjs} +4 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var persistence = require('./api-
|
|
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-
|
|
2
|
-
import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-
|
|
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
|
package/dist/{ProviderSelectionHandler-Cjfd17Lp.mjs → ProviderSelectionHandler-C1q60HP6.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as logger } from './api-
|
|
2
|
-
import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-
|
|
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;
|
package/dist/{ProviderSelectionHandler-ql1Ikkru.cjs → ProviderSelectionHandler-D9Bd_S25.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var persistence = require('./api-
|
|
4
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
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.
|
|
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";
|
|
@@ -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.
|
|
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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as createDefaultRuntimeShell } from './index-
|
|
1
|
+
import { c as createDefaultRuntimeShell } from './index-CFH8qcTw.mjs';
|
|
2
2
|
import 'chalk';
|
|
3
|
-
import './api-
|
|
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-
|
|
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,
|
|
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
|
|
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 {
|
|
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
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
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
|
-
}
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
11672
|
-
const { ApiClient: ApiClient2 } = await import('./api-
|
|
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();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
|
-
var persistence = require('./api-
|
|
4
|
+
var persistence = require('./api-DeDVledu.cjs');
|
|
5
5
|
var z = require('zod');
|
|
6
6
|
var fs$2 = require('fs/promises');
|
|
7
7
|
var os$1 = require('os');
|
|
@@ -72,7 +72,7 @@ async function openBrowser(url) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
75
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href)));
|
|
76
76
|
const QRCode = require$1("qrcode-terminal/vendor/QRCode");
|
|
77
77
|
const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
|
|
78
78
|
const pendingTempFiles = /* @__PURE__ */ new Set();
|
|
@@ -637,7 +637,7 @@ function setupCleanupHandlers() {
|
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
-
const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
640
|
+
const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href))));
|
|
641
641
|
function projectPath() {
|
|
642
642
|
const path = path$1.resolve(__dirname$2, "..");
|
|
643
643
|
return path;
|
|
@@ -2517,14 +2517,177 @@ async function closeProviderSession(session, opts = {}) {
|
|
|
2517
2517
|
}
|
|
2518
2518
|
}
|
|
2519
2519
|
|
|
2520
|
+
const HOME_DOC_FILENAMES = ["IDENTITY.md", "AGENT.md", "SOUL.md", "USER.md", "TOOLS.md"];
|
|
2521
|
+
const MAX_HOME_DOC_CHARS = 4e3;
|
|
2522
|
+
function pathExists(targetPath) {
|
|
2523
|
+
return fs.existsSync(targetPath);
|
|
2524
|
+
}
|
|
2525
|
+
function normalizePathKey(targetPath) {
|
|
2526
|
+
const normalizedPath = path.normalize(path.resolve(targetPath));
|
|
2527
|
+
return process.platform === "win32" ? normalizedPath.toLowerCase() : normalizedPath;
|
|
2528
|
+
}
|
|
2529
|
+
function readTextIfExists(targetPath) {
|
|
2530
|
+
if (!pathExists(targetPath)) {
|
|
2531
|
+
return null;
|
|
2532
|
+
}
|
|
2533
|
+
try {
|
|
2534
|
+
return fs.readFileSync(targetPath, "utf8");
|
|
2535
|
+
} catch {
|
|
2536
|
+
return null;
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
function isLegacyHappyOrgRoot(rootPath) {
|
|
2540
|
+
return pathExists(path.join(rootPath, "ORGANIZATION.md")) && pathExists(path.join(rootPath, "agents"));
|
|
2541
|
+
}
|
|
2542
|
+
function isLocalRepoHappyOrgRoot(rootPath) {
|
|
2543
|
+
return pathExists(path.join(rootPath, "ORGANIZATION.json")) || pathExists(path.join(rootPath, "MIGRATION.json"));
|
|
2544
|
+
}
|
|
2545
|
+
function isHappyOrgRoot(rootPath) {
|
|
2546
|
+
return isLegacyHappyOrgRoot(rootPath) || isLocalRepoHappyOrgRoot(rootPath);
|
|
2547
|
+
}
|
|
2548
|
+
function isCeoHomePath(homePath) {
|
|
2549
|
+
return pathExists(path.join(homePath, "IDENTITY.md")) || pathExists(path.join(homePath, "AGENT.md"));
|
|
2550
|
+
}
|
|
2551
|
+
function deriveOrganizationRootFromHomePath(homePath) {
|
|
2552
|
+
const resolvedHomePath = path.resolve(homePath);
|
|
2553
|
+
const homeDirName = path.resolve(homePath).split(/[\\/]/).pop()?.toLowerCase();
|
|
2554
|
+
const parentPath = path.dirname(resolvedHomePath);
|
|
2555
|
+
const parentDirName = parentPath.split(/[\\/]/).pop()?.toLowerCase();
|
|
2556
|
+
if (homeDirName !== "ceo" || parentDirName !== "positions" && parentDirName !== "agents" || !isCeoHomePath(resolvedHomePath)) {
|
|
2557
|
+
return null;
|
|
2558
|
+
}
|
|
2559
|
+
return path.dirname(parentPath);
|
|
2560
|
+
}
|
|
2561
|
+
function collectCandidateRoots(startPath) {
|
|
2562
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
2563
|
+
const addCandidate = (candidateRootPath) => {
|
|
2564
|
+
if (!candidateRootPath || !isHappyOrgRoot(candidateRootPath)) {
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
candidates.set(normalizePathKey(candidateRootPath), path.resolve(candidateRootPath));
|
|
2568
|
+
};
|
|
2569
|
+
let currentPath = path.resolve(startPath);
|
|
2570
|
+
while (true) {
|
|
2571
|
+
addCandidate(currentPath);
|
|
2572
|
+
addCandidate(deriveOrganizationRootFromHomePath(currentPath));
|
|
2573
|
+
const parentPath = path.dirname(currentPath);
|
|
2574
|
+
if (parentPath === currentPath) {
|
|
2575
|
+
break;
|
|
2576
|
+
}
|
|
2577
|
+
currentPath = parentPath;
|
|
2578
|
+
}
|
|
2579
|
+
addCandidate(path.join(startPath, "happy-org", "happy_org"));
|
|
2580
|
+
addCandidate(path.join(startPath, "happy_org"));
|
|
2581
|
+
return [...candidates.values()];
|
|
2582
|
+
}
|
|
2583
|
+
function resolveHomeFromRoot(rootPath) {
|
|
2584
|
+
const positionHomePath = path.join(rootPath, "positions", "ceo");
|
|
2585
|
+
if (isCeoHomePath(positionHomePath)) {
|
|
2586
|
+
return {
|
|
2587
|
+
homePath: positionHomePath,
|
|
2588
|
+
source: "position-home"
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
const legacyHomePath = path.join(rootPath, "agents", "ceo");
|
|
2592
|
+
if (isCeoHomePath(legacyHomePath)) {
|
|
2593
|
+
return {
|
|
2594
|
+
homePath: legacyHomePath,
|
|
2595
|
+
source: "legacy-agent-home"
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
return null;
|
|
2599
|
+
}
|
|
2600
|
+
function readHomeDocSection(homePath, fileName) {
|
|
2601
|
+
const content = readTextIfExists(path.join(homePath, fileName))?.trim();
|
|
2602
|
+
if (!content) {
|
|
2603
|
+
return null;
|
|
2604
|
+
}
|
|
2605
|
+
const limitedContent = content.length > MAX_HOME_DOC_CHARS ? `${content.slice(0, MAX_HOME_DOC_CHARS).trimEnd()}
|
|
2606
|
+
[truncated]` : content;
|
|
2607
|
+
return [
|
|
2608
|
+
`<HOME_DOC name="${fileName}">`,
|
|
2609
|
+
limitedContent,
|
|
2610
|
+
"</HOME_DOC>"
|
|
2611
|
+
].join("\n");
|
|
2612
|
+
}
|
|
2613
|
+
function extractIdentityField(markdown, fieldName) {
|
|
2614
|
+
if (!markdown) {
|
|
2615
|
+
return null;
|
|
2616
|
+
}
|
|
2617
|
+
const pattern = new RegExp(`(?:^|\\n)-\\s*${fieldName}:\\s*\`?([^\\n\`]+?)\`?\\s*(?:$|\\n)`, "i");
|
|
2618
|
+
const match = markdown.match(pattern);
|
|
2619
|
+
return match?.[1]?.trim() || null;
|
|
2620
|
+
}
|
|
2621
|
+
function extractHeading(markdown) {
|
|
2622
|
+
if (!markdown) {
|
|
2623
|
+
return null;
|
|
2624
|
+
}
|
|
2625
|
+
const match = markdown.match(/^#\s+(.+)$/m);
|
|
2626
|
+
return match?.[1]?.trim() || null;
|
|
2627
|
+
}
|
|
2628
|
+
function resolveDisplayName(identityMarkdown, agentMarkdown) {
|
|
2629
|
+
return extractIdentityField(identityMarkdown, "display_name") || extractHeading(agentMarkdown) || "Happy CEO";
|
|
2630
|
+
}
|
|
2631
|
+
function buildIdentityPrompt(opts) {
|
|
2632
|
+
const identityMarkdown = readTextIfExists(path.join(opts.homePath, "IDENTITY.md"));
|
|
2633
|
+
const homeSections = HOME_DOC_FILENAMES.map((fileName) => readHomeDocSection(opts.homePath, fileName)).filter((value) => Boolean(value));
|
|
2634
|
+
if (homeSections.length === 0) {
|
|
2635
|
+
return null;
|
|
2636
|
+
}
|
|
2637
|
+
const role = extractIdentityField(identityMarkdown, "role") || "ceo";
|
|
2638
|
+
return [
|
|
2639
|
+
"[HAPPY_LOCAL_HOME_STARTUP]",
|
|
2640
|
+
"You are starting inside a local Happy Org CEO home, not a generic repository session.",
|
|
2641
|
+
"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.",
|
|
2642
|
+
`organization_root_path=${opts.organizationRootPath}`,
|
|
2643
|
+
`home_path=${opts.homePath}`,
|
|
2644
|
+
`role=${role}`,
|
|
2645
|
+
`display_name=${opts.displayName}`,
|
|
2646
|
+
`source=${opts.source}`,
|
|
2647
|
+
"",
|
|
2648
|
+
...homeSections,
|
|
2649
|
+
"[/HAPPY_LOCAL_HOME_STARTUP]"
|
|
2650
|
+
].join("\n");
|
|
2651
|
+
}
|
|
2652
|
+
function resolveHappyOrgStartupBinding(startPath) {
|
|
2653
|
+
const candidateRoots = collectCandidateRoots(startPath);
|
|
2654
|
+
if (candidateRoots.length !== 1) {
|
|
2655
|
+
return null;
|
|
2656
|
+
}
|
|
2657
|
+
const organizationRootPath = candidateRoots[0];
|
|
2658
|
+
const home = resolveHomeFromRoot(organizationRootPath);
|
|
2659
|
+
if (!home) {
|
|
2660
|
+
return null;
|
|
2661
|
+
}
|
|
2662
|
+
const identityMarkdown = readTextIfExists(path.join(home.homePath, "IDENTITY.md"));
|
|
2663
|
+
const agentMarkdown = readTextIfExists(path.join(home.homePath, "AGENT.md"));
|
|
2664
|
+
const displayName = resolveDisplayName(identityMarkdown, agentMarkdown);
|
|
2665
|
+
return {
|
|
2666
|
+
organizationRootPath,
|
|
2667
|
+
homePath: home.homePath,
|
|
2668
|
+
role: "ceo",
|
|
2669
|
+
displayName,
|
|
2670
|
+
source: home.source,
|
|
2671
|
+
identityPrompt: buildIdentityPrompt({
|
|
2672
|
+
organizationRootPath,
|
|
2673
|
+
homePath: home.homePath,
|
|
2674
|
+
displayName,
|
|
2675
|
+
source: home.source
|
|
2676
|
+
})
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2520
2680
|
function createSessionMetadata(opts) {
|
|
2521
2681
|
const state = {
|
|
2522
2682
|
controlledByUser: false
|
|
2523
2683
|
};
|
|
2524
|
-
const
|
|
2684
|
+
const requestedMetadataPath = opts.path ?? process.cwd();
|
|
2685
|
+
const happyOrgStartupBinding = resolveHappyOrgStartupBinding(requestedMetadataPath);
|
|
2686
|
+
const metadataPath = happyOrgStartupBinding?.homePath ?? requestedMetadataPath;
|
|
2525
2687
|
const metadataHostPid = opts.hostPid === void 0 ? process.pid : opts.hostPid;
|
|
2526
2688
|
const metadata = {
|
|
2527
2689
|
path: metadataPath,
|
|
2690
|
+
...happyOrgStartupBinding?.displayName ? { name: happyOrgStartupBinding.displayName } : {},
|
|
2528
2691
|
host: os.hostname(),
|
|
2529
2692
|
version: persistence.packageJson.version,
|
|
2530
2693
|
os: os.platform(),
|
|
@@ -2541,7 +2704,11 @@ function createSessionMetadata(opts) {
|
|
|
2541
2704
|
flavor: opts.flavor,
|
|
2542
2705
|
...metadataHostPid == null ? {} : { hostPid: metadataHostPid }
|
|
2543
2706
|
};
|
|
2544
|
-
return {
|
|
2707
|
+
return {
|
|
2708
|
+
state,
|
|
2709
|
+
metadata,
|
|
2710
|
+
happyOrgStartupBinding
|
|
2711
|
+
};
|
|
2545
2712
|
}
|
|
2546
2713
|
|
|
2547
2714
|
async function archiveManagedSessionById(opts) {
|
|
@@ -6881,21 +7048,26 @@ function appendToolOutput(existing, next) {
|
|
|
6881
7048
|
DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_HEAD_BYTES,
|
|
6882
7049
|
DEFAULT_TOOL_CALL_OUTPUT_PREVIEW_TAIL_BYTES
|
|
6883
7050
|
) : existing.preview;
|
|
7051
|
+
let emittedChunk = null;
|
|
6884
7052
|
if (shouldReplace) {
|
|
6885
7053
|
preview.append(next);
|
|
6886
7054
|
} else {
|
|
6887
7055
|
const textToAppend = getToolOutputDelta(existing?.lastRawText, next);
|
|
6888
7056
|
if (textToAppend.length > 0) {
|
|
6889
7057
|
preview.append(textToAppend);
|
|
7058
|
+
emittedChunk = textToAppend;
|
|
6890
7059
|
}
|
|
6891
7060
|
}
|
|
6892
7061
|
return {
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
7062
|
+
accumulator: {
|
|
7063
|
+
preview,
|
|
7064
|
+
// ACP runtimes sometimes resend the entire cumulative stdout snapshot.
|
|
7065
|
+
// Keep only a bounded summary for dedupe so long tool runs cannot retain
|
|
7066
|
+
// every historical snapshot in memory.
|
|
7067
|
+
lastRawText: buildToolOutputSnapshot(next),
|
|
7068
|
+
updateCount: (existing?.updateCount ?? 0) + 1
|
|
7069
|
+
},
|
|
7070
|
+
emittedChunk
|
|
6899
7071
|
};
|
|
6900
7072
|
}
|
|
6901
7073
|
function renderToolOutput(accumulator) {
|
|
@@ -6920,6 +7092,13 @@ function extractTerminalOutputMeta(update) {
|
|
|
6920
7092
|
const toolCallId = typeof update.toolCallId === "string" && update.toolCallId.length > 0 ? update.toolCallId : terminalId;
|
|
6921
7093
|
return toolCallId ? { toolCallId, data } : null;
|
|
6922
7094
|
}
|
|
7095
|
+
function isTerminalLikeToolKind(toolKind) {
|
|
7096
|
+
if (typeof toolKind !== "string" || toolKind.length === 0) {
|
|
7097
|
+
return false;
|
|
7098
|
+
}
|
|
7099
|
+
const normalized = toolKind.toLowerCase();
|
|
7100
|
+
return normalized === "execute" || normalized.includes("bash") || normalized.includes("shell") || normalized.includes("terminal") || normalized.includes("command");
|
|
7101
|
+
}
|
|
6923
7102
|
function formatToolCallTimeoutLimit(timeoutMs) {
|
|
6924
7103
|
if (timeoutMs < 1e3) {
|
|
6925
7104
|
return `${timeoutMs}ms`;
|
|
@@ -7264,11 +7443,8 @@ function handleToolCallUpdate(update, ctx, options) {
|
|
|
7264
7443
|
}
|
|
7265
7444
|
const toolKind = update.kind || ctx.toolCallIdToNameMap.get(toolCallId) || "unknown";
|
|
7266
7445
|
let toolCallCountSincePrompt = ctx.toolCallCountSincePrompt;
|
|
7446
|
+
const hasSupplementalTerminalOutput = typeof options?.supplementalOutputChunk === "string" && options.supplementalOutputChunk.length > 0;
|
|
7267
7447
|
const outputChunk = extractToolOutputChunk(update.content) ?? options?.supplementalOutputChunk ?? null;
|
|
7268
|
-
if (outputChunk) {
|
|
7269
|
-
const nextOutput = appendToolOutput(ctx.toolCallOutputs.get(toolCallId), outputChunk);
|
|
7270
|
-
ctx.toolCallOutputs.set(toolCallId, nextOutput);
|
|
7271
|
-
}
|
|
7272
7448
|
if (status === "in_progress" || status === "pending") {
|
|
7273
7449
|
if (!ctx.activeToolCalls.has(toolCallId)) {
|
|
7274
7450
|
toolCallCountSincePrompt++;
|
|
@@ -7276,7 +7452,19 @@ function handleToolCallUpdate(update, ctx, options) {
|
|
|
7276
7452
|
} else {
|
|
7277
7453
|
persistence.logger.debug(`[AcpBackend] Tool call ${toolCallId} already tracked, status: ${status}`);
|
|
7278
7454
|
}
|
|
7279
|
-
}
|
|
7455
|
+
}
|
|
7456
|
+
if (outputChunk) {
|
|
7457
|
+
const nextOutput = appendToolOutput(ctx.toolCallOutputs.get(toolCallId), outputChunk);
|
|
7458
|
+
ctx.toolCallOutputs.set(toolCallId, nextOutput.accumulator);
|
|
7459
|
+
if (ctx.activeToolCalls.has(toolCallId) && nextOutput.emittedChunk && (hasSupplementalTerminalOutput || isTerminalLikeToolKind(toolKind))) {
|
|
7460
|
+
ctx.emit({
|
|
7461
|
+
type: "terminal-output",
|
|
7462
|
+
data: nextOutput.emittedChunk,
|
|
7463
|
+
callId: toolCallId
|
|
7464
|
+
});
|
|
7465
|
+
}
|
|
7466
|
+
}
|
|
7467
|
+
if (status === "completed") {
|
|
7280
7468
|
completeToolCall(toolCallId, toolKind, update.content, ctx);
|
|
7281
7469
|
} else if (status === "failed" || status === "cancelled") {
|
|
7282
7470
|
failToolCall(toolCallId, status, toolKind, update.content, ctx);
|
|
@@ -10062,7 +10250,7 @@ class AbortError extends Error {
|
|
|
10062
10250
|
}
|
|
10063
10251
|
}
|
|
10064
10252
|
|
|
10065
|
-
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
10253
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href)));
|
|
10066
10254
|
const __dirname$1 = path.join(__filename$1, "..");
|
|
10067
10255
|
function getGlobalClaudeVersion() {
|
|
10068
10256
|
try {
|
|
@@ -11385,14 +11573,14 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
11385
11573
|
const unifiedProviderExecutors = {
|
|
11386
11574
|
claude: async (opts) => {
|
|
11387
11575
|
const claudeOptions = opts.claudeOptions ?? {};
|
|
11388
|
-
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-
|
|
11576
|
+
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BmW-_Yrl.cjs'); });
|
|
11389
11577
|
await runClaude(opts.credentials, {
|
|
11390
11578
|
...claudeOptions,
|
|
11391
11579
|
startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
|
|
11392
11580
|
});
|
|
11393
11581
|
},
|
|
11394
11582
|
codex: async (opts) => {
|
|
11395
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
11583
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-dmjiaB1v.cjs'); });
|
|
11396
11584
|
await runCodex({
|
|
11397
11585
|
credentials: opts.credentials,
|
|
11398
11586
|
startedBy: opts.startedBy,
|
|
@@ -11401,7 +11589,7 @@ const unifiedProviderExecutors = {
|
|
|
11401
11589
|
});
|
|
11402
11590
|
},
|
|
11403
11591
|
gemini: async (opts) => {
|
|
11404
|
-
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-
|
|
11592
|
+
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-CyERhKhw.cjs'); });
|
|
11405
11593
|
await runGemini({
|
|
11406
11594
|
credentials: opts.credentials,
|
|
11407
11595
|
startedBy: opts.startedBy
|
|
@@ -11484,7 +11672,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
11484
11672
|
return;
|
|
11485
11673
|
} else if (subcommand === "runtime") {
|
|
11486
11674
|
if (args[1] === "providers") {
|
|
11487
|
-
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-
|
|
11675
|
+
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-Cl7kVs7K.cjs'); });
|
|
11488
11676
|
console.log(renderRuntimeProviders());
|
|
11489
11677
|
return;
|
|
11490
11678
|
}
|
|
@@ -11690,8 +11878,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
11690
11878
|
const projectId = args[3];
|
|
11691
11879
|
try {
|
|
11692
11880
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
11693
|
-
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-
|
|
11694
|
-
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-
|
|
11881
|
+
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-DeDVledu.cjs'); }).then(function (n) { return n.persistence; });
|
|
11882
|
+
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-DeDVledu.cjs'); }).then(function (n) { return n.api; });
|
|
11695
11883
|
let userEmail = void 0;
|
|
11696
11884
|
try {
|
|
11697
11885
|
const credentials = await readCredentials2();
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('chalk');
|
|
4
|
-
require('./api-
|
|
4
|
+
require('./api-DeDVledu.cjs');
|
|
5
5
|
require('zod');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-CT1dgGsX.cjs');
|
|
7
7
|
require('node:child_process');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('cross-spawn');
|
package/dist/index.mjs
CHANGED
package/dist/lib.cjs
CHANGED
package/dist/lib.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient, c as configuration, l as logger } from './api-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient, c as configuration, l as logger } from './api-DIFbsA6t.mjs';
|
|
2
2
|
export { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'chalk';
|
package/dist/{registerKillSessionHandler-D1QR0rK1.cjs → registerKillSessionHandler-9O3r5bEa.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var persistence = require('./api-
|
|
3
|
+
var index = require('./index-CT1dgGsX.cjs');
|
|
4
|
+
var persistence = require('./api-DeDVledu.cjs');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var crypto = require('crypto');
|
package/dist/{registerKillSessionHandler-WMXTq_kr.mjs → registerKillSessionHandler-DxpGgu6u.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, l as resolveCanonicalToolNameV2 } from './index-
|
|
2
|
-
import { r as readSettings, H as HeadTailPreviewBuffer, d as HAPPY_ORG_TURN_REPORT_TAG, e as HAPPY_ORG_SUMMARY_MAX_LENGTH, f as HAPPY_ORG_REPEAT_THRESHOLD, l as logger } from './api-
|
|
1
|
+
import { k as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, l as resolveCanonicalToolNameV2 } from './index-CFH8qcTw.mjs';
|
|
2
|
+
import { r as readSettings, H as HeadTailPreviewBuffer, d as HAPPY_ORG_TURN_REPORT_TAG, e as HAPPY_ORG_SUMMARY_MAX_LENGTH, f as HAPPY_ORG_REPEAT_THRESHOLD, l as logger } from './api-DIFbsA6t.mjs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
|
-
var persistence = require('./api-
|
|
4
|
+
var persistence = require('./api-DeDVledu.cjs');
|
|
5
5
|
require('cross-spawn');
|
|
6
6
|
require('@agentclientprotocol/sdk');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-CT1dgGsX.cjs');
|
|
8
8
|
require('ps-list');
|
|
9
9
|
require('fs');
|
|
10
10
|
require('path');
|
|
@@ -25,9 +25,9 @@ require('tweetnacl');
|
|
|
25
25
|
require('open');
|
|
26
26
|
var React = require('react');
|
|
27
27
|
var ink = require('ink');
|
|
28
|
-
var ProviderSelectionHandler = require('./ProviderSelectionHandler-
|
|
28
|
+
var ProviderSelectionHandler = require('./ProviderSelectionHandler-D9Bd_S25.cjs');
|
|
29
29
|
var types = require('./types-DVk3crez.cjs');
|
|
30
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
30
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-9O3r5bEa.cjs');
|
|
31
31
|
require('socket.io-client');
|
|
32
32
|
require('expo-server-sdk');
|
|
33
33
|
var node_util = require('node:util');
|
|
@@ -3321,7 +3321,7 @@ function bindClaudeUserMessageQueue(opts) {
|
|
|
3321
3321
|
async function runClaude(credentials, options = {}) {
|
|
3322
3322
|
persistence.logger.debug(`[CLAUDE] ===== CLAUDE MODE STARTING =====`);
|
|
3323
3323
|
persistence.logger.debug(`[CLAUDE] This is the Claude agent, NOT Gemini`);
|
|
3324
|
-
const
|
|
3324
|
+
const requestedWorkingDirectory = process.cwd();
|
|
3325
3325
|
const sessionTag = node_crypto.randomUUID();
|
|
3326
3326
|
persistence.logger.debugLargeJson("[START] Happy process started", index.getEnvironmentInfo());
|
|
3327
3327
|
persistence.logger.debug(`[START] Options: startedBy=${options.startedBy}, startingMode=${options.startingMode}`);
|
|
@@ -3347,8 +3347,10 @@ async function runClaude(credentials, options = {}) {
|
|
|
3347
3347
|
const { state, metadata } = index.createSessionMetadata({
|
|
3348
3348
|
flavor: "claude",
|
|
3349
3349
|
machineId,
|
|
3350
|
-
startedBy: options.startedBy
|
|
3350
|
+
startedBy: options.startedBy,
|
|
3351
|
+
path: requestedWorkingDirectory
|
|
3351
3352
|
});
|
|
3353
|
+
const workingDirectory = metadata.path;
|
|
3352
3354
|
let response = null;
|
|
3353
3355
|
try {
|
|
3354
3356
|
response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { l as logger, g as backoff, h as delay, j as AsyncLock, c as configuration, s as startOfflineReconnection, b as connectionState, A as ApiClient, i as isAuthenticationRequiredError } from './api-
|
|
2
|
+
import { l as logger, g as backoff, h as delay, j as AsyncLock, c as configuration, s as startOfflineReconnection, b as connectionState, A as ApiClient, i as isAuthenticationRequiredError } from './api-DIFbsA6t.mjs';
|
|
3
3
|
import 'cross-spawn';
|
|
4
4
|
import '@agentclientprotocol/sdk';
|
|
5
|
-
import { m as getProjectPath, F as Future, n as claudeLocal, E as ExitCodeError, o as trimIdent, q as createClaudeBackend, f as formatDisplayMessage, t as truncateDisplayMessage, u as claudeCheckSession, w as projectPath, x as mapToClaudeMode, P as PushableAsyncIterable, y as query, A as AbortError, e as stopCaffeinate, p as publishSessionRegistration, z as getEnvironmentInfo, a as createSessionMetadata, B as startCaffeinate, b as closeProviderSession } from './index-
|
|
5
|
+
import { m as getProjectPath, F as Future, n as claudeLocal, E as ExitCodeError, o as trimIdent, q as createClaudeBackend, f as formatDisplayMessage, t as truncateDisplayMessage, u as claudeCheckSession, w as projectPath, x as mapToClaudeMode, P as PushableAsyncIterable, y as query, A as AbortError, e as stopCaffeinate, p as publishSessionRegistration, z as getEnvironmentInfo, a as createSessionMetadata, B as startCaffeinate, b as closeProviderSession } from './index-CFH8qcTw.mjs';
|
|
6
6
|
import 'ps-list';
|
|
7
7
|
import 'fs';
|
|
8
8
|
import 'path';
|
|
@@ -23,9 +23,9 @@ import 'tweetnacl';
|
|
|
23
23
|
import 'open';
|
|
24
24
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
25
25
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
26
|
-
import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-
|
|
26
|
+
import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-C1q60HP6.mjs';
|
|
27
27
|
import { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
28
|
-
import { B as BasePermissionHandler, d as MessageBuffer, C as ConversationHistory$1, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, m as forwardAgentMessageToProviderSession, s as syncControlledByUserState, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, h as hashObject, c as registerKillSessionHandler } from './registerKillSessionHandler-
|
|
28
|
+
import { B as BasePermissionHandler, d as MessageBuffer, C as ConversationHistory$1, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, m as forwardAgentMessageToProviderSession, s as syncControlledByUserState, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, h as hashObject, c as registerKillSessionHandler } from './registerKillSessionHandler-DxpGgu6u.mjs';
|
|
29
29
|
import 'socket.io-client';
|
|
30
30
|
import 'expo-server-sdk';
|
|
31
31
|
import { isDeepStrictEqual } from 'node:util';
|
|
@@ -3319,7 +3319,7 @@ function bindClaudeUserMessageQueue(opts) {
|
|
|
3319
3319
|
async function runClaude(credentials, options = {}) {
|
|
3320
3320
|
logger.debug(`[CLAUDE] ===== CLAUDE MODE STARTING =====`);
|
|
3321
3321
|
logger.debug(`[CLAUDE] This is the Claude agent, NOT Gemini`);
|
|
3322
|
-
const
|
|
3322
|
+
const requestedWorkingDirectory = process.cwd();
|
|
3323
3323
|
const sessionTag = randomUUID();
|
|
3324
3324
|
logger.debugLargeJson("[START] Happy process started", getEnvironmentInfo());
|
|
3325
3325
|
logger.debug(`[START] Options: startedBy=${options.startedBy}, startingMode=${options.startingMode}`);
|
|
@@ -3345,8 +3345,10 @@ async function runClaude(credentials, options = {}) {
|
|
|
3345
3345
|
const { state, metadata } = createSessionMetadata({
|
|
3346
3346
|
flavor: "claude",
|
|
3347
3347
|
machineId,
|
|
3348
|
-
startedBy: options.startedBy
|
|
3348
|
+
startedBy: options.startedBy,
|
|
3349
|
+
path: requestedWorkingDirectory
|
|
3349
3350
|
});
|
|
3351
|
+
const workingDirectory = metadata.path;
|
|
3350
3352
|
let response = null;
|
|
3351
3353
|
try {
|
|
3352
3354
|
response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as preserveSessionRuntimeMetadata, l as logger, b as connectionState, A as ApiClient } from './api-
|
|
2
|
-
import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, c as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, k as inferToolResultError, m as forwardAgentMessageToProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, r as resolveHappyOrgQueuedTurn, s as syncControlledByUserState } from './registerKillSessionHandler-
|
|
3
|
-
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, h as createCodexBackend, t as truncateDisplayMessage, b as closeProviderSession, e as stopCaffeinate, i as readManagedSessionTag, j as resolveManagedSessionTag } from './index-
|
|
1
|
+
import { p as preserveSessionRuntimeMetadata, l as logger, b as connectionState, A as ApiClient } from './api-DIFbsA6t.mjs';
|
|
2
|
+
import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, c as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, k as inferToolResultError, m as forwardAgentMessageToProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, r as resolveHappyOrgQueuedTurn, s as syncControlledByUserState } from './registerKillSessionHandler-DxpGgu6u.mjs';
|
|
3
|
+
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, h as createCodexBackend, t as truncateDisplayMessage, b as closeProviderSession, e as stopCaffeinate, i as readManagedSessionTag, j as resolveManagedSessionTag } from './index-CFH8qcTw.mjs';
|
|
4
4
|
import 'cross-spawn';
|
|
5
5
|
import '@agentclientprotocol/sdk';
|
|
6
6
|
import { randomUUID } from 'node:crypto';
|
|
@@ -24,8 +24,8 @@ import 'tweetnacl';
|
|
|
24
24
|
import 'open';
|
|
25
25
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
26
26
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
27
|
-
import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-
|
|
28
|
-
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-
|
|
27
|
+
import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-C1q60HP6.mjs';
|
|
28
|
+
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-CfibmGoR.mjs';
|
|
29
29
|
import 'zod';
|
|
30
30
|
import 'socket.io-client';
|
|
31
31
|
import 'expo-server-sdk';
|
|
@@ -153,6 +153,7 @@ function createCodexRuntimeSession(options) {
|
|
|
153
153
|
class CodexSession {
|
|
154
154
|
path;
|
|
155
155
|
logPath;
|
|
156
|
+
startupRolePrompt;
|
|
156
157
|
api;
|
|
157
158
|
client;
|
|
158
159
|
runtimeSession;
|
|
@@ -173,6 +174,7 @@ class CodexSession {
|
|
|
173
174
|
this.path = opts.path;
|
|
174
175
|
this.api = opts.api;
|
|
175
176
|
this.client = opts.client;
|
|
177
|
+
this.startupRolePrompt = opts.startupRolePrompt ?? null;
|
|
176
178
|
this.protocolDescriptor = opts.protocolDescriptor ?? null;
|
|
177
179
|
this.protocolStateSources = opts.protocolStateSources ?? [];
|
|
178
180
|
this.userObserver = opts.userObserver ?? null;
|
|
@@ -1164,24 +1166,30 @@ async function codexRemoteLauncher(session) {
|
|
|
1164
1166
|
try {
|
|
1165
1167
|
turnInFlight = true;
|
|
1166
1168
|
shouldCommitAccumulatedResponse = false;
|
|
1169
|
+
const isNewRuntimeSession = runtimeHandle === null;
|
|
1167
1170
|
const activeRuntimeHandle = runtimeHandle ?? await createRuntimeHandle(message.mode);
|
|
1168
1171
|
if (!activeRuntimeHandle) {
|
|
1169
1172
|
throw new Error("Failed to create Codex ACP backend");
|
|
1170
1173
|
}
|
|
1171
1174
|
session.onThinkingChange(true);
|
|
1172
|
-
|
|
1175
|
+
const promptPreludeParts = [];
|
|
1176
|
+
if (isNewRuntimeSession && session.startupRolePrompt) {
|
|
1177
|
+
promptPreludeParts.push(session.startupRolePrompt);
|
|
1178
|
+
logger.debug("[Codex] Injected local startup home identity prompt into a new ACP session");
|
|
1179
|
+
}
|
|
1173
1180
|
if (shouldInjectLargeOutputRecoveryHintOnNextSession) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
${promptToSend}`;
|
|
1181
|
+
promptPreludeParts.push(CODEX_LARGE_OUTPUT_RECOVERY_HINT);
|
|
1177
1182
|
shouldInjectLargeOutputRecoveryHintOnNextSession = false;
|
|
1178
1183
|
logger.debug("[Codex] Injected large-output recovery hint into the next session prompt");
|
|
1179
1184
|
}
|
|
1180
1185
|
if (shouldInjectHistoryOnNextSession && conversationHistory.hasHistory()) {
|
|
1181
1186
|
const historyContext = conversationHistory.getContextForNewSession();
|
|
1182
|
-
|
|
1187
|
+
promptPreludeParts.push(historyContext.trim());
|
|
1183
1188
|
logger.debug(`[Codex] Injected conversation history context (${historyContext.length} chars)`);
|
|
1184
1189
|
}
|
|
1190
|
+
let promptToSend = promptPreludeParts.length > 0 ? `${promptPreludeParts.join("\n\n")}
|
|
1191
|
+
|
|
1192
|
+
${message.message}` : message.message;
|
|
1185
1193
|
if (message.mode.happyOrg) {
|
|
1186
1194
|
promptToSend = buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
|
|
1187
1195
|
}
|
|
@@ -1434,7 +1442,7 @@ async function runCodex(opts) {
|
|
|
1434
1442
|
}
|
|
1435
1443
|
let sessionClient;
|
|
1436
1444
|
let codexSession = null;
|
|
1437
|
-
const { metadata, session: initialSession, reconnectionHandle } = await bootstrapManagedProviderSession({
|
|
1445
|
+
const { metadata, session: initialSession, reconnectionHandle, happyOrgStartupBinding } = await bootstrapManagedProviderSession({
|
|
1438
1446
|
api,
|
|
1439
1447
|
sessionTag,
|
|
1440
1448
|
flavor: "codex",
|
|
@@ -1495,8 +1503,9 @@ async function runCodex(opts) {
|
|
|
1495
1503
|
codexSession = new CodexSession({
|
|
1496
1504
|
api,
|
|
1497
1505
|
client: sessionClient,
|
|
1498
|
-
path:
|
|
1506
|
+
path: metadata.path,
|
|
1499
1507
|
logPath: logger.logFilePath,
|
|
1508
|
+
startupRolePrompt: happyOrgStartupBinding?.identityPrompt ?? null,
|
|
1500
1509
|
sessionId: null,
|
|
1501
1510
|
mode: requestedStartingMode,
|
|
1502
1511
|
messageQueue,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var persistence = require('./api-
|
|
4
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
5
|
-
var index = require('./index-
|
|
3
|
+
var persistence = require('./api-DeDVledu.cjs');
|
|
4
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-9O3r5bEa.cjs');
|
|
5
|
+
var index = require('./index-CT1dgGsX.cjs');
|
|
6
6
|
require('cross-spawn');
|
|
7
7
|
require('@agentclientprotocol/sdk');
|
|
8
8
|
var node_crypto = require('node:crypto');
|
|
@@ -26,8 +26,8 @@ require('tweetnacl');
|
|
|
26
26
|
require('open');
|
|
27
27
|
var React = require('react');
|
|
28
28
|
var ink = require('ink');
|
|
29
|
-
var ProviderSelectionHandler = require('./ProviderSelectionHandler-
|
|
30
|
-
var BaseReasoningProcessor = require('./BaseReasoningProcessor-
|
|
29
|
+
var ProviderSelectionHandler = require('./ProviderSelectionHandler-D9Bd_S25.cjs');
|
|
30
|
+
var BaseReasoningProcessor = require('./BaseReasoningProcessor-CQQrYyo3.cjs');
|
|
31
31
|
require('zod');
|
|
32
32
|
require('socket.io-client');
|
|
33
33
|
require('expo-server-sdk');
|
|
@@ -155,6 +155,7 @@ function createCodexRuntimeSession(options) {
|
|
|
155
155
|
class CodexSession {
|
|
156
156
|
path;
|
|
157
157
|
logPath;
|
|
158
|
+
startupRolePrompt;
|
|
158
159
|
api;
|
|
159
160
|
client;
|
|
160
161
|
runtimeSession;
|
|
@@ -175,6 +176,7 @@ class CodexSession {
|
|
|
175
176
|
this.path = opts.path;
|
|
176
177
|
this.api = opts.api;
|
|
177
178
|
this.client = opts.client;
|
|
179
|
+
this.startupRolePrompt = opts.startupRolePrompt ?? null;
|
|
178
180
|
this.protocolDescriptor = opts.protocolDescriptor ?? null;
|
|
179
181
|
this.protocolStateSources = opts.protocolStateSources ?? [];
|
|
180
182
|
this.userObserver = opts.userObserver ?? null;
|
|
@@ -1166,24 +1168,30 @@ async function codexRemoteLauncher(session) {
|
|
|
1166
1168
|
try {
|
|
1167
1169
|
turnInFlight = true;
|
|
1168
1170
|
shouldCommitAccumulatedResponse = false;
|
|
1171
|
+
const isNewRuntimeSession = runtimeHandle === null;
|
|
1169
1172
|
const activeRuntimeHandle = runtimeHandle ?? await createRuntimeHandle(message.mode);
|
|
1170
1173
|
if (!activeRuntimeHandle) {
|
|
1171
1174
|
throw new Error("Failed to create Codex ACP backend");
|
|
1172
1175
|
}
|
|
1173
1176
|
session.onThinkingChange(true);
|
|
1174
|
-
|
|
1177
|
+
const promptPreludeParts = [];
|
|
1178
|
+
if (isNewRuntimeSession && session.startupRolePrompt) {
|
|
1179
|
+
promptPreludeParts.push(session.startupRolePrompt);
|
|
1180
|
+
persistence.logger.debug("[Codex] Injected local startup home identity prompt into a new ACP session");
|
|
1181
|
+
}
|
|
1175
1182
|
if (shouldInjectLargeOutputRecoveryHintOnNextSession) {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
${promptToSend}`;
|
|
1183
|
+
promptPreludeParts.push(CODEX_LARGE_OUTPUT_RECOVERY_HINT);
|
|
1179
1184
|
shouldInjectLargeOutputRecoveryHintOnNextSession = false;
|
|
1180
1185
|
persistence.logger.debug("[Codex] Injected large-output recovery hint into the next session prompt");
|
|
1181
1186
|
}
|
|
1182
1187
|
if (shouldInjectHistoryOnNextSession && conversationHistory.hasHistory()) {
|
|
1183
1188
|
const historyContext = conversationHistory.getContextForNewSession();
|
|
1184
|
-
|
|
1189
|
+
promptPreludeParts.push(historyContext.trim());
|
|
1185
1190
|
persistence.logger.debug(`[Codex] Injected conversation history context (${historyContext.length} chars)`);
|
|
1186
1191
|
}
|
|
1192
|
+
let promptToSend = promptPreludeParts.length > 0 ? `${promptPreludeParts.join("\n\n")}
|
|
1193
|
+
|
|
1194
|
+
${message.message}` : message.message;
|
|
1187
1195
|
if (message.mode.happyOrg) {
|
|
1188
1196
|
promptToSend = registerKillSessionHandler.buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
|
|
1189
1197
|
}
|
|
@@ -1436,7 +1444,7 @@ async function runCodex(opts) {
|
|
|
1436
1444
|
}
|
|
1437
1445
|
let sessionClient;
|
|
1438
1446
|
let codexSession = null;
|
|
1439
|
-
const { metadata, session: initialSession, reconnectionHandle } = await BaseReasoningProcessor.bootstrapManagedProviderSession({
|
|
1447
|
+
const { metadata, session: initialSession, reconnectionHandle, happyOrgStartupBinding } = await BaseReasoningProcessor.bootstrapManagedProviderSession({
|
|
1440
1448
|
api,
|
|
1441
1449
|
sessionTag,
|
|
1442
1450
|
flavor: "codex",
|
|
@@ -1497,8 +1505,9 @@ async function runCodex(opts) {
|
|
|
1497
1505
|
codexSession = new CodexSession({
|
|
1498
1506
|
api,
|
|
1499
1507
|
client: sessionClient,
|
|
1500
|
-
path:
|
|
1508
|
+
path: metadata.path,
|
|
1501
1509
|
logPath: persistence.logger.logFilePath,
|
|
1510
|
+
startupRolePrompt: happyOrgStartupBinding?.identityPrompt ?? null,
|
|
1502
1511
|
sessionId: null,
|
|
1503
1512
|
mode: requestedStartingMode,
|
|
1504
1513
|
messageQueue,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
2
2
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { l as logger, b as connectionState, A as ApiClient } from './api-
|
|
5
|
-
import { B as BasePermissionHandler, C as ConversationHistory$1, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, h as hashObject, c as registerKillSessionHandler, d as MessageBuffer, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, k as inferToolResultError, m as forwardAgentMessageToProviderSession } from './registerKillSessionHandler-
|
|
6
|
-
import { g as getInitialGeminiModel, r as readGeminiLocalConfig, G as GEMINI_MODEL_ENV, b as closeProviderSession, s as saveGeminiModelToConfig, d as createGeminiBackend, e as stopCaffeinate } from './index-
|
|
7
|
-
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-
|
|
4
|
+
import { l as logger, b as connectionState, A as ApiClient } from './api-DIFbsA6t.mjs';
|
|
5
|
+
import { B as BasePermissionHandler, C as ConversationHistory$1, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, h as hashObject, c as registerKillSessionHandler, d as MessageBuffer, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, i as finalizeHappyOrgTurnWithBusinessAck, l as launchRuntimeHandleWithFactoryResult, j as renderOutputPreview, k as inferToolResultError, m as forwardAgentMessageToProviderSession } from './registerKillSessionHandler-DxpGgu6u.mjs';
|
|
6
|
+
import { g as getInitialGeminiModel, r as readGeminiLocalConfig, G as GEMINI_MODEL_ENV, b as closeProviderSession, s as saveGeminiModelToConfig, d as createGeminiBackend, e as stopCaffeinate } from './index-CFH8qcTw.mjs';
|
|
7
|
+
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-CfibmGoR.mjs';
|
|
8
8
|
import 'cross-spawn';
|
|
9
9
|
import '@agentclientprotocol/sdk';
|
|
10
10
|
import 'ps-list';
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var ink = require('ink');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var persistence = require('./api-
|
|
7
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
8
|
-
var index = require('./index-
|
|
9
|
-
var BaseReasoningProcessor = require('./BaseReasoningProcessor-
|
|
6
|
+
var persistence = require('./api-DeDVledu.cjs');
|
|
7
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-9O3r5bEa.cjs');
|
|
8
|
+
var index = require('./index-CT1dgGsX.cjs');
|
|
9
|
+
var BaseReasoningProcessor = require('./BaseReasoningProcessor-CQQrYyo3.cjs');
|
|
10
10
|
require('cross-spawn');
|
|
11
11
|
require('@agentclientprotocol/sdk');
|
|
12
12
|
require('ps-list');
|