happy-imou-cloud 2.1.41 → 2.1.43
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-Dica2zdX.mjs → BaseReasoningProcessor-CWCPAVJ3.mjs} +4 -2
- package/dist/{BaseReasoningProcessor-DAPsauUX.cjs → BaseReasoningProcessor-D6itItnT.cjs} +4 -2
- package/dist/{ProviderSelectionHandler-4nuTd8AP.cjs → ProviderSelectionHandler-CXwqOJpC.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-CmeZ92yO.mjs → ProviderSelectionHandler-CYUH1U8F.mjs} +2 -2
- package/dist/{api-CwNEbJBM.mjs → api-B89O-SC-.mjs} +398 -43
- package/dist/{api-C_Tnx4UG.cjs → api-zMic8QXq.cjs} +399 -42
- package/dist/{command-D0FxDynx.mjs → command-W01qXC9C.mjs} +2 -2
- package/dist/{command-C3RwwPVD.cjs → command-_qNFoJ-l.cjs} +2 -2
- package/dist/{index-D5m2Duxd.mjs → index-CiHiCC31.mjs} +31 -16
- package/dist/{index-Dh0qGrEd.cjs → index-DVVbyQGZ.cjs} +34 -19
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +1041 -214
- package/dist/lib.d.mts +1041 -214
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-6JloVYkb.mjs → registerKillSessionHandler-BnS3ozFX.mjs} +274 -101
- package/dist/{registerKillSessionHandler-Bkh8uLhC.cjs → registerKillSessionHandler-CDYAY5Ev.cjs} +274 -101
- package/dist/{runClaude-Bng_IsE7.mjs → runClaude-0U7kV07_.mjs} +13 -4
- package/dist/{runClaude-mIFO7YxF.cjs → runClaude-C1xfptKt.cjs} +14 -5
- package/dist/{runCodex-cNuxGshy.cjs → runCodex-BBgKpYLO.cjs} +20 -6
- package/dist/{runCodex-DAc6flez.mjs → runCodex-DnDmHm7E.mjs} +19 -5
- package/dist/{runGemini-DsRFV8WN.cjs → runGemini-CUwQHJ9y.cjs} +21 -5
- package/dist/{runGemini-DdXj8ltI.mjs → runGemini-DcsIBQSc.mjs} +20 -4
- package/package.json +1 -1
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-B89O-SC-.mjs';
|
|
2
2
|
export { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import 'chalk';
|
package/dist/{registerKillSessionHandler-6JloVYkb.mjs → registerKillSessionHandler-BnS3ozFX.mjs}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { k as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, l as resolveCanonicalToolNameV2, m as isTerminalReferenceOnlyPayload } from './index-
|
|
2
|
-
import { r as readSettings, H as HeadTailPreviewBuffer, e as HAPPY_ORG_REPLY_ACK_VERSION, f as HAPPY_ORG_TURN_REPORT_TAG, g as HAPPY_ORG_SUMMARY_MAX_LENGTH,
|
|
1
|
+
import { k as initialMachineMetadata, R as RuntimeShell, f as formatDisplayMessage, l as resolveCanonicalToolNameV2, m as isTerminalReferenceOnlyPayload, t as truncateDisplayMessage } from './index-CiHiCC31.mjs';
|
|
2
|
+
import { r as readSettings, H as HeadTailPreviewBuffer, e as HAPPY_ORG_REPLY_ACK_VERSION, f as HAPPY_ORG_TURN_REPORT_TAG, g as HAPPY_ORG_SUMMARY_MAX_LENGTH, j as HAPPY_ORG_REPEAT_THRESHOLD, l as logger, n as normalizePreviewableArtifactTarget } from './api-B89O-SC-.mjs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
|
-
import { createHash } from 'crypto';
|
|
6
5
|
import 'axios';
|
|
7
6
|
import 'node:events';
|
|
8
7
|
import 'node:fs/promises';
|
|
9
8
|
import 'socket.io-client';
|
|
10
9
|
import 'tweetnacl';
|
|
11
10
|
import 'fs/promises';
|
|
11
|
+
import 'crypto';
|
|
12
12
|
import 'path';
|
|
13
13
|
import 'node:child_process';
|
|
14
14
|
import 'chalk';
|
|
@@ -115,11 +115,11 @@ function renderTerminalOutputPreview(value, opts) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const DISPLAY_FRIENDLY_TOOL_FIELDS = ["stdout", "stderr", "output", "text", "message", "detail", "reason", "data"];
|
|
118
|
-
function isRecord$
|
|
118
|
+
function isRecord$2(value) {
|
|
119
119
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
120
120
|
}
|
|
121
121
|
function stripInternalToolMeta(value) {
|
|
122
|
-
if (!isRecord$
|
|
122
|
+
if (!isRecord$2(value)) {
|
|
123
123
|
return value;
|
|
124
124
|
}
|
|
125
125
|
const {
|
|
@@ -140,7 +140,7 @@ function extractNestedTextContent(value) {
|
|
|
140
140
|
const parts = value.map((item) => extractNestedTextContent(item)).filter((item) => typeof item === "string" && item.length > 0);
|
|
141
141
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
142
142
|
}
|
|
143
|
-
if (!isRecord$
|
|
143
|
+
if (!isRecord$2(value)) {
|
|
144
144
|
return null;
|
|
145
145
|
}
|
|
146
146
|
if (typeof value.text === "string" && value.text.trim().length > 0) {
|
|
@@ -160,7 +160,7 @@ function humanizeToolLabel(rawToolName) {
|
|
|
160
160
|
return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();
|
|
161
161
|
}
|
|
162
162
|
function isToolLifecycleResult(value) {
|
|
163
|
-
if (!isRecord$
|
|
163
|
+
if (!isRecord$2(value)) {
|
|
164
164
|
return false;
|
|
165
165
|
}
|
|
166
166
|
return typeof value.state === "string" && ("messages" in value || "description" in value || "createdAt" in value || "startedAt" in value || "completedAt" in value);
|
|
@@ -209,7 +209,7 @@ function normalizeCodexToolOutput(rawToolName, value) {
|
|
|
209
209
|
if (isTerminalReferenceOnlyPayload(normalizedLifecyclePayload)) {
|
|
210
210
|
return void 0;
|
|
211
211
|
}
|
|
212
|
-
if (!isRecord$
|
|
212
|
+
if (!isRecord$2(normalizedLifecyclePayload)) {
|
|
213
213
|
return normalizedLifecyclePayload;
|
|
214
214
|
}
|
|
215
215
|
const hasDisplayFriendlyField = DISPLAY_FRIENDLY_TOOL_FIELDS.some((field) => field in normalizedLifecyclePayload);
|
|
@@ -236,7 +236,7 @@ function truncateProviderOutputValue(value, label, seen = /* @__PURE__ */ new We
|
|
|
236
236
|
if (Array.isArray(value)) {
|
|
237
237
|
return renderOutputPreview(value, label);
|
|
238
238
|
}
|
|
239
|
-
if (!isRecord$
|
|
239
|
+
if (!isRecord$2(value)) {
|
|
240
240
|
return value;
|
|
241
241
|
}
|
|
242
242
|
if (seen.has(value)) {
|
|
@@ -307,7 +307,7 @@ function hasDisplayPayload(value) {
|
|
|
307
307
|
if (Array.isArray(sanitized)) {
|
|
308
308
|
return sanitized.length > 0;
|
|
309
309
|
}
|
|
310
|
-
if (isRecord$
|
|
310
|
+
if (isRecord$2(sanitized)) {
|
|
311
311
|
return Object.keys(sanitized).length > 0;
|
|
312
312
|
}
|
|
313
313
|
return true;
|
|
@@ -507,7 +507,7 @@ async function syncControlledByUserState(sessionClient, controlledByUser) {
|
|
|
507
507
|
const SESSION_LABEL_MAX_LENGTH = 60;
|
|
508
508
|
const TITLE_MAX_LENGTH = 80;
|
|
509
509
|
const BODY_MAX_LENGTH = 140;
|
|
510
|
-
function isRecord(value) {
|
|
510
|
+
function isRecord$1(value) {
|
|
511
511
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
512
512
|
}
|
|
513
513
|
function normalizeText(value) {
|
|
@@ -658,7 +658,7 @@ function humanizeToolName(toolName) {
|
|
|
658
658
|
return normalized.replace(/[_-]+/g, " ");
|
|
659
659
|
}
|
|
660
660
|
function extractPermissionRequestPushContext(message) {
|
|
661
|
-
const payload = isRecord(message.payload) ? message.payload : null;
|
|
661
|
+
const payload = isRecord$1(message.payload) ? message.payload : null;
|
|
662
662
|
const toolName = normalizeText(payload?.toolName) ?? normalizeText(message.reason);
|
|
663
663
|
const payloadDescription = normalizeText(payload?.description);
|
|
664
664
|
const reasonDescription = normalizeText(message.reason);
|
|
@@ -1614,7 +1614,7 @@ function normalizeTurnReportDraft(draft) {
|
|
|
1614
1614
|
interventionType: inferInterventionType(draft),
|
|
1615
1615
|
blockerCode: normalizeOptionalText(draft?.blockerCode),
|
|
1616
1616
|
decisionNeeded: normalizeOptionalText(draft?.decisionNeeded),
|
|
1617
|
-
targetArtifact:
|
|
1617
|
+
targetArtifact: normalizePreviewableArtifactTarget(draft?.targetArtifact),
|
|
1618
1618
|
accessChannelState: normalizeAccessChannelState(draft?.accessChannelState)
|
|
1619
1619
|
};
|
|
1620
1620
|
}
|
|
@@ -1646,7 +1646,7 @@ function extractTaggedTurnReport(text) {
|
|
|
1646
1646
|
interventionType: normalizeOptionalText(parsed.interventionType),
|
|
1647
1647
|
blockerCode: normalizeOptionalText(parsed.blockerCode),
|
|
1648
1648
|
decisionNeeded: normalizeOptionalText(parsed.decisionNeeded),
|
|
1649
|
-
targetArtifact:
|
|
1649
|
+
targetArtifact: normalizePreviewableArtifactTarget(parsed.targetArtifact),
|
|
1650
1650
|
accessChannelState: normalizeAccessChannelState(parsed.accessChannelState)
|
|
1651
1651
|
};
|
|
1652
1652
|
} catch {
|
|
@@ -1776,6 +1776,8 @@ function buildHappyOrgTurnPrompt(prompt, turn) {
|
|
|
1776
1776
|
"Use turnStatus=task_complete only when you believe the assigned task is finished and ready for CEO acceptance.",
|
|
1777
1777
|
"If turnStatus=task_complete, the task will wait for CEO close; do not treat it as automatically closed.",
|
|
1778
1778
|
"If turnStatus=task_complete, interventionType must be review_needed.",
|
|
1779
|
+
"targetArtifact must be null or a concrete previewable file target. Use a repo-relative path, absolute path, file:// URL, or https:// URL when you actually produced a material or artifact the client should open directly.",
|
|
1780
|
+
"Do not use abstract labels like release-checklist-template or completion-board-template in targetArtifact.",
|
|
1779
1781
|
`summary must fit on a one-line CEO card or task-board card: short, actionable, no long process logs, max ${HAPPY_ORG_SUMMARY_MAX_LENGTH} characters.`,
|
|
1780
1782
|
"Use blocker only for problems the organization may still solve internally.",
|
|
1781
1783
|
"Use decision_needed only when a CEO or user decision is required.",
|
|
@@ -2179,6 +2181,263 @@ class MessageBuffer {
|
|
|
2179
2181
|
}
|
|
2180
2182
|
}
|
|
2181
2183
|
|
|
2184
|
+
function isRecord(value) {
|
|
2185
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2186
|
+
}
|
|
2187
|
+
function hasClaudeCompatibilityShadow(value) {
|
|
2188
|
+
if (!isRecord(value)) {
|
|
2189
|
+
return false;
|
|
2190
|
+
}
|
|
2191
|
+
if (typeof value.happyCompatibilityShadow === "string" && value.happyCompatibilityShadow.trim()) {
|
|
2192
|
+
return true;
|
|
2193
|
+
}
|
|
2194
|
+
const message = value.message;
|
|
2195
|
+
if (!isRecord(message) || !Array.isArray(message.content)) {
|
|
2196
|
+
return false;
|
|
2197
|
+
}
|
|
2198
|
+
return message.content.some((block) => isRecord(block) && typeof block.happyCompatibilityShadow === "string" && block.happyCompatibilityShadow.trim().length > 0);
|
|
2199
|
+
}
|
|
2200
|
+
function createSessionTranscriptInkRenderer(opts) {
|
|
2201
|
+
const streamedAssistantMessages = /* @__PURE__ */ new Map();
|
|
2202
|
+
const renderBufferedText = (text, type, streamMetadata) => {
|
|
2203
|
+
const normalizedText = text.trim();
|
|
2204
|
+
if (!normalizedText) {
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
const streamKey = typeof streamMetadata?.messageId === "string" ? streamMetadata.messageId : typeof streamMetadata?.id === "string" ? streamMetadata.id : null;
|
|
2208
|
+
const phase = typeof streamMetadata?.phase === "string" ? streamMetadata.phase : null;
|
|
2209
|
+
const updateMode = streamMetadata?.mode === "replace" || phase === "commit" ? "replace" : "append";
|
|
2210
|
+
if (phase === "abort") {
|
|
2211
|
+
if (streamKey) {
|
|
2212
|
+
const bufferedId = streamedAssistantMessages.get(streamKey);
|
|
2213
|
+
if (bufferedId) {
|
|
2214
|
+
opts.messageBuffer.removeMessage(bufferedId);
|
|
2215
|
+
streamedAssistantMessages.delete(streamKey);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
if (!streamKey) {
|
|
2221
|
+
opts.messageBuffer.addMessage(normalizedText, type);
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2224
|
+
const existingBufferedId = streamedAssistantMessages.get(streamKey);
|
|
2225
|
+
if (!existingBufferedId) {
|
|
2226
|
+
const nextBufferedId = opts.messageBuffer.addMessage(normalizedText, type);
|
|
2227
|
+
if (phase !== "commit") {
|
|
2228
|
+
streamedAssistantMessages.set(streamKey, nextBufferedId);
|
|
2229
|
+
}
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
const updated = opts.messageBuffer.updateMessage(existingBufferedId, normalizedText, {
|
|
2233
|
+
mode: updateMode
|
|
2234
|
+
});
|
|
2235
|
+
if (!updated) {
|
|
2236
|
+
const nextBufferedId = opts.messageBuffer.addMessage(normalizedText, type);
|
|
2237
|
+
if (phase !== "commit") {
|
|
2238
|
+
streamedAssistantMessages.set(streamKey, nextBufferedId);
|
|
2239
|
+
}
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
if (phase === "commit") {
|
|
2243
|
+
streamedAssistantMessages.delete(streamKey);
|
|
2244
|
+
}
|
|
2245
|
+
};
|
|
2246
|
+
const renderStructuredAgentPayload = (payload) => {
|
|
2247
|
+
if (!isRecord(payload) || typeof payload.type !== "string") {
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
switch (payload.type) {
|
|
2251
|
+
case "message":
|
|
2252
|
+
case "reasoning": {
|
|
2253
|
+
if (typeof payload.message !== "string") {
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
renderBufferedText(
|
|
2257
|
+
payload.message,
|
|
2258
|
+
payload.type === "reasoning" ? "status" : "assistant",
|
|
2259
|
+
payload
|
|
2260
|
+
);
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
case "thinking": {
|
|
2264
|
+
if (typeof payload.text === "string" && payload.text.trim()) {
|
|
2265
|
+
opts.messageBuffer.addMessage(`[Thinking] ${payload.text.trim()}`, "status");
|
|
2266
|
+
}
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
case "tool-call": {
|
|
2270
|
+
const name = typeof payload.name === "string" ? payload.name : typeof payload.toolName === "string" ? payload.toolName : "tool";
|
|
2271
|
+
const inputPreview = truncateDisplayMessage(
|
|
2272
|
+
isRecord(payload.input) || Array.isArray(payload.input) ? JSON.stringify(payload.input) : payload.input,
|
|
2273
|
+
120
|
|
2274
|
+
);
|
|
2275
|
+
opts.messageBuffer.addMessage(
|
|
2276
|
+
`Executing: ${name}${inputPreview ? ` ${inputPreview}` : ""}`,
|
|
2277
|
+
"tool"
|
|
2278
|
+
);
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
case "tool-result":
|
|
2282
|
+
case "tool-call-result": {
|
|
2283
|
+
const resultValue = Object.prototype.hasOwnProperty.call(payload, "output") ? payload.output : payload.result;
|
|
2284
|
+
const resultPreview = truncateDisplayMessage(resultValue, 200);
|
|
2285
|
+
const prefix = payload.isError ? "Error:" : "Result:";
|
|
2286
|
+
opts.messageBuffer.addMessage(
|
|
2287
|
+
resultPreview ? `${prefix} ${resultPreview}` : "Tool completed",
|
|
2288
|
+
payload.isError ? "status" : "result"
|
|
2289
|
+
);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
case "file-edit":
|
|
2293
|
+
case "fs-edit": {
|
|
2294
|
+
const description = typeof payload.description === "string" ? payload.description : "File edit";
|
|
2295
|
+
opts.messageBuffer.addMessage(`File edit: ${description}`, "tool");
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
case "terminal-output": {
|
|
2299
|
+
if (typeof payload.data !== "string") {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
const preview = renderTerminalOutputPreview(payload.data);
|
|
2303
|
+
if (preview) {
|
|
2304
|
+
opts.messageBuffer.addMessage(preview, "result");
|
|
2305
|
+
}
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
case "permission-request": {
|
|
2309
|
+
const toolName = typeof payload.toolName === "string" ? payload.toolName : "tool";
|
|
2310
|
+
opts.messageBuffer.addMessage(`Permission requested: ${toolName}`, "status");
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
case "exec-approval-request": {
|
|
2314
|
+
opts.messageBuffer.addMessage("Exec approval requested", "status");
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
case "patch-apply-begin": {
|
|
2318
|
+
opts.messageBuffer.addMessage("Applying patch...", "tool");
|
|
2319
|
+
return;
|
|
2320
|
+
}
|
|
2321
|
+
case "patch-apply-end": {
|
|
2322
|
+
const completionMessage = payload.success === false ? truncateDisplayMessage(payload.stderr, 200) || "Patch failed" : truncateDisplayMessage(payload.stdout, 200) || "Patch applied";
|
|
2323
|
+
opts.messageBuffer.addMessage(completionMessage, payload.success === false ? "status" : "result");
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
case "event": {
|
|
2327
|
+
if (payload.name === "thinking" && isRecord(payload.payload) && typeof payload.payload.text === "string" && payload.payload.text.trim()) {
|
|
2328
|
+
opts.messageBuffer.addMessage(`[Thinking] ${payload.payload.text.trim()}`, "status");
|
|
2329
|
+
}
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
case "task_started":
|
|
2333
|
+
case "task_complete":
|
|
2334
|
+
case "turn_aborted":
|
|
2335
|
+
case "turn-report":
|
|
2336
|
+
case "token_count":
|
|
2337
|
+
case "token-count":
|
|
2338
|
+
return;
|
|
2339
|
+
default:
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
const renderLegacyClaudeOutput = (payload) => {
|
|
2344
|
+
if (!isRecord(payload) || hasClaudeCompatibilityShadow(payload)) {
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
if (payload.type === "summary" && typeof payload.summary === "string" && payload.summary.trim()) {
|
|
2348
|
+
opts.messageBuffer.addMessage(payload.summary.trim(), "result");
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
if (payload.type !== "assistant") {
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
const message = isRecord(payload.message) ? payload.message : null;
|
|
2355
|
+
const content = message?.content;
|
|
2356
|
+
if (typeof content === "string" && content.trim()) {
|
|
2357
|
+
opts.messageBuffer.addMessage(content.trim(), "assistant");
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
if (!Array.isArray(content)) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
for (const block of content) {
|
|
2364
|
+
if (!isRecord(block) || typeof block.type !== "string") {
|
|
2365
|
+
continue;
|
|
2366
|
+
}
|
|
2367
|
+
if (block.type === "thinking" && typeof block.thinking === "string" && block.thinking.trim()) {
|
|
2368
|
+
opts.messageBuffer.addMessage(`[Thinking] ${block.thinking.trim()}`, "status");
|
|
2369
|
+
continue;
|
|
2370
|
+
}
|
|
2371
|
+
if (block.type === "text" && typeof block.text === "string" && block.text.trim()) {
|
|
2372
|
+
opts.messageBuffer.addMessage(block.text.trim(), "assistant");
|
|
2373
|
+
continue;
|
|
2374
|
+
}
|
|
2375
|
+
if (block.type === "tool_use") {
|
|
2376
|
+
const toolName = typeof block.name === "string" ? block.name : "tool";
|
|
2377
|
+
const inputPreview = truncateDisplayMessage(
|
|
2378
|
+
isRecord(block.input) || Array.isArray(block.input) ? JSON.stringify(block.input) : block.input,
|
|
2379
|
+
120
|
|
2380
|
+
);
|
|
2381
|
+
opts.messageBuffer.addMessage(
|
|
2382
|
+
`Executing: ${toolName}${inputPreview ? ` ${inputPreview}` : ""}`,
|
|
2383
|
+
"tool"
|
|
2384
|
+
);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
const renderSessionEvent = (payload) => {
|
|
2389
|
+
if (!isRecord(payload) || typeof payload.type !== "string") {
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
switch (payload.type) {
|
|
2393
|
+
case "message":
|
|
2394
|
+
if (typeof payload.message === "string" && payload.message.trim()) {
|
|
2395
|
+
opts.messageBuffer.addMessage(payload.message.trim(), "status");
|
|
2396
|
+
}
|
|
2397
|
+
return;
|
|
2398
|
+
case "switch":
|
|
2399
|
+
if (payload.mode === "local" || payload.mode === "remote") {
|
|
2400
|
+
opts.messageBuffer.addMessage(`Mode switched to ${payload.mode}`, "status");
|
|
2401
|
+
}
|
|
2402
|
+
return;
|
|
2403
|
+
case "permission-mode-changed":
|
|
2404
|
+
if (typeof payload.mode === "string" && payload.mode.trim()) {
|
|
2405
|
+
opts.messageBuffer.addMessage(`Permission mode: ${payload.mode}`, "status");
|
|
2406
|
+
}
|
|
2407
|
+
return;
|
|
2408
|
+
case "ready":
|
|
2409
|
+
return;
|
|
2410
|
+
default:
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
};
|
|
2414
|
+
return (transcriptMessage) => {
|
|
2415
|
+
if (transcriptMessage.message.role === "user") {
|
|
2416
|
+
const text = transcriptMessage.message.content.text.trim();
|
|
2417
|
+
if (text) {
|
|
2418
|
+
opts.messageBuffer.addMessage(text, "user");
|
|
2419
|
+
}
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
switch (transcriptMessage.message.content.type) {
|
|
2423
|
+
case "output":
|
|
2424
|
+
renderLegacyClaudeOutput(transcriptMessage.message.content.data);
|
|
2425
|
+
return;
|
|
2426
|
+
case "codex":
|
|
2427
|
+
renderStructuredAgentPayload(transcriptMessage.message.content.data);
|
|
2428
|
+
return;
|
|
2429
|
+
case "acp":
|
|
2430
|
+
renderStructuredAgentPayload(transcriptMessage.message.content.data);
|
|
2431
|
+
return;
|
|
2432
|
+
case "event":
|
|
2433
|
+
renderSessionEvent(transcriptMessage.message.content.data);
|
|
2434
|
+
return;
|
|
2435
|
+
default:
|
|
2436
|
+
opts.messageBuffer.addMessage(formatDisplayMessage(transcriptMessage.message), "status");
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2182
2441
|
let ConversationHistory$1 = class ConversationHistory {
|
|
2183
2442
|
messages = [];
|
|
2184
2443
|
maxMessages;
|
|
@@ -2750,92 +3009,6 @@ class MessageQueue2 {
|
|
|
2750
3009
|
}
|
|
2751
3010
|
}
|
|
2752
3011
|
|
|
2753
|
-
function deterministicStringify(obj, options = {}) {
|
|
2754
|
-
const {
|
|
2755
|
-
undefinedBehavior = "omit",
|
|
2756
|
-
sortArrays = false,
|
|
2757
|
-
replacer,
|
|
2758
|
-
includeSymbols = false
|
|
2759
|
-
} = options;
|
|
2760
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
2761
|
-
function processValue(value, key) {
|
|
2762
|
-
if (replacer && key !== void 0) {
|
|
2763
|
-
value = replacer(key, value);
|
|
2764
|
-
}
|
|
2765
|
-
if (value === null) return null;
|
|
2766
|
-
if (value === void 0) {
|
|
2767
|
-
switch (undefinedBehavior) {
|
|
2768
|
-
case "omit":
|
|
2769
|
-
return void 0;
|
|
2770
|
-
case "null":
|
|
2771
|
-
return null;
|
|
2772
|
-
case "throw":
|
|
2773
|
-
throw new Error(`Undefined value at key: ${key}`);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
if (typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
|
|
2777
|
-
return value;
|
|
2778
|
-
}
|
|
2779
|
-
if (value instanceof Date) {
|
|
2780
|
-
return value.toISOString();
|
|
2781
|
-
}
|
|
2782
|
-
if (value instanceof RegExp) {
|
|
2783
|
-
return value.toString();
|
|
2784
|
-
}
|
|
2785
|
-
if (typeof value === "function") {
|
|
2786
|
-
return void 0;
|
|
2787
|
-
}
|
|
2788
|
-
if (typeof value === "symbol") {
|
|
2789
|
-
return includeSymbols ? value.toString() : void 0;
|
|
2790
|
-
}
|
|
2791
|
-
if (typeof value === "bigint") {
|
|
2792
|
-
return value.toString() + "n";
|
|
2793
|
-
}
|
|
2794
|
-
if (seen.has(value)) {
|
|
2795
|
-
throw new Error("Circular reference detected");
|
|
2796
|
-
}
|
|
2797
|
-
seen.add(value);
|
|
2798
|
-
if (Array.isArray(value)) {
|
|
2799
|
-
const processed2 = value.map((item, index) => processValue(item, String(index))).filter((item) => item !== void 0);
|
|
2800
|
-
if (sortArrays) {
|
|
2801
|
-
processed2.sort((a, b) => {
|
|
2802
|
-
const aStr = JSON.stringify(processValue(a));
|
|
2803
|
-
const bStr = JSON.stringify(processValue(b));
|
|
2804
|
-
return aStr.localeCompare(bStr);
|
|
2805
|
-
});
|
|
2806
|
-
}
|
|
2807
|
-
seen.delete(value);
|
|
2808
|
-
return processed2;
|
|
2809
|
-
}
|
|
2810
|
-
if (value.constructor === Object || value.constructor === void 0) {
|
|
2811
|
-
const processed2 = {};
|
|
2812
|
-
const keys = Object.keys(value).sort();
|
|
2813
|
-
for (const k of keys) {
|
|
2814
|
-
const processedValue = processValue(value[k], k);
|
|
2815
|
-
if (processedValue !== void 0) {
|
|
2816
|
-
processed2[k] = processedValue;
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
seen.delete(value);
|
|
2820
|
-
return processed2;
|
|
2821
|
-
}
|
|
2822
|
-
try {
|
|
2823
|
-
const plain = { ...value };
|
|
2824
|
-
seen.delete(value);
|
|
2825
|
-
return processValue(plain, key);
|
|
2826
|
-
} catch {
|
|
2827
|
-
seen.delete(value);
|
|
2828
|
-
return String(value);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
const processed = processValue(obj);
|
|
2832
|
-
return JSON.stringify(processed);
|
|
2833
|
-
}
|
|
2834
|
-
function hashObject(obj, options, encoding = "hex") {
|
|
2835
|
-
const jsonString = deterministicStringify(obj, options);
|
|
2836
|
-
return createHash("sha256").update(jsonString).digest(encoding);
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
3012
|
function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
|
|
2840
3013
|
rpcHandlerManager.registerHandler("killSession", async () => {
|
|
2841
3014
|
logger.debug("Kill session request received");
|
|
@@ -2847,4 +3020,4 @@ function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
|
|
|
2847
3020
|
});
|
|
2848
3021
|
}
|
|
2849
3022
|
|
|
2850
|
-
export { BasePermissionHandler as B, ConversationHistory$1 as C, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b, registerKillSessionHandler as c, MessageBuffer as d, ensureManagedProviderMachine as e, buildHappyOrgTurnPrompt as f, getPendingInteractionTimeoutMs as g,
|
|
3023
|
+
export { BasePermissionHandler as B, ConversationHistory$1 as C, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b, registerKillSessionHandler as c, MessageBuffer as d, ensureManagedProviderMachine as e, buildHappyOrgTurnPrompt as f, getPendingInteractionTimeoutMs as g, finalizeHappyOrgTurnWithBusinessAck as h, buildTurnResultPushNotification as i, buildReadyPushNotification as j, extractPermissionRequestPushContext as k, launchRuntimeHandleWithFactoryResult as l, buildPermissionPushNotification as m, renderTerminalOutputPreview as n, inferToolResultError as o, forwardAgentMessageToProviderSession as p, createSessionTranscriptInkRenderer as q, resolveHappyOrgQueuedTurn as r, syncControlledByUserState as s, waitForResponseCompleteWithAbort as w };
|