twenty-sdk 2.56.0 → 2.57.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.
@@ -49,21 +49,21 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
49
49
  }, m = {
50
50
  user: "USER",
51
51
  workspace: "WORKSPACE"
52
- }, h = "TWENTY_API_URL", ee = "TWENTY_APP_ACCESS_TOKEN", g = "TWENTY_APP_APPLICATION_ACCESS_TOKEN", _ = {
52
+ }, h = "TWENTY_API_URL", ee = "TWENTY_APP_ACCESS_TOKEN", g = "TWENTY_APP_APPLICATION_ACCESS_TOKEN", te = {
53
53
  USER: "user",
54
54
  WORKSPACE: "workspace"
55
- }, v = (e) => ({
55
+ }, _ = (e) => ({
56
56
  ...e,
57
- visibility: _[e.scope]
58
- }), te = () => process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN ?? process.env.TWENTY_APP_ACCESS_TOKEN, ne = () => process.env.TWENTY_APP_ACCESS_TOKEN ?? process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN, y = ({ caller: e, isActingAsCaller: n = !1 }) => {
59
- let r = process.env[h], i = n ? ne() : te();
57
+ visibility: te[e.scope]
58
+ }), ne = () => process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN ?? process.env.TWENTY_APP_ACCESS_TOKEN, re = () => process.env.TWENTY_APP_ACCESS_TOKEN ?? process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN, v = ({ caller: e, isActingAsCaller: n = !1 }) => {
59
+ let r = process.env[h], i = n ? re() : ne();
60
60
  if (!t(r) || !t(i)) throw Error(`${e}() requires the app runtime env vars ${h} and ${g} (or ${ee}).`);
61
61
  return {
62
62
  apiUrl: r,
63
63
  accessToken: i
64
64
  };
65
- }, b = async ({ query: e, variables: t, caller: n, signal: r, isActingAsCaller: i = !1 }) => {
66
- let { apiUrl: a, accessToken: o } = y({
65
+ }, y = async ({ query: e, variables: t, caller: n, signal: r, isActingAsCaller: i = !1 }) => {
66
+ let { apiUrl: a, accessToken: o } = v({
67
67
  caller: n,
68
68
  isActingAsCaller: i
69
69
  }), s = await fetch(`${a}/metadata`, {
@@ -83,16 +83,16 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
83
83
  if (c.errors && c.errors.length > 0) throw Error(`${n}() failed: ${c.errors.map((e) => e.message).join(", ")}`);
84
84
  if (!c.data) throw Error(`${n}() failed: response contained no data.`);
85
85
  return c.data;
86
- }, x = "\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n externalAccountId\n scope\n userWorkspaceId\n workspaceMemberId\n providerType\n accessToken\n scopes\n authFailedAt\n authFailedReason\n }\n }\n", re = async (e) => {
87
- let { appConnection: t } = await b({
88
- query: x,
86
+ }, ie = "\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n externalAccountId\n scope\n userWorkspaceId\n workspaceMemberId\n providerType\n accessToken\n scopes\n authFailedAt\n authFailedReason\n }\n }\n", b = async (e) => {
87
+ let { appConnection: t } = await y({
88
+ query: ie,
89
89
  variables: { id: e },
90
90
  caller: "getConnection"
91
91
  });
92
92
  if (t.authFailedAt !== null) throw new p(t.id);
93
- return v(t);
94
- }, S = "agentChatAssistant", C = ({ objectNameSingular: e, recordId: t, displayName: n }) => e === "agentChatAssistant" ? `@${n}` : `[[record:${e}:${t}:${n}]]`, ie = (e) => t(e) ? e.charAt(0).toUpperCase() + e.slice(1) : "", ae = "\n query ListAppConnections($filter: ListAppConnectionsInput) {\n appConnections(filter: $filter) {\n id\n providerName\n name\n handle\n externalAccountId\n scope\n userWorkspaceId\n workspaceMemberId\n providerType\n accessToken\n scopes\n authFailedAt\n authFailedReason\n }\n }\n", oe = async ({ visibility: e, ...t } = {}) => {
95
- let { appConnections: n } = await b({
93
+ return _(t);
94
+ }, x = ({ objectNameSingular: e, recordId: t, displayName: n }) => `[[record:${e}:${t}:${n}]]`, S = (e) => t(e) ? e.charAt(0).toUpperCase() + e.slice(1) : "", ae = "\n query ListAppConnections($filter: ListAppConnectionsInput) {\n appConnections(filter: $filter) {\n id\n providerName\n name\n handle\n externalAccountId\n scope\n userWorkspaceId\n workspaceMemberId\n providerType\n accessToken\n scopes\n authFailedAt\n authFailedReason\n }\n }\n", oe = async ({ visibility: e, ...t } = {}) => {
95
+ let { appConnections: n } = await y({
96
96
  query: ae,
97
97
  variables: { filter: {
98
98
  ...t,
@@ -100,7 +100,7 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
100
100
  } },
101
101
  caller: "listConnections"
102
102
  });
103
- return n.map(v);
103
+ return n.map(_);
104
104
  }, se = (e, t) => {
105
105
  if (t.userWorkspaceId !== null) {
106
106
  let n = e.find((e) => e.scope === "USER" && e.userWorkspaceId === t.userWorkspaceId);
@@ -108,7 +108,7 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
108
108
  }
109
109
  return e.find((e) => e.scope === "WORKSPACE") ?? null;
110
110
  }, ce = "\n mutation ReportAppConnectionAuthFailure($input: ReportAppConnectionAuthFailureInput!) {\n reportAppConnectionAuthFailure(input: $input)\n }\n", le = async ({ connectionId: e, reason: t }) => {
111
- await b({
111
+ await y({
112
112
  query: ce,
113
113
  variables: { input: {
114
114
  id: e,
@@ -116,15 +116,15 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
116
116
  } },
117
117
  caller: "reportConnectionAuthFailure"
118
118
  });
119
- }, w = "\n id\n handle\n displayName\n visibility\n connectedAccountId\n isSyncEnabled\n participantHandleFieldUniversalIdentifier\n messagingProviderUniversalIdentifier\n", T = `
119
+ }, C = "\n id\n handle\n displayName\n visibility\n connectedAccountId\n isSyncEnabled\n participantHandleFieldUniversalIdentifier\n messagingProviderUniversalIdentifier\n", ue = `
120
120
  mutation CreateAppMessageChannel($input: CreateAppMessageChannelInput!) {
121
121
  createAppMessageChannel(input: $input) {
122
- ${w}
122
+ ${C}
123
123
  }
124
124
  }
125
- `, E = async ({ messagingProvider: e, ...t }) => {
126
- let { createAppMessageChannel: n } = await b({
127
- query: T,
125
+ `, de = async ({ messagingProvider: e, ...t }) => {
126
+ let { createAppMessageChannel: n } = await y({
127
+ query: ue,
128
128
  variables: { input: {
129
129
  ...t,
130
130
  messagingProviderUniversalIdentifier: e?.universalIdentifier
@@ -132,28 +132,28 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
132
132
  caller: "createMessageChannel"
133
133
  });
134
134
  return n;
135
- }, D = `
135
+ }, fe = `
136
136
  query ListAppMessageChannels($filter: ListAppMessageChannelsInput) {
137
137
  appMessageChannels(filter: $filter) {
138
- ${w}
138
+ ${C}
139
139
  }
140
140
  }
141
- `, O = async (e = {}) => {
142
- let { appMessageChannels: t } = await b({
143
- query: D,
141
+ `, w = async (e = {}) => {
142
+ let { appMessageChannels: t } = await y({
143
+ query: fe,
144
144
  variables: { filter: e },
145
145
  caller: "listMessageChannels"
146
146
  });
147
147
  return t;
148
- }, k = `
148
+ }, T = `
149
149
  mutation UpdateAppMessageChannel($input: UpdateAppMessageChannelInput!) {
150
150
  updateAppMessageChannel(input: $input) {
151
- ${w}
151
+ ${C}
152
152
  }
153
153
  }
154
- `, A = async ({ messagingProvider: e, ...t }) => {
155
- let { updateAppMessageChannel: n } = await b({
156
- query: k,
154
+ `, E = async ({ messagingProvider: e, ...t }) => {
155
+ let { updateAppMessageChannel: n } = await y({
156
+ query: T,
157
157
  variables: { input: {
158
158
  ...t,
159
159
  messagingProviderUniversalIdentifier: e === void 0 ? void 0 : e?.universalIdentifier ?? null
@@ -161,22 +161,22 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
161
161
  caller: "updateMessageChannel"
162
162
  });
163
163
  return n;
164
- }, j = `
164
+ }, D = `
165
165
  mutation DeleteAppMessageChannel($id: UUID!) {
166
166
  deleteAppMessageChannel(id: $id) {
167
- ${w}
167
+ ${C}
168
168
  }
169
169
  }
170
- `, M = async (e) => {
171
- let { deleteAppMessageChannel: t } = await b({
172
- query: j,
170
+ `, O = async (e) => {
171
+ let { deleteAppMessageChannel: t } = await y({
172
+ query: D,
173
173
  variables: { id: e },
174
174
  caller: "deleteMessageChannel"
175
175
  });
176
176
  return t;
177
- }, N = "\n mutation IngestAppMessages($input: IngestAppMessagesInput!) {\n ingestAppMessages(input: $input) {\n messages {\n externalId\n messageId\n messageThreadId\n }\n }\n }\n", P = async ({ messageChannelId: e, messages: t }) => {
178
- let { ingestAppMessages: n } = await b({
179
- query: N,
177
+ }, k = "\n mutation IngestAppMessages($input: IngestAppMessagesInput!) {\n ingestAppMessages(input: $input) {\n messages {\n externalId\n messageId\n messageThreadId\n hasAttachments\n }\n }\n }\n", A = async ({ messageChannelId: e, messages: t }) => {
178
+ let { ingestAppMessages: n } = await y({
179
+ query: k,
180
180
  variables: { input: {
181
181
  messageChannelId: e,
182
182
  messages: t
@@ -184,46 +184,66 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
184
184
  caller: "ingestMessages"
185
185
  });
186
186
  return n.messages;
187
- }, F = "\n id\n externalId\n name\n isSynced\n messageChannelId\n", I = `
187
+ }, j = "20202020-15db-460e-8166-c7b5d87ad4be", M = 255, N = async ({ filename: e, content: n, signal: r }) => {
188
+ if (!t(e) || e.length > M) throw Error(`uploadMessageAttachment() failed: filename must be 1 to ${M} characters long`);
189
+ let { apiUrl: i, accessToken: a } = v({ caller: "uploadMessageAttachment" });
190
+ return {
191
+ fileId: (await new o({
192
+ url: `${i}/metadata`,
193
+ headers: { Authorization: `Bearer ${a}` },
194
+ fetch: (e, t) => fetch(e, {
195
+ ...t,
196
+ signal: r
197
+ })
198
+ }).uploadFile({
199
+ fileBuffer: n,
200
+ filename: e,
201
+ fieldMetadataUniversalIdentifier: j
202
+ })).id,
203
+ label: e
204
+ };
205
+ }, P = "\n id\n externalId\n name\n isSynced\n messageChannelId\n", F = `
188
206
  query ListAppMessageFolders($filter: ListAppMessageFoldersInput) {
189
207
  appMessageFolders(filter: $filter) {
190
- ${F}
208
+ ${P}
191
209
  }
192
210
  }
193
- `, L = async (e = {}) => {
194
- let { appMessageFolders: t } = await b({
195
- query: I,
211
+ `, I = async (e = {}) => {
212
+ let { appMessageFolders: t } = await y({
213
+ query: F,
196
214
  variables: { filter: e },
197
215
  caller: "listMessageFolders"
198
216
  });
199
217
  return t;
200
- }, R = `
218
+ }, L = `
201
219
  mutation SyncAppMessageFolders($input: SyncAppMessageFoldersInput!) {
202
220
  syncAppMessageFolders(input: $input) {
203
- ${F}
221
+ ${P}
204
222
  }
205
223
  }
206
- `, z = async (e) => {
207
- let { syncAppMessageFolders: t } = await b({
208
- query: R,
224
+ `, R = async (e) => {
225
+ let { syncAppMessageFolders: t } = await y({
226
+ query: L,
209
227
  variables: { input: e },
210
228
  caller: "syncMessageFolders"
211
229
  });
212
230
  return t;
213
- }, B = (e) => i(e) ? [{
231
+ }, z = (e) => i(e) ? [{
214
232
  role: "user",
215
233
  content: e
216
- }] : e, V = "\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n threadId\n runId\n status\n result\n error\n success\n }\n }\n", H = async ({ input: e, ...t }) => {
217
- let { runAgent: n } = await b({
218
- query: V,
234
+ }] : e, B = "\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n threadId\n runId\n status\n result\n error\n success\n }\n }\n", V = async ({ input: e, ...t }) => {
235
+ let { runAgent: n } = await y({
236
+ query: B,
219
237
  variables: { input: c(e) ? {
220
238
  ...t,
221
- input: B(e)
239
+ input: z(e)
222
240
  } : t },
223
241
  caller: "runAgent"
224
242
  });
225
243
  return n;
226
- }, U = (e) => e.type === "message-persisted" && c(e.turnId) || e.type === "stream-ended" || e.type === "run-finished" || e.type === "credits-exhausted" || e.type === "stream-error", W = (e) => {
244
+ }, H = "agentChatAssistant", U = "(?:[^\\[\\]\\n\\r]|\\[[^\\[\\]\\n\\r]*\\])*";
245
+ RegExp(`^${U}$`);
246
+ var W = (e) => e.type === "message-persisted" && c(e.turnId) || e.type === "stream-ended" || e.type === "run-finished" || e.type === "credits-exhausted" || e.type === "stream-error", pe = (e) => {
227
247
  let t = e.providerMetadata ?? void 0;
228
248
  switch (e.type) {
229
249
  case "text": return {
@@ -274,11 +294,11 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
274
294
  };
275
295
  }
276
296
  }
277
- }, ue = (e) => e.map((e) => ({
297
+ }, me = (e) => e.map((e) => ({
278
298
  id: e.id,
279
299
  role: e.role,
280
300
  status: e.status,
281
- parts: [...e.parts].sort((e, t) => e.orderIndex - t.orderIndex).map(W).filter(c),
301
+ parts: [...e.parts].sort((e, t) => e.orderIndex - t.orderIndex).map(pe).filter(c),
282
302
  metadata: {
283
303
  createdAt: e.createdAt,
284
304
  senderWorkspaceMemberId: e.senderWorkspaceMemberId,
@@ -289,17 +309,21 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
289
309
  } : {}
290
310
  },
291
311
  threadId: e.threadId
292
- })), de = "\n query ConversationMessages($agentUniversalIdentifier: UUID!, $threadKey: String!) {\n messages: chatMessages(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n id\n threadId\n turnId\n senderWorkspaceMemberId\n role\n status\n createdAt\n processedAt\n parts {\n orderIndex\n type\n textContent\n reasoningContent\n toolName\n toolCallId\n toolInput\n toolOutput\n state\n providerExecuted\n errorMessage\n sourceUrlSourceId\n sourceUrlUrl\n sourceUrlTitle\n sourceDocumentSourceId\n sourceDocumentMediaType\n sourceDocumentTitle\n sourceDocumentFilename\n fileMediaType\n fileFilename\n fileUrl\n fileId\n providerMetadata\n }\n }\n streamCatchup: chatStreamCatchupChunks(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n chunks\n maxSeq\n error {\n code\n message\n }\n }\n }\n", fe = async (e) => {
293
- let { messages: t, streamCatchup: n } = await b({
294
- query: de,
312
+ }));
313
+ RegExp(`^record:${H}:${H}:(${U})$`);
314
+ //#endregion
315
+ //#region src/sdk/logic-function/agents/list-conversation-messages.ts
316
+ var he = "\n query ConversationMessages($agentUniversalIdentifier: UUID!, $threadKey: String!) {\n messages: chatMessages(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n id\n threadId\n turnId\n senderWorkspaceMemberId\n role\n status\n createdAt\n processedAt\n parts {\n orderIndex\n type\n textContent\n reasoningContent\n toolName\n toolCallId\n toolInput\n toolOutput\n state\n providerExecuted\n errorMessage\n sourceUrlSourceId\n sourceUrlUrl\n sourceUrlTitle\n sourceDocumentSourceId\n sourceDocumentMediaType\n sourceDocumentTitle\n sourceDocumentFilename\n fileMediaType\n fileFilename\n fileUrl\n fileId\n providerMetadata\n }\n }\n streamCatchup: chatStreamCatchupChunks(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n chunks\n maxSeq\n error {\n code\n message\n }\n }\n }\n", ge = async (e) => {
317
+ let { messages: t, streamCatchup: n } = await y({
318
+ query: he,
295
319
  variables: e,
296
320
  caller: "listConversationMessages"
297
321
  });
298
322
  return {
299
- messages: ue(t),
323
+ messages: me(t),
300
324
  streamCatchup: n
301
325
  };
302
- }, G = (t) => r(t) && !e(t), K = (e) => e.map((e) => G(e) && i(e.message) ? e.message : JSON.stringify(e)), pe = (e) => G(e) && i(e.type), me = ({ block: n, caller: r }) => {
326
+ }, G = (t) => r(t) && !e(t), K = (e) => e.map((e) => G(e) && i(e.message) ? e.message : JSON.stringify(e)), _e = (e) => G(e) && i(e.type), ve = ({ block: n, caller: r }) => {
303
327
  let i = n.split("\n");
304
328
  if (i.includes("event: complete")) return { type: "complete" };
305
329
  let a = i.filter((e) => e.startsWith("data:")).map((e) => e.slice(5).trimStart()).join("\n");
@@ -311,17 +335,17 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
311
335
  messages: K(o.errors)
312
336
  };
313
337
  let s = G(o.data) && G(o.data.onAgentChatEvent) ? o.data.onAgentChatEvent.event : void 0;
314
- if (!pe(s)) throw Error(`${r}() failed: unexpected result ${a}`);
338
+ if (!_e(s)) throw Error(`${r}() failed: unexpected result ${a}`);
315
339
  return {
316
340
  type: "event",
317
341
  event: s
318
342
  };
319
- }, he = async (t) => {
343
+ }, ye = async (t) => {
320
344
  let n = await t.json().catch(() => void 0);
321
345
  return G(n) && e(n.errors) ? K(n.errors).join(", ") : `HTTP ${t.status} ${t.statusText}`;
322
346
  };
323
347
  async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdvice: i = "", isActingAsCaller: a = !1 }) {
324
- let { apiUrl: o, accessToken: s } = y({
348
+ let { apiUrl: o, accessToken: s } = v({
325
349
  caller: n,
326
350
  isActingAsCaller: a
327
351
  }), l;
@@ -339,7 +363,7 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
339
363
  }),
340
364
  signal: r
341
365
  });
342
- if (!a.ok || !c(a.body)) throw Error(`${n}() failed: ${await he(a)}`);
366
+ if (!a.ok || !c(a.body)) throw Error(`${n}() failed: ${await ye(a)}`);
343
367
  l = a.body.pipeThrough(new TextDecoderStream()).getReader();
344
368
  let u = "";
345
369
  for (;;) {
@@ -348,7 +372,7 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
348
372
  u = (u + t).replace(/\r\n/g, "\n");
349
373
  let r = u.indexOf("\n\n");
350
374
  for (; r !== -1;) {
351
- let e = me({
375
+ let e = ve({
352
376
  block: u.slice(0, r),
353
377
  caller: n
354
378
  });
@@ -366,34 +390,34 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
366
390
  }
367
391
  //#endregion
368
392
  //#region src/sdk/logic-function/agents/stream-conversation.ts
369
- var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $threadKey: String!) {\n onAgentChatEvent(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n event\n }\n }\n", _e = ({ signal: e, ...t }) => q({
370
- query: ge,
393
+ var be = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $threadKey: String!) {\n onAgentChatEvent(agentUniversalIdentifier: $agentUniversalIdentifier, threadKey: $threadKey) {\n event\n }\n }\n", xe = ({ signal: e, ...t }) => q({
394
+ query: be,
371
395
  variables: t,
372
396
  caller: "streamConversation",
373
397
  signal: e,
374
398
  closedEarlyAdvice: "; read the history and stream again to resume"
375
- }), ve = "\n mutation Generate($input: GenerateInput!) {\n generate(input: $input) {\n success\n text\n object\n error\n runId\n usage {\n inputTokens\n outputTokens\n }\n }\n }\n", ye = "\n subscription OnAgentRunEvent($runId: UUID!) {\n onAgentChatEvent(runId: $runId) {\n event\n }\n }\n", be = 5e3, J = async ({ variables: e, signal: t }) => {
376
- let { generate: n } = await b({
377
- query: ve,
399
+ }), Se = "\n mutation Generate($input: GenerateInput!) {\n generate(input: $input) {\n success\n text\n object\n error\n runId\n usage {\n inputTokens\n outputTokens\n }\n }\n }\n", Ce = "\n subscription OnAgentRunEvent($runId: UUID!) {\n onAgentChatEvent(runId: $runId) {\n event\n }\n }\n", we = 5e3, J = async ({ variables: e, signal: t }) => {
400
+ let { generate: n } = await y({
401
+ query: Se,
378
402
  variables: e,
379
403
  caller: "ai.generate",
380
404
  signal: t,
381
405
  isActingAsCaller: !0
382
406
  });
383
407
  return n;
384
- }, xe = (e) => i(e.type), Y = (e) => {
408
+ }, Te = (e) => i(e.type), Y = (e) => {
385
409
  let t, n = !0;
386
410
  return {
387
411
  quiet: new Promise((r) => {
388
412
  e.then(() => {
389
- n && (t = setTimeout(() => r(void 0), be));
413
+ n && (t = setTimeout(() => r(void 0), we));
390
414
  }, () => void 0);
391
415
  }),
392
416
  stop: () => {
393
417
  n = !1, clearTimeout(t);
394
418
  }
395
419
  };
396
- }, Se = async ({ variables: e, onChunk: t, signal: n }) => {
420
+ }, Ee = async ({ variables: e, onChunk: t, signal: n }) => {
397
421
  let r = crypto.randomUUID(), i = new AbortController(), a = c(n) ? AbortSignal.any([n, i.signal]) : i.signal, o = new Promise((e, t) => n?.addEventListener("abort", () => t(n.reason), {
398
422
  once: !0,
399
423
  signal: i.signal
@@ -401,7 +425,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
401
425
  o.catch(() => void 0);
402
426
  try {
403
427
  let i = q({
404
- query: ye,
428
+ query: Ce,
405
429
  variables: { runId: r },
406
430
  caller: "ai.generate",
407
431
  signal: a,
@@ -419,8 +443,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
419
443
  try {
420
444
  for (;;) {
421
445
  let n = await Promise.race([i.next(), e.quiet]).catch(() => void 0);
422
- if (!c(n) || n.done || a.aborted || U(n.value)) return;
423
- n.value.type === "stream-chunk" && xe(n.value.chunk) && (e.stop(), await t(n.value.chunk), e = Y(s));
446
+ if (!c(n) || n.done || a.aborted || W(n.value)) return;
447
+ n.value.type === "stream-chunk" && Te(n.value.chunk) && (e.stop(), await t(n.value.chunk), e = Y(s));
424
448
  }
425
449
  } finally {
426
450
  e.stop(), i.return(void 0).catch(() => void 0);
@@ -430,12 +454,12 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
430
454
  } finally {
431
455
  i.abort();
432
456
  }
433
- }, Ce = { generate: async ({ input: e, onChunk: t, signal: n, ...r }) => {
457
+ }, De = { generate: async ({ input: e, onChunk: t, signal: n, ...r }) => {
434
458
  let i = { input: {
435
459
  ...r,
436
- input: B(e)
460
+ input: z(e)
437
461
  } };
438
- return c(t) ? Se({
462
+ return c(t) ? Ee({
439
463
  variables: i,
440
464
  onChunk: t,
441
465
  signal: n
@@ -443,15 +467,15 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
443
467
  variables: i,
444
468
  signal: n
445
469
  });
446
- } }, we = async (e) => {
470
+ } }, Oe = async (e) => {
447
471
  let { sendInboxMessage: t } = await new o().mutation({ sendInboxMessage: {
448
472
  __args: { input: e },
449
473
  threadId: !0
450
474
  } });
451
475
  return t;
452
- }, Te = /\[/g, Ee = /\]/g, De = /\r?\n/g, X = (e) => e.replace(Te, "(").replace(Ee, ")").replace(De, " ").trim(), Oe = async ({ workspaceMemberId: e }) => {
476
+ }, ke = /\[/g, Ae = /\]/g, je = /\r?\n/g, X = (e) => e.replace(ke, "(").replace(Ae, ")").replace(je, " ").trim(), Me = async ({ workspaceMemberId: e }) => {
453
477
  let { data: { workspaceMember: n } } = await new s().get(`/rest/workspaceMembers/${e}`), r = `${n.name.firstName ?? ""} ${n.name.lastName ?? ""}`.trim();
454
- return C({
478
+ return x({
455
479
  objectNameSingular: "workspaceMember",
456
480
  recordId: e,
457
481
  displayName: X(t(r) ? r : n.userEmail)
@@ -459,7 +483,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
459
483
  }, Z = ({ fullName: e, partName: t }) => {
460
484
  let n = r(e) ? Reflect.get(e, t) : void 0;
461
485
  return i(n) ? n : "";
462
- }, ke = ({ record: e, recordId: t, labelIdentifierField: n }) => {
486
+ }, Ne = ({ record: e, recordId: t, labelIdentifierField: n }) => {
463
487
  if (!c(n)) return t;
464
488
  let r = e[n.name];
465
489
  return n.type === "FULL_NAME" ? `${Z({
@@ -469,7 +493,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
469
493
  fullName: r,
470
494
  partName: "lastName"
471
495
  })}`.trim() : c(r) ? String(r) : "";
472
- }, Ae = async ({ metadataClient: e, objectMetadata: t }) => {
496
+ }, Pe = async ({ metadataClient: e, objectMetadata: t }) => {
473
497
  if (!c(t.labelIdentifierFieldMetadataId)) return;
474
498
  let { object: n } = await e.query({ object: {
475
499
  __args: { id: t.id },
@@ -485,11 +509,11 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
485
509
  }
486
510
  } });
487
511
  return n.fields.edges[0]?.node;
488
- }, je = 1e3, Me = async ({ metadataClient: e, objectNameSingular: t }) => {
512
+ }, Fe = 1e3, Ie = async ({ metadataClient: e, objectNameSingular: t }) => {
489
513
  let { objects: n } = await e.query({ objects: {
490
514
  __args: {
491
515
  filter: {},
492
- paging: { first: je }
516
+ paging: { first: Fe }
493
517
  },
494
518
  edges: { node: {
495
519
  id: !0,
@@ -500,32 +524,32 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
500
524
  } }), r = n.edges.find(({ node: e }) => e.nameSingular === t)?.node;
501
525
  if (!c(r)) throw Error(`This workspace has no ${t} object.`);
502
526
  return r;
503
- }, Ne = async ({ objectNameSingular: e, recordId: t }) => {
504
- let n = new o(), r = await Me({
527
+ }, Le = async ({ objectNameSingular: e, recordId: t }) => {
528
+ let n = new o(), r = await Ie({
505
529
  metadataClient: n,
506
530
  objectNameSingular: e
507
- }), [i, a] = await Promise.all([Ae({
531
+ }), [i, a] = await Promise.all([Pe({
508
532
  metadataClient: n,
509
533
  objectMetadata: r
510
534
  }), new s().get(`/rest/${r.namePlural}/${t}`)]);
511
- return C({
535
+ return x({
512
536
  objectNameSingular: e,
513
537
  recordId: t,
514
- displayName: X(ke({
538
+ displayName: X(Ne({
515
539
  record: a.data[e],
516
540
  recordId: t,
517
541
  labelIdentifierField: i
518
542
  }))
519
543
  });
520
- }, Pe = C({
521
- objectNameSingular: S,
522
- recordId: S,
544
+ }, Re = x({
545
+ objectNameSingular: H,
546
+ recordId: H,
523
547
  displayName: "Ada"
524
- }), Fe = async (e) => {
548
+ }), ze = async (e) => {
525
549
  await new o().mutation({ attachRecordToInboxThread: { __args: { input: e } } });
526
- }, Q = async (e) => {
550
+ }, Be = async (e) => {
527
551
  await new o().mutation({ detachRecordFromInboxThread: { __args: { input: e } } });
528
- }, Ie = async (e) => {
552
+ }, Ve = async (e) => {
529
553
  let { enqueueJob: t } = await new o().mutation({ enqueueJob: {
530
554
  __args: { input: e },
531
555
  enqueued: !0,
@@ -533,16 +557,21 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
533
557
  jobId: !0
534
558
  } });
535
559
  return t;
536
- }, Le = async (e) => {
560
+ }, He = async (e) => {
537
561
  let { enqueueJobs: t } = await new o().mutation({ enqueueJobs: {
538
562
  __args: { input: e },
539
563
  enqueued: !0,
540
564
  logicFunctionUniversalIdentifier: !0,
541
565
  enqueuedJobsCount: !0,
542
- jobIds: !0
566
+ jobIds: !0,
567
+ jobs: {
568
+ jobId: !0,
569
+ sizeBytes: !0
570
+ },
571
+ availableBytes: !0
543
572
  } });
544
573
  return t;
545
- }, Re = async (e) => {
574
+ }, Ue = async (e) => {
546
575
  let { getJobs: t } = await new o().query({ getJobs: {
547
576
  __args: { jobIds: e },
548
577
  jobId: !0,
@@ -554,7 +583,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
554
583
  finishedAt: !0
555
584
  } });
556
585
  return t;
557
- }, ze = (e) => ({
586
+ }, We = (e) => ({
558
587
  __args: {
559
588
  paging: { first: e.length },
560
589
  filter: { universalIdentifier: { in: e } }
@@ -564,20 +593,20 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
564
593
  universalIdentifier: !0,
565
594
  nameSingular: !0
566
595
  } }
567
- }), Be = async ({ timelineActivityTypeUniversalIdentifier: e, targetObjectUniversalIdentifier: t, linkedObjectMetadataUniversalIdentifier: n, targetRecordId: r, ...i }) => {
596
+ }), Q = async ({ timelineActivityTypeUniversalIdentifier: e, targetObjectUniversalIdentifier: t, linkedObjectMetadataUniversalIdentifier: n, targetRecordId: r, ...i }) => {
568
597
  let a = [...new Set([t, n].filter(c))], { timelineActivityTypes: l, objects: u } = await new o().query({
569
598
  timelineActivityTypes: {
570
599
  id: !0,
571
600
  universalIdentifier: !0,
572
601
  isActive: !0
573
602
  },
574
- objects: ze(a)
603
+ objects: We(a)
575
604
  }), d = l.find(({ universalIdentifier: t }) => t === e);
576
605
  if (!c(d)) throw Error(`Timeline activity type ${e} is not installed`);
577
606
  if (!d.isActive) throw Error(`Timeline activity type ${e} is inactive`);
578
607
  let f = new Map(u.edges.map(({ node: e }) => [e.universalIdentifier, e])), p = f.get(t);
579
608
  if (!c(p)) throw Error(`Timeline activity target object ${t} is not installed`);
580
- let m = `target${ie(p.nameSingular)}Id`, h = c(n) ? f.get(n) : void 0;
609
+ let m = `target${S(p.nameSingular)}Id`, h = c(n) ? f.get(n) : void 0;
581
610
  if (c(n) && !c(h)) throw Error(`Timeline activity linked object ${n} is not installed`);
582
611
  return (await new s().post("/rest/timelineActivities", {
583
612
  ...i,
@@ -585,10 +614,10 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
585
614
  linkedObjectMetadataId: h?.id,
586
615
  [m]: r
587
616
  })).data.createTimelineActivity;
588
- }, Ve = "\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n", He = "\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n", Ue = "\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n", $ = "WORKSPACE", We = {
617
+ }, Ge = "\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n", Ke = "\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n", qe = "\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n", $ = "WORKSPACE", Je = {
589
618
  async get(e, t) {
590
- let { appKeyValue: n } = await b({
591
- query: Ve,
619
+ let { appKeyValue: n } = await y({
620
+ query: Ge,
592
621
  variables: {
593
622
  key: e,
594
623
  scope: t?.scope ?? $
@@ -598,8 +627,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
598
627
  return n?.value ?? null;
599
628
  },
600
629
  async set(e, t, n) {
601
- await b({
602
- query: He,
630
+ await y({
631
+ query: Ke,
603
632
  variables: { input: {
604
633
  key: e,
605
634
  value: t,
@@ -609,8 +638,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
609
638
  });
610
639
  },
611
640
  async delete(e, t) {
612
- let { deleteAppKeyValue: n } = await b({
613
- query: Ue,
641
+ let { deleteAppKeyValue: n } = await y({
642
+ query: qe,
614
643
  variables: {
615
644
  key: e,
616
645
  scope: t?.scope ?? $
@@ -619,12 +648,12 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
619
648
  });
620
649
  return n;
621
650
  }
622
- }, Ge = class {
651
+ }, Ye = class {
623
652
  constructor(e, t) {
624
653
  this.__twentyHttpResponse = !0, this.body = e, this.status = t?.status, this.headers = t?.headers;
625
654
  }
626
655
  };
627
656
  //#endregion
628
- export { p as AppConnectionAuthFailedError, Pe as INBOX_ASSISTANT_MENTION, Ge as Response, f as RetryableLogicFunctionError, Ce as ai, Fe as attachRecordToInboxThread, E as createMessageChannel, Be as createTimelineActivity, M as deleteMessageChannel, Q as detachRecordFromInboxThread, Ie as enqueueJob, Le as enqueueJobs, se as findConnectionForRequest, re as getConnection, Re as getJobs, Oe as inboxMention, Ne as inboxReferenceRecord, P as ingestMessages, U as isAgentChatTurnEndEvent, u as jsonSchemaToInputSchema, We as kv, oe as listConnections, fe as listConversationMessages, O as listMessageChannels, L as listMessageFolders, le as reportConnectionAuthFailure, H as runAgent, we as sendInboxMessage, _e as streamConversation, z as syncMessageFolders, A as updateMessageChannel };
657
+ export { p as AppConnectionAuthFailedError, Re as INBOX_ASSISTANT_MENTION, Ye as Response, f as RetryableLogicFunctionError, De as ai, ze as attachRecordToInboxThread, de as createMessageChannel, Q as createTimelineActivity, O as deleteMessageChannel, Be as detachRecordFromInboxThread, Ve as enqueueJob, He as enqueueJobs, se as findConnectionForRequest, b as getConnection, Ue as getJobs, Me as inboxMention, Le as inboxReferenceRecord, A as ingestMessages, W as isAgentChatTurnEndEvent, u as jsonSchemaToInputSchema, Je as kv, oe as listConnections, ge as listConversationMessages, w as listMessageChannels, I as listMessageFolders, le as reportConnectionAuthFailure, V as runAgent, Oe as sendInboxMessage, xe as streamConversation, R as syncMessageFolders, E as updateMessageChannel, N as uploadMessageAttachment };
629
658
 
630
659
  //# sourceMappingURL=index.mjs.map