@zonease/happy 0.6.38 → 0.6.40
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/bin/happy.mjs +10 -0
- package/dist/{types-DvTsFaqR.cjs → api-C7FyJfZ1.cjs} +400 -1964
- package/dist/{types-BWpRU1VN.mjs → api-D6WL40-U.mjs} +220 -1729
- package/dist/auth-C7ZScWEw.cjs +274 -0
- package/dist/auth-DCsIoZLT.cjs +183 -0
- package/dist/auth-DO9GexAR.mjs +181 -0
- package/dist/auth-DxJ3VvrX.mjs +270 -0
- package/dist/browser-AoVGRX7y.mjs +20 -0
- package/dist/browser-DzgO4oaD.cjs +22 -0
- package/dist/claudeLocal-C6BdzhDx.cjs +352 -0
- package/dist/claudeLocal-CWNGpJ0-.mjs +344 -0
- package/dist/codex/happyMcpStdioBridge.cjs +4 -1
- package/dist/codex/happyMcpStdioBridge.mjs +4 -1
- package/dist/common-BdNgghUJ.mjs +75 -0
- package/dist/common-CZvSRU4p.cjs +83 -0
- package/dist/{config-0Xnc8ARM.cjs → config-CclB3QW9.cjs} +21 -34
- package/dist/{config-_GW4YBCP.mjs → config-DZk-mJ0K.mjs} +7 -20
- package/dist/connect-BXLUKJ5P.mjs +679 -0
- package/dist/connect-k9CqDJ-T.cjs +681 -0
- package/dist/{constants-B4x1K7by.cjs → constants-E_UWYTo3.cjs} +2 -2
- package/dist/{constants-BO9OAFOT.mjs → constants-pmXZGibX.mjs} +1 -1
- package/dist/controlClient-B23M-WPp.cjs +177 -0
- package/dist/controlClient-DB5tDU7V.mjs +167 -0
- package/dist/deviceKeys-BTdo34Uz.mjs +175 -0
- package/dist/deviceKeys-C540DcXl.cjs +182 -0
- package/dist/diagnose-B3D1a_v0.cjs +60 -0
- package/dist/diagnose-CuRKXxt1.mjs +58 -0
- package/dist/doctor-BQGLhrcI.cjs +214 -0
- package/dist/doctor-C08m5Z9f.cjs +78 -0
- package/dist/doctor-CU4JLGQ1.mjs +211 -0
- package/dist/doctor-ON7pN5G5.mjs +74 -0
- package/dist/downloadImage-DZXI3mXL.mjs +887 -0
- package/dist/downloadImage-cQ1Z7hkC.cjs +897 -0
- package/dist/enroll-B55BQR56.mjs +113 -0
- package/dist/enroll-Bo-CNio1.cjs +115 -0
- package/dist/evidence-DQp8QWcv.cjs +129 -0
- package/dist/evidence-DTYRAaOZ.mjs +127 -0
- package/dist/formatImageMessage-CixDYY6G.cjs +46 -0
- package/dist/formatImageMessage-DbKSSjMx.mjs +43 -0
- package/dist/github-DKcyF1zp.mjs +57 -0
- package/dist/github-h9GhJJ_C.cjs +59 -0
- package/dist/index-CDTNgfUf.cjs +578 -0
- package/dist/index-CPKdvi7J.mjs +554 -0
- package/dist/index.cjs +812 -40
- package/dist/index.mjs +813 -40
- package/dist/install-B1e6rdy7.mjs +94 -0
- package/dist/install-CgUPGIoF.mjs +95 -0
- package/dist/install-D7Ir7ciZ.cjs +96 -0
- package/dist/install-DSDufaPd.cjs +98 -0
- package/dist/lib.cjs +18 -12
- package/dist/lib.d.cts +77 -0
- package/dist/lib.d.mts +77 -0
- package/dist/lib.mjs +13 -7
- package/dist/{loadableToolOutput-va3RLplh.mjs → loadableToolOutput-Bfei9wPq.mjs} +4 -2
- package/dist/{loadableToolOutput-5vdQB98M.cjs → loadableToolOutput-CbLGtvST.cjs} +63 -61
- package/dist/mcpToolSchemas-CjeTfrAs.mjs +62 -0
- package/dist/mcpToolSchemas-DK42yoZ_.cjs +64 -0
- package/dist/persistence-CBTtC_dm.cjs +996 -0
- package/dist/persistence-DKfF81pd.mjs +944 -0
- package/dist/projectPath-BTBIMB57.mjs +10 -0
- package/dist/projectPath-ChLhdOyt.cjs +13 -0
- package/dist/prompt-BTWDZZO0.cjs +25 -0
- package/dist/prompt-BsAZsPbo.mjs +22 -0
- package/dist/release-BMEzNONE.mjs +168 -0
- package/dist/release-EhOJeAZe.cjs +171 -0
- package/dist/run-BVZsMNwN.mjs +2164 -0
- package/dist/run-CURx7LhK.cjs +2188 -0
- package/dist/runClaude-6Gi0sYQy.mjs +3763 -0
- package/dist/runClaude-CL3Kt5ex.cjs +3766 -0
- package/dist/{runCodex-DiKzBf9q.mjs → runCodex-ClwEgJ7M.mjs} +36 -20
- package/dist/{runCodex-skq0j05d.cjs → runCodex-YKyVBkJ3.cjs} +169 -153
- package/dist/{runGemini-BeqrVq8R.mjs → runGemini-BPWxVr60.mjs} +34 -17
- package/dist/{runGemini-CVp-CEIh.cjs → runGemini-Xz2W1spn.cjs} +212 -195
- package/dist/{runOneShot-ltCpHbBB.mjs → runOneShot-CdCWiiLr.mjs} +14 -38
- package/dist/{runOneShot-BQNkNW61.cjs → runOneShot-DjZyCvDI.cjs} +31 -55
- package/dist/{serve-BNdoEDVx.mjs → serve-B48JttQ3.mjs} +12 -35
- package/dist/{serve-BECdtivY.cjs → serve-B8vaWQA0.cjs} +35 -58
- package/dist/session-BXboDn2V.mjs +108 -0
- package/dist/session-BZO25zxp.cjs +110 -0
- package/dist/sessionKeyCache-B6cGadYL.mjs +33 -0
- package/dist/sessionKeyCache-CDmexJ9p.cjs +36 -0
- package/dist/sessionList-CgAYZpNj.mjs +51 -0
- package/dist/sessionList-lQ-nqEhc.cjs +54 -0
- package/dist/sessionSummary-CcORiQSq.cjs +393 -0
- package/dist/sessionSummary-DCWQoaDP.mjs +387 -0
- package/dist/spawnHappyCLI-KiazE3kL.cjs +70 -0
- package/dist/spawnHappyCLI-yBIP_Oqi.mjs +66 -0
- package/dist/ssh-q5uZhqBf.mjs +359 -0
- package/dist/ssh-yMllSHu5.cjs +365 -0
- package/dist/systemdScope-BeOtAkhk.mjs +25 -0
- package/dist/systemdScope-DW3-UoKB.cjs +29 -0
- package/dist/task-_nr7J19j.cjs +167 -0
- package/dist/task-wNX1N2i4.mjs +165 -0
- package/dist/time-Bj2HRkKH.cjs +33 -0
- package/dist/time-DgsBLJA_.mjs +29 -0
- package/dist/trimIdent-4gvk9Wk6.cjs +22 -0
- package/dist/trimIdent-BAjmv_TG.mjs +20 -0
- package/dist/types-BoJh4Qfv.mjs +57 -0
- package/dist/types-DWeB7aqh.cjs +59 -0
- package/dist/uninstall-Buaz7d-X.cjs +77 -0
- package/dist/uninstall-Dxf6_4mQ.mjs +75 -0
- package/dist/update-CGlIfa8e.cjs +111 -0
- package/dist/update-CnnoX2cV.mjs +109 -0
- package/dist/workflowCommon-B0d01Y_a.mjs +56 -0
- package/dist/workflowCommon-Bl568-rt.cjs +62 -0
- package/dist/workflowReports-BEWuQesA.cjs +113 -0
- package/dist/workflowReports-Dd8-4-8f.mjs +108 -0
- package/package.json +1 -1
- package/dist/index-BbCDDvoB.cjs +0 -11376
- package/dist/index-vvZXdswy.mjs +0 -11336
- package/dist/mcpToolSchemas-CdPXJQmb.mjs +0 -175
- package/dist/mcpToolSchemas-f-kttjFw.cjs +0 -186
|
@@ -1,48 +1,24 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import { c as claudeCliPath } from './
|
|
4
|
-
import { l as logger
|
|
5
|
-
import { i as
|
|
6
|
-
import '
|
|
7
|
-
import 'node:os';
|
|
8
|
-
import 'node:crypto';
|
|
9
|
-
import 'node:fs/promises';
|
|
3
|
+
import { c as claudeCliPath } from './claudeLocal-CWNGpJ0-.mjs';
|
|
4
|
+
import { l as logger } from './persistence-DKfF81pd.mjs';
|
|
5
|
+
import { i as isModelModeForAgent, M as MODEL_MODE_DEFAULT, p as parseCodexModelMode, a as parseClaudeModelMode } from './index-CPKdvi7J.mjs';
|
|
6
|
+
import { i as isOrchestratorProvider, O as ORCHESTRATOR_ENV_KEYS, d as decodePromptFromBase64 } from './common-BdNgghUJ.mjs';
|
|
10
7
|
import 'node:path';
|
|
11
8
|
import 'node:readline';
|
|
12
|
-
import '
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import 'node:url';
|
|
16
|
-
import 'axios';
|
|
17
|
-
import 'node:events';
|
|
18
|
-
import 'socket.io-client';
|
|
19
|
-
import 'tweetnacl';
|
|
20
|
-
import 'ws';
|
|
21
|
-
import 'crypto';
|
|
22
|
-
import '@stablelib/base64';
|
|
23
|
-
import 'expo-server-sdk';
|
|
24
|
-
import 'node:util';
|
|
25
|
-
import 'child_process';
|
|
26
|
-
import 'fs';
|
|
9
|
+
import 'node:crypto';
|
|
10
|
+
import 'node:os';
|
|
11
|
+
import './projectPath-BTBIMB57.mjs';
|
|
27
12
|
import 'path';
|
|
28
|
-
import '
|
|
29
|
-
import '
|
|
30
|
-
import '
|
|
31
|
-
import '
|
|
32
|
-
import 'qrcode-terminal';
|
|
33
|
-
import 'open';
|
|
34
|
-
import 'fastify';
|
|
13
|
+
import 'url';
|
|
14
|
+
import './prompt-BsAZsPbo.mjs';
|
|
15
|
+
import './trimIdent-BAjmv_TG.mjs';
|
|
16
|
+
import 'node:fs/promises';
|
|
35
17
|
import 'zod';
|
|
36
|
-
import '
|
|
37
|
-
import '
|
|
38
|
-
import '
|
|
39
|
-
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
40
|
-
import '@modelcontextprotocol/sdk/types.js';
|
|
41
|
-
import 'http';
|
|
42
|
-
import 'util';
|
|
18
|
+
import 'tweetnacl';
|
|
19
|
+
import 'chalk';
|
|
20
|
+
import 'fs';
|
|
43
21
|
import '@paralleldrive/cuid2';
|
|
44
|
-
import 'url';
|
|
45
|
-
import 'node:module';
|
|
46
22
|
|
|
47
23
|
function parseProvider(providerArg) {
|
|
48
24
|
if (!providerArg || !isOrchestratorProvider(providerArg)) {
|
|
@@ -2,86 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
var node_child_process = require('node:child_process');
|
|
4
4
|
var fs = require('node:fs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
require('
|
|
9
|
-
require('node:os');
|
|
10
|
-
require('node:crypto');
|
|
11
|
-
require('node:fs/promises');
|
|
5
|
+
var claudeLocal = require('./claudeLocal-C6BdzhDx.cjs');
|
|
6
|
+
var logger = require('./persistence-CBTtC_dm.cjs');
|
|
7
|
+
var index = require('./index-CDTNgfUf.cjs');
|
|
8
|
+
var common = require('./common-CZvSRU4p.cjs');
|
|
12
9
|
require('node:path');
|
|
13
10
|
require('node:readline');
|
|
14
|
-
require('
|
|
15
|
-
require('
|
|
16
|
-
require('
|
|
17
|
-
require('node:url');
|
|
18
|
-
require('axios');
|
|
19
|
-
require('node:events');
|
|
20
|
-
require('socket.io-client');
|
|
21
|
-
require('tweetnacl');
|
|
22
|
-
require('ws');
|
|
23
|
-
require('crypto');
|
|
24
|
-
require('@stablelib/base64');
|
|
25
|
-
require('expo-server-sdk');
|
|
26
|
-
require('node:util');
|
|
27
|
-
require('child_process');
|
|
28
|
-
require('fs');
|
|
11
|
+
require('node:crypto');
|
|
12
|
+
require('node:os');
|
|
13
|
+
require('./projectPath-ChLhdOyt.cjs');
|
|
29
14
|
require('path');
|
|
30
|
-
require('
|
|
31
|
-
require('
|
|
32
|
-
require('
|
|
33
|
-
require('
|
|
34
|
-
require('qrcode-terminal');
|
|
35
|
-
require('open');
|
|
36
|
-
require('fastify');
|
|
15
|
+
require('url');
|
|
16
|
+
require('./prompt-BTWDZZO0.cjs');
|
|
17
|
+
require('./trimIdent-4gvk9Wk6.cjs');
|
|
18
|
+
require('node:fs/promises');
|
|
37
19
|
require('zod');
|
|
38
|
-
require('
|
|
39
|
-
require('
|
|
40
|
-
require('
|
|
41
|
-
require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
42
|
-
require('@modelcontextprotocol/sdk/types.js');
|
|
43
|
-
require('http');
|
|
44
|
-
require('util');
|
|
20
|
+
require('tweetnacl');
|
|
21
|
+
require('chalk');
|
|
22
|
+
require('fs');
|
|
45
23
|
require('@paralleldrive/cuid2');
|
|
46
|
-
require('url');
|
|
47
|
-
require('node:module');
|
|
48
24
|
|
|
49
25
|
function parseProvider(providerArg) {
|
|
50
|
-
if (!providerArg || !
|
|
26
|
+
if (!providerArg || !common.isOrchestratorProvider(providerArg)) {
|
|
51
27
|
throw new Error(`Invalid --provider value: ${providerArg ?? "(missing)"}`);
|
|
52
28
|
}
|
|
53
29
|
return providerArg;
|
|
54
30
|
}
|
|
55
31
|
function readPromptFromEnv() {
|
|
56
|
-
const promptB64 = process.env[
|
|
32
|
+
const promptB64 = process.env[common.ORCHESTRATOR_ENV_KEYS.promptB64];
|
|
57
33
|
if (!promptB64) {
|
|
58
|
-
throw new Error(`${
|
|
34
|
+
throw new Error(`${common.ORCHESTRATOR_ENV_KEYS.promptB64} is required`);
|
|
59
35
|
}
|
|
60
|
-
return
|
|
36
|
+
return common.decodePromptFromBase64(promptB64);
|
|
61
37
|
}
|
|
62
38
|
function readWorkingDirectoryFromEnv() {
|
|
63
|
-
const value = process.env[
|
|
39
|
+
const value = process.env[common.ORCHESTRATOR_ENV_KEYS.workingDirectory];
|
|
64
40
|
if (typeof value !== "string" || value.length === 0) {
|
|
65
41
|
return void 0;
|
|
66
42
|
}
|
|
67
43
|
return value;
|
|
68
44
|
}
|
|
69
45
|
function readModelModeFromEnv() {
|
|
70
|
-
const value = process.env[
|
|
46
|
+
const value = process.env[common.ORCHESTRATOR_ENV_KEYS.modelMode];
|
|
71
47
|
if (typeof value !== "string" || value.length === 0) {
|
|
72
48
|
return void 0;
|
|
73
49
|
}
|
|
74
50
|
return value;
|
|
75
51
|
}
|
|
76
52
|
function readExecutionTypeFromEnv() {
|
|
77
|
-
const value = process.env[
|
|
53
|
+
const value = process.env[common.ORCHESTRATOR_ENV_KEYS.executionType];
|
|
78
54
|
if (value === "resume") {
|
|
79
55
|
return "resume";
|
|
80
56
|
}
|
|
81
57
|
return "initial";
|
|
82
58
|
}
|
|
83
59
|
function readChildSessionIdFromEnv() {
|
|
84
|
-
const value = process.env[
|
|
60
|
+
const value = process.env[common.ORCHESTRATOR_ENV_KEYS.childSessionId];
|
|
85
61
|
if (typeof value !== "string" || value.length === 0) {
|
|
86
62
|
return void 0;
|
|
87
63
|
}
|
|
@@ -91,17 +67,17 @@ function buildSpawnPlan(provider, prompt, workingDirectory, modelMode, execution
|
|
|
91
67
|
if (executionType === "resume" && !childSessionId) {
|
|
92
68
|
throw new Error("childSessionId is required for resume execution");
|
|
93
69
|
}
|
|
94
|
-
const normalizedModelMode = modelMode ===
|
|
70
|
+
const normalizedModelMode = modelMode === index.MODEL_MODE_DEFAULT ? void 0 : modelMode;
|
|
95
71
|
switch (provider) {
|
|
96
72
|
case "claude": {
|
|
97
|
-
const baseArgs = [
|
|
73
|
+
const baseArgs = [claudeLocal.claudeCliPath, "--dangerously-skip-permissions"];
|
|
98
74
|
if (executionType === "resume") {
|
|
99
75
|
baseArgs.push("--resume", childSessionId, "-p", prompt);
|
|
100
76
|
} else {
|
|
101
77
|
if (normalizedModelMode) {
|
|
102
|
-
if (
|
|
103
|
-
const parsed =
|
|
104
|
-
if (parsed.family !==
|
|
78
|
+
if (index.isModelModeForAgent("claude", normalizedModelMode)) {
|
|
79
|
+
const parsed = index.parseClaudeModelMode(normalizedModelMode);
|
|
80
|
+
if (parsed.family !== index.MODEL_MODE_DEFAULT) {
|
|
105
81
|
baseArgs.push("--model", parsed.family);
|
|
106
82
|
if (parsed.effort) {
|
|
107
83
|
baseArgs.push("--effort", parsed.effort);
|
|
@@ -131,9 +107,9 @@ function buildSpawnPlan(provider, prompt, workingDirectory, modelMode, execution
|
|
|
131
107
|
} else {
|
|
132
108
|
codexArgs.push(prompt);
|
|
133
109
|
if (normalizedModelMode) {
|
|
134
|
-
if (
|
|
135
|
-
const parsed =
|
|
136
|
-
if (parsed.family !==
|
|
110
|
+
if (index.isModelModeForAgent("codex", normalizedModelMode)) {
|
|
111
|
+
const parsed = index.parseCodexModelMode(normalizedModelMode);
|
|
112
|
+
if (parsed.family !== index.MODEL_MODE_DEFAULT) {
|
|
137
113
|
codexArgs.push("--model", parsed.family);
|
|
138
114
|
if (parsed.effort) {
|
|
139
115
|
codexArgs.push("-c", `model_reasoning_effort=${parsed.effort}`);
|
|
@@ -211,7 +187,7 @@ async function runOrchestratorOneShot(args) {
|
|
|
211
187
|
const modelMode = readModelModeFromEnv();
|
|
212
188
|
const executionType = readExecutionTypeFromEnv();
|
|
213
189
|
const childSessionId = readChildSessionIdFromEnv();
|
|
214
|
-
|
|
190
|
+
logger.logger.debug(`[ORCHESTRATOR ONESHOT] Starting ${provider} one-shot`);
|
|
215
191
|
const plan = buildSpawnPlan(provider, prompt, workingDirectory, modelMode, executionType, childSessionId);
|
|
216
192
|
return spawnAndWait(plan);
|
|
217
193
|
}
|
|
@@ -1,49 +1,26 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { c as configuration,
|
|
4
|
-
import {
|
|
3
|
+
import { c as configuration, g as encodeBase64, h as encrypt, f as decodeBase64, e as decrypt, r as readCredentials } from './persistence-DKfF81pd.mjs';
|
|
4
|
+
import { s as sessionListInputSchema, r as runSessionList } from './sessionList-CgAYZpNj.mjs';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { f as fetchSessionById, a as decryptMessage, s as sessionSummaryInputSchema, r as runSessionSummary } from './sessionSummary-DCWQoaDP.mjs';
|
|
7
8
|
import { randomUUID } from 'node:crypto';
|
|
8
|
-
import '
|
|
9
|
-
import 'fs';
|
|
9
|
+
import 'node:fs/promises';
|
|
10
10
|
import 'node:fs';
|
|
11
11
|
import 'node:os';
|
|
12
12
|
import 'node:path';
|
|
13
|
-
import 'node:events';
|
|
14
|
-
import 'socket.io-client';
|
|
15
|
-
import '@paralleldrive/cuid2';
|
|
16
13
|
import 'tweetnacl';
|
|
17
|
-
import '
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
20
|
-
import 'child_process';
|
|
21
|
-
import 'util';
|
|
22
|
-
import 'fs/promises';
|
|
23
|
-
import 'path';
|
|
24
|
-
import 'url';
|
|
25
|
-
import 'node:module';
|
|
26
|
-
import 'ws';
|
|
27
|
-
import 'crypto';
|
|
28
|
-
import '@stablelib/base64';
|
|
29
|
-
import 'node:readline';
|
|
30
|
-
import 'expo-server-sdk';
|
|
31
|
-
import './mcpToolSchemas-CdPXJQmb.mjs';
|
|
32
|
-
import 'ink';
|
|
33
|
-
import 'react';
|
|
34
|
-
import 'node:url';
|
|
35
|
-
import 'ps-list';
|
|
36
|
-
import 'cross-spawn';
|
|
37
|
-
import 'os';
|
|
38
|
-
import 'tmp';
|
|
14
|
+
import 'chalk';
|
|
15
|
+
import 'fs';
|
|
16
|
+
import './auth-DxJ3VvrX.mjs';
|
|
39
17
|
import 'qrcode-terminal';
|
|
18
|
+
import './time-DgsBLJA_.mjs';
|
|
19
|
+
import './browser-AoVGRX7y.mjs';
|
|
40
20
|
import 'open';
|
|
41
|
-
import '
|
|
42
|
-
import '
|
|
43
|
-
import '
|
|
44
|
-
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
45
|
-
import '@modelcontextprotocol/sdk/types.js';
|
|
46
|
-
import 'http';
|
|
21
|
+
import 'react';
|
|
22
|
+
import 'ink';
|
|
23
|
+
import './sessionKeyCache-B6cGadYL.mjs';
|
|
47
24
|
|
|
48
25
|
const PREVIEW_LIMIT = 200;
|
|
49
26
|
const TAIL_MESSAGES = 5;
|
|
@@ -2,50 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
4
4
|
var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var logger = require('./persistence-CBTtC_dm.cjs');
|
|
6
|
+
var sessionList = require('./sessionList-lQ-nqEhc.cjs');
|
|
7
7
|
var axios = require('axios');
|
|
8
8
|
var z = require('zod');
|
|
9
|
+
var sessionSummary = require('./sessionSummary-CcORiQSq.cjs');
|
|
9
10
|
var node_crypto = require('node:crypto');
|
|
10
|
-
require('
|
|
11
|
-
require('fs');
|
|
11
|
+
require('node:fs/promises');
|
|
12
12
|
require('node:fs');
|
|
13
13
|
require('node:os');
|
|
14
14
|
require('node:path');
|
|
15
|
-
require('node:events');
|
|
16
|
-
require('socket.io-client');
|
|
17
|
-
require('@paralleldrive/cuid2');
|
|
18
15
|
require('tweetnacl');
|
|
19
|
-
require('
|
|
20
|
-
require('
|
|
21
|
-
require('
|
|
22
|
-
require('child_process');
|
|
23
|
-
require('util');
|
|
24
|
-
require('fs/promises');
|
|
25
|
-
require('path');
|
|
26
|
-
require('url');
|
|
27
|
-
require('node:module');
|
|
28
|
-
require('ws');
|
|
29
|
-
require('crypto');
|
|
30
|
-
require('@stablelib/base64');
|
|
31
|
-
require('node:readline');
|
|
32
|
-
require('expo-server-sdk');
|
|
33
|
-
require('./mcpToolSchemas-f-kttjFw.cjs');
|
|
34
|
-
require('ink');
|
|
35
|
-
require('react');
|
|
36
|
-
require('node:url');
|
|
37
|
-
require('ps-list');
|
|
38
|
-
require('cross-spawn');
|
|
39
|
-
require('os');
|
|
40
|
-
require('tmp');
|
|
16
|
+
require('chalk');
|
|
17
|
+
require('fs');
|
|
18
|
+
require('./auth-C7ZScWEw.cjs');
|
|
41
19
|
require('qrcode-terminal');
|
|
20
|
+
require('./time-Bj2HRkKH.cjs');
|
|
21
|
+
require('./browser-DzgO4oaD.cjs');
|
|
42
22
|
require('open');
|
|
43
|
-
require('
|
|
44
|
-
require('
|
|
45
|
-
require('
|
|
46
|
-
require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
47
|
-
require('@modelcontextprotocol/sdk/types.js');
|
|
48
|
-
require('http');
|
|
23
|
+
require('react');
|
|
24
|
+
require('ink');
|
|
25
|
+
require('./sessionKeyCache-CDmexJ9p.cjs');
|
|
49
26
|
|
|
50
27
|
const PREVIEW_LIMIT = 200;
|
|
51
28
|
const TAIL_MESSAGES = 5;
|
|
@@ -59,19 +36,19 @@ function trim(text) {
|
|
|
59
36
|
}
|
|
60
37
|
async function runSessionInspect(credentials, input) {
|
|
61
38
|
const tail = input.tail ?? TAIL_MESSAGES;
|
|
62
|
-
const session = await
|
|
39
|
+
const session = await sessionSummary.fetchSessionById(credentials, input.sessionId);
|
|
63
40
|
if (!session) {
|
|
64
41
|
throw new Error(`Session ${input.sessionId} not found or not decryptable.`);
|
|
65
42
|
}
|
|
66
43
|
const response = await axios.get(
|
|
67
|
-
`${
|
|
44
|
+
`${logger.configuration.serverUrl}/v3/sessions/${encodeURIComponent(input.sessionId)}/messages`,
|
|
68
45
|
{
|
|
69
46
|
params: { limit: String(tail) },
|
|
70
47
|
headers: { Authorization: `Bearer ${credentials.token}` },
|
|
71
48
|
timeout: 1e4
|
|
72
49
|
}
|
|
73
50
|
);
|
|
74
|
-
const recent = response.data.messages.map((raw) =>
|
|
51
|
+
const recent = response.data.messages.map((raw) => sessionSummary.decryptMessage(raw, session.encryptionKey, session.encryptionVariant)).reverse();
|
|
75
52
|
const previews = recent.map((m) => ({
|
|
76
53
|
seq: m.seq,
|
|
77
54
|
role: m.role,
|
|
@@ -125,7 +102,7 @@ async function runSessionMessages(credentials, input) {
|
|
|
125
102
|
if (input.beforeSeq !== void 0 && input.afterSeq !== void 0) {
|
|
126
103
|
throw new Error("Specify only one of beforeSeq / afterSeq, not both.");
|
|
127
104
|
}
|
|
128
|
-
const session = await
|
|
105
|
+
const session = await sessionSummary.fetchSessionById(credentials, input.sessionId);
|
|
129
106
|
if (!session) {
|
|
130
107
|
throw new Error(`Session ${input.sessionId} not found or not decryptable.`);
|
|
131
108
|
}
|
|
@@ -135,14 +112,14 @@ async function runSessionMessages(credentials, input) {
|
|
|
135
112
|
if (input.beforeSeq !== void 0) params.before_seq = String(input.beforeSeq);
|
|
136
113
|
if (input.afterSeq !== void 0) params.after_seq = String(input.afterSeq);
|
|
137
114
|
const response = await axios.get(
|
|
138
|
-
`${
|
|
115
|
+
`${logger.configuration.serverUrl}/v3/sessions/${encodeURIComponent(input.sessionId)}/messages`,
|
|
139
116
|
{
|
|
140
117
|
params,
|
|
141
118
|
headers: { Authorization: `Bearer ${credentials.token}` },
|
|
142
119
|
timeout: 1e4
|
|
143
120
|
}
|
|
144
121
|
);
|
|
145
|
-
const decrypted = response.data.messages.map((raw) =>
|
|
122
|
+
const decrypted = response.data.messages.map((raw) => sessionSummary.decryptMessage(raw, session.encryptionKey, session.encryptionVariant)).filter((message) => input.includeHumanOnly === true || !isHumanOnlyMessage(message));
|
|
146
123
|
const seqs = decrypted.map((m) => m.seq);
|
|
147
124
|
const minSeq = seqs.length > 0 ? Math.min(...seqs) : null;
|
|
148
125
|
const maxSeq = seqs.length > 0 ? Math.max(...seqs) : null;
|
|
@@ -173,7 +150,7 @@ async function runSessionSend(credentials, input) {
|
|
|
173
150
|
if (!trimmed) {
|
|
174
151
|
throw new Error("text must be non-empty after trim.");
|
|
175
152
|
}
|
|
176
|
-
const session = await
|
|
153
|
+
const session = await sessionSummary.fetchSessionById(credentials, input.sessionId);
|
|
177
154
|
if (!session) {
|
|
178
155
|
throw new Error(`Session ${input.sessionId} not found or not decryptable.`);
|
|
179
156
|
}
|
|
@@ -181,12 +158,12 @@ async function runSessionSend(credentials, input) {
|
|
|
181
158
|
role: "user",
|
|
182
159
|
content: { type: "text", text: trimmed }
|
|
183
160
|
};
|
|
184
|
-
const encryptedContent =
|
|
185
|
-
|
|
161
|
+
const encryptedContent = logger.encodeBase64(
|
|
162
|
+
logger.encrypt(session.encryptionKey, session.encryptionVariant, userMessage)
|
|
186
163
|
);
|
|
187
164
|
const localId = node_crypto.randomUUID();
|
|
188
165
|
const response = await axios.post(
|
|
189
|
-
`${
|
|
166
|
+
`${logger.configuration.serverUrl}/v3/sessions/${encodeURIComponent(input.sessionId)}/messages`,
|
|
190
167
|
{
|
|
191
168
|
messages: [{
|
|
192
169
|
content: encryptedContent,
|
|
@@ -213,16 +190,16 @@ const sessionCancelInputSchema = {
|
|
|
213
190
|
sessionId: z.z.string().describe("Target session ID (from happy_session_list).")
|
|
214
191
|
};
|
|
215
192
|
async function runSessionCancel(credentials, input) {
|
|
216
|
-
const session = await
|
|
193
|
+
const session = await sessionSummary.fetchSessionById(credentials, input.sessionId);
|
|
217
194
|
if (!session) {
|
|
218
195
|
throw new Error(`Session ${input.sessionId} not found or not decryptable.`);
|
|
219
196
|
}
|
|
220
|
-
const encryptedParams =
|
|
221
|
-
|
|
197
|
+
const encryptedParams = logger.encodeBase64(
|
|
198
|
+
logger.encrypt(session.encryptionKey, session.encryptionVariant, {})
|
|
222
199
|
);
|
|
223
200
|
try {
|
|
224
201
|
const response = await axios.post(
|
|
225
|
-
`${
|
|
202
|
+
`${logger.configuration.serverUrl}/v1/sessions/${encodeURIComponent(input.sessionId)}/abort`,
|
|
226
203
|
{ params: encryptedParams },
|
|
227
204
|
{
|
|
228
205
|
headers: { Authorization: `Bearer ${credentials.token}` },
|
|
@@ -278,11 +255,11 @@ async function runSessionSpawn(credentials, input) {
|
|
|
278
255
|
spawnParams.resumeSessionId = input.resumeSessionId;
|
|
279
256
|
spawnParams.intent = "resume";
|
|
280
257
|
}
|
|
281
|
-
const encryptedParams =
|
|
258
|
+
const encryptedParams = logger.encodeBase64(logger.encrypt(key, variant, spawnParams));
|
|
282
259
|
let response;
|
|
283
260
|
try {
|
|
284
261
|
response = await axios.post(
|
|
285
|
-
`${
|
|
262
|
+
`${logger.configuration.serverUrl}/v1/sessions/spawn`,
|
|
286
263
|
{ machineId: input.machineId, params: encryptedParams },
|
|
287
264
|
{
|
|
288
265
|
headers: { Authorization: `Bearer ${credentials.token}` },
|
|
@@ -303,8 +280,8 @@ async function runSessionSpawn(credentials, input) {
|
|
|
303
280
|
if (!response.data.ok || !response.data.result) {
|
|
304
281
|
throw new Error(`Spawn failed: ${response.data.error || "no result returned"}`);
|
|
305
282
|
}
|
|
306
|
-
const decoded =
|
|
307
|
-
const reply =
|
|
283
|
+
const decoded = logger.decodeBase64(response.data.result);
|
|
284
|
+
const reply = logger.decrypt(key, variant, decoded);
|
|
308
285
|
if (!reply) {
|
|
309
286
|
throw new Error("Failed to decrypt spawn response from daemon.");
|
|
310
287
|
}
|
|
@@ -343,7 +320,7 @@ function wrap(name, credentials, handler) {
|
|
|
343
320
|
};
|
|
344
321
|
}
|
|
345
322
|
async function runMcpServe() {
|
|
346
|
-
const credentials = await
|
|
323
|
+
const credentials = await logger.readCredentials();
|
|
347
324
|
if (!credentials) {
|
|
348
325
|
logStderr('No happy credentials found at ~/.happy/. Run "happy auth" first.');
|
|
349
326
|
process.exit(1);
|
|
@@ -355,8 +332,8 @@ async function runMcpServe() {
|
|
|
355
332
|
server.tool(
|
|
356
333
|
"happy_session_list",
|
|
357
334
|
"List happy sessions with metadata (status, agent, machine, last-active timestamp). Does not include message content \u2014 call happy_session_messages or happy_session_inspect for that.",
|
|
358
|
-
|
|
359
|
-
wrap("happy_session_list", credentials,
|
|
335
|
+
sessionList.sessionListInputSchema,
|
|
336
|
+
wrap("happy_session_list", credentials, sessionList.runSessionList)
|
|
360
337
|
);
|
|
361
338
|
server.tool(
|
|
362
339
|
"happy_session_inspect",
|
|
@@ -367,8 +344,8 @@ async function runMcpServe() {
|
|
|
367
344
|
server.tool(
|
|
368
345
|
"happy_session_summary",
|
|
369
346
|
"Compact, bounded reader for large Happy sessions. Returns session metadata plus a concise chronological timeline of user prompts, assistant text, and optional tool names without raw thinking/event/tool payloads. Use this before happy_session_messages when you need to understand a long session quickly.",
|
|
370
|
-
|
|
371
|
-
wrap("happy_session_summary", credentials,
|
|
347
|
+
sessionSummary.sessionSummaryInputSchema,
|
|
348
|
+
wrap("happy_session_summary", credentials, sessionSummary.runSessionSummary)
|
|
372
349
|
);
|
|
373
350
|
server.tool(
|
|
374
351
|
"happy_session_messages",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { r as readCredentials } from './persistence-DKfF81pd.mjs';
|
|
3
|
+
import { r as runSessionSummary } from './sessionSummary-DCWQoaDP.mjs';
|
|
4
|
+
import 'node:fs/promises';
|
|
5
|
+
import 'node:fs';
|
|
6
|
+
import 'node:os';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import 'node:crypto';
|
|
10
|
+
import 'tweetnacl';
|
|
11
|
+
import 'fs';
|
|
12
|
+
import 'axios';
|
|
13
|
+
import './auth-DxJ3VvrX.mjs';
|
|
14
|
+
import 'qrcode-terminal';
|
|
15
|
+
import './time-DgsBLJA_.mjs';
|
|
16
|
+
import './browser-AoVGRX7y.mjs';
|
|
17
|
+
import 'open';
|
|
18
|
+
import 'react';
|
|
19
|
+
import 'ink';
|
|
20
|
+
import './sessionKeyCache-B6cGadYL.mjs';
|
|
21
|
+
|
|
22
|
+
function printSessionHelp() {
|
|
23
|
+
console.log(`
|
|
24
|
+
${chalk.bold("happy session")} - Read Happy sessions
|
|
25
|
+
|
|
26
|
+
${chalk.bold("Usage:")}
|
|
27
|
+
happy session summary <sessionId> [options]
|
|
28
|
+
happy session summarize <sessionId> [options]
|
|
29
|
+
|
|
30
|
+
${chalk.bold("Options:")}
|
|
31
|
+
--limit <n> Raw messages to compact (1-500, default 200)
|
|
32
|
+
--before-seq <n> Page backwards: messages with seq < n
|
|
33
|
+
--after-seq <n> Page forwards: messages with seq > n
|
|
34
|
+
--max-turns <n> Compact turns to print (1-200, default 80)
|
|
35
|
+
--text-limit <n> Max chars per text block (80-4000, default 800)
|
|
36
|
+
--max-tools <n> Max tool names per turn (0-50, default 12)
|
|
37
|
+
--no-tools Hide tool-use names
|
|
38
|
+
--json Print full JSON instead of markdown
|
|
39
|
+
-h, --help Show this help
|
|
40
|
+
`);
|
|
41
|
+
}
|
|
42
|
+
function readNumberFlag(flag, value) {
|
|
43
|
+
if (!value || value.startsWith("-")) {
|
|
44
|
+
throw new Error(`${flag} requires a number value.`);
|
|
45
|
+
}
|
|
46
|
+
const parsed = Number(value);
|
|
47
|
+
if (!Number.isInteger(parsed)) {
|
|
48
|
+
throw new Error(`${flag} must be an integer.`);
|
|
49
|
+
}
|
|
50
|
+
return parsed;
|
|
51
|
+
}
|
|
52
|
+
async function handleSessionCommand(args) {
|
|
53
|
+
const action = args[0];
|
|
54
|
+
if (!action || action === "-h" || action === "--help") {
|
|
55
|
+
printSessionHelp();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (action !== "summary" && action !== "summarize") {
|
|
59
|
+
throw new Error(`Unknown session command: ${action}. Use "happy session summary <sessionId>".`);
|
|
60
|
+
}
|
|
61
|
+
const sessionId = args[1];
|
|
62
|
+
if (!sessionId || sessionId.startsWith("-")) {
|
|
63
|
+
throw new Error('Session ID required. Use "happy session summary <sessionId>".');
|
|
64
|
+
}
|
|
65
|
+
const input = { sessionId };
|
|
66
|
+
let printJson = false;
|
|
67
|
+
for (let i = 2; i < args.length; i++) {
|
|
68
|
+
const arg = args[i];
|
|
69
|
+
if (arg === "--limit") {
|
|
70
|
+
input.limit = readNumberFlag(arg, args[++i]);
|
|
71
|
+
} else if (arg === "--before-seq") {
|
|
72
|
+
input.beforeSeq = readNumberFlag(arg, args[++i]);
|
|
73
|
+
} else if (arg === "--after-seq") {
|
|
74
|
+
input.afterSeq = readNumberFlag(arg, args[++i]);
|
|
75
|
+
} else if (arg === "--max-turns") {
|
|
76
|
+
input.maxTurns = readNumberFlag(arg, args[++i]);
|
|
77
|
+
} else if (arg === "--text-limit") {
|
|
78
|
+
input.textLimit = readNumberFlag(arg, args[++i]);
|
|
79
|
+
} else if (arg === "--max-tools") {
|
|
80
|
+
input.maxToolsPerTurn = readNumberFlag(arg, args[++i]);
|
|
81
|
+
} else if (arg === "--no-tools") {
|
|
82
|
+
input.includeTools = false;
|
|
83
|
+
} else if (arg === "--json") {
|
|
84
|
+
printJson = true;
|
|
85
|
+
} else if (arg === "-h" || arg === "--help") {
|
|
86
|
+
printSessionHelp();
|
|
87
|
+
return;
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const credentials = await readCredentials();
|
|
93
|
+
if (!credentials) {
|
|
94
|
+
throw new Error('No happy credentials found. Run "happy auth login" first.');
|
|
95
|
+
}
|
|
96
|
+
const result = await runSessionSummary(credentials, input);
|
|
97
|
+
if (printJson) {
|
|
98
|
+
console.log(JSON.stringify(result, null, 2));
|
|
99
|
+
} else {
|
|
100
|
+
console.log(result.summaryText);
|
|
101
|
+
if (result.messageWindow.hasMore) {
|
|
102
|
+
console.log("");
|
|
103
|
+
console.log(chalk.gray(`More messages available. Continue with --before-seq ${result.messageWindow.nextBeforeSeq}`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { handleSessionCommand };
|