@cosmoops/connect-sdk 0.29.0 → 0.30.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.
@@ -1,5 +1,5 @@
1
1
  import { type TransportOptions } from "../http.js";
2
- import type { ChatMessage, ConnectScreen } from "../../types.js";
2
+ import type { AiConversationDetail, AiConversationList, ChatMessage, ConnectScreen } from "../../types.js";
3
3
  /**
4
4
  * RAG chat and structured extraction against a workspace's data.
5
5
  *
@@ -21,6 +21,15 @@ export declare class AiResource {
21
21
  workspaceId: string;
22
22
  messages: ChatMessage[];
23
23
  asUser?: string;
24
+ /**
25
+ * Your own id for this conversation, sent with every turn of it.
26
+ *
27
+ * What makes the conversation *resumable*: Connect upserts against it and
28
+ * `conversations.list`/`get` read it back. Persisted only alongside
29
+ * `asUser` - a conversation belongs to a person, and a server-to-server
30
+ * call acts as nobody. Omit it to keep a turn out of history entirely.
31
+ */
32
+ conversationId?: string;
24
33
  /**
25
34
  * Your application's screens, so the assistant answers in your product's
26
35
  * words and can link into it - see `ConnectScreen`. Prose and links only:
@@ -34,6 +43,45 @@ export declare class AiResource {
34
43
  }, options?: {
35
44
  signal?: AbortSignal;
36
45
  }): Promise<Response>;
46
+ /**
47
+ * The signed-in user's past conversations in your application, most recent
48
+ * first.
49
+ *
50
+ * `asUser` is required rather than optional here, unlike on `chat`: the rows
51
+ * are scoped to a person, and there is no application-wide view of them to
52
+ * fall back to. Connect reads the user and the workspace from the token.
53
+ *
54
+ * Cursor-paginated with no total - the list is ordered by last use, which
55
+ * moves while it is being read.
56
+ */
57
+ listConversations(input: {
58
+ asUser: string;
59
+ limit?: number;
60
+ cursor?: string;
61
+ }): Promise<AiConversationList>;
62
+ /**
63
+ * One stored transcript, oldest turn first.
64
+ *
65
+ * `turns[].parts` comes back exactly as the model produced it - prose,
66
+ * reasoning and tool calls in order - so it can be handed straight back to a
67
+ * chat UI. Not this user's, or not your application's, is a `404` either way.
68
+ */
69
+ getConversation(input: {
70
+ conversationId: string;
71
+ asUser: string;
72
+ }): Promise<AiConversationDetail>;
73
+ /**
74
+ * Deletes a conversation and every turn beneath it.
75
+ *
76
+ * Idempotent - one already gone answers `{ deleted: true }`, so a retry after
77
+ * a dropped response does not read as a failure.
78
+ */
79
+ deleteConversation(input: {
80
+ conversationId: string;
81
+ asUser: string;
82
+ }): Promise<{
83
+ deleted: true;
84
+ }>;
37
85
  /** Extract structured JSON from a file or image URL, against a platform extraction schema referenced by id. */
38
86
  extract<T = unknown>(input: {
39
87
  schemaId: string;
@@ -538,6 +538,54 @@ export interface ChatMessage {
538
538
  role: "user" | "assistant" | "system";
539
539
  [field: string]: unknown;
540
540
  }
541
+ /**
542
+ * One row of Ask AI history.
543
+ *
544
+ * A conversation exists only if the turns that made it carried a
545
+ * `conversationId` *and* were sent on a user's behalf - see `AiResource.chat`.
546
+ * It belongs to one person in one of your workspaces, and never leaves your
547
+ * application: a workspace subscribing to two products keeps two lists.
548
+ */
549
+ export interface AiConversation {
550
+ id: string;
551
+ /** Derived from the first thing the user said - no model call, so it costs nothing. */
552
+ title: string;
553
+ /** ISO-8601. */
554
+ createdAt: string;
555
+ /**
556
+ * ISO-8601, and the sort key - a conversation returned to a week later is at
557
+ * the top, not where it was created.
558
+ */
559
+ updatedAt: string;
560
+ }
561
+ export interface AiConversationList {
562
+ conversations: AiConversation[];
563
+ /** Pass back as `cursor` for the next page; `null` at the end. */
564
+ nextCursor: string | null;
565
+ }
566
+ /** One stored turn, in the AI SDK's own shape. */
567
+ export interface AiConversationTurn {
568
+ id: string;
569
+ role: "user" | "assistant";
570
+ /**
571
+ * The message's parts exactly as the model produced them - prose, reasoning
572
+ * and tool calls, in the order they arrived.
573
+ *
574
+ * Opaque on purpose. The shape is the AI SDK's and moves with it, so a type
575
+ * restating it here would start rejecting transcripts the moment the SDK adds
576
+ * a part kind. Flattening it to text is the other mistake: the order is the
577
+ * model's own argument, and a flattened turn cannot be resumed.
578
+ */
579
+ parts: unknown[];
580
+ /** Position in the conversation. Turns arrive in this order. */
581
+ sequence: number;
582
+ /** ISO-8601. */
583
+ createdAt: string;
584
+ }
585
+ export interface AiConversationDetail {
586
+ conversation: AiConversation;
587
+ turns: AiConversationTurn[];
588
+ }
541
589
  export interface WorkspaceApp {
542
590
  applicationId: string;
543
591
  /** Stable, human-readable key - branch on this, not `applicationId`, which is per-environment. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoops/connect-sdk",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Official server-side SDK for the CosmoOps Connect platform API - Login with Connect, entitlements, billing and metering.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",