nolo-cli 0.105.0 → 0.106.1
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/{_executeModel-JXG5TLPE.js → _executeModel-EP6HAX3W.js} +38 -37
- package/{addContentAction-J3DLDV64.js → addContentAction-NZZNAVCB.js} +4 -4
- package/{addDialogAgentAction-PHIXJCF2.js → addDialogAgentAction-5HVGEIXI.js} +4 -4
- package/{agentDeleteCommand-2AWJGHXG.js → agentDeleteCommand-M25A6UGB.js} +45 -45
- package/{agentEmailCommands-VV5OSILE.js → agentEmailCommands-RUL4NL64.js} +46 -46
- package/{agentListCommands-OQMRBDWP.js → agentListCommands-KSPFKHFO.js} +23 -24
- package/{agentMachineCommands-3VLLR6RL.js → agentMachineCommands-IHBB6PHD.js} +20 -21
- package/{agentProviderCommands-XPJYZSCE.js → agentProviderCommands-ND4S2Q6Q.js} +1 -1
- package/{agentRecordCommands-GPIARVOW.js → agentRecordCommands-7OKIBN6H.js} +45 -45
- package/{agentRunCommand-LRJTZ7IM.js → agentRunCommand-GBKJTQQU.js} +45 -45
- package/{agentRuntimeLocal-PV6AZOEU.js → agentRuntimeLocal-E5HXZNXZ.js} +18 -19
- package/{agentSlice-6R3JKS6I.js → agentSlice-7T3ZLYET.js} +4 -4
- package/{appDeleteCommands-WEX73P5R.js → appDeleteCommands-TTJUYTQN.js} +21 -22
- package/{appDeployCommands-7BAXWA4M.js → appDeployCommands-65WYK2TQ.js} +21 -22
- package/{appDeployStatusCommands-EJ6A2U4X.js → appDeployStatusCommands-U4XESYYG.js} +21 -22
- package/{appGetCommands-SB355OEX.js → appGetCommands-VNHZZC4D.js} +21 -22
- package/{appListCommands-TSZDPIKJ.js → appListCommands-O667ZEU6.js} +21 -22
- package/{authCommand-5PB3YRVV.js → authCommand-SUHHTVHA.js} +8 -8
- package/{builtinSkillRegistry-SBBWTANC.js → builtinSkillRegistry-PUGT65WS.js} +5 -5
- package/{chunk-Z5NGE5DH.js → chunk-2NGKYC3L.js} +3 -3
- package/{chunk-S2NSK7AZ.js → chunk-3SXZ6SUC.js} +4 -4
- package/{chunk-NSBID7PR.js → chunk-3VKDWQMJ.js} +2 -2
- package/{chunk-QKTESDWK.js → chunk-4VDS344D.js} +3 -3
- package/{chunk-7KVZ5LDQ.js → chunk-5F7UKMLN.js} +8 -4
- package/{chunk-BB7LVBTS.js → chunk-6AIURTE7.js} +3 -3
- package/{chunk-HP57OUJO.js → chunk-7I25CBT5.js} +31 -5
- package/{chunk-NSAFG343.js → chunk-AM4G3LDJ.js} +59 -47
- package/{chunk-NTR4SD3P.js → chunk-AZB6HR4I.js} +13 -48
- package/{chunk-AFH5QC6R.js → chunk-BIH7KCDJ.js} +3 -3
- package/{chunk-UA324D4O.js → chunk-BPLIXNC6.js} +1 -1
- package/{chunk-YK5MHOWM.js → chunk-CEQ75WPL.js} +1 -1
- package/{chunk-K6U4NKFJ.js → chunk-DBKRC5O2.js} +1 -1
- package/{chunk-UWXDA7L5.js → chunk-DJ3JABG5.js} +22 -37
- package/{chunk-HYXABXCZ.js → chunk-DSXRVBTA.js} +98 -21
- package/{chunk-3Q7NEHAR.js → chunk-EBS4FKW4.js} +1 -1
- package/{chunk-ZBHR642M.js → chunk-EHGIEGLI.js} +161 -43
- package/{chunk-YVU4XVJD.js → chunk-FJKZSR5P.js} +1 -1
- package/{chunk-54VPQTOA.js → chunk-GMP3NBAA.js} +5 -7
- package/{chunk-3BXNTXYI.js → chunk-GU7DC2TD.js} +2 -1
- package/{chunk-FGSJ3YMD.js → chunk-HNA5KV37.js} +5 -5
- package/{chunk-CYSYR67N.js → chunk-I5YMDACN.js} +1 -1
- package/{chunk-WJ3B6FX6.js → chunk-IXH3HKY2.js} +0 -8
- package/{chunk-Y3PMXGLH.js → chunk-IYIXAIEB.js} +197 -92
- package/{chunk-RWX7AY7J.js → chunk-JWNBEIME.js} +1 -1
- package/{chunk-VVJ2ENLY.js → chunk-LGWABBTZ.js} +4 -4
- package/{chunk-QYUBY3OZ.js → chunk-LOPP5VT6.js} +1 -1
- package/{chunk-GSKPJIHY.js → chunk-LUBFABMJ.js} +2 -6
- package/{chunk-BNGW5ASC.js → chunk-LYLO5U3H.js} +15 -2
- package/{chunk-L5WOICCV.js → chunk-MJ3CRU77.js} +22 -6
- package/{chunk-AWVP7PPG.js → chunk-NTNKA5VL.js} +1 -1
- package/{chunk-EP7BWZ4B.js → chunk-OAXBDMT7.js} +1 -1
- package/{chunk-4DPP773Q.js → chunk-ODTBO4W6.js} +9 -6
- package/{chunk-B7APRSPS.js → chunk-OQ5IVGCV.js} +3 -3
- package/{chunk-EKPKW6RM.js → chunk-OYTWDOQV.js} +3 -3
- package/{chunk-P5GCTVGV.js → chunk-OZ2IIIRP.js} +2 -2
- package/{chunk-D2GQE6AF.js → chunk-PFLF4R4E.js} +1 -1
- package/{chunk-RILRSUGC.js → chunk-QDH32WF5.js} +1 -1
- package/{chunk-VCAQFMVN.js → chunk-QVAWUJAJ.js} +1 -1
- package/{chunk-27ONFIEY.js → chunk-SJ7CUF65.js} +2 -2
- package/{chunk-CNA27EMD.js → chunk-SYEBIZOF.js} +1 -1
- package/{chunk-ZSUDOTPL.js → chunk-TLKXNTQJ.js} +3 -3
- package/{chunk-A4SQRTZ6.js → chunk-TLYSGGPG.js} +1 -1
- package/chunk-UM7TA3K4.js +1008 -0
- package/{chunk-BZ7NPA6G.js → chunk-VBG7GWWR.js} +218 -6
- package/{chunk-DZ7R5V3Y.js → chunk-VBQGO5NX.js} +1 -1
- package/{chunk-44CU7CKA.js → chunk-VYKXIHRP.js} +181 -34
- package/chunk-VZLO4XJD.js +17 -0
- package/{chunk-IEJ5YDA4.js → chunk-WMWYWYK2.js} +2 -2
- package/{chunk-LWXE6IFU.js → chunk-XDQ7PHU3.js} +31 -196
- package/{chunk-AFSY3ZMB.js → chunk-XGOHDYM2.js} +1 -1
- package/{chunk-2WJ57RJA.js → chunk-XLWMNFBZ.js} +1 -1
- package/{chunk-3F424ASC.js → chunk-YFU5EELM.js} +1 -1
- package/{chunk-QMXJ5KDJ.js → chunk-YQFLBS6A.js} +13 -13
- package/{chunk-CFHWVEUJ.js → chunk-ZVGXD7UJ.js} +2 -2
- package/{chunk-4WMMIL66.js → chunk-ZYM73IHG.js} +3 -2
- package/{commandRegistry-QU62WJQX.js → commandRegistry-6QIAUQDS.js} +49 -49
- package/{contentThunks-VGV3JJVB.js → contentThunks-5DDMUQ7B.js} +17 -16
- package/{createAgentAutomationAction-ZNVLI4WV.js → createAgentAutomationAction-NQ6AZM42.js} +17 -16
- package/{createDialogAction-TTUA46DT.js → createDialogAction-QZ6X4A7O.js} +20 -19
- package/{createPageAction-KUFSC5XW.js → createPageAction-NCGEJBVK.js} +17 -16
- package/{dbSlice-MYEETO73.js → dbSlice-RCZ7NRAF.js} +3 -3
- package/{dialogCommands-DRDPEOTL.js → dialogCommands-OGQLEF63.js} +21 -22
- package/{dialogSlice-V2SVSTIV.js → dialogSlice-GIKNUHNW.js} +30 -17
- package/{docCreateCommands-M26CFDDQ.js → docCreateCommands-RW6LNYT6.js} +20 -21
- package/{docDeleteCommands-LRZHCKVX.js → docDeleteCommands-Z742TRNY.js} +21 -22
- package/{docReadCommands-6QJSISHK.js → docReadCommands-5DIGA42Y.js} +20 -21
- package/{docStore-4RWAFNDM.js → docStore-6GUOZH52.js} +4 -4
- package/{docUpdateCommands-W4KU4U5T.js → docUpdateCommands-ZFZ2QEVK.js} +20 -21
- package/{getPricing-NMMFT3YI.js → getPricing-QVSNUFZ6.js} +3 -3
- package/{handleSendMessageAction-VEWLGB5Z.js → handleSendMessageAction-B2VXOLMM.js} +16 -15
- package/index.js +3 -3
- package/{machineCommands-AEHHCJEW.js → machineCommands-AI3N7JHQ.js} +44 -44
- package/{machineWsRunDispatch-MY2KHS36.js → machineWsRunDispatch-RPF2D6VV.js} +44 -44
- package/{memberThunks-EE6TI3TV.js → memberThunks-YICJI4IS.js} +4 -4
- package/{models-ZPU5EDF4.js → models-FTNFVO3D.js} +2 -2
- package/package.json +1 -1
- package/{providerPresetApply-TEBH7FDX.js → providerPresetApply-OJJXQ7NM.js} +6 -6
- package/{providerRegistry-CBJLNCET.js → providerRegistry-DXFBDCGQ.js} +6 -6
- package/{read-PJIT2YEJ.js → read-XMBM52Y4.js} +2 -2
- package/{readDocTool-DRSXHGNL.js → readDocTool-LAQHKCVT.js} +1 -1
- package/{readlineWorkspace-7Q6MITLV.js → readlineWorkspace-EPUCVZ73.js} +48 -48
- package/{removeDialogAgentAction-IN4WUKJJ.js → removeDialogAgentAction-HDUI2MU3.js} +5 -5
- package/{runAgentClientLoop-H2JALUVD.js → runAgentClientLoop-OXQMDGAN.js} +36 -35
- package/{setDialogExtraReferencesAction-VDRF7LPK.js → setDialogExtraReferencesAction-ADBVOP4O.js} +5 -5
- package/{setPrimaryDialogAgentAction-RO6LIWJ4.js → setPrimaryDialogAgentAction-PXVXQJ62.js} +5 -5
- package/{settingThunks-3OPOLOIA.js → settingThunks-G2MJRKUE.js} +6 -6
- package/{spaceCommands-UBLL5EF2.js → spaceCommands-Z662QYY6.js} +20 -21
- package/{streamAgentChatTurn-FFJWW3FD.js → streamAgentChatTurn-YJYEJHP7.js} +40 -46
- package/{switchDialogAgentAction-MVF2JNE7.js → switchDialogAgentAction-Z3RZACGF.js} +4 -4
- package/{toolApiClient-EJT6TMFG.js → toolApiClient-AD7CXTA4.js} +3 -2
- package/{tools-AZRYLYNK.js → tools-GHI3WBEI.js} +32 -31
- package/{tuiSummaryLlmCaller-7S5HJ3MT.js → tuiSummaryLlmCaller-WTC6GCQC.js} +11 -12
- package/{updateDialogTitleAction-5WXTRUJM.js → updateDialogTitleAction-GJCNWTPY.js} +17 -16
- package/chunk-M7VLQGQP.js +0 -405
- package/chunk-NKWIS6G2.js +0 -442
|
@@ -10,6 +10,114 @@ var GLOBAL_DIALOG_RUNTIME_KEY = "__global__";
|
|
|
10
10
|
|
|
11
11
|
// packages/chat/dialog/dialogRuntimeStore.ts
|
|
12
12
|
var import_react = __toESM(require_react());
|
|
13
|
+
|
|
14
|
+
// packages/app/utils/localStorageState.ts
|
|
15
|
+
function readStorageJSON(key) {
|
|
16
|
+
if (typeof window === "undefined") return null;
|
|
17
|
+
try {
|
|
18
|
+
const raw = window.localStorage.getItem(key);
|
|
19
|
+
if (!raw) return null;
|
|
20
|
+
return JSON.parse(raw);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function writeStorageJSON(key, value) {
|
|
26
|
+
if (typeof window === "undefined") return;
|
|
27
|
+
try {
|
|
28
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// packages/chat/dialog/mediaJobPendingPersistence.ts
|
|
34
|
+
var MEDIA_JOB_PENDING_STORAGE_KEY = "nolo:chat:media-job-pending:v1";
|
|
35
|
+
var MEDIA_JOB_PENDING_KEEP_PER_DIALOG = 10;
|
|
36
|
+
var currentActorId = null;
|
|
37
|
+
function setMediaJobPendingActor(actorId) {
|
|
38
|
+
currentActorId = actorId && actorId.length > 0 ? actorId : null;
|
|
39
|
+
}
|
|
40
|
+
function getMediaJobPendingActor() {
|
|
41
|
+
return currentActorId;
|
|
42
|
+
}
|
|
43
|
+
var actorKey = () => `@${currentActorId ?? "anon"}`;
|
|
44
|
+
var bucketKeyOf = (dialogKey) => dialogKey ?? GLOBAL_DIALOG_RUNTIME_KEY;
|
|
45
|
+
var isEntry = (value) => {
|
|
46
|
+
if (!value || typeof value !== "object") return false;
|
|
47
|
+
const entry = value;
|
|
48
|
+
return typeof entry.id === "string" && entry.id.length > 0 && typeof entry.name === "string";
|
|
49
|
+
};
|
|
50
|
+
var readAllActors = () => {
|
|
51
|
+
const raw = readStorageJSON(MEDIA_JOB_PENDING_STORAGE_KEY);
|
|
52
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
53
|
+
return raw;
|
|
54
|
+
};
|
|
55
|
+
var writeActorMap = (map) => {
|
|
56
|
+
const all = readAllActors();
|
|
57
|
+
all[actorKey()] = map;
|
|
58
|
+
writeStorageJSON(MEDIA_JOB_PENDING_STORAGE_KEY, all);
|
|
59
|
+
};
|
|
60
|
+
function readMediaJobPendingMap() {
|
|
61
|
+
const scoped = readAllActors()[actorKey()];
|
|
62
|
+
if (!scoped || typeof scoped !== "object" || Array.isArray(scoped)) return {};
|
|
63
|
+
const map = {};
|
|
64
|
+
for (const [dialogKey, entries] of Object.entries(scoped)) {
|
|
65
|
+
if (!Array.isArray(entries)) continue;
|
|
66
|
+
const valid = entries.filter(isEntry).map((entry) => ({
|
|
67
|
+
id: entry.id,
|
|
68
|
+
name: entry.name,
|
|
69
|
+
fileKey: typeof entry.fileKey === "string" ? entry.fileKey : void 0,
|
|
70
|
+
mimeType: typeof entry.mimeType === "string" ? entry.mimeType : void 0,
|
|
71
|
+
size: typeof entry.size === "number" ? entry.size : void 0,
|
|
72
|
+
durationSec: typeof entry.durationSec === "number" ? entry.durationSec : void 0,
|
|
73
|
+
savedAt: typeof entry.savedAt === "number" && Number.isFinite(entry.savedAt) ? entry.savedAt : 0
|
|
74
|
+
}));
|
|
75
|
+
if (valid.length) map[dialogKey] = valid;
|
|
76
|
+
}
|
|
77
|
+
return map;
|
|
78
|
+
}
|
|
79
|
+
function upsertMediaJobPendingEntry(entry) {
|
|
80
|
+
const map = readMediaJobPendingMap();
|
|
81
|
+
const dialogKey = bucketKeyOf(entry.dialogKey);
|
|
82
|
+
const kept = (map[dialogKey] ?? []).filter((item) => item.id !== entry.id);
|
|
83
|
+
kept.push({ ...entry, savedAt: Date.now() });
|
|
84
|
+
map[dialogKey] = kept.slice(-MEDIA_JOB_PENDING_KEEP_PER_DIALOG);
|
|
85
|
+
writeActorMap(map);
|
|
86
|
+
}
|
|
87
|
+
function removeMediaJobPendingEntryById(id) {
|
|
88
|
+
const map = readMediaJobPendingMap();
|
|
89
|
+
let changed = false;
|
|
90
|
+
for (const [dialogKey, entries] of Object.entries(map)) {
|
|
91
|
+
const kept = entries.filter((entry) => entry.id !== id);
|
|
92
|
+
if (kept.length !== entries.length) {
|
|
93
|
+
changed = true;
|
|
94
|
+
if (kept.length) map[dialogKey] = kept;
|
|
95
|
+
else delete map[dialogKey];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (changed) writeActorMap(map);
|
|
99
|
+
}
|
|
100
|
+
function clearMediaJobPendingEntries(payload) {
|
|
101
|
+
if (payload?.all) {
|
|
102
|
+
writeStorageJSON(MEDIA_JOB_PENDING_STORAGE_KEY, {});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const dialogKey = bucketKeyOf(payload?.dialogKey);
|
|
106
|
+
const map = readMediaJobPendingMap();
|
|
107
|
+
if (!(dialogKey in map)) return;
|
|
108
|
+
delete map[dialogKey];
|
|
109
|
+
writeActorMap(map);
|
|
110
|
+
}
|
|
111
|
+
function pruneMediaJobPendingEntries(dialogKey, keep = MEDIA_JOB_PENDING_KEEP_PER_DIALOG) {
|
|
112
|
+
const key = bucketKeyOf(dialogKey);
|
|
113
|
+
const map = readMediaJobPendingMap();
|
|
114
|
+
const entries = map[key];
|
|
115
|
+
if (!entries || entries.length <= keep) return;
|
|
116
|
+
map[key] = entries.slice(-keep);
|
|
117
|
+
writeActorMap(map);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// packages/chat/dialog/dialogRuntimeStore.ts
|
|
13
121
|
var createEmptyTokenStats = () => ({
|
|
14
122
|
inputTokens: 0,
|
|
15
123
|
outputTokens: 0,
|
|
@@ -23,7 +131,8 @@ var createEmptyDialogRuntimeState = () => ({
|
|
|
23
131
|
loopStopReason: null,
|
|
24
132
|
turnPhase: null,
|
|
25
133
|
turnPhaseTurnId: null,
|
|
26
|
-
pendingUserInputQueue: []
|
|
134
|
+
pendingUserInputQueue: [],
|
|
135
|
+
recoveredForegroundTurn: null
|
|
27
136
|
});
|
|
28
137
|
var activeDialogKey = null;
|
|
29
138
|
var configError = null;
|
|
@@ -78,21 +187,49 @@ function addPendingFile(payload) {
|
|
|
78
187
|
const targetRuntimeKey = payload.targetDialogKey ?? payload.runtimeDialogKey ?? (payload.type === "dialog" ? activeDialogKey : payload.dialogKey);
|
|
79
188
|
const runtime = ensureDialogRuntimeState(targetRuntimeKey);
|
|
80
189
|
if (!runtime.pendingFiles.some((f) => f.id === payload.id)) {
|
|
81
|
-
runtime.pendingFiles.
|
|
190
|
+
runtime.pendingFiles = [...runtime.pendingFiles, payload];
|
|
191
|
+
if (payload.type === "media_job") {
|
|
192
|
+
upsertMediaJobPendingEntry({
|
|
193
|
+
id: payload.id,
|
|
194
|
+
name: payload.name,
|
|
195
|
+
fileKey: payload.fileKey,
|
|
196
|
+
mimeType: payload.mimeType,
|
|
197
|
+
size: payload.size,
|
|
198
|
+
durationSec: payload.durationSec,
|
|
199
|
+
// 与写入侧 bucket 推导严格同源:`dialogKey || GLOBAL_DIALOG_RUNTIME_KEY`
|
|
200
|
+
// (useMessageInputFiles 的 effectiveDialogKey 同规则)。不依赖
|
|
201
|
+
// activeDialogKey 隐式回退,保证恢复时读到的就是当初写入的 bucket。
|
|
202
|
+
dialogKey: payload.dialogKey ?? GLOBAL_DIALOG_RUNTIME_KEY
|
|
203
|
+
});
|
|
204
|
+
}
|
|
82
205
|
notify();
|
|
83
206
|
}
|
|
84
207
|
return action("dialogRuntime/addPendingFile", payload);
|
|
85
208
|
}
|
|
86
209
|
function removePendingFile(fileId) {
|
|
87
210
|
const runtime = ensureDialogRuntimeState();
|
|
88
|
-
|
|
211
|
+
let fileToRemove = runtime.pendingFiles.find((f) => f.id === fileId);
|
|
212
|
+
let runtimeHoldingFile = runtime;
|
|
213
|
+
if (!fileToRemove) {
|
|
214
|
+
for (const candidate of Object.values(runtimeByKey)) {
|
|
215
|
+
const found = candidate.pendingFiles.find((f) => f.id === fileId);
|
|
216
|
+
if (found) {
|
|
217
|
+
fileToRemove = found;
|
|
218
|
+
runtimeHoldingFile = candidate;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
89
223
|
if (fileToRemove) {
|
|
90
224
|
if (fileToRemove.pageKey) {
|
|
91
|
-
delete
|
|
225
|
+
delete runtimeHoldingFile.pendingRawData[fileToRemove.pageKey];
|
|
92
226
|
}
|
|
93
|
-
|
|
227
|
+
runtimeHoldingFile.pendingFiles = runtimeHoldingFile.pendingFiles.filter(
|
|
94
228
|
(file) => file.id !== fileId
|
|
95
229
|
);
|
|
230
|
+
if (fileToRemove.type === "media_job") {
|
|
231
|
+
removeMediaJobPendingEntryById(fileToRemove.id);
|
|
232
|
+
}
|
|
96
233
|
notify();
|
|
97
234
|
}
|
|
98
235
|
return action("dialogRuntime/removePendingFile", fileId);
|
|
@@ -103,10 +240,14 @@ function clearPendingAttachments(payload) {
|
|
|
103
240
|
runtime2.pendingFiles = [];
|
|
104
241
|
runtime2.pendingRawData = {};
|
|
105
242
|
});
|
|
243
|
+
clearMediaJobPendingEntries({ all: true });
|
|
106
244
|
notify();
|
|
107
245
|
return action("dialogRuntime/clearPendingAttachments", payload);
|
|
108
246
|
}
|
|
109
247
|
const runtime = ensureDialogRuntimeState(payload?.dialogKey);
|
|
248
|
+
runtime.pendingFiles.forEach((file) => {
|
|
249
|
+
if (file.type === "media_job") removeMediaJobPendingEntryById(file.id);
|
|
250
|
+
});
|
|
110
251
|
runtime.pendingFiles = [];
|
|
111
252
|
runtime.pendingRawData = {};
|
|
112
253
|
notify();
|
|
@@ -118,6 +259,12 @@ function setLoopStopReason(payload) {
|
|
|
118
259
|
notify();
|
|
119
260
|
return action("dialogRuntime/setLoopStopReason", payload);
|
|
120
261
|
}
|
|
262
|
+
function setRecoveredForegroundTurn(payload) {
|
|
263
|
+
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
264
|
+
runtime.recoveredForegroundTurn = payload.status;
|
|
265
|
+
notify();
|
|
266
|
+
return action("dialogRuntime/setRecoveredForegroundTurn", payload);
|
|
267
|
+
}
|
|
121
268
|
function claimDialogTurnPhase(payload) {
|
|
122
269
|
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
123
270
|
runtime.turnPhaseTurnId = payload.turnId;
|
|
@@ -139,10 +286,62 @@ function clearDialogTurnPhase(payload = {}) {
|
|
|
139
286
|
return setDialogTurnPhase({ phase: null, dialogKey: payload.dialogKey, turnId: payload.turnId });
|
|
140
287
|
}
|
|
141
288
|
function clearDialogRuntimeState(payload) {
|
|
289
|
+
const runtime = runtimeByKey[payload.dialogKey];
|
|
290
|
+
runtime?.pendingFiles.forEach((file) => {
|
|
291
|
+
if (file.type === "media_job") removeMediaJobPendingEntryById(file.id);
|
|
292
|
+
});
|
|
142
293
|
delete runtimeByKey[payload.dialogKey];
|
|
143
294
|
notify();
|
|
144
295
|
return action("dialogRuntime/clearDialogRuntimeState", payload);
|
|
145
296
|
}
|
|
297
|
+
function restoreMediaJobPendingFiles(dialogKey) {
|
|
298
|
+
const runtimeKey = resolveDialogRuntimeKey(dialogKey);
|
|
299
|
+
const entries = (readMediaJobPendingMap()[runtimeKey] ?? []).slice(-MEDIA_JOB_PENDING_KEEP_PER_DIALOG);
|
|
300
|
+
if (!entries.length) return 0;
|
|
301
|
+
const runtime = ensureDialogRuntimeState(runtimeKey);
|
|
302
|
+
const existingIds = new Set(runtime.pendingFiles.map((file) => file.id));
|
|
303
|
+
let restored = 0;
|
|
304
|
+
for (const entry of entries) {
|
|
305
|
+
if (existingIds.has(entry.id)) continue;
|
|
306
|
+
addPendingFile({
|
|
307
|
+
id: entry.id,
|
|
308
|
+
name: entry.name,
|
|
309
|
+
type: "media_job",
|
|
310
|
+
fileKey: entry.fileKey,
|
|
311
|
+
mimeType: entry.mimeType,
|
|
312
|
+
size: entry.size,
|
|
313
|
+
durationSec: entry.durationSec,
|
|
314
|
+
trackingId: entry.id,
|
|
315
|
+
dialogKey: runtimeKey
|
|
316
|
+
});
|
|
317
|
+
restored += 1;
|
|
318
|
+
}
|
|
319
|
+
pruneMediaJobPendingEntries(runtimeKey);
|
|
320
|
+
return restored;
|
|
321
|
+
}
|
|
322
|
+
var MEDIA_NOTE_PAGE_KEY_PREFIX = "media-note:";
|
|
323
|
+
var isMediaNotePageReference = (pageKey) => typeof pageKey === "string" && pageKey.startsWith(MEDIA_NOTE_PAGE_KEY_PREFIX);
|
|
324
|
+
var getMediaJobRuntimeActor = () => getMediaJobPendingActor();
|
|
325
|
+
function setMediaJobRuntimeActor(actorId) {
|
|
326
|
+
const next = actorId && actorId.length ? actorId : null;
|
|
327
|
+
if (getMediaJobPendingActor() === next) return;
|
|
328
|
+
setMediaJobPendingActor(next);
|
|
329
|
+
for (const key of Object.keys(runtimeByKey)) {
|
|
330
|
+
const runtime = runtimeByKey[key];
|
|
331
|
+
const kept = runtime.pendingFiles.filter(
|
|
332
|
+
(f) => f.type !== "media_job" && !isMediaNotePageReference(f.pageKey)
|
|
333
|
+
);
|
|
334
|
+
if (kept.length !== runtime.pendingFiles.length) {
|
|
335
|
+
runtime.pendingFiles = kept;
|
|
336
|
+
}
|
|
337
|
+
for (const pageKey of Object.keys(runtime.pendingRawData)) {
|
|
338
|
+
if (isMediaNotePageReference(pageKey)) {
|
|
339
|
+
delete runtime.pendingRawData[pageKey];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
notify();
|
|
344
|
+
}
|
|
146
345
|
function addActiveController(payload) {
|
|
147
346
|
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
148
347
|
runtime.activeControllers[payload.messageId] = payload.controller;
|
|
@@ -205,7 +404,7 @@ function tokenUsageLiveUpdate(payload) {
|
|
|
205
404
|
}
|
|
206
405
|
function addPageReferenceToRuntime(payload) {
|
|
207
406
|
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
208
|
-
runtime.pendingFiles.
|
|
407
|
+
runtime.pendingFiles = [...runtime.pendingFiles, payload.reference];
|
|
209
408
|
if (payload.rawData?.pageKey) {
|
|
210
409
|
runtime.pendingRawData[payload.rawData.pageKey] = payload.rawData;
|
|
211
410
|
}
|
|
@@ -285,6 +484,9 @@ function getLoopStopReason(dialogKey) {
|
|
|
285
484
|
function getDialogTurnPhase(dialogKey) {
|
|
286
485
|
return getDialogRuntimeState(dialogKey).turnPhase;
|
|
287
486
|
}
|
|
487
|
+
function getRecoveredForegroundTurn(dialogKey) {
|
|
488
|
+
return getDialogRuntimeState(dialogKey).recoveredForegroundTurn;
|
|
489
|
+
}
|
|
288
490
|
var selectDialogRuntimeByKey = (_state, dialogKey) => getDialogRuntimeState(dialogKey);
|
|
289
491
|
var selectPendingFiles = (_state, dialogKey) => getPendingFiles(dialogKey);
|
|
290
492
|
var selectActiveControllers = (_state, dialogKey) => getActiveControllers(dialogKey);
|
|
@@ -324,6 +526,10 @@ function useDialogTurnPhase(dialogKey) {
|
|
|
324
526
|
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
325
527
|
return getDialogTurnPhase(dialogKey);
|
|
326
528
|
}
|
|
529
|
+
function useRecoveredForegroundTurn(dialogKey) {
|
|
530
|
+
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
531
|
+
return getRecoveredForegroundTurn(dialogKey);
|
|
532
|
+
}
|
|
327
533
|
function useDialogRuntimeTokens(dialogKey) {
|
|
328
534
|
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
329
535
|
return getDialogRuntimeTokens(dialogKey);
|
|
@@ -347,10 +553,14 @@ export {
|
|
|
347
553
|
removePendingFile,
|
|
348
554
|
clearPendingAttachments,
|
|
349
555
|
setLoopStopReason,
|
|
556
|
+
setRecoveredForegroundTurn,
|
|
350
557
|
claimDialogTurnPhase,
|
|
351
558
|
setDialogTurnPhase,
|
|
352
559
|
clearDialogTurnPhase,
|
|
353
560
|
clearDialogRuntimeState,
|
|
561
|
+
restoreMediaJobPendingFiles,
|
|
562
|
+
getMediaJobRuntimeActor,
|
|
563
|
+
setMediaJobRuntimeActor,
|
|
354
564
|
addActiveController,
|
|
355
565
|
removeActiveController,
|
|
356
566
|
clearActiveControllers,
|
|
@@ -364,6 +574,7 @@ export {
|
|
|
364
574
|
deleteDialogRuntime,
|
|
365
575
|
abortActiveControllers,
|
|
366
576
|
getDialogRuntimeTokens,
|
|
577
|
+
getRecoveredForegroundTurn,
|
|
367
578
|
selectDialogRuntimeByKey,
|
|
368
579
|
selectPendingFiles,
|
|
369
580
|
selectActiveControllers,
|
|
@@ -379,6 +590,7 @@ export {
|
|
|
379
590
|
usePendingUserInputQueue,
|
|
380
591
|
useLoopStopReason,
|
|
381
592
|
useDialogTurnPhase,
|
|
593
|
+
useRecoveredForegroundTurn,
|
|
382
594
|
useDialogRuntimeTokens,
|
|
383
595
|
useCurrentDialogKey,
|
|
384
596
|
useDialogConfigError
|