@aparte/core 0.7.1 → 0.8.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/README.md +20 -6
- package/dist/client/aparte-client.d.ts +113 -47
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/lifecycle-events.d.ts +55 -0
- package/dist/client/lifecycle-events.d.ts.map +1 -0
- package/dist/client/stream-adapter.d.ts +11 -5
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/client/xml-artifact-feed.d.ts +76 -0
- package/dist/client/xml-artifact-feed.d.ts.map +1 -0
- package/dist/components/bubble/aparte-chat-bubble.d.ts +35 -8
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +0 -6
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-action.d.ts +18 -3
- package/dist/components/composer/aparte-composer-action.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-cancel.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +0 -2
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-send.d.ts +5 -0
- package/dist/components/composer/aparte-composer-send.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-toolbar.d.ts +4 -0
- package/dist/components/composer/aparte-composer-toolbar.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +64 -6
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/composer/index.d.ts +1 -1
- package/dist/components/composer/index.d.ts.map +1 -1
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +2 -5
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/conversation-list/index.d.ts +1 -1
- package/dist/components/conversation-list/index.d.ts.map +1 -1
- package/dist/components/elicitation/aparte-elicitation.d.ts +63 -3
- package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/status/aparte-chat-status.d.ts +8 -6
- package/dist/components/status/aparte-chat-status.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +35 -9
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/action-provider.d.ts +4 -4
- package/dist/config/aparte-config.d.ts +124 -41
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/attachment-renderer.d.ts +1 -1
- package/dist/config/avatar-provider.d.ts +1 -1
- package/dist/config/config-context.d.ts +66 -11
- package/dist/config/config-context.d.ts.map +1 -1
- package/dist/config/elicitation-field-renderer.d.ts +73 -0
- package/dist/config/elicitation-field-renderer.d.ts.map +1 -0
- package/dist/config/error-renderer.d.ts +1 -1
- package/dist/config/icon-provider.d.ts +2 -2
- package/dist/config/icon-provider.d.ts.map +1 -1
- package/dist/config/index.d.ts +7 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/locale.d.ts +43 -2
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/config/sanitize.d.ts +1 -7
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sibling-nav-renderer.d.ts +1 -1
- package/dist/config/skeleton-provider.d.ts +2 -2
- package/dist/config/skeleton-provider.d.ts.map +1 -1
- package/dist/config/status-renderer.d.ts +1 -1
- package/dist/conversations/conversation-controller.d.ts +19 -5
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +2 -2
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/conversations/index.d.ts +1 -1
- package/dist/conversations/index.d.ts.map +1 -1
- package/dist/conversations/types.d.ts +1 -1
- package/dist/custom-elements.json +6664 -4877
- package/dist/elicitation/index.d.ts +1 -1
- package/dist/elicitation/panel.d.ts +32 -0
- package/dist/elicitation/panel.d.ts.map +1 -1
- package/dist/elicitation/types.d.ts +29 -2
- package/dist/elicitation/types.d.ts.map +1 -1
- package/dist/host/aparte-chat-host.d.ts +3 -3
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/{index-Dn7TH14G.js → index-BieFbKeW.js} +1795 -1238
- package/dist/index-BieFbKeW.js.map +1 -0
- package/dist/index.css +299 -21
- package/dist/index.d.ts +21 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +447 -200
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +22 -13
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +54 -46
- package/dist/index.node.js.map +1 -1
- package/dist/interop/element-props.d.ts +1 -1
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/parsers/aparte-stream-parser.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/select/aparte-optgroup.d.ts +15 -4
- package/dist/primitives/select/aparte-optgroup.d.ts.map +1 -1
- package/dist/primitives/select/aparte-option.d.ts +0 -5
- package/dist/primitives/select/aparte-option.d.ts.map +1 -1
- package/dist/primitives/select/aparte-select.d.ts +17 -5
- package/dist/primitives/select/aparte-select.d.ts.map +1 -1
- package/dist/primitives/select/index.d.ts +1 -1
- package/dist/primitives/select/index.d.ts.map +1 -1
- package/dist/renderers/markdown-stream.d.ts +42 -0
- package/dist/renderers/markdown-stream.d.ts.map +1 -0
- package/dist/renderers/segment-renderers.d.ts +20 -14
- package/dist/renderers/segment-renderers.d.ts.map +1 -1
- package/dist/renderers/segments/artifact/binary-file.d.ts +45 -0
- package/dist/renderers/segments/artifact/binary-file.d.ts.map +1 -0
- package/dist/renderers/segments/artifact/card.d.ts +3 -0
- package/dist/renderers/segments/artifact/card.d.ts.map +1 -0
- package/dist/renderers/segments/artifact/preview-document.d.ts +27 -0
- package/dist/renderers/segments/artifact/preview-document.d.ts.map +1 -0
- package/dist/renderers/segments/artifact/shared.d.ts +12 -0
- package/dist/renderers/segments/artifact/shared.d.ts.map +1 -0
- package/dist/renderers/segments/code.d.ts +3 -0
- package/dist/renderers/segments/code.d.ts.map +1 -0
- package/dist/renderers/segments/error.d.ts +3 -0
- package/dist/renderers/segments/error.d.ts.map +1 -0
- package/dist/renderers/segments/file-tree.d.ts +3 -0
- package/dist/renderers/segments/file-tree.d.ts.map +1 -0
- package/dist/renderers/segments/pipeline-waiting.d.ts +3 -0
- package/dist/renderers/segments/pipeline-waiting.d.ts.map +1 -0
- package/dist/renderers/segments/progress.d.ts +3 -0
- package/dist/renderers/segments/progress.d.ts.map +1 -0
- package/dist/renderers/segments/terminal.d.ts +3 -0
- package/dist/renderers/segments/terminal.d.ts.map +1 -0
- package/dist/renderers/segments/text.d.ts +10 -0
- package/dist/renderers/segments/text.d.ts.map +1 -0
- package/dist/renderers/segments/thinking.d.ts +3 -0
- package/dist/renderers/segments/thinking.d.ts.map +1 -0
- package/dist/renderers/segments/tool-call.d.ts +3 -0
- package/dist/renderers/segments/tool-call.d.ts.map +1 -0
- package/dist/runtime/message-repository.d.ts +3 -3
- package/dist/runtime/message-repository.d.ts.map +1 -1
- package/dist/transport/backend-handler.d.ts +19 -7
- package/dist/transport/backend-handler.d.ts.map +1 -1
- package/dist/transport/backend-transport.d.ts +1 -1
- package/dist/transport/backend-transport.d.ts.map +1 -1
- package/dist/transport/direct-transport.d.ts +4 -4
- package/dist/transport/direct-transport.d.ts.map +1 -1
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/types.d.ts +3 -3
- package/dist/types/element-map.d.ts +69 -0
- package/dist/types/element-map.d.ts.map +1 -0
- package/dist/types/event-map.d.ts +84 -23
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +206 -64
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +100 -54
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/models.d.ts +29 -7
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/segments.d.ts +1 -8
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/theming.d.ts +25 -37
- package/dist/types/theming.d.ts.map +1 -1
- package/dist/types/tools.d.ts +60 -15
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/escape.d.ts +46 -0
- package/dist/utils/escape.d.ts.map +1 -0
- package/dist/utils/files-to-attachments.d.ts +18 -1
- package/dist/utils/files-to-attachments.d.ts.map +1 -1
- package/dist/utils/uuid.d.ts +26 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/package.json +3 -5
- package/dist/index-Dn7TH14G.js.map +0 -1
- package/dist/types/providers.d.ts +0 -93
- package/dist/types/providers.d.ts.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a previewed artifact is allowed to FETCH. Inline script and style are
|
|
3
|
+
* permitted (that IS the preview); no fetch, no XHR, no websocket, no remote image,
|
|
4
|
+
* no font. Without this the sandbox still lets injected code beacon out to any
|
|
5
|
+
* origin, so the policy does real work — measured blocked in Chromium, Firefox and
|
|
6
|
+
* WebKit.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT DOES NOT STOP, stated because the sentence here used to claim otherwise:
|
|
9
|
+
* the frame NAVIGATING ITSELF. Assigning `location.href` is a navigation, not a
|
|
10
|
+
* fetch, and no directive in this policy governs it — CSP's `navigate-to` was
|
|
11
|
+
* removed from the spec and never shipped, and the parent page's `frame-src` does
|
|
12
|
+
* not apply to a navigation the frame initiates. Reproduced in all three engines;
|
|
13
|
+
* in Firefox and WebKit the frame then RENDERS the attacker's page inside the card,
|
|
14
|
+
* which is a phishing surface as well as an exfiltration channel.
|
|
15
|
+
*
|
|
16
|
+
* What still holds, and is why this is serious rather than fatal: the sandbox has
|
|
17
|
+
* no `allow-same-origin`, so the frame's origin is opaque — it cannot read the host
|
|
18
|
+
* page, its storage, or the API key — and no `allow-forms` or
|
|
19
|
+
* `allow-top-navigation`, so it can neither POST nor move the tab.
|
|
20
|
+
*
|
|
21
|
+
* The honest summary for a consumer: a previewed artifact cannot reach your page or
|
|
22
|
+
* your data, and can phone home once. Previewing model-authored HTML is running
|
|
23
|
+
* untrusted content in a box, not running nothing.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PREVIEW_CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:";
|
|
26
|
+
export declare function buildSafePreviewDocument(kind: string, body: string, title: string): string;
|
|
27
|
+
//# sourceMappingURL=preview-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-document.d.ts","sourceRoot":"","sources":["../../../../src/renderers/segments/artifact/preview-document.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,WAAW,6GAA6G,CAAC;AAkDtI,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip leading/trailing markdown code fences (``` or ~~~, optional lang tag).
|
|
3
|
+
* Also strips any content that appears after the closing fence (small models
|
|
4
|
+
* frequently duplicate lines after the closing ``` block).
|
|
5
|
+
*
|
|
6
|
+
* Char-based scanner — no regex.
|
|
7
|
+
*/
|
|
8
|
+
export declare function stripCodeFences(content: string): string;
|
|
9
|
+
export declare function markThrottle(map: Map<string, number>, id: string, at: number): void;
|
|
10
|
+
export declare function debounceHighlight(element: HTMLElement, paneSelector: string, content: string, lang: string, segId: string): void;
|
|
11
|
+
export declare function labelForKind(kind: string): string;
|
|
12
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/renderers/segments/artifact/shared.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBvD;AA8CD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAOnF;AAED,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACd,IAAI,CAUN;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/code.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,YAAY,EAAE,qBAAqB,CAAC,iBAAiB,CAkEjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/error.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,qBAAqB,EACrB,kBAAkB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,aAAa,EAAE,qBAAqB,CAAC,kBAAkB,CA6BnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/file-tree.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,qBAAqB,EAErB,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAkB9B,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,qBAAqB,CAazE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-waiting.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/pipeline-waiting.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,uBAAuB,EAAE,qBAgDrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/progress.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,qBAAqB,CAQzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/terminal.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,qBAAqB,CA2DzE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AparteSegmentRenderer, AparteTextSegment } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Text segment renderer.
|
|
4
|
+
*
|
|
5
|
+
* The incremental-vs-one-shot Markdown machinery lives in
|
|
6
|
+
* `../markdown-stream.ts`, shared with the thinking renderer — see that file for
|
|
7
|
+
* why appending beats rebuilding, and what the settling update flushes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const textRenderer: AparteSegmentRenderer<AparteTextSegment>;
|
|
10
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/text.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACR,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,qBAAqB,CAAC,iBAAiB,CAcjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/thinking.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACR,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAa9B,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,qBAAqB,CA0DzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../../src/renderers/segments/tool-call.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,qBAAqB,CAwHzE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* AparteMessageRepository — Conversation Tree Storage
|
|
3
3
|
*
|
|
4
4
|
* Manages the branching conversation tree while keeping AparteMessage pure
|
|
5
5
|
* (no topology fields on the message itself). Inspired by assistant-ui's
|
|
6
|
-
*
|
|
6
|
+
* AparteMessageRepository but adapted for the Aparte vanilla-TS stack.
|
|
7
7
|
*
|
|
8
8
|
* Internal structure: a doubly-linked tree where each node holds a pointer
|
|
9
9
|
* to its parent (prev) and its active child (next). `children` stores all
|
|
@@ -20,7 +20,7 @@ export type ExportedMessageRepository = {
|
|
|
20
20
|
parentId: string | null;
|
|
21
21
|
}>;
|
|
22
22
|
};
|
|
23
|
-
export declare class
|
|
23
|
+
export declare class AparteMessageRepository {
|
|
24
24
|
private _nodes;
|
|
25
25
|
private _head;
|
|
26
26
|
private _root;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-repository.d.ts","sourceRoot":"","sources":["../../src/runtime/message-repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAsBvD,sDAAsD;AACtD,MAAM,MAAM,yBAAyB,GAAG;IACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CACxE,CAAC;AAaF,qBAAa,
|
|
1
|
+
{"version":3,"file":"message-repository.d.ts","sourceRoot":"","sources":["../../src/runtime/message-repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAsBvD,sDAAsD;AACtD,MAAM,MAAM,yBAAyB,GAAG;IACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CACxE,CAAC;AAaF,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,KAAK,CAA0C;IAIvD,8CAA8C;IAC9C,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAE1B;IAED;;;OAGG;IACH,WAAW,IAAI,aAAa,EAAE;IAU9B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAUtG;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIrD;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IASxC;;;;OAIG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAkCzE;;;;;;;OAOG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAQvC;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAuBlC;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAMvE;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAgBrC,oDAAoD;IACpD,KAAK,IAAI,IAAI;IAMb;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAUjD;;;OAGG;IACH,MAAM,IAAI,yBAAyB;IAanC,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,OAAO;IA0Bf,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,kBAAkB;CAW7B"}
|
|
@@ -7,12 +7,22 @@ export interface AparteChatHandlerOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
providers: Record<string, AparteAIProvider>;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Gate run on EVERY request before any work. **Required.**
|
|
11
|
+
*
|
|
12
|
+
* This endpoint spends your server-held vendor key, so leaving it open means
|
|
13
|
+
* anyone who finds the URL spends your money. It used to be optional, and both
|
|
14
|
+
* the JSDoc example here and the primary snippet in the docs omitted it — so
|
|
15
|
+
* the copy-paste path was the unauthenticated one. Making it required moves
|
|
16
|
+
* that decision from "did you notice?" to a compile error.
|
|
17
|
+
*
|
|
18
|
+
* Return `false` to reject with 401, a `Response` to reject with your own
|
|
19
|
+
* status/body (e.g. 403 + a message), or `true` to proceed. Reads
|
|
20
|
+
* cookies/headers via `req`.
|
|
21
|
+
*
|
|
22
|
+
* A deliberately open endpoint is still possible — `authorize: () => true` —
|
|
23
|
+
* but now it is a line someone wrote on purpose.
|
|
14
24
|
*/
|
|
15
|
-
authorize
|
|
25
|
+
authorize: (req: Request) => boolean | Response | Promise<boolean | Response>;
|
|
16
26
|
/**
|
|
17
27
|
* Resolve the vendor API key for a providerId — from env / a secret store.
|
|
18
28
|
* Runs server-side only. Return `undefined` for keyless/local providers.
|
|
@@ -25,7 +35,7 @@ export interface AparteChatHandlerOptions {
|
|
|
25
35
|
fetchImpl?: typeof fetch;
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
|
-
* Build a framework-free `/api/chat` handler for {@link
|
|
38
|
+
* Build a framework-free `/api/chat` handler for {@link AparteBackendTransport} — the
|
|
29
39
|
* server counterpart that keeps the key off the client.
|
|
30
40
|
*
|
|
31
41
|
* The returned handler speaks the Web `fetch` API (`Request` → `Response`), so
|
|
@@ -33,7 +43,7 @@ export interface AparteChatHandlerOptions {
|
|
|
33
43
|
* unchanged. It reads `{ providerId, request }`, runs the matching format
|
|
34
44
|
* adapter **server-side** (buildRequest → auth → vendor fetch → parseStream),
|
|
35
45
|
* and streams back normalized `AparteStreamEvent`s as NDJSON — the exact wire
|
|
36
|
-
* format `
|
|
46
|
+
* format `AparteBackendTransport` expects. The vendor key is injected here and never
|
|
37
47
|
* travels to the browser.
|
|
38
48
|
*
|
|
39
49
|
* ```ts
|
|
@@ -43,6 +53,8 @@ export interface AparteChatHandlerOptions {
|
|
|
43
53
|
* export const POST = createAparteChatHandler({
|
|
44
54
|
* providers: { openai: createOpenAICompatProvider(presets.OPENAI) },
|
|
45
55
|
* resolveKey: (id) => process.env[`${id.toUpperCase()}_KEY`],
|
|
56
|
+
* // Required: this route spends your key. Your own session check goes here.
|
|
57
|
+
* authorize: async (req) => Boolean(await getSession(req)),
|
|
46
58
|
* });
|
|
47
59
|
* ```
|
|
48
60
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-handler.d.ts","sourceRoot":"","sources":["../../src/transport/backend-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC5C
|
|
1
|
+
{"version":3,"file":"backend-handler.d.ts","sourceRoot":"","sources":["../../src/transport/backend-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC5C;;;;;;;;;;;;;;;OAeG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;IAC9E;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACtF;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,wBAAwB,GAClC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CA8HrC"}
|
|
@@ -31,7 +31,7 @@ export interface BackendTransportOptions {
|
|
|
31
31
|
* server-side, key held server-side). Drop it into a Next.js route handler,
|
|
32
32
|
* Deno, Bun, or a Worker rather than hand-rolling one.
|
|
33
33
|
*/
|
|
34
|
-
export declare class
|
|
34
|
+
export declare class AparteBackendTransport implements AparteTransport {
|
|
35
35
|
private readonly options;
|
|
36
36
|
constructor(options: BackendTransportOptions);
|
|
37
37
|
chat(_provider: AparteAIProvider, request: AparteChatRequest, _auth: string | Record<string, string> | undefined, ctx: AparteTransportContext): Promise<AparteChatResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-transport.d.ts","sourceRoot":"","sources":["../../src/transport/backend-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAI1E,MAAM,WAAW,uBAAuB;IACpC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"backend-transport.d.ts","sourceRoot":"","sources":["../../src/transport/backend-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAI1E,MAAM,WAAW,uBAAuB;IACpC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,uBAAuB;IAEvD,IAAI,CACN,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAClD,GAAG,EAAE,sBAAsB,GAC5B,OAAO,CAAC,kBAAkB,CAAC;CA4BjC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AparteChatRequest, AparteChatResponse } from '../types/chat.js';
|
|
2
2
|
import type { AparteAIProvider } from '../types/model-provider.js';
|
|
3
3
|
import type { AparteTransport, AparteTransportContext } from './types.js';
|
|
4
|
-
/** Options for {@link
|
|
4
|
+
/** Options for {@link AparteDirectTransport}. */
|
|
5
5
|
export interface DirectTransportOptions {
|
|
6
6
|
/**
|
|
7
7
|
* Set when the key is the end-user's own (BYOK) or the model runs locally —
|
|
8
8
|
* i.e. you *intend* the credential to live in the browser. This silences the
|
|
9
9
|
* one-time insecure-key warning. Leave it unset for keys that must stay
|
|
10
|
-
* server-side, and use `
|
|
10
|
+
* server-side, and use `AparteBackendTransport` for those instead.
|
|
11
11
|
*/
|
|
12
12
|
byok?: boolean;
|
|
13
13
|
}
|
|
@@ -17,7 +17,7 @@ export interface DirectTransportOptions {
|
|
|
17
17
|
* Calls the vendor endpoint straight from the browser, injecting the resolved
|
|
18
18
|
* key via the adapter's `authHeaders`. This is the pre-refactor behaviour and
|
|
19
19
|
* is only safe when the user brings their own key or the model runs locally.
|
|
20
|
-
* Production apps that must keep a key server-side should use `
|
|
20
|
+
* Production apps that must keep a key server-side should use `AparteBackendTransport`.
|
|
21
21
|
*
|
|
22
22
|
* When a real key is sent straight from the browser and the transport was not
|
|
23
23
|
* flagged `{ byok: true }`, a one-time `console.warn` names the exposure — the
|
|
@@ -26,7 +26,7 @@ export interface DirectTransportOptions {
|
|
|
26
26
|
* Legacy providers (still exposing `chat()` rather than the adapter surface) are
|
|
27
27
|
* delegated to untouched, so the migration can proceed provider-by-provider.
|
|
28
28
|
*/
|
|
29
|
-
export declare class
|
|
29
|
+
export declare class AparteDirectTransport implements AparteTransport {
|
|
30
30
|
private readonly byok;
|
|
31
31
|
private warnedBrowserKey;
|
|
32
32
|
constructor(options?: DirectTransportOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"direct-transport.d.ts","sourceRoot":"","sources":["../../src/transport/direct-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAG1E,
|
|
1
|
+
{"version":3,"file":"direct-transport.d.ts","sourceRoot":"","sources":["../../src/transport/direct-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAG1E,iDAAiD;AACjD,MAAM,WAAW,sBAAsB;IACnC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,gBAAgB,CAAS;gBAErB,OAAO,GAAE,sBAA2B;IAI1C,IAAI,CACN,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACjD,GAAG,EAAE,sBAAsB,GAC5B,OAAO,CAAC,kBAAkB,CAAC;IAoD9B,OAAO,CAAC,kBAAkB;CAU7B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { AparteTransport, AparteTransportContext, AparteFormatAdapter, AparteVendorRequest, } from './types.js';
|
|
2
2
|
export { isFormatAdapter, readAuth } from './types.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { AparteDirectTransport, type DirectTransportOptions } from './direct-transport.js';
|
|
4
|
+
export { AparteBackendTransport, type BackendTransportOptions } from './backend-transport.js';
|
|
5
5
|
export { createAparteChatHandler, type AparteChatHandlerOptions } from './backend-handler.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* how to shape the HTTP request and how to parse the response stream into
|
|
6
6
|
* unified `AparteStreamEvent`s. No network, no auth, no key.
|
|
7
7
|
* • **Transport** (`AparteTransport`): WHERE the call goes and how auth is
|
|
8
|
-
* handled — straight to the vendor from the browser (`
|
|
8
|
+
* handled — straight to the vendor from the browser (`AparteDirectTransport`,
|
|
9
9
|
* BYOK/local) or via your own backend that holds the key
|
|
10
|
-
* (`
|
|
10
|
+
* (`AparteBackendTransport`, recommended for production).
|
|
11
11
|
*
|
|
12
12
|
* A "provider" is migrating from a monolithic `chat()` (fetch + key + parse) to
|
|
13
13
|
* a pure format adapter. During the migration a provider may expose EITHER the
|
|
@@ -64,7 +64,7 @@ export declare function vendorErrorMessage(response: Response, label?: string):
|
|
|
64
64
|
/**
|
|
65
65
|
* Resolve a non-streaming response to text via the adapter's `parseText`.
|
|
66
66
|
* Both transports use this so `stream: false` behaves identically (previously
|
|
67
|
-
*
|
|
67
|
+
* AparteDirectTransport returned '' and AparteBackendTransport returned raw JSON when
|
|
68
68
|
* `parseText` was missing — now both fail loud).
|
|
69
69
|
*/
|
|
70
70
|
export declare function parseNonStreamText(provider: {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global typing for the aparté custom elements. Once `@aparte/core` is in a
|
|
3
|
+
* consumer's TypeScript program, `document.querySelector('aparte-composer-input')`
|
|
4
|
+
* returns `AparteComposerInput | null` instead of `Element | null` — no cast, and
|
|
5
|
+
* the element's own properties and methods are reachable.
|
|
6
|
+
*
|
|
7
|
+
* This used to live inline: each component appended its own
|
|
8
|
+
* `declare global { interface HTMLElementTagNameMap { … } }` at the bottom of its
|
|
9
|
+
* file. Seven of the eighteen elements did; the other eleven did not, and nothing
|
|
10
|
+
* could notice. The consequence was not abstract — the canonical example in the
|
|
11
|
+
* generated API reference, `list.conversations = [...]` after a
|
|
12
|
+
* `querySelector('aparte-conversation-list')`, could not compile, and the same held
|
|
13
|
+
* for every `aparte-composer-*` primitive on the "compose your own composer" path
|
|
14
|
+
* that `getting-started` recommends.
|
|
15
|
+
*
|
|
16
|
+
* One file instead of eighteen for one reason: a per-component convention cannot be
|
|
17
|
+
* enforced, and it was not. Here the whole element surface is in one place, next to
|
|
18
|
+
* the `customElements.define` calls it has to agree with, which is what makes
|
|
19
|
+
* `pnpm check:element-map` a five-line diff rather than a parser.
|
|
20
|
+
*
|
|
21
|
+
* Every import is `import type`, so nothing is emitted and this cannot introduce a
|
|
22
|
+
* runtime cycle — the same reason `event-map.ts` can name a component-coupled detail
|
|
23
|
+
* type from the types layer.
|
|
24
|
+
*
|
|
25
|
+
* DOM-only, therefore imported by `index.ts` and NOT by `index.node.ts`:
|
|
26
|
+
* `HTMLElementTagNameMap` does not exist without the DOM lib.
|
|
27
|
+
*/
|
|
28
|
+
import type { AparteChat } from '../components/chat/aparte-chat.js';
|
|
29
|
+
import type { AparteChatBubble } from '../components/bubble/aparte-chat-bubble.js';
|
|
30
|
+
import type { AparteChatStatus } from '../components/status/aparte-chat-status.js';
|
|
31
|
+
import type { AparteChatViewport } from '../components/viewport/aparte-chat-viewport.js';
|
|
32
|
+
import type { AparteComposer } from '../components/composer/aparte-composer.js';
|
|
33
|
+
import type { AparteComposerInput } from '../components/composer/aparte-composer-input.js';
|
|
34
|
+
import type { AparteComposerSend } from '../components/composer/aparte-composer-send.js';
|
|
35
|
+
import type { AparteComposerCancel } from '../components/composer/aparte-composer-cancel.js';
|
|
36
|
+
import type { AparteComposerAttachments } from '../components/composer/aparte-composer-attachments.js';
|
|
37
|
+
import type { AparteComposerAddAttachment } from '../components/composer/aparte-composer-add-attachment.js';
|
|
38
|
+
import type { AparteComposerAction } from '../components/composer/aparte-composer-action.js';
|
|
39
|
+
import type { AparteComposerToolbar } from '../components/composer/aparte-composer-toolbar.js';
|
|
40
|
+
import type { AparteConversationList } from '../components/conversation-list/aparte-conversation-list.js';
|
|
41
|
+
import type { AparteElicitation } from '../components/elicitation/aparte-elicitation.js';
|
|
42
|
+
import type { AparteSelect } from '../primitives/select/aparte-select.js';
|
|
43
|
+
import type { AparteOption } from '../primitives/select/aparte-option.js';
|
|
44
|
+
import type { AparteOptgroup } from '../primitives/select/aparte-optgroup.js';
|
|
45
|
+
import type { AparteProgressSpinner } from '../primitives/progress-spinner/aparte-progress-spinner.js';
|
|
46
|
+
declare global {
|
|
47
|
+
interface HTMLElementTagNameMap {
|
|
48
|
+
'aparte-chat': AparteChat;
|
|
49
|
+
'aparte-chat-viewport': AparteChatViewport;
|
|
50
|
+
'aparte-chat-bubble': AparteChatBubble;
|
|
51
|
+
'aparte-chat-status': AparteChatStatus;
|
|
52
|
+
'aparte-composer': AparteComposer;
|
|
53
|
+
'aparte-composer-input': AparteComposerInput;
|
|
54
|
+
'aparte-composer-send': AparteComposerSend;
|
|
55
|
+
'aparte-composer-cancel': AparteComposerCancel;
|
|
56
|
+
'aparte-composer-attachments': AparteComposerAttachments;
|
|
57
|
+
'aparte-composer-add-attachment': AparteComposerAddAttachment;
|
|
58
|
+
'aparte-composer-action': AparteComposerAction;
|
|
59
|
+
'aparte-composer-toolbar': AparteComposerToolbar;
|
|
60
|
+
'aparte-conversation-list': AparteConversationList;
|
|
61
|
+
'aparte-elicitation': AparteElicitation;
|
|
62
|
+
'aparte-select': AparteSelect;
|
|
63
|
+
'aparte-option': AparteOption;
|
|
64
|
+
'aparte-optgroup': AparteOptgroup;
|
|
65
|
+
'aparte-progress-spinner': AparteProgressSpinner;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=element-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-map.d.ts","sourceRoot":"","sources":["../../src/types/element-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AACvG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0DAA0D,CAAC;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAC;AAC1G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2DAA2D,CAAC;AAEvG,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAE3B,aAAa,EAAE,UAAU,CAAC;QAC1B,sBAAsB,EAAE,kBAAkB,CAAC;QAC3C,oBAAoB,EAAE,gBAAgB,CAAC;QACvC,oBAAoB,EAAE,gBAAgB,CAAC;QAGvC,iBAAiB,EAAE,cAAc,CAAC;QAClC,uBAAuB,EAAE,mBAAmB,CAAC;QAC7C,sBAAsB,EAAE,kBAAkB,CAAC;QAC3C,wBAAwB,EAAE,oBAAoB,CAAC;QAC/C,6BAA6B,EAAE,yBAAyB,CAAC;QACzD,gCAAgC,EAAE,2BAA2B,CAAC;QAC9D,wBAAwB,EAAE,oBAAoB,CAAC;QAC/C,yBAAyB,EAAE,qBAAqB,CAAC;QAGjD,0BAA0B,EAAE,sBAAsB,CAAC;QACnD,oBAAoB,EAAE,iBAAiB,CAAC;QAGxC,eAAe,EAAE,YAAY,CAAC;QAC9B,eAAe,EAAE,YAAY,CAAC;QAC9B,iBAAiB,EAAE,cAAc,CAAC;QAClC,yBAAyB,EAAE,qBAAqB,CAAC;KACpD;CACJ;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -4,37 +4,98 @@
|
|
|
4
4
|
* types `e` as `CustomEvent<AparteRetryEventDetail>` with a typed `e.detail` — no
|
|
5
5
|
* manual `(e as CustomEvent<…>).detail` cast.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
7
|
+
* ## What belongs here
|
|
8
|
+
*
|
|
9
|
+
* One rule: **an event with a detail belongs in the map.** If a consumer can read
|
|
10
|
+
* `e.detail`, the map is the only thing that types it, and its absence forces the
|
|
11
|
+
* exact cast the paragraph above promises you never need.
|
|
12
|
+
*
|
|
13
|
+
* The rule this file used to state was different and wrong. It said the map covers
|
|
14
|
+
* "events whose detail type lives in the types layer", and named composer-submit,
|
|
15
|
+
* select-change and optgroup-toggle as internal ones that "carry no cross-package
|
|
16
|
+
* detail contract". Two of those three do: `@aparte/plugin-model-selector` reads
|
|
17
|
+
* both across a package boundary, and `AparteSelectChangeDetail` is exported from
|
|
18
|
+
* both public barrels. Meanwhile `aparte-composer-change` sat in the map with its
|
|
19
|
+
* detail imported from a component — breaking the stated criterion in the other
|
|
20
|
+
* direction. A rule contradicted by its own list is not a rule.
|
|
21
|
+
*
|
|
22
|
+
* Events that carry NO detail stay out, and that is the whole exclusion:
|
|
23
|
+
* `aparte-composer-submit`, `aparte-cancel`, `aparte-reset`, `aparte-reset-done`,
|
|
24
|
+
* `aparte-compact-start`, `aparte-select-open`, `aparte-select-close` are all
|
|
25
|
+
* dispatched as a bare `new CustomEvent(name)`. A map entry would type `e.detail`
|
|
26
|
+
* as `null` and gain nothing.
|
|
11
27
|
*
|
|
12
28
|
* All names are kebab-case (`aparte-*`) so every framework can bind them in a
|
|
13
29
|
* template (Angular parses a `:` in an event name as a `target:event` selector,
|
|
14
30
|
* so a colon name could never be `(aparte:x)`-bound there).
|
|
15
31
|
*/
|
|
16
|
-
import type { AparteSendEventDetail, AparteRetryEventDetail, AparteEditEventDetail, AparteActionEventDetail, ApartePathChangedEventDetail, AparteBranchNavigateEventDetail, AparteFeedbackEventDetail, AparteMessageInfoEventDetail, AparteMessageDoneEventDetail, AparteModelChangeEventDetail, AparteArtifactStartEventDetail, AparteArtifactDeltaEventDetail, AparteArtifactReadyEventDetail,
|
|
32
|
+
import type { AparteSendEventDetail, AparteRetryEventDetail, AparteEditEventDetail, AparteActionEventDetail, ApartePathChangedEventDetail, AparteBranchNavigateEventDetail, AparteFeedbackEventDetail, AparteMessageInfoEventDetail, AparteMessageDoneEventDetail, AparteModelChangeEventDetail, AparteArtifactStartEventDetail, AparteArtifactDeltaEventDetail, AparteArtifactReadyEventDetail, AparteArtifactRedownloadEventDetail, AparteMessageStartEventDetail, AparteMessageErrorEventDetail, AparteMessageAbortedEventDetail, AparteAbortEventDetail, AparteCompactEventDetail, AparteCompactDoneEventDetail, AparteCompactErrorEventDetail, AparteAttachmentPreviewEventDetail, AparteTerminalRunEventDetail, AparteFileGenReadyEventDetail, AparteFileGenErrorEventDetail } from './events.js';
|
|
33
|
+
import type { AparteActionClickEventDetail } from '../components/composer/aparte-composer-action.js';
|
|
34
|
+
import type { AparteOptgroupToggleEventDetail } from '../primitives/select/aparte-optgroup.js';
|
|
35
|
+
import type { AparteConfigChangeEventDetail } from '../config/aparte-config.js';
|
|
17
36
|
import type { AparteToolDecisionDetail, AparteToolApprovalRequestDetail } from './tools.js';
|
|
37
|
+
import type { AparteSegmentUpdateEventDetail } from './segments.js';
|
|
38
|
+
import type { AparteSelectChangeDetail } from '../primitives/select/aparte-select.js';
|
|
39
|
+
import type { AparteConversationSelectDetail, AparteConversationDeleteDetail, AparteConversationArchiveDetail } from '../components/conversation-list/aparte-conversation-list.js';
|
|
18
40
|
import type { AparteComposerChangeEventDetail } from '../components/composer/aparte-composer.js';
|
|
41
|
+
/**
|
|
42
|
+
* Declared once, applied to all three targets below.
|
|
43
|
+
*
|
|
44
|
+
* It used to be written straight into `HTMLElementEventMap`, which typed
|
|
45
|
+
* `chat.addEventListener(...)` and nothing else — while `document.addEventListener`
|
|
46
|
+
* resolves through `DocumentEventMap` and `window.addEventListener` through
|
|
47
|
+
* `WindowEventMap`, neither of which inherits from it. Every aparté event bubbles
|
|
48
|
+
* and composes, so listening on `document` is the natural way to handle a page's
|
|
49
|
+
* worth of chats in one place; the docs recommend exactly that ("Clicks are
|
|
50
|
+
* declarative — they emit `aparte-action`, so you handle them in one place"), and
|
|
51
|
+
* that recommended snippet did not compile. `AparteClient` itself listens on
|
|
52
|
+
* `window`, so the third map is not hypothetical either.
|
|
53
|
+
*/
|
|
54
|
+
interface AparteEventMap {
|
|
55
|
+
'aparte-send': CustomEvent<AparteSendEventDetail>;
|
|
56
|
+
'aparte-retry': CustomEvent<AparteRetryEventDetail>;
|
|
57
|
+
'aparte-edit': CustomEvent<AparteEditEventDetail>;
|
|
58
|
+
'aparte-action': CustomEvent<AparteActionEventDetail>;
|
|
59
|
+
'aparte-path-changed': CustomEvent<ApartePathChangedEventDetail>;
|
|
60
|
+
'aparte-branch-navigate': CustomEvent<AparteBranchNavigateEventDetail>;
|
|
61
|
+
'aparte-feedback': CustomEvent<AparteFeedbackEventDetail>;
|
|
62
|
+
'aparte-message-info': CustomEvent<AparteMessageInfoEventDetail>;
|
|
63
|
+
'aparte-message-done': CustomEvent<AparteMessageDoneEventDetail>;
|
|
64
|
+
'aparte-model-change': CustomEvent<AparteModelChangeEventDetail>;
|
|
65
|
+
'aparte-artifact-start': CustomEvent<AparteArtifactStartEventDetail>;
|
|
66
|
+
'aparte-artifact-delta': CustomEvent<AparteArtifactDeltaEventDetail>;
|
|
67
|
+
'aparte-artifact-ready': CustomEvent<AparteArtifactReadyEventDetail>;
|
|
68
|
+
'aparte-artifact-redownload': CustomEvent<AparteArtifactRedownloadEventDetail>;
|
|
69
|
+
'aparte-tool-decision': CustomEvent<AparteToolDecisionDetail>;
|
|
70
|
+
'aparte-tool-approval-request': CustomEvent<AparteToolApprovalRequestDetail>;
|
|
71
|
+
'aparte-composer-change': CustomEvent<AparteComposerChangeEventDetail>;
|
|
72
|
+
'aparte-select-change': CustomEvent<AparteSelectChangeDetail>;
|
|
73
|
+
'aparte-segment-update': CustomEvent<AparteSegmentUpdateEventDetail>;
|
|
74
|
+
'aparte-select-conversation': CustomEvent<AparteConversationSelectDetail>;
|
|
75
|
+
'aparte-delete-conversation': CustomEvent<AparteConversationDeleteDetail>;
|
|
76
|
+
'aparte-archive-conversation': CustomEvent<AparteConversationArchiveDetail>;
|
|
77
|
+
'aparte-unarchive-conversation': CustomEvent<AparteConversationArchiveDetail>;
|
|
78
|
+
'aparte-message-start': CustomEvent<AparteMessageStartEventDetail>;
|
|
79
|
+
'aparte-message-error': CustomEvent<AparteMessageErrorEventDetail>;
|
|
80
|
+
'aparte-message-aborted': CustomEvent<AparteMessageAbortedEventDetail>;
|
|
81
|
+
'aparte-abort': CustomEvent<AparteAbortEventDetail>;
|
|
82
|
+
'aparte-compact': CustomEvent<AparteCompactEventDetail>;
|
|
83
|
+
'aparte-compact-done': CustomEvent<AparteCompactDoneEventDetail>;
|
|
84
|
+
'aparte-compact-error': CustomEvent<AparteCompactErrorEventDetail>;
|
|
85
|
+
'aparte-file-gen-ready': CustomEvent<AparteFileGenReadyEventDetail>;
|
|
86
|
+
'aparte-file-gen-error': CustomEvent<AparteFileGenErrorEventDetail>;
|
|
87
|
+
'aparte-attachment-preview': CustomEvent<AparteAttachmentPreviewEventDetail>;
|
|
88
|
+
'aparte-terminal-run': CustomEvent<AparteTerminalRunEventDetail>;
|
|
89
|
+
'aparte-action-click': CustomEvent<AparteActionClickEventDetail>;
|
|
90
|
+
'aparte-optgroup-toggle': CustomEvent<AparteOptgroupToggleEventDetail>;
|
|
91
|
+
'aparte-config-change': CustomEvent<AparteConfigChangeEventDetail>;
|
|
92
|
+
}
|
|
19
93
|
declare global {
|
|
20
|
-
interface HTMLElementEventMap {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'aparte-path-changed': CustomEvent<ApartePathChangedEventDetail>;
|
|
26
|
-
'aparte-branch-navigate': CustomEvent<AparteBranchNavigateEventDetail>;
|
|
27
|
-
'aparte-feedback': CustomEvent<AparteFeedbackEventDetail>;
|
|
28
|
-
'aparte-message-info': CustomEvent<AparteMessageInfoEventDetail>;
|
|
29
|
-
'aparte-message-done': CustomEvent<AparteMessageDoneEventDetail>;
|
|
30
|
-
'aparte-model-change': CustomEvent<AparteModelChangeEventDetail>;
|
|
31
|
-
'aparte-artifact-start': CustomEvent<AparteArtifactStartEventDetail>;
|
|
32
|
-
'aparte-artifact-delta': CustomEvent<AparteArtifactDeltaEventDetail>;
|
|
33
|
-
'aparte-artifact-ready': CustomEvent<AparteArtifactReadyEventDetail>;
|
|
34
|
-
'aparte-artifact-open': CustomEvent<AparteArtifactOpenEventDetail>;
|
|
35
|
-
'aparte-tool-decision': CustomEvent<AparteToolDecisionDetail>;
|
|
36
|
-
'aparte-tool-approval-request': CustomEvent<AparteToolApprovalRequestDetail>;
|
|
37
|
-
'aparte-composer-change': CustomEvent<AparteComposerChangeEventDetail>;
|
|
94
|
+
interface HTMLElementEventMap extends AparteEventMap {
|
|
95
|
+
}
|
|
96
|
+
interface DocumentEventMap extends AparteEventMap {
|
|
97
|
+
}
|
|
98
|
+
interface WindowEventMap extends AparteEventMap {
|
|
38
99
|
}
|
|
39
100
|
}
|
|
40
101
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../../src/types/event-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../../src/types/event-map.ts"],"names":[],"mappings":"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"}
|