@gentiq/core 1.0.0-beta.1 → 1.0.0-beta.3
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/dist/client/api.es.js +65 -43
- package/dist/client/brandingUrl.es.js +22 -0
- package/dist/composer/composerDrafts.es.js +77 -34
- package/dist/composer/runSelection.es.js +142 -0
- package/dist/errors.es.js +5 -0
- package/dist/index.d.ts +1301 -229
- package/dist/index.es.js +45 -42
- package/dist/internal.d.ts +1202 -219
- package/dist/internal.es.js +39 -35
- package/dist/protocol/chatRequest.es.js +47 -38
- package/dist/thread/chatTransport.es.js +28 -17
- package/dist/thread/threadController.es.js +200 -184
- package/package.json +1 -1
package/dist/client/api.es.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import { resolveAuthAdapter as m, createLocalStorageAuthAdapter as
|
|
2
|
-
import { createComposerDrafts as
|
|
3
|
-
import { createComposerFiles as
|
|
4
|
-
import { createChatRuntime as
|
|
5
|
-
import { createHttpClient as
|
|
6
|
-
const
|
|
7
|
-
function f(t = {},
|
|
1
|
+
import { resolveAuthAdapter as m, createLocalStorageAuthAdapter as q } from "./auth.es.js";
|
|
2
|
+
import { createComposerDrafts as y } from "../composer/composerDrafts.es.js";
|
|
3
|
+
import { createComposerFiles as g } from "../composer/composerFiles.es.js";
|
|
4
|
+
import { createChatRuntime as _ } from "../thread/chatRuntime.es.js";
|
|
5
|
+
import { createHttpClient as p, errorFromResponse as b } from "./http.es.js";
|
|
6
|
+
const l = 3e4;
|
|
7
|
+
function f(t = {}, o = {}) {
|
|
8
8
|
const c = m(
|
|
9
|
-
t.authAdapter ??
|
|
10
|
-
),
|
|
9
|
+
t.authAdapter ?? q(t.cacheNamespace ?? "gentiq")
|
|
10
|
+
), u = p({
|
|
11
11
|
basePath: t.basePath ?? "/api",
|
|
12
12
|
fetch: t.fetch,
|
|
13
|
-
timeout: t.timeout ??
|
|
13
|
+
timeout: t.timeout ?? l,
|
|
14
14
|
getHeaders: c.getHeaders,
|
|
15
15
|
credentials: c.credentials
|
|
16
|
-
}),
|
|
17
|
-
http:
|
|
18
|
-
resolveAttachment: (
|
|
19
|
-
throttleMs:
|
|
20
|
-
getRunOptions:
|
|
16
|
+
}), d = T(u, c, t), e = g((a, i) => d.uploadAttachment(a, i)), r = y(), s = _({
|
|
17
|
+
http: u,
|
|
18
|
+
resolveAttachment: (a) => d.getAttachmentBlobUrl(a),
|
|
19
|
+
throttleMs: o.throttleMs,
|
|
20
|
+
getRunOptions: o.getRunOptions
|
|
21
21
|
});
|
|
22
|
-
return
|
|
22
|
+
return s.onEvent((a) => {
|
|
23
|
+
a.type === "thread-started" && r.moveRunSelection("", a.threadId);
|
|
24
|
+
}), { api: d, http: u, auth: c, options: t, composerFiles: e, composerDrafts: r, chat: s };
|
|
23
25
|
}
|
|
24
|
-
function
|
|
26
|
+
function U(t) {
|
|
25
27
|
return f(t).api;
|
|
26
28
|
}
|
|
27
|
-
const
|
|
28
|
-
function T(t,
|
|
29
|
-
const
|
|
30
|
-
async function
|
|
29
|
+
const n = (t) => t.replace(/^\//, "");
|
|
30
|
+
function T(t, o, c) {
|
|
31
|
+
const u = c.timeout ?? l;
|
|
32
|
+
async function d(e) {
|
|
31
33
|
return URL.createObjectURL(await e.blob());
|
|
32
34
|
}
|
|
33
35
|
return {
|
|
@@ -43,8 +45,8 @@ function T(t, a, c) {
|
|
|
43
45
|
logout: async () => {
|
|
44
46
|
const e = await t.fetch("/auth/logout", { method: "POST" });
|
|
45
47
|
if (!e.ok && e.status !== 401)
|
|
46
|
-
throw
|
|
47
|
-
|
|
48
|
+
throw b(e, await e.text().catch(() => ""));
|
|
49
|
+
o.clearToken();
|
|
48
50
|
},
|
|
49
51
|
/**
|
|
50
52
|
* Sign in. `identifier` is matched against every enabled login field on the backend (the
|
|
@@ -55,18 +57,18 @@ function T(t, a, c) {
|
|
|
55
57
|
body: { login: e, password: r },
|
|
56
58
|
auth: !1
|
|
57
59
|
});
|
|
58
|
-
return
|
|
60
|
+
return o.setToken(s.token), s;
|
|
59
61
|
},
|
|
60
62
|
/**
|
|
61
63
|
* Create an account and sign in. `values` maps each enabled login field to the value the
|
|
62
64
|
* user gave for it; the backend requires at least one.
|
|
63
65
|
*/
|
|
64
|
-
register: async (e, r, s,
|
|
65
|
-
const
|
|
66
|
-
body: { ...e, password: r, name: s, surname:
|
|
66
|
+
register: async (e, r, s, a, i) => {
|
|
67
|
+
const h = await t.request("post", "/public/auth/register", {
|
|
68
|
+
body: { ...e, password: r, name: s, surname: a, metadata: i },
|
|
67
69
|
auth: !1
|
|
68
70
|
});
|
|
69
|
-
return
|
|
71
|
+
return o.setToken(h.token), h;
|
|
70
72
|
},
|
|
71
73
|
/** The signed-in user's access: their plan and its usage windows, or their credits. */
|
|
72
74
|
getEntitlement: (e) => t.request("get", "/users/me/entitlement", { signal: e }),
|
|
@@ -81,7 +83,7 @@ function T(t, a, c) {
|
|
|
81
83
|
*/
|
|
82
84
|
exchangeLoginCode: async (e, r) => {
|
|
83
85
|
const s = await t.request("post", "/auth/exchange", { body: { code: e }, signal: r });
|
|
84
|
-
return s.token &&
|
|
86
|
+
return s.token && o.setToken(s.token), s;
|
|
85
87
|
},
|
|
86
88
|
/**
|
|
87
89
|
* A page of the user's threads, pinned first and then by last activity; with `query`, only
|
|
@@ -98,27 +100,27 @@ function T(t, a, c) {
|
|
|
98
100
|
* `before`, a page's `next_cursor`, the `limit` before that page.
|
|
99
101
|
*/
|
|
100
102
|
getThreadMessages: (e, { before: r, limit: s } = {}) => t.request("get", "/chat/threads/{thread_id}", {
|
|
101
|
-
path: { thread_id:
|
|
103
|
+
path: { thread_id: n(e) },
|
|
102
104
|
query: { before: r, limit: s }
|
|
103
105
|
}),
|
|
104
106
|
deleteThread: (e) => t.request("delete", "/chat/threads/{thread_id}", {
|
|
105
|
-
path: { thread_id:
|
|
107
|
+
path: { thread_id: n(e) }
|
|
106
108
|
}),
|
|
107
109
|
updateThreadTitle: (e, r) => t.request("patch", "/chat/threads/{thread_id}", {
|
|
108
|
-
path: { thread_id:
|
|
110
|
+
path: { thread_id: n(e) },
|
|
109
111
|
body: { title: r }
|
|
110
112
|
}),
|
|
111
113
|
pinThread: (e, r) => t.request("patch", "/chat/threads/{thread_id}", {
|
|
112
|
-
path: { thread_id:
|
|
114
|
+
path: { thread_id: n(e) },
|
|
113
115
|
body: { pinned: r }
|
|
114
116
|
}),
|
|
115
117
|
shareThread: (e) => t.request("post", "/chat/threads/{thread_id}/share", {
|
|
116
|
-
path: { thread_id:
|
|
118
|
+
path: { thread_id: n(e) }
|
|
117
119
|
}),
|
|
118
120
|
/** Revoke every public link to a thread. */
|
|
119
121
|
unshareThread: async (e) => {
|
|
120
122
|
await t.request("delete", "/chat/threads/{thread_id}/share", {
|
|
121
|
-
path: { thread_id:
|
|
123
|
+
path: { thread_id: n(e) }
|
|
122
124
|
});
|
|
123
125
|
},
|
|
124
126
|
getSharedThread: (e) => t.request("get", "/public/shared/{share_id}", {
|
|
@@ -129,9 +131,9 @@ function T(t, a, c) {
|
|
|
129
131
|
* Fetch an attachment and return a blob URL usable in `<img src>`. The caller revokes it
|
|
130
132
|
* with `URL.revokeObjectURL` when done.
|
|
131
133
|
*/
|
|
132
|
-
getAttachmentBlobUrl: async (e) => c.attachmentResolver ? c.attachmentResolver(e) :
|
|
134
|
+
getAttachmentBlobUrl: async (e) => c.attachmentResolver ? c.attachmentResolver(e) : d(await t.send(`/chat/attachments/${e}`)),
|
|
133
135
|
/** Fetch an attachment of a shared snapshot and return a blob URL. */
|
|
134
|
-
getPublicAttachmentBlobUrl: async (e, r) =>
|
|
136
|
+
getPublicAttachmentBlobUrl: async (e, r) => d(
|
|
135
137
|
await t.send(
|
|
136
138
|
`/public/shared/${encodeURIComponent(e)}/attachments/${r}`,
|
|
137
139
|
{
|
|
@@ -140,7 +142,7 @@ function T(t, a, c) {
|
|
|
140
142
|
)
|
|
141
143
|
),
|
|
142
144
|
saveFeedback: (e, r, s) => t.request("post", "/chat/feedback", {
|
|
143
|
-
body: { thread_id:
|
|
145
|
+
body: { thread_id: n(e), message_id: r, sentiment: s }
|
|
144
146
|
}),
|
|
145
147
|
/**
|
|
146
148
|
* Transcribe a recording of the user into text for the composer. The text is empty
|
|
@@ -150,7 +152,7 @@ function T(t, a, c) {
|
|
|
150
152
|
transcribe: (e, r) => t.request("post", "/chat/transcribe", {
|
|
151
153
|
blob: e.type ? e : new Blob([e], { type: "audio/webm" }),
|
|
152
154
|
signal: r,
|
|
153
|
-
timeout:
|
|
155
|
+
timeout: u * 4
|
|
154
156
|
}),
|
|
155
157
|
/**
|
|
156
158
|
* Upload a file for a message the user is about to send. A file part names the answer's `id`
|
|
@@ -167,7 +169,7 @@ function T(t, a, c) {
|
|
|
167
169
|
getMe: (e) => t.request("get", "/users/me", { signal: e }),
|
|
168
170
|
updateMe: async (e) => {
|
|
169
171
|
const r = await t.request("patch", "/users/me", { body: e });
|
|
170
|
-
return r.token &&
|
|
172
|
+
return r.token && o.setToken(r.token), r;
|
|
171
173
|
},
|
|
172
174
|
getAppConfig: (e) => t.request("get", "/config", { signal: e, auth: !1 }),
|
|
173
175
|
/** Whether the service is under maintenance. Public; polled by `useGentiqStatus`. */
|
|
@@ -237,11 +239,31 @@ function T(t, a, c) {
|
|
|
237
239
|
/** Delete a user-owned custom remote MCP server. */
|
|
238
240
|
deleteUserMCPConnector: (e) => t.request("delete", "/connectors/user-mcp/{connector_id}", {
|
|
239
241
|
path: { connector_id: e }
|
|
240
|
-
})
|
|
242
|
+
}),
|
|
243
|
+
// --- Memory ---
|
|
244
|
+
/** List memories belonging to the current user (or requested authorized scope). */
|
|
245
|
+
listMemories: (e, r) => t.request("get", "/memory", { query: e, signal: r }),
|
|
246
|
+
/** Create (or deduplicate) a memory item for the current user. */
|
|
247
|
+
createMemory: (e) => t.request("post", "/memory", { body: e }),
|
|
248
|
+
/** Update an existing memory item owned by the current user. */
|
|
249
|
+
updateMemory: (e, r) => t.request("patch", "/memory/{memory_id}", {
|
|
250
|
+
path: { memory_id: e },
|
|
251
|
+
body: r
|
|
252
|
+
}),
|
|
253
|
+
/** Delete a stored memory item owned by the current user. */
|
|
254
|
+
deleteMemory: (e) => t.request("delete", "/memory/{memory_id}", {
|
|
255
|
+
path: { memory_id: e }
|
|
256
|
+
}),
|
|
257
|
+
/** Delete all memories in the user's writable scopes (or the named scope). */
|
|
258
|
+
clearMemories: (e) => t.request("delete", "/memory", { query: e }),
|
|
259
|
+
/** Fetch the current user's memory preferences and limits. */
|
|
260
|
+
getMemorySettings: (e) => t.request("get", "/memory/settings", { signal: e }),
|
|
261
|
+
/** Update the current user's memory preferences. */
|
|
262
|
+
updateMemorySettings: (e) => t.request("patch", "/memory/settings", { body: e })
|
|
241
263
|
};
|
|
242
264
|
}
|
|
243
265
|
export {
|
|
244
|
-
|
|
245
|
-
|
|
266
|
+
l as DEFAULT_TIMEOUT_MS,
|
|
267
|
+
U as createGentiqApi,
|
|
246
268
|
f as createGentiqRuntime
|
|
247
269
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const n = "/api/public/branding/";
|
|
2
|
+
function s(e, t = "/api") {
|
|
3
|
+
return e.startsWith(n) ? `${t.replace(/\/+$/, "")}${e.slice(4)}` : e;
|
|
4
|
+
}
|
|
5
|
+
function o(e) {
|
|
6
|
+
const t = e.trim();
|
|
7
|
+
if (!t || t.length > 2048 || [...t].some((r) => /\s/.test(r) || r.charCodeAt(0) < 32))
|
|
8
|
+
return !1;
|
|
9
|
+
if (t.startsWith("/") && !t.startsWith("//"))
|
|
10
|
+
return !0;
|
|
11
|
+
try {
|
|
12
|
+
const r = new URL(t);
|
|
13
|
+
return (r.protocol === "http:" || r.protocol === "https:") && !!r.host;
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
n as BRANDING_URL_PREFIX,
|
|
20
|
+
o as isValidIconUrl,
|
|
21
|
+
s as resolveBrandingUrl
|
|
22
|
+
};
|
|
@@ -1,55 +1,98 @@
|
|
|
1
1
|
import { normalizeWhitespace as p } from "./references.es.js";
|
|
2
|
-
function
|
|
3
|
-
return
|
|
2
|
+
function h(s) {
|
|
3
|
+
return s ?? "";
|
|
4
4
|
}
|
|
5
|
-
const
|
|
6
|
-
function
|
|
5
|
+
const u = { text: "", references: [], voiceInputs: [] };
|
|
6
|
+
function v(s) {
|
|
7
7
|
return [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
p(
|
|
13
|
-
].filter((
|
|
8
|
+
s.sourceId,
|
|
9
|
+
s.messageId,
|
|
10
|
+
s.partIndex,
|
|
11
|
+
s.kind,
|
|
12
|
+
p(s.excerpt)
|
|
13
|
+
].filter((o) => o !== void 0 && o !== "").join(":");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
function g() {
|
|
16
|
+
const s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), a = (e) => s.get(e) ?? u, f = (e) => e !== void 0 && Object.keys(e).length > 0;
|
|
17
|
+
function b(e) {
|
|
18
|
+
return e.text === "" && e.references.length === 0 && e.voiceInputs.length === 0 && e.mode === void 0 && !f(e.capabilities);
|
|
19
|
+
}
|
|
20
|
+
function c(e, i) {
|
|
21
|
+
const t = a(e), n = { ...t, ...i(t) };
|
|
22
|
+
n.capabilities && Object.keys(n.capabilities).length === 0 && delete n.capabilities, b(n) ? s.delete(e) : s.set(e, n), o.forEach((r) => r());
|
|
20
23
|
}
|
|
21
24
|
return {
|
|
22
|
-
get:
|
|
25
|
+
get: a,
|
|
23
26
|
subscribe(e) {
|
|
24
|
-
return
|
|
25
|
-
|
|
27
|
+
return o.add(e), () => {
|
|
28
|
+
o.delete(e);
|
|
26
29
|
};
|
|
27
30
|
},
|
|
28
|
-
setText: (e,
|
|
29
|
-
|
|
31
|
+
setText: (e, i) => {
|
|
32
|
+
a(e).text !== i && c(e, () => ({ text: i }));
|
|
30
33
|
},
|
|
31
|
-
addReference: (e,
|
|
32
|
-
const
|
|
33
|
-
return { references: [
|
|
34
|
+
addReference: (e, i, t) => c(e, ({ references: n }) => {
|
|
35
|
+
const r = v(i), d = n.filter((l) => v(l) !== r);
|
|
36
|
+
return { references: [i, ...d].slice(0, t) };
|
|
34
37
|
}),
|
|
35
|
-
removeReference: (e,
|
|
36
|
-
references:
|
|
38
|
+
removeReference: (e, i) => c(e, ({ references: t }) => ({
|
|
39
|
+
references: t.filter((n) => n.id !== i)
|
|
37
40
|
})),
|
|
38
41
|
clearReferences: (e) => {
|
|
39
|
-
|
|
42
|
+
a(e).references.length > 0 && c(e, () => ({ references: [] }));
|
|
43
|
+
},
|
|
44
|
+
addVoiceInput: (e, i) => c(e, ({ voiceInputs: t }) => ({ voiceInputs: [...t, i] })),
|
|
45
|
+
setMode: (e, i) => {
|
|
46
|
+
a(e).mode !== i && c(e, () => ({ mode: i }));
|
|
47
|
+
},
|
|
48
|
+
setCapability: (e, i, t) => {
|
|
49
|
+
const n = a(e).capabilities ?? {};
|
|
50
|
+
if (t === void 0) {
|
|
51
|
+
if (!(i in n)) return;
|
|
52
|
+
const r = { ...n };
|
|
53
|
+
delete r[i], c(e, () => ({ capabilities: Object.keys(r).length > 0 ? r : void 0 }));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
n[i] !== t && c(e, () => ({ capabilities: { ...n, [i]: t } }));
|
|
57
|
+
},
|
|
58
|
+
clearRunSelection: (e) => {
|
|
59
|
+
const i = a(e);
|
|
60
|
+
i.mode === void 0 && !f(i.capabilities) || c(e, () => ({ mode: void 0, capabilities: void 0 }));
|
|
61
|
+
},
|
|
62
|
+
moveRunSelection: (e, i) => {
|
|
63
|
+
const t = a(e);
|
|
64
|
+
if (e === i || t.mode === void 0 && !f(t.capabilities)) return;
|
|
65
|
+
const n = t.mode, r = t.capabilities ? { ...t.capabilities } : void 0;
|
|
66
|
+
c(e, () => ({ mode: void 0, capabilities: void 0 })), c(i, () => ({
|
|
67
|
+
...n !== void 0 ? { mode: n } : {},
|
|
68
|
+
...r ? { capabilities: r } : {}
|
|
69
|
+
}));
|
|
40
70
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
71
|
+
take: (e, i) => {
|
|
72
|
+
const t = a(e);
|
|
73
|
+
if (t !== u) {
|
|
74
|
+
const n = i?.clearMode ? void 0 : t.mode;
|
|
75
|
+
let r = t.capabilities ? { ...t.capabilities } : void 0;
|
|
76
|
+
if (r && i?.clearCapabilities?.length) {
|
|
77
|
+
for (const l of i.clearCapabilities) delete r[l];
|
|
78
|
+
Object.keys(r).length === 0 && (r = void 0);
|
|
79
|
+
}
|
|
80
|
+
const d = {
|
|
81
|
+
...u,
|
|
82
|
+
...n !== void 0 ? { mode: n } : {},
|
|
83
|
+
...r ? { capabilities: r } : {}
|
|
84
|
+
};
|
|
85
|
+
b(d) ? s.delete(e) : s.set(e, d), o.forEach((l) => l());
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
45
88
|
},
|
|
46
89
|
clear() {
|
|
47
|
-
|
|
90
|
+
s.size !== 0 && (s.clear(), o.forEach((e) => e()));
|
|
48
91
|
}
|
|
49
92
|
};
|
|
50
93
|
}
|
|
51
94
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
h as composerScope,
|
|
96
|
+
g as createComposerDrafts,
|
|
97
|
+
v as referenceSourceKey
|
|
55
98
|
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
function P(s) {
|
|
2
|
+
return [...s].sort((l, a) => (l.order ?? 0) - (a.order ?? 0));
|
|
3
|
+
}
|
|
4
|
+
function z(s, l) {
|
|
5
|
+
return s ? l?.[s] === !0 : !0;
|
|
6
|
+
}
|
|
7
|
+
function I({
|
|
8
|
+
modes: s,
|
|
9
|
+
capabilities: l,
|
|
10
|
+
entitlementFeatures: a,
|
|
11
|
+
threadMode: m,
|
|
12
|
+
threadCapabilities: r,
|
|
13
|
+
draftMode: k,
|
|
14
|
+
draftCapabilities: p,
|
|
15
|
+
hiddenModes: u,
|
|
16
|
+
hiddenCapabilities: S
|
|
17
|
+
}) {
|
|
18
|
+
const f = P(s.filter((e) => !u?.has(e.key))), w = P(l.filter((e) => !S?.has(e.key))), v = f.find((e) => e.default) ?? null, M = (e) => z(e.feature, a);
|
|
19
|
+
let n = v;
|
|
20
|
+
if (k === null)
|
|
21
|
+
n = v;
|
|
22
|
+
else if (typeof k == "string") {
|
|
23
|
+
const e = f.find((t) => t.key === k);
|
|
24
|
+
n = e && M(e) ? e : v;
|
|
25
|
+
} else if (typeof m == "string") {
|
|
26
|
+
const e = f.find((t) => t.key === m);
|
|
27
|
+
n = e && M(e) ? e : v;
|
|
28
|
+
}
|
|
29
|
+
const F = f.map((e) => {
|
|
30
|
+
const t = M(e);
|
|
31
|
+
return {
|
|
32
|
+
mode: e,
|
|
33
|
+
active: n?.key === e.key,
|
|
34
|
+
isDefault: !!e.default,
|
|
35
|
+
disabled: !t,
|
|
36
|
+
...t ? {} : { disabledReason: "feature" }
|
|
37
|
+
};
|
|
38
|
+
}), q = n?.allowed_capabilities != null ? new Set(n.allowed_capabilities) : null, B = new Set(n?.forced_capabilities ?? []), G = new Set(n?.disabled_capabilities ?? []), g = new Map(l.map((e) => [e.key, e])), T = (e) => z(e.feature, a) ? G.has(e.key) || q !== null && !q.has(e.key) ? "mode" : void 0 : "feature", C = (e) => {
|
|
39
|
+
const t = /* @__PURE__ */ new Set([e]), o = [e];
|
|
40
|
+
for (let i = 0; i < o.length; i += 1) {
|
|
41
|
+
const c = g.get(o[i]);
|
|
42
|
+
for (const y of c?.implies ?? [])
|
|
43
|
+
!t.has(y) && g.has(y) && (t.add(y), o.push(y));
|
|
44
|
+
}
|
|
45
|
+
return o;
|
|
46
|
+
}, R = (e) => {
|
|
47
|
+
let t = !1;
|
|
48
|
+
for (const o of C(e)) {
|
|
49
|
+
const i = g.get(o);
|
|
50
|
+
if (!i) continue;
|
|
51
|
+
const c = T(i);
|
|
52
|
+
if (c === "feature") return "feature";
|
|
53
|
+
c === "mode" && (t = !0);
|
|
54
|
+
}
|
|
55
|
+
return t ? "mode" : void 0;
|
|
56
|
+
}, d = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const e of B) {
|
|
58
|
+
const t = g.get(e);
|
|
59
|
+
t?.exclusive_group && d.set(t.exclusive_group, e);
|
|
60
|
+
}
|
|
61
|
+
for (const e of w)
|
|
62
|
+
!e.exclusive_group || d.has(e.exclusive_group) || p?.[e.key] === !0 && !R(e.key) && d.set(e.exclusive_group, e.key);
|
|
63
|
+
for (const e of w)
|
|
64
|
+
!e.exclusive_group || d.has(e.exclusive_group) || e.sticky === "thread" && r?.[e.key] === !0 && p?.[e.key] !== !1 && !R(e.key) && d.set(e.exclusive_group, e.key);
|
|
65
|
+
const A = /* @__PURE__ */ new Set(), W = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const e of w) {
|
|
67
|
+
const t = R(e.key);
|
|
68
|
+
if (W.set(e.key, t), t || B.has(e.key)) continue;
|
|
69
|
+
const o = e.exclusive_group ? d.get(e.exclusive_group) : void 0;
|
|
70
|
+
if (o && o !== e.key) continue;
|
|
71
|
+
const i = e.default ?? !1;
|
|
72
|
+
let c;
|
|
73
|
+
p && e.key in p ? c = p[e.key] : e.sticky === "thread" && r && e.key in r ? c = r[e.key] : c = i, c && (e.exclusive_group && !d.has(e.exclusive_group) && d.set(e.exclusive_group, e.key), A.add(e.key));
|
|
74
|
+
}
|
|
75
|
+
const h = /* @__PURE__ */ new Map();
|
|
76
|
+
if (n)
|
|
77
|
+
for (const e of B) {
|
|
78
|
+
const t = g.get(e);
|
|
79
|
+
if (!(!t || T(t))) {
|
|
80
|
+
h.set(e, { kind: "mode", key: n.key });
|
|
81
|
+
for (const o of C(e))
|
|
82
|
+
o !== e && !h.has(o) && h.set(o, { kind: "mode", key: n.key });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const e of A)
|
|
86
|
+
for (const t of C(e))
|
|
87
|
+
t !== e && !h.has(t) && h.set(t, { kind: "capability", key: e });
|
|
88
|
+
const K = w.map((e) => {
|
|
89
|
+
const t = W.get(e.key), o = h.get(e.key), i = !!o, c = !!t && !i, y = c ? t : void 0, H = e.default ?? !1, O = i || !c && A.has(e.key), E = O !== H, j = e.chip ?? "when_changed";
|
|
90
|
+
let x = !1;
|
|
91
|
+
return !c && !i && (j === "always" ? x = !0 : j === "when_active" ? x = O : j === "when_changed" && (x = E)), {
|
|
92
|
+
capability: e,
|
|
93
|
+
active: O,
|
|
94
|
+
isChanged: E,
|
|
95
|
+
forced: i,
|
|
96
|
+
...o ? { forcedBy: o } : {},
|
|
97
|
+
disabled: c,
|
|
98
|
+
...y ? { disabledReason: y } : {},
|
|
99
|
+
showChip: x
|
|
100
|
+
};
|
|
101
|
+
}), D = [];
|
|
102
|
+
for (const e of K)
|
|
103
|
+
e.showChip && D.push({
|
|
104
|
+
kind: "capability",
|
|
105
|
+
key: e.capability.key,
|
|
106
|
+
capability: e.capability,
|
|
107
|
+
active: e.active,
|
|
108
|
+
forced: e.forced
|
|
109
|
+
});
|
|
110
|
+
let b, _;
|
|
111
|
+
for (const e of K)
|
|
112
|
+
e.active && (!b && e.capability.placeholder && (b = e.capability.placeholder), !_ && e.capability.attachment_types != null && (_ = e.capability.attachment_types));
|
|
113
|
+
return !b && n?.placeholder && (b = n.placeholder), !_ && n?.attachment_types != null && (_ = n.attachment_types), {
|
|
114
|
+
modes: F,
|
|
115
|
+
capabilities: K,
|
|
116
|
+
activeMode: n,
|
|
117
|
+
defaultMode: v,
|
|
118
|
+
chips: D,
|
|
119
|
+
effectivePlaceholder: b,
|
|
120
|
+
effectiveAttachmentTypes: _
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function J(s, l) {
|
|
124
|
+
let a;
|
|
125
|
+
s.mode === null ? a = null : typeof s.mode == "string" && l.activeMode?.key === s.mode && (a = s.mode);
|
|
126
|
+
const m = new Map(l.capabilities.map((u) => [u.capability.key, u])), r = {}, k = [];
|
|
127
|
+
for (const [u, S] of Object.entries(s.capabilities ?? {})) {
|
|
128
|
+
const f = m.get(u);
|
|
129
|
+
f && (f.capability.sticky === "turn" && k.push(u), !(f.disabled || f.forced) && (r[u] = S));
|
|
130
|
+
}
|
|
131
|
+
const p = typeof s.mode == "string" && l.activeMode?.key === s.mode && l.activeMode.sticky === "turn";
|
|
132
|
+
return {
|
|
133
|
+
...a !== void 0 ? { requestMode: a } : {},
|
|
134
|
+
...Object.keys(r).length > 0 ? { requestCapabilities: r } : {},
|
|
135
|
+
clearModeAfterSend: p,
|
|
136
|
+
clearCapabilitiesAfterSend: k
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
J as buildTurnSelection,
|
|
141
|
+
I as resolveRunSelection
|
|
142
|
+
};
|
package/dist/errors.es.js
CHANGED
|
@@ -68,6 +68,11 @@ const n = {
|
|
|
68
68
|
CONNECTOR_OAUTH_INVALID_STATE: "connector_oauth_invalid_state",
|
|
69
69
|
CONNECTOR_URL_BLOCKED: "connector_url_blocked",
|
|
70
70
|
USER_MCP_DISABLED: "user_mcp_disabled",
|
|
71
|
+
// Memory
|
|
72
|
+
MEMORY_NOT_FOUND: "memory_not_found",
|
|
73
|
+
MEMORY_LIMIT_REACHED: "memory_limit_reached",
|
|
74
|
+
MEMORY_DISABLED: "memory_disabled",
|
|
75
|
+
MEMORY_SCOPE_FORBIDDEN: "memory_scope_forbidden",
|
|
71
76
|
// System Errors
|
|
72
77
|
INTERNAL_ERROR: "internal_error",
|
|
73
78
|
VALIDATION_ERROR: "validation_error",
|