@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.
Files changed (138) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/components.json +82 -4
  3. package/dist/components/access-gate/index.js +381 -239
  4. package/dist/components/chat/builders.d.ts +17 -8
  5. package/dist/components/chat/conversation-model.d.ts +1 -1
  6. package/dist/components/chat/index.d.ts +1 -1
  7. package/dist/components/chat/index.js +300 -17
  8. package/dist/components/chat/utilities/conversation.d.ts +6 -6
  9. package/dist/components/chat-conversation-header/index.js +19 -6
  10. package/dist/components/chat-conversation-list/index.js +19 -6
  11. package/dist/components/connection-indicator/connection-indicator.css +136 -0
  12. package/dist/components/connection-indicator/connection-indicator.css.d.ts +1 -0
  13. package/dist/components/connection-indicator/connection-indicator.schema.d.ts +3 -0
  14. package/dist/components/connection-indicator/connection-indicator.schema.js +89 -0
  15. package/dist/components/connection-indicator/connection-indicator.svelte.d.ts +21 -0
  16. package/dist/components/connection-indicator/connection-indicator.types.d.ts +46 -0
  17. package/dist/components/connection-indicator/connection-indicator.variables.d.ts +2 -0
  18. package/dist/components/connection-indicator/connection-indicator.variables.js +61 -0
  19. package/dist/components/connection-indicator/index.d.ts +5 -0
  20. package/dist/components/connection-indicator/index.js +409 -0
  21. package/dist/components/container/container.schema.js +4 -4
  22. package/dist/components/invocation-rule-builder/index.d.ts +1 -1
  23. package/dist/components/invocation-rule-builder/index.js +305 -150
  24. package/dist/components/invocation-rule-builder/invocation-rule-builder.css +28 -0
  25. package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.js +89 -5
  26. package/dist/components/invocation-rule-builder/invocation-rule-builder.svelte.d.ts +2 -1
  27. package/dist/components/invocation-rule-builder/invocation-rule-builder.types.d.ts +114 -16
  28. package/dist/components/run-step-timeline/index.d.ts +1 -1
  29. package/dist/components/run-step-timeline/index.js +992 -559
  30. package/dist/components/run-step-timeline/run-step-branch-disclosure.svelte.d.ts +17 -0
  31. package/dist/components/run-step-timeline/run-step-timeline.css +124 -0
  32. package/dist/components/run-step-timeline/run-step-timeline.schema.js +873 -350
  33. package/dist/components/run-step-timeline/run-step-timeline.svelte.d.ts +1 -15
  34. package/dist/components/run-step-timeline/run-step-timeline.types.d.ts +182 -5
  35. package/dist/components/run-step-timeline/run-step-timeline.utilities.d.ts +52 -0
  36. package/dist/components/schedule-builder/index.d.ts +5 -0
  37. package/dist/components/schedule-builder/index.js +3176 -0
  38. package/dist/components/schedule-builder/schedule-builder.css +121 -0
  39. package/dist/components/schedule-builder/schedule-builder.css.d.ts +1 -0
  40. package/dist/components/schedule-builder/schedule-builder.schema.d.ts +3 -0
  41. package/dist/components/schedule-builder/schedule-builder.schema.js +141 -0
  42. package/dist/components/schedule-builder/schedule-builder.svelte.d.ts +22 -0
  43. package/dist/components/schedule-builder/schedule-builder.types.d.ts +130 -0
  44. package/dist/components/schedule-builder/schedule-builder.utilities.d.ts +78 -0
  45. package/dist/components/schedule-builder/schedule-builder.variables.d.ts +2 -0
  46. package/dist/components/schedule-builder/schedule-builder.variables.js +61 -0
  47. package/dist/components/tag-input/index.js +22 -4
  48. package/dist/components/tag-input/tag-input.schema.js +5 -1
  49. package/dist/components/tag-input/tag-input.types.d.ts +4 -0
  50. package/dist/index.d.ts +6 -2
  51. package/dist/index.js +22704 -20574
  52. package/dist/server/components/access-gate/index.js +2 -1
  53. package/dist/server/components/chat/index.js +4 -4
  54. package/dist/server/components/chat-conversation-header/index.js +5 -5
  55. package/dist/server/components/chat-conversation-list/index.js +3 -3
  56. package/dist/server/components/connection-indicator/index.js +16 -0
  57. package/dist/server/components/data-table/index.js +3 -3
  58. package/dist/server/components/diff-viewer/index.js +4 -3
  59. package/dist/server/components/invocation-rule-builder/index.js +1 -1
  60. package/dist/server/components/json-schema-editor/index.js +4 -3
  61. package/dist/server/components/review-editor/index.js +4 -3
  62. package/dist/server/components/run-step-timeline/index.js +1 -1
  63. package/dist/server/components/schedule-builder/index.js +30 -0
  64. package/dist/server/components/side-navigation/index.js +2 -2
  65. package/dist/server/components/table/index.js +3 -3
  66. package/dist/server/components/tag-input/index.js +1 -1
  67. package/dist/server/components/time-field/index.js +5 -3
  68. package/dist/server/index.js +100 -87
  69. package/dist/server/index.server-0sx92swg.js +9 -0
  70. package/dist/server/{index.server-mzzb7dnm.js → index.server-2bbwajb2.js} +1 -1
  71. package/dist/server/{index.server-q7w4jw89.js → index.server-2s5h1d05.js} +2 -2
  72. package/dist/server/{index.server-dg83ke3k.js → index.server-2zdbz3rj.js} +1 -1
  73. package/dist/server/{index.server-0jhra85x.js → index.server-3w72dxz7.js} +4 -4
  74. package/dist/server/{index.server-qh9qzd5t.js → index.server-4x4hgvqe.js} +283 -13
  75. package/dist/server/{index.server-c6pe4kaf.js → index.server-5gzyqv78.js} +1 -1
  76. package/dist/server/{index.server-mqt1ngqw.js → index.server-6hnfzc7f.js} +19 -6
  77. package/dist/server/index.server-be9bpqeh.js +93 -0
  78. package/dist/server/{index.server-f3z7tpxr.js → index.server-c42b462p.js} +2 -4
  79. package/dist/server/{index.server-7vyzen5x.js → index.server-c5qv3p61.js} +171 -63
  80. package/dist/server/index.server-cch0eed5.js +144 -0
  81. package/dist/server/index.server-gmh5ar16.js +2 -0
  82. package/dist/server/{index.server-0atyznp7.js → index.server-h89zk5ev.js} +7 -7
  83. package/dist/server/{index.server-jxg42jpz.js → index.server-jdcq5zza.js} +7 -7
  84. package/dist/server/{index.server-2dga5yzr.js → index.server-jfrssta6.js} +1 -1
  85. package/dist/server/{index.server-fy068yne.js → index.server-jj76374p.js} +1 -1
  86. package/dist/server/index.server-qbkxz7r2.js +750 -0
  87. package/dist/server/{index.server-marjz8ps.js → index.server-tcay903b.js} +3 -2
  88. package/dist/server/index.server-z38bxms8.js +734 -0
  89. package/dist/server/{index.server-yz4k36cw.js → index.server-z7hxtqs1.js} +1 -1
  90. package/package.json +66 -3
  91. package/src/components/chat/builders.ts +445 -14
  92. package/src/components/chat/conversation-model.ts +1 -0
  93. package/src/components/chat/index.ts +1 -0
  94. package/src/components/chat/utilities/conversation.ts +33 -15
  95. package/src/components/connection-indicator/connection-indicator.css +136 -0
  96. package/src/components/connection-indicator/connection-indicator.examples.json +31 -0
  97. package/src/components/connection-indicator/connection-indicator.schema.json +29 -0
  98. package/src/components/connection-indicator/connection-indicator.schema.ts +36 -0
  99. package/src/components/connection-indicator/connection-indicator.svelte +63 -0
  100. package/src/components/connection-indicator/connection-indicator.types.ts +58 -0
  101. package/src/components/connection-indicator/connection-indicator.variables.json +1 -0
  102. package/src/components/connection-indicator/connection-indicator.variables.ts +3 -0
  103. package/src/components/connection-indicator/index.ts +10 -0
  104. package/src/components/container/container.schema.json +3 -3
  105. package/src/components/container/container.schema.ts +3 -3
  106. package/src/components/invocation-rule-builder/index.ts +4 -0
  107. package/src/components/invocation-rule-builder/invocation-rule-builder.css +28 -0
  108. package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +6 -0
  109. package/src/components/invocation-rule-builder/invocation-rule-builder.schema.json +76 -3
  110. package/src/components/invocation-rule-builder/invocation-rule-builder.schema.ts +83 -3
  111. package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +326 -113
  112. package/src/components/invocation-rule-builder/invocation-rule-builder.types.ts +157 -43
  113. package/src/components/run-step-timeline/index.ts +8 -0
  114. package/src/components/run-step-timeline/run-step-branch-disclosure.svelte +16 -0
  115. package/src/components/run-step-timeline/run-step-timeline.css +124 -0
  116. package/src/components/run-step-timeline/run-step-timeline.examples.json +18 -0
  117. package/src/components/run-step-timeline/run-step-timeline.schema.json +872 -349
  118. package/src/components/run-step-timeline/run-step-timeline.schema.ts +931 -349
  119. package/src/components/run-step-timeline/run-step-timeline.svelte +387 -268
  120. package/src/components/run-step-timeline/run-step-timeline.types.ts +192 -5
  121. package/src/components/run-step-timeline/run-step-timeline.utilities.ts +242 -0
  122. package/src/components/schedule-builder/index.ts +14 -0
  123. package/src/components/schedule-builder/schedule-builder.css +121 -0
  124. package/src/components/schedule-builder/schedule-builder.examples.json +31 -0
  125. package/src/components/schedule-builder/schedule-builder.schema.json +78 -0
  126. package/src/components/schedule-builder/schedule-builder.schema.ts +86 -0
  127. package/src/components/schedule-builder/schedule-builder.svelte +629 -0
  128. package/src/components/schedule-builder/schedule-builder.types.ts +137 -0
  129. package/src/components/schedule-builder/schedule-builder.utilities.ts +344 -0
  130. package/src/components/schedule-builder/schedule-builder.variables.json +1 -0
  131. package/src/components/schedule-builder/schedule-builder.variables.ts +3 -0
  132. package/src/components/tag-input/tag-input.schema.json +4 -0
  133. package/src/components/tag-input/tag-input.schema.ts +4 -0
  134. package/src/components/tag-input/tag-input.svelte +20 -3
  135. package/src/components/tag-input/tag-input.types.ts +4 -0
  136. package/src/index.ts +23 -0
  137. package/src/styles/components.css +2 -0
  138. package/dist/server/index.server-qk1h0n02.js +0 -393
@@ -1,16 +1,25 @@
1
1
  /**
2
2
  * Conversation builders for the Chat component.
3
3
  *
4
- * Chat renders a {@link ConversationHistory} snapshot. These are thin aliases
5
- * over the published `conversationalist` builders so examples, demos, tests, and
6
- * simple apps construct the same transcript shape Chat consumes.
4
+ * Chat renders a {@link ConversationHistory} snapshot. These helpers construct
5
+ * the published Conversationalist shape without importing the package runtime
6
+ * into Cinder's browser graph.
7
7
  */
8
- import { appendAssistantMessage as appendConversationalistAssistantMessage, appendUserMessage as appendConversationalistUserMessage, createConversationHistory } from 'conversationalist';
9
- import type { ConversationHistory, MessageInput } from './conversation-model.ts';
8
+ import type { ConversationEnvironment, ConversationHistory, ConversationStatus, JSONValue, MessageInput } from './conversation-model.ts';
9
+ type CreateConversationOptions = {
10
+ id?: string;
11
+ title?: string;
12
+ status?: ConversationStatus;
13
+ metadata?: Record<string, JSONValue>;
14
+ };
15
+ type ConversationEnvironmentInput = Partial<ConversationEnvironment>;
10
16
  /** Creates a new empty conversation snapshot. */
11
- declare const createConversation: typeof createConversationHistory;
17
+ declare function createConversation(options?: CreateConversationOptions, environment?: ConversationEnvironmentInput): ConversationHistory;
12
18
  /** Appends one or more messages, preserving the previous no-op identity contract. */
13
19
  declare function appendMessages(conversation: ConversationHistory, ...inputs: MessageInput[]): ConversationHistory;
14
- declare const appendUserMessage: typeof appendConversationalistUserMessage;
15
- declare const appendAssistantMessage: typeof appendConversationalistAssistantMessage;
20
+ declare function appendMessages(conversation: ConversationHistory, ...inputsAndEnvironment: [...MessageInput[], ConversationEnvironmentInput | undefined]): ConversationHistory;
21
+ declare function appendUserMessage(conversation: ConversationHistory, content: MessageInput['content'], metadata?: Record<string, JSONValue>, environment?: ConversationEnvironmentInput): ConversationHistory;
22
+ declare function appendUserMessage(conversation: ConversationHistory, content: MessageInput['content'], environment?: ConversationEnvironmentInput): ConversationHistory;
23
+ declare function appendAssistantMessage(conversation: ConversationHistory, content: MessageInput['content'], metadata?: Record<string, JSONValue>, environment?: ConversationEnvironmentInput): ConversationHistory;
24
+ declare function appendAssistantMessage(conversation: ConversationHistory, content: MessageInput['content'], environment?: ConversationEnvironmentInput): ConversationHistory;
16
25
  export { appendAssistantMessage, appendMessages, appendUserMessage, createConversation };
@@ -8,7 +8,7 @@
8
8
  * @module
9
9
  */
10
10
  import type { ToMarkdownOptions as ConversationalistToMarkdownOptions } from 'conversationalist/markdown';
11
- export type { AssistantMessage, ContainerUploadContent, ConversationHistory, ConversationStatus, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, TokenUsage, ToolAction, ToolCall, ToolError, ToolErrorCategory, ToolResult, WebSearchToolResultContent, } from 'conversationalist';
11
+ export type { AssistantMessage, ContainerUploadContent, ConversationEnvironment, ConversationHistory, ConversationStatus, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, TokenUsage, ToolAction, ToolCall, ToolError, ToolErrorCategory, ToolResult, WebSearchToolResultContent, } from 'conversationalist';
12
12
  export type { ToolCallPair } from 'conversationalist/utilities';
13
13
  /** Base options shared by all transcript export operations. */
14
14
  export type ExportOptions = Omit<ConversationalistToMarkdownOptions, 'includeMetadata'>;
@@ -12,7 +12,7 @@ export type { ChatAnnounceLevel, ChatCapabilities, ChatProps, ReadReceipt, Typin
12
12
  export { Chat };
13
13
  export type { ChatAdapter, ChatAdapterErrorEvent, ChatCommand, ChatPushHandlers, ChatReadReceiptEvent, } from './adapter';
14
14
  export { appendAssistantMessage, appendMessages, appendUserMessage, createConversation, } from './builders.ts';
15
- export type { AssistantMessage, ContainerUploadContent, ConversationHistory, ConversationStatus, ExportOptions, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, ToMarkdownOptions, TokenUsage, ToolAction, ToolCall, ToolCallPair, ToolError, ToolErrorCategory, ToolResult, WebSearchToolResultContent, } from './conversation-model.ts';
15
+ export type { AssistantMessage, ContainerUploadContent, ConversationEnvironment, ConversationHistory, ConversationStatus, ExportOptions, ImageContent, JSONValue, Message, MessageInput, MessageRole, MultiModalContent, RedactedThinkingContent, ServerToolResultContent, ServerToolResultType, ServerToolUseContent, TextContent, ThinkingContent, ToMarkdownOptions, TokenUsage, ToolAction, ToolCall, ToolCallPair, ToolError, ToolErrorCategory, ToolResult, WebSearchToolResultContent, } from './conversation-model.ts';
16
16
  export { formatMessageAsMarkdown, getMessageRoleLabel, getMessageText, messagesToMarkdown, type ChatExportOptions, type DeliveryStatus, } from './utilities';
17
17
  export { ChatAttachmentPreview, ChatInput, deriveAttachmentKind, serializeChatAttachment, serializeChatAttachments, } from './input';
18
18
  export type { AttachmentKind, ChatAttachment, SerializedChatAttachment } from './input';
@@ -2489,13 +2489,26 @@ import * as $65 from "svelte/internal/client";
2489
2489
  import { tick as tick2, untrack as untrack3 } from "svelte";
2490
2490
 
2491
2491
  // src/components/chat/utilities/conversation.ts
2492
- import { getMessages } from "conversationalist";
2493
- import { pairToolCallsWithResults as pairConversationalistToolCallsWithResults } from "conversationalist/utilities";
2494
- function hasPairableToolField(message) {
2495
- return message.role === "tool-call" && message.toolCall !== undefined || message.role === "tool-result" && message.toolResult !== undefined;
2492
+ function getMessages(conversation, options = {}) {
2493
+ return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined).filter((message) => options.includeHidden === true || !message.hidden);
2496
2494
  }
2497
2495
  function pairToolCallsWithResults(messages) {
2498
- return pairConversationalistToolCallsWithResults(messages.filter(hasPairableToolField));
2496
+ const resultsByCallId = new Map;
2497
+ for (const message of messages) {
2498
+ if (message.role === "tool-result" && message.toolResult !== undefined) {
2499
+ resultsByCallId.set(message.toolResult.callId, message.toolResult);
2500
+ }
2501
+ }
2502
+ const pairs = [];
2503
+ for (const message of messages) {
2504
+ if (message.role === "tool-call" && message.toolCall !== undefined) {
2505
+ pairs.push({
2506
+ call: message.toolCall,
2507
+ result: resultsByCallId.get(message.toolCall.id)
2508
+ });
2509
+ }
2510
+ }
2511
+ return pairs;
2499
2512
  }
2500
2513
  // src/components/chat/utilities/utilities.ts
2501
2514
  var CINDER_REASONING_METADATA_KEY = "cinder:reasoning";
@@ -9521,20 +9534,290 @@ function Chat2($$anchor, $$props) {
9521
9534
  }
9522
9535
 
9523
9536
  // src/components/chat/builders.ts
9524
- import {
9525
- appendAssistantMessage as appendConversationalistAssistantMessage,
9526
- appendMessages as appendConversationalistMessages,
9527
- appendUserMessage as appendConversationalistUserMessage,
9528
- createConversationHistory
9529
- } from "conversationalist";
9530
- var createConversation = createConversationHistory;
9531
- function appendMessages(conversation, ...inputs) {
9537
+ var MESSAGE_ROLES = new Set([
9538
+ "user",
9539
+ "assistant",
9540
+ "system",
9541
+ "developer",
9542
+ "tool-call",
9543
+ "tool-result",
9544
+ "snapshot"
9545
+ ]);
9546
+ var CONVERSATION_STATUSES = new Set(["active", "archived", "deleted"]);
9547
+ function createId() {
9548
+ return globalThis.crypto?.randomUUID?.() ?? `message-${Date.now()}-${Math.random()}`;
9549
+ }
9550
+ function isRecord(value) {
9551
+ return typeof value === "object" && value !== null;
9552
+ }
9553
+ function isJsonObject(value) {
9554
+ if (!isRecord(value) || Array.isArray(value))
9555
+ return false;
9556
+ const prototype = Object.getPrototypeOf(value);
9557
+ return prototype === Object.prototype || prototype === null;
9558
+ }
9559
+ function isJsonValue(value) {
9560
+ if (value === null)
9561
+ return true;
9562
+ switch (typeof value) {
9563
+ case "string":
9564
+ case "boolean":
9565
+ return true;
9566
+ case "number":
9567
+ return Number.isFinite(value);
9568
+ case "object":
9569
+ if (Array.isArray(value))
9570
+ return value.every(isJsonValue);
9571
+ return isJsonObject(value) && Object.values(value).every(isJsonValue);
9572
+ default:
9573
+ return false;
9574
+ }
9575
+ }
9576
+ function assertJsonObject(value, label) {
9577
+ if (!isJsonObject(value) || !Object.values(value).every(isJsonValue)) {
9578
+ throw new Error(`${label} must be a JSON-compatible object`);
9579
+ }
9580
+ }
9581
+ function isConversationEnvironmentParameter(value) {
9582
+ if (!isRecord(value) || "role" in value)
9583
+ return false;
9584
+ return typeof value["now"] === "function" || typeof value["randomId"] === "function" || typeof value["estimateTokens"] === "function" || Array.isArray(value["plugins"]) && value["plugins"].every((plugin) => typeof plugin === "function");
9585
+ }
9586
+ function isRoleHelperEnvironmentParameter(value) {
9587
+ if (!isRecord(value) || "role" in value)
9588
+ return false;
9589
+ 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");
9590
+ }
9591
+ function isMultiModalContentPart(value) {
9592
+ if (!isJsonObject(value) || typeof value["type"] !== "string")
9593
+ return false;
9594
+ if (!Object.values(value).every(isJsonValue))
9595
+ return false;
9596
+ switch (value["type"]) {
9597
+ case "text":
9598
+ return typeof value["text"] === "string";
9599
+ case "image":
9600
+ return typeof value["url"] === "string";
9601
+ case "thinking":
9602
+ return typeof value["thinking"] === "string";
9603
+ case "redacted_thinking":
9604
+ return typeof value["data"] === "string";
9605
+ case "server_tool_use":
9606
+ return typeof value["id"] === "string" && typeof value["name"] === "string";
9607
+ case "web_search_tool_result":
9608
+ return typeof value["tool_use_id"] === "string" && "content" in value;
9609
+ case "container_upload":
9610
+ return typeof value["file_id"] === "string";
9611
+ default:
9612
+ return false;
9613
+ }
9614
+ }
9615
+ function isMessageContentInput(value) {
9616
+ return typeof value === "string" || Array.isArray(value) && value.every(isMultiModalContentPart) || isMultiModalContentPart(value);
9617
+ }
9618
+ function isLooseMessageInput(value) {
9619
+ 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");
9620
+ }
9621
+ function isMetadataRecord(value) {
9622
+ return isJsonObject(value);
9623
+ }
9624
+ function resolveEnvironment(environment) {
9625
+ const plugins = environment?.plugins ?? [];
9626
+ if (!Array.isArray(plugins) || plugins.some((plugin) => typeof plugin !== "function")) {
9627
+ throw new Error("conversation environment plugins must be functions");
9628
+ }
9629
+ return {
9630
+ now: environment?.now ?? (() => new Date().toISOString()),
9631
+ randomId: environment?.randomId ?? createId,
9632
+ plugins: [...plugins]
9633
+ };
9634
+ }
9635
+ function cloneStructuredValue(value) {
9636
+ return structuredClone(value);
9637
+ }
9638
+ function cloneMetadata(metadata) {
9639
+ if (metadata === undefined)
9640
+ return {};
9641
+ assertJsonObject(metadata, "metadata");
9642
+ return cloneStructuredValue(metadata);
9643
+ }
9644
+ function normalizeContent(content) {
9645
+ if (typeof content === "string")
9646
+ return content;
9647
+ return Array.isArray(content) ? cloneStructuredValue(content) : [cloneStructuredValue(content)];
9648
+ }
9649
+ function cloneTokenUsage(tokenUsage) {
9650
+ assertJsonObject(tokenUsage, "tokenUsage");
9651
+ const values = Object.values(tokenUsage);
9652
+ if (values.some((value) => typeof value !== "number")) {
9653
+ throw new Error("tokenUsage values must be numbers");
9654
+ }
9655
+ if (values.some((value) => typeof value === "number" && (!Number.isInteger(value) || value < 0))) {
9656
+ throw new Error("tokenUsage values must be non-negative integers");
9657
+ }
9658
+ return cloneStructuredValue(tokenUsage);
9659
+ }
9660
+ function cloneToolCall(toolCall) {
9661
+ assertJsonObject(toolCall, "toolCall");
9662
+ if (typeof toolCall.id !== "string" || typeof toolCall.name !== "string" || !("arguments" in toolCall) || !isJsonValue(toolCall.arguments)) {
9663
+ throw new Error("toolCall must include string id, string name, and JSON arguments");
9664
+ }
9665
+ return cloneStructuredValue(toolCall);
9666
+ }
9667
+ function cloneToolResult(toolResult) {
9668
+ assertJsonObject(toolResult, "toolResult");
9669
+ if (typeof toolResult.callId !== "string" || !["success", "error", "action_required"].includes(String(toolResult.outcome)) || !("content" in toolResult) || !isJsonValue(toolResult.content)) {
9670
+ throw new Error("toolResult must include string callId, valid outcome, and JSON content");
9671
+ }
9672
+ return cloneStructuredValue(toolResult);
9673
+ }
9674
+ function getOrderedMessages(conversation) {
9675
+ return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined);
9676
+ }
9677
+ function buildToolCallIds(messages) {
9678
+ const toolCallIds = new Set;
9679
+ for (const message of messages) {
9680
+ if (message.role === "tool-call" && message.toolCall !== undefined) {
9681
+ if (toolCallIds.has(message.toolCall.id)) {
9682
+ throw new Error(`duplicate toolCall.id in conversation: ${message.toolCall.id}`);
9683
+ }
9684
+ toolCallIds.add(message.toolCall.id);
9685
+ }
9686
+ }
9687
+ return toolCallIds;
9688
+ }
9689
+ function assertValidToolMessage(input, toolCallIds) {
9690
+ if (input.role === "tool-result" && input.toolResult !== undefined) {
9691
+ if (!toolCallIds.has(input.toolResult.callId)) {
9692
+ throw new Error(`tool result references non-existent tool-call: ${input.toolResult.callId}`);
9693
+ }
9694
+ }
9695
+ if (input.role === "tool-call" && input.toolCall !== undefined) {
9696
+ if (toolCallIds.has(input.toolCall.id)) {
9697
+ throw new Error(`duplicate toolCall.id in conversation: ${input.toolCall.id}`);
9698
+ }
9699
+ toolCallIds.add(input.toolCall.id);
9700
+ }
9701
+ }
9702
+ function createConversation(options = {}, environment) {
9703
+ const resolvedEnvironment = resolveEnvironment(environment);
9704
+ const createdAt = resolvedEnvironment.now();
9705
+ const conversationId = options.id ?? resolvedEnvironment.randomId();
9706
+ if (typeof conversationId !== "string") {
9707
+ throw new Error("conversation id must be a string");
9708
+ }
9709
+ if (typeof createdAt !== "string") {
9710
+ throw new Error("conversation timestamp must be a string");
9711
+ }
9712
+ if (options.title !== undefined && typeof options.title !== "string") {
9713
+ throw new Error("conversation title must be a string");
9714
+ }
9715
+ if (options.status !== undefined && !CONVERSATION_STATUSES.has(options.status)) {
9716
+ throw new Error("conversation status must be active, archived, or deleted");
9717
+ }
9718
+ return {
9719
+ schemaVersion: 4,
9720
+ id: conversationId,
9721
+ ...options.title !== undefined ? { title: options.title } : {},
9722
+ status: options.status ?? "active",
9723
+ metadata: cloneMetadata(options.metadata),
9724
+ ids: [],
9725
+ messages: {},
9726
+ createdAt,
9727
+ updatedAt: createdAt
9728
+ };
9729
+ }
9730
+ function materializeMessage(input, position, createdAt, id) {
9731
+ return {
9732
+ id,
9733
+ role: input.role,
9734
+ content: normalizeContent(input.content),
9735
+ position,
9736
+ createdAt,
9737
+ metadata: cloneMetadata(input.metadata),
9738
+ hidden: input.hidden ?? false,
9739
+ ...input.toolCall !== undefined ? { toolCall: cloneToolCall(input.toolCall) } : {},
9740
+ ...input.toolResult !== undefined ? { toolResult: cloneToolResult(input.toolResult) } : {},
9741
+ ...input.tokenUsage !== undefined ? { tokenUsage: cloneTokenUsage(input.tokenUsage) } : {},
9742
+ ...input.role === "assistant" && input.goalCompleted !== undefined ? { goalCompleted: input.goalCompleted } : {}
9743
+ };
9744
+ }
9745
+ function partitionAppendArguments(args) {
9746
+ const filteredArguments = args.at(-1) === undefined ? args.slice(0, -1) : args;
9747
+ if (filteredArguments.some((argument) => argument === undefined)) {
9748
+ throw new Error("appendMessages expected MessageInput arguments before the optional environment");
9749
+ }
9750
+ const lastArgument = filteredArguments.at(-1);
9751
+ const inputArguments = isConversationEnvironmentParameter(lastArgument) ? filteredArguments.slice(0, -1) : filteredArguments;
9752
+ const inputs = [];
9753
+ for (const argument of inputArguments) {
9754
+ if (!isLooseMessageInput(argument)) {
9755
+ throw new Error("appendMessages expected MessageInput arguments before the optional environment");
9756
+ }
9757
+ inputs.push(argument);
9758
+ }
9759
+ if (isConversationEnvironmentParameter(lastArgument)) {
9760
+ return { inputs, environment: lastArgument };
9761
+ }
9762
+ return { inputs };
9763
+ }
9764
+ function appendMessages(conversation, ...args) {
9765
+ const { inputs, environment } = partitionAppendArguments(args);
9532
9766
  if (inputs.length === 0)
9533
9767
  return conversation;
9534
- return appendConversationalistMessages(conversation, ...inputs);
9768
+ const resolvedEnvironment = resolveEnvironment(environment);
9769
+ const updatedAt = resolvedEnvironment.now();
9770
+ if (typeof updatedAt !== "string") {
9771
+ throw new Error("conversation timestamp must be a string");
9772
+ }
9773
+ const nextIds = [...conversation.ids];
9774
+ const nextMessages = { ...conversation.messages };
9775
+ const toolCallIds = buildToolCallIds(getOrderedMessages(conversation));
9776
+ inputs.forEach((input, index3) => {
9777
+ const normalizedInput = { ...input, content: normalizeContent(input.content) };
9778
+ const processedInput = resolvedEnvironment.plugins.reduce((current, plugin) => plugin(current), normalizedInput);
9779
+ if (!isLooseMessageInput(processedInput)) {
9780
+ throw new Error("conversation plugin returned an invalid MessageInput");
9781
+ }
9782
+ assertValidToolMessage(processedInput, toolCallIds);
9783
+ const messageId = resolvedEnvironment.randomId();
9784
+ if (typeof messageId !== "string") {
9785
+ throw new Error("generated message id must be a string");
9786
+ }
9787
+ if (nextMessages[messageId] !== undefined || nextIds.includes(messageId)) {
9788
+ throw new Error(`duplicate message id in conversation: ${messageId}`);
9789
+ }
9790
+ const message = materializeMessage(processedInput, conversation.ids.length + index3, updatedAt, messageId);
9791
+ nextIds.push(message.id);
9792
+ nextMessages[message.id] = message;
9793
+ });
9794
+ return {
9795
+ ...conversation,
9796
+ ids: nextIds,
9797
+ messages: nextMessages,
9798
+ updatedAt
9799
+ };
9800
+ }
9801
+ function appendUserMessage(conversation, content, metadataOrEnvironment, environment) {
9802
+ const metadata = resolveRoleHelperMetadata(metadataOrEnvironment, environment);
9803
+ const resolvedEnvironment = environment ?? (isRoleHelperEnvironmentParameter(metadataOrEnvironment) ? metadataOrEnvironment : undefined);
9804
+ return appendMessages(conversation, { role: "user", content, metadata }, resolvedEnvironment);
9805
+ }
9806
+ function appendAssistantMessage(conversation, content, metadataOrEnvironment, environment) {
9807
+ const metadata = resolveRoleHelperMetadata(metadataOrEnvironment, environment);
9808
+ const resolvedEnvironment = environment ?? (isRoleHelperEnvironmentParameter(metadataOrEnvironment) ? metadataOrEnvironment : undefined);
9809
+ return appendMessages(conversation, { role: "assistant", content, metadata }, resolvedEnvironment);
9810
+ }
9811
+ function resolveRoleHelperMetadata(metadataOrEnvironment, environment) {
9812
+ if (metadataOrEnvironment === undefined)
9813
+ return;
9814
+ if (environment === undefined && isRoleHelperEnvironmentParameter(metadataOrEnvironment)) {
9815
+ return;
9816
+ }
9817
+ if (isMetadataRecord(metadataOrEnvironment))
9818
+ return metadataOrEnvironment;
9819
+ throw new Error("metadata must be a JSON-compatible object");
9535
9820
  }
9536
- var appendUserMessage = appendConversationalistUserMessage;
9537
- var appendAssistantMessage = appendConversationalistAssistantMessage;
9538
9821
  // src/components/chat/export/conversation-export-actions.svelte
9539
9822
  import"svelte/internal/disclose-version";
9540
9823
  import * as $73 from "svelte/internal/client";
@@ -11019,4 +11302,4 @@ export {
11019
11302
  Artifact_panel as ArtifactPanel
11020
11303
  };
11021
11304
 
11022
- //# debugId=39AB4E5BB8E0D1BE64756E2164756E21
11305
+ //# debugId=58C35D46F786E29A64756E2164756E21
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Conversation-reading helpers for Chat.
3
3
  *
4
- * These delegate to `conversationalist` so message ordering stays aligned with
5
- * the published conversation package. Tool pairing keeps Chat's role gate so an
6
- * incidental tool-shaped field on a non-tool message never renders as a pair.
4
+ * These helpers operate on the Conversationalist transcript shape while keeping
5
+ * Cinder's browser runtime free of the full conversation package.
7
6
  */
8
- import { getMessages } from 'conversationalist';
9
- import type { Message, ToolCallPair } from '../conversation-model.ts';
7
+ import type { ConversationHistory, Message, ToolCallPair } from '../conversation-model.ts';
8
+ export declare function getMessages(conversation: ConversationHistory, options?: {
9
+ includeHidden?: boolean;
10
+ }): Message[];
10
11
  /** Pairs tool calls with role-valid tool results from an already-ordered message array. */
11
12
  export declare function pairToolCallsWithResults(messages: ReadonlyArray<Message>): ToolCallPair[];
12
- export { getMessages };
@@ -3666,13 +3666,26 @@ function File_text($$anchor, $$props) {
3666
3666
  }));
3667
3667
  }
3668
3668
  // src/components/chat/utilities/conversation.ts
3669
- import { getMessages } from "conversationalist";
3670
- import { pairToolCallsWithResults as pairConversationalistToolCallsWithResults } from "conversationalist/utilities";
3671
- function hasPairableToolField(message) {
3672
- return message.role === "tool-call" && message.toolCall !== undefined || message.role === "tool-result" && message.toolResult !== undefined;
3669
+ function getMessages(conversation, options = {}) {
3670
+ return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined).filter((message) => options.includeHidden === true || !message.hidden);
3673
3671
  }
3674
3672
  function pairToolCallsWithResults(messages) {
3675
- return pairConversationalistToolCallsWithResults(messages.filter(hasPairableToolField));
3673
+ const resultsByCallId = new Map;
3674
+ for (const message of messages) {
3675
+ if (message.role === "tool-result" && message.toolResult !== undefined) {
3676
+ resultsByCallId.set(message.toolResult.callId, message.toolResult);
3677
+ }
3678
+ }
3679
+ const pairs = [];
3680
+ for (const message of messages) {
3681
+ if (message.role === "tool-call" && message.toolCall !== undefined) {
3682
+ pairs.push({
3683
+ call: message.toolCall,
3684
+ result: resultsByCallId.get(message.toolCall.id)
3685
+ });
3686
+ }
3687
+ }
3688
+ return pairs;
3676
3689
  }
3677
3690
  // src/components/chat/utilities/utilities.ts
3678
3691
  var CINDER_REASONING_METADATA_KEY = "cinder:reasoning";
@@ -4262,4 +4275,4 @@ export {
4262
4275
  Chat_conversation_header as ChatConversationHeader
4263
4276
  };
4264
4277
 
4265
- //# debugId=3FF39ABB234DF4E864756E2164756E21
4278
+ //# debugId=B66F016402C32A4164756E2164756E21
@@ -64,13 +64,26 @@ function classNames(...parts) {
64
64
  }
65
65
 
66
66
  // src/components/chat/utilities/conversation.ts
67
- import { getMessages } from "conversationalist";
68
- import { pairToolCallsWithResults as pairConversationalistToolCallsWithResults } from "conversationalist/utilities";
69
- function hasPairableToolField(message) {
70
- return message.role === "tool-call" && message.toolCall !== undefined || message.role === "tool-result" && message.toolResult !== undefined;
67
+ function getMessages(conversation, options = {}) {
68
+ return conversation.ids.map((id) => conversation.messages[id]).filter((message) => message !== undefined).filter((message) => options.includeHidden === true || !message.hidden);
71
69
  }
72
70
  function pairToolCallsWithResults(messages) {
73
- return pairConversationalistToolCallsWithResults(messages.filter(hasPairableToolField));
71
+ const resultsByCallId = new Map;
72
+ for (const message of messages) {
73
+ if (message.role === "tool-result" && message.toolResult !== undefined) {
74
+ resultsByCallId.set(message.toolResult.callId, message.toolResult);
75
+ }
76
+ }
77
+ const pairs = [];
78
+ for (const message of messages) {
79
+ if (message.role === "tool-call" && message.toolCall !== undefined) {
80
+ pairs.push({
81
+ call: message.toolCall,
82
+ result: resultsByCallId.get(message.toolCall.id)
83
+ });
84
+ }
85
+ }
86
+ return pairs;
74
87
  }
75
88
  // src/components/chat/utilities/utilities.ts
76
89
  var CINDER_REASONING_METADATA_KEY = "cinder:reasoning";
@@ -520,4 +533,4 @@ export {
520
533
  Chat_conversation_list as ChatConversationList
521
534
  };
522
535
 
523
- //# debugId=FA6DE2C72C326CFB64756E2164756E21
536
+ //# debugId=ADE11286DEEAF0C664756E2164756E21
@@ -0,0 +1,136 @@
1
+ @layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
2
+ @layer cinder.components {
3
+ /* ========================================
4
+ * CONNECTION INDICATOR
5
+ *
6
+ * Small standalone status pill for a live connection. Color is driven
7
+ * exclusively from the `data-cinder-status` attribute via the existing
8
+ * semantic status tokens (`--cinder-success`, `--cinder-warning`,
9
+ * `--cinder-text-muted`) — never hard-code hex values when consuming this
10
+ * component. `polling` is deliberately quieter than `live`: it carries no
11
+ * motion and a lighter font-weight so it can never be mistaken for push,
12
+ * even under grayscale or forced-colors rendering where the color
13
+ * difference disappears.
14
+ * ======================================== */
15
+
16
+ .cinder-connection-indicator {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ gap: var(--cinder-space-1-5);
20
+ padding: var(--cinder-space-0-5) var(--cinder-space-2-5);
21
+ border-radius: var(--cinder-radius-full);
22
+ background: var(--cinder-surface-inset);
23
+ color: var(--cinder-text-muted);
24
+ font-size: var(--cinder-text-xs);
25
+ font-weight: var(--cinder-font-medium);
26
+ line-height: 1.25;
27
+ vertical-align: middle;
28
+ }
29
+
30
+ .cinder-connection-indicator__dot {
31
+ display: inline-block;
32
+ flex-shrink: 0;
33
+ inline-size: 0.375rem;
34
+ block-size: 0.375rem;
35
+ border-radius: var(--cinder-radius-full);
36
+ background: currentColor;
37
+ }
38
+
39
+ .cinder-connection-indicator[data-cinder-status='live'] .cinder-connection-indicator__dot {
40
+ animation: cinder-connection-indicator-pulse 1.4s ease-in-out infinite;
41
+ }
42
+
43
+ @media (prefers-reduced-motion: reduce) {
44
+ .cinder-connection-indicator[data-cinder-status='live'] .cinder-connection-indicator__dot {
45
+ animation: none;
46
+ }
47
+ }
48
+
49
+ @keyframes cinder-connection-indicator-pulse {
50
+ 0%,
51
+ 100% {
52
+ opacity: 1;
53
+ }
54
+ 50% {
55
+ opacity: 0.35;
56
+ }
57
+ }
58
+
59
+ .cinder-connection-indicator__icon {
60
+ display: inline-flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ flex-shrink: 0;
64
+ inline-size: 0.8125rem;
65
+ block-size: 0.8125rem;
66
+ color: currentColor;
67
+ }
68
+
69
+ /* connecting and reconnecting both spin the icon wrapper to signal in-progress work. This
70
+ * targets the wrapper span (not the inner svg with a :global() selector) because this file is
71
+ * a plain CSS asset imported from index.ts — the Svelte compiler never processes it, so
72
+ * :global() has no effect here and browsers drop the whole rule as an unknown pseudo-class.
73
+ * Rotating the wrapper rotates its svg child identically. */
74
+ .cinder-connection-indicator[data-cinder-status='connecting'] .cinder-connection-indicator__icon,
75
+ .cinder-connection-indicator[data-cinder-status='reconnecting']
76
+ .cinder-connection-indicator__icon {
77
+ animation: cinder-connection-indicator-spin var(--cinder-duration-spin) linear infinite;
78
+ }
79
+
80
+ @media (prefers-reduced-motion: reduce) {
81
+ .cinder-connection-indicator[data-cinder-status='connecting']
82
+ .cinder-connection-indicator__icon,
83
+ .cinder-connection-indicator[data-cinder-status='reconnecting']
84
+ .cinder-connection-indicator__icon {
85
+ animation: none;
86
+ }
87
+ }
88
+
89
+ @keyframes cinder-connection-indicator-spin {
90
+ to {
91
+ transform: rotate(360deg);
92
+ }
93
+ }
94
+
95
+ .cinder-connection-indicator__label {
96
+ color: inherit;
97
+ }
98
+
99
+ .cinder-connection-indicator__attempt {
100
+ color: var(--cinder-text-muted);
101
+ font-weight: var(--cinder-font-normal);
102
+ }
103
+
104
+ /* ----------------------------------------
105
+ * Status → semantic token mapping
106
+ *
107
+ * `polling` reuses the same muted tone as `closed` but is disambiguated by
108
+ * its icon, its lack of motion (see above), and its label text — color is
109
+ * never the sole signal (WCAG 1.4.1).
110
+ * ---------------------------------------- */
111
+
112
+ .cinder-connection-indicator[data-cinder-status='connecting'] {
113
+ color: var(--cinder-warning);
114
+ }
115
+
116
+ .cinder-connection-indicator[data-cinder-status='live'] {
117
+ color: var(--cinder-success);
118
+ }
119
+
120
+ .cinder-connection-indicator[data-cinder-status='reconnecting'] {
121
+ color: var(--cinder-warning);
122
+ }
123
+
124
+ .cinder-connection-indicator[data-cinder-status='polling'] {
125
+ color: var(--cinder-text-muted);
126
+ font-weight: var(--cinder-font-normal);
127
+ }
128
+
129
+ .cinder-connection-indicator[data-cinder-status='stale'] {
130
+ color: var(--cinder-info);
131
+ }
132
+
133
+ .cinder-connection-indicator[data-cinder-status='closed'] {
134
+ color: var(--cinder-text-muted);
135
+ }
136
+ }
@@ -0,0 +1,3 @@
1
+ import type { ComponentSchema } from '../../schema-types';
2
+ declare const _default: ComponentSchema;
3
+ export default _default;