@lostgradient/cinder 0.9.0 → 0.11.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/CHANGELOG.md +16 -0
- package/components.json +82 -4
- package/dist/components/access-gate/index.js +381 -239
- package/dist/components/chat/builders.d.ts +17 -8
- package/dist/components/chat/conversation-model.d.ts +1 -1
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +300 -17
- package/dist/components/chat/utilities/conversation.d.ts +6 -6
- package/dist/components/chat-conversation-header/index.js +19 -6
- package/dist/components/chat-conversation-list/index.js +19 -6
- package/dist/components/connection-indicator/connection-indicator.css +136 -0
- package/dist/components/connection-indicator/connection-indicator.css.d.ts +1 -0
- package/dist/components/connection-indicator/connection-indicator.schema.d.ts +3 -0
- package/dist/components/connection-indicator/connection-indicator.schema.js +89 -0
- package/dist/components/connection-indicator/connection-indicator.svelte.d.ts +21 -0
- package/dist/components/connection-indicator/connection-indicator.types.d.ts +46 -0
- package/dist/components/connection-indicator/connection-indicator.variables.d.ts +2 -0
- package/dist/components/connection-indicator/connection-indicator.variables.js +61 -0
- package/dist/components/connection-indicator/index.d.ts +5 -0
- package/dist/components/connection-indicator/index.js +409 -0
- package/dist/components/container/container.schema.js +4 -4
- package/dist/components/invocation-rule-builder/index.d.ts +1 -1
- package/dist/components/invocation-rule-builder/index.js +305 -150
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +28 -0
- package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.js +89 -5
- package/dist/components/invocation-rule-builder/invocation-rule-builder.svelte.d.ts +2 -1
- package/dist/components/invocation-rule-builder/invocation-rule-builder.types.d.ts +114 -16
- package/dist/components/run-step-timeline/index.d.ts +1 -1
- package/dist/components/run-step-timeline/index.js +992 -559
- package/dist/components/run-step-timeline/run-step-branch-disclosure.svelte.d.ts +17 -0
- package/dist/components/run-step-timeline/run-step-timeline.css +124 -0
- package/dist/components/run-step-timeline/run-step-timeline.schema.js +873 -350
- package/dist/components/run-step-timeline/run-step-timeline.svelte.d.ts +1 -15
- package/dist/components/run-step-timeline/run-step-timeline.types.d.ts +182 -5
- package/dist/components/run-step-timeline/run-step-timeline.utilities.d.ts +52 -0
- package/dist/components/schedule-builder/index.d.ts +5 -0
- package/dist/components/schedule-builder/index.js +3176 -0
- package/dist/components/schedule-builder/schedule-builder.css +121 -0
- package/dist/components/schedule-builder/schedule-builder.css.d.ts +1 -0
- package/dist/components/schedule-builder/schedule-builder.schema.d.ts +3 -0
- package/dist/components/schedule-builder/schedule-builder.schema.js +141 -0
- package/dist/components/schedule-builder/schedule-builder.svelte.d.ts +22 -0
- package/dist/components/schedule-builder/schedule-builder.types.d.ts +130 -0
- package/dist/components/schedule-builder/schedule-builder.utilities.d.ts +78 -0
- package/dist/components/schedule-builder/schedule-builder.variables.d.ts +2 -0
- package/dist/components/schedule-builder/schedule-builder.variables.js +61 -0
- package/dist/components/tag-input/index.js +22 -4
- package/dist/components/tag-input/tag-input.schema.js +5 -1
- package/dist/components/tag-input/tag-input.types.d.ts +4 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +22704 -20574
- package/dist/server/components/access-gate/index.js +2 -1
- package/dist/server/components/chat/index.js +4 -4
- package/dist/server/components/chat-conversation-header/index.js +5 -5
- package/dist/server/components/chat-conversation-list/index.js +3 -3
- package/dist/server/components/connection-indicator/index.js +16 -0
- package/dist/server/components/data-table/index.js +3 -3
- package/dist/server/components/diff-viewer/index.js +4 -3
- package/dist/server/components/invocation-rule-builder/index.js +1 -1
- package/dist/server/components/json-schema-editor/index.js +4 -3
- package/dist/server/components/review-editor/index.js +4 -3
- package/dist/server/components/run-step-timeline/index.js +1 -1
- package/dist/server/components/schedule-builder/index.js +30 -0
- package/dist/server/components/side-navigation/index.js +2 -2
- package/dist/server/components/table/index.js +3 -3
- package/dist/server/components/tag-input/index.js +1 -1
- package/dist/server/components/time-field/index.js +5 -3
- package/dist/server/index.js +100 -87
- package/dist/server/index.server-0sx92swg.js +9 -0
- package/dist/server/{index.server-mzzb7dnm.js → index.server-2bbwajb2.js} +1 -1
- package/dist/server/{index.server-q7w4jw89.js → index.server-2s5h1d05.js} +2 -2
- package/dist/server/{index.server-dg83ke3k.js → index.server-2zdbz3rj.js} +1 -1
- package/dist/server/{index.server-0jhra85x.js → index.server-3w72dxz7.js} +4 -4
- package/dist/server/{index.server-qh9qzd5t.js → index.server-4x4hgvqe.js} +283 -13
- package/dist/server/{index.server-c6pe4kaf.js → index.server-5gzyqv78.js} +1 -1
- package/dist/server/{index.server-mqt1ngqw.js → index.server-6hnfzc7f.js} +19 -6
- package/dist/server/index.server-be9bpqeh.js +93 -0
- package/dist/server/{index.server-f3z7tpxr.js → index.server-c42b462p.js} +2 -4
- package/dist/server/{index.server-7vyzen5x.js → index.server-c5qv3p61.js} +171 -63
- package/dist/server/index.server-cch0eed5.js +144 -0
- package/dist/server/index.server-gmh5ar16.js +2 -0
- package/dist/server/{index.server-0atyznp7.js → index.server-h89zk5ev.js} +7 -7
- package/dist/server/{index.server-jxg42jpz.js → index.server-jdcq5zza.js} +7 -7
- package/dist/server/{index.server-2dga5yzr.js → index.server-jfrssta6.js} +1 -1
- package/dist/server/{index.server-fy068yne.js → index.server-jj76374p.js} +1 -1
- package/dist/server/index.server-qbkxz7r2.js +750 -0
- package/dist/server/{index.server-marjz8ps.js → index.server-tcay903b.js} +3 -2
- package/dist/server/index.server-z38bxms8.js +734 -0
- package/dist/server/{index.server-yz4k36cw.js → index.server-z7hxtqs1.js} +1 -1
- package/package.json +66 -3
- package/src/components/chat/builders.ts +445 -14
- package/src/components/chat/conversation-model.ts +1 -0
- package/src/components/chat/index.ts +1 -0
- package/src/components/chat/utilities/conversation.ts +33 -15
- package/src/components/connection-indicator/connection-indicator.css +136 -0
- package/src/components/connection-indicator/connection-indicator.examples.json +31 -0
- package/src/components/connection-indicator/connection-indicator.schema.json +29 -0
- package/src/components/connection-indicator/connection-indicator.schema.ts +36 -0
- package/src/components/connection-indicator/connection-indicator.svelte +63 -0
- package/src/components/connection-indicator/connection-indicator.types.ts +58 -0
- package/src/components/connection-indicator/connection-indicator.variables.json +1 -0
- package/src/components/connection-indicator/connection-indicator.variables.ts +3 -0
- package/src/components/connection-indicator/index.ts +10 -0
- package/src/components/container/container.schema.json +3 -3
- package/src/components/container/container.schema.ts +3 -3
- package/src/components/invocation-rule-builder/index.ts +4 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.css +28 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +6 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.json +76 -3
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.ts +83 -3
- package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +326 -113
- package/src/components/invocation-rule-builder/invocation-rule-builder.types.ts +157 -43
- package/src/components/run-step-timeline/index.ts +8 -0
- package/src/components/run-step-timeline/run-step-branch-disclosure.svelte +16 -0
- package/src/components/run-step-timeline/run-step-timeline.css +124 -0
- package/src/components/run-step-timeline/run-step-timeline.examples.json +18 -0
- package/src/components/run-step-timeline/run-step-timeline.schema.json +872 -349
- package/src/components/run-step-timeline/run-step-timeline.schema.ts +931 -349
- package/src/components/run-step-timeline/run-step-timeline.svelte +387 -268
- package/src/components/run-step-timeline/run-step-timeline.types.ts +192 -5
- package/src/components/run-step-timeline/run-step-timeline.utilities.ts +242 -0
- package/src/components/schedule-builder/index.ts +14 -0
- package/src/components/schedule-builder/schedule-builder.css +121 -0
- package/src/components/schedule-builder/schedule-builder.examples.json +31 -0
- package/src/components/schedule-builder/schedule-builder.schema.json +78 -0
- package/src/components/schedule-builder/schedule-builder.schema.ts +86 -0
- package/src/components/schedule-builder/schedule-builder.svelte +629 -0
- package/src/components/schedule-builder/schedule-builder.types.ts +137 -0
- package/src/components/schedule-builder/schedule-builder.utilities.ts +344 -0
- package/src/components/schedule-builder/schedule-builder.variables.json +1 -0
- package/src/components/schedule-builder/schedule-builder.variables.ts +3 -0
- package/src/components/tag-input/tag-input.schema.json +4 -0
- package/src/components/tag-input/tag-input.schema.ts +4 -0
- package/src/components/tag-input/tag-input.svelte +20 -3
- package/src/components/tag-input/tag-input.types.ts +4 -0
- package/src/index.ts +23 -0
- package/src/styles/components.css +2 -0
- package/dist/server/index.server-qk1h0n02.js +0 -393
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
resolveMessageReasoning,
|
|
19
19
|
resolveMessageSteps,
|
|
20
20
|
resolveMessageSuggestions
|
|
21
|
-
} from "./index.server-
|
|
21
|
+
} from "./index.server-6hnfzc7f.js";
|
|
22
22
|
import {
|
|
23
23
|
Arrow_up,
|
|
24
24
|
Check_check,
|
|
@@ -3866,20 +3866,290 @@ function Chat2($$renderer, $$props) {
|
|
|
3866
3866
|
}
|
|
3867
3867
|
|
|
3868
3868
|
// src/components/chat/builders.ts
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3869
|
+
var MESSAGE_ROLES = new Set([
|
|
3870
|
+
"user",
|
|
3871
|
+
"assistant",
|
|
3872
|
+
"system",
|
|
3873
|
+
"developer",
|
|
3874
|
+
"tool-call",
|
|
3875
|
+
"tool-result",
|
|
3876
|
+
"snapshot"
|
|
3877
|
+
]);
|
|
3878
|
+
var CONVERSATION_STATUSES = new Set(["active", "archived", "deleted"]);
|
|
3879
|
+
function createId() {
|
|
3880
|
+
return globalThis.crypto?.randomUUID?.() ?? `message-${Date.now()}-${Math.random()}`;
|
|
3881
|
+
}
|
|
3882
|
+
function isRecord(value) {
|
|
3883
|
+
return typeof value === "object" && value !== null;
|
|
3884
|
+
}
|
|
3885
|
+
function isJsonObject(value) {
|
|
3886
|
+
if (!isRecord(value) || Array.isArray(value))
|
|
3887
|
+
return false;
|
|
3888
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3889
|
+
return prototype === Object.prototype || prototype === null;
|
|
3890
|
+
}
|
|
3891
|
+
function isJsonValue(value) {
|
|
3892
|
+
if (value === null)
|
|
3893
|
+
return true;
|
|
3894
|
+
switch (typeof value) {
|
|
3895
|
+
case "string":
|
|
3896
|
+
case "boolean":
|
|
3897
|
+
return true;
|
|
3898
|
+
case "number":
|
|
3899
|
+
return Number.isFinite(value);
|
|
3900
|
+
case "object":
|
|
3901
|
+
if (Array.isArray(value))
|
|
3902
|
+
return value.every(isJsonValue);
|
|
3903
|
+
return isJsonObject(value) && Object.values(value).every(isJsonValue);
|
|
3904
|
+
default:
|
|
3905
|
+
return false;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
function assertJsonObject(value, label) {
|
|
3909
|
+
if (!isJsonObject(value) || !Object.values(value).every(isJsonValue)) {
|
|
3910
|
+
throw new Error(`${label} must be a JSON-compatible object`);
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
function isConversationEnvironmentParameter(value) {
|
|
3914
|
+
if (!isRecord(value) || "role" in value)
|
|
3915
|
+
return false;
|
|
3916
|
+
return typeof value["now"] === "function" || typeof value["randomId"] === "function" || typeof value["estimateTokens"] === "function" || Array.isArray(value["plugins"]) && value["plugins"].every((plugin) => typeof plugin === "function");
|
|
3917
|
+
}
|
|
3918
|
+
function isRoleHelperEnvironmentParameter(value) {
|
|
3919
|
+
if (!isRecord(value) || "role" in value)
|
|
3920
|
+
return false;
|
|
3921
|
+
return typeof value["now"] === "function" || typeof value["randomId"] === "function" || typeof value["estimateTokens"] === "function" || Array.isArray(value["plugins"]) && value["plugins"].length > 0 && value["plugins"].every((plugin) => typeof plugin === "function");
|
|
3922
|
+
}
|
|
3923
|
+
function isMultiModalContentPart(value) {
|
|
3924
|
+
if (!isJsonObject(value) || typeof value["type"] !== "string")
|
|
3925
|
+
return false;
|
|
3926
|
+
if (!Object.values(value).every(isJsonValue))
|
|
3927
|
+
return false;
|
|
3928
|
+
switch (value["type"]) {
|
|
3929
|
+
case "text":
|
|
3930
|
+
return typeof value["text"] === "string";
|
|
3931
|
+
case "image":
|
|
3932
|
+
return typeof value["url"] === "string";
|
|
3933
|
+
case "thinking":
|
|
3934
|
+
return typeof value["thinking"] === "string";
|
|
3935
|
+
case "redacted_thinking":
|
|
3936
|
+
return typeof value["data"] === "string";
|
|
3937
|
+
case "server_tool_use":
|
|
3938
|
+
return typeof value["id"] === "string" && typeof value["name"] === "string";
|
|
3939
|
+
case "web_search_tool_result":
|
|
3940
|
+
return typeof value["tool_use_id"] === "string" && "content" in value;
|
|
3941
|
+
case "container_upload":
|
|
3942
|
+
return typeof value["file_id"] === "string";
|
|
3943
|
+
default:
|
|
3944
|
+
return false;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
function isMessageContentInput(value) {
|
|
3948
|
+
return typeof value === "string" || Array.isArray(value) && value.every(isMultiModalContentPart) || isMultiModalContentPart(value);
|
|
3949
|
+
}
|
|
3950
|
+
function isLooseMessageInput(value) {
|
|
3951
|
+
return isRecord(value) && typeof value["role"] === "string" && MESSAGE_ROLES.has(value["role"]) && isMessageContentInput(value["content"]) && (value["hidden"] === undefined || typeof value["hidden"] === "boolean") && (value["goalCompleted"] === undefined || typeof value["goalCompleted"] === "boolean");
|
|
3952
|
+
}
|
|
3953
|
+
function isMetadataRecord(value) {
|
|
3954
|
+
return isJsonObject(value);
|
|
3955
|
+
}
|
|
3956
|
+
function resolveEnvironment(environment) {
|
|
3957
|
+
const plugins = environment?.plugins ?? [];
|
|
3958
|
+
if (!Array.isArray(plugins) || plugins.some((plugin) => typeof plugin !== "function")) {
|
|
3959
|
+
throw new Error("conversation environment plugins must be functions");
|
|
3960
|
+
}
|
|
3961
|
+
return {
|
|
3962
|
+
now: environment?.now ?? (() => new Date().toISOString()),
|
|
3963
|
+
randomId: environment?.randomId ?? createId,
|
|
3964
|
+
plugins: [...plugins]
|
|
3965
|
+
};
|
|
3966
|
+
}
|
|
3967
|
+
function cloneStructuredValue(value) {
|
|
3968
|
+
return structuredClone(value);
|
|
3969
|
+
}
|
|
3970
|
+
function cloneMetadata(metadata) {
|
|
3971
|
+
if (metadata === undefined)
|
|
3972
|
+
return {};
|
|
3973
|
+
assertJsonObject(metadata, "metadata");
|
|
3974
|
+
return cloneStructuredValue(metadata);
|
|
3975
|
+
}
|
|
3976
|
+
function normalizeContent(content) {
|
|
3977
|
+
if (typeof content === "string")
|
|
3978
|
+
return content;
|
|
3979
|
+
return Array.isArray(content) ? cloneStructuredValue(content) : [cloneStructuredValue(content)];
|
|
3980
|
+
}
|
|
3981
|
+
function cloneTokenUsage(tokenUsage) {
|
|
3982
|
+
assertJsonObject(tokenUsage, "tokenUsage");
|
|
3983
|
+
const values = Object.values(tokenUsage);
|
|
3984
|
+
if (values.some((value) => typeof value !== "number")) {
|
|
3985
|
+
throw new Error("tokenUsage values must be numbers");
|
|
3986
|
+
}
|
|
3987
|
+
if (values.some((value) => typeof value === "number" && (!Number.isInteger(value) || value < 0))) {
|
|
3988
|
+
throw new Error("tokenUsage values must be non-negative integers");
|
|
3989
|
+
}
|
|
3990
|
+
return cloneStructuredValue(tokenUsage);
|
|
3991
|
+
}
|
|
3992
|
+
function cloneToolCall(toolCall) {
|
|
3993
|
+
assertJsonObject(toolCall, "toolCall");
|
|
3994
|
+
if (typeof toolCall.id !== "string" || typeof toolCall.name !== "string" || !("arguments" in toolCall) || !isJsonValue(toolCall.arguments)) {
|
|
3995
|
+
throw new Error("toolCall must include string id, string name, and JSON arguments");
|
|
3996
|
+
}
|
|
3997
|
+
return cloneStructuredValue(toolCall);
|
|
3998
|
+
}
|
|
3999
|
+
function cloneToolResult(toolResult) {
|
|
4000
|
+
assertJsonObject(toolResult, "toolResult");
|
|
4001
|
+
if (typeof toolResult.callId !== "string" || !["success", "error", "action_required"].includes(String(toolResult.outcome)) || !("content" in toolResult) || !isJsonValue(toolResult.content)) {
|
|
4002
|
+
throw new Error("toolResult must include string callId, valid outcome, and JSON content");
|
|
4003
|
+
}
|
|
4004
|
+
return cloneStructuredValue(toolResult);
|
|
4005
|
+
}
|
|
4006
|
+
function getOrderedMessages(conversation) {
|
|
4007
|
+
return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined);
|
|
4008
|
+
}
|
|
4009
|
+
function buildToolCallIds(messages) {
|
|
4010
|
+
const toolCallIds = new Set;
|
|
4011
|
+
for (const message of messages) {
|
|
4012
|
+
if (message.role === "tool-call" && message.toolCall !== undefined) {
|
|
4013
|
+
if (toolCallIds.has(message.toolCall.id)) {
|
|
4014
|
+
throw new Error(`duplicate toolCall.id in conversation: ${message.toolCall.id}`);
|
|
4015
|
+
}
|
|
4016
|
+
toolCallIds.add(message.toolCall.id);
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
return toolCallIds;
|
|
4020
|
+
}
|
|
4021
|
+
function assertValidToolMessage(input, toolCallIds) {
|
|
4022
|
+
if (input.role === "tool-result" && input.toolResult !== undefined) {
|
|
4023
|
+
if (!toolCallIds.has(input.toolResult.callId)) {
|
|
4024
|
+
throw new Error(`tool result references non-existent tool-call: ${input.toolResult.callId}`);
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
if (input.role === "tool-call" && input.toolCall !== undefined) {
|
|
4028
|
+
if (toolCallIds.has(input.toolCall.id)) {
|
|
4029
|
+
throw new Error(`duplicate toolCall.id in conversation: ${input.toolCall.id}`);
|
|
4030
|
+
}
|
|
4031
|
+
toolCallIds.add(input.toolCall.id);
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
function createConversation(options = {}, environment) {
|
|
4035
|
+
const resolvedEnvironment = resolveEnvironment(environment);
|
|
4036
|
+
const createdAt = resolvedEnvironment.now();
|
|
4037
|
+
const conversationId = options.id ?? resolvedEnvironment.randomId();
|
|
4038
|
+
if (typeof conversationId !== "string") {
|
|
4039
|
+
throw new Error("conversation id must be a string");
|
|
4040
|
+
}
|
|
4041
|
+
if (typeof createdAt !== "string") {
|
|
4042
|
+
throw new Error("conversation timestamp must be a string");
|
|
4043
|
+
}
|
|
4044
|
+
if (options.title !== undefined && typeof options.title !== "string") {
|
|
4045
|
+
throw new Error("conversation title must be a string");
|
|
4046
|
+
}
|
|
4047
|
+
if (options.status !== undefined && !CONVERSATION_STATUSES.has(options.status)) {
|
|
4048
|
+
throw new Error("conversation status must be active, archived, or deleted");
|
|
4049
|
+
}
|
|
4050
|
+
return {
|
|
4051
|
+
schemaVersion: 4,
|
|
4052
|
+
id: conversationId,
|
|
4053
|
+
...options.title !== undefined ? { title: options.title } : {},
|
|
4054
|
+
status: options.status ?? "active",
|
|
4055
|
+
metadata: cloneMetadata(options.metadata),
|
|
4056
|
+
ids: [],
|
|
4057
|
+
messages: {},
|
|
4058
|
+
createdAt,
|
|
4059
|
+
updatedAt: createdAt
|
|
4060
|
+
};
|
|
4061
|
+
}
|
|
4062
|
+
function materializeMessage(input, position, createdAt, id) {
|
|
4063
|
+
return {
|
|
4064
|
+
id,
|
|
4065
|
+
role: input.role,
|
|
4066
|
+
content: normalizeContent(input.content),
|
|
4067
|
+
position,
|
|
4068
|
+
createdAt,
|
|
4069
|
+
metadata: cloneMetadata(input.metadata),
|
|
4070
|
+
hidden: input.hidden ?? false,
|
|
4071
|
+
...input.toolCall !== undefined ? { toolCall: cloneToolCall(input.toolCall) } : {},
|
|
4072
|
+
...input.toolResult !== undefined ? { toolResult: cloneToolResult(input.toolResult) } : {},
|
|
4073
|
+
...input.tokenUsage !== undefined ? { tokenUsage: cloneTokenUsage(input.tokenUsage) } : {},
|
|
4074
|
+
...input.role === "assistant" && input.goalCompleted !== undefined ? { goalCompleted: input.goalCompleted } : {}
|
|
4075
|
+
};
|
|
4076
|
+
}
|
|
4077
|
+
function partitionAppendArguments(args) {
|
|
4078
|
+
const filteredArguments = args.at(-1) === undefined ? args.slice(0, -1) : args;
|
|
4079
|
+
if (filteredArguments.some((argument) => argument === undefined)) {
|
|
4080
|
+
throw new Error("appendMessages expected MessageInput arguments before the optional environment");
|
|
4081
|
+
}
|
|
4082
|
+
const lastArgument = filteredArguments.at(-1);
|
|
4083
|
+
const inputArguments = isConversationEnvironmentParameter(lastArgument) ? filteredArguments.slice(0, -1) : filteredArguments;
|
|
4084
|
+
const inputs = [];
|
|
4085
|
+
for (const argument of inputArguments) {
|
|
4086
|
+
if (!isLooseMessageInput(argument)) {
|
|
4087
|
+
throw new Error("appendMessages expected MessageInput arguments before the optional environment");
|
|
4088
|
+
}
|
|
4089
|
+
inputs.push(argument);
|
|
4090
|
+
}
|
|
4091
|
+
if (isConversationEnvironmentParameter(lastArgument)) {
|
|
4092
|
+
return { inputs, environment: lastArgument };
|
|
4093
|
+
}
|
|
4094
|
+
return { inputs };
|
|
4095
|
+
}
|
|
4096
|
+
function appendMessages(conversation, ...args) {
|
|
4097
|
+
const { inputs, environment } = partitionAppendArguments(args);
|
|
3877
4098
|
if (inputs.length === 0)
|
|
3878
4099
|
return conversation;
|
|
3879
|
-
|
|
4100
|
+
const resolvedEnvironment = resolveEnvironment(environment);
|
|
4101
|
+
const updatedAt = resolvedEnvironment.now();
|
|
4102
|
+
if (typeof updatedAt !== "string") {
|
|
4103
|
+
throw new Error("conversation timestamp must be a string");
|
|
4104
|
+
}
|
|
4105
|
+
const nextIds = [...conversation.ids];
|
|
4106
|
+
const nextMessages = { ...conversation.messages };
|
|
4107
|
+
const toolCallIds = buildToolCallIds(getOrderedMessages(conversation));
|
|
4108
|
+
inputs.forEach((input, index) => {
|
|
4109
|
+
const normalizedInput = { ...input, content: normalizeContent(input.content) };
|
|
4110
|
+
const processedInput = resolvedEnvironment.plugins.reduce((current, plugin) => plugin(current), normalizedInput);
|
|
4111
|
+
if (!isLooseMessageInput(processedInput)) {
|
|
4112
|
+
throw new Error("conversation plugin returned an invalid MessageInput");
|
|
4113
|
+
}
|
|
4114
|
+
assertValidToolMessage(processedInput, toolCallIds);
|
|
4115
|
+
const messageId = resolvedEnvironment.randomId();
|
|
4116
|
+
if (typeof messageId !== "string") {
|
|
4117
|
+
throw new Error("generated message id must be a string");
|
|
4118
|
+
}
|
|
4119
|
+
if (nextMessages[messageId] !== undefined || nextIds.includes(messageId)) {
|
|
4120
|
+
throw new Error(`duplicate message id in conversation: ${messageId}`);
|
|
4121
|
+
}
|
|
4122
|
+
const message = materializeMessage(processedInput, conversation.ids.length + index, updatedAt, messageId);
|
|
4123
|
+
nextIds.push(message.id);
|
|
4124
|
+
nextMessages[message.id] = message;
|
|
4125
|
+
});
|
|
4126
|
+
return {
|
|
4127
|
+
...conversation,
|
|
4128
|
+
ids: nextIds,
|
|
4129
|
+
messages: nextMessages,
|
|
4130
|
+
updatedAt
|
|
4131
|
+
};
|
|
4132
|
+
}
|
|
4133
|
+
function appendUserMessage(conversation, content, metadataOrEnvironment, environment) {
|
|
4134
|
+
const metadata = resolveRoleHelperMetadata(metadataOrEnvironment, environment);
|
|
4135
|
+
const resolvedEnvironment = environment ?? (isRoleHelperEnvironmentParameter(metadataOrEnvironment) ? metadataOrEnvironment : undefined);
|
|
4136
|
+
return appendMessages(conversation, { role: "user", content, metadata }, resolvedEnvironment);
|
|
4137
|
+
}
|
|
4138
|
+
function appendAssistantMessage(conversation, content, metadataOrEnvironment, environment) {
|
|
4139
|
+
const metadata = resolveRoleHelperMetadata(metadataOrEnvironment, environment);
|
|
4140
|
+
const resolvedEnvironment = environment ?? (isRoleHelperEnvironmentParameter(metadataOrEnvironment) ? metadataOrEnvironment : undefined);
|
|
4141
|
+
return appendMessages(conversation, { role: "assistant", content, metadata }, resolvedEnvironment);
|
|
4142
|
+
}
|
|
4143
|
+
function resolveRoleHelperMetadata(metadataOrEnvironment, environment) {
|
|
4144
|
+
if (metadataOrEnvironment === undefined)
|
|
4145
|
+
return;
|
|
4146
|
+
if (environment === undefined && isRoleHelperEnvironmentParameter(metadataOrEnvironment)) {
|
|
4147
|
+
return;
|
|
4148
|
+
}
|
|
4149
|
+
if (isMetadataRecord(metadataOrEnvironment))
|
|
4150
|
+
return metadataOrEnvironment;
|
|
4151
|
+
throw new Error("metadata must be a JSON-compatible object");
|
|
3880
4152
|
}
|
|
3881
|
-
var appendUserMessage = appendConversationalistUserMessage;
|
|
3882
|
-
var appendAssistantMessage = appendConversationalistAssistantMessage;
|
|
3883
4153
|
// src/components/chat/artifact/artifact-panel.svelte
|
|
3884
4154
|
import * as $37 from "svelte/internal/server";
|
|
3885
4155
|
function Artifact_panel($$renderer, $$props) {
|
|
@@ -3957,4 +4227,4 @@ function Chat_artifact_layout($$renderer, $$props) {
|
|
|
3957
4227
|
var chat_default = Chat2;
|
|
3958
4228
|
export { Chat_date_separator, Message_content, Tool_call_group, Message_attachments, Chat_message, deriveAttachmentKind, Chat_attachment_preview, serializeChatAttachment, serializeChatAttachments, Chat_input, DEFAULT_SCROLL_CONFIGURATION, isAtBottom, shouldShowJumpToLatest, calculateUnreadCount, findUnreadBoundaryIndex, calculateScrollToBottom, extractTimestamp, Chat2 as Chat, createConversation, appendMessages, appendUserMessage, appendAssistantMessage, Artifact_panel, Artifact_viewer, Chat_artifact_layout, chat_default };
|
|
3959
4229
|
|
|
3960
|
-
//# debugId=
|
|
4230
|
+
//# debugId=9292A60BC4AACCA764756E2164756E21
|
|
@@ -237,14 +237,27 @@ function messagesToMarkdown(messages) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// src/components/chat/utilities/conversation.ts
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
function hasPairableToolField(message) {
|
|
243
|
-
return message.role === "tool-call" && message.toolCall !== undefined || message.role === "tool-result" && message.toolResult !== undefined;
|
|
240
|
+
function getMessages(conversation, options = {}) {
|
|
241
|
+
return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined).filter((message) => options.includeHidden === true || !message.hidden);
|
|
244
242
|
}
|
|
245
243
|
function pairToolCallsWithResults(messages) {
|
|
246
|
-
|
|
244
|
+
const resultsByCallId = new Map;
|
|
245
|
+
for (const message of messages) {
|
|
246
|
+
if (message.role === "tool-result" && message.toolResult !== undefined) {
|
|
247
|
+
resultsByCallId.set(message.toolResult.callId, message.toolResult);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const pairs = [];
|
|
251
|
+
for (const message of messages) {
|
|
252
|
+
if (message.role === "tool-call" && message.toolCall !== undefined) {
|
|
253
|
+
pairs.push({
|
|
254
|
+
call: message.toolCall,
|
|
255
|
+
result: resultsByCallId.get(message.toolCall.id)
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return pairs;
|
|
247
260
|
}
|
|
248
261
|
export { getMessages, pairToolCallsWithResults, resolveMessageReasoning, resolveMessageSteps, resolveMessageSuggestions, getMessageText, deriveMessageParts, getMessageRoleLabel, formatMessageAsMarkdown, messagesToMarkdown };
|
|
249
262
|
|
|
250
|
-
//# debugId=
|
|
263
|
+
//# debugId=2F56845F38FA430464756E2164756E21
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Loader,
|
|
3
|
+
Refresh_ccw_dot,
|
|
4
|
+
Triangle_alert,
|
|
5
|
+
Wifi,
|
|
6
|
+
Wifi_off
|
|
7
|
+
} from "./index.server-cch0eed5.js";
|
|
8
|
+
import {
|
|
9
|
+
Refresh_cw
|
|
10
|
+
} from "./index.server-1nm6seqc.js";
|
|
11
|
+
import {
|
|
12
|
+
classNames
|
|
13
|
+
} from "./index.server-z7nvkz8v.js";
|
|
14
|
+
|
|
15
|
+
// src/components/connection-indicator/connection-indicator.svelte
|
|
16
|
+
import * as $ from "svelte/internal/server";
|
|
17
|
+
function Connection_indicator($$renderer, $$props) {
|
|
18
|
+
$$renderer.component(($$renderer2) => {
|
|
19
|
+
const statusLabels = {
|
|
20
|
+
connecting: "Connecting",
|
|
21
|
+
live: "Live",
|
|
22
|
+
reconnecting: "Reconnecting",
|
|
23
|
+
polling: "Polling",
|
|
24
|
+
stale: "Stale",
|
|
25
|
+
closed: "Closed"
|
|
26
|
+
};
|
|
27
|
+
const statusIcons = {
|
|
28
|
+
connecting: Loader,
|
|
29
|
+
live: Wifi,
|
|
30
|
+
reconnecting: Refresh_cw,
|
|
31
|
+
polling: Refresh_ccw_dot,
|
|
32
|
+
stale: Triangle_alert,
|
|
33
|
+
closed: Wifi_off
|
|
34
|
+
};
|
|
35
|
+
let {
|
|
36
|
+
status,
|
|
37
|
+
label,
|
|
38
|
+
attempt,
|
|
39
|
+
class: className,
|
|
40
|
+
"aria-label": ariaLabel,
|
|
41
|
+
"aria-labelledby": ariaLabelledby,
|
|
42
|
+
$$slots,
|
|
43
|
+
$$events,
|
|
44
|
+
...rest
|
|
45
|
+
} = $$props;
|
|
46
|
+
const normalizedAriaLabel = $.derived(() => ariaLabel?.trim() ? ariaLabel.trim() : undefined);
|
|
47
|
+
const normalizedAriaLabelledby = $.derived(() => ariaLabelledby?.trim() ? ariaLabelledby.trim() : undefined);
|
|
48
|
+
const resolvedLabel = $.derived(() => label?.trim() ? label.trim() : statusLabels[status]);
|
|
49
|
+
const resolvedAriaLabel = $.derived(() => normalizedAriaLabelledby() !== undefined ? undefined : normalizedAriaLabel() ?? `Connection: ${resolvedLabel()}`);
|
|
50
|
+
const Icon = $.derived(() => statusIcons[status]);
|
|
51
|
+
$$renderer2.push(`<div${$.attributes({
|
|
52
|
+
...rest,
|
|
53
|
+
class: $.clsx(classNames("cinder-connection-indicator", className)),
|
|
54
|
+
"data-cinder-status": status,
|
|
55
|
+
role: "status",
|
|
56
|
+
"aria-live": "polite",
|
|
57
|
+
"aria-atomic": "true",
|
|
58
|
+
"aria-label": resolvedAriaLabel(),
|
|
59
|
+
"aria-labelledby": normalizedAriaLabelledby()
|
|
60
|
+
})}>`);
|
|
61
|
+
if (status === "live") {
|
|
62
|
+
$$renderer2.push("<!--[0-->");
|
|
63
|
+
$$renderer2.push(`<span class="cinder-connection-indicator__dot" aria-hidden="true"></span>`);
|
|
64
|
+
} else {
|
|
65
|
+
$$renderer2.push("<!--[-1-->");
|
|
66
|
+
}
|
|
67
|
+
$$renderer2.push(`<!--]--> <span class="cinder-connection-indicator__icon" aria-hidden="true">`);
|
|
68
|
+
if (Icon()) {
|
|
69
|
+
$$renderer2.push("<!--[-->");
|
|
70
|
+
Icon()($$renderer2, { size: 13, strokeWidth: 2.25 });
|
|
71
|
+
$$renderer2.push("<!--]-->");
|
|
72
|
+
} else {
|
|
73
|
+
$$renderer2.push("<!--[!-->");
|
|
74
|
+
$$renderer2.push("<!--]-->");
|
|
75
|
+
}
|
|
76
|
+
$$renderer2.push(`</span> <span class="cinder-connection-indicator__label">${$.escape(resolvedLabel())}</span> `);
|
|
77
|
+
if (status === "reconnecting" && attempt) {
|
|
78
|
+
$$renderer2.push("<!--[0-->");
|
|
79
|
+
$$renderer2.push(`<span class="cinder-connection-indicator__attempt">`);
|
|
80
|
+
attempt($$renderer2);
|
|
81
|
+
$$renderer2.push(`<!----></span>`);
|
|
82
|
+
} else {
|
|
83
|
+
$$renderer2.push("<!--[-1-->");
|
|
84
|
+
}
|
|
85
|
+
$$renderer2.push(`<!--]--></div>`);
|
|
86
|
+
}, Connection_indicator);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/components/connection-indicator/index.ts
|
|
90
|
+
var connection_indicator_default = Connection_indicator;
|
|
91
|
+
export { Connection_indicator, connection_indicator_default };
|
|
92
|
+
|
|
93
|
+
//# debugId=6E6598FD152C292F64756E2164756E21
|
|
@@ -223,8 +223,6 @@ function Time_field($$renderer, $$props) {
|
|
|
223
223
|
}, Time_field);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
var time_field_default = Time_field;
|
|
228
|
-
export { Time_field, time_field_default };
|
|
226
|
+
export { Time_field };
|
|
229
227
|
|
|
230
|
-
//# debugId=
|
|
228
|
+
//# debugId=D1DD292633A8F77C64756E2164756E21
|