nolo-cli 0.82.0-alpha.5 → 0.82.0

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.
Files changed (161) hide show
  1. package/README.md +2 -2
  2. package/{_executeModel-225YRU52.js → _executeModel-FHVQOYWX.js} +48 -48
  3. package/{action-D22U6CTH.js → action-YVYQEAAV.js} +11 -11
  4. package/{addContentAction-XAPUTGL4.js → addContentAction-O7R66HEX.js} +9 -9
  5. package/{addDialogAgentAction-M7VLLBZM.js → addDialogAgentAction-74OA7KYP.js} +8 -8
  6. package/{agentDeleteCommand-ZJNQGVR2.js → agentDeleteCommand-4427YKQF.js} +31 -29
  7. package/{agentEmailCommands-VLVWFWX2.js → agentEmailCommands-LYDIAUOP.js} +67 -63
  8. package/{agentGrantCommands-R3VQEZJR.js → agentGrantCommands-M3XFO6EN.js} +2 -2
  9. package/{agentListCommands-GHQGLAUU.js → agentListCommands-O4AEMQVV.js} +40 -32
  10. package/{agentMachineCommands-QDXYENZJ.js → agentMachineCommands-F6IHXMPD.js} +31 -29
  11. package/{agentProviderCommands-65ZC2WB4.js → agentProviderCommands-GNPTL5XR.js} +87 -0
  12. package/{agentPullCommand-N7L2CT7L.js → agentPullCommand-O5MPVJ5E.js} +3 -3
  13. package/agentRecordCommands-BDLFOU7E.js +128 -0
  14. package/{agentRunCommand-YSCD65HH.js → agentRunCommand-HSSYFGMC.js} +65 -61
  15. package/{agentRunControl-T44MESII.js → agentRunControl-WCTKX5VL.js} +2 -2
  16. package/{agentRuntimeLocal-ZOHB7OOO.js → agentRuntimeLocal-IW3IM5P6.js} +27 -25
  17. package/{agentSlice-O2SBU5TK.js → agentSlice-G54NT6PX.js} +10 -10
  18. package/{appDeleteCommands-PRT6K5N2.js → appDeleteCommands-ZXLXNRHF.js} +31 -29
  19. package/{appDeployCommands-63ZONFAN.js → appDeployCommands-PWB4YERK.js} +31 -29
  20. package/{appDeployStatusCommands-AFAYCVR3.js → appDeployStatusCommands-2EZKZP7Y.js} +31 -29
  21. package/{appGetCommands-TNZDZE36.js → appGetCommands-JNUKOWHO.js} +31 -29
  22. package/{appListCommands-IA4SPG2X.js → appListCommands-6X3H67SS.js} +31 -29
  23. package/{authCommand-EVGFLAHO.js → authCommand-F4EFRRX6.js} +164 -24
  24. package/{authCommands-ILTBI6JV.js → authCommands-RGOGCPP6.js} +4 -5
  25. package/builtinSkillRegistry-FUAVTRVZ.js +33 -0
  26. package/{chatQueueReduxAdapter-4SM3DAWX.js → chatQueueReduxAdapter-VJXYSZ2D.js} +24 -24
  27. package/{chromeCommands-VOIRNJBL.js → chromeCommands-FZYAU75D.js} +1 -1
  28. package/{chromeOpsCommands-M7DPCX2T.js → chromeOpsCommands-62P2Q2YB.js} +31 -1
  29. package/{chunk-C3FZR5EC.js → chunk-2F7RJC6L.js} +1 -1
  30. package/{chunk-QC5LGHYP.js → chunk-2YMRWISD.js} +10 -5
  31. package/{chunk-HQUORJTM.js → chunk-3BMYXEUW.js} +1 -1
  32. package/{chunk-3QPYFHAH.js → chunk-3DII57IT.js} +1 -1
  33. package/{chunk-NTW5GWDM.js → chunk-3VNWWVKB.js} +2 -0
  34. package/{chunk-DWUCB2A3.js → chunk-42V6BK2E.js} +1 -1
  35. package/{chunk-KIS76A2P.js → chunk-4EZHSKTB.js} +38 -4
  36. package/{chunk-GBPZKFYK.js → chunk-53HEEOTT.js} +4 -4
  37. package/{chunk-5XTOKQLW.js → chunk-5UTFL4QJ.js} +6 -2
  38. package/chunk-5ZUL4CUO.js +10 -0
  39. package/{chunk-E6RGHPDR.js → chunk-6D6VBVEW.js} +4 -6
  40. package/{chunk-CMH2SYHX.js → chunk-6OZ36FXI.js} +2 -2
  41. package/{chunk-NRALD3CC.js → chunk-76WEAXJB.js} +49 -10
  42. package/{chunk-3W2JJOH3.js → chunk-7REEVK4I.js} +3 -3
  43. package/{chunk-BYEJ7K2Z.js → chunk-7S4YWN7P.js} +1 -1
  44. package/{chunk-SREASRV5.js → chunk-ABQYVJBJ.js} +1 -1
  45. package/chunk-ACTMNVHM.js +93 -0
  46. package/{chunk-XWNRAIUL.js → chunk-AFUORTY4.js} +6 -16
  47. package/{chunk-E36HZARC.js → chunk-ASQYTZTR.js} +46 -9
  48. package/{chunk-73IOJLK2.js → chunk-AVV3M6CX.js} +10 -10
  49. package/{chunk-WL2RKIBF.js → chunk-BLJWCTRL.js} +1 -1
  50. package/chunk-BNGW5ASC.js +344 -0
  51. package/{chunk-SZLVDREM.js → chunk-BP4XNZRM.js} +3 -3
  52. package/{chunk-2KDR4CWE.js → chunk-BYMV6QZG.js} +24 -1
  53. package/{chunk-MYU3MJCF.js → chunk-DHDMC6FO.js} +175 -7
  54. package/{chunk-FP27MNSX.js → chunk-DL2LVM5E.js} +3 -3
  55. package/{chunk-EXMHJN7C.js → chunk-EYAQT56M.js} +4 -3
  56. package/{chunk-5LSS6MFZ.js → chunk-F5OE5KSJ.js} +13 -15
  57. package/{chunk-CJCJF5XB.js → chunk-FDTR4QJ6.js} +4 -2
  58. package/{chunk-NJ6WLAPS.js → chunk-FEEHCOBD.js} +1 -1
  59. package/{chunk-YSKEOTPH.js → chunk-GGMVRZRO.js} +155 -795
  60. package/{chunk-PYXL2CJL.js → chunk-GPCZ7UXG.js} +1 -1
  61. package/{chunk-K7AG465Q.js → chunk-GQBOR3G6.js} +4 -2
  62. package/{chunk-YFADVSZE.js → chunk-H62HCIUP.js} +6 -6
  63. package/{chunk-PZM3EENV.js → chunk-HJUYAD4A.js} +1 -1
  64. package/{chunk-A3NNC2LA.js → chunk-HOBJGHLD.js} +1235 -59
  65. package/{chunk-3JQ2NRYU.js → chunk-HVURBGF3.js} +4 -4
  66. package/{chunk-6SD5OPQ4.js → chunk-IIBAPOTQ.js} +11 -173
  67. package/{chunk-ZVN6I33J.js → chunk-IIVGDG4I.js} +6 -5
  68. package/{chunk-UDQWGU7F.js → chunk-J4MOO56S.js} +1 -1
  69. package/{chunk-KC5FAHVS.js → chunk-JEDZAO7L.js} +1 -1
  70. package/{chunk-6XIE5ZGI.js → chunk-JPGCXHNM.js} +1 -1
  71. package/chunk-JRQFUXY7.js +1625 -0
  72. package/chunk-KQ4ONNQD.js +677 -0
  73. package/{chunk-CPSZJBLK.js → chunk-L7I247DF.js} +105 -26
  74. package/{chunk-RXX4GDIH.js → chunk-LS2ZANRJ.js} +1 -1
  75. package/{chunk-BJIRLHJR.js → chunk-M2EJHDJP.js} +4 -0
  76. package/{chunk-EVBFYPDC.js → chunk-MC4XLIJ7.js} +6 -2
  77. package/{chunk-DSRXPQWA.js → chunk-NEDZDG3M.js} +43 -43
  78. package/{chunk-UJ63UXGE.js → chunk-OIVSQH2O.js} +1006 -801
  79. package/{chunk-AETZ7AD6.js → chunk-Q554LLSI.js} +1 -1
  80. package/chunk-Q5FJJ6XI.js +103 -0
  81. package/{chunk-AJHEFRGJ.js → chunk-Q67DOFOO.js} +214 -5
  82. package/{chunk-UZ6XXCVR.js → chunk-QDSINZM3.js} +15 -2
  83. package/{chunk-D6XYLSOS.js → chunk-QIAVMDHY.js} +1 -1
  84. package/{chunk-YWG6EMH3.js → chunk-RG6JBBX5.js} +10 -6
  85. package/{chunk-YXLXHIT2.js → chunk-RTUYRRBM.js} +6 -6
  86. package/{chunk-HHLTFENG.js → chunk-SDTTBMBU.js} +907 -317
  87. package/{chunk-QCZX4FTW.js → chunk-SH43IESU.js} +173 -15
  88. package/{chunk-LSZXYE64.js → chunk-SL4QHSPQ.js} +756 -80
  89. package/{chunk-FNGAF7C4.js → chunk-SNPMM7H3.js} +137 -12
  90. package/{chunk-EM6MPSEI.js → chunk-SPUTJ4DW.js} +52 -30
  91. package/{chunk-SO7B7NW3.js → chunk-STHU4Y5X.js} +413 -62
  92. package/{chunk-SPAQ4PVV.js → chunk-SV5IJK6K.js} +1 -1
  93. package/{chunk-KVDUCO4Q.js → chunk-TDRTS7QW.js} +16 -12
  94. package/{chunk-BJCWNHVU.js → chunk-TOP2VXOR.js} +2 -2
  95. package/{chunk-4EJ5QYB5.js → chunk-UKZDAFYT.js} +1 -1
  96. package/{chunk-PGSKWZCB.js → chunk-UZGQNTVW.js} +1 -1
  97. package/{chunk-ZZCJUXUI.js → chunk-V4MJDUSR.js} +2 -2
  98. package/{chunk-JYYZCK2Z.js → chunk-V7E4PXQD.js} +1 -1
  99. package/{chunk-OZX2IPKM.js → chunk-VLTIYV3X.js} +1 -1
  100. package/{chunk-NHRQCXIQ.js → chunk-VMFTFOWF.js} +13 -3
  101. package/{chunk-4UW2LDVA.js → chunk-VQW3EKYS.js} +15 -15
  102. package/{chunk-HH65VA5U.js → chunk-WGR3J4Q6.js} +101 -4
  103. package/{chunk-5J7W2VWW.js → chunk-WV42OMV7.js} +6 -265
  104. package/{chunk-Q46HQOW3.js → chunk-XTAZCQUT.js} +7 -7
  105. package/{chunk-DUJWWUGV.js → chunk-YQTQQX2H.js} +1 -1
  106. package/{chunk-BOYUESO7.js → chunk-Z77CRGTW.js} +1 -1
  107. package/{contentThunks-ENAVF2YU.js → contentThunks-D6QQKIPF.js} +25 -25
  108. package/{cooldownCommands-BSCH2W7P.js → cooldownCommands-REAWYVTY.js} +2 -2
  109. package/{createAgentAutomationAction-CH6BYC7K.js → createAgentAutomationAction-UIPWW4DG.js} +25 -25
  110. package/{createDialogAction-23UDOXSO.js → createDialogAction-573VVP3X.js} +28 -28
  111. package/{createPageAction-J6AEMLHK.js → createPageAction-LRFSS6TD.js} +26 -26
  112. package/{dbSlice-GKGGFNOB.js → dbSlice-XVWBAGYN.js} +8 -8
  113. package/{deleteFile-LWSR674W.js → deleteFile-YG6QMJLU.js} +3 -3
  114. package/{dialogCommands-BJJGCCQR.js → dialogCommands-KFK2FF5B.js} +35 -31
  115. package/{dialogSlice-F7RD6PUY.js → dialogSlice-EXLC5XTD.js} +24 -24
  116. package/{docCreateCommands-53GB2FU3.js → docCreateCommands-V777WOZ7.js} +32 -30
  117. package/{docDeleteCommands-TAW5JEBU.js → docDeleteCommands-5KHT7Z5Q.js} +33 -31
  118. package/{docReadCommands-F5N7N5E3.js → docReadCommands-BLROGWP3.js} +32 -30
  119. package/{docStore-WX4YBGXC.js → docStore-DZNGJXX7.js} +9 -9
  120. package/{docUpdateCommands-YQ7TRT35.js → docUpdateCommands-QXOZHQ5H.js} +32 -30
  121. package/{fetchMessages-DRABNDPZ.js → fetchMessages-EIU7UFFK.js} +3 -4
  122. package/{getPricing-HRMSOF3E.js → getPricing-LUSEABA6.js} +4 -4
  123. package/{handleSendMessageAction-CW4LULIR.js → handleSendMessageAction-OROTZBPO.js} +24 -24
  124. package/index.js +102 -85
  125. package/{localDialogRead-PUQKFI73.js → localDialogRead-BTFJ4V2I.js} +2 -2
  126. package/{localRuntimeDb-P37ZTX55.js → localRuntimeDb-SYQGUF4U.js} +1 -1
  127. package/{machineCommands-FIYWY5EU.js → machineCommands-IJWERHRH.js} +64 -60
  128. package/{machineWsRunDispatch-KQ4OFFNR.js → machineWsRunDispatch-XQ36M4L7.js} +62 -58
  129. package/{memberThunks-KATHH3F4.js → memberThunks-QGFLFVCI.js} +9 -9
  130. package/{models-GS72DVJS.js → models-T3SG6MJ5.js} +2 -2
  131. package/{offlineMarxistsAgentCommand-GEH6SNNA.js → offlineMarxistsAgentCommand-HGXZV4XJ.js} +1 -1
  132. package/package.json +1 -1
  133. package/providerPresetApply-FG6NZ57W.js +214 -0
  134. package/providerRegistry-757OWH3O.js +31 -0
  135. package/{read-LC6HVYBN.js → read-COE3ZYR6.js} +5 -4
  136. package/{readDocTool-N3ERJHHF.js → readDocTool-5USN4A6V.js} +1 -1
  137. package/{readlineWorkspace-QYI6BRNA.js → readlineWorkspace-EB3362L3.js} +144 -108
  138. package/{removeDialogAgentAction-F5GPTALR.js → removeDialogAgentAction-IX3MN2ZO.js} +11 -11
  139. package/{runAgentClientLoop-GZ5VUGAW.js → runAgentClientLoop-3MR2NPWR.js} +47 -47
  140. package/{runtimeDoctorCommands-CROTMULY.js → runtimeDoctorCommands-X6WDBEQX.js} +2 -2
  141. package/{setDialogExtraReferencesAction-AY4ZCF3A.js → setDialogExtraReferencesAction-X4HCPNZL.js} +9 -9
  142. package/{setPrimaryDialogAgentAction-HPMG7V3R.js → setPrimaryDialogAgentAction-4GMIQLOD.js} +11 -11
  143. package/{settingSlice-OEJA4NQO.js → settingSlice-ZQZVUPKK.js} +10 -10
  144. package/{spaceCommands-IYMIXCMC.js → spaceCommands-TIDVUPDV.js} +30 -28
  145. package/{streamAgentChatTurn-EAXIUJTK.js → streamAgentChatTurn-CLP2JWCQ.js} +59 -58
  146. package/{switchDialogAgentAction-HMDZTZ4I.js → switchDialogAgentAction-N52LRPA3.js} +8 -8
  147. package/{tableCommands-SUNTHAYX.js → tableCommands-O6NWHFKV.js} +1 -1
  148. package/{toolApiClient-VGYUB4P5.js → toolApiClient-QVJ6HDNN.js} +2 -2
  149. package/{tools-QWQOW6J4.js → tools-OXEEBABR.js} +43 -43
  150. package/tuiSummaryLlmCaller-VJY3YD2Q.js +127 -0
  151. package/{updateCommands-Y363MC3L.js → updateCommands-2M74UL7P.js} +2 -2
  152. package/{updateDialogTitleAction-2HCE2M7S.js → updateDialogTitleAction-4YWKF2OE.js} +45 -28
  153. package/agentRecordCommands-AQFYM5HS.js +0 -124
  154. package/chunk-3IT2PFHL.js +0 -611
  155. package/chunk-I42VC5KR.js +0 -15
  156. package/chunk-NG4UT4K4.js +0 -79
  157. package/codingSkills-E6KSDNSJ.js +0 -48
  158. package/tuiSummaryLlmCaller-3Z24VUWM.js +0 -116
  159. package/{chunk-3RAG2NAD.js → chunk-UKWGR5SS.js} +3 -3
  160. package/{db-VQSAOWAO.js → db-WK5MDZVN.js} +1 -1
  161. package/{localRuntimeAuthority-R5UBODT3.js → localRuntimeAuthority-6IR6BBXE.js} +3 -3
@@ -6,19 +6,146 @@ import {
6
6
  } from "./chunk-KUG52IAP.js";
7
7
 
8
8
  // packages/desktop-chrome-connector/chromeConnector.ts
9
- import { existsSync, readFileSync } from "node:fs";
10
- import { resolve } from "node:path";
9
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
10
+ import { resolve as resolve2 } from "node:path";
11
+
12
+ // packages/desktop-chrome-connector/uploadSecurity.mjs
13
+ import { existsSync, realpathSync, statSync } from "node:fs";
14
+ import { isAbsolute, relative, resolve } from "node:path";
15
+ var DEFAULT_MAX_FILE_BYTES = 25 * 1024 * 1024;
16
+ var DEFAULT_MAX_FILES = 10;
17
+ var UploadSecurityError = class extends Error {
18
+ constructor(code, message) {
19
+ super(message);
20
+ this.name = "UploadSecurityError";
21
+ this.code = code;
22
+ }
23
+ };
24
+ function createUploadSecurityError(code, message) {
25
+ return new UploadSecurityError(code, message);
26
+ }
27
+ function isSubpath(parent, child) {
28
+ const rel = relative(parent, child);
29
+ return !rel.startsWith("..") && !isAbsolute(rel);
30
+ }
31
+ function parseAllowedRoots(env = process.env) {
32
+ const raw = env?.NOLO_CHROME_UPLOAD_ROOTS;
33
+ if (!raw || typeof raw !== "string") {
34
+ return [];
35
+ }
36
+ return raw.split(",").map((entry) => entry.trim()).filter(Boolean).filter((entry) => isAbsolute(entry)).map((entry) => {
37
+ const resolved = resolve(entry);
38
+ if (existsSync(resolved)) {
39
+ try {
40
+ return realpathSync(resolved);
41
+ } catch {
42
+ return resolved;
43
+ }
44
+ }
45
+ return resolved;
46
+ });
47
+ }
48
+ function validateUploadFiles(options = {}) {
49
+ const {
50
+ files,
51
+ env = process.env,
52
+ maxFiles = DEFAULT_MAX_FILES,
53
+ maxFileBytes = DEFAULT_MAX_FILE_BYTES
54
+ } = options;
55
+ if (!Array.isArray(files) || files.length === 0) {
56
+ throw createUploadSecurityError("no_files", "Provide at least one file to upload.");
57
+ }
58
+ if (files.length > maxFiles) {
59
+ throw createUploadSecurityError(
60
+ "too_many_files",
61
+ `Too many files: ${files.length} provided, maximum allowed is ${maxFiles}.`
62
+ );
63
+ }
64
+ const allowedRoots = parseAllowedRoots(env);
65
+ if (allowedRoots.length === 0) {
66
+ throw createUploadSecurityError(
67
+ "path_not_allowed",
68
+ "Upload roots not configured in NOLO_CHROME_UPLOAD_ROOTS; all uploads are refused."
69
+ );
70
+ }
71
+ const fileStats = [];
72
+ const canonicalFiles = [];
73
+ let totalBytes = 0;
74
+ for (const rawFile of files) {
75
+ if (typeof rawFile !== "string" || !rawFile.trim()) {
76
+ throw createUploadSecurityError("path_not_allowed", "File path must be a non-empty string.");
77
+ }
78
+ const trimmed = rawFile.trim();
79
+ const resolvedCandidate = resolve(trimmed);
80
+ if (!existsSync(resolvedCandidate)) {
81
+ throw createUploadSecurityError("path_not_allowed", `File not found or inaccessible: ${rawFile}`);
82
+ }
83
+ let real;
84
+ try {
85
+ real = realpathSync(resolvedCandidate);
86
+ } catch {
87
+ throw createUploadSecurityError("path_not_allowed", `Could not resolve canonical path for: ${rawFile}`);
88
+ }
89
+ let st;
90
+ try {
91
+ st = statSync(real);
92
+ } catch {
93
+ throw createUploadSecurityError("path_not_allowed", `Could not stat file: ${rawFile}`);
94
+ }
95
+ if (!st.isFile()) {
96
+ throw createUploadSecurityError("path_not_allowed", `Target path is not a regular file: ${rawFile}`);
97
+ }
98
+ if (st.size > maxFileBytes) {
99
+ throw createUploadSecurityError(
100
+ "too_large",
101
+ `File size ${st.size} bytes exceeds maximum allowed limit of ${maxFileBytes} bytes: ${rawFile}`
102
+ );
103
+ }
104
+ const realInside = allowedRoots.some((root) => isSubpath(root, real));
105
+ if (!realInside) {
106
+ throw createUploadSecurityError(
107
+ "path_not_allowed",
108
+ `Path '${rawFile}' (resolved: '${real}') is not within allowed upload roots.`
109
+ );
110
+ }
111
+ canonicalFiles.push(real);
112
+ fileStats.push({ path: real, bytes: st.size });
113
+ totalBytes += st.size;
114
+ }
115
+ return {
116
+ ok: true,
117
+ files: canonicalFiles,
118
+ fileStats,
119
+ totalBytes
120
+ };
121
+ }
122
+ function formatUploadAuditLog(entry = {}) {
123
+ const ts = entry.timestamp || (/* @__PURE__ */ new Date()).toISOString();
124
+ const safeTabId = String(entry.tabId ?? "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
125
+ const safeTarget = String(entry.target ?? "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
126
+ const files = Array.isArray(entry.files) ? entry.files : [];
127
+ const totalBytes = files.reduce((sum, f) => sum + (Number(f.bytes) || 0), 0);
128
+ const fileDetails = files.map((f) => `${String(f.path || "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ")}(${f.bytes || 0}B)`).join(", ");
129
+ return `[chrome-upload] ${ts} tabId=${safeTabId} target=${safeTarget} files=[${fileDetails}] totalBytes=${totalBytes}`;
130
+ }
131
+ function logUploadAudit(entry, logFn = console.warn) {
132
+ const line = formatUploadAuditLog(entry);
133
+ logFn(line);
134
+ return line;
135
+ }
136
+
137
+ // packages/desktop-chrome-connector/chromeConnector.ts
11
138
  var NOLO_CHROME_CONNECTOR_EXTENSION_ID = "ahpdoopadkamnglhlacfjdfnonpjdplg";
12
139
  var NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION = "2";
13
140
  function defaultTokenPath() {
14
- return resolve(
141
+ return resolve2(
15
142
  process.env.HOME || "",
16
143
  "Library/Application Support/Nolo/ChromeConnector/token"
17
144
  );
18
145
  }
19
146
  function readConnectorToken(tokenPath = defaultTokenPath()) {
20
147
  if (process.env.NOLO_CHROME_CONNECTOR_TOKEN) return process.env.NOLO_CHROME_CONNECTOR_TOKEN;
21
- if (!existsSync(tokenPath)) return "";
148
+ if (!existsSync2(tokenPath)) return "";
22
149
  return readFileSync(tokenPath, "utf8").trim();
23
150
  }
24
151
  var CHROME_TOOL_ACTIONS = {
@@ -32,7 +159,10 @@ var CHROME_TOOL_ACTIONS = {
32
159
  chrome_scroll: "scroll",
33
160
  chrome_screenshot: "screenshot",
34
161
  chrome_read_console: "read_console",
35
- chrome_read_network: "read_network"
162
+ chrome_read_network: "read_network",
163
+ chrome_set_files: "set_files",
164
+ chrome_upload_file: "set_files",
165
+ chrome_upload: "set_files"
36
166
  };
37
167
  function createConnectorError(code, message, details) {
38
168
  const error = new Error(message);
@@ -59,8 +189,8 @@ function errorPayload(error) {
59
189
  ...error?.details !== void 0 ? { details: error.details } : {}
60
190
  };
61
191
  }
62
- var TARGET_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["click", "type"]);
63
- var TAB_ID_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["close_tab", "detach"]);
192
+ var TARGET_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["click", "type", "set_files"]);
193
+ var TAB_ID_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["close_tab", "detach", "set_files"]);
64
194
  function validateChromeConnectorPayload(action, payload) {
65
195
  if (TAB_ID_REQUIRED_ACTIONS.has(action)) {
66
196
  const raw = payload.tabId;
@@ -71,16 +201,42 @@ function validateChromeConnectorPayload(action, payload) {
71
201
  `Provide the tabId from chrome_list_tabs before calling ${action}.`
72
202
  );
73
203
  }
74
- return;
204
+ if (!TARGET_REQUIRED_ACTIONS.has(action)) return;
75
205
  }
76
206
  if (!TARGET_REQUIRED_ACTIONS.has(action)) return;
77
- const elementRef = typeof payload.elementRef === "string" ? payload.elementRef.trim() : "";
207
+ const rawRef = typeof payload.elementRef === "string" ? payload.elementRef : typeof payload.ref === "string" ? payload.ref : "";
208
+ const elementRef = rawRef.trim();
78
209
  const selector = typeof payload.selector === "string" ? payload.selector.trim() : "";
79
- if (elementRef || selector) return;
80
- throw createConnectorError(
81
- "ELEMENT_TARGET_REQUIRED",
82
- "Provide elementRef from chrome_read_page or a CSS selector."
83
- );
210
+ if (!elementRef && !selector) {
211
+ throw createConnectorError(
212
+ "ELEMENT_TARGET_REQUIRED",
213
+ "Provide elementRef from chrome_read_page or a CSS selector."
214
+ );
215
+ }
216
+ if (action === "set_files") {
217
+ if (!Array.isArray(payload.files) || payload.files.length === 0) {
218
+ throw createConnectorError(
219
+ "no_files",
220
+ "Provide at least one file path in files array."
221
+ );
222
+ }
223
+ try {
224
+ const validated = validateUploadFiles({
225
+ files: payload.files,
226
+ env: process.env
227
+ });
228
+ payload.files = validated.files;
229
+ const targetStr = elementRef ? `ref:${elementRef}` : `selector:${selector}`;
230
+ logUploadAudit({
231
+ tabId: String(payload.tabId),
232
+ target: targetStr,
233
+ files: validated.fileStats
234
+ });
235
+ } catch (err) {
236
+ const code = err?.code ?? "path_not_allowed";
237
+ throw createConnectorError(code, toErrorMessage(err));
238
+ }
239
+ }
84
240
  }
85
241
  function createChromeConnectorClient(args) {
86
242
  if (args?.request) return { request: args.request };
@@ -90,6 +246,7 @@ function createChromeConnectorClient(args) {
90
246
  const token = args?.token ?? readConnectorToken(args?.tokenPath);
91
247
  return {
92
248
  async request(action, payload) {
249
+ validateChromeConnectorPayload(action, payload);
93
250
  let response;
94
251
  try {
95
252
  response = await fetchImpl(endpoint, {
@@ -131,7 +288,8 @@ var REQUIRED_CHROME_CONNECTOR_FEATURES = {
131
288
  screenshot: ["browser_debug"],
132
289
  read_console: ["browser_debug"],
133
290
  read_network: ["browser_debug"],
134
- detach: ["browser_debug"]
291
+ detach: ["browser_debug"],
292
+ set_files: ["compact_observation_v2", "file_upload"]
135
293
  };
136
294
  function requiredFeaturesForConnectorAction(action) {
137
295
  return [...REQUIRED_CHROME_CONNECTOR_FEATURES[action] ?? []];