@aparte/core 0.22.0 → 0.24.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/dist/client/aparte-client.d.ts +10 -22
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/stream-adapter.d.ts +16 -0
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +38 -0
- 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/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +10 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +76 -19
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/error-renderer.d.ts +3 -1
- package/dist/config/error-renderer.d.ts.map +1 -1
- package/dist/config/locale.d.ts +49 -4
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/config/tool-table.d.ts +30 -0
- package/dist/config/tool-table.d.ts.map +1 -0
- package/dist/conversations/conversation-controller.d.ts +19 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-status.d.ts +27 -0
- package/dist/conversations/conversation-status.d.ts.map +1 -0
- package/dist/custom-elements.json +12058 -11106
- package/dist/{dialog-triggers-3Rk7PuZa.js → dialog-triggers-BqXRdHWZ.js} +746 -205
- package/dist/dialog-triggers-BqXRdHWZ.js.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -18
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +3 -2
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +4 -3
- 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/renderers/copy-button.d.ts +12 -0
- package/dist/renderers/copy-button.d.ts.map +1 -0
- package/dist/renderers/segment-renderers.d.ts +6 -3
- package/dist/renderers/segment-renderers.d.ts.map +1 -1
- package/dist/renderers/segments/code.d.ts.map +1 -1
- package/dist/renderers/segments/error.d.ts.map +1 -1
- package/dist/renderers/segments/thinking.d.ts.map +1 -1
- package/dist/renderers/segments/tool-call.d.ts.map +1 -1
- package/dist/transport/agent-handler.d.ts.map +1 -1
- package/dist/types/errors.d.ts +2 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +4 -2
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +15 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/segments.d.ts +42 -2
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/tools.d.ts +77 -0
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/format-duration.d.ts +9 -0
- package/dist/utils/format-duration.d.ts.map +1 -0
- package/dist/utils/tool-line.d.ts +23 -0
- package/dist/utils/tool-line.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/dialog-triggers-3Rk7PuZa.js.map +0 -1
package/dist/types/tools.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provider-agnostic tool calling interface
|
|
4
4
|
*/
|
|
5
5
|
import type { AparteToolCallSegment } from './segments.js';
|
|
6
|
+
import type { AparteIconName } from '../config/icon-provider.js';
|
|
6
7
|
/** Definition of a tool the AI can call */
|
|
7
8
|
export interface AparteTool {
|
|
8
9
|
name: string;
|
|
@@ -160,6 +161,82 @@ export type AparteToolSummary = (segment: AparteToolCallSegment) => string;
|
|
|
160
161
|
* falls back to the JSON.
|
|
161
162
|
*/
|
|
162
163
|
export type AparteToolInputFormatter = (input: Record<string, unknown>) => string;
|
|
164
|
+
/**
|
|
165
|
+
* Which tools a registration names: one exact name, a RegExp tested against the name
|
|
166
|
+
* (`name.search(re) !== -1`, so a `g` flag is harmless), or `'*'` for every tool nothing
|
|
167
|
+
* more specific describes.
|
|
168
|
+
*/
|
|
169
|
+
export type AparteToolMatcher = string | RegExp;
|
|
170
|
+
/**
|
|
171
|
+
* How a tool's calls are shown — registered with `registerToolDisplay(matcher, display)`.
|
|
172
|
+
*
|
|
173
|
+
* Every field is optional; what is left out keeps core's default row. The tool's NAME is
|
|
174
|
+
* the app's wire format and core never turns it into words on its own: `label` is how an
|
|
175
|
+
* app gives a person something better to read than `web_search`.
|
|
176
|
+
*/
|
|
177
|
+
export interface AparteToolDisplay {
|
|
178
|
+
/**
|
|
179
|
+
* What the row and the approval question call the tool, in place of its identifier.
|
|
180
|
+
* Plain text, never HTML. A function reads the call (its status, its input); one that
|
|
181
|
+
* throws falls back to the identifier.
|
|
182
|
+
*/
|
|
183
|
+
label?: string | ((segment: AparteToolCallSegment) => string);
|
|
184
|
+
/**
|
|
185
|
+
* The row's glyph: an icon-provider key (`file`, `edit`, `terminal`… — or `search`,
|
|
186
|
+
* `globe` from `@aparte/core/icons` once registered). Unknown keys fall back to `tool`.
|
|
187
|
+
*/
|
|
188
|
+
icon?: AparteIconName | (string & {});
|
|
189
|
+
/** What the call targets, after the label — see {@link AparteToolSummary}. */
|
|
190
|
+
summary?: AparteToolSummary;
|
|
191
|
+
/** The arguments as a person reads them — see {@link AparteToolInputFormatter}. */
|
|
192
|
+
formatInput?: AparteToolInputFormatter;
|
|
193
|
+
/**
|
|
194
|
+
* Draw nothing for these calls. The call stays in the message, in storage and in the
|
|
195
|
+
* model's history; an approval it needs is still asked.
|
|
196
|
+
*/
|
|
197
|
+
hidden?: boolean;
|
|
198
|
+
/** Open the row's disclosure by default (a segment's own `collapsed` wins). */
|
|
199
|
+
open?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* What is behind the line. Left out, Input and Output: the arguments and the result,
|
|
202
|
+
* a developer's view. `false`, nothing: the line alone, with no disclosure, for a chat
|
|
203
|
+
* whose reader should not be one click from raw JSON (`open` and a segment's
|
|
204
|
+
* `collapsed` then have nothing to open). A function: what it returns, in place of
|
|
205
|
+
* Input and Output — see {@link AparteToolDetails}.
|
|
206
|
+
*/
|
|
207
|
+
details?: false | AparteToolDetails;
|
|
208
|
+
/**
|
|
209
|
+
* The line a person reads in a conversational chat, where the default is an agent's.
|
|
210
|
+
* While the call runs, the label shimmers (`aparte-shimmer`) instead of a spinner and
|
|
211
|
+
* "Running"; once it is done, nothing marks success — the label's tense says it, so
|
|
212
|
+
* write one that reads the status ("Searching the web…" / "Searched the web" / a plain
|
|
213
|
+
* "Search the web" for the rest). Under reduced motion the shimmer holds still, so that
|
|
214
|
+
* label is what says the call runs. A wait
|
|
215
|
+
* for approval, a refusal, a failure and a stop still show their word and note. The
|
|
216
|
+
* words it does not show are still read by a screen reader. The target is set in the
|
|
217
|
+
* chat's font and the chevron moves to the end of the line; the row carries
|
|
218
|
+
* `data-quiet` for a stylesheet of your own.
|
|
219
|
+
*/
|
|
220
|
+
quiet?: boolean;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* What a row shows behind its line, in place of Input and Output: a list of sources for a
|
|
224
|
+
* search, a sentence for a write. Called when the row is drawn and on every update of the
|
|
225
|
+
* call, so it can read the status and the result as they land — and on a language switch,
|
|
226
|
+
* whose words are written into the nodes already there when the shape is the same.
|
|
227
|
+
*
|
|
228
|
+
* Return an **HTMLElement** and nothing goes through `innerHTML`. Return a **string** and
|
|
229
|
+
* core inserts it as HTML after the config's HTML sanitizer (`setHtmlSanitizer`, as for
|
|
230
|
+
* Markdown): what it shows comes from a tool's result, so a script or an event handler in
|
|
231
|
+
* it is removed. Escape the call's values all the same (`escapeHtml`): the sanitizer keeps
|
|
232
|
+
* markup that is harmless but can still mislead. Return `''` for nothing behind the
|
|
233
|
+
* line yet: no disclosure, which appears once there is something (a result, say).
|
|
234
|
+
*
|
|
235
|
+
* A function that throws costs the row its detail, never its line, and never falls back
|
|
236
|
+
* to the raw Input and Output. Register the same function rather than a new closure each
|
|
237
|
+
* time: a different `details` redraws the messages on screen.
|
|
238
|
+
*/
|
|
239
|
+
export type AparteToolDetails = (segment: AparteToolCallSegment) => HTMLElement | string;
|
|
163
240
|
/**
|
|
164
241
|
* Per-tool segment renderer.
|
|
165
242
|
* Registered via aparteGlobalConfig.registerToolRenderer(toolName, renderer).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,8GAA8G;IAC9G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,+BAA+B;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qDAAqD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qB,KAAK,IAAI,CAAC;IACzE,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A duration as a person reads it, in the locale's own units: "8s", "1m 12s", "1 min 12 s".
|
|
3
|
+
*
|
|
4
|
+
* `Intl`'s narrow unit style rather than a sentence of our own: the units, their order and
|
|
5
|
+
* their spacing are the locale's, and a translation never has to spell "seconds". A floor
|
|
6
|
+
* of one second — a block that took 300ms still took time, and "0s" reads as nothing.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatDuration(ms: number, tag?: string): string;
|
|
9
|
+
//# sourceMappingURL=format-duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-duration.d.ts","sourceRoot":"","sources":["../../src/utils/format-duration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAc/D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a tool call is called, and what it targets — read by the transcript row AND by the
|
|
3
|
+
* approval question, so a person cannot read the two differently (the same reason
|
|
4
|
+
* `tool-input.ts` exists for the arguments).
|
|
5
|
+
*/
|
|
6
|
+
import type { AparteConfig } from '../config/aparte-config.js';
|
|
7
|
+
import type { AparteToolCallSegment } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* The name a call goes by: the label its display declares (`registerToolDisplay`), else
|
|
10
|
+
* the identifier — the app's wire format, which core never turns into words on its own.
|
|
11
|
+
* A label that throws or says nothing costs the call its label, not its render.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toolNameOf(segment: AparteToolCallSegment, config: AparteConfig): {
|
|
14
|
+
text: string;
|
|
15
|
+
isLabel: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* What a call targets, from the summary its display declares — `''` when there is none,
|
|
19
|
+
* or when it throws: a summary reads model-chosen input, and a bad one must cost the call
|
|
20
|
+
* its one line, not the bubble its render.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toolTargetOf(segment: AparteToolCallSegment, config: AparteConfig): string;
|
|
23
|
+
//# sourceMappingURL=tool-line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-line.d.ts","sourceRoot":"","sources":["../../src/utils/tool-line.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAUnH;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CASzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparte/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"homepage": "https://apartejs.dev/",
|
|
5
5
|
"description": "AI chat and agent UI components as Web Components, with the agent loop inside — zero third-party dependencies",
|
|
6
6
|
"type": "module",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"node": ">=18"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@aparte/engine": "0.
|
|
82
|
+
"@aparte/engine": "0.24.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|