happy-imou-cloud 2.1.52 → 2.1.53
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/{AcpBackend-DtxGBKiz.cjs → AcpBackend-B3s99ivd.cjs} +3 -3
- package/dist/{AcpBackend-3-XDjrku.mjs → AcpBackend-Dephumdg.mjs} +3 -3
- package/dist/{BaseReasoningProcessor-GrsmssbV.mjs → BaseReasoningProcessor-D0lBynU3.mjs} +1 -1
- package/dist/{BaseReasoningProcessor-CAQB14n9.cjs → BaseReasoningProcessor-DgyEX2ex.cjs} +1 -1
- package/dist/{ConversationHistory-DblMPp5X.cjs → ConversationHistory-DYF60lvE.cjs} +3 -3
- package/dist/{ConversationHistory-BtPGSkJU.mjs → ConversationHistory-Dr1H-t58.mjs} +3 -3
- package/dist/{ProviderSelectionHandler-DrWMeahq.cjs → ProviderSelectionHandler-BsIj6tUM.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-AbhoRyth.mjs → ProviderSelectionHandler-oIejggTi.mjs} +2 -2
- package/dist/{RuntimeShell-DCeyYzOs.cjs → RuntimeShell-CoXntnel.cjs} +2 -2
- package/dist/{RuntimeShell-BbEINPUC.mjs → RuntimeShell-DZhi4Zhd.mjs} +2 -2
- package/dist/{bootstrapManagedProviderSession-BM1PDHRS.cjs → bootstrapManagedProviderSession-DuPoeGsz.cjs} +2 -2
- package/dist/{bootstrapManagedProviderSession-pAWC0cg8.mjs → bootstrapManagedProviderSession-HezKZOHo.mjs} +2 -2
- package/dist/{claude-Cd1EV34h.cjs → claude-DJ98mF1g.cjs} +3 -3
- package/dist/{claude-CwRWUUVR.mjs → claude-Dm0RQqLD.mjs} +3 -3
- package/dist/{codex-suiruFqm.cjs → codex-CGoezd1l.cjs} +4 -4
- package/dist/{codex-B0MiKtqc.mjs → codex-CjtUx7la.mjs} +4 -4
- package/dist/{command-BNdy9kbh.mjs → command-CX3Ijure.mjs} +8 -8
- package/dist/{command-DD7nnM4r.cjs → command-DAb1FNFD.cjs} +8 -8
- package/dist/{config-BuQStBK_.cjs → config-D9ppiOqF.cjs} +1 -1
- package/dist/{config-C9Yb905M.mjs → config-DsOkKwwg.mjs} +1 -1
- package/dist/{createDefaultRuntimeShell-BM2lyPQ4.mjs → createDefaultRuntimeShell-BJdgPwWt.mjs} +6 -6
- package/dist/{createDefaultRuntimeShell-DQlet_Es.cjs → createDefaultRuntimeShell-Dt2klFXx.cjs} +6 -6
- package/dist/{cursor-Cf87RaxN.mjs → cursor-BxWThmbf.mjs} +4 -4
- package/dist/{cursor-D4eQeadD.cjs → cursor-DOu6sau_.cjs} +4 -4
- package/dist/{index-CxPxEDeE.mjs → index-B_Cm6MhB.mjs} +11 -11
- package/dist/{index-Ca00OSY5.cjs → index-Cd7d2BMe.cjs} +14 -14
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{installFatalProcessHandlers-CwVyatD4.cjs → installFatalProcessHandlers-CNnOiioM.cjs} +1 -1
- package/dist/{installFatalProcessHandlers-DG1QZYHP.mjs → installFatalProcessHandlers-DeJFoOCl.mjs} +1 -1
- package/dist/{launch-Cj9fXgj3.mjs → launch-CTC8E1YI.mjs} +8 -8
- package/dist/{launch-BZfxJTsA.cjs → launch-CVYm-vTg.cjs} +8 -8
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +8 -1
- package/dist/lib.d.mts +8 -1
- package/dist/lib.mjs +1 -1
- package/dist/{runClaude-CqqJipYj.mjs → runClaude-BB-5Su2y.mjs} +29 -37
- package/dist/{runClaude-vRuF9RZV.cjs → runClaude-DbiPMUS4.cjs} +29 -37
- package/dist/{runCodex-BuENvdll.mjs → runCodex-BAWWDwBE.mjs} +49 -34
- package/dist/{runCodex-D61xJnYS.cjs → runCodex-CIZFYkTI.cjs} +49 -34
- package/dist/{runCursor-BuIUSR5U.mjs → runCursor-DJgPZ-11.mjs} +17 -28
- package/dist/{runCursor-avWVar8f.cjs → runCursor-GR8a5T-H.cjs} +17 -28
- package/dist/{runGemini-DPeGLZXt.mjs → runGemini-CwKyhP0O.mjs} +23 -34
- package/dist/{runGemini-Dkmy1MA6.cjs → runGemini-yWXF4JBe.cjs} +23 -34
- package/dist/{sessionControl-DoQKVLbo.cjs → sessionControl-BM3380c0.cjs} +122 -3
- package/dist/{sessionControl-BmmjRdC4.mjs → sessionControl-D8sHsOfs.mjs} +122 -4
- package/dist/{types-CwpYbO-W.cjs → types-Be833t7e.cjs} +82 -11
- package/dist/{types-DleyDaIf.mjs → types-CDuesyX_.mjs} +83 -12
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
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, h as hashObject
|
|
5
|
-
import { C as ConversationHistory$1, M as MessageBuffer, b as buildTurnResultPushNotification, a as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, e as extractPermissionRequestPushContext, c as buildPermissionPushNotification, d as createSessionTranscriptInkRenderer } from './ConversationHistory-
|
|
6
|
-
import { B as BasePermissionHandler,
|
|
7
|
-
import { f as resolveAcpSessionPreferences, n as scaleAcpTimeoutMs, b as closeProviderSession, s as stopCaffeinate } from './index-
|
|
8
|
-
import { A as AcpBackend } from './AcpBackend-
|
|
9
|
-
import { r as readGeminiLocalConfig, G as GEMINI_API_KEY_ENV, a as GOOGLE_API_KEY_ENV, d as determineGeminiModel, g as getGeminiModelSource, b as GEMINI_MODEL_ENV, c as getInitialGeminiModel, s as saveGeminiModelToConfig } from './config-
|
|
10
|
-
import { B as BaseReasoningProcessor } from './BaseReasoningProcessor-
|
|
4
|
+
import { l as logger, b as connectionState, A as ApiClient, h as hashObject } from './types-CDuesyX_.mjs';
|
|
5
|
+
import { C as ConversationHistory$1, M as MessageBuffer, b as buildTurnResultPushNotification, a as buildReadyPushNotification, l as launchRuntimeHandleWithFactoryResult, e as extractPermissionRequestPushContext, c as buildPermissionPushNotification, d as createSessionTranscriptInkRenderer } from './ConversationHistory-Dr1H-t58.mjs';
|
|
6
|
+
import { B as BasePermissionHandler, d as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, c as BufferedAssistantStreamEmitter, r as registerKillSessionHandler, f as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, h as finalizeHappyOrgTurnWithBusinessAck, j as renderTerminalOutputPreview, p as prepareTerminalOutputForForwarding, k as inferToolResultError, i as forwardAgentMessageToProviderSession } from './sessionControl-D8sHsOfs.mjs';
|
|
7
|
+
import { f as resolveAcpSessionPreferences, n as scaleAcpTimeoutMs, b as closeProviderSession, s as stopCaffeinate } from './index-B_Cm6MhB.mjs';
|
|
8
|
+
import { A as AcpBackend } from './AcpBackend-Dephumdg.mjs';
|
|
9
|
+
import { r as readGeminiLocalConfig, G as GEMINI_API_KEY_ENV, a as GOOGLE_API_KEY_ENV, d as determineGeminiModel, g as getGeminiModelSource, b as GEMINI_MODEL_ENV, c as getInitialGeminiModel, s as saveGeminiModelToConfig } from './config-DsOkKwwg.mjs';
|
|
10
|
+
import { B as BaseReasoningProcessor } from './BaseReasoningProcessor-D0lBynU3.mjs';
|
|
11
11
|
import 'cross-spawn';
|
|
12
12
|
import '@agentclientprotocol/sdk';
|
|
13
13
|
import 'ps-list';
|
|
@@ -16,7 +16,7 @@ import 'node:path';
|
|
|
16
16
|
import 'node:os';
|
|
17
17
|
import 'node:child_process';
|
|
18
18
|
import 'node:readline';
|
|
19
|
-
import { b as bootstrapManagedProviderSession } from './bootstrapManagedProviderSession-
|
|
19
|
+
import { b as bootstrapManagedProviderSession } from './bootstrapManagedProviderSession-HezKZOHo.mjs';
|
|
20
20
|
import 'tweetnacl';
|
|
21
21
|
import 'axios';
|
|
22
22
|
import 'open';
|
|
@@ -31,7 +31,7 @@ import 'socket.io-client';
|
|
|
31
31
|
import 'fs/promises';
|
|
32
32
|
import 'crypto';
|
|
33
33
|
import 'expo-server-sdk';
|
|
34
|
-
import './RuntimeShell-
|
|
34
|
+
import './RuntimeShell-DZhi4Zhd.mjs';
|
|
35
35
|
import 'os';
|
|
36
36
|
import 'qrcode-terminal';
|
|
37
37
|
import 'node:module';
|
|
@@ -967,6 +967,9 @@ async function runGemini(opts) {
|
|
|
967
967
|
let unexpectedRuntimeStopRecovery = null;
|
|
968
968
|
let readyAlreadySent = false;
|
|
969
969
|
let currentHappyOrgTurn = null;
|
|
970
|
+
const assistantMessageEmitter = new BufferedAssistantStreamEmitter({
|
|
971
|
+
send: (payload) => session.sendAgentMessage("gemini", payload)
|
|
972
|
+
});
|
|
970
973
|
async function handleAbort() {
|
|
971
974
|
logger.debug("[Gemini] Abort requested - stopping current task");
|
|
972
975
|
if (!turnAbortedSent) {
|
|
@@ -978,7 +981,7 @@ async function runGemini(opts) {
|
|
|
978
981
|
}
|
|
979
982
|
reasoningProcessor.abort();
|
|
980
983
|
diffProcessor.reset();
|
|
981
|
-
|
|
984
|
+
assistantMessageEmitter.reset();
|
|
982
985
|
try {
|
|
983
986
|
abortController.abort();
|
|
984
987
|
messageQueue.reset();
|
|
@@ -1135,7 +1138,6 @@ async function runGemini(opts) {
|
|
|
1135
1138
|
let isResponseInProgress = false;
|
|
1136
1139
|
let hadToolCallInTurn = false;
|
|
1137
1140
|
let taskStartedSent = false;
|
|
1138
|
-
const assistantMessageStream = new AssistantMessageStream();
|
|
1139
1141
|
const resetTurnState = () => {
|
|
1140
1142
|
reasoningProcessor.abort();
|
|
1141
1143
|
diffProcessor.reset();
|
|
@@ -1146,7 +1148,7 @@ async function runGemini(opts) {
|
|
|
1146
1148
|
taskStartedSent = false;
|
|
1147
1149
|
turnAbortedSent = false;
|
|
1148
1150
|
currentHappyOrgTurn = null;
|
|
1149
|
-
|
|
1151
|
+
assistantMessageEmitter.reset();
|
|
1150
1152
|
thinking = false;
|
|
1151
1153
|
session.keepAlive(thinking, "remote");
|
|
1152
1154
|
};
|
|
@@ -1157,43 +1159,30 @@ async function runGemini(opts) {
|
|
|
1157
1159
|
if (!text.trim()) {
|
|
1158
1160
|
return false;
|
|
1159
1161
|
}
|
|
1160
|
-
if (!
|
|
1162
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1161
1163
|
currentAssistantStreamStartLength = accumulatedResponse.length - text.length;
|
|
1162
1164
|
}
|
|
1163
|
-
|
|
1164
|
-
session.sendAgentMessage("gemini", {
|
|
1165
|
-
type: "message",
|
|
1166
|
-
message: text,
|
|
1167
|
-
id: stream.messageId,
|
|
1168
|
-
...stream
|
|
1169
|
-
});
|
|
1170
|
-
return true;
|
|
1165
|
+
return assistantMessageEmitter.pushDelta(text);
|
|
1171
1166
|
};
|
|
1172
1167
|
const buildAssistantMessageCommit = (message) => {
|
|
1173
|
-
if (!
|
|
1168
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1174
1169
|
return {
|
|
1175
1170
|
type: "message",
|
|
1176
1171
|
message,
|
|
1177
1172
|
id: randomUUID()
|
|
1178
1173
|
};
|
|
1179
1174
|
}
|
|
1180
|
-
|
|
1181
|
-
return {
|
|
1182
|
-
type: "message",
|
|
1183
|
-
message: message.slice(currentAssistantStreamStartLength),
|
|
1184
|
-
id: stream.messageId,
|
|
1185
|
-
...stream
|
|
1186
|
-
};
|
|
1175
|
+
return assistantMessageEmitter.buildCommitPayload(message.slice(currentAssistantStreamStartLength));
|
|
1187
1176
|
};
|
|
1188
1177
|
const commitActiveAssistantMessageStream = () => {
|
|
1189
|
-
if (!
|
|
1178
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1190
1179
|
return false;
|
|
1191
1180
|
}
|
|
1192
|
-
const
|
|
1193
|
-
if (!
|
|
1181
|
+
const message = accumulatedResponse.slice(currentAssistantStreamStartLength);
|
|
1182
|
+
if (!message.trim()) {
|
|
1194
1183
|
return false;
|
|
1195
1184
|
}
|
|
1196
|
-
|
|
1185
|
+
assistantMessageEmitter.commit(message);
|
|
1197
1186
|
currentAssistantStreamStartLength = accumulatedResponse.length;
|
|
1198
1187
|
return true;
|
|
1199
1188
|
};
|
|
@@ -1321,7 +1310,7 @@ Guide: https://goo.gle/gemini-cli-auth-docs#workspace-gca`;
|
|
|
1321
1310
|
type: "message",
|
|
1322
1311
|
message: `Error: ${errorMessage}`
|
|
1323
1312
|
});
|
|
1324
|
-
|
|
1313
|
+
assistantMessageEmitter.reset();
|
|
1325
1314
|
}
|
|
1326
1315
|
break;
|
|
1327
1316
|
case "tool-call":
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var ink = require('ink');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var persistence = require('./types-
|
|
7
|
-
var ConversationHistory$1 = require('./ConversationHistory-
|
|
8
|
-
var sessionControl = require('./sessionControl-
|
|
9
|
-
var index = require('./index-
|
|
10
|
-
var AcpBackend = require('./AcpBackend-
|
|
11
|
-
var config = require('./config-
|
|
12
|
-
var BaseReasoningProcessor = require('./BaseReasoningProcessor-
|
|
6
|
+
var persistence = require('./types-Be833t7e.cjs');
|
|
7
|
+
var ConversationHistory$1 = require('./ConversationHistory-DYF60lvE.cjs');
|
|
8
|
+
var sessionControl = require('./sessionControl-BM3380c0.cjs');
|
|
9
|
+
var index = require('./index-Cd7d2BMe.cjs');
|
|
10
|
+
var AcpBackend = require('./AcpBackend-B3s99ivd.cjs');
|
|
11
|
+
var config = require('./config-D9ppiOqF.cjs');
|
|
12
|
+
var BaseReasoningProcessor = require('./BaseReasoningProcessor-DgyEX2ex.cjs');
|
|
13
13
|
require('cross-spawn');
|
|
14
14
|
require('@agentclientprotocol/sdk');
|
|
15
15
|
require('ps-list');
|
|
@@ -18,7 +18,7 @@ require('node:path');
|
|
|
18
18
|
require('node:os');
|
|
19
19
|
require('node:child_process');
|
|
20
20
|
require('node:readline');
|
|
21
|
-
var bootstrapManagedProviderSession = require('./bootstrapManagedProviderSession-
|
|
21
|
+
var bootstrapManagedProviderSession = require('./bootstrapManagedProviderSession-DuPoeGsz.cjs');
|
|
22
22
|
require('tweetnacl');
|
|
23
23
|
require('axios');
|
|
24
24
|
require('open');
|
|
@@ -33,7 +33,7 @@ require('socket.io-client');
|
|
|
33
33
|
require('fs/promises');
|
|
34
34
|
require('crypto');
|
|
35
35
|
require('expo-server-sdk');
|
|
36
|
-
require('./RuntimeShell-
|
|
36
|
+
require('./RuntimeShell-CoXntnel.cjs');
|
|
37
37
|
require('os');
|
|
38
38
|
require('qrcode-terminal');
|
|
39
39
|
require('node:module');
|
|
@@ -969,6 +969,9 @@ async function runGemini(opts) {
|
|
|
969
969
|
let unexpectedRuntimeStopRecovery = null;
|
|
970
970
|
let readyAlreadySent = false;
|
|
971
971
|
let currentHappyOrgTurn = null;
|
|
972
|
+
const assistantMessageEmitter = new sessionControl.BufferedAssistantStreamEmitter({
|
|
973
|
+
send: (payload) => session.sendAgentMessage("gemini", payload)
|
|
974
|
+
});
|
|
972
975
|
async function handleAbort() {
|
|
973
976
|
persistence.logger.debug("[Gemini] Abort requested - stopping current task");
|
|
974
977
|
if (!turnAbortedSent) {
|
|
@@ -980,7 +983,7 @@ async function runGemini(opts) {
|
|
|
980
983
|
}
|
|
981
984
|
reasoningProcessor.abort();
|
|
982
985
|
diffProcessor.reset();
|
|
983
|
-
|
|
986
|
+
assistantMessageEmitter.reset();
|
|
984
987
|
try {
|
|
985
988
|
abortController.abort();
|
|
986
989
|
messageQueue.reset();
|
|
@@ -1137,7 +1140,6 @@ async function runGemini(opts) {
|
|
|
1137
1140
|
let isResponseInProgress = false;
|
|
1138
1141
|
let hadToolCallInTurn = false;
|
|
1139
1142
|
let taskStartedSent = false;
|
|
1140
|
-
const assistantMessageStream = new persistence.AssistantMessageStream();
|
|
1141
1143
|
const resetTurnState = () => {
|
|
1142
1144
|
reasoningProcessor.abort();
|
|
1143
1145
|
diffProcessor.reset();
|
|
@@ -1148,7 +1150,7 @@ async function runGemini(opts) {
|
|
|
1148
1150
|
taskStartedSent = false;
|
|
1149
1151
|
turnAbortedSent = false;
|
|
1150
1152
|
currentHappyOrgTurn = null;
|
|
1151
|
-
|
|
1153
|
+
assistantMessageEmitter.reset();
|
|
1152
1154
|
thinking = false;
|
|
1153
1155
|
session.keepAlive(thinking, "remote");
|
|
1154
1156
|
};
|
|
@@ -1159,43 +1161,30 @@ async function runGemini(opts) {
|
|
|
1159
1161
|
if (!text.trim()) {
|
|
1160
1162
|
return false;
|
|
1161
1163
|
}
|
|
1162
|
-
if (!
|
|
1164
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1163
1165
|
currentAssistantStreamStartLength = accumulatedResponse.length - text.length;
|
|
1164
1166
|
}
|
|
1165
|
-
|
|
1166
|
-
session.sendAgentMessage("gemini", {
|
|
1167
|
-
type: "message",
|
|
1168
|
-
message: text,
|
|
1169
|
-
id: stream.messageId,
|
|
1170
|
-
...stream
|
|
1171
|
-
});
|
|
1172
|
-
return true;
|
|
1167
|
+
return assistantMessageEmitter.pushDelta(text);
|
|
1173
1168
|
};
|
|
1174
1169
|
const buildAssistantMessageCommit = (message) => {
|
|
1175
|
-
if (!
|
|
1170
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1176
1171
|
return {
|
|
1177
1172
|
type: "message",
|
|
1178
1173
|
message,
|
|
1179
1174
|
id: node_crypto.randomUUID()
|
|
1180
1175
|
};
|
|
1181
1176
|
}
|
|
1182
|
-
|
|
1183
|
-
return {
|
|
1184
|
-
type: "message",
|
|
1185
|
-
message: message.slice(currentAssistantStreamStartLength),
|
|
1186
|
-
id: stream.messageId,
|
|
1187
|
-
...stream
|
|
1188
|
-
};
|
|
1177
|
+
return assistantMessageEmitter.buildCommitPayload(message.slice(currentAssistantStreamStartLength));
|
|
1189
1178
|
};
|
|
1190
1179
|
const commitActiveAssistantMessageStream = () => {
|
|
1191
|
-
if (!
|
|
1180
|
+
if (!assistantMessageEmitter.hasActive()) {
|
|
1192
1181
|
return false;
|
|
1193
1182
|
}
|
|
1194
|
-
const
|
|
1195
|
-
if (!
|
|
1183
|
+
const message = accumulatedResponse.slice(currentAssistantStreamStartLength);
|
|
1184
|
+
if (!message.trim()) {
|
|
1196
1185
|
return false;
|
|
1197
1186
|
}
|
|
1198
|
-
|
|
1187
|
+
assistantMessageEmitter.commit(message);
|
|
1199
1188
|
currentAssistantStreamStartLength = accumulatedResponse.length;
|
|
1200
1189
|
return true;
|
|
1201
1190
|
};
|
|
@@ -1323,7 +1312,7 @@ Guide: https://goo.gle/gemini-cli-auth-docs#workspace-gca`;
|
|
|
1323
1312
|
type: "message",
|
|
1324
1313
|
message: `Error: ${errorMessage}`
|
|
1325
1314
|
});
|
|
1326
|
-
|
|
1315
|
+
assistantMessageEmitter.reset();
|
|
1327
1316
|
}
|
|
1328
1317
|
break;
|
|
1329
1318
|
case "tool-call":
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var persistence = require('./types-
|
|
3
|
+
var index = require('./index-Cd7d2BMe.cjs');
|
|
4
|
+
var persistence = require('./types-Be833t7e.cjs');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var RuntimeShell = require('./RuntimeShell-
|
|
6
|
+
var RuntimeShell = require('./RuntimeShell-CoXntnel.cjs');
|
|
7
7
|
require('axios');
|
|
8
8
|
require('node:events');
|
|
9
9
|
require('node:fs/promises');
|
|
@@ -2226,6 +2226,124 @@ async function finalizeHappyOrgTurnWithBusinessAck(opts) {
|
|
|
2226
2226
|
};
|
|
2227
2227
|
}
|
|
2228
2228
|
|
|
2229
|
+
const DEFAULT_FLUSH_DELAY_MS = 80;
|
|
2230
|
+
const DEFAULT_FLUSH_CHAR_THRESHOLD = 120;
|
|
2231
|
+
const BOUNDARY_PATTERN = /[\n.!?;:。!?;:]$/;
|
|
2232
|
+
class BufferedAssistantStreamEmitter {
|
|
2233
|
+
stream;
|
|
2234
|
+
send;
|
|
2235
|
+
flushDelayMs;
|
|
2236
|
+
flushCharThreshold;
|
|
2237
|
+
pendingDelta = "";
|
|
2238
|
+
accumulated = "";
|
|
2239
|
+
flushTimer = null;
|
|
2240
|
+
constructor(options) {
|
|
2241
|
+
this.stream = options.stream ?? new persistence.AssistantMessageStream();
|
|
2242
|
+
this.send = options.send;
|
|
2243
|
+
this.flushDelayMs = options.flushDelayMs ?? DEFAULT_FLUSH_DELAY_MS;
|
|
2244
|
+
this.flushCharThreshold = options.flushCharThreshold ?? DEFAULT_FLUSH_CHAR_THRESHOLD;
|
|
2245
|
+
}
|
|
2246
|
+
hasActive() {
|
|
2247
|
+
return this.stream.hasActive();
|
|
2248
|
+
}
|
|
2249
|
+
pushDelta(text) {
|
|
2250
|
+
if (!text) {
|
|
2251
|
+
return false;
|
|
2252
|
+
}
|
|
2253
|
+
const isFirstDelta = !this.stream.hasActive();
|
|
2254
|
+
this.accumulated += text;
|
|
2255
|
+
this.pendingDelta += text;
|
|
2256
|
+
if (!this.pendingDelta.trim()) {
|
|
2257
|
+
return false;
|
|
2258
|
+
}
|
|
2259
|
+
if (isFirstDelta || this.pendingDelta.length >= this.flushCharThreshold || BOUNDARY_PATTERN.test(this.pendingDelta)) {
|
|
2260
|
+
return this.flushDelta();
|
|
2261
|
+
}
|
|
2262
|
+
this.scheduleFlush();
|
|
2263
|
+
return false;
|
|
2264
|
+
}
|
|
2265
|
+
flushDelta() {
|
|
2266
|
+
this.clearFlushTimer();
|
|
2267
|
+
const message = this.pendingDelta;
|
|
2268
|
+
this.pendingDelta = "";
|
|
2269
|
+
if (!message.trim()) {
|
|
2270
|
+
return false;
|
|
2271
|
+
}
|
|
2272
|
+
const stream = this.stream.delta();
|
|
2273
|
+
this.send({
|
|
2274
|
+
type: "message",
|
|
2275
|
+
message,
|
|
2276
|
+
id: stream.messageId,
|
|
2277
|
+
...stream
|
|
2278
|
+
});
|
|
2279
|
+
return true;
|
|
2280
|
+
}
|
|
2281
|
+
commit(finalMessage) {
|
|
2282
|
+
const payload = this.buildCommitPayload(finalMessage);
|
|
2283
|
+
if (!payload) {
|
|
2284
|
+
return false;
|
|
2285
|
+
}
|
|
2286
|
+
this.send(payload);
|
|
2287
|
+
return true;
|
|
2288
|
+
}
|
|
2289
|
+
buildCommitPayload(finalMessage) {
|
|
2290
|
+
this.clearFlushTimer();
|
|
2291
|
+
this.pendingDelta = "";
|
|
2292
|
+
const message = finalMessage ?? this.accumulated;
|
|
2293
|
+
this.accumulated = "";
|
|
2294
|
+
if (!message.trim()) {
|
|
2295
|
+
this.stream.reset();
|
|
2296
|
+
return null;
|
|
2297
|
+
}
|
|
2298
|
+
const stream = this.stream.commit();
|
|
2299
|
+
return {
|
|
2300
|
+
type: "message",
|
|
2301
|
+
message,
|
|
2302
|
+
id: stream.messageId,
|
|
2303
|
+
...stream
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
abort() {
|
|
2307
|
+
this.clearFlushTimer();
|
|
2308
|
+
this.pendingDelta = "";
|
|
2309
|
+
this.accumulated = "";
|
|
2310
|
+
if (!this.stream.hasActive()) {
|
|
2311
|
+
return false;
|
|
2312
|
+
}
|
|
2313
|
+
const stream = this.stream.abort();
|
|
2314
|
+
this.send({
|
|
2315
|
+
type: "message",
|
|
2316
|
+
message: "",
|
|
2317
|
+
id: stream.messageId,
|
|
2318
|
+
...stream
|
|
2319
|
+
});
|
|
2320
|
+
return true;
|
|
2321
|
+
}
|
|
2322
|
+
reset() {
|
|
2323
|
+
this.clearFlushTimer();
|
|
2324
|
+
this.pendingDelta = "";
|
|
2325
|
+
this.accumulated = "";
|
|
2326
|
+
this.stream.reset();
|
|
2327
|
+
}
|
|
2328
|
+
scheduleFlush() {
|
|
2329
|
+
if (this.flushTimer) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
this.flushTimer = setTimeout(() => {
|
|
2333
|
+
this.flushTimer = null;
|
|
2334
|
+
this.flushDelta();
|
|
2335
|
+
}, this.flushDelayMs);
|
|
2336
|
+
this.flushTimer.unref?.();
|
|
2337
|
+
}
|
|
2338
|
+
clearFlushTimer() {
|
|
2339
|
+
if (!this.flushTimer) {
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
clearTimeout(this.flushTimer);
|
|
2343
|
+
this.flushTimer = null;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2229
2347
|
function supportsAgentStateUpdateEvents(sessionClient) {
|
|
2230
2348
|
return typeof sessionClient.once === "function" && typeof sessionClient.off === "function";
|
|
2231
2349
|
}
|
|
@@ -2265,6 +2383,7 @@ async function syncControlledByUserState(sessionClient, controlledByUser) {
|
|
|
2265
2383
|
}
|
|
2266
2384
|
|
|
2267
2385
|
exports.BasePermissionHandler = BasePermissionHandler;
|
|
2386
|
+
exports.BufferedAssistantStreamEmitter = BufferedAssistantStreamEmitter;
|
|
2268
2387
|
exports.INTERACTION_SUPERSEDED_ERROR = INTERACTION_SUPERSEDED_ERROR;
|
|
2269
2388
|
exports.INTERACTION_TIMED_OUT_ERROR = INTERACTION_TIMED_OUT_ERROR;
|
|
2270
2389
|
exports.MessageQueue2 = MessageQueue2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as initialMachineMetadata, q as resolveCanonicalToolNameV2 } from './index-
|
|
2
|
-
import { r as readSettings, H as HeadTailPreviewBuffer, l as logger,
|
|
1
|
+
import { o as initialMachineMetadata, q as resolveCanonicalToolNameV2 } from './index-B_Cm6MhB.mjs';
|
|
2
|
+
import { r as readSettings, H as HeadTailPreviewBuffer, l as logger, 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, n as normalizePreviewableArtifactTarget, k as AssistantMessageStream } from './types-CDuesyX_.mjs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { f as formatDisplayMessage, i as isTerminalReferenceOnlyPayload } from './RuntimeShell-
|
|
4
|
+
import { f as formatDisplayMessage, i as isTerminalReferenceOnlyPayload } from './RuntimeShell-DZhi4Zhd.mjs';
|
|
5
5
|
import 'axios';
|
|
6
6
|
import 'node:events';
|
|
7
7
|
import 'node:fs/promises';
|
|
@@ -2224,6 +2224,124 @@ async function finalizeHappyOrgTurnWithBusinessAck(opts) {
|
|
|
2224
2224
|
};
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
|
+
const DEFAULT_FLUSH_DELAY_MS = 80;
|
|
2228
|
+
const DEFAULT_FLUSH_CHAR_THRESHOLD = 120;
|
|
2229
|
+
const BOUNDARY_PATTERN = /[\n.!?;:。!?;:]$/;
|
|
2230
|
+
class BufferedAssistantStreamEmitter {
|
|
2231
|
+
stream;
|
|
2232
|
+
send;
|
|
2233
|
+
flushDelayMs;
|
|
2234
|
+
flushCharThreshold;
|
|
2235
|
+
pendingDelta = "";
|
|
2236
|
+
accumulated = "";
|
|
2237
|
+
flushTimer = null;
|
|
2238
|
+
constructor(options) {
|
|
2239
|
+
this.stream = options.stream ?? new AssistantMessageStream();
|
|
2240
|
+
this.send = options.send;
|
|
2241
|
+
this.flushDelayMs = options.flushDelayMs ?? DEFAULT_FLUSH_DELAY_MS;
|
|
2242
|
+
this.flushCharThreshold = options.flushCharThreshold ?? DEFAULT_FLUSH_CHAR_THRESHOLD;
|
|
2243
|
+
}
|
|
2244
|
+
hasActive() {
|
|
2245
|
+
return this.stream.hasActive();
|
|
2246
|
+
}
|
|
2247
|
+
pushDelta(text) {
|
|
2248
|
+
if (!text) {
|
|
2249
|
+
return false;
|
|
2250
|
+
}
|
|
2251
|
+
const isFirstDelta = !this.stream.hasActive();
|
|
2252
|
+
this.accumulated += text;
|
|
2253
|
+
this.pendingDelta += text;
|
|
2254
|
+
if (!this.pendingDelta.trim()) {
|
|
2255
|
+
return false;
|
|
2256
|
+
}
|
|
2257
|
+
if (isFirstDelta || this.pendingDelta.length >= this.flushCharThreshold || BOUNDARY_PATTERN.test(this.pendingDelta)) {
|
|
2258
|
+
return this.flushDelta();
|
|
2259
|
+
}
|
|
2260
|
+
this.scheduleFlush();
|
|
2261
|
+
return false;
|
|
2262
|
+
}
|
|
2263
|
+
flushDelta() {
|
|
2264
|
+
this.clearFlushTimer();
|
|
2265
|
+
const message = this.pendingDelta;
|
|
2266
|
+
this.pendingDelta = "";
|
|
2267
|
+
if (!message.trim()) {
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
2270
|
+
const stream = this.stream.delta();
|
|
2271
|
+
this.send({
|
|
2272
|
+
type: "message",
|
|
2273
|
+
message,
|
|
2274
|
+
id: stream.messageId,
|
|
2275
|
+
...stream
|
|
2276
|
+
});
|
|
2277
|
+
return true;
|
|
2278
|
+
}
|
|
2279
|
+
commit(finalMessage) {
|
|
2280
|
+
const payload = this.buildCommitPayload(finalMessage);
|
|
2281
|
+
if (!payload) {
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
this.send(payload);
|
|
2285
|
+
return true;
|
|
2286
|
+
}
|
|
2287
|
+
buildCommitPayload(finalMessage) {
|
|
2288
|
+
this.clearFlushTimer();
|
|
2289
|
+
this.pendingDelta = "";
|
|
2290
|
+
const message = finalMessage ?? this.accumulated;
|
|
2291
|
+
this.accumulated = "";
|
|
2292
|
+
if (!message.trim()) {
|
|
2293
|
+
this.stream.reset();
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
const stream = this.stream.commit();
|
|
2297
|
+
return {
|
|
2298
|
+
type: "message",
|
|
2299
|
+
message,
|
|
2300
|
+
id: stream.messageId,
|
|
2301
|
+
...stream
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
abort() {
|
|
2305
|
+
this.clearFlushTimer();
|
|
2306
|
+
this.pendingDelta = "";
|
|
2307
|
+
this.accumulated = "";
|
|
2308
|
+
if (!this.stream.hasActive()) {
|
|
2309
|
+
return false;
|
|
2310
|
+
}
|
|
2311
|
+
const stream = this.stream.abort();
|
|
2312
|
+
this.send({
|
|
2313
|
+
type: "message",
|
|
2314
|
+
message: "",
|
|
2315
|
+
id: stream.messageId,
|
|
2316
|
+
...stream
|
|
2317
|
+
});
|
|
2318
|
+
return true;
|
|
2319
|
+
}
|
|
2320
|
+
reset() {
|
|
2321
|
+
this.clearFlushTimer();
|
|
2322
|
+
this.pendingDelta = "";
|
|
2323
|
+
this.accumulated = "";
|
|
2324
|
+
this.stream.reset();
|
|
2325
|
+
}
|
|
2326
|
+
scheduleFlush() {
|
|
2327
|
+
if (this.flushTimer) {
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
this.flushTimer = setTimeout(() => {
|
|
2331
|
+
this.flushTimer = null;
|
|
2332
|
+
this.flushDelta();
|
|
2333
|
+
}, this.flushDelayMs);
|
|
2334
|
+
this.flushTimer.unref?.();
|
|
2335
|
+
}
|
|
2336
|
+
clearFlushTimer() {
|
|
2337
|
+
if (!this.flushTimer) {
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
clearTimeout(this.flushTimer);
|
|
2341
|
+
this.flushTimer = null;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2227
2345
|
function supportsAgentStateUpdateEvents(sessionClient) {
|
|
2228
2346
|
return typeof sessionClient.once === "function" && typeof sessionClient.off === "function";
|
|
2229
2347
|
}
|
|
@@ -2262,4 +2380,4 @@ async function syncControlledByUserState(sessionClient, controlledByUser) {
|
|
|
2262
2380
|
});
|
|
2263
2381
|
}
|
|
2264
2382
|
|
|
2265
|
-
export { BasePermissionHandler as B, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b,
|
|
2383
|
+
export { BasePermissionHandler as B, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b, BufferedAssistantStreamEmitter as c, resolveHappyOrgQueuedTurn as d, ensureManagedProviderMachine as e, buildHappyOrgTurnPrompt as f, getPendingInteractionTimeoutMs as g, finalizeHappyOrgTurnWithBusinessAck as h, forwardAgentMessageToProviderSession as i, renderTerminalOutputPreview as j, inferToolResultError as k, prepareTerminalOutputForForwarding as p, registerKillSessionHandler as r, syncControlledByUserState as s, waitForResponseCompleteWithAbort as w };
|