nolo-cli 0.74.0-alpha.2 → 0.75.0-alpha.2

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 (54) hide show
  1. package/{_executeModel-YEVZAJYX.js → _executeModel-WEZ3PEQX.js} +10 -10
  2. package/agentDeleteCommand-WVO3JTH6.js +1 -1
  3. package/{agentEmailCommands-QYQ2DZUS.js → agentEmailCommands-63LDSFLY.js} +11 -10
  4. package/agentListCommands-XWLQZ2ZH.js +1 -1
  5. package/{agentMachineCommands-BJZUZ2EY.js → agentMachineCommands-NZ7GGXDI.js} +2 -2
  6. package/{agentRecordCommands-O6PYBK2A.js → agentRecordCommands-CVYIAAA7.js} +11 -10
  7. package/{agentRunCommand-POFC5W46.js → agentRunCommand-DTSXYOFC.js} +11 -10
  8. package/{agentSlice-RRZS2UII.js → agentSlice-J6B5FD5T.js} +1 -1
  9. package/appDeleteCommands-426QK2XG.js +1 -1
  10. package/appDeployCommands-FIGFGXIJ.js +1 -1
  11. package/appDeployStatusCommands-D3B235FQ.js +1 -1
  12. package/appGetCommands-U6RZJII4.js +1 -1
  13. package/appListCommands-732PFEWM.js +1 -1
  14. package/{chatQueueReduxAdapter-LSBTGZW2.js → chatQueueReduxAdapter-7HTXKEAI.js} +2 -2
  15. package/chromeCommands-VOIRNJBL.js +499 -0
  16. package/chromeOpsCommands-M7DPCX2T.js +258 -0
  17. package/{chunk-TI4CCL34.js → chunk-2BA5B35E.js} +3 -3
  18. package/{chunk-I4UWPYBH.js → chunk-3WR7AKML.js} +2 -2
  19. package/{chunk-SJTCDYBY.js → chunk-6ULAXDTC.js} +5 -5
  20. package/{chunk-VOEW2KF3.js → chunk-6VHEHZ3O.js} +8 -8
  21. package/{chunk-XPQJXIF5.js → chunk-73Z4HXBB.js} +43 -4
  22. package/{chunk-CS36XM4N.js → chunk-7SM7OIAA.js} +3 -3
  23. package/{chunk-HSELVGAL.js → chunk-CB4TPLND.js} +1 -1
  24. package/{chunk-DFY6PUV4.js → chunk-DORA6JDU.js} +5 -5
  25. package/{chunk-2JCTE5UN.js → chunk-ESNV5ZH6.js} +2 -2
  26. package/{chunk-AWPU7GXU.js → chunk-GKCVKZMJ.js} +2 -2
  27. package/{chunk-VE3O45CJ.js → chunk-IHHZ5QIT.js} +2 -2
  28. package/{chunk-QBA5KMJI.js → chunk-KTCEAOB7.js} +22 -8
  29. package/{chunk-57VRXRLF.js → chunk-OCIRWOJN.js} +1 -1
  30. package/chunk-QCZX4FTW.js +242 -0
  31. package/{chunk-XGZM6BTX.js → chunk-X4J6SLM7.js} +59 -119
  32. package/{contentThunks-476Y6CFR.js → contentThunks-YTGI4QHN.js} +3 -3
  33. package/{createAgentAutomationAction-DN4SFTP5.js → createAgentAutomationAction-NKJB4ZUJ.js} +3 -3
  34. package/{createDialogAction-2GS4JCMU.js → createDialogAction-46TNX2KI.js} +4 -4
  35. package/{createPageAction-44WTUMZ5.js → createPageAction-XKCTX2L5.js} +3 -3
  36. package/dialogCommands-7FH6Z2YK.js +1 -1
  37. package/{dialogSlice-7HEVCJFT.js → dialogSlice-IA4AYIZT.js} +2 -2
  38. package/docCreateCommands-GN5E5ULM.js +1 -1
  39. package/docDeleteCommands-OQWPPQME.js +1 -1
  40. package/docReadCommands-E4QK2223.js +1 -1
  41. package/{docStore-LJ7KNKFB.js → docStore-BTPXEBOF.js} +1 -1
  42. package/docUpdateCommands-ZDJE4SI7.js +1 -1
  43. package/{handleSendMessageAction-ETA5QZIN.js → handleSendMessageAction-EVLVKKX5.js} +2 -2
  44. package/index.js +75 -15
  45. package/{machineCommands-SJLMLCCV.js → machineCommands-6IEXOQSE.js} +11 -10
  46. package/{machineWsRunDispatch-74GHVCNY.js → machineWsRunDispatch-Y6X7MZZT.js} +11 -10
  47. package/package.json +1 -1
  48. package/{readlineWorkspace-XHS5C5F7.js → readlineWorkspace-XKMEZZ5A.js} +11 -10
  49. package/{runAgentClientLoop-2PGZSCET.js → runAgentClientLoop-3XIXREHM.js} +8 -8
  50. package/spaceCommands-GSQCO2LI.js +1 -1
  51. package/{streamAgentChatTurn-I6FUM6RV.js → streamAgentChatTurn-J27A54UC.js} +9 -9
  52. package/{tools-KU4X5HGZ.js → tools-CZTAI4BF.js} +6 -6
  53. package/{updateDialogTitleAction-E3SNB75W.js → updateDialogTitleAction-QUU6G7SD.js} +3 -3
  54. package/{agentRuntimeLocal-O6DZDTK4.js → agentRuntimeLocal-ZSUEMWRL.js} +1 -1
@@ -81,14 +81,14 @@ import {
81
81
  } from "./chunk-VF4K2QE6.js";
82
82
  import {
83
83
  createDocState
84
- } from "./chunk-AWPU7GXU.js";
84
+ } from "./chunk-GKCVKZMJ.js";
85
85
  import {
86
86
  BUILTIN_OBJECT_SKILL_IDS,
87
87
  buildBuiltinObjectSkillConfig,
88
88
  buildBuiltinObjectSkillDbKey,
89
89
  buildBuiltinObjectSkillPageContent,
90
90
  createDialogAction
91
- } from "./chunk-2JCTE5UN.js";
91
+ } from "./chunk-ESNV5ZH6.js";
92
92
  import {
93
93
  DEFAULT_COLLAPSED_CATEGORIES,
94
94
  addContentToSpace,
@@ -106,7 +106,7 @@ import {
106
106
  updateContentCategory,
107
107
  updateContentTitle,
108
108
  writeStoredCollapsedCategories
109
- } from "./chunk-XGZM6BTX.js";
109
+ } from "./chunk-X4J6SLM7.js";
110
110
  import {
111
111
  getCurrentSpaceId,
112
112
  getCurrentSpaceIdRaw,
@@ -128,14 +128,14 @@ import {
128
128
  selectMsgById,
129
129
  uiAskChoiceFunc,
130
130
  uiAskChoiceFunctionSchema
131
- } from "./chunk-VOEW2KF3.js";
131
+ } from "./chunk-6VHEHZ3O.js";
132
132
  import {
133
133
  createAgent,
134
134
  deleteServerSyncedCredential,
135
135
  runLlm,
136
136
  streamAgentChatTurn,
137
137
  updateAgent
138
- } from "./chunk-TI4CCL34.js";
138
+ } from "./chunk-2BA5B35E.js";
139
139
  import {
140
140
  getActiveDialogKey,
141
141
  selectCurrentDialogKey,
@@ -4672,7 +4672,7 @@ async function deleteDialogsFunc(args, thunkApi) {
4672
4672
  const deletedDialogIds = [];
4673
4673
  const deletedDialogKeys = [];
4674
4674
  const failures = [];
4675
- const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-7HEVCJFT.js");
4675
+ const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-IA4AYIZT.js");
4676
4676
  for (const target of targets) {
4677
4677
  try {
4678
4678
  await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
@@ -9933,6 +9933,19 @@ ${preview}`
9933
9933
  }
9934
9934
 
9935
9935
  // packages/ai/tools/chromeConnectorTools.ts
9936
+ var CHROME_CONNECTOR_TOOL_NAMES = [
9937
+ "chrome_list_tabs",
9938
+ "chrome_open_tab",
9939
+ "chrome_close_tab",
9940
+ "chrome_read_page",
9941
+ "chrome_click",
9942
+ "chrome_type",
9943
+ "chrome_press",
9944
+ "chrome_scroll",
9945
+ "chrome_screenshot",
9946
+ "chrome_read_console",
9947
+ "chrome_read_network"
9948
+ ];
9936
9949
  var CHROME_CONNECTOR_READ_TOOL_NAMES = [
9937
9950
  "chrome_list_tabs",
9938
9951
  "chrome_read_page",
@@ -15533,7 +15546,7 @@ var executeToolRun = createAsyncThunk(
15533
15546
  if (!executionInput) {
15534
15547
  throw new Error(`ToolRun ${id} has no input to execute with.`);
15535
15548
  }
15536
- const { findToolExecutor: findToolExecutor2 } = await import("./tools-KU4X5HGZ.js");
15549
+ const { findToolExecutor: findToolExecutor2 } = await import("./tools-CZTAI4BF.js");
15537
15550
  const { executor } = findToolExecutor2(run.toolName);
15538
15551
  toolRunStarted({
15539
15552
  id: run.id,
@@ -18040,7 +18053,7 @@ async function updateDocFunc(args, thunkApi) {
18040
18053
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
18041
18054
  };
18042
18055
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
18043
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-LJ7KNKFB.js");
18056
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-BTPXEBOF.js");
18044
18057
  if (getDocState().pageKey === id) {
18045
18058
  applyExternalDocUpdate({
18046
18059
  slateData: finalSlateData,
@@ -20343,6 +20356,7 @@ export {
20343
20356
  readXPostFunc,
20344
20357
  readXhsProfileFunctionSchema,
20345
20358
  readXhsProfileFunc,
20359
+ CHROME_CONNECTOR_TOOL_NAMES,
20346
20360
  rememberMemoryFunctionSchema,
20347
20361
  deleteMemoryFunctionSchema,
20348
20362
  queryMemoryFunctionSchema,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-CS36XM4N.js";
4
+ } from "./chunk-7SM7OIAA.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {
@@ -0,0 +1,242 @@
1
+ import {
2
+ toErrorMessage
3
+ } from "./chunk-HNMXYYJR.js";
4
+ import {
5
+ isRecord
6
+ } from "./chunk-KUG52IAP.js";
7
+
8
+ // packages/desktop-chrome-connector/chromeConnector.ts
9
+ import { existsSync, readFileSync } from "node:fs";
10
+ import { resolve } from "node:path";
11
+ var NOLO_CHROME_CONNECTOR_EXTENSION_ID = "ahpdoopadkamnglhlacfjdfnonpjdplg";
12
+ var NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION = "2";
13
+ function defaultTokenPath() {
14
+ return resolve(
15
+ process.env.HOME || "",
16
+ "Library/Application Support/Nolo/ChromeConnector/token"
17
+ );
18
+ }
19
+ function readConnectorToken(tokenPath = defaultTokenPath()) {
20
+ if (process.env.NOLO_CHROME_CONNECTOR_TOKEN) return process.env.NOLO_CHROME_CONNECTOR_TOKEN;
21
+ if (!existsSync(tokenPath)) return "";
22
+ return readFileSync(tokenPath, "utf8").trim();
23
+ }
24
+ var CHROME_TOOL_ACTIONS = {
25
+ chrome_list_tabs: "list_tabs",
26
+ chrome_open_tab: "open_tab",
27
+ chrome_close_tab: "close_tab",
28
+ chrome_read_page: "read_page",
29
+ chrome_click: "click",
30
+ chrome_type: "type",
31
+ chrome_press: "press",
32
+ chrome_scroll: "scroll",
33
+ chrome_screenshot: "screenshot",
34
+ chrome_read_console: "read_console",
35
+ chrome_read_network: "read_network"
36
+ };
37
+ function createConnectorError(code, message, details) {
38
+ const error = new Error(message);
39
+ error.code = code;
40
+ if (details !== void 0) error.details = details;
41
+ return error;
42
+ }
43
+ function parseArguments(raw) {
44
+ try {
45
+ const parsed = JSON.parse(raw || "{}");
46
+ if (!isRecord(parsed)) {
47
+ throw createConnectorError("INVALID_ARGUMENTS", "Chrome connector tool arguments must be a JSON object.");
48
+ }
49
+ return parsed;
50
+ } catch (error) {
51
+ if (error.code) throw error;
52
+ throw createConnectorError("INVALID_ARGUMENTS", "Chrome connector tool arguments must be valid JSON.");
53
+ }
54
+ }
55
+ function errorPayload(error) {
56
+ return {
57
+ code: error?.code ?? "CHROME_CONNECTOR_ERROR",
58
+ message: toErrorMessage(error),
59
+ ...error?.details !== void 0 ? { details: error.details } : {}
60
+ };
61
+ }
62
+ var TARGET_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["click", "type"]);
63
+ var TAB_ID_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["close_tab", "detach"]);
64
+ function validateChromeConnectorPayload(action, payload) {
65
+ if (TAB_ID_REQUIRED_ACTIONS.has(action)) {
66
+ const raw = payload.tabId;
67
+ const tabId = typeof raw === "string" ? raw.trim() : typeof raw === "number" && Number.isFinite(raw) ? String(raw) : "";
68
+ if (!tabId) {
69
+ throw createConnectorError(
70
+ "TAB_ID_REQUIRED",
71
+ `Provide the tabId from chrome_list_tabs before calling ${action}.`
72
+ );
73
+ }
74
+ return;
75
+ }
76
+ if (!TARGET_REQUIRED_ACTIONS.has(action)) return;
77
+ const elementRef = typeof payload.elementRef === "string" ? payload.elementRef.trim() : "";
78
+ 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
+ );
84
+ }
85
+ function createChromeConnectorClient(args) {
86
+ if (args?.request) return { request: args.request };
87
+ const defaultPort = process.env.NOLO_CHROME_CONNECTOR_PORT || "38947";
88
+ const endpoint = args?.endpoint ?? process.env.NOLO_CHROME_CONNECTOR_RPC_URL ?? `http://127.0.0.1:${defaultPort}/rpc`;
89
+ const fetchImpl = args?.fetchImpl ?? fetch;
90
+ const token = args?.token ?? readConnectorToken(args?.tokenPath);
91
+ return {
92
+ async request(action, payload) {
93
+ let response;
94
+ try {
95
+ response = await fetchImpl(endpoint, {
96
+ method: "POST",
97
+ headers: {
98
+ "Content-Type": "application/json",
99
+ ...token ? { "X-Nolo-Chrome-Connector-Token": token } : {}
100
+ },
101
+ body: JSON.stringify({ action, payload })
102
+ });
103
+ } catch (error) {
104
+ throw createConnectorError(
105
+ "CHROME_CONNECTOR_UNAVAILABLE",
106
+ `Chrome connector RPC endpoint is unavailable at ${endpoint}.`,
107
+ { cause: toErrorMessage(error) }
108
+ );
109
+ }
110
+ const data = await response.json().catch(() => ({}));
111
+ if (!response.ok || data?.ok === false) {
112
+ throw createConnectorError(
113
+ typeof data?.error?.code === "string" ? data.error.code : "CHROME_CONNECTOR_RPC_ERROR",
114
+ typeof data?.error?.message === "string" ? data.error.message : `Chrome connector RPC failed with HTTP ${response.status}.`,
115
+ data?.error?.details
116
+ );
117
+ }
118
+ return data?.result;
119
+ }
120
+ };
121
+ }
122
+ var REQUIRED_CHROME_CONNECTOR_FEATURES = {
123
+ list_tabs: ["tabs"],
124
+ open_tab: ["tabs"],
125
+ close_tab: ["tabs"],
126
+ read_page: ["compact_observation_v2"],
127
+ click: ["compact_observation_v2", "action_gate"],
128
+ type: ["compact_observation_v2", "action_gate"],
129
+ press: ["compact_observation_v2", "action_gate"],
130
+ scroll: ["compact_observation_v2"],
131
+ screenshot: ["browser_debug"],
132
+ read_console: ["browser_debug"],
133
+ read_network: ["browser_debug"],
134
+ detach: ["browser_debug"]
135
+ };
136
+ function requiredFeaturesForConnectorAction(action) {
137
+ return [...REQUIRED_CHROME_CONNECTOR_FEATURES[action] ?? []];
138
+ }
139
+ function createVerifiedChromeConnectorClient(args) {
140
+ const client = args?.client ?? createChromeConnectorClient();
141
+ const expectedExtensionId = args?.expectedExtensionId ?? NOLO_CHROME_CONNECTOR_EXTENSION_ID;
142
+ let verified = null;
143
+ let negotiatedFeatures = [];
144
+ const verify = async () => {
145
+ const connectorInfo = await client.request("connector_info", {});
146
+ const receivedExtensionId = connectorInfo?.extensionId;
147
+ if (receivedExtensionId !== expectedExtensionId) {
148
+ throw createConnectorError(
149
+ "CHROME_CONNECTOR_EXTENSION_MISMATCH",
150
+ `Chrome connector extension id mismatch: expected ${expectedExtensionId}, received ${typeof receivedExtensionId === "string" ? receivedExtensionId : "unknown"}.`,
151
+ { expectedExtensionId, receivedExtensionId }
152
+ );
153
+ }
154
+ const receivedProtocolVersion = connectorInfo?.protocolVersion;
155
+ if (receivedProtocolVersion !== NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION) {
156
+ throw createConnectorError(
157
+ "CHROME_CONNECTOR_PROTOCOL_MISMATCH",
158
+ `Chrome connector protocol mismatch: expected ${NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION}, received ${typeof receivedProtocolVersion === "string" ? receivedProtocolVersion : "unknown"}. Reload the Nolo Desktop Chrome Connector extension.`,
159
+ {
160
+ expectedProtocolVersion: NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION,
161
+ receivedProtocolVersion
162
+ }
163
+ );
164
+ }
165
+ const rawFeatures = connectorInfo?.features;
166
+ negotiatedFeatures = Array.isArray(rawFeatures) ? rawFeatures.filter((entry) => typeof entry === "string") : [];
167
+ };
168
+ return {
169
+ async request(action, payload) {
170
+ verified ??= verify().catch((error) => {
171
+ verified = null;
172
+ throw error;
173
+ });
174
+ await verified;
175
+ const missing = requiredFeaturesForConnectorAction(action).filter(
176
+ (feature) => !negotiatedFeatures.includes(feature)
177
+ );
178
+ if (missing.length > 0) {
179
+ throw createConnectorError(
180
+ "CAPABILITY_UNSUPPORTED",
181
+ `The installed Nolo Browser Connector extension does not support ${missing.join(", ")} (needed by ${action}). Reload or update the extension, then try again.`,
182
+ { action, missingFeatures: missing, requiredFeatures: requiredFeaturesForConnectorAction(action), features: [...negotiatedFeatures] }
183
+ );
184
+ }
185
+ return client.request(action, payload);
186
+ },
187
+ features() {
188
+ return [...negotiatedFeatures];
189
+ }
190
+ };
191
+ }
192
+ async function executeChromeConnectorTool(args) {
193
+ const action = CHROME_TOOL_ACTIONS[args.call.name];
194
+ if (!action) {
195
+ return {
196
+ content: JSON.stringify({
197
+ ok: false,
198
+ error: {
199
+ code: "UNKNOWN_CHROME_TOOL",
200
+ message: `Unknown Chrome connector tool: ${args.call.name}`
201
+ }
202
+ }),
203
+ metadata: {
204
+ chromeConnector: true,
205
+ error: true,
206
+ code: "UNKNOWN_CHROME_TOOL"
207
+ }
208
+ };
209
+ }
210
+ try {
211
+ const payload = parseArguments(args.call.arguments);
212
+ validateChromeConnectorPayload(action, payload);
213
+ const result = await (args.client ?? createChromeConnectorClient()).request(action, payload);
214
+ return {
215
+ content: JSON.stringify({ ok: true, result }),
216
+ metadata: {
217
+ chromeConnector: true,
218
+ action
219
+ }
220
+ };
221
+ } catch (error) {
222
+ const payload = errorPayload(error);
223
+ return {
224
+ content: JSON.stringify({ ok: false, error: payload }),
225
+ metadata: {
226
+ chromeConnector: true,
227
+ error: true,
228
+ code: payload.code
229
+ }
230
+ };
231
+ }
232
+ }
233
+ var CHROME_CONNECTOR_TOOL_ACTIONS = { ...CHROME_TOOL_ACTIONS };
234
+
235
+ export {
236
+ NOLO_CHROME_CONNECTOR_EXTENSION_ID,
237
+ NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION,
238
+ createChromeConnectorClient,
239
+ REQUIRED_CHROME_CONNECTOR_FEATURES,
240
+ createVerifiedChromeConnectorClient,
241
+ executeChromeConnectorTool
242
+ };
@@ -9,7 +9,7 @@ import {
9
9
  initReactI18next,
10
10
  instance,
11
11
  toast
12
- } from "./chunk-VOEW2KF3.js";
12
+ } from "./chunk-6VHEHZ3O.js";
13
13
  import {
14
14
  require_date_fns
15
15
  } from "./chunk-M76ECQRD.js";
@@ -72,7 +72,8 @@ import {
72
72
  scheduleWriteReplication
73
73
  } from "./chunk-3RAG2NAD.js";
74
74
  import {
75
- createClientLogger
75
+ createClientLogger,
76
+ isAbortError
76
77
  } from "./chunk-QOKAKDPE.js";
77
78
  import {
78
79
  selectIdentityUserId
@@ -102,6 +103,7 @@ var import_date_fns2 = __toESM(require_date_fns(), 1);
102
103
  import { ulid as ulid3 } from "ulid";
103
104
 
104
105
  // packages/render/table/fetchAndCacheTableRows.ts
106
+ var TABLE_ROWS_FETCH_TIMEOUT_MS = 5e3;
105
107
  var getRowTimestamp = (row) => {
106
108
  if (!row || typeof row !== "object") return 0;
107
109
  return asOptionalPositiveFiniteNumber(Date.parse(row.updatedAt ?? "")) ?? asOptionalPositiveFiniteNumber(Date.parse(row.createdAt ?? "")) ?? 0;
@@ -155,46 +157,63 @@ var loadLocalTableRows = async (db, tenantId, tableId) => {
155
157
  }
156
158
  return rows;
157
159
  };
158
- var fetchTableRowsFromServer = async (server, tenantId, tableId, headers) => {
159
- const res = await fetch(`${server}/rpc/listTableRows`, {
160
- method: "POST",
161
- headers,
162
- body: JSON.stringify({
163
- tenantId,
164
- tableId,
165
- includeDeleted: true,
166
- envelope: TABLE_SYNC_ENVELOPE
167
- })
168
- });
169
- if (!res.ok) {
170
- let msg = `\u52A0\u8F7D\u8868 ${tableId} \u884C\u5931\u8D25\uFF08${res.status}\uFF09`;
171
- try {
172
- const err2 = await res.json();
173
- if (err2 && typeof err2.message === "string") {
174
- msg = err2.message;
160
+ var fetchTableRowsFromServer = async (server, tenantId, tableId, headers, fetchImpl = fetch) => {
161
+ const controller = new AbortController();
162
+ const timeoutId = setTimeout(
163
+ () => controller.abort(),
164
+ TABLE_ROWS_FETCH_TIMEOUT_MS
165
+ );
166
+ try {
167
+ const res = await fetchImpl(`${server}/rpc/listTableRows`, {
168
+ method: "POST",
169
+ headers,
170
+ body: JSON.stringify({
171
+ tenantId,
172
+ tableId,
173
+ includeDeleted: true,
174
+ envelope: TABLE_SYNC_ENVELOPE
175
+ }),
176
+ signal: controller.signal
177
+ });
178
+ if (!res.ok) {
179
+ let msg = `\u52A0\u8F7D\u8868 ${tableId} \u884C\u5931\u8D25\uFF08${res.status}\uFF09`;
180
+ try {
181
+ const err2 = await res.json();
182
+ if (err2 && typeof err2.message === "string") {
183
+ msg = err2.message;
184
+ }
185
+ } catch {
175
186
  }
176
- } catch {
187
+ throw new Error(msg);
188
+ }
189
+ const data = await res.json();
190
+ if (Array.isArray(data)) {
191
+ return {
192
+ rows: data,
193
+ deletedRows: [],
194
+ tableMeta: null,
195
+ complete: false
196
+ };
197
+ }
198
+ if (!data || typeof data !== "object" || !Array.isArray(data.rows)) {
199
+ throw new Error("\u670D\u52A1\u5668\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\uFF1A\u9884\u671F\u4E3A\u6570\u7EC4");
177
200
  }
178
- throw new Error(msg);
179
- }
180
- const data = await res.json();
181
- if (Array.isArray(data)) {
182
201
  return {
183
- rows: data,
184
- deletedRows: [],
185
- tableMeta: null,
186
- complete: false
202
+ rows: data.rows,
203
+ deletedRows: Array.isArray(data.deletedRows) ? data.deletedRows : [],
204
+ tableMeta: data.tableMeta ?? null,
205
+ complete: data.complete === true
187
206
  };
207
+ } catch (err2) {
208
+ if (isAbortError(err2)) {
209
+ throw new Error(
210
+ `\u52A0\u8F7D\u8868 ${tableId} \u884C\u8D85\u65F6\uFF1A${server} \u5728 ${TABLE_ROWS_FETCH_TIMEOUT_MS / 1e3}s \u5185\u65E0\u54CD\u5E94`
211
+ );
212
+ }
213
+ throw err2;
214
+ } finally {
215
+ clearTimeout(timeoutId);
188
216
  }
189
- if (!data || typeof data !== "object" || !Array.isArray(data.rows)) {
190
- throw new Error("\u670D\u52A1\u5668\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\uFF1A\u9884\u671F\u4E3A\u6570\u7EC4");
191
- }
192
- return {
193
- rows: data.rows,
194
- deletedRows: Array.isArray(data.deletedRows) ? data.deletedRows : [],
195
- tableMeta: data.tableMeta ?? null,
196
- complete: data.complete === true
197
- };
198
217
  };
199
218
  var cacheMergedTableRows = async (db, mergedRows) => {
200
219
  if (!db) return;
@@ -252,7 +271,8 @@ var fetchAndCacheTableRows = async ({
252
271
  tenantId,
253
272
  tableId,
254
273
  token,
255
- remoteServers = []
274
+ remoteServers = [],
275
+ fetchImpl = fetch
256
276
  }) => {
257
277
  const headers = {
258
278
  "Content-Type": "application/json"
@@ -263,7 +283,7 @@ var fetchAndCacheTableRows = async ({
263
283
  const localRows = await loadLocalTableRows(db, tenantId, tableId);
264
284
  const remoteResults = await Promise.allSettled(
265
285
  remoteServers.map(
266
- (server) => fetchTableRowsFromServer(server, tenantId, tableId, headers)
286
+ (server) => fetchTableRowsFromServer(server, tenantId, tableId, headers, fetchImpl)
267
287
  )
268
288
  );
269
289
  const fulfilledRemoteSnapshots = remoteResults.filter(
@@ -367,43 +387,6 @@ function reorderColumnInMeta(meta, input, deps) {
367
387
  buildMeta(meta, reorderList(meta.columns, fromIndex, toIndex), deps.nowIso)
368
388
  );
369
389
  }
370
- function renameColumnInMeta(meta, rows, input, deps) {
371
- const { oldName } = input;
372
- const { nowIso } = deps;
373
- const newName = input.newName.trim();
374
- if (!newName) {
375
- return err("\u65B0\u7684\u5B57\u6BB5\u540D\u4E0D\u80FD\u4E3A\u7A7A");
376
- }
377
- if (!meta.columns.some((c) => c.name === oldName)) {
378
- return err(`\u5B57\u6BB5 ${oldName} \u4E0D\u5B58\u5728`);
379
- }
380
- if (meta.columns.some((c) => c.name === newName)) {
381
- return err(`\u5B57\u6BB5 ${newName} \u5DF2\u5B58\u5728`);
382
- }
383
- const newColumns = meta.columns.map(
384
- (c) => c.name === oldName ? { ...c, name: newName } : c
385
- );
386
- const rowPatches = rows.filter((row) => hasOwn(row, oldName)).map((row) => ({
387
- dbKey: row.dbKey,
388
- changes: {
389
- [newName]: row[oldName],
390
- [oldName]: null,
391
- updatedAt: nowIso
392
- }
393
- }));
394
- const newRows = rows.map((row) => {
395
- if (!hasOwn(row, oldName)) {
396
- return row;
397
- }
398
- const { [oldName]: oldValue, ...rest } = row;
399
- return { ...rest, [newName]: oldValue, updatedAt: nowIso };
400
- });
401
- return ok({
402
- ...buildMeta(meta, newColumns, nowIso),
403
- rows: newRows,
404
- rowPatches
405
- });
406
- }
407
390
  function renameColumnLabelInMeta(meta, input, deps) {
408
391
  const { columnId } = input;
409
392
  const label = input.label.trim();
@@ -1189,49 +1172,6 @@ var reorderColumn = createTableCommand(
1189
1172
  }
1190
1173
  }
1191
1174
  );
1192
- var renameColumn = createTableCommand(
1193
- "table/renameColumn",
1194
- async (args, { dispatch } = {}) => {
1195
- const { tenantId, tableId, oldName, newName } = args;
1196
- const meta = state.currentTable;
1197
- if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
1198
- throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
1199
- }
1200
- const result = renameColumnInMeta(
1201
- meta,
1202
- state.rows,
1203
- { oldName, newName },
1204
- { nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
1205
- );
1206
- if (!result.ok) {
1207
- throw new Error(result.error);
1208
- }
1209
- const { meta: nextMeta, metaChanges, rows: newRows, rowPatches } = result.value;
1210
- setState((s) => ({ ...s, error: null }));
1211
- try {
1212
- if (dispatch) {
1213
- await Promise.all(
1214
- rowPatches.map((p) => safeDispatch(dispatch, patch(p)))
1215
- );
1216
- await safeDispatch(
1217
- dispatch,
1218
- patch({ dbKey: meta.dbKey, changes: metaChanges })
1219
- );
1220
- }
1221
- setState((s) => ({
1222
- ...s,
1223
- currentTable: nextMeta,
1224
- rows: newRows,
1225
- isInitialized: true
1226
- }));
1227
- return { meta: nextMeta, rows: newRows };
1228
- } catch (e) {
1229
- const msg = e?.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u5931\u8D25";
1230
- setState((s) => ({ ...s, error: msg }));
1231
- throw e;
1232
- }
1233
- }
1234
- );
1235
1175
  var renameColumnLabel = createTableCommand(
1236
1176
  "table/renameColumnLabel",
1237
1177
  async (args, { dispatch } = {}) => {
@@ -7,14 +7,14 @@ import {
7
7
  updateContentPinned,
8
8
  updateContentTitle,
9
9
  uploadAndAddFileToSpace
10
- } from "./chunk-XGZM6BTX.js";
10
+ } from "./chunk-X4J6SLM7.js";
11
11
  import "./chunk-ZJ7UHBJS.js";
12
- import "./chunk-VOEW2KF3.js";
12
+ import "./chunk-6VHEHZ3O.js";
13
13
  import "./chunk-EVBFYPDC.js";
14
14
  import "./chunk-HQUORJTM.js";
15
15
  import "./chunk-YYLHWIW6.js";
16
16
  import "./chunk-AGGIDPCZ.js";
17
- import "./chunk-TI4CCL34.js";
17
+ import "./chunk-2BA5B35E.js";
18
18
  import "./chunk-BJCWNHVU.js";
19
19
  import "./chunk-5RGU3J7P.js";
20
20
  import "./chunk-6YTOJY35.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-XGZM6BTX.js";
3
+ } from "./chunk-X4J6SLM7.js";
4
4
  import "./chunk-ZJ7UHBJS.js";
5
- import "./chunk-VOEW2KF3.js";
5
+ import "./chunk-6VHEHZ3O.js";
6
6
  import "./chunk-EVBFYPDC.js";
7
7
  import "./chunk-HQUORJTM.js";
8
8
  import "./chunk-YYLHWIW6.js";
9
9
  import "./chunk-AGGIDPCZ.js";
10
- import "./chunk-TI4CCL34.js";
10
+ import "./chunk-2BA5B35E.js";
11
11
  import "./chunk-BJCWNHVU.js";
12
12
  import "./chunk-5RGU3J7P.js";
13
13
  import "./chunk-6YTOJY35.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  createDialogAction,
3
3
  isLocalOwnerDialogAgents
4
- } from "./chunk-2JCTE5UN.js";
5
- import "./chunk-XGZM6BTX.js";
4
+ } from "./chunk-ESNV5ZH6.js";
5
+ import "./chunk-X4J6SLM7.js";
6
6
  import "./chunk-ZJ7UHBJS.js";
7
- import "./chunk-VOEW2KF3.js";
7
+ import "./chunk-6VHEHZ3O.js";
8
8
  import "./chunk-EVBFYPDC.js";
9
9
  import "./chunk-HQUORJTM.js";
10
10
  import "./chunk-YYLHWIW6.js";
11
11
  import "./chunk-AGGIDPCZ.js";
12
- import "./chunk-TI4CCL34.js";
12
+ import "./chunk-2BA5B35E.js";
13
13
  import "./chunk-BJCWNHVU.js";
14
14
  import "./chunk-5RGU3J7P.js";
15
15
  import "./chunk-6YTOJY35.js";
@@ -14,16 +14,16 @@ import {
14
14
  import {
15
15
  addContentToSpace,
16
16
  client_default
17
- } from "./chunk-XGZM6BTX.js";
17
+ } from "./chunk-X4J6SLM7.js";
18
18
  import {
19
19
  getCurrentSpaceId
20
20
  } from "./chunk-ZJ7UHBJS.js";
21
- import "./chunk-VOEW2KF3.js";
21
+ import "./chunk-6VHEHZ3O.js";
22
22
  import "./chunk-EVBFYPDC.js";
23
23
  import "./chunk-HQUORJTM.js";
24
24
  import "./chunk-YYLHWIW6.js";
25
25
  import "./chunk-AGGIDPCZ.js";
26
- import "./chunk-TI4CCL34.js";
26
+ import "./chunk-2BA5B35E.js";
27
27
  import "./chunk-BJCWNHVU.js";
28
28
  import "./chunk-5RGU3J7P.js";
29
29
  import "./chunk-6YTOJY35.js";
@@ -24,8 +24,8 @@ import "./chunk-HQUORJTM.js";
24
24
  import "./chunk-URMS4XY2.js";
25
25
  import "./chunk-GLKOYSRU.js";
26
26
  import "./chunk-CJ23A7U4.js";
27
- import "./chunk-HXAINXPQ.js";
28
27
  import "./chunk-ZNFJWEN4.js";
28
+ import "./chunk-HXAINXPQ.js";
29
29
  import "./chunk-KIS76A2P.js";
30
30
  import "./chunk-2QDDKFG5.js";
31
31
  import "./chunk-N7J63Q6C.js";
@@ -20,12 +20,12 @@ import {
20
20
  switchDialogAgent,
21
21
  updateDialogTitle,
22
22
  updateTokens
23
- } from "./chunk-VOEW2KF3.js";
23
+ } from "./chunk-6VHEHZ3O.js";
24
24
  import "./chunk-EVBFYPDC.js";
25
25
  import "./chunk-HQUORJTM.js";
26
26
  import "./chunk-YYLHWIW6.js";
27
27
  import "./chunk-AGGIDPCZ.js";
28
- import "./chunk-TI4CCL34.js";
28
+ import "./chunk-2BA5B35E.js";
29
29
  import "./chunk-BJCWNHVU.js";
30
30
  import {
31
31
  getActiveDialogAgentId