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