@zonease/happy 0.6.41 → 0.6.42
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/{api-XeHlmApX.cjs → api-CIE4_cWd.cjs} +4 -4
- package/dist/{api-K2-jr9ar.mjs → api-Ew6xr81i.mjs} +4 -4
- package/dist/{auth-CjLkoM3m.mjs → auth-BzYevJo2.mjs} +4 -4
- package/dist/{auth-BbvPcnkY.cjs → auth-Dor79zTL.cjs} +4 -4
- package/dist/{auth-BQvEuSs5.cjs → auth-G9fZpVJ2.cjs} +2 -2
- package/dist/{auth-DS8fzlin.mjs → auth-Q2STUNI-.mjs} +2 -2
- package/dist/{browser-C05Ak6RL.mjs → browser-BI7s-V8E.mjs} +1 -1
- package/dist/{browser-C05SP_Tt.cjs → browser-qDIIAL7S.cjs} +1 -1
- package/dist/{claudeLocal-DJNRlHIC.mjs → claudeLocal-Db2tDC4X.mjs} +1 -1
- package/dist/{claudeLocal-CpDhLCcZ.cjs → claudeLocal-f4uBLJaM.cjs} +1 -1
- package/dist/{config-DWWtjKQx.mjs → config-CHjDs8AS.mjs} +1 -1
- package/dist/{config-B0mns9fF.cjs → config-CSBlEik9.cjs} +1 -1
- package/dist/{connect-BxCScVNX.cjs → connect-CJoTliii.cjs} +5 -5
- package/dist/{connect-DXQC1CJe.mjs → connect-O_nA5BOC.mjs} +5 -5
- package/dist/{controlClient-DgELDZgM.cjs → controlClient-CEz_p1zc.cjs} +1 -1
- package/dist/{controlClient-DgjVRN8D.mjs → controlClient-DoS9JqQC.mjs} +1 -1
- package/dist/cursorApprovalHook-B0v1kGa7.mjs +95 -0
- package/dist/cursorApprovalHook-DRAHfTXU.cjs +97 -0
- package/dist/cursorApprovalServer-DzY8yJlI.cjs +167 -0
- package/dist/cursorApprovalServer-JjPkdjGR.mjs +164 -0
- package/dist/{deviceKeys-CejCdWpw.mjs → deviceKeys-B4aqjnE6.mjs} +2 -2
- package/dist/{deviceKeys-BpIAWz13.cjs → deviceKeys-DyUn0bEx.cjs} +2 -2
- package/dist/{doctor-DznasgP3.cjs → doctor-BJSuVRUZ.cjs} +2 -2
- package/dist/{doctor-B-LCMVN9.mjs → doctor-DRnft_5-.mjs} +2 -2
- package/dist/{downloadImage-ia5SzlCV.mjs → downloadImage-BpVF7A79.mjs} +7 -40
- package/dist/{downloadImage-B_ygLAXY.cjs → downloadImage-Cijmufpr.cjs} +5 -39
- package/dist/{enroll-BvfpRUGJ.cjs → enroll-C2gunHdt.cjs} +3 -3
- package/dist/{enroll-HjUqyGnD.mjs → enroll-CysDL6ee.mjs} +3 -3
- package/dist/{evidence-BEQd1dCh.mjs → evidence-DPutCuUr.mjs} +1 -1
- package/dist/{evidence-CVgTjBrq.cjs → evidence-DsQ-h-_W.cjs} +1 -1
- package/dist/{formatImageMessage-DVs57t3x.mjs → formatImageMessage-6aV9YFWr.mjs} +1 -1
- package/dist/{formatImageMessage-CmJTP_hU.cjs → formatImageMessage-BPK_Ivfe.cjs} +1 -1
- package/dist/gitWorktree-C6jLoaMw.cjs +39 -0
- package/dist/gitWorktree-CzJDU2BV.mjs +37 -0
- package/dist/{index-CDTNgfUf.cjs → index-BeKrqPYR.cjs} +25 -1
- package/dist/{index-CPKdvi7J.mjs → index-DTV7drqs.mjs} +25 -1
- package/dist/index.cjs +91 -41
- package/dist/index.mjs +91 -41
- package/dist/{install-UTz_vYvB.mjs → install-BsTA2tZn.mjs} +2 -2
- package/dist/{install-B3mMGISS.mjs → install-DBg0xQ3g.mjs} +1 -1
- package/dist/{install-2Yl_L582.cjs → install-DlOppA-e.cjs} +2 -2
- package/dist/{install-Ck22tYHP.cjs → install-Tyhs6rUp.cjs} +1 -1
- package/dist/lib.cjs +4 -4
- package/dist/lib.d.cts +3 -2
- package/dist/lib.d.mts +3 -2
- package/dist/lib.mjs +4 -4
- package/dist/{loadableToolOutput-4EvraaNY.mjs → loadableToolOutput-2dMPAp4N.mjs} +3 -456
- package/dist/{loadableToolOutput-BZYlaqHn.cjs → loadableToolOutput-DPGTtKJM.cjs} +2 -458
- package/dist/{persistence-DrfN7TzY.cjs → persistence-BcQmjobZ.cjs} +7 -4
- package/dist/{persistence-CIUFyOwz.mjs → persistence-D9tMm6bj.mjs} +7 -4
- package/dist/{push-CCOXCcM_.cjs → push-Cnm6JQMD.cjs} +6 -6
- package/dist/{push-USXj_pv0.mjs → push-Dxsugkes.mjs} +6 -6
- package/dist/{run-Dy6KX6m-.mjs → run-BEflQaQ2.mjs} +12 -9
- package/dist/{run-D3CopmEb.cjs → run-CiPWWhXt.cjs} +12 -9
- package/dist/{runClaude-aHzvx6Ha.cjs → runClaude-BVXsyCHb.cjs} +19 -18
- package/dist/{runClaude-CWux2RDq.mjs → runClaude-sPkSqHWY.mjs} +16 -15
- package/dist/{runCodex-G-Aq531U.cjs → runCodex-BAwhdmSA.cjs} +19 -17
- package/dist/{runCodex-D0ZxSj3O.mjs → runCodex-C4rHkIyw.mjs} +16 -14
- package/dist/runCursor-CD5wC3gA.cjs +578 -0
- package/dist/runCursor-DiHLWMs8.mjs +576 -0
- package/dist/{runGemini-DZC2i6vA.mjs → runGemini-B-93gOqB.mjs} +18 -16
- package/dist/{runGemini-DxGgDAIM.cjs → runGemini-Cto-adir.cjs} +21 -19
- package/dist/{runOneShot-BgT-JNMA.cjs → runOneShot-BfIzE9W4.cjs} +3 -3
- package/dist/{runOneShot-cxlk7VKA.mjs → runOneShot-DGjlYVhR.mjs} +3 -3
- package/dist/{serve-Dr3wPrtK.cjs → serve-CqL6NWDr.cjs} +7 -7
- package/dist/{serve-CKyvJNs0.mjs → serve-ttlqF5jn.mjs} +7 -7
- package/dist/{session-dYzbOo_W.cjs → session-BZhGpQUJ.cjs} +5 -5
- package/dist/{session-vf2ZjFto.mjs → session-Co0REU9e.mjs} +5 -5
- package/dist/{sessionKeyCache-dDquDzn0.cjs → sessionKeyCache-BwFUGgMs.cjs} +1 -1
- package/dist/{sessionKeyCache-D2u3JUys.mjs → sessionKeyCache-pXTjpETo.mjs} +1 -1
- package/dist/{sessionList-C1k2PNg_.mjs → sessionList-DaufR-sA.mjs} +2 -2
- package/dist/{sessionList-DmmtC7uR.cjs → sessionList-fG5uAPzU.cjs} +2 -2
- package/dist/{sessionSummary-DGLoVOxd.cjs → sessionSummary-CjZPt6nr.cjs} +3 -3
- package/dist/{sessionSummary-5a1QtFVS.mjs → sessionSummary-Dv6dPABg.mjs} +3 -3
- package/dist/setupOfflineReconnection-B6coH9QN.cjs +461 -0
- package/dist/setupOfflineReconnection-DW5il97B.mjs +457 -0
- package/dist/{spawnHappyCLI-CarRI4GM.cjs → spawnHappyCLI-Cfu7C1uM.cjs} +1 -1
- package/dist/{spawnHappyCLI-D3EkTFIn.mjs → spawnHappyCLI-DhUeycct.mjs} +1 -1
- package/dist/{ssh-B0hvEYIl.mjs → ssh-8tPIKk-i.mjs} +5 -5
- package/dist/{ssh-CBgVwKsB.cjs → ssh-C4YTSHXL.cjs} +5 -5
- package/dist/{task-CRo6W-3_.mjs → task-CH-oidFy.mjs} +6 -6
- package/dist/{task-CMunPKCV.cjs → task-DFW-PecP.cjs} +6 -6
- package/dist/{uninstall-BALE2up0.mjs → uninstall-CeioRZNI.mjs} +2 -2
- package/dist/{uninstall-BJ3eEGM4.cjs → uninstall-yTSL3X6Y.cjs} +2 -2
- package/dist/{update-Bb3iijy8.cjs → update-Bju28vNP.cjs} +3 -3
- package/dist/{update-BfjtLrhO.mjs → update-Derd2hoX.mjs} +3 -3
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var api = require('./api-
|
|
4
|
-
var logger = require('./persistence-
|
|
3
|
+
var api = require('./api-CIE4_cWd.cjs');
|
|
4
|
+
var logger = require('./persistence-BcQmjobZ.cjs');
|
|
5
5
|
var types = require('./types-DWeB7aqh.cjs');
|
|
6
6
|
require('axios');
|
|
7
7
|
require('node:events');
|
|
8
8
|
require('socket.io-client');
|
|
9
9
|
require('zod');
|
|
10
|
-
require('./index-
|
|
10
|
+
require('./index-BeKrqPYR.cjs');
|
|
11
11
|
require('@paralleldrive/cuid2');
|
|
12
12
|
require('./time-Bj2HRkKH.cjs');
|
|
13
13
|
require('node:crypto');
|
|
@@ -30,7 +30,7 @@ require('tweetnacl');
|
|
|
30
30
|
require('@stablelib/base64');
|
|
31
31
|
require('node:readline');
|
|
32
32
|
require('expo-server-sdk');
|
|
33
|
-
require('./sessionKeyCache-
|
|
33
|
+
require('./sessionKeyCache-BwFUGgMs.cjs');
|
|
34
34
|
require('chalk');
|
|
35
35
|
require('fs');
|
|
36
36
|
|
package/dist/lib.d.cts
CHANGED
|
@@ -1309,6 +1309,7 @@ type ACPMessageData = {
|
|
|
1309
1309
|
type: 'token_count';
|
|
1310
1310
|
[key: string]: unknown;
|
|
1311
1311
|
};
|
|
1312
|
+
type ACPProvider = 'gemini' | 'codex' | 'claude' | 'opencode' | 'cursor';
|
|
1312
1313
|
type OrchestratorProvider = 'claude' | 'codex' | 'gemini';
|
|
1313
1314
|
type OrchestratorSubmitTask = {
|
|
1314
1315
|
taskKey?: string;
|
|
@@ -1461,7 +1462,7 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
1461
1462
|
* @param provider - The agent provider sending the message (e.g., 'gemini', 'codex', 'claude')
|
|
1462
1463
|
* @param body - The message payload (type: 'message' | 'reasoning' | 'tool-call' | 'tool-result')
|
|
1463
1464
|
*/
|
|
1464
|
-
sendAgentMessage(provider:
|
|
1465
|
+
sendAgentMessage(provider: ACPProvider, body: ACPMessageData): void;
|
|
1465
1466
|
/**
|
|
1466
1467
|
* Send a batch of pre-built message content objects for backfill (session resume/copy).
|
|
1467
1468
|
* Each item.content should be a complete message object (role + content) ready to encrypt.
|
|
@@ -1555,7 +1556,7 @@ interface SpawnSessionOptions {
|
|
|
1555
1556
|
sessionTitle?: string;
|
|
1556
1557
|
skipForkSession?: boolean;
|
|
1557
1558
|
approvedNewDirectoryCreation?: boolean;
|
|
1558
|
-
agent?: 'claude' | 'codex' | 'gemini';
|
|
1559
|
+
agent?: 'claude' | 'codex' | 'gemini' | 'cursor';
|
|
1559
1560
|
token?: string;
|
|
1560
1561
|
environmentVariables?: {
|
|
1561
1562
|
ANTHROPIC_BASE_URL?: string;
|
package/dist/lib.d.mts
CHANGED
|
@@ -1309,6 +1309,7 @@ type ACPMessageData = {
|
|
|
1309
1309
|
type: 'token_count';
|
|
1310
1310
|
[key: string]: unknown;
|
|
1311
1311
|
};
|
|
1312
|
+
type ACPProvider = 'gemini' | 'codex' | 'claude' | 'opencode' | 'cursor';
|
|
1312
1313
|
type OrchestratorProvider = 'claude' | 'codex' | 'gemini';
|
|
1313
1314
|
type OrchestratorSubmitTask = {
|
|
1314
1315
|
taskKey?: string;
|
|
@@ -1461,7 +1462,7 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
1461
1462
|
* @param provider - The agent provider sending the message (e.g., 'gemini', 'codex', 'claude')
|
|
1462
1463
|
* @param body - The message payload (type: 'message' | 'reasoning' | 'tool-call' | 'tool-result')
|
|
1463
1464
|
*/
|
|
1464
|
-
sendAgentMessage(provider:
|
|
1465
|
+
sendAgentMessage(provider: ACPProvider, body: ACPMessageData): void;
|
|
1465
1466
|
/**
|
|
1466
1467
|
* Send a batch of pre-built message content objects for backfill (session resume/copy).
|
|
1467
1468
|
* Each item.content should be a complete message object (role + content) ready to encrypt.
|
|
@@ -1555,7 +1556,7 @@ interface SpawnSessionOptions {
|
|
|
1555
1556
|
sessionTitle?: string;
|
|
1556
1557
|
skipForkSession?: boolean;
|
|
1557
1558
|
approvedNewDirectoryCreation?: boolean;
|
|
1558
|
-
agent?: 'claude' | 'codex' | 'gemini';
|
|
1559
|
+
agent?: 'claude' | 'codex' | 'gemini' | 'cursor';
|
|
1559
1560
|
token?: string;
|
|
1560
1561
|
environmentVariables?: {
|
|
1561
1562
|
ANTHROPIC_BASE_URL?: string;
|
package/dist/lib.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient } from './api-
|
|
2
|
-
export { c as configuration, l as logger } from './persistence-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient } from './api-Ew6xr81i.mjs';
|
|
2
|
+
export { c as configuration, l as logger } from './persistence-D9tMm6bj.mjs';
|
|
3
3
|
export { R as RawJSONLinesSchema } from './types-BoJh4Qfv.mjs';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'node:events';
|
|
6
6
|
import 'socket.io-client';
|
|
7
7
|
import 'zod';
|
|
8
|
-
import './index-
|
|
8
|
+
import './index-DTV7drqs.mjs';
|
|
9
9
|
import '@paralleldrive/cuid2';
|
|
10
10
|
import './time-DgsBLJA_.mjs';
|
|
11
11
|
import 'node:crypto';
|
|
@@ -28,6 +28,6 @@ import 'tweetnacl';
|
|
|
28
28
|
import '@stablelib/base64';
|
|
29
29
|
import 'node:readline';
|
|
30
30
|
import 'expo-server-sdk';
|
|
31
|
-
import './sessionKeyCache-
|
|
31
|
+
import './sessionKeyCache-pXTjpETo.mjs';
|
|
32
32
|
import 'chalk';
|
|
33
33
|
import 'fs';
|
|
@@ -1,192 +1,6 @@
|
|
|
1
|
-
import { l as logger, c as configuration, p as packageJson } from './persistence-CIUFyOwz.mjs';
|
|
2
1
|
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { join, basename, dirname } from 'node:path';
|
|
6
|
-
import { p as projectPath } from './projectPath-BTBIMB57.mjs';
|
|
7
|
-
import { r as resolveToolsDir, s as startOfflineReconnection, b as saveToolOutputRecord } from './api-K2-jr9ar.mjs';
|
|
8
|
-
import { a as detectGitWorktree } from './downloadImage-ia5SzlCV.mjs';
|
|
9
|
-
|
|
10
|
-
class BasePermissionHandler {
|
|
11
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
12
|
-
session;
|
|
13
|
-
pushClient;
|
|
14
|
-
isResetting = false;
|
|
15
|
-
isUserInteractionTool(toolName) {
|
|
16
|
-
return ["AskUserQuestion", "ExitPlanMode", "exit_plan_mode"].includes(toolName);
|
|
17
|
-
}
|
|
18
|
-
constructor(session, pushClient) {
|
|
19
|
-
this.session = session;
|
|
20
|
-
this.pushClient = pushClient;
|
|
21
|
-
this.setupRpcHandler();
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Update the session reference (used after offline reconnection swaps sessions).
|
|
25
|
-
* This is critical for avoiding stale session references after onSessionSwap.
|
|
26
|
-
*/
|
|
27
|
-
updateSession(newSession) {
|
|
28
|
-
logger.debug(`${this.getLogPrefix()} Session reference updated`);
|
|
29
|
-
this.session = newSession;
|
|
30
|
-
this.setupRpcHandler();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Setup RPC handler for permission responses.
|
|
34
|
-
*/
|
|
35
|
-
setupRpcHandler() {
|
|
36
|
-
this.session.rpcHandlerManager.registerHandler(
|
|
37
|
-
"permission",
|
|
38
|
-
async (response) => {
|
|
39
|
-
const pending = this.pendingRequests.get(response.id);
|
|
40
|
-
if (!pending) {
|
|
41
|
-
logger.debug(`${this.getLogPrefix()} Permission request not found or already resolved`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.pendingRequests.delete(response.id);
|
|
45
|
-
const result = response.approved ? { decision: response.decision === "approved_for_session" ? "approved_for_session" : "approved" } : { decision: response.decision === "denied" ? "denied" : "abort" };
|
|
46
|
-
pending.resolve(result);
|
|
47
|
-
if (response.approved && (response.mode === "bypassPermissions" || response.decision === "approved_for_session")) {
|
|
48
|
-
this.approvePendingRequestsForSession(response);
|
|
49
|
-
}
|
|
50
|
-
this.session.updateAgentState((currentState) => {
|
|
51
|
-
const request = currentState.requests?.[response.id];
|
|
52
|
-
if (!request) return currentState;
|
|
53
|
-
const { [response.id]: _, ...remainingRequests } = currentState.requests || {};
|
|
54
|
-
let res = {
|
|
55
|
-
...currentState,
|
|
56
|
-
requests: remainingRequests,
|
|
57
|
-
completedRequests: {
|
|
58
|
-
...currentState.completedRequests,
|
|
59
|
-
[response.id]: {
|
|
60
|
-
...request,
|
|
61
|
-
completedAt: Date.now(),
|
|
62
|
-
status: response.approved ? "approved" : "denied",
|
|
63
|
-
decision: result.decision,
|
|
64
|
-
mode: response.mode,
|
|
65
|
-
allowedTools: response.allowTools
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return res;
|
|
70
|
-
});
|
|
71
|
-
logger.debug(`${this.getLogPrefix()} Permission ${response.approved ? "approved" : "denied"} for ${pending.toolName}`);
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
approvePendingRequestsForSession(response) {
|
|
76
|
-
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
77
|
-
const completedAt = Date.now();
|
|
78
|
-
for (const [id, pending] of pendingSnapshot) {
|
|
79
|
-
if (this.isUserInteractionTool(pending.toolName)) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
this.pendingRequests.delete(id);
|
|
83
|
-
pending.resolve({ decision: "approved_for_session" });
|
|
84
|
-
}
|
|
85
|
-
if (pendingSnapshot.length === 0) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.session.updateAgentState((currentState) => {
|
|
89
|
-
const requests = { ...currentState.requests || {} };
|
|
90
|
-
const completedRequests = { ...currentState.completedRequests };
|
|
91
|
-
let changed = false;
|
|
92
|
-
for (const [id, pending] of pendingSnapshot) {
|
|
93
|
-
if (this.isUserInteractionTool(pending.toolName)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
const request = requests[id];
|
|
97
|
-
if (!request) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
delete requests[id];
|
|
101
|
-
completedRequests[id] = {
|
|
102
|
-
...request,
|
|
103
|
-
completedAt,
|
|
104
|
-
status: "approved",
|
|
105
|
-
decision: "approved_for_session",
|
|
106
|
-
mode: response.mode,
|
|
107
|
-
allowedTools: response.allowTools
|
|
108
|
-
};
|
|
109
|
-
changed = true;
|
|
110
|
-
}
|
|
111
|
-
if (!changed) {
|
|
112
|
-
return currentState;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
...currentState,
|
|
116
|
-
requests,
|
|
117
|
-
completedRequests
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Add a pending request to the agent state and send a push notification.
|
|
123
|
-
*/
|
|
124
|
-
addPendingRequestToState(toolCallId, toolName, input) {
|
|
125
|
-
this.pushClient.sendToAllDevices(
|
|
126
|
-
"Permission Request",
|
|
127
|
-
`${this.getAgentName()} wants to ${toolName}`,
|
|
128
|
-
{
|
|
129
|
-
sessionId: this.session.sessionId,
|
|
130
|
-
requestId: toolCallId,
|
|
131
|
-
tool: toolName,
|
|
132
|
-
type: "permission_request"
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
this.session.updateAgentState((currentState) => ({
|
|
136
|
-
...currentState,
|
|
137
|
-
requests: {
|
|
138
|
-
...currentState.requests,
|
|
139
|
-
[toolCallId]: {
|
|
140
|
-
tool: toolName,
|
|
141
|
-
arguments: input,
|
|
142
|
-
createdAt: Date.now()
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Reset state for new sessions.
|
|
149
|
-
* This method is idempotent - safe to call multiple times.
|
|
150
|
-
*/
|
|
151
|
-
reset() {
|
|
152
|
-
if (this.isResetting) {
|
|
153
|
-
logger.debug(`${this.getLogPrefix()} Reset already in progress, skipping`);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
this.isResetting = true;
|
|
157
|
-
try {
|
|
158
|
-
const pendingSnapshot = Array.from(this.pendingRequests.entries());
|
|
159
|
-
this.pendingRequests.clear();
|
|
160
|
-
for (const [id, pending] of pendingSnapshot) {
|
|
161
|
-
try {
|
|
162
|
-
pending.reject(new Error("Session reset"));
|
|
163
|
-
} catch (err) {
|
|
164
|
-
logger.debug(`${this.getLogPrefix()} Error rejecting pending request ${id}:`, err);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
this.session.updateAgentState((currentState) => {
|
|
168
|
-
const pendingRequests = currentState.requests || {};
|
|
169
|
-
const completedRequests = { ...currentState.completedRequests };
|
|
170
|
-
for (const [id, request] of Object.entries(pendingRequests)) {
|
|
171
|
-
completedRequests[id] = {
|
|
172
|
-
...request,
|
|
173
|
-
completedAt: Date.now(),
|
|
174
|
-
status: "canceled",
|
|
175
|
-
reason: "Session reset"
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
...currentState,
|
|
180
|
-
requests: {},
|
|
181
|
-
completedRequests
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
logger.debug(`${this.getLogPrefix()} Permission handler reset`);
|
|
185
|
-
} finally {
|
|
186
|
-
this.isResetting = false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
2
|
+
import { l as logger } from './persistence-D9tMm6bj.mjs';
|
|
3
|
+
import { s as saveToolOutputRecord } from './api-Ew6xr81i.mjs';
|
|
190
4
|
|
|
191
5
|
class BaseReasoningProcessor {
|
|
192
6
|
accumulator = "";
|
|
@@ -382,273 +196,6 @@ class BaseReasoningProcessor {
|
|
|
382
196
|
}
|
|
383
197
|
}
|
|
384
198
|
|
|
385
|
-
const DEFAULT_MAX_SKILLS = 400;
|
|
386
|
-
const DEFAULT_MAX_DEPTH = 10;
|
|
387
|
-
const SKILL_FILE = "SKILL.md";
|
|
388
|
-
const IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
389
|
-
".git",
|
|
390
|
-
"node_modules",
|
|
391
|
-
"dist",
|
|
392
|
-
"build",
|
|
393
|
-
"references",
|
|
394
|
-
"assets",
|
|
395
|
-
"templates"
|
|
396
|
-
]);
|
|
397
|
-
function parseFrontMatter(content) {
|
|
398
|
-
if (!content.startsWith("---")) return {};
|
|
399
|
-
const end = content.indexOf("\n---", 3);
|
|
400
|
-
if (end < 0) return {};
|
|
401
|
-
const block = content.slice(3, end).split(/\r?\n/);
|
|
402
|
-
const result = {};
|
|
403
|
-
for (let i = 0; i < block.length; i++) {
|
|
404
|
-
const line = block[i];
|
|
405
|
-
const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line.trim());
|
|
406
|
-
if (!match) continue;
|
|
407
|
-
const [, key, rawValue] = match;
|
|
408
|
-
let value = rawValue.trim().replace(/^['"]|['"]$/g, "");
|
|
409
|
-
if ((rawValue.trim() === ">-" || rawValue.trim() === ">" || rawValue.trim() === "|-" || rawValue.trim() === "|") && key === "description") {
|
|
410
|
-
const continuation = [];
|
|
411
|
-
while (i + 1 < block.length && /^\s+/.test(block[i + 1])) {
|
|
412
|
-
i++;
|
|
413
|
-
continuation.push(block[i].trim());
|
|
414
|
-
}
|
|
415
|
-
value = continuation.join(rawValue.trim().startsWith("|") ? "\n" : " ").trim();
|
|
416
|
-
}
|
|
417
|
-
if (key === "name" && value) result.name = value;
|
|
418
|
-
if (key === "description" && value) result.description = value;
|
|
419
|
-
}
|
|
420
|
-
return result;
|
|
421
|
-
}
|
|
422
|
-
function deriveSkillName(skillFilePath) {
|
|
423
|
-
return basename(dirname(skillFilePath));
|
|
424
|
-
}
|
|
425
|
-
function collectSkillFiles(root, maxDepth, maxFiles) {
|
|
426
|
-
const files = [];
|
|
427
|
-
function walk(dir, depth) {
|
|
428
|
-
if (files.length >= maxFiles || depth > maxDepth) return;
|
|
429
|
-
let entries;
|
|
430
|
-
try {
|
|
431
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
432
|
-
} catch {
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
for (const entry of entries) {
|
|
436
|
-
if (files.length >= maxFiles) return;
|
|
437
|
-
const fullPath = join(dir, entry.name);
|
|
438
|
-
if (entry.isFile() && entry.name === SKILL_FILE) {
|
|
439
|
-
files.push(fullPath);
|
|
440
|
-
continue;
|
|
441
|
-
}
|
|
442
|
-
if (!entry.isDirectory()) continue;
|
|
443
|
-
if (IGNORED_DIRECTORIES.has(entry.name)) continue;
|
|
444
|
-
walk(fullPath, depth + 1);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
if (existsSync(root)) {
|
|
448
|
-
walk(root, 0);
|
|
449
|
-
}
|
|
450
|
-
return files;
|
|
451
|
-
}
|
|
452
|
-
function skillRoots(homeDir, includePluginCache) {
|
|
453
|
-
const roots = [
|
|
454
|
-
{ path: join(homeDir, ".agents", "skills"), source: "agents" },
|
|
455
|
-
{ path: join(homeDir, ".codex", "skills"), source: "codex" },
|
|
456
|
-
{ path: join(homeDir, ".claude", "skills"), source: "claude" }
|
|
457
|
-
];
|
|
458
|
-
if (includePluginCache) {
|
|
459
|
-
roots.push(
|
|
460
|
-
{ path: join(homeDir, ".codex", "plugins", "cache"), source: "codex-plugin-cache" },
|
|
461
|
-
{ path: join(homeDir, ".codex", ".tmp", "plugins", "plugins"), source: "codex-plugin-marketplace" }
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
return roots;
|
|
465
|
-
}
|
|
466
|
-
function discoverCodexSkills(options = {}) {
|
|
467
|
-
const homeDir = options.homeDir ?? homedir();
|
|
468
|
-
const maxSkills = options.maxSkills ?? DEFAULT_MAX_SKILLS;
|
|
469
|
-
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
470
|
-
const includePluginCache = options.includePluginCache ?? true;
|
|
471
|
-
const result = [];
|
|
472
|
-
const seen = /* @__PURE__ */ new Set();
|
|
473
|
-
for (const root of skillRoots(homeDir, includePluginCache)) {
|
|
474
|
-
if (result.length >= maxSkills) break;
|
|
475
|
-
const skillFiles = collectSkillFiles(root.path, maxDepth, maxSkills - result.length);
|
|
476
|
-
for (const skillFile of skillFiles) {
|
|
477
|
-
if (result.length >= maxSkills) break;
|
|
478
|
-
let content = "";
|
|
479
|
-
try {
|
|
480
|
-
content = readFileSync(skillFile, "utf8");
|
|
481
|
-
} catch {
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
const frontMatter = parseFrontMatter(content);
|
|
485
|
-
const name = (frontMatter.name || deriveSkillName(skillFile)).trim();
|
|
486
|
-
if (!name) continue;
|
|
487
|
-
const key = name.toLowerCase();
|
|
488
|
-
if (seen.has(key)) continue;
|
|
489
|
-
seen.add(key);
|
|
490
|
-
result.push({
|
|
491
|
-
name,
|
|
492
|
-
description: frontMatter.description,
|
|
493
|
-
source: root.source
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
return result;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function detectWorkspaceSubdirectories(cwd) {
|
|
501
|
-
try {
|
|
502
|
-
const entries = readdirSync(cwd, { withFileTypes: true });
|
|
503
|
-
const repos = [];
|
|
504
|
-
for (const entry of entries) {
|
|
505
|
-
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
506
|
-
const subDir = join(cwd, entry.name);
|
|
507
|
-
const info = detectGitWorktree(subDir);
|
|
508
|
-
if (info.isWorktree && info.worktreeBasePath && info.worktreeBranchName) {
|
|
509
|
-
repos.push({
|
|
510
|
-
path: subDir,
|
|
511
|
-
basePath: info.worktreeBasePath,
|
|
512
|
-
branchName: info.worktreeBranchName,
|
|
513
|
-
displayName: entry.name
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
if (repos.length > 0) {
|
|
518
|
-
return {
|
|
519
|
-
isWorktree: true,
|
|
520
|
-
workspaceRepos: repos,
|
|
521
|
-
workspacePath: cwd
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
} catch {
|
|
525
|
-
}
|
|
526
|
-
return {};
|
|
527
|
-
}
|
|
528
|
-
function detectWorktreeMetadata() {
|
|
529
|
-
if (process.env.HAPPY_WORKSPACE_REPOS) {
|
|
530
|
-
try {
|
|
531
|
-
const repos = JSON.parse(process.env.HAPPY_WORKSPACE_REPOS);
|
|
532
|
-
return {
|
|
533
|
-
isWorktree: true,
|
|
534
|
-
workspaceRepos: repos,
|
|
535
|
-
workspacePath: process.env.HAPPY_WORKSPACE_PATH
|
|
536
|
-
};
|
|
537
|
-
} catch {
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
if (process.env.HAPPY_WORKTREE_BASE_PATH) {
|
|
541
|
-
return {
|
|
542
|
-
isWorktree: true,
|
|
543
|
-
worktreeBasePath: process.env.HAPPY_WORKTREE_BASE_PATH,
|
|
544
|
-
worktreeBranchName: process.env.HAPPY_WORKTREE_BRANCH_NAME
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
const info = detectGitWorktree(process.cwd());
|
|
548
|
-
if (info.isWorktree) {
|
|
549
|
-
return {
|
|
550
|
-
isWorktree: true,
|
|
551
|
-
worktreeBasePath: info.worktreeBasePath,
|
|
552
|
-
worktreeBranchName: info.worktreeBranchName
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
const workspaceResult = detectWorkspaceSubdirectories(process.cwd());
|
|
556
|
-
if (workspaceResult.isWorktree) {
|
|
557
|
-
return workspaceResult;
|
|
558
|
-
}
|
|
559
|
-
return {};
|
|
560
|
-
}
|
|
561
|
-
function createSessionMetadata(opts) {
|
|
562
|
-
const state = {
|
|
563
|
-
controlledByUser: false
|
|
564
|
-
};
|
|
565
|
-
const metadata = {
|
|
566
|
-
path: process.cwd(),
|
|
567
|
-
host: os.hostname(),
|
|
568
|
-
version: packageJson.version,
|
|
569
|
-
os: os.platform(),
|
|
570
|
-
machineId: opts.machineId,
|
|
571
|
-
homeDir: os.homedir(),
|
|
572
|
-
happyHomeDir: configuration.happyHomeDir,
|
|
573
|
-
happyLibDir: projectPath(),
|
|
574
|
-
happyToolsDir: resolveToolsDir(),
|
|
575
|
-
startedFromDaemon: opts.startedBy === "daemon",
|
|
576
|
-
hostPid: process.pid,
|
|
577
|
-
startedBy: opts.startedBy || "terminal",
|
|
578
|
-
lifecycleState: "running",
|
|
579
|
-
lifecycleStateSince: Date.now(),
|
|
580
|
-
flavor: opts.flavor,
|
|
581
|
-
// Worktree metadata: env vars from daemon take priority, otherwise detect via git
|
|
582
|
-
...detectWorktreeMetadata()
|
|
583
|
-
};
|
|
584
|
-
if (opts.flavor === "codex") {
|
|
585
|
-
metadata.skills = discoverCodexSkills();
|
|
586
|
-
}
|
|
587
|
-
return { state, metadata };
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function createOfflineSessionStub(sessionTag) {
|
|
591
|
-
return {
|
|
592
|
-
sessionId: `offline-${sessionTag}`,
|
|
593
|
-
sendCodexMessage: () => {
|
|
594
|
-
},
|
|
595
|
-
sendAgentMessage: () => {
|
|
596
|
-
},
|
|
597
|
-
sendClaudeSessionMessage: () => {
|
|
598
|
-
},
|
|
599
|
-
keepAlive: () => {
|
|
600
|
-
},
|
|
601
|
-
sendSessionEvent: () => {
|
|
602
|
-
},
|
|
603
|
-
sendSessionDeath: () => {
|
|
604
|
-
},
|
|
605
|
-
updateLifecycleState: () => {
|
|
606
|
-
},
|
|
607
|
-
requestControlTransfer: async () => {
|
|
608
|
-
},
|
|
609
|
-
flush: async () => {
|
|
610
|
-
},
|
|
611
|
-
close: async () => {
|
|
612
|
-
},
|
|
613
|
-
updateMetadata: () => {
|
|
614
|
-
},
|
|
615
|
-
updateAgentState: () => {
|
|
616
|
-
},
|
|
617
|
-
onUserMessage: () => {
|
|
618
|
-
},
|
|
619
|
-
rpcHandlerManager: {
|
|
620
|
-
registerHandler: () => {
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
function setupOfflineReconnection(opts) {
|
|
627
|
-
const { api, sessionTag, metadata, state, response, onSessionSwap } = opts;
|
|
628
|
-
let session;
|
|
629
|
-
let reconnectionHandle = null;
|
|
630
|
-
if (!response) {
|
|
631
|
-
session = createOfflineSessionStub(sessionTag);
|
|
632
|
-
reconnectionHandle = startOfflineReconnection({
|
|
633
|
-
serverUrl: configuration.serverUrl,
|
|
634
|
-
onReconnected: async () => {
|
|
635
|
-
const resp = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
|
|
636
|
-
if (!resp) throw new Error("Server unavailable");
|
|
637
|
-
const realSession = api.sessionSyncClient(resp);
|
|
638
|
-
onSessionSwap(realSession);
|
|
639
|
-
return realSession;
|
|
640
|
-
},
|
|
641
|
-
onNotify: (msg) => {
|
|
642
|
-
console.log(msg);
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
return { session, reconnectionHandle, isOffline: true };
|
|
646
|
-
} else {
|
|
647
|
-
session = api.sessionSyncClient(response);
|
|
648
|
-
return { session, reconnectionHandle: null, isOffline: false };
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
199
|
const SUPPORTED_CATEGORIES = /* @__PURE__ */ new Set(["mode", "model", "thought_level"]);
|
|
653
200
|
function isRecord(value) {
|
|
654
201
|
return !!value && typeof value === "object";
|
|
@@ -1189,4 +736,4 @@ function summarizeBashToolOutput(options) {
|
|
|
1189
736
|
});
|
|
1190
737
|
}
|
|
1191
738
|
|
|
1192
|
-
export {
|
|
739
|
+
export { BaseReasoningProcessor as B, handleAgentMessageChunk as a, handleToolCallUpdate as b, handleAgentThoughtChunk as c, handleToolCall as d, handleLegacyMessageChunk as e, handlePlanUpdate as f, handleThinkingUpdate as g, handleConfigMetadataEvent as h, summarizeBashToolOutput as s };
|