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.
- package/CHANGELOG.md +18 -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 +57 -203
- package/dist/define/index.mjs +4968 -45967
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs +1 -84
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.d.ts +13 -2
- package/dist/front-component/index.mjs +203 -49932
- 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 +26 -26
- package/dist/logic-function/index.cjs.map +1 -1
- package/dist/logic-function/index.d.ts +46 -3
- package/dist/logic-function/index.mjs +123 -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 +3 -3
|
@@ -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"
|
|
47
|
+
}, re = (e) => {
|
|
48
|
+
let n = e[te];
|
|
49
|
+
return t(n) ? n : e[h];
|
|
55
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,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",
|
|
87
|
-
let { appConnection: t } = await
|
|
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
|
-
},
|
|
95
|
-
let { appConnections: n } = await
|
|
96
|
-
query:
|
|
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
|
-
},
|
|
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
|
-
}, C = "\n id\n handle\n displayName\n visibility\n connectedAccountId\n isSyncEnabled\n participantHandleFieldUniversalIdentifier\n messagingProviderUniversalIdentifier\n",
|
|
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,9 +179,9 @@ var d = "RetryableLogicFunctionError", f = class extends Error {
|
|
|
184
179
|
caller: "ingestMessages"
|
|
185
180
|
});
|
|
186
181
|
return n.messages;
|
|
187
|
-
},
|
|
188
|
-
if (!t(e) || e.length >
|
|
189
|
-
let { apiUrl: i, accessToken: a } =
|
|
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:
|
|
196
|
+
fieldMetadataUniversalIdentifier: P
|
|
202
197
|
})).id,
|
|
203
198
|
label: e
|
|
204
199
|
};
|
|
205
|
-
},
|
|
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
|
-
${
|
|
203
|
+
${L}
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
|
-
`,
|
|
212
|
-
let { appMessageFolders: t } = await
|
|
213
|
-
query:
|
|
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
|
-
},
|
|
213
|
+
}, B = `
|
|
219
214
|
mutation SyncAppMessageFolders($input: SyncAppMessageFoldersInput!) {
|
|
220
215
|
syncAppMessageFolders(input: $input) {
|
|
221
|
-
${
|
|
216
|
+
${L}
|
|
222
217
|
}
|
|
223
218
|
}
|
|
224
|
-
`,
|
|
225
|
-
let { syncAppMessageFolders: t } = await
|
|
226
|
-
query:
|
|
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
|
-
},
|
|
226
|
+
}, H = (e) => i(e) ? [{
|
|
232
227
|
role: "user",
|
|
233
228
|
content: e
|
|
234
|
-
}] : e,
|
|
235
|
-
let { runAgent: n } = await
|
|
236
|
-
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,
|
|
237
232
|
variables: { input: c(e) ? {
|
|
238
233
|
...t,
|
|
239
|
-
input:
|
|
234
|
+
input: H(e)
|
|
240
235
|
} : t },
|
|
241
236
|
caller: "runAgent"
|
|
242
237
|
});
|
|
243
238
|
return n;
|
|
244
|
-
},
|
|
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
|
-
},
|
|
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(
|
|
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
|
-
|
|
314
|
-
|
|
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:
|
|
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)),
|
|
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 (!
|
|
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
|
-
},
|
|
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 } =
|
|
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
|
|
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 =
|
|
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
|
|
394
|
-
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,
|
|
395
387
|
variables: t,
|
|
396
388
|
caller: "streamConversation",
|
|
397
389
|
signal: e,
|
|
398
390
|
closedEarlyAdvice: "; read the history and stream again to resume"
|
|
399
|
-
}),
|
|
400
|
-
let { generate: n } = await
|
|
401
|
-
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,
|
|
402
394
|
variables: e,
|
|
403
395
|
caller: "ai.generate",
|
|
404
396
|
signal: t,
|
|
405
397
|
isActingAsCaller: !0
|
|
406
398
|
});
|
|
407
399
|
return n;
|
|
408
|
-
},
|
|
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),
|
|
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
|
-
},
|
|
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:
|
|
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" &&
|
|
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
|
-
},
|
|
449
|
+
}, Oe = { generate: async ({ input: e, onChunk: t, signal: n, ...r }) => {
|
|
458
450
|
let i = { input: {
|
|
459
451
|
...r,
|
|
460
|
-
input:
|
|
452
|
+
input: H(e)
|
|
461
453
|
} };
|
|
462
|
-
return c(t) ?
|
|
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
|
-
} },
|
|
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
|
-
},
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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:
|
|
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
|
-
},
|
|
528
|
-
let n = new o(), r = await
|
|
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([
|
|
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
|
|
527
|
+
return S({
|
|
536
528
|
objectNameSingular: e,
|
|
537
529
|
recordId: t,
|
|
538
|
-
displayName: X(
|
|
530
|
+
displayName: X(Pe({
|
|
539
531
|
record: a.data[e],
|
|
540
532
|
recordId: t,
|
|
541
533
|
labelIdentifierField: i
|
|
542
534
|
}))
|
|
543
535
|
});
|
|
544
|
-
},
|
|
545
|
-
objectNameSingular:
|
|
546
|
-
recordId:
|
|
536
|
+
}, ze = S({
|
|
537
|
+
objectNameSingular: U,
|
|
538
|
+
recordId: U,
|
|
547
539
|
displayName: "Ada"
|
|
548
|
-
}),
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
}),
|
|
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:
|
|
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${
|
|
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
|
-
},
|
|
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
|
|
620
|
-
query:
|
|
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
|
|
631
|
-
query:
|
|
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
|
|
642
|
-
query:
|
|
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
|
-
},
|
|
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,
|
|
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
|