@aparte/core 0.26.0 → 0.27.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.
- package/dist/client/aparte-client.d.ts +2 -0
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +2 -2
- package/dist/components/composer/accepts-file.d.ts +10 -0
- package/dist/components/composer/accepts-file.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-add-attachment.d.ts +5 -1
- package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-attachments.d.ts +9 -4
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/context/aparte-context.d.ts +15 -0
- package/dist/components/context/aparte-context.d.ts.map +1 -1
- package/dist/components/elicitation/aparte-elicitation.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/launcher/aparte-launcher.d.ts +167 -0
- package/dist/components/launcher/aparte-launcher.d.ts.map +1 -0
- package/dist/components/launcher/index.d.ts +3 -0
- package/dist/components/launcher/index.d.ts.map +1 -0
- package/dist/config/aparte-config.d.ts +19 -13
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/error-renderer.d.ts +21 -10
- package/dist/config/error-renderer.d.ts.map +1 -1
- package/dist/config/icon-provider.d.ts +2 -0
- package/dist/config/icon-provider.d.ts.map +1 -1
- package/dist/config/locale.d.ts +23 -1
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/custom-elements.json +16598 -16014
- package/dist/{defer-hydration-8vI8xNNx.js → defer-hydration-CcoHD2cy.js} +112 -26
- package/dist/defer-hydration-CcoHD2cy.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +13 -1
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/{glyphs-2bym5jl5.js → glyphs-DFp-825O.js} +33 -30
- package/dist/{glyphs-2bym5jl5.js.map → glyphs-DFp-825O.js.map} +1 -1
- package/dist/icons/extended.d.ts +2 -2
- package/dist/icons/extended.d.ts.map +1 -1
- package/dist/icons/glyphs.d.ts +3 -0
- package/dist/icons/glyphs.d.ts.map +1 -1
- package/dist/icons.js +29 -30
- package/dist/icons.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +326 -19
- 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 +1 -1
- 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/segments/error.d.ts.map +1 -1
- package/dist/renderers/segments/tool-call.d.ts.map +1 -1
- package/dist/types/element-map.d.ts +2 -0
- package/dist/types/element-map.d.ts.map +1 -1
- package/dist/types/errors.d.ts +7 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +2 -0
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models.d.ts +7 -5
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/segments.d.ts +12 -4
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/tools.d.ts +6 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/error-sentence.d.ts +21 -0
- package/dist/utils/error-sentence.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/defer-hydration-8vI8xNNx.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toolRefusal as toolRefusal$1, unansweredTail, runStreamAgent } from "@aparte/engine";
|
|
2
|
-
import { A as APARTE_ICON_GLYPHS } from "./glyphs-
|
|
2
|
+
import { A as APARTE_ICON_GLYPHS } from "./glyphs-DFp-825O.js";
|
|
3
3
|
function contentToText(content) {
|
|
4
4
|
if (typeof content === "string") return content;
|
|
5
5
|
return content.filter((p) => p.type === "text").map((p) => p.text).join("");
|
|
@@ -18,6 +18,7 @@ var AparteErrorCode = /* @__PURE__ */ ((AparteErrorCode2) => {
|
|
|
18
18
|
AparteErrorCode2["PROVIDER_ERROR"] = "PROVIDER_ERROR";
|
|
19
19
|
AparteErrorCode2["PROVIDER_UNAVAILABLE"] = "PROVIDER_UNAVAILABLE";
|
|
20
20
|
AparteErrorCode2["PROVIDER_POLICY"] = "PROVIDER_POLICY";
|
|
21
|
+
AparteErrorCode2["PROVIDER_MISCONFIGURED"] = "PROVIDER_MISCONFIGURED";
|
|
21
22
|
AparteErrorCode2["MAX_TURNS_EXCEEDED"] = "MAX_TURNS_EXCEEDED";
|
|
22
23
|
AparteErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
23
24
|
return AparteErrorCode2;
|
|
@@ -169,6 +170,13 @@ const APARTE_DEFAULT_LOCALE = {
|
|
|
169
170
|
typing: "Typing",
|
|
170
171
|
responseCutOff: "Cut off at the model's length limit.",
|
|
171
172
|
error: "Error",
|
|
173
|
+
errorUnreachable: "The assistant can’t be reached right now. Try again in a moment.",
|
|
174
|
+
errorTimeout: "The answer took too long. Try again in a moment.",
|
|
175
|
+
errorRefused: "The assistant isn’t allowed to answer right now.",
|
|
176
|
+
errorRateLimited: "Too many requests right now. Try again in a moment.",
|
|
177
|
+
errorTooLong: "This conversation is too long for the model. Start a new one.",
|
|
178
|
+
errorFailed: "The assistant couldn’t answer. Try again in a moment.",
|
|
179
|
+
errorNoAnswer: "The assistant couldn’t answer this request.",
|
|
172
180
|
running: "Running...",
|
|
173
181
|
run: "Run",
|
|
174
182
|
file: "File",
|
|
@@ -214,6 +222,8 @@ const APARTE_DEFAULT_LOCALE = {
|
|
|
214
222
|
scrollRailLabel: "Conversation outline",
|
|
215
223
|
sidebarLabel: "Conversations",
|
|
216
224
|
splitHandleLabel: "Resize the panes",
|
|
225
|
+
launcherOpen: "Open the chat",
|
|
226
|
+
launcherClose: "Close the chat",
|
|
217
227
|
transcript: "Transcript"
|
|
218
228
|
};
|
|
219
229
|
function isFormatAdapter(p) {
|
|
@@ -1961,7 +1971,7 @@ class ToolTable {
|
|
|
1961
1971
|
}
|
|
1962
1972
|
}
|
|
1963
1973
|
const APARTE_DEFAULT_BUBBLE_ACTIONS = {
|
|
1964
|
-
copy:
|
|
1974
|
+
copy: false,
|
|
1965
1975
|
retry: false,
|
|
1966
1976
|
edit: false,
|
|
1967
1977
|
feedback: false,
|
|
@@ -2164,13 +2174,13 @@ class AparteConfig {
|
|
|
2164
2174
|
}
|
|
2165
2175
|
/**
|
|
2166
2176
|
* Configure which action buttons appear in message bubbles.
|
|
2167
|
-
* Unset keys keep their defaults — see {@link APARTE_DEFAULT_BUBBLE_ACTIONS}:
|
|
2168
|
-
*
|
|
2177
|
+
* Unset keys keep their defaults — see {@link APARTE_DEFAULT_BUBBLE_ACTIONS}: none, so
|
|
2178
|
+
* a message carries no button until you turn one on.
|
|
2169
2179
|
*
|
|
2170
2180
|
* @example
|
|
2181
|
+
* aparteGlobalConfig.setBubbleActions({ copy: true }) // core copies on its own
|
|
2171
2182
|
* aparteGlobalConfig.setBubbleActions({ retry: true, edit: true }) // you run AparteClient
|
|
2172
|
-
* aparteGlobalConfig.setBubbleActions({ feedback: true }) // you listen for aparte-feedback
|
|
2173
|
-
* aparteGlobalConfig.setBubbleActions({ copy: false }) // hides copy; calls merge, so anything turned on above stays on
|
|
2183
|
+
* aparteGlobalConfig.setBubbleActions({ feedback: true }) // you listen for aparte-feedback; calls merge, so copy stays on
|
|
2174
2184
|
* // Explicit per-role ordered sets (replace the flag defaults for that role):
|
|
2175
2185
|
* aparteGlobalConfig.setBubbleActions({ user: ['edit', 'copy'], assistant: ['copy', 'thumbUp', 'thumbDown', 'retry'] })
|
|
2176
2186
|
*/
|
|
@@ -3122,8 +3132,13 @@ class AparteConfig {
|
|
|
3122
3132
|
* aparteGlobalConfig.registerToolDisplay('*', { hidden: true });
|
|
3123
3133
|
*
|
|
3124
3134
|
* @example
|
|
3135
|
+
* // An agent's chat: the spinner, "Running" and "Done" (the default is quiet), on every
|
|
3136
|
+
* // tool without an entry of its own — a tool with one says `quiet: false` there too.
|
|
3137
|
+
* aparteGlobalConfig.registerToolDisplay('*', { quiet: false });
|
|
3138
|
+
*
|
|
3139
|
+
* @example
|
|
3125
3140
|
* // The line, and no raw JSON behind it: nothing, or a detail of the app's own.
|
|
3126
|
-
* aparteGlobalConfig.registerToolDisplay('read_file', { label: '
|
|
3141
|
+
* aparteGlobalConfig.registerToolDisplay('read_file', { label: 'Read a file', details: false });
|
|
3127
3142
|
* aparteGlobalConfig.registerToolDisplay('web_search', {
|
|
3128
3143
|
* label: 'Searched the web',
|
|
3129
3144
|
* details: (segment) => sourcesList(segment.result),
|
|
@@ -3815,13 +3830,42 @@ const codeRenderer = {
|
|
|
3815
3830
|
},
|
|
3816
3831
|
getStyles: () => ``
|
|
3817
3832
|
};
|
|
3833
|
+
function errorSentence(code, t) {
|
|
3834
|
+
switch (code) {
|
|
3835
|
+
case AparteErrorCode.NET_OFFLINE:
|
|
3836
|
+
case AparteErrorCode.NET_ERROR:
|
|
3837
|
+
return t("errorUnreachable");
|
|
3838
|
+
case AparteErrorCode.NET_TIMEOUT:
|
|
3839
|
+
return t("errorTimeout");
|
|
3840
|
+
case AparteErrorCode.CONFIG_INVALID_KEY:
|
|
3841
|
+
return t("errorRefused");
|
|
3842
|
+
case AparteErrorCode.USAGE_RATE_LIMIT:
|
|
3843
|
+
return t("errorRateLimited");
|
|
3844
|
+
case AparteErrorCode.USAGE_CONTEXT_EXCEEDED:
|
|
3845
|
+
return t("errorTooLong");
|
|
3846
|
+
case AparteErrorCode.PROVIDER_ERROR:
|
|
3847
|
+
case AparteErrorCode.PROVIDER_UNAVAILABLE:
|
|
3848
|
+
return t("errorFailed");
|
|
3849
|
+
case AparteErrorCode.USAGE_BAD_REQUEST:
|
|
3850
|
+
case AparteErrorCode.PROVIDER_POLICY:
|
|
3851
|
+
case AparteErrorCode.PROVIDER_MISCONFIGURED:
|
|
3852
|
+
case AparteErrorCode.CONFIG_INVALID_MODEL:
|
|
3853
|
+
case AparteErrorCode.UNKNOWN_ERROR:
|
|
3854
|
+
return t("errorNoAnswer");
|
|
3855
|
+
default:
|
|
3856
|
+
return void 0;
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3818
3859
|
const errorRenderer = {
|
|
3819
3860
|
type: "error",
|
|
3820
3861
|
render: (segment) => {
|
|
3821
|
-
const
|
|
3862
|
+
const cfg = contextConfig();
|
|
3863
|
+
const sentence = errorSentence(segment.code, (key) => cfg.t(key));
|
|
3864
|
+
const custom = cfg.getErrorRenderer?.();
|
|
3822
3865
|
if (custom) {
|
|
3823
3866
|
const out = custom({
|
|
3824
3867
|
message: segment.content,
|
|
3868
|
+
...sentence !== void 0 ? { sentence } : {},
|
|
3825
3869
|
...segment.details !== void 0 ? { details: segment.details } : {},
|
|
3826
3870
|
...segment.code !== void 0 ? { code: segment.code } : {}
|
|
3827
3871
|
});
|
|
@@ -3831,28 +3875,35 @@ const errorRenderer = {
|
|
|
3831
3875
|
}
|
|
3832
3876
|
return out;
|
|
3833
3877
|
}
|
|
3878
|
+
const message = sentence ?? segment.content;
|
|
3834
3879
|
return `
|
|
3835
3880
|
<div class="aparte-segment aparte-alert aparte-alert--danger aparte-segment-error" data-segment-id="${escapeHtml(segment.id)}"${segment.code ? ` data-error-code="${escapeAttr(segment.code)}"` : ""}>
|
|
3836
|
-
<span class="aparte-alert__icon">${
|
|
3881
|
+
<span class="aparte-alert__icon">${cfg.getIcon("error") || "⚠"}</span>
|
|
3837
3882
|
<div class="aparte-alert__body">
|
|
3838
|
-
<div class="aparte-alert__title">${escapeHtml(
|
|
3839
|
-
<div class="aparte-alert__message">${escapeHtml(
|
|
3883
|
+
<div class="aparte-alert__title">${escapeHtml(cfg.t("error"))}</div>
|
|
3884
|
+
<div class="aparte-alert__message">${escapeHtml(message)}</div>
|
|
3840
3885
|
${segment.details ? `<pre class="aparte-segment-error__details">${escapeHtml(segment.details)}</pre>` : ""}
|
|
3841
3886
|
</div>
|
|
3842
3887
|
</div>
|
|
3843
3888
|
`;
|
|
3844
3889
|
},
|
|
3845
3890
|
/**
|
|
3846
|
-
* The icon
|
|
3891
|
+
* The icon, the heading (`locale.error`) and a sentence chosen by the code.
|
|
3847
3892
|
*
|
|
3848
|
-
* Not the
|
|
3849
|
-
* language it
|
|
3893
|
+
* Not a message the error keeps as its own: that is the app's, a setup error's or the
|
|
3894
|
+
* turn limit's text, in the language it was written in. Relabelling it would be
|
|
3895
|
+
* inventing content.
|
|
3850
3896
|
*/
|
|
3851
|
-
relabel: (element) => {
|
|
3897
|
+
relabel: (element, segment) => {
|
|
3898
|
+
const cfg = contextConfig();
|
|
3899
|
+
if (cfg.getErrorRenderer?.()) return;
|
|
3852
3900
|
const wrap = element.querySelector(".aparte-alert__icon");
|
|
3853
|
-
if (wrap) wrap.innerHTML =
|
|
3901
|
+
if (wrap) wrap.innerHTML = cfg.getIcon("error") || "⚠";
|
|
3854
3902
|
const title = element.querySelector(".aparte-alert__title");
|
|
3855
|
-
if (title) title.textContent =
|
|
3903
|
+
if (title) title.textContent = cfg.t("error");
|
|
3904
|
+
const sentence = errorSentence(segment.code, (key) => cfg.t(key));
|
|
3905
|
+
const message = element.querySelector(".aparte-alert__message");
|
|
3906
|
+
if (message && sentence !== void 0) message.textContent = sentence;
|
|
3856
3907
|
},
|
|
3857
3908
|
getStyles: () => ``
|
|
3858
3909
|
};
|
|
@@ -4111,7 +4162,7 @@ function iconOf(segment) {
|
|
|
4111
4162
|
const key = cfg.getToolDisplay(segment.toolCall?.name ?? "")?.icon;
|
|
4112
4163
|
return (key ? cfg.getIcon(key) : void 0) || cfg.getIcon("tool");
|
|
4113
4164
|
}
|
|
4114
|
-
const isQuiet = (segment) => contextConfig().getToolDisplay(segment.toolCall?.name ?? "")?.quiet
|
|
4165
|
+
const isQuiet = (segment) => contextConfig().getToolDisplay(segment.toolCall?.name ?? "")?.quiet ?? true;
|
|
4115
4166
|
function quietOf(segment) {
|
|
4116
4167
|
const status = segment.status ?? "pending";
|
|
4117
4168
|
const quiet = isQuiet(segment);
|
|
@@ -7250,6 +7301,7 @@ function requestUserInput(request) {
|
|
|
7250
7301
|
const NOT_RUN_AFTER_A_REFUSAL = "Not run: an earlier call of the same step was refused.";
|
|
7251
7302
|
const approvalKey = (call) => JSON.stringify([call.id, call.name, call.input]);
|
|
7252
7303
|
const warnedUninlinedFiles = /* @__PURE__ */ new Set();
|
|
7304
|
+
const claimedConfigs = /* @__PURE__ */ new Map();
|
|
7253
7305
|
const CHAT_SELECTOR = "aparte-chat, aparte-chat-viewport, [data-aparte-chat]";
|
|
7254
7306
|
function remoteProvider(id) {
|
|
7255
7307
|
return {
|
|
@@ -7313,7 +7365,12 @@ class AparteClient {
|
|
|
7313
7365
|
const detail = e.detail;
|
|
7314
7366
|
const scope = this.options.scopeToTargetId;
|
|
7315
7367
|
if (scope) return detail?.targetId === scope;
|
|
7316
|
-
if (this._config === aparteGlobalConfig)
|
|
7368
|
+
if (this._config === aparteGlobalConfig) {
|
|
7369
|
+
if (claimedConfigs.size === 0) return true;
|
|
7370
|
+
const claimed = this._resolveTarget(detail?.targetId, e);
|
|
7371
|
+
const owner2 = claimed ? resolveConfig(claimed) : aparteGlobalConfig;
|
|
7372
|
+
return owner2 === aparteGlobalConfig || !claimedConfigs.has(owner2);
|
|
7373
|
+
}
|
|
7317
7374
|
const target = this._resolveTarget(detail?.targetId, e);
|
|
7318
7375
|
if (!target) return true;
|
|
7319
7376
|
const owner = resolveConfig(target);
|
|
@@ -7324,6 +7381,8 @@ class AparteClient {
|
|
|
7324
7381
|
options;
|
|
7325
7382
|
/** Config read by this client — an instance config, or the global default. */
|
|
7326
7383
|
_config;
|
|
7384
|
+
/** Whether this client, started on an instance config, counts in `claimedConfigs`. */
|
|
7385
|
+
_claims = false;
|
|
7327
7386
|
/**
|
|
7328
7387
|
* A `keyResolver` becomes a key source on the client's config at once, before `start()`,
|
|
7329
7388
|
* so everything that needs a key can use it — the model selector's list included.
|
|
@@ -7393,6 +7452,10 @@ class AparteClient {
|
|
|
7393
7452
|
*/
|
|
7394
7453
|
start() {
|
|
7395
7454
|
this._registerKeyResolver();
|
|
7455
|
+
if (this._config !== aparteGlobalConfig && !this._claims) {
|
|
7456
|
+
this._claims = true;
|
|
7457
|
+
claimedConfigs.set(this._config, (claimedConfigs.get(this._config) ?? 0) + 1);
|
|
7458
|
+
}
|
|
7396
7459
|
if (!this._boundHandler) {
|
|
7397
7460
|
this._setupListeners();
|
|
7398
7461
|
}
|
|
@@ -7438,6 +7501,12 @@ class AparteClient {
|
|
|
7438
7501
|
*/
|
|
7439
7502
|
stop() {
|
|
7440
7503
|
this.abort();
|
|
7504
|
+
if (this._claims) {
|
|
7505
|
+
this._claims = false;
|
|
7506
|
+
const left = (claimedConfigs.get(this._config) ?? 1) - 1;
|
|
7507
|
+
if (left > 0) claimedConfigs.set(this._config, left);
|
|
7508
|
+
else claimedConfigs.delete(this._config);
|
|
7509
|
+
}
|
|
7441
7510
|
this._releaseKeyResolver?.();
|
|
7442
7511
|
this._releaseKeyResolver = null;
|
|
7443
7512
|
if (!this._listening || !this._boundHandler) return;
|
|
@@ -7632,7 +7701,7 @@ class AparteClient {
|
|
|
7632
7701
|
};
|
|
7633
7702
|
const isStopped = () => this._isAborted || streamController.signal.aborted;
|
|
7634
7703
|
const runOnce = async () => {
|
|
7635
|
-
let result = opts?.resume ? { usage: void 0, suspended: opts.resume } : await this._streamLoop(targetElement, messageId, provider, baseRequest, authConfig, streamController);
|
|
7704
|
+
let result = opts?.resume ? { usage: void 0, suspended: opts.resume } : await this._streamLoop(targetElement, messageId, provider, baseRequest, authConfig, streamController, void 0, opts?.files);
|
|
7636
7705
|
const maxResumes = this.options.maxTurns ?? 10;
|
|
7637
7706
|
let resumes = 0;
|
|
7638
7707
|
let approvedAtLastPause = /* @__PURE__ */ new Set();
|
|
@@ -8129,9 +8198,9 @@ class AparteClient {
|
|
|
8129
8198
|
let authConfig;
|
|
8130
8199
|
let messages;
|
|
8131
8200
|
let fileParts;
|
|
8201
|
+
const rawFiles = Array.isArray(event.detail?.files) ? event.detail.files : [];
|
|
8132
8202
|
try {
|
|
8133
8203
|
authConfig = providerId ? await this._resolveAuth(providerId) : void 0;
|
|
8134
|
-
const rawFiles = Array.isArray(event.detail?.files) ? event.detail.files : [];
|
|
8135
8204
|
const filesToInject = this._selectFilesToInject(rawFiles);
|
|
8136
8205
|
const contentParts = filesToInject.length > 0 ? await this._filesToContentParts(filesToInject) : [];
|
|
8137
8206
|
fileParts = contentParts.length > 0 ? contentParts : void 0;
|
|
@@ -8147,7 +8216,10 @@ class AparteClient {
|
|
|
8147
8216
|
messages,
|
|
8148
8217
|
modelId || config.defaultModel || "",
|
|
8149
8218
|
authConfig,
|
|
8150
|
-
{
|
|
8219
|
+
{
|
|
8220
|
+
rebuild: async () => this._buildMessages(content, targetElement, fileParts),
|
|
8221
|
+
...rawFiles.length > 0 ? { files: rawFiles } : {}
|
|
8222
|
+
}
|
|
8151
8223
|
);
|
|
8152
8224
|
}
|
|
8153
8225
|
/**
|
|
@@ -8256,11 +8328,11 @@ ${content}
|
|
|
8256
8328
|
* adapter, or the runner a host injected — after the fetch-level abort bookkeeping.
|
|
8257
8329
|
*/
|
|
8258
8330
|
/** One run of the loop: its usage, and whether it paused (a server loop). */
|
|
8259
|
-
async _streamLoop(targetElement, messageId, provider, baseRequest, authConfig, streamController = new AbortController(), deferral) {
|
|
8331
|
+
async _streamLoop(targetElement, messageId, provider, baseRequest, authConfig, streamController = new AbortController(), deferral, files) {
|
|
8260
8332
|
if (this._streamController !== streamController) this._streamController?.abort();
|
|
8261
8333
|
this._streamController = streamController;
|
|
8262
8334
|
const runner = this.options.streamRunner ?? runStreamAgent;
|
|
8263
|
-
return this._runViaStreamRunner(runner, targetElement, messageId, provider, baseRequest, authConfig, streamController, deferral);
|
|
8335
|
+
return this._runViaStreamRunner(runner, targetElement, messageId, provider, baseRequest, authConfig, streamController, deferral, files);
|
|
8264
8336
|
}
|
|
8265
8337
|
/**
|
|
8266
8338
|
* Run the loop through a {@link AparteStreamRunner} — the engine's by default —
|
|
@@ -8271,7 +8343,7 @@ ${content}
|
|
|
8271
8343
|
* produces is pinned by the `stream-parity` suite's snapshots, recorded while
|
|
8272
8344
|
* the inline loop it replaced still ran beside it.
|
|
8273
8345
|
*/
|
|
8274
|
-
async _runViaStreamRunner(streamRunner, targetElement, messageId, provider, baseRequest, authConfig, streamController, deferral) {
|
|
8346
|
+
async _runViaStreamRunner(streamRunner, targetElement, messageId, provider, baseRequest, authConfig, streamController, deferral, files) {
|
|
8275
8347
|
const signal = streamController.signal;
|
|
8276
8348
|
const chatId = this._targetIdOf(targetElement);
|
|
8277
8349
|
const adapter = createStreamAdapter({
|
|
@@ -8283,8 +8355,10 @@ ${content}
|
|
|
8283
8355
|
const prefixSegments = baseRequest._meta?.["prefixSegments"];
|
|
8284
8356
|
let suspended;
|
|
8285
8357
|
let finishReason;
|
|
8358
|
+
let toolCrash;
|
|
8286
8359
|
const emitter = (event) => {
|
|
8287
8360
|
adapter(event);
|
|
8361
|
+
if (event.type === "tool-failed") toolCrash = event.error;
|
|
8288
8362
|
if (event.type === "run-done") finishReason = event.finishReason;
|
|
8289
8363
|
if (event.type === "run-suspended") {
|
|
8290
8364
|
const ticket = event.ticket;
|
|
@@ -8317,10 +8391,16 @@ ${content}
|
|
|
8317
8391
|
};
|
|
8318
8392
|
};
|
|
8319
8393
|
const approvalResolver = this._approvalResolverFor(targetElement);
|
|
8394
|
+
const asToolCrash = (error) => {
|
|
8395
|
+
if (toolCrash === void 0 || error instanceof AparteError) return error;
|
|
8396
|
+
const text = error instanceof Error ? error.message || error.name : typeof error === "string" ? error : String(error);
|
|
8397
|
+
return text === toolCrash ? new AparteError(text, AparteErrorCode.UNKNOWN_ERROR, void 0, error) : error;
|
|
8398
|
+
};
|
|
8320
8399
|
const usage = await streamRunner({
|
|
8321
8400
|
messageId,
|
|
8322
8401
|
...provider.id ? { providerId: provider.id } : {},
|
|
8323
8402
|
...deferral ? { deferral } : {},
|
|
8403
|
+
...files && files.length > 0 ? { files } : {},
|
|
8324
8404
|
baseRequest,
|
|
8325
8405
|
transportCall,
|
|
8326
8406
|
toolLookup,
|
|
@@ -8337,6 +8417,8 @@ ${content}
|
|
|
8337
8417
|
// The id conventions the loop always had: prefixed artifact ids, but a
|
|
8338
8418
|
// BARE uuid for the synthetic tool (the adapter renders `tool-<id>`).
|
|
8339
8419
|
idGen: (prefix) => prefix === "synthetic-tool" ? uuid() : `${prefix}-${uuid()}`
|
|
8420
|
+
}).catch((error) => {
|
|
8421
|
+
throw asToolCrash(error);
|
|
8340
8422
|
});
|
|
8341
8423
|
return {
|
|
8342
8424
|
usage: usage ?? void 0,
|
|
@@ -8605,6 +8687,9 @@ ${content}
|
|
|
8605
8687
|
content: error.message,
|
|
8606
8688
|
code: error.code
|
|
8607
8689
|
};
|
|
8690
|
+
if (errorSentence(error.code, (key) => this._config.t(key)) !== void 0) {
|
|
8691
|
+
console.warn(`[aparte] A turn failed (${error.code}): ${error.message}`);
|
|
8692
|
+
}
|
|
8608
8693
|
if (target.updateMessage) {
|
|
8609
8694
|
const rendered = target.getMessage?.(messageId)?.segments ?? target.getMessages?.()?.find((m) => m.id === messageId)?.segments ?? [];
|
|
8610
8695
|
target.updateMessage(messageId, {
|
|
@@ -8984,6 +9069,7 @@ const APARTE_DEFAULT_UI_EVENTS = [
|
|
|
8984
9069
|
"aparte-scroll-rail-jump",
|
|
8985
9070
|
"aparte-sidebar-toggle",
|
|
8986
9071
|
"aparte-split-resize",
|
|
9072
|
+
"aparte-launcher-toggle",
|
|
8987
9073
|
// the turn's lifecycle, dispatched on the HOST element by `dispatchLifecycleEvent`
|
|
8988
9074
|
"aparte-message-start",
|
|
8989
9075
|
"aparte-message-done",
|
|
@@ -9254,4 +9340,4 @@ export {
|
|
|
9254
9340
|
collectRendererStyles as y,
|
|
9255
9341
|
contentToText as z
|
|
9256
9342
|
};
|
|
9257
|
-
//# sourceMappingURL=defer-hydration-
|
|
9343
|
+
//# sourceMappingURL=defer-hydration-CcoHD2cy.js.map
|