nolo-cli 0.240.0-alpha.3 → 0.242.0-alpha.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/README.md +3 -5
- package/{_executeModel-5NA4USGG.js → _executeModel-IZ2MCXHO.js} +77 -77
- package/{action-X75O3XPH.js → action-VDEW6WLI.js} +9 -9
- package/{addContentAction-GVC77QSN.js → addContentAction-7YVXHIPQ.js} +14 -14
- package/{addDialogAgentAction-KKDVAMW3.js → addDialogAgentAction-BX7B47HF.js} +17 -17
- package/{agentDeleteCommand-2RFGKFAB.js → agentDeleteCommand-N7ELXPLD.js} +107 -108
- package/{agentEmailCommands-GQCQKKOR.js → agentEmailCommands-OFS477PV.js} +110 -111
- package/{agentListCommands-HSGLDPDQ.js → agentListCommands-IQQHJSXP.js} +202 -164
- package/{agentMachineCommands-BISF6PVV.js → agentMachineCommands-NS65BEW7.js} +52 -49
- package/{agentProviderCommands-O3Q25PKU.js → agentProviderCommands-SS6M6VGY.js} +2 -2
- package/{agentPullCommand-G6U2LHMW.js → agentPullCommand-QQQZSC6S.js} +1 -1
- package/{agentRecordCommands-AOXPGYAJ.js → agentRecordCommands-4VE7CNLC.js} +103 -104
- package/{agentRunCommand-AFAIP7U7.js → agentRunCommand-2MUXHKNW.js} +109 -108
- package/{agentRunControl-VBL7UFSG.js → agentRunControl-55GL6Q3M.js} +11 -9
- package/{agentRuntimeLocal-T7BX2WGL.js → agentRuntimeLocal-5DB2P4MU.js} +51 -43
- package/{agentSlice-XJNKE3PG.js → agentSlice-5VTAFG43.js} +14 -14
- package/{appDeleteCommands-LURUSPY7.js → appDeleteCommands-EDKUPHJM.js} +52 -49
- package/{appDeployCommands-SMEW4AK2.js → appDeployCommands-JO74GW4L.js} +52 -49
- package/{appDeployStatusCommands-VYPJTBJK.js → appDeployStatusCommands-U77ZUHX7.js} +52 -49
- package/{appGetCommands-N4NI5GGJ.js → appGetCommands-QCMHBYPX.js} +52 -49
- package/{appListCommands-5C6ONN3Z.js → appListCommands-ZQJYEXI6.js} +52 -49
- package/{authCommand-4CVBDADE.js → authCommand-W4KXRZLI.js} +23 -19
- package/{authCommands-EHU2BHOX.js → authCommands-6AUYO65N.js} +10 -6
- package/{builtinSkillRegistry-AYWYQVA4.js → builtinSkillRegistry-GHE3RD3V.js} +6 -6
- package/{chromeCommands-G5UDKVSV.js → chromeCommands-S7AW3AOD.js} +383 -6
- package/{chromeOpsCommands-CSDG2HYN.js → chromeOpsCommands-TBPM6MR4.js} +1 -1
- package/{chunk-7TTMMOKH.js → chunk-247AAJRK.js} +1 -1
- package/{chunk-4X5AVCM7.js → chunk-2BSLGODA.js} +258 -23
- package/{chunk-P3IZUMIC.js → chunk-2N4UBHUU.js} +4 -4
- package/{chunk-A74QP4FI.js → chunk-2T5BHLID.js} +572 -208
- package/{chunk-H7ZYKHAZ.js → chunk-3OQFXODL.js} +102 -31
- package/{chunk-BIABIPGW.js → chunk-3ORFJP2Z.js} +1 -1
- package/{chunk-3FBAVU2Y.js → chunk-3UNAGTBW.js} +19 -84
- package/{chunk-DNZ4JJ7C.js → chunk-4F7SWSWO.js} +19 -6
- package/{chunk-2X7WFDT6.js → chunk-4FE3IWRE.js} +1 -1
- package/{chunk-N2JROHD3.js → chunk-4UK6UBXF.js} +3 -3
- package/{chunk-XS5A3EKX.js → chunk-4YFC3DWW.js} +75 -1
- package/chunk-53W5BXLN.js +340 -0
- package/{chunk-E5KJOZWY.js → chunk-5GRWWUB4.js} +3 -3
- package/{chunk-HCNOO374.js → chunk-6326DRQY.js} +1 -1
- package/{chunk-RM4UMFY4.js → chunk-6MQWGA5F.js} +10 -10
- package/{chunk-TEMLHVGX.js → chunk-6MX6S6TE.js} +3 -3
- package/{chunk-6WOLPIPY.js → chunk-6RSNVJGO.js} +2 -102
- package/{chunk-Y5OWZQMJ.js → chunk-6S6CZUXK.js} +19 -19
- package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-FZKA3XFA.js → chunk-6XLWUNZB.js} +27 -27
- package/{chunk-62HXNQVV.js → chunk-776CXKMX.js} +1 -1
- package/{chunk-MYPKBJJO.js → chunk-7AWKDRXG.js} +2 -2
- package/{chunk-GDUC4VS2.js → chunk-7GTXPS3D.js} +10 -10
- package/{chunk-Z2WZAE4P.js → chunk-7HUHOCIY.js} +36 -30
- package/{chunk-PWTNI4N7.js → chunk-ANUP75N2.js} +22 -0
- package/{chunk-ULLHVDTZ.js → chunk-BH7CEVOH.js} +4 -4
- package/{chunk-A3LUWRQK.js → chunk-C4KX626C.js} +5 -5
- package/chunk-C5A54QS7.js +108 -0
- package/{chunk-DXW5WDHZ.js → chunk-CHYYSFFM.js} +6 -6
- package/{chunk-O6IPRAVV.js → chunk-CJTB3OYB.js} +2 -2
- package/{chunk-AVJDELEA.js → chunk-DLT2DN4M.js} +1 -1
- package/{chunk-LKA64WH4.js → chunk-DMPZMYH4.js} +37 -1
- package/{chunk-MM73SP4K.js → chunk-DOK7GDRU.js} +1 -1
- package/{chunk-VREG6ANQ.js → chunk-DPAIQLAL.js} +16 -16
- package/{chunk-ANJRDS6U.js → chunk-EKXPHL7M.js} +3 -3
- package/{chunk-TWTJV35S.js → chunk-ENYTIRIO.js} +3 -3
- package/{chunk-PGKA77TZ.js → chunk-ER3P6MBT.js} +170 -107
- package/{chunk-EEOOBRA7.js → chunk-F4MCAOWN.js} +2 -2
- package/{chunk-7NIBQ4HY.js → chunk-FDZ2GBWO.js} +30 -2
- package/{chunk-VSRISJXZ.js → chunk-GAHJLSDO.js} +1 -1
- package/{chunk-U3G7RRXJ.js → chunk-GES5GIAU.js} +8 -8
- package/{chunk-4IQVE43Z.js → chunk-HQVNO7FH.js} +22 -22
- package/{chunk-DVYAFH2Q.js → chunk-HSWEFHFS.js} +1 -1
- package/{chunk-MECDGHLK.js → chunk-IIG3TT73.js} +43 -6
- package/{chunk-YGCOJNFZ.js → chunk-IZJFTY4R.js} +3 -3
- package/{chunk-BXSMFPTG.js → chunk-J25ESVUW.js} +10 -10
- package/{chunk-CVJRVBJL.js → chunk-J2XZZXIH.js} +4 -4
- package/{chunk-3EMIEC27.js → chunk-JVJ53XCH.js} +1 -1
- package/{chunk-AH5R7BYW.js → chunk-KC2QVCI7.js} +6 -6
- package/{chunk-MYOSN6BT.js → chunk-KF2DWSAH.js} +34 -13
- package/chunk-KK3FCYZM.js +647 -0
- package/{chunk-PRMEU7BT.js → chunk-KLD7K5FD.js} +7 -7
- package/{chunk-7AJRJGSQ.js → chunk-KMW5CRRM.js} +801 -381
- package/{chunk-Y2MF4DCJ.js → chunk-LELADM5Q.js} +1 -1
- package/{chunk-RTHFJZ6M.js → chunk-LMFMV5UC.js} +2 -2
- package/{chunk-2574ANSV.js → chunk-LZOOUQAZ.js} +4 -4
- package/{chunk-HOM6LTEW.js → chunk-M5EA44QU.js} +6 -6
- package/{chunk-IUMS6F53.js → chunk-MEDPR36J.js} +9 -5
- package/{chunk-6D25V6CB.js → chunk-MFXJY44K.js} +4 -4
- package/chunk-MVOZ22RZ.js +26 -0
- package/{chunk-CBUZ6DKA.js → chunk-N6EN3HK3.js} +1 -1
- package/{chunk-VS276URX.js → chunk-NEG5LYK5.js} +1 -1
- package/{chunk-B7DE5XJW.js → chunk-ODGSLWLO.js} +249 -66
- package/{chunk-S2MHR4PU.js → chunk-OGZE6BZG.js} +190 -118
- package/{chunk-CD3RU7XL.js → chunk-OJRTTERA.js} +62 -2
- package/{chunk-GXXY2NL3.js → chunk-OKPC4QNX.js} +37 -2
- package/{chunk-5QZSEQSK.js → chunk-ONFFUQYM.js} +1 -1
- package/{chunk-BGGAY6OK.js → chunk-P244EH4W.js} +3 -3
- package/chunk-P27E22MA.js +203 -0
- package/{chunk-UFC4J7OY.js → chunk-PK7VT4ZU.js} +3 -3
- package/{chunk-4FIO2S7Z.js → chunk-QLUYDJST.js} +1 -1
- package/{chunk-AEQMKYZN.js → chunk-QUJKDFZW.js} +7 -7
- package/{chunk-G22P367E.js → chunk-QXUVCIPB.js} +62 -18
- package/{chunk-IJTXNLQE.js → chunk-QYNABNNQ.js} +6 -6
- package/{chunk-TRHJ4NJB.js → chunk-RGUWOMXU.js} +626 -237
- package/{chunk-L32W3PRP.js → chunk-RH44TIHX.js} +165 -16
- package/{chunk-EBKHA63G.js → chunk-RIMFTQMC.js} +178 -46
- package/{chunk-OOJNQK6V.js → chunk-S25VJYXV.js} +8 -2
- package/{chunk-BGGV6B5O.js → chunk-SBRJOYND.js} +280 -139
- package/{chunk-KZPEGO6D.js → chunk-SBRSXY67.js} +6 -6
- package/chunk-SR4FE5VD.js +9 -0
- package/{chunk-4WVJLODK.js → chunk-T23G6PXQ.js} +8 -3
- package/{chunk-D374I563.js → chunk-T3WSFTBS.js} +1 -1
- package/{chunk-VP3BINY7.js → chunk-TOK555CQ.js} +31 -1
- package/{chunk-OBSEKCVK.js → chunk-U4VSBDO5.js} +88 -0
- package/{chunk-OX6GNNVT.js → chunk-U5LOKQ2R.js} +24 -13
- package/{chunk-LYDEFPQP.js → chunk-UDT4SI37.js} +1 -1
- package/{chunk-CKZPMJNU.js → chunk-UQXOORR3.js} +5 -5
- package/{chunk-FFYE5ATM.js → chunk-UR7555FE.js} +11 -11
- package/{chunk-F3XI6WQP.js → chunk-UWOCASVL.js} +5 -5
- package/{chunk-A5EVA6HU.js → chunk-V2V5Q6DU.js} +2 -2
- package/{chunk-PROOOQZ3.js → chunk-VCU5GV42.js} +1 -1
- package/{chunk-F6YWDVIB.js → chunk-VMWY7TUA.js} +1 -1
- package/{chunk-RETQOQ4D.js → chunk-VNALJT32.js} +2 -2
- package/{chunk-HGDKT2D6.js → chunk-VTHWBTRE.js} +177 -1
- package/{chunk-X7IA2B7R.js → chunk-WBSJAIZP.js} +7 -3
- package/{chunk-ZEKUFJLW.js → chunk-WVOZ35E4.js} +7 -7
- package/{chunk-B5SV4H3J.js → chunk-XDNXKFWF.js} +4 -4
- package/{chunk-4Q6HQORG.js → chunk-XLN2GD6Z.js} +4 -4
- package/{chunk-HBRDSQ3M.js → chunk-XNEDFWT4.js} +2 -2
- package/{chunk-6CKUO32A.js → chunk-Y22P6ASC.js} +11 -8
- package/{chunk-SRCCSTIM.js → chunk-Y3DOUQQQ.js} +4 -4
- package/{chunk-6WZVM33D.js → chunk-Y5EBOURK.js} +3 -3
- package/{chunk-6OVNSQHN.js → chunk-YLAHYLDQ.js} +5 -0
- package/{chunk-T6VROBY7.js → chunk-YTEY27GN.js} +2 -2
- package/{chunk-5ZUOVCKT.js → chunk-YUZ2DAIH.js} +3 -1
- package/{chunk-IUTUWIKE.js → chunk-ZCVBIIUE.js} +4 -4
- package/{chunk-VM72HKW2.js → chunk-ZCZLTJEW.js} +9 -36
- package/{cliAgentConfigHelpers-U5OAVAKQ.js → cliAgentConfigHelpers-6OFDHJFT.js} +8 -8
- package/{cliAuthorityBrokerClient-S42VMGB6.js → cliAuthorityBrokerClient-SFPC3WVK.js} +1 -1
- package/{cliLocalAgentRecordReader-HVZAQCUD.js → cliLocalAgentRecordReader-FHIMCBUK.js} +52 -45
- package/{commandRegistry-TME7INFU.js → commandRegistry-OKIWAJIS.js} +101 -93
- package/{contentThunks-U6OC4R2N.js → contentThunks-VF2DCU46.js} +33 -32
- package/{cooldownCommands-U7XSRVJP.js → cooldownCommands-QL6DWGVU.js} +1 -1
- package/{createAgentAutomationAction-IP4LFN3W.js → createAgentAutomationAction-BGET7Q6K.js} +34 -33
- package/{createDialogAction-IAGQJ3LH.js → createDialogAction-XYDQZETK.js} +34 -33
- package/{createPageAction-AZ3UIFKA.js → createPageAction-74S5RO7U.js} +38 -37
- package/{db-M7FU2GNK.js → db-6NRZLEW2.js} +1 -1
- package/{dbSlice-DKKMJJYY.js → dbSlice-FI7VNDR5.js} +13 -13
- package/{deleteFile-TQSONMVU.js → deleteFile-GD62MPZW.js} +8 -8
- package/{dialogCommands-PCDRMBWG.js → dialogCommands-Y6DHZUAM.js} +56 -54
- package/{dialogNotifyCommand-O35MWMOS.js → dialogNotifyCommand-MKXL4NGL.js} +10 -10
- package/{dialogSlice-QAKYN4DE.js → dialogSlice-XAUKSWZ4.js} +32 -31
- package/{dialogUsageCommand-2SSLTXKO.js → dialogUsageCommand-BZPKR3DW.js} +5 -5
- package/{docCreateCommands-CFQFZOAD.js → docCreateCommands-PHDFOQBM.js} +51 -48
- package/{docDeleteCommands-5CPNTIIS.js → docDeleteCommands-OSHJM67Y.js} +53 -50
- package/{docReadCommands-XQILYSAJ.js → docReadCommands-E6QYCFMS.js} +51 -48
- package/{docStore-GIVRT7TQ.js → docStore-ZZT2BEBU.js} +15 -15
- package/{docUpdateCommands-VETKSUDD.js → docUpdateCommands-DHIOPK2C.js} +51 -48
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-LF5C4XSI.js → getPricing-RNRITFOP.js} +4 -4
- package/{handleSendMessageAction-HKIW4ZNO.js → handleSendMessageAction-ARUU6CNF.js} +71 -70
- package/{hostCredentialCreate-6VDJFNDO.js → hostCredentialCreate-SNQT73H4.js} +103 -104
- package/index.js +8 -8
- package/{localDialogRead-AV2VKKPG.js → localDialogRead-3T2KMCRC.js} +1 -1
- package/{localRuntimeAdapter-BQ4F5PZV.js → localRuntimeAdapter-MHI6Y2IZ.js} +112 -111
- package/{localRuntimeAuthority-WCNA4A3G.js → localRuntimeAuthority-7DKIT7UH.js} +2 -2
- package/{localRuntimeDb-CRNIBOOM.js → localRuntimeDb-5WZ4RJJO.js} +1 -1
- package/{machineCommands-K6XIGOAD.js → machineCommands-3O6Y27R4.js} +229 -321
- package/{machineWsRunDispatch-4OO7Z6UM.js → machineWsRunDispatch-5PFLR5XC.js} +101 -102
- package/markdownToSlate-KIYM7B3P.js +8 -0
- package/{mcpLocalAuthorizeCommand-ZP6ESAGE.js → mcpLocalAuthorizeCommand-BQCQ2KRJ.js} +15 -15
- package/{memberThunks-PBJPZ2JU.js → memberThunks-TU6A6OBV.js} +16 -16
- package/{models-H5NNZRLH.js → models-CINY5UZR.js} +2 -2
- package/package.json +1 -1
- package/{projectArchive-G7AOQPRW.js → projectArchive-X2EVXU3N.js} +40 -39
- package/{providerPresetApply-OPBCAONX.js → providerPresetApply-HUWNV2NI.js} +6 -6
- package/{providerRegistry-J2HCVTHE.js → providerRegistry-7FWKDKZJ.js} +6 -6
- package/{read-JEGPITEW.js → read-QAHEQID5.js} +8 -8
- package/{readDocTool-TE3XIU4Y.js → readDocTool-KG5DP6EM.js} +1 -1
- package/{readlineWorkspace-SOW5QUGZ.js → readlineWorkspace-SO3APHVP.js} +3300 -1518
- package/rememberExplicit-CPAPONSI.js +15 -0
- package/{removeDialogAgentAction-CX3OAH4Y.js → removeDialogAgentAction-QZCCVK2G.js} +19 -19
- package/{runAgentClientLoop-HQJPDFGQ.js → runAgentClientLoop-FLHHCOVH.js} +77 -77
- package/{runtimeDoctorCommands-GUH2YGMH.js → runtimeDoctorCommands-DN3I52C6.js} +8 -8
- package/{secretCommands-NJXFVHZU.js → secretCommands-36BCE3UE.js} +2 -2
- package/{setDialogExtraReferencesAction-CGM67EEQ.js → setDialogExtraReferencesAction-PDPTYSEW.js} +15 -15
- package/{setPrimaryDialogAgentAction-3ABWPPXR.js → setPrimaryDialogAgentAction-DOUIPR66.js} +19 -19
- package/{settingThunks-AY76OHYX.js → settingThunks-MHGGP6UE.js} +23 -23
- package/{spaceCommands-G63QGYQO.js → spaceCommands-JH7UYE3K.js} +54 -51
- package/{streamAgentChatTurn-E3XH2KFD.js → streamAgentChatTurn-VDDA2TX6.js} +118 -118
- package/{switchDialogAgentAction-G6EZRKCQ.js → switchDialogAgentAction-7USK3DAP.js} +17 -17
- package/{tableCommands-JI75ZHDI.js → tableCommands-UONBFC7L.js} +6 -6
- package/{toolApiClient-62UUPDUA.js → toolApiClient-53YMJ2G6.js} +7 -3
- package/{tools-7RSX22FT.js → tools-MIOCXKMG.js} +59 -60
- package/{tuiRestart-KAAA7TND.js → tuiRestart-ET3QISZ5.js} +10 -10
- package/{tuiSummaryLlmCaller-BVNHMWLR.js → tuiSummaryLlmCaller-MSINBP3M.js} +15 -14
- package/{updateCommands-ASK5XYPH.js → updateCommands-5OYND6EF.js} +3 -3
- package/{updateDialogTitleAction-SEWV252V.js → updateDialogTitleAction-2L4CC4YO.js} +35 -34
- package/{usageCommand-JVT5J3DC.js → usageCommand-JTKDAG6I.js} +2 -2
- package/{usageRebuildCommand-IZYYUTEW.js → usageRebuildCommand-4TFZCKXM.js} +3 -3
- package/{windowsSelfUpdate-BSDIS2J5.js → windowsSelfUpdate-HIYNL3VR.js} +2 -2
- package/{workContext-MM3P5GP5.js → workContext-Y3ADAPZU.js} +2 -1
- package/{workloadLifecycle-YIZ7KLUP.js → workloadLifecycle-ZCSQCHG3.js} +6 -6
- package/chunk-TUSTONB3.js +0 -81
- package/chunk-XBAEM4RI.js +0 -272
- package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +3 -3
- package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
- package/{chunk-VMJVAJ6W.js → chunk-TB5KTLNB.js} +3 -3
- /package/{chunk-FJ23FZXF.js → chunk-VIYVRPMJ.js} +0 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyMemoryInterpreterMutation
|
|
3
|
+
} from "./chunk-6RSNVJGO.js";
|
|
4
|
+
import {
|
|
5
|
+
getMemoryEntityVNext,
|
|
6
|
+
getMemoryEvidenceVNextStrict,
|
|
7
|
+
getMemoryStateVNext,
|
|
8
|
+
listMemoryStatesForEntityVNext
|
|
9
|
+
} from "./chunk-324FWHUA.js";
|
|
10
|
+
import {
|
|
11
|
+
normalizeTopicKey
|
|
12
|
+
} from "./chunk-MVOZ22RZ.js";
|
|
13
|
+
import {
|
|
14
|
+
sha256Hex
|
|
15
|
+
} from "./chunk-SR4FE5VD.js";
|
|
16
|
+
|
|
17
|
+
// packages/ai/memory/vnext/rememberExplicit.ts
|
|
18
|
+
async function rememberExplicitVNext(db, item) {
|
|
19
|
+
const ownerId = `${item.ownerType}:${encodeURIComponent(item.ownerId)}`;
|
|
20
|
+
const topicKey = normalizeTopicKey(item.topicKey);
|
|
21
|
+
if (!topicKey) {
|
|
22
|
+
const digest = sha256Hex(
|
|
23
|
+
JSON.stringify([
|
|
24
|
+
ownerId,
|
|
25
|
+
item.subjectType,
|
|
26
|
+
item.subjectId,
|
|
27
|
+
item.kind,
|
|
28
|
+
item.content
|
|
29
|
+
])
|
|
30
|
+
);
|
|
31
|
+
const entityId2 = `explicit-${digest}`;
|
|
32
|
+
const stateId = `explicit-${digest}`;
|
|
33
|
+
let saved2;
|
|
34
|
+
await applyMemoryInterpreterMutation(db, ownerId, async () => {
|
|
35
|
+
const existing = await getMemoryStateVNext(db, ownerId, stateId);
|
|
36
|
+
if (existing?.retiredAt)
|
|
37
|
+
throw new Error("Explicit memory conflicts with a retired state");
|
|
38
|
+
const entity = await getMemoryEntityVNext(db, ownerId, entityId2);
|
|
39
|
+
const createdAt = existing?.createdAt ?? item.createdAt;
|
|
40
|
+
const oldValue = existing?.value && typeof existing.value === "object" ? existing.value : {};
|
|
41
|
+
const confidence = Math.max(
|
|
42
|
+
Number(oldValue.confidence) || 0,
|
|
43
|
+
item.confidence ?? 0
|
|
44
|
+
);
|
|
45
|
+
const resident = oldValue.resident === true || item.resident === true;
|
|
46
|
+
const evidenceId = `explicit-${digest}-${sha256Hex(
|
|
47
|
+
JSON.stringify([
|
|
48
|
+
item.confidence,
|
|
49
|
+
item.sourceDialogId ?? null,
|
|
50
|
+
item.provenance ?? null
|
|
51
|
+
])
|
|
52
|
+
).slice(0, 24)}`;
|
|
53
|
+
const evidence = await getMemoryEvidenceVNextStrict(
|
|
54
|
+
db,
|
|
55
|
+
ownerId,
|
|
56
|
+
evidenceId
|
|
57
|
+
);
|
|
58
|
+
saved2 = {
|
|
59
|
+
...item,
|
|
60
|
+
id: `vnext-state-${stateId}`,
|
|
61
|
+
createdAt,
|
|
62
|
+
confidence,
|
|
63
|
+
...resident ? { resident: true } : {}
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
action: existing ? "update" : "create",
|
|
67
|
+
reason: "Explicit memory save",
|
|
68
|
+
entities: entity ? [] : [
|
|
69
|
+
{
|
|
70
|
+
id: entityId2,
|
|
71
|
+
ownerId,
|
|
72
|
+
type: "concept",
|
|
73
|
+
name: item.content,
|
|
74
|
+
createdAt,
|
|
75
|
+
updatedAt: createdAt
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
evidence: evidence ? [] : [
|
|
79
|
+
{
|
|
80
|
+
id: evidenceId,
|
|
81
|
+
ownerId,
|
|
82
|
+
text: item.content,
|
|
83
|
+
confidence: item.confidence,
|
|
84
|
+
...item.provenance ? { provenance: item.provenance } : {},
|
|
85
|
+
sourceRef: item.sourceDialogId ? `dialog:${item.sourceDialogId}` : `explicit:${digest}`,
|
|
86
|
+
createdAt
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
states: [
|
|
90
|
+
{
|
|
91
|
+
id: stateId,
|
|
92
|
+
ownerId,
|
|
93
|
+
entityId: entityId2,
|
|
94
|
+
facet: "explicit-memory",
|
|
95
|
+
text: item.content,
|
|
96
|
+
value: {
|
|
97
|
+
...oldValue,
|
|
98
|
+
kind: item.kind,
|
|
99
|
+
subjectType: item.subjectType,
|
|
100
|
+
subjectId: item.subjectId,
|
|
101
|
+
confidence,
|
|
102
|
+
resident,
|
|
103
|
+
visibility: item.visibility,
|
|
104
|
+
tags: item.tags,
|
|
105
|
+
importance: item.importance,
|
|
106
|
+
patternKey: item.patternKey,
|
|
107
|
+
recurrenceEvidence: item.recurrenceEvidence,
|
|
108
|
+
provenance: item.provenance,
|
|
109
|
+
sourceKind: item.sourceKind,
|
|
110
|
+
sourceDialogId: item.sourceDialogId
|
|
111
|
+
},
|
|
112
|
+
evidenceIds: [
|
|
113
|
+
.../* @__PURE__ */ new Set([...existing?.evidenceIds ?? [], evidenceId])
|
|
114
|
+
],
|
|
115
|
+
createdAt,
|
|
116
|
+
updatedAt: item.createdAt
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
return saved2;
|
|
122
|
+
}
|
|
123
|
+
const topicDigest = sha256Hex(
|
|
124
|
+
JSON.stringify([
|
|
125
|
+
ownerId,
|
|
126
|
+
item.subjectType,
|
|
127
|
+
item.subjectId,
|
|
128
|
+
item.kind,
|
|
129
|
+
topicKey
|
|
130
|
+
])
|
|
131
|
+
);
|
|
132
|
+
const entityId = `explicit-topic-${topicDigest}`;
|
|
133
|
+
const contentDigest = sha256Hex(
|
|
134
|
+
JSON.stringify([
|
|
135
|
+
ownerId,
|
|
136
|
+
item.subjectType,
|
|
137
|
+
item.subjectId,
|
|
138
|
+
item.kind,
|
|
139
|
+
item.content
|
|
140
|
+
])
|
|
141
|
+
);
|
|
142
|
+
let saved;
|
|
143
|
+
await applyMemoryInterpreterMutation(db, ownerId, async () => {
|
|
144
|
+
const entity = await getMemoryEntityVNext(db, ownerId, entityId);
|
|
145
|
+
const entityStates = (await listMemoryStatesForEntityVNext(db, ownerId, entityId)).filter((state) => state.facet === "explicit-memory");
|
|
146
|
+
const activeStates = entityStates.filter((state) => !state.retiredAt);
|
|
147
|
+
const matchingCurrent = activeStates.find(
|
|
148
|
+
(state) => state.text === item.content
|
|
149
|
+
);
|
|
150
|
+
if (matchingCurrent) {
|
|
151
|
+
const stateId2 = matchingCurrent.id;
|
|
152
|
+
const createdAt2 = matchingCurrent.createdAt;
|
|
153
|
+
const oldValue = matchingCurrent.value && typeof matchingCurrent.value === "object" ? matchingCurrent.value : {};
|
|
154
|
+
const confidence2 = Math.max(
|
|
155
|
+
Number(oldValue.confidence) || 0,
|
|
156
|
+
item.confidence ?? 0
|
|
157
|
+
);
|
|
158
|
+
const resident2 = oldValue.resident === true || item.resident === true;
|
|
159
|
+
const existingSupersedes = Array.isArray(oldValue.supersedesStateIds) ? oldValue.supersedesStateIds.map(String) : void 0;
|
|
160
|
+
const evidenceId2 = `${stateId2}-${sha256Hex(
|
|
161
|
+
JSON.stringify([
|
|
162
|
+
item.confidence,
|
|
163
|
+
item.sourceDialogId ?? null,
|
|
164
|
+
item.provenance ?? null
|
|
165
|
+
])
|
|
166
|
+
).slice(0, 24)}`;
|
|
167
|
+
const evidence2 = await getMemoryEvidenceVNextStrict(
|
|
168
|
+
db,
|
|
169
|
+
ownerId,
|
|
170
|
+
evidenceId2
|
|
171
|
+
);
|
|
172
|
+
saved = {
|
|
173
|
+
...item,
|
|
174
|
+
topicKey,
|
|
175
|
+
...existingSupersedes?.length ? { supersedesStateIds: existingSupersedes } : {},
|
|
176
|
+
id: `vnext-state-${stateId2}`,
|
|
177
|
+
createdAt: createdAt2,
|
|
178
|
+
confidence: confidence2,
|
|
179
|
+
...resident2 ? { resident: true } : {}
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
action: "update",
|
|
183
|
+
reason: "Explicit memory save (topicKey idempotent update)",
|
|
184
|
+
entities: entity ? [] : [
|
|
185
|
+
{
|
|
186
|
+
id: entityId,
|
|
187
|
+
ownerId,
|
|
188
|
+
type: "concept",
|
|
189
|
+
subtype: "explicit-topic",
|
|
190
|
+
name: topicKey,
|
|
191
|
+
createdAt: createdAt2,
|
|
192
|
+
updatedAt: createdAt2
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
evidence: evidence2 ? [] : [
|
|
196
|
+
{
|
|
197
|
+
id: evidenceId2,
|
|
198
|
+
ownerId,
|
|
199
|
+
text: item.content,
|
|
200
|
+
confidence: item.confidence,
|
|
201
|
+
...item.provenance ? { provenance: item.provenance } : {},
|
|
202
|
+
sourceRef: item.sourceDialogId ? `dialog:${item.sourceDialogId}` : `explicit:${topicDigest}`,
|
|
203
|
+
createdAt: item.createdAt
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
states: [
|
|
207
|
+
{
|
|
208
|
+
id: stateId2,
|
|
209
|
+
ownerId,
|
|
210
|
+
entityId,
|
|
211
|
+
facet: "explicit-memory",
|
|
212
|
+
text: item.content,
|
|
213
|
+
value: {
|
|
214
|
+
...oldValue,
|
|
215
|
+
kind: item.kind,
|
|
216
|
+
subjectType: item.subjectType,
|
|
217
|
+
subjectId: item.subjectId,
|
|
218
|
+
confidence: confidence2,
|
|
219
|
+
resident: resident2,
|
|
220
|
+
visibility: item.visibility,
|
|
221
|
+
tags: item.tags,
|
|
222
|
+
importance: item.importance,
|
|
223
|
+
patternKey: item.patternKey,
|
|
224
|
+
recurrenceEvidence: item.recurrenceEvidence,
|
|
225
|
+
provenance: item.provenance,
|
|
226
|
+
sourceKind: item.sourceKind,
|
|
227
|
+
sourceDialogId: item.sourceDialogId,
|
|
228
|
+
topicKey,
|
|
229
|
+
...existingSupersedes?.length ? { supersedesStateIds: existingSupersedes } : {}
|
|
230
|
+
},
|
|
231
|
+
evidenceIds: [
|
|
232
|
+
.../* @__PURE__ */ new Set([...matchingCurrent.evidenceIds, evidenceId2])
|
|
233
|
+
],
|
|
234
|
+
createdAt: createdAt2,
|
|
235
|
+
updatedAt: item.createdAt
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const supersededIds = activeStates.map((state) => state.id);
|
|
241
|
+
const isSupersede = supersededIds.length > 0;
|
|
242
|
+
const version = entityStates.length + 1;
|
|
243
|
+
const stateId = `explicit-topic-${topicDigest.slice(0, 24)}-v${version}-${contentDigest.slice(0, 16)}`;
|
|
244
|
+
const createdAt = item.createdAt;
|
|
245
|
+
const confidence = item.confidence ?? 0;
|
|
246
|
+
const resident = item.resident === true;
|
|
247
|
+
const evidenceId = `${stateId}-${sha256Hex(
|
|
248
|
+
JSON.stringify([
|
|
249
|
+
item.confidence,
|
|
250
|
+
item.sourceDialogId ?? null,
|
|
251
|
+
item.provenance ?? null
|
|
252
|
+
])
|
|
253
|
+
).slice(0, 24)}`;
|
|
254
|
+
const evidence = await getMemoryEvidenceVNextStrict(
|
|
255
|
+
db,
|
|
256
|
+
ownerId,
|
|
257
|
+
evidenceId
|
|
258
|
+
);
|
|
259
|
+
const relations = supersededIds.map(
|
|
260
|
+
(oldId, idx) => ({
|
|
261
|
+
id: `rel-supersedes-${stateId}-${idx}`,
|
|
262
|
+
ownerId,
|
|
263
|
+
from: stateId,
|
|
264
|
+
type: "supersedes",
|
|
265
|
+
to: oldId,
|
|
266
|
+
createdAt
|
|
267
|
+
})
|
|
268
|
+
);
|
|
269
|
+
saved = {
|
|
270
|
+
...item,
|
|
271
|
+
topicKey,
|
|
272
|
+
...isSupersede ? { supersedesStateIds: supersededIds } : {},
|
|
273
|
+
id: `vnext-state-${stateId}`,
|
|
274
|
+
createdAt,
|
|
275
|
+
confidence,
|
|
276
|
+
...resident ? { resident: true } : {}
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
action: isSupersede ? "supersede" : "create",
|
|
280
|
+
reason: isSupersede ? "Explicit memory topicKey supersede" : "Explicit memory save (topicKey)",
|
|
281
|
+
entities: entity ? [] : [
|
|
282
|
+
{
|
|
283
|
+
id: entityId,
|
|
284
|
+
ownerId,
|
|
285
|
+
type: "concept",
|
|
286
|
+
subtype: "explicit-topic",
|
|
287
|
+
name: topicKey,
|
|
288
|
+
createdAt,
|
|
289
|
+
updatedAt: createdAt
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
evidence: evidence ? [] : [
|
|
293
|
+
{
|
|
294
|
+
id: evidenceId,
|
|
295
|
+
ownerId,
|
|
296
|
+
text: item.content,
|
|
297
|
+
confidence: item.confidence,
|
|
298
|
+
...item.provenance ? { provenance: item.provenance } : {},
|
|
299
|
+
sourceRef: item.sourceDialogId ? `dialog:${item.sourceDialogId}` : `explicit:${topicDigest}`,
|
|
300
|
+
createdAt
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
states: [
|
|
304
|
+
{
|
|
305
|
+
id: stateId,
|
|
306
|
+
ownerId,
|
|
307
|
+
entityId,
|
|
308
|
+
facet: "explicit-memory",
|
|
309
|
+
text: item.content,
|
|
310
|
+
value: {
|
|
311
|
+
kind: item.kind,
|
|
312
|
+
subjectType: item.subjectType,
|
|
313
|
+
subjectId: item.subjectId,
|
|
314
|
+
confidence,
|
|
315
|
+
resident,
|
|
316
|
+
visibility: item.visibility,
|
|
317
|
+
tags: item.tags,
|
|
318
|
+
importance: item.importance,
|
|
319
|
+
patternKey: item.patternKey,
|
|
320
|
+
recurrenceEvidence: item.recurrenceEvidence,
|
|
321
|
+
provenance: item.provenance,
|
|
322
|
+
sourceKind: item.sourceKind,
|
|
323
|
+
sourceDialogId: item.sourceDialogId,
|
|
324
|
+
topicKey,
|
|
325
|
+
...isSupersede ? { supersedesStateIds: supersededIds } : {}
|
|
326
|
+
},
|
|
327
|
+
evidenceIds: [evidenceId],
|
|
328
|
+
createdAt,
|
|
329
|
+
updatedAt: item.createdAt
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
...isSupersede ? { supersededStateIds: supersededIds, relations } : {}
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
return saved;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export {
|
|
339
|
+
rememberExplicitVNext
|
|
340
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchReferenceContents,
|
|
3
3
|
resolveReferenceAssets
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6S6CZUXK.js";
|
|
5
5
|
import {
|
|
6
6
|
updateTokensAction
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ODGSLWLO.js";
|
|
8
8
|
import {
|
|
9
9
|
applyUpdateTokensFulfilled
|
|
10
10
|
} from "./chunk-I2OYPD3Y.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
extractReasoningFromResponseOutput,
|
|
13
13
|
extractTextFromResponseOutput,
|
|
14
14
|
extractToolCallsFromResponseOutput
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-F4MCAOWN.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord
|
|
18
18
|
} from "./chunk-KUG52IAP.js";
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
loadFileFromIndexedDb,
|
|
7
7
|
removeAction,
|
|
8
8
|
saveFileToIndexedDb
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-V2V5Q6DU.js";
|
|
10
10
|
import {
|
|
11
11
|
readAction,
|
|
12
12
|
readRequestManager,
|
|
13
13
|
resolveAgentReadServers
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UWOCASVL.js";
|
|
15
15
|
import {
|
|
16
16
|
beginWriteAck,
|
|
17
17
|
compareRemoteRecordsByComparableTime,
|
|
@@ -29,13 +29,13 @@ import {
|
|
|
29
29
|
shouldReplaceLocalWithRemoteRecord,
|
|
30
30
|
shouldReplicateLocalRecord,
|
|
31
31
|
uploadToCurrentServer
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OKPC4QNX.js";
|
|
33
33
|
import {
|
|
34
34
|
asyncThunkCreator,
|
|
35
35
|
buildCreateSlice,
|
|
36
36
|
createEntityAdapter,
|
|
37
37
|
noloDeleteRequest
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-247AAJRK.js";
|
|
39
39
|
import {
|
|
40
40
|
fetchFromClientDb,
|
|
41
41
|
fetchFromServer,
|
|
@@ -44,13 +44,10 @@ import {
|
|
|
44
44
|
logger,
|
|
45
45
|
normalizeTimeFields,
|
|
46
46
|
scopeGoogleSessionServers
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-BH7CEVOH.js";
|
|
48
48
|
import {
|
|
49
49
|
isTombstoneRecord
|
|
50
50
|
} from "./chunk-BV3FLP2L.js";
|
|
51
|
-
import {
|
|
52
|
-
isPublicBuiltinPlatformAgentKey
|
|
53
|
-
} from "./chunk-WRKMXMU7.js";
|
|
54
51
|
import {
|
|
55
52
|
fileKey,
|
|
56
53
|
getFileIdFromKey
|
|
@@ -58,6 +55,9 @@ import {
|
|
|
58
55
|
import {
|
|
59
56
|
ulid
|
|
60
57
|
} from "./chunk-OJKUU3LP.js";
|
|
58
|
+
import {
|
|
59
|
+
isPublicBuiltinPlatformAgentKey
|
|
60
|
+
} from "./chunk-WRKMXMU7.js";
|
|
61
61
|
import {
|
|
62
62
|
API_ENDPOINTS
|
|
63
63
|
} from "./chunk-LCBAMY2M.js";
|
|
@@ -1494,7 +1494,7 @@ var dbSlice = createSliceWithThunks({
|
|
|
1494
1494
|
// 动态 import 在调用期解析,避开 TDZ/求值顺序问题(同下方 share)。
|
|
1495
1495
|
read: create.asyncThunk(
|
|
1496
1496
|
async (payload, thunkApi) => {
|
|
1497
|
-
const { readAction: readAction2 } = await import("./read-
|
|
1497
|
+
const { readAction: readAction2 } = await import("./read-QAHEQID5.js");
|
|
1498
1498
|
return readAction2(payload, thunkApi);
|
|
1499
1499
|
},
|
|
1500
1500
|
{
|
|
@@ -1568,7 +1568,7 @@ var dbSlice = createSliceWithThunks({
|
|
|
1568
1568
|
// 这里改成动态 import,运行期才解析,彻底断开这条边。
|
|
1569
1569
|
share: create.asyncThunk(
|
|
1570
1570
|
async (config, thunkApi) => {
|
|
1571
|
-
const { shareResourceAction } = await import("./action-
|
|
1571
|
+
const { shareResourceAction } = await import("./action-VDEW6WLI.js");
|
|
1572
1572
|
return shareResourceAction(config, thunkApi);
|
|
1573
1573
|
}
|
|
1574
1574
|
),
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveLocalUserId
|
|
3
|
-
} from "./chunk-2574ANSV.js";
|
|
4
1
|
import {
|
|
5
2
|
resolveNoloHome
|
|
6
3
|
} from "./chunk-GLKOYSRU.js";
|
|
@@ -8,6 +5,9 @@ import {
|
|
|
8
5
|
isSupportedDialogId,
|
|
9
6
|
splitDialogKeyIdentity
|
|
10
7
|
} from "./chunk-YZMNK53S.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveLocalUserId
|
|
10
|
+
} from "./chunk-LZOOUQAZ.js";
|
|
11
11
|
import {
|
|
12
12
|
toErrorMessage
|
|
13
13
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -8,13 +8,9 @@ import {
|
|
|
8
8
|
getMemoryEvidenceVNext,
|
|
9
9
|
getMemoryEvidenceVNextStrict,
|
|
10
10
|
getMemoryStateVNext,
|
|
11
|
-
listMemoryStatesForEntityVNext
|
|
12
|
-
loadMemoryVNextCatalog
|
|
11
|
+
listMemoryStatesForEntityVNext
|
|
13
12
|
} from "./chunk-324FWHUA.js";
|
|
14
13
|
|
|
15
|
-
// packages/ai/memory/vnext/workContext.ts
|
|
16
|
-
import { createHash } from "crypto";
|
|
17
|
-
|
|
18
14
|
// packages/ai/memory/vnext/applyMutation.ts
|
|
19
15
|
async function validateMutation(db, ownerId, mutation) {
|
|
20
16
|
const pending = {
|
|
@@ -278,102 +274,6 @@ var applyMemoryInterpreterMutation = async (db, ownerId, mutation) => {
|
|
|
278
274
|
}
|
|
279
275
|
};
|
|
280
276
|
|
|
281
|
-
// packages/ai/memory/vnext/workContext.ts
|
|
282
|
-
var facet = "work-context";
|
|
283
|
-
var statuses = ["active", "paused", "completed", "cancelled"];
|
|
284
|
-
var hash = (v) => createHash("sha256").update(JSON.stringify(v)).digest("hex");
|
|
285
|
-
var isWorkContextState = (state) => state.facet === facet;
|
|
286
|
-
var bounded = (s, max) => typeof s === "string" && s.trim().length > 0 && s.length <= max;
|
|
287
|
-
var list = (x, maxCount, maxLength) => Array.isArray(x) && x.length <= maxCount && x.every((v) => bounded(v, maxLength));
|
|
288
|
-
var object = (x) => !!x && typeof x === "object" && !Array.isArray(x);
|
|
289
|
-
var validScope = (s) => {
|
|
290
|
-
if (!s || !bounded(s.ownerId, 256) || !bounded(s.dialogId, 512) || !(s.spaceId === null || bounded(s.spaceId, 256))) throw new Error("invalid authorized scope");
|
|
291
|
-
};
|
|
292
|
-
function validValue(v) {
|
|
293
|
-
return object(v) && v.version === 1 && Number.isSafeInteger(v.revision) && v.revision > 0 && statuses.includes(v.status) && bounded(v.goal, 4096) && list(v.constraints, 50, 2048) && list(v.openItems, 50, 2048) && (v.nextStep === void 0 || typeof v.nextStep === "string" && v.nextStep.length <= 4096) && list(v.latestSourceRefs, 20, 2048) && v.latestSourceRefs.length > 0 && (v.spaceId === null || bounded(v.spaceId, 256)) && list(v.dialogIds, 100, 512) && v.dialogIds.length > 0;
|
|
294
|
-
}
|
|
295
|
-
function validPatch(p) {
|
|
296
|
-
if (!object(p) || Object.keys(p).some((k) => !["status", "goal", "constraints", "openItems", "nextStep"].includes(k))) throw new Error("invalid patch");
|
|
297
|
-
if (p.status !== void 0 && !statuses.includes(p.status)) throw new Error("invalid status");
|
|
298
|
-
if (p.goal !== void 0 && !bounded(p.goal, 4096)) throw new Error("invalid goal");
|
|
299
|
-
if (p.nextStep !== void 0 && (typeof p.nextStep !== "string" || p.nextStep.length > 4096)) throw new Error("invalid nextStep");
|
|
300
|
-
for (const a of [p.constraints, p.openItems]) if (a !== void 0 && !list(a, 50, 2048)) throw new Error("invalid list");
|
|
301
|
-
}
|
|
302
|
-
async function updateWorkContext(db, scope, input) {
|
|
303
|
-
validScope(scope);
|
|
304
|
-
if (!object(input) || Object.keys(input).some((k) => !["activityId", "expectedRevision", "itemKey", "originRef", "changeId", "sourceRefs", "patch"].includes(k))) throw new Error("invalid input");
|
|
305
|
-
validPatch(input.patch);
|
|
306
|
-
if (!bounded(input.changeId, 256) || !list(input.sourceRefs, 20, 2048) || !input.sourceRefs.length) throw new Error("source and changeId required");
|
|
307
|
-
const creating = input.activityId === void 0;
|
|
308
|
-
if (creating && (!bounded(input.itemKey, 256) || !bounded(input.originRef, 2048) || input.expectedRevision !== void 0)) throw new Error("origin and itemKey required");
|
|
309
|
-
if (!creating && (!bounded(input.activityId, 256) || !Number.isSafeInteger(input.expectedRevision) || input.expectedRevision < 1 || input.itemKey !== void 0 || input.originRef !== void 0)) throw new Error("activityId and revision required");
|
|
310
|
-
const activityId = creating ? `work-${hash([scope.ownerId, scope.spaceId, input.originRef, input.itemKey])}` : input.activityId;
|
|
311
|
-
const evidenceId = `work-change-${hash([activityId, input.changeId])}`;
|
|
312
|
-
const fingerprint = hash([scope.spaceId, scope.dialogId, input]);
|
|
313
|
-
let result;
|
|
314
|
-
await applyMemoryInterpreterMutation(db, scope.ownerId, async () => {
|
|
315
|
-
const states = (await listMemoryStatesForEntityVNext(db, scope.ownerId, activityId)).filter(isWorkContextState);
|
|
316
|
-
const currents = states.filter((s) => !s.retiredAt);
|
|
317
|
-
if (currents.length > 1 || currents[0] && !validValue(currents[0].value)) throw new Error("invalid work context state");
|
|
318
|
-
const current = currents[0];
|
|
319
|
-
const old = current?.value;
|
|
320
|
-
if (old && old.spaceId !== scope.spaceId) {
|
|
321
|
-
result = { activityId, revision: 0, outcome: "conflict" };
|
|
322
|
-
return { action: "no_op", reason: "scope mismatch" };
|
|
323
|
-
}
|
|
324
|
-
const receipt = await getMemoryEvidenceVNextStrict(db, scope.ownerId, evidenceId);
|
|
325
|
-
if (receipt) {
|
|
326
|
-
const matching = states.find((s) => s.evidenceIds.includes(evidenceId));
|
|
327
|
-
const savedValue = matching && validValue(matching.value) ? matching.value : void 0;
|
|
328
|
-
const match = receipt.text === fingerprint && !!savedValue;
|
|
329
|
-
result = { activityId, revision: match ? savedValue.revision : old?.revision ?? 0, outcome: match ? savedValue.revision === 1 ? "created" : "updated" : "conflict" };
|
|
330
|
-
return { action: "no_op", reason: "duplicate change" };
|
|
331
|
-
}
|
|
332
|
-
if (creating && current || !creating && (!old || old.revision !== input.expectedRevision)) {
|
|
333
|
-
result = { activityId, revision: old?.revision ?? 0, outcome: "conflict" };
|
|
334
|
-
return { action: "no_op", reason: "revision conflict" };
|
|
335
|
-
}
|
|
336
|
-
if (!old && !input.patch.goal) throw new Error("goal required");
|
|
337
|
-
const status = input.patch.status ?? old?.status ?? "active";
|
|
338
|
-
const dialogIds = [.../* @__PURE__ */ new Set([...old?.dialogIds ?? [], scope.dialogId])];
|
|
339
|
-
if (dialogIds.length > 100) throw new Error("dialog association limit exceeded");
|
|
340
|
-
const value = { version: 1, revision: (old?.revision ?? 0) + 1, status, goal: input.patch.goal ?? old.goal, constraints: input.patch.constraints ?? old?.constraints ?? [], openItems: input.patch.openItems ?? old?.openItems ?? [], nextStep: input.patch.nextStep ?? old?.nextStep, latestSourceRefs: input.sourceRefs, spaceId: scope.spaceId, dialogIds };
|
|
341
|
-
const unchanged = !!old && JSON.stringify([old.status, old.goal, old.constraints, old.openItems, old.nextStep]) === JSON.stringify([value.status, value.goal, value.constraints, value.openItems, value.nextStep]);
|
|
342
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
343
|
-
result = { activityId, revision: unchanged ? old.revision : value.revision, outcome: unchanged ? "unchanged" : old ? "updated" : "created" };
|
|
344
|
-
if (unchanged) return { action: "no_op", reason: "unchanged" };
|
|
345
|
-
const evidence = { id: evidenceId, ownerId: scope.ownerId, text: fingerprint, sourceRef: input.sourceRefs[0], confidence: 1, createdAt: now };
|
|
346
|
-
return { action: old ? "update" : "create", reason: "work context", entities: old ? [] : [{ id: activityId, ownerId: scope.ownerId, type: "activity", subtype: facet, name: value.goal, createdAt: now, updatedAt: now }], evidence: [evidence], states: [{ id: `work-state-${hash([activityId, value.revision])}`, ownerId: scope.ownerId, entityId: activityId, facet, value, text: value.goal, evidenceIds: [evidenceId], createdAt: now, updatedAt: now }], supersededStateIds: current ? [current.id] : [] };
|
|
347
|
-
});
|
|
348
|
-
return result;
|
|
349
|
-
}
|
|
350
|
-
async function readWorkContexts(db, scope, query = {}) {
|
|
351
|
-
validScope(scope);
|
|
352
|
-
if (!object(query) || Object.keys(query).some((k) => !["activityId", "status", "query", "limit", "discovery"].includes(k))) throw new Error("invalid query");
|
|
353
|
-
const limit = query.limit ?? 20;
|
|
354
|
-
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 100) throw new Error("limit must be 1..100");
|
|
355
|
-
if (query.status !== void 0 && query.status !== "all" && !statuses.some((status) => status === query.status)) throw new Error("invalid status");
|
|
356
|
-
if (query.discovery !== void 0 && query.discovery !== "dialog" && query.discovery !== "scope") throw new Error("invalid discovery");
|
|
357
|
-
if (query.activityId !== void 0 && !bounded(query.activityId, 256)) throw new Error("invalid activityId");
|
|
358
|
-
if (query.query !== void 0 && !bounded(query.query, 512)) throw new Error("invalid query text");
|
|
359
|
-
const states = query.activityId ? await listMemoryStatesForEntityVNext(db, scope.ownerId, query.activityId) : (await loadMemoryVNextCatalog(db, scope.ownerId)).states;
|
|
360
|
-
const items = [];
|
|
361
|
-
for (const state of states) {
|
|
362
|
-
if (!isWorkContextState(state) || state.retiredAt) continue;
|
|
363
|
-
if (!validValue(state.value) || !bounded(state.entityId, 256) || !bounded(state.updatedAt, 128)) throw new Error("invalid work context state");
|
|
364
|
-
const value = state.value;
|
|
365
|
-
if (value.spaceId !== scope.spaceId || !query.activityId && query.discovery !== "scope" && !value.dialogIds.includes(scope.dialogId)) continue;
|
|
366
|
-
if (query.status !== "all" && value.status !== (query.status ?? (query.activityId ? value.status : "active"))) continue;
|
|
367
|
-
if (query.query && !JSON.stringify([value.goal, value.constraints, value.openItems, value.nextStep]).toLowerCase().includes(query.query.toLowerCase())) continue;
|
|
368
|
-
items.push({ activityId: state.entityId, value, updatedAt: state.updatedAt });
|
|
369
|
-
}
|
|
370
|
-
items.sort((a, b) => Number(b.value.dialogIds.includes(scope.dialogId)) - Number(a.value.dialogIds.includes(scope.dialogId)) || b.updatedAt.localeCompare(a.updatedAt) || a.activityId.localeCompare(b.activityId));
|
|
371
|
-
return { items: items.slice(0, limit), hasMore: items.length > limit };
|
|
372
|
-
}
|
|
373
|
-
|
|
374
277
|
export {
|
|
375
|
-
applyMemoryInterpreterMutation
|
|
376
|
-
isWorkContextState,
|
|
377
|
-
updateWorkContext,
|
|
378
|
-
readWorkContexts
|
|
278
|
+
applyMemoryInterpreterMutation
|
|
379
279
|
};
|
|
@@ -2,63 +2,63 @@ import {
|
|
|
2
2
|
clipMultilineText,
|
|
3
3
|
fetchAndSerializeTable,
|
|
4
4
|
waitForAbortableDelay
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DPAIQLAL.js";
|
|
6
6
|
import {
|
|
7
7
|
isGatewayHttpStatus
|
|
8
8
|
} from "./chunk-NF64D32W.js";
|
|
9
9
|
import {
|
|
10
10
|
resolvePageReadMarkdown,
|
|
11
11
|
slateToSimplifiedMarkdown
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3ORFJP2Z.js";
|
|
13
13
|
import {
|
|
14
14
|
extractCategorizedMentions
|
|
15
15
|
} from "./chunk-AGIM7IMJ.js";
|
|
16
16
|
import {
|
|
17
17
|
fetchAndCacheMessages
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ODGSLWLO.js";
|
|
19
|
+
import {
|
|
20
|
+
createSpaceKey
|
|
21
|
+
} from "./chunk-UAD2WT54.js";
|
|
22
|
+
import {
|
|
23
|
+
read
|
|
24
|
+
} from "./chunk-6MQWGA5F.js";
|
|
19
25
|
import {
|
|
20
26
|
createDrainExhaustedResponse,
|
|
21
27
|
isCoreDrainingBody,
|
|
22
28
|
normalizeNonNegativeMs,
|
|
23
29
|
parseRetryAfterHeaderMs
|
|
24
30
|
} from "./chunk-3L2WKC3W.js";
|
|
25
|
-
import {
|
|
26
|
-
createSpaceKey
|
|
27
|
-
} from "./chunk-UAD2WT54.js";
|
|
28
|
-
import {
|
|
29
|
-
read
|
|
30
|
-
} from "./chunk-RM4UMFY4.js";
|
|
31
31
|
import {
|
|
32
32
|
getRuntimeServerContext
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-OKPC4QNX.js";
|
|
34
34
|
import {
|
|
35
35
|
classifyGenerationError
|
|
36
36
|
} from "./chunk-TLE77UJ5.js";
|
|
37
|
+
import {
|
|
38
|
+
estimateTokenCount
|
|
39
|
+
} from "./chunk-PSCNXBYA.js";
|
|
37
40
|
import {
|
|
38
41
|
isAbortError
|
|
39
42
|
} from "./chunk-7DPNBQSV.js";
|
|
40
43
|
import {
|
|
41
|
-
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
wrapHistoricalSummaryWithReplayGuard
|
|
45
|
+
} from "./chunk-2SXN7LAY.js";
|
|
43
46
|
import {
|
|
44
47
|
dedupeSkillPromptPatches,
|
|
45
48
|
extractRuntimePageCapabilities,
|
|
46
49
|
resolveBuiltinSkillEntry,
|
|
47
50
|
resolveBuiltinSkillPage,
|
|
48
51
|
resolveSkillGraphFromRoots
|
|
49
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-RIMFTQMC.js";
|
|
50
53
|
import {
|
|
51
54
|
resolvePageSkillMetadata
|
|
52
|
-
} from "./chunk-
|
|
53
|
-
import {
|
|
54
|
-
extractCustomId
|
|
55
|
-
} from "./chunk-M2EJHDJP.js";
|
|
55
|
+
} from "./chunk-AETZ7AD6.js";
|
|
56
56
|
import {
|
|
57
57
|
isDialogRecordKey
|
|
58
58
|
} from "./chunk-OJKUU3LP.js";
|
|
59
59
|
import {
|
|
60
|
-
|
|
61
|
-
} from "./chunk-
|
|
60
|
+
extractCustomId
|
|
61
|
+
} from "./chunk-M2EJHDJP.js";
|
|
62
62
|
import {
|
|
63
63
|
asTrimmedString
|
|
64
64
|
} from "./chunk-3EUW3WEO.js";
|