@m6d/cortex-angular 1.7.0 → 1.8.1
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.
|
@@ -51,6 +51,9 @@ function createCortexApiClient(getTransport) {
|
|
|
51
51
|
return text ? JSON.parse(text) : undefined;
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
|
+
getCapabilities() {
|
|
55
|
+
return send("/capabilities");
|
|
56
|
+
},
|
|
54
57
|
listThreads() {
|
|
55
58
|
return send("/threads");
|
|
56
59
|
},
|
|
@@ -1199,6 +1202,9 @@ var CORTEX_CLIENT_CONFIG = new InjectionToken("CORTEX_CLIENT_CONFIG");
|
|
|
1199
1202
|
class CortexApiClient {
|
|
1200
1203
|
config = inject(CORTEX_CLIENT_CONFIG);
|
|
1201
1204
|
client = createCortexApiClient(() => this.config().transport);
|
|
1205
|
+
getCapabilities() {
|
|
1206
|
+
return this.client.getCapabilities();
|
|
1207
|
+
}
|
|
1202
1208
|
listThreads() {
|
|
1203
1209
|
return this.client.listThreads();
|
|
1204
1210
|
}
|
|
@@ -1347,6 +1353,7 @@ class CortexChatService {
|
|
|
1347
1353
|
return unansweredToolCalls(chat.messages()).length > 0;
|
|
1348
1354
|
}, ...ngDevMode ? [{ debugName: "hasPendingToolCalls" }] : []);
|
|
1349
1355
|
messageMetadata = signal(new Map, ...ngDevMode ? [{ debugName: "messageMetadata" }] : []);
|
|
1356
|
+
capabilities = signal(undefined, ...ngDevMode ? [{ debugName: "capabilities" }] : []);
|
|
1350
1357
|
events = new Subject;
|
|
1351
1358
|
selectedThreadSnapshot = signal(undefined, ...ngDevMode ? [{ debugName: "selectedThreadSnapshot" }] : []);
|
|
1352
1359
|
config = inject(CORTEX_CLIENT_CONFIG);
|
|
@@ -1369,6 +1376,7 @@ class CortexChatService {
|
|
|
1369
1376
|
this.threadService.start();
|
|
1370
1377
|
this.subscribeToWsEvents();
|
|
1371
1378
|
this.subscribeToWsConnections();
|
|
1379
|
+
this.api.getCapabilities().then((capabilities) => this.capabilities.set(capabilities)).catch(() => {});
|
|
1372
1380
|
}
|
|
1373
1381
|
get events$() {
|
|
1374
1382
|
return this.events.asObservable();
|
|
@@ -1807,6 +1815,7 @@ class ChatComposerComponent {
|
|
|
1807
1815
|
translateService = inject(TranslateService);
|
|
1808
1816
|
text = model("", ...ngDevMode ? [{ debugName: "text" }] : []);
|
|
1809
1817
|
dragging = signal(false, ...ngDevMode ? [{ debugName: "dragging" }] : []);
|
|
1818
|
+
attachmentsEnabled = computed(() => this.chatService.capabilities()?.attachments ?? false, ...ngDevMode ? [{ debugName: "attachmentsEnabled" }] : []);
|
|
1810
1819
|
acceptedTypes = ATTACHMENT_MIME_TYPES.join(",");
|
|
1811
1820
|
canSend = computed(() => !this.queue.busy() && (Boolean(this.text().trim()) || this.queue.hasReady()), ...ngDevMode ? [{ debugName: "canSend" }] : []);
|
|
1812
1821
|
messageInput = viewChild("messageInput", ...ngDevMode ? [{ debugName: "messageInput" }] : []);
|
|
@@ -1821,7 +1830,8 @@ class ChatComposerComponent {
|
|
|
1821
1830
|
}
|
|
1822
1831
|
onDragOver(event) {
|
|
1823
1832
|
event.preventDefault();
|
|
1824
|
-
this.
|
|
1833
|
+
if (this.attachmentsEnabled())
|
|
1834
|
+
this.dragging.set(true);
|
|
1825
1835
|
}
|
|
1826
1836
|
onDragLeave(event) {
|
|
1827
1837
|
const area = event.currentTarget;
|
|
@@ -1832,11 +1842,12 @@ class ChatComposerComponent {
|
|
|
1832
1842
|
onDrop(event) {
|
|
1833
1843
|
event.preventDefault();
|
|
1834
1844
|
this.dragging.set(false);
|
|
1835
|
-
this.
|
|
1845
|
+
if (this.attachmentsEnabled())
|
|
1846
|
+
this.queue.accept([...event.dataTransfer?.files ?? []]);
|
|
1836
1847
|
}
|
|
1837
1848
|
onPaste(event) {
|
|
1838
1849
|
const files = event.clipboardData?.files;
|
|
1839
|
-
if (!files?.length)
|
|
1850
|
+
if (!this.attachmentsEnabled() || !files?.length)
|
|
1840
1851
|
return;
|
|
1841
1852
|
event.preventDefault();
|
|
1842
1853
|
this.queue.accept([...files]);
|
|
@@ -1902,31 +1913,33 @@ class ChatComposerComponent {
|
|
|
1902
1913
|
</button>
|
|
1903
1914
|
} @else {
|
|
1904
1915
|
<div class="cortex-widget__input-actions">
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
<
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1916
|
+
@if (attachmentsEnabled()) {
|
|
1917
|
+
<!-- Attach button -->
|
|
1918
|
+
<button
|
|
1919
|
+
type="button"
|
|
1920
|
+
(click)="fileInput.click()"
|
|
1921
|
+
class="cortex-widget__attach-btn"
|
|
1922
|
+
[attr.aria-label]="'translate_attach_files' | translate"
|
|
1923
|
+
>
|
|
1924
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
1925
|
+
<path
|
|
1926
|
+
d="M10.5 5.5 6.2 9.8a1.4 1.4 0 0 0 2 2l4.6-4.6a2.8 2.8 0 0 0-4-4L4.2 7.8a4.2 4.2 0 0 0 6 6l4-4"
|
|
1927
|
+
stroke="currentColor"
|
|
1928
|
+
stroke-width="1.3"
|
|
1929
|
+
stroke-linecap="round"
|
|
1930
|
+
stroke-linejoin="round"
|
|
1931
|
+
/>
|
|
1932
|
+
</svg>
|
|
1933
|
+
</button>
|
|
1934
|
+
<input
|
|
1935
|
+
#fileInput
|
|
1936
|
+
type="file"
|
|
1937
|
+
multiple
|
|
1938
|
+
[accept]="acceptedTypes"
|
|
1939
|
+
(change)="onFilesPicked($event)"
|
|
1940
|
+
class="cortex-widget__file-input"
|
|
1941
|
+
/>
|
|
1942
|
+
}
|
|
1930
1943
|
|
|
1931
1944
|
<!-- Send button -->
|
|
1932
1945
|
<button
|
|
@@ -2003,31 +2016,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.3", ngImpor
|
|
|
2003
2016
|
</button>
|
|
2004
2017
|
} @else {
|
|
2005
2018
|
<div class="cortex-widget__input-actions">
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
<
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2019
|
+
@if (attachmentsEnabled()) {
|
|
2020
|
+
<!-- Attach button -->
|
|
2021
|
+
<button
|
|
2022
|
+
type="button"
|
|
2023
|
+
(click)="fileInput.click()"
|
|
2024
|
+
class="cortex-widget__attach-btn"
|
|
2025
|
+
[attr.aria-label]="'translate_attach_files' | translate"
|
|
2026
|
+
>
|
|
2027
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
2028
|
+
<path
|
|
2029
|
+
d="M10.5 5.5 6.2 9.8a1.4 1.4 0 0 0 2 2l4.6-4.6a2.8 2.8 0 0 0-4-4L4.2 7.8a4.2 4.2 0 0 0 6 6l4-4"
|
|
2030
|
+
stroke="currentColor"
|
|
2031
|
+
stroke-width="1.3"
|
|
2032
|
+
stroke-linecap="round"
|
|
2033
|
+
stroke-linejoin="round"
|
|
2034
|
+
/>
|
|
2035
|
+
</svg>
|
|
2036
|
+
</button>
|
|
2037
|
+
<input
|
|
2038
|
+
#fileInput
|
|
2039
|
+
type="file"
|
|
2040
|
+
multiple
|
|
2041
|
+
[accept]="acceptedTypes"
|
|
2042
|
+
(change)="onFilesPicked($event)"
|
|
2043
|
+
class="cortex-widget__file-input"
|
|
2044
|
+
/>
|
|
2045
|
+
}
|
|
2031
2046
|
|
|
2032
2047
|
<!-- Send button -->
|
|
2033
2048
|
<button
|
package/package.json
CHANGED
|
@@ -52,6 +52,13 @@ export type ClientToolBinding = {
|
|
|
52
52
|
surface: "inline" | "modal";
|
|
53
53
|
embedOrigin: string;
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* What the server offers this agent's clients, fetched once at widget startup.
|
|
57
|
+
* The widget hides UI for anything absent; enforcement stays server-side.
|
|
58
|
+
*/
|
|
59
|
+
export type AgentCapabilities = {
|
|
60
|
+
attachments: boolean;
|
|
61
|
+
};
|
|
55
62
|
export type MessageMetadata = {
|
|
56
63
|
modelId?: string;
|
|
57
64
|
providerMetadata?: unknown;
|
|
@@ -214,6 +221,8 @@ declare class CortexChatService {
|
|
|
214
221
|
* the stream, and are merged back in by message id at render time.
|
|
215
222
|
*/
|
|
216
223
|
readonly messageMetadata: _angular_core.WritableSignal<ReadonlyMap<string, MessageMetadata>>;
|
|
224
|
+
/** What the server offers this agent's clients; undefined until the handshake answers. */
|
|
225
|
+
readonly capabilities: _angular_core.WritableSignal<AgentCapabilities | undefined>;
|
|
217
226
|
private readonly events;
|
|
218
227
|
private readonly selectedThreadSnapshot;
|
|
219
228
|
private readonly config;
|