twenty-sdk 2.56.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.
- package/CHANGELOG.md +24 -0
- package/dist/billing/index.cjs +1 -1
- package/dist/billing/index.cjs.map +1 -1
- package/dist/billing/index.mjs +32 -28
- package/dist/billing/index.mjs.map +1 -1
- package/dist/define/index.cjs +6 -16
- package/dist/define/index.cjs.map +1 -1
- package/dist/define/index.d.ts +102 -232
- package/dist/define/index.mjs +4974 -45959
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs +1 -74
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.d.ts +13 -2
- package/dist/front-component/index.mjs +270 -5087
- package/dist/front-component/index.mjs.map +1 -1
- package/dist/front-component-renderer/build.cjs +8 -441
- package/dist/front-component-renderer/build.mjs +50 -112128
- package/dist/logic-function/index.cjs +27 -26
- package/dist/logic-function/index.cjs.map +1 -1
- package/dist/logic-function/index.d.ts +64 -3
- package/dist/logic-function/index.mjs +152 -129
- package/dist/logic-function/index.mjs.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -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
|
|
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",
|
|
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"
|
|
55
|
-
},
|
|
47
|
+
}, re = (e) => {
|
|
48
|
+
let n = e[te];
|
|
49
|
+
return t(n) ? n : e[h];
|
|
50
|
+
}, _ = (e) => ({
|
|
56
51
|
...e,
|
|
57
|
-
visibility:
|
|
58
|
-
}),
|
|
59
|
-
let r = process.env
|
|
60
|
-
if (!t(r) || !t(i)) throw Error(`${e}() requires the app runtime env vars ${h} and ${
|
|
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
|
-
},
|
|
66
|
-
let { apiUrl: a, accessToken: o } =
|
|
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,48 +78,48 @@ 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
|
-
},
|
|
87
|
-
let { appConnection: t } = await
|
|
88
|
-
query:
|
|
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({
|
|
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
|
-
return
|
|
94
|
-
},
|
|
95
|
-
let { appConnections: n } = await
|
|
96
|
-
query:
|
|
88
|
+
return _(t);
|
|
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)
|
|
100
95
|
} },
|
|
101
96
|
caller: "listConnections"
|
|
102
97
|
});
|
|
103
|
-
return n.map(
|
|
104
|
-
},
|
|
98
|
+
return n.map(_);
|
|
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
|
-
},
|
|
111
|
-
await
|
|
112
|
-
query:
|
|
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
|
-
},
|
|
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
|
-
`,
|
|
126
|
-
let { createAppMessageChannel: n } = await
|
|
127
|
-
query:
|
|
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
|
-
},
|
|
130
|
+
}, E = `
|
|
136
131
|
query ListAppMessageChannels($filter: ListAppMessageChannelsInput) {
|
|
137
132
|
appMessageChannels(filter: $filter) {
|
|
138
|
-
${
|
|
133
|
+
${C}
|
|
139
134
|
}
|
|
140
135
|
}
|
|
141
|
-
`,
|
|
142
|
-
let { appMessageChannels: t } = await
|
|
143
|
-
query:
|
|
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
|
-
},
|
|
143
|
+
}, O = `
|
|
149
144
|
mutation UpdateAppMessageChannel($input: UpdateAppMessageChannelInput!) {
|
|
150
145
|
updateAppMessageChannel(input: $input) {
|
|
151
|
-
${
|
|
146
|
+
${C}
|
|
152
147
|
}
|
|
153
148
|
}
|
|
154
|
-
`,
|
|
155
|
-
let { updateAppMessageChannel: n } = await
|
|
156
|
-
query:
|
|
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
|
-
},
|
|
159
|
+
}, A = `
|
|
165
160
|
mutation DeleteAppMessageChannel($id: UUID!) {
|
|
166
161
|
deleteAppMessageChannel(id: $id) {
|
|
167
|
-
${
|
|
162
|
+
${C}
|
|
168
163
|
}
|
|
169
164
|
}
|
|
170
|
-
`,
|
|
171
|
-
let { deleteAppMessageChannel: t } = await
|
|
172
|
-
query:
|
|
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
|
-
},
|
|
178
|
-
let { ingestAppMessages: n } = await
|
|
179
|
-
query:
|
|
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,46 +179,64 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
|
|
|
184
179
|
caller: "ingestMessages"
|
|
185
180
|
});
|
|
186
181
|
return n.messages;
|
|
187
|
-
},
|
|
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" });
|
|
185
|
+
return {
|
|
186
|
+
fileId: (await new o({
|
|
187
|
+
url: `${i}/metadata`,
|
|
188
|
+
headers: { Authorization: `Bearer ${a}` },
|
|
189
|
+
fetch: (e, t) => fetch(e, {
|
|
190
|
+
...t,
|
|
191
|
+
signal: r
|
|
192
|
+
})
|
|
193
|
+
}).uploadFile({
|
|
194
|
+
fileBuffer: n,
|
|
195
|
+
filename: e,
|
|
196
|
+
fieldMetadataUniversalIdentifier: P
|
|
197
|
+
})).id,
|
|
198
|
+
label: e
|
|
199
|
+
};
|
|
200
|
+
}, L = "\n id\n externalId\n name\n isSynced\n messageChannelId\n", R = `
|
|
188
201
|
query ListAppMessageFolders($filter: ListAppMessageFoldersInput) {
|
|
189
202
|
appMessageFolders(filter: $filter) {
|
|
190
|
-
${
|
|
203
|
+
${L}
|
|
191
204
|
}
|
|
192
205
|
}
|
|
193
|
-
`,
|
|
194
|
-
let { appMessageFolders: t } = await
|
|
195
|
-
query:
|
|
206
|
+
`, z = async (e = {}) => {
|
|
207
|
+
let { appMessageFolders: t } = await x({
|
|
208
|
+
query: R,
|
|
196
209
|
variables: { filter: e },
|
|
197
210
|
caller: "listMessageFolders"
|
|
198
211
|
});
|
|
199
212
|
return t;
|
|
200
|
-
},
|
|
213
|
+
}, B = `
|
|
201
214
|
mutation SyncAppMessageFolders($input: SyncAppMessageFoldersInput!) {
|
|
202
215
|
syncAppMessageFolders(input: $input) {
|
|
203
|
-
${
|
|
216
|
+
${L}
|
|
204
217
|
}
|
|
205
218
|
}
|
|
206
|
-
`,
|
|
207
|
-
let { syncAppMessageFolders: t } = await
|
|
208
|
-
query:
|
|
219
|
+
`, V = async (e) => {
|
|
220
|
+
let { syncAppMessageFolders: t } = await x({
|
|
221
|
+
query: B,
|
|
209
222
|
variables: { input: e },
|
|
210
223
|
caller: "syncMessageFolders"
|
|
211
224
|
});
|
|
212
225
|
return t;
|
|
213
|
-
},
|
|
226
|
+
}, H = (e) => i(e) ? [{
|
|
214
227
|
role: "user",
|
|
215
228
|
content: e
|
|
216
|
-
}] : e,
|
|
217
|
-
let { runAgent: n } = await
|
|
218
|
-
query:
|
|
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,
|
|
219
232
|
variables: { input: c(e) ? {
|
|
220
233
|
...t,
|
|
221
|
-
input:
|
|
234
|
+
input: H(e)
|
|
222
235
|
} : t },
|
|
223
236
|
caller: "runAgent"
|
|
224
237
|
});
|
|
225
238
|
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",
|
|
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) => {
|
|
227
240
|
let t = e.providerMetadata ?? void 0;
|
|
228
241
|
switch (e.type) {
|
|
229
242
|
case "text": return {
|
|
@@ -274,14 +287,17 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
|
|
|
274
287
|
};
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
|
-
},
|
|
290
|
+
}, he = (e) => e.map((e) => ({
|
|
278
291
|
id: e.id,
|
|
279
292
|
role: e.role,
|
|
280
293
|
status: e.status,
|
|
281
|
-
parts: [...e.parts].sort((e, t) => e.orderIndex - t.orderIndex).map(
|
|
294
|
+
parts: [...e.parts].sort((e, t) => e.orderIndex - t.orderIndex).map(me).filter(c),
|
|
282
295
|
metadata: {
|
|
283
296
|
createdAt: e.createdAt,
|
|
284
297
|
senderWorkspaceMemberId: e.senderWorkspaceMemberId,
|
|
298
|
+
senderApplicationId: e.senderApplicationId,
|
|
299
|
+
agentId: e.agentId,
|
|
300
|
+
isBuiltInAssistant: e.isBuiltInAssistant,
|
|
285
301
|
turnId: e.turnId,
|
|
286
302
|
...e.role === "assistant" ? {
|
|
287
303
|
startedAt: e.createdAt,
|
|
@@ -289,17 +305,17 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
|
|
|
289
305
|
} : {}
|
|
290
306
|
},
|
|
291
307
|
threadId: e.threadId
|
|
292
|
-
})),
|
|
293
|
-
let { messages: t, streamCatchup: n } = await
|
|
294
|
-
query:
|
|
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,
|
|
295
311
|
variables: e,
|
|
296
312
|
caller: "listConversationMessages"
|
|
297
313
|
});
|
|
298
314
|
return {
|
|
299
|
-
messages:
|
|
315
|
+
messages: he(t),
|
|
300
316
|
streamCatchup: n
|
|
301
317
|
};
|
|
302
|
-
}, G = (t) => r(t) && !e(t), K = (e) => e.map((e) => G(e) && i(e.message) ? e.message : JSON.stringify(e)),
|
|
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 }) => {
|
|
303
319
|
let i = n.split("\n");
|
|
304
320
|
if (i.includes("event: complete")) return { type: "complete" };
|
|
305
321
|
let a = i.filter((e) => e.startsWith("data:")).map((e) => e.slice(5).trimStart()).join("\n");
|
|
@@ -311,17 +327,17 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
|
|
|
311
327
|
messages: K(o.errors)
|
|
312
328
|
};
|
|
313
329
|
let s = G(o.data) && G(o.data.onAgentChatEvent) ? o.data.onAgentChatEvent.event : void 0;
|
|
314
|
-
if (!
|
|
330
|
+
if (!ve(s)) throw Error(`${r}() failed: unexpected result ${a}`);
|
|
315
331
|
return {
|
|
316
332
|
type: "event",
|
|
317
333
|
event: s
|
|
318
334
|
};
|
|
319
|
-
},
|
|
335
|
+
}, be = async (t) => {
|
|
320
336
|
let n = await t.json().catch(() => void 0);
|
|
321
337
|
return G(n) && e(n.errors) ? K(n.errors).join(", ") : `HTTP ${t.status} ${t.statusText}`;
|
|
322
338
|
};
|
|
323
339
|
async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdvice: i = "", isActingAsCaller: a = !1 }) {
|
|
324
|
-
let { apiUrl: o, accessToken: s } =
|
|
340
|
+
let { apiUrl: o, accessToken: s } = b({
|
|
325
341
|
caller: n,
|
|
326
342
|
isActingAsCaller: a
|
|
327
343
|
}), l;
|
|
@@ -339,7 +355,7 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
|
|
|
339
355
|
}),
|
|
340
356
|
signal: r
|
|
341
357
|
});
|
|
342
|
-
if (!a.ok || !c(a.body)) throw Error(`${n}() failed: ${await
|
|
358
|
+
if (!a.ok || !c(a.body)) throw Error(`${n}() failed: ${await be(a)}`);
|
|
343
359
|
l = a.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
344
360
|
let u = "";
|
|
345
361
|
for (;;) {
|
|
@@ -348,7 +364,7 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
|
|
|
348
364
|
u = (u + t).replace(/\r\n/g, "\n");
|
|
349
365
|
let r = u.indexOf("\n\n");
|
|
350
366
|
for (; r !== -1;) {
|
|
351
|
-
let e =
|
|
367
|
+
let e = ye({
|
|
352
368
|
block: u.slice(0, r),
|
|
353
369
|
caller: n
|
|
354
370
|
});
|
|
@@ -366,34 +382,34 @@ async function* q({ query: e, variables: t, caller: n, signal: r, closedEarlyAdv
|
|
|
366
382
|
}
|
|
367
383
|
//#endregion
|
|
368
384
|
//#region src/sdk/logic-function/agents/stream-conversation.ts
|
|
369
|
-
var
|
|
370
|
-
query:
|
|
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,
|
|
371
387
|
variables: t,
|
|
372
388
|
caller: "streamConversation",
|
|
373
389
|
signal: e,
|
|
374
390
|
closedEarlyAdvice: "; read the history and stream again to resume"
|
|
375
|
-
}),
|
|
376
|
-
let { generate: n } = await
|
|
377
|
-
query:
|
|
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,
|
|
378
394
|
variables: e,
|
|
379
395
|
caller: "ai.generate",
|
|
380
396
|
signal: t,
|
|
381
397
|
isActingAsCaller: !0
|
|
382
398
|
});
|
|
383
399
|
return n;
|
|
384
|
-
},
|
|
400
|
+
}, Ee = (e) => i(e.type), Y = (e) => {
|
|
385
401
|
let t, n = !0;
|
|
386
402
|
return {
|
|
387
403
|
quiet: new Promise((r) => {
|
|
388
404
|
e.then(() => {
|
|
389
|
-
n && (t = setTimeout(() => r(void 0),
|
|
405
|
+
n && (t = setTimeout(() => r(void 0), Te));
|
|
390
406
|
}, () => void 0);
|
|
391
407
|
}),
|
|
392
408
|
stop: () => {
|
|
393
409
|
n = !1, clearTimeout(t);
|
|
394
410
|
}
|
|
395
411
|
};
|
|
396
|
-
},
|
|
412
|
+
}, De = async ({ variables: e, onChunk: t, signal: n }) => {
|
|
397
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), {
|
|
398
414
|
once: !0,
|
|
399
415
|
signal: i.signal
|
|
@@ -401,7 +417,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
401
417
|
o.catch(() => void 0);
|
|
402
418
|
try {
|
|
403
419
|
let i = q({
|
|
404
|
-
query:
|
|
420
|
+
query: we,
|
|
405
421
|
variables: { runId: r },
|
|
406
422
|
caller: "ai.generate",
|
|
407
423
|
signal: a,
|
|
@@ -419,8 +435,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
419
435
|
try {
|
|
420
436
|
for (;;) {
|
|
421
437
|
let n = await Promise.race([i.next(), e.quiet]).catch(() => void 0);
|
|
422
|
-
if (!c(n) || n.done || a.aborted ||
|
|
423
|
-
n.value.type === "stream-chunk" &&
|
|
438
|
+
if (!c(n) || n.done || a.aborted || W(n.value)) return;
|
|
439
|
+
n.value.type === "stream-chunk" && Ee(n.value.chunk) && (e.stop(), await t(n.value.chunk), e = Y(s));
|
|
424
440
|
}
|
|
425
441
|
} finally {
|
|
426
442
|
e.stop(), i.return(void 0).catch(() => void 0);
|
|
@@ -430,12 +446,12 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
430
446
|
} finally {
|
|
431
447
|
i.abort();
|
|
432
448
|
}
|
|
433
|
-
},
|
|
449
|
+
}, Oe = { generate: async ({ input: e, onChunk: t, signal: n, ...r }) => {
|
|
434
450
|
let i = { input: {
|
|
435
451
|
...r,
|
|
436
|
-
input:
|
|
452
|
+
input: H(e)
|
|
437
453
|
} };
|
|
438
|
-
return c(t) ?
|
|
454
|
+
return c(t) ? De({
|
|
439
455
|
variables: i,
|
|
440
456
|
onChunk: t,
|
|
441
457
|
signal: n
|
|
@@ -443,15 +459,15 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
443
459
|
variables: i,
|
|
444
460
|
signal: n
|
|
445
461
|
});
|
|
446
|
-
} },
|
|
462
|
+
} }, ke = async (e) => {
|
|
447
463
|
let { sendInboxMessage: t } = await new o().mutation({ sendInboxMessage: {
|
|
448
464
|
__args: { input: e },
|
|
449
465
|
threadId: !0
|
|
450
466
|
} });
|
|
451
467
|
return t;
|
|
452
|
-
},
|
|
468
|
+
}, Ae = /\[/g, je = /\]/g, Me = /\r?\n/g, X = (e) => e.replace(Ae, "(").replace(je, ")").replace(Me, " ").trim(), Ne = async ({ workspaceMemberId: e }) => {
|
|
453
469
|
let { data: { workspaceMember: n } } = await new s().get(`/rest/workspaceMembers/${e}`), r = `${n.name.firstName ?? ""} ${n.name.lastName ?? ""}`.trim();
|
|
454
|
-
return
|
|
470
|
+
return S({
|
|
455
471
|
objectNameSingular: "workspaceMember",
|
|
456
472
|
recordId: e,
|
|
457
473
|
displayName: X(t(r) ? r : n.userEmail)
|
|
@@ -459,7 +475,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
459
475
|
}, Z = ({ fullName: e, partName: t }) => {
|
|
460
476
|
let n = r(e) ? Reflect.get(e, t) : void 0;
|
|
461
477
|
return i(n) ? n : "";
|
|
462
|
-
},
|
|
478
|
+
}, Pe = ({ record: e, recordId: t, labelIdentifierField: n }) => {
|
|
463
479
|
if (!c(n)) return t;
|
|
464
480
|
let r = e[n.name];
|
|
465
481
|
return n.type === "FULL_NAME" ? `${Z({
|
|
@@ -469,7 +485,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
469
485
|
fullName: r,
|
|
470
486
|
partName: "lastName"
|
|
471
487
|
})}`.trim() : c(r) ? String(r) : "";
|
|
472
|
-
},
|
|
488
|
+
}, Fe = async ({ metadataClient: e, objectMetadata: t }) => {
|
|
473
489
|
if (!c(t.labelIdentifierFieldMetadataId)) return;
|
|
474
490
|
let { object: n } = await e.query({ object: {
|
|
475
491
|
__args: { id: t.id },
|
|
@@ -485,11 +501,11 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
485
501
|
}
|
|
486
502
|
} });
|
|
487
503
|
return n.fields.edges[0]?.node;
|
|
488
|
-
},
|
|
504
|
+
}, Ie = 1e3, Le = async ({ metadataClient: e, objectNameSingular: t }) => {
|
|
489
505
|
let { objects: n } = await e.query({ objects: {
|
|
490
506
|
__args: {
|
|
491
507
|
filter: {},
|
|
492
|
-
paging: { first:
|
|
508
|
+
paging: { first: Ie }
|
|
493
509
|
},
|
|
494
510
|
edges: { node: {
|
|
495
511
|
id: !0,
|
|
@@ -500,32 +516,34 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
500
516
|
} }), r = n.edges.find(({ node: e }) => e.nameSingular === t)?.node;
|
|
501
517
|
if (!c(r)) throw Error(`This workspace has no ${t} object.`);
|
|
502
518
|
return r;
|
|
503
|
-
},
|
|
504
|
-
let n = new o(), r = await
|
|
519
|
+
}, Re = async ({ objectNameSingular: e, recordId: t }) => {
|
|
520
|
+
let n = new o(), r = await Le({
|
|
505
521
|
metadataClient: n,
|
|
506
522
|
objectNameSingular: e
|
|
507
|
-
}), [i, a] = await Promise.all([
|
|
523
|
+
}), [i, a] = await Promise.all([Fe({
|
|
508
524
|
metadataClient: n,
|
|
509
525
|
objectMetadata: r
|
|
510
526
|
}), new s().get(`/rest/${r.namePlural}/${t}`)]);
|
|
511
|
-
return
|
|
527
|
+
return S({
|
|
512
528
|
objectNameSingular: e,
|
|
513
529
|
recordId: t,
|
|
514
|
-
displayName: X(
|
|
530
|
+
displayName: X(Pe({
|
|
515
531
|
record: a.data[e],
|
|
516
532
|
recordId: t,
|
|
517
533
|
labelIdentifierField: i
|
|
518
534
|
}))
|
|
519
535
|
});
|
|
520
|
-
},
|
|
521
|
-
objectNameSingular:
|
|
522
|
-
recordId:
|
|
536
|
+
}, ze = S({
|
|
537
|
+
objectNameSingular: U,
|
|
538
|
+
recordId: U,
|
|
523
539
|
displayName: "Ada"
|
|
524
|
-
}),
|
|
540
|
+
}), Be = async (e) => {
|
|
525
541
|
await new o().mutation({ attachRecordToInboxThread: { __args: { input: e } } });
|
|
526
|
-
},
|
|
542
|
+
}, Ve = async (e) => {
|
|
527
543
|
await new o().mutation({ detachRecordFromInboxThread: { __args: { input: e } } });
|
|
528
|
-
},
|
|
544
|
+
}, He = async (e) => {
|
|
545
|
+
await new o().mutation({ archiveInboxThread: { __args: { input: e } } });
|
|
546
|
+
}, Q = async (e) => {
|
|
529
547
|
let { enqueueJob: t } = await new o().mutation({ enqueueJob: {
|
|
530
548
|
__args: { input: e },
|
|
531
549
|
enqueued: !0,
|
|
@@ -533,16 +551,21 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
533
551
|
jobId: !0
|
|
534
552
|
} });
|
|
535
553
|
return t;
|
|
536
|
-
},
|
|
554
|
+
}, Ue = async (e) => {
|
|
537
555
|
let { enqueueJobs: t } = await new o().mutation({ enqueueJobs: {
|
|
538
556
|
__args: { input: e },
|
|
539
557
|
enqueued: !0,
|
|
540
558
|
logicFunctionUniversalIdentifier: !0,
|
|
541
559
|
enqueuedJobsCount: !0,
|
|
542
|
-
jobIds: !0
|
|
560
|
+
jobIds: !0,
|
|
561
|
+
jobs: {
|
|
562
|
+
jobId: !0,
|
|
563
|
+
sizeBytes: !0
|
|
564
|
+
},
|
|
565
|
+
availableBytes: !0
|
|
543
566
|
} });
|
|
544
567
|
return t;
|
|
545
|
-
},
|
|
568
|
+
}, We = async (e) => {
|
|
546
569
|
let { getJobs: t } = await new o().query({ getJobs: {
|
|
547
570
|
__args: { jobIds: e },
|
|
548
571
|
jobId: !0,
|
|
@@ -554,7 +577,7 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
554
577
|
finishedAt: !0
|
|
555
578
|
} });
|
|
556
579
|
return t;
|
|
557
|
-
},
|
|
580
|
+
}, Ge = (e) => ({
|
|
558
581
|
__args: {
|
|
559
582
|
paging: { first: e.length },
|
|
560
583
|
filter: { universalIdentifier: { in: e } }
|
|
@@ -564,20 +587,20 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
564
587
|
universalIdentifier: !0,
|
|
565
588
|
nameSingular: !0
|
|
566
589
|
} }
|
|
567
|
-
}),
|
|
590
|
+
}), Ke = async ({ timelineActivityTypeUniversalIdentifier: e, targetObjectUniversalIdentifier: t, linkedObjectMetadataUniversalIdentifier: n, targetRecordId: r, ...i }) => {
|
|
568
591
|
let a = [...new Set([t, n].filter(c))], { timelineActivityTypes: l, objects: u } = await new o().query({
|
|
569
592
|
timelineActivityTypes: {
|
|
570
593
|
id: !0,
|
|
571
594
|
universalIdentifier: !0,
|
|
572
595
|
isActive: !0
|
|
573
596
|
},
|
|
574
|
-
objects:
|
|
597
|
+
objects: Ge(a)
|
|
575
598
|
}), d = l.find(({ universalIdentifier: t }) => t === e);
|
|
576
599
|
if (!c(d)) throw Error(`Timeline activity type ${e} is not installed`);
|
|
577
600
|
if (!d.isActive) throw Error(`Timeline activity type ${e} is inactive`);
|
|
578
601
|
let f = new Map(u.edges.map(({ node: e }) => [e.universalIdentifier, e])), p = f.get(t);
|
|
579
602
|
if (!c(p)) throw Error(`Timeline activity target object ${t} is not installed`);
|
|
580
|
-
let m = `target${
|
|
603
|
+
let m = `target${oe(p.nameSingular)}Id`, h = c(n) ? f.get(n) : void 0;
|
|
581
604
|
if (c(n) && !c(h)) throw Error(`Timeline activity linked object ${n} is not installed`);
|
|
582
605
|
return (await new s().post("/rest/timelineActivities", {
|
|
583
606
|
...i,
|
|
@@ -585,10 +608,10 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
585
608
|
linkedObjectMetadataId: h?.id,
|
|
586
609
|
[m]: r
|
|
587
610
|
})).data.createTimelineActivity;
|
|
588
|
-
},
|
|
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 = {
|
|
589
612
|
async get(e, t) {
|
|
590
|
-
let { appKeyValue: n } = await
|
|
591
|
-
query:
|
|
613
|
+
let { appKeyValue: n } = await x({
|
|
614
|
+
query: qe,
|
|
592
615
|
variables: {
|
|
593
616
|
key: e,
|
|
594
617
|
scope: t?.scope ?? $
|
|
@@ -598,8 +621,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
598
621
|
return n?.value ?? null;
|
|
599
622
|
},
|
|
600
623
|
async set(e, t, n) {
|
|
601
|
-
await
|
|
602
|
-
query:
|
|
624
|
+
await x({
|
|
625
|
+
query: Je,
|
|
603
626
|
variables: { input: {
|
|
604
627
|
key: e,
|
|
605
628
|
value: t,
|
|
@@ -609,8 +632,8 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
609
632
|
});
|
|
610
633
|
},
|
|
611
634
|
async delete(e, t) {
|
|
612
|
-
let { deleteAppKeyValue: n } = await
|
|
613
|
-
query:
|
|
635
|
+
let { deleteAppKeyValue: n } = await x({
|
|
636
|
+
query: Ye,
|
|
614
637
|
variables: {
|
|
615
638
|
key: e,
|
|
616
639
|
scope: t?.scope ?? $
|
|
@@ -619,12 +642,12 @@ var ge = "\n subscription OnAgentChatEvent($agentUniversalIdentifier: UUID!, $t
|
|
|
619
642
|
});
|
|
620
643
|
return n;
|
|
621
644
|
}
|
|
622
|
-
},
|
|
645
|
+
}, Ze = class {
|
|
623
646
|
constructor(e, t) {
|
|
624
647
|
this.__twentyHttpResponse = !0, this.body = e, this.status = t?.status, this.headers = t?.headers;
|
|
625
648
|
}
|
|
626
649
|
};
|
|
627
650
|
//#endregion
|
|
628
|
-
export { p as AppConnectionAuthFailedError,
|
|
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 };
|
|
629
652
|
|
|
630
653
|
//# sourceMappingURL=index.mjs.map
|