@squidcloud/client 1.0.502 → 1.0.504

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 (62) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +28 -2
  4. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +3 -3
  5. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +30 -8
  6. package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +5 -0
  7. package/dist/internal-common/src/public-types/ai-voice.public-types.d.ts +16 -0
  8. package/dist/internal-common/src/public-types/context.public-types.d.ts +2 -0
  9. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +1 -1
  10. package/dist/internal-common/src/public-types/integration.public-types.d.ts +1 -1
  11. package/dist/internal-common/src/public-types/langgraph.public-types.d.ts +86 -0
  12. package/dist/internal-common/src/public-types/session.public-types.d.ts +82 -0
  13. package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +4 -4
  14. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +1 -1
  15. package/dist/typescript-client/src/index.d.ts +1 -0
  16. package/dist/typescript-client/src/langgraph-client.d.ts +23 -1
  17. package/dist/typescript-client/src/public-types.d.ts +1 -0
  18. package/dist/typescript-client/src/session-client.d.ts +21 -0
  19. package/dist/typescript-client/src/squid.d.ts +12 -0
  20. package/dist/typescript-client/src/version.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/dist/internal-common/src/ai/system-openai-compatible.d.ts +0 -35
  23. package/dist/internal-common/src/metric-name.d.ts +0 -5
  24. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +0 -30
  25. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +0 -161
  26. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +0 -75
  27. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +0 -193
  28. package/dist/internal-common/src/types/ai-agent.types.d.ts +0 -304
  29. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +0 -798
  30. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +0 -19
  31. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  32. package/dist/internal-common/src/types/communication.types.d.ts +0 -1
  33. package/dist/internal-common/src/types/document.types.d.ts +0 -1
  34. package/dist/internal-common/src/types/file.types.d.ts +0 -6
  35. package/dist/internal-common/src/types/headers.types.d.ts +0 -45
  36. package/dist/internal-common/src/types/management-api-key.types.d.ts +0 -92
  37. package/dist/internal-common/src/types/mutation.types.d.ts +0 -1
  38. package/dist/internal-common/src/types/notification.types.d.ts +0 -19
  39. package/dist/internal-common/src/types/observability.types.d.ts +0 -296
  40. package/dist/internal-common/src/types/query.types.d.ts +0 -21
  41. package/dist/internal-common/src/types/secret.types.d.ts +0 -7
  42. package/dist/internal-common/src/types/socket.types.d.ts +0 -1
  43. package/dist/internal-common/src/types/stage.d.ts +0 -9
  44. package/dist/internal-common/src/types/time-units.d.ts +0 -1
  45. package/dist/internal-common/src/types/url-shortener.types.d.ts +0 -45
  46. package/dist/internal-common/src/utils/array.d.ts +0 -7
  47. package/dist/internal-common/src/utils/connector-path-status.d.ts +0 -27
  48. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +0 -2
  49. package/dist/internal-common/src/utils/file-utils.d.ts +0 -2
  50. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  51. package/dist/internal-common/src/utils/http-utils.d.ts +0 -15
  52. package/dist/internal-common/src/utils/http.d.ts +0 -4
  53. package/dist/internal-common/src/utils/integration-access-tokens.d.ts +0 -15
  54. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  55. package/dist/internal-common/src/utils/metric-utils.d.ts +0 -4
  56. package/dist/internal-common/src/utils/metrics.types.d.ts +0 -7
  57. package/dist/internal-common/src/utils/object.d.ts +0 -93
  58. package/dist/internal-common/src/utils/serialization.d.ts +0 -30
  59. package/dist/internal-common/src/utils/squid.constants.d.ts +0 -3
  60. package/dist/internal-common/src/utils/trace-id-generator.d.ts +0 -1
  61. package/dist/internal-common/src/utils/validation.d.ts +0 -21
  62. package/dist/internal-common/src/websocket.impl.d.ts +0 -26
@@ -7,6 +7,7 @@ import { DocumentExtractionMethod } from './extraction.public-types';
7
7
  import { IntegrationType } from './integration.public-types';
8
8
  import { JobId } from './job.public-types';
9
9
  import { SecretKey } from './secret.public-types';
10
+ import { UpsertSessionRequest } from './session.public-types';
10
11
  /**
11
12
  * @category AI
12
13
  */
@@ -653,6 +654,9 @@ export interface BaseAiChatOptions {
653
654
  * conversation, not only the one that fell back — tuning meant for one model is not evidence of
654
655
  * what another should use.
655
656
  *
657
+ * A turn the primary's safety classifier declines outright — no text at all came back — falls
658
+ * back the same way, since another model may well answer the same prompt.
659
+ *
656
660
  * Applies to models served through Squid's own provider SDKs — the vendor models and
657
661
  * `openai_compatible`, Bedrock and Vertex integrations. A model you serve yourself from backend
658
662
  * code reports its failures as plain errors that carry no provider status, so a turn on one is
@@ -863,6 +867,19 @@ export interface AiChatRequestCredentials {
863
867
  */
864
868
  integrationAccessTokens?: Record<IntegrationId, string>;
865
869
  }
870
+ /**
871
+ * The session (`squid.sessions()`) a chat request runs in. It is part of the request only: never stored with the agent.
872
+ * @category AI
873
+ */
874
+ export interface AiChatRequestSession {
875
+ /**
876
+ * Every AI function the request calls gets the session as `context.session`. With the app API key, the request
877
+ * creates the session or updates the one with the same id. Without it, a new id creates the session with its data
878
+ * and a live one is attached as it is; the agent's `@secureAiAgent` rules see both and can refuse them. A call that
879
+ * skips the rules, to a public agent or with the agent's API key, cannot attach one.
880
+ */
881
+ session?: UpsertSessionRequest;
882
+ }
866
883
  /**
867
884
  * Configuration for exposing an AI agent as an MCP server at `/mcp/<agentId>`.
868
885
  * @category AI
@@ -1279,6 +1296,14 @@ export type BaseAiContextOptions = {
1279
1296
  ragType?: AiRagType;
1280
1297
  /** Amount of chunk overlap, in characters. */
1281
1298
  chunkOverlap?: number;
1299
+ /**
1300
+ * Contextual RAG only. On a re-upsert, a chunk whose text is unchanged keeps its stored blurb and
1301
+ * embedding, and only chunks with new text are sent to the LLM; with GraphRAG it also keeps its graph
1302
+ * entities and is not extracted again. A chunk that carries an image is always written anew. A reused blurb
1303
+ * was written against the previous version of the document; set false when an edit can change the meaning
1304
+ * of text elsewhere in it. Defaults to true.
1305
+ */
1306
+ reuseChunkContext?: boolean;
1282
1307
  };
1283
1308
  /**
1284
1309
  * @category AI
@@ -1331,8 +1356,9 @@ export type AiPiiOptions = {
1331
1356
  /** App-specific PII in plain language, e.g. `'internal case numbers like CASE-12345'`. */
1332
1357
  customRules?: Array<string>;
1333
1358
  /**
1334
- * Model performing the screening. Defaults to {@link DEFAULT_PII_CLASSIFIER_MODEL}. Each attempt is
1335
- * bounded at a minute, so an override has to answer within it.
1359
+ * Model performing the screening. Defaults to {@link DEFAULT_PII_CLASSIFIER_MODEL}, or the app's best
1360
+ * available model when that one is unavailable. Each attempt is bounded at a minute, so an override has
1361
+ * to answer within it.
1336
1362
  */
1337
1363
  classifierModel?: AiChatModelSelection;
1338
1364
  /** Literal values that never count as PII, e.g. a shared support address. */
@@ -51,7 +51,7 @@ export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-5.6-sol", "gpt-5.6-
51
51
  * Public Gemini chat model names (active models only).
52
52
  * @category AI
53
53
  */
54
- export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-3.1-pro", "gemini-3.8-flash", "gemini-3.5-flash-lite"];
54
+ export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-4-argon", "gemini-3.8-flash", "gemini-3.5-flash-lite"];
55
55
  /**
56
56
  * Public Grok chat model names (active models only).
57
57
  * @category AI
@@ -61,12 +61,12 @@ export declare const GROK_CHAT_MODEL_NAMES: readonly ["grok-4.6", "grok-4-1-fast
61
61
  * Public Anthropic chat model names (active models only).
62
62
  * @category AI
63
63
  */
64
- export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5-20251001", "claude-opus-5-5", "claude-sonnet-5-5"];
64
+ export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-fable-5", "claude-fable-5-1", "claude-haiku-5-5", "claude-opus-5-5", "claude-sonnet-5-5"];
65
65
  /**
66
66
  * The supported AI model names.
67
67
  * @category AI
68
68
  */
69
- export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-6-astra", "gpt-6-luna", "gpt-6.1-sol", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5-20251001", "claude-opus-5-5", "claude-sonnet-5-5", "gemini-3.1-pro", "gemini-3.8-flash", "gemini-3.5-flash-lite", "grok-4.6", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
69
+ export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-6-astra", "gpt-6-luna", "gpt-6.1-sol", "claude-fable-5", "claude-fable-5-1", "claude-haiku-5-5", "claude-opus-5-5", "claude-sonnet-5-5", "gemini-4-argon", "gemini-3.8-flash", "gemini-3.5-flash-lite", "grok-4.6", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
70
70
  /** Checks if the given model name is a global AI chat model name. */
71
71
  export declare function isVendorAiChatModelName(modelName: unknown): modelName is VendorAiChatModelName;
72
72
  /**
@@ -220,6 +220,13 @@ export interface AiKnowledgeBaseGraphConfig {
220
220
  extractionModel?: AiChatModelSelection;
221
221
  /** Optional domain taxonomy hint (entity types) injected into the extraction prompt. */
222
222
  entityTypes?: string[];
223
+ /**
224
+ * How hard per-chunk extraction works. `'thorough'` allows about 40 entities per chunk instead of 15 and runs
225
+ * at high reasoning effort on OpenAI extraction models: more entities and relationships, a bigger graph (a
226
+ * listing yields ~40 entities per chunk) and about 1.5x the extraction cost. Like `extractionModel`, a change
227
+ * reaches already-indexed content on the next `full` rebuild. Defaults to `'standard'`.
228
+ */
229
+ extractionDepth?: 'standard' | 'thorough';
223
230
  /**
224
231
  * Quiet window (milliseconds) after the last graph activity before the sweep auto-builds the
225
232
  * structure. Must be a positive integer, and is floored at 3 seconds — a shorter window is not
@@ -528,6 +535,11 @@ export interface AiKnowledgeBaseContext {
528
535
  * carry none; their reupsert takes the defaults.
529
536
  */
530
537
  requestConfig?: AiKnowledgeBaseContextRequestConfig;
538
+ /**
539
+ * Set on an attachment of a OneNote section or email that the knowledge base indexed as its own context: the
540
+ * id of that container. Such contexts are managed with their container and left out of context listings.
541
+ */
542
+ parentContextId?: string;
531
543
  }
532
544
  /**
533
545
  * The ingestion request's options only. Everything else a reupsert needs lives on the context itself —
@@ -709,6 +721,14 @@ export type BaseAiKnowledgeBaseContextOptions = {
709
721
  ragType?: AiRagType;
710
722
  /** Amount of chunk overlap, in characters. */
711
723
  chunkOverlap?: number;
724
+ /**
725
+ * Contextual RAG only. On a re-upsert, a chunk whose text is unchanged keeps its stored blurb and
726
+ * embedding, and only chunks with new text are sent to the LLM; with GraphRAG it also keeps its graph
727
+ * entities and is not extracted again. A chunk that carries an image is always written anew. A reused blurb
728
+ * was written against the previous version of the document; set false when an edit can change the meaning
729
+ * of text elsewhere in it. Defaults to true.
730
+ */
731
+ reuseChunkContext?: boolean;
712
732
  };
713
733
  /**
714
734
  * Specific options for the AI knowledgebase search method.
@@ -795,9 +815,10 @@ export interface UpsertKnowledgeBaseContextResponse {
795
815
  /** List of the upsert status of each item sent in the request. */
796
816
  failure?: UpsertContextStatusError;
797
817
  /**
798
- * Set when the context was stored (and is fully searchable via vector/keyword) but NOT graph-indexed
799
- * because the knowledge base is over its per-KB graph chunk cap. Only GraphRAG coverage is absent; the
800
- * singular counterpart of {@link UpsertKnowledgeBaseContextsResponse.graphIndexingSkippedContextIds}.
818
+ * Set when the context was stored (and is fully searchable via vector/keyword) but NOT graph-indexed by
819
+ * this upsert: the knowledge base is over its per-KB graph chunk cap, or its stale graph data could not be
820
+ * pruned, which a later graph rebuild repairs. Only GraphRAG coverage is absent; the singular counterpart
821
+ * of {@link UpsertKnowledgeBaseContextsResponse.graphIndexingSkippedContextIds}.
801
822
  */
802
823
  graphIndexingSkipped?: boolean;
803
824
  /**
@@ -838,9 +859,10 @@ export interface UpsertKnowledgeBaseContextsResponse {
838
859
  */
839
860
  contextIds?: Array<AiContextId>;
840
861
  /**
841
- * Contexts that were stored (and are fully searchable via vector/keyword) but NOT graph-indexed because
842
- * the knowledge base is over its per-KB graph chunk cap. Only GraphRAG coverage is absent; surfaced so a
843
- * caller can report the graph-coverage gap. Absent/empty when nothing was skipped or graph is disabled.
862
+ * Contexts that were stored (and are fully searchable via vector/keyword) but NOT graph-indexed by this
863
+ * upsert: the knowledge base is over its per-KB graph chunk cap, or their stale graph data could not be
864
+ * pruned, which a later graph rebuild repairs. Only GraphRAG coverage is absent; surfaced so a caller can
865
+ * report the graph-coverage gap. Absent/empty when nothing was skipped or graph is disabled.
844
866
  */
845
867
  graphIndexingSkippedContextIds?: Array<AiContextId>;
846
868
  /**
@@ -1549,8 +1571,8 @@ export interface KnowledgeBaseGraphFacetValueStatus {
1549
1571
  * documents into topics/facets.
1550
1572
  * - `'full'` — wipes the graph and re-extracts entities/relationships from every chunk with an LLM,
1551
1573
  * then rebuilds the concept layer. The expensive deep-clean: re-extraction dominates its cost.
1552
- * Only needed when the extraction itself must be redone, e.g. after changing `entityTypes` or
1553
- * `extractionModel`.
1574
+ * Only needed when the extraction itself must be redone, e.g. after changing `entityTypes`,
1575
+ * `extractionModel` or `extractionDepth`.
1554
1576
  * @category AI
1555
1577
  */
1556
1578
  export type KnowledgeBaseGraphRebuildMode = 'full' | 'structural';
@@ -24,6 +24,11 @@ export interface AiQueryOptions {
24
24
  instructions?: string;
25
25
  /** Whether to enable raw results output. */
26
26
  enableRawResults?: boolean;
27
+ /**
28
+ * When the results are too large to analyze in the answer, skips the analysis and returns the raw results as
29
+ * files instead, for a caller that processes them itself (e.g. an agent with `executePythonCode`). Default: false.
30
+ */
31
+ largeResultsAsFiles?: boolean;
27
32
  /** Options for the collection selection stage. */
28
33
  selectCollectionsOptions?: AiQuerySelectCollectionsOptions;
29
34
  /** Options for the query generation stage. */
@@ -1,5 +1,6 @@
1
1
  import type { AllAiAgentChatOptions } from './ai-agent.public-types';
2
2
  import type { AiAgentId, IntegrationId } from './communication.public-types';
3
+ import type { UpsertSessionRequest } from './session.public-types';
3
4
  /**
4
5
  * Providers that put a Squid agent on a phone call. `twilio` relays the call to Squid over a WebSocket
5
6
  * Squid serves; `openai` is an OpenAI Realtime call Squid answers itself, see
@@ -48,6 +49,11 @@ export interface CreateAiVoiceSessionRequest {
48
49
  connectTimeoutSeconds?: number;
49
50
  /** Public base URL of the application when it differs from the default, such as a tunnel in local development. */
50
51
  relayBaseUrl?: string;
52
+ /**
53
+ * The session (`squid.sessions()`) the call runs in: the AI functions of every turn get it as `context.session`.
54
+ * Attached once, when the call starts.
55
+ */
56
+ session?: UpsertSessionRequest;
51
57
  }
52
58
  /**
53
59
  * The opened voice session.
@@ -94,6 +100,11 @@ export interface AnswerOpenAiVoiceCallRequest {
94
100
  chatOptions?: AllAiAgentChatOptions;
95
101
  /** Free-form data echoed on every session event, for the caller's own bookkeeping. */
96
102
  metadata?: Record<string, unknown>;
103
+ /**
104
+ * The session (`squid.sessions()`) the call runs in: the AI functions of every turn get it as `context.session`.
105
+ * Attached once, when the call starts.
106
+ */
107
+ session?: UpsertSessionRequest;
97
108
  }
98
109
  /**
99
110
  * The answered OpenAI call.
@@ -148,6 +159,11 @@ export interface StartOpenAiWebVoiceCallRequest {
148
159
  chatOptions?: AllAiAgentChatOptions;
149
160
  /** Free-form data echoed on every session event, for the caller's own bookkeeping. */
150
161
  metadata?: Record<string, unknown>;
162
+ /**
163
+ * The session (`squid.sessions()`) the call runs in: the AI functions of every turn get it as `context.session`.
164
+ * Attached once, when the call starts.
165
+ */
166
+ session?: UpsertSessionRequest;
151
167
  }
152
168
  /**
153
169
  * The started browser call.
@@ -62,6 +62,8 @@ export interface RunContext {
62
62
  headers?: Record<string, any>;
63
63
  /** Additional context for OpenAPI requests */
64
64
  openApiContext?: OpenApiContext;
65
+ /** The id of the session (`squid.sessions()`) this request runs in, when the AI agent or LangGraph call attached one. */
66
+ sessionId?: string;
65
67
  }
66
68
  /** In the case of OpenAPI, the context of the request is provided in a separate object. */
67
69
  export interface OpenApiContext {
@@ -399,7 +399,7 @@ export interface DocumentMetadata {
399
399
  docModifiedAt?: string;
400
400
  /**
401
401
  * Source document type: `pdf` | `docx` | `doc` | `pptx` | `ppt` | `xlsx` | `xlsm` | `xls` | `xlsb` |
402
- * `eml` | `msg` | `csv` | `tsv` | `md` | `html` | `txt`.
402
+ * `eml` | `msg` | `one` | `csv` | `tsv` | `md` | `html` | `txt`.
403
403
  */
404
404
  docType?: string;
405
405
  }
@@ -1,6 +1,6 @@
1
1
  import { IntegrationId } from './communication.public-types';
2
2
  /** List of all integration types supported by Squid. */
3
- export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "bedrock", "azure_blob", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "bitbucket", "built_in_azure_blob", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "connected_knowledgebases", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "azure-entra-external-id", "azure-entra-id", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "generic_site_ingester", "github", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jira_jsm", "jwt_hmac", "jwt_rsa", "kafka", "keycloak", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "outlook", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce", "sap_hana", "sentry", "snowflake", "spanner", "xata", "zendesk", "servicenow_csm", "freshdesk", "mail", "slack", "twilio", "elevenlabs", "openai_voice", "mcp", "a2a", "legend", "teams", "openai_compatible", "openai_compatible_embedding", "sharepoint", "vertex"];
3
+ export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "bedrock", "azure_blob", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "bitbucket", "built_in_azure_blob", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "connected_knowledgebases", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "azure-entra-external-id", "azure-entra-id", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "generic_site_ingester", "github", "google_calendar", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jira_jsm", "jwt_hmac", "jwt_rsa", "kafka", "keycloak", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "outlook", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce", "sap_hana", "sentry", "snowflake", "spanner", "xata", "zendesk", "servicenow_csm", "freshdesk", "mail", "slack", "twilio", "elevenlabs", "openai_voice", "mcp", "a2a", "legend", "teams", "openai_compatible", "openai_compatible_embedding", "bedrock_embedding", "sharepoint", "vertex"];
4
4
  /**
5
5
  * @category Database
6
6
  */
@@ -1,3 +1,4 @@
1
+ import { UpsertSessionRequest } from './session.public-types';
1
2
  /**
2
3
  * Options for starting a new LangGraph run.
3
4
  * @category AI
@@ -14,6 +15,13 @@ export interface InvokeLangGraphOptions {
14
15
  * passes its own.
15
16
  */
16
17
  context?: Record<string, unknown>;
18
+ /**
19
+ * The session (`squid.sessions()`) the run runs in: nodes read its id from `RunContext.sessionId`. With the app API
20
+ * key, the run creates the session or updates the one with the same id. Without it, a new id creates the session
21
+ * with its data and a live one is attached as it is; the graph's `@secureLangGraph` rules see both and can refuse
22
+ * them.
23
+ */
24
+ session?: UpsertSessionRequest;
17
25
  }
18
26
  /**
19
27
  * Options for resuming an interrupted LangGraph thread.
@@ -24,6 +32,24 @@ export interface ResumeLangGraphOptions {
24
32
  timeoutMs?: number;
25
33
  /** Context of the resumed run, which every node reads as LangGraph's `runtime.context`. */
26
34
  context?: Record<string, unknown>;
35
+ /** The session the resumed run runs in, as for {@link InvokeLangGraphOptions.session}. */
36
+ session?: UpsertSessionRequest;
37
+ }
38
+ /**
39
+ * Options for streaming a new LangGraph run.
40
+ * @category AI
41
+ */
42
+ export interface StreamLangGraphOptions extends InvokeLangGraphOptions {
43
+ /** Streams only the tokens of LLM calls with one of these tags, such as those set with `model.withConfig({ tags })`. */
44
+ tokenTags?: string[];
45
+ }
46
+ /**
47
+ * Options for streaming the resume of an interrupted LangGraph thread.
48
+ * @category AI
49
+ */
50
+ export interface StreamResumeLangGraphOptions extends ResumeLangGraphOptions {
51
+ /** Streams only the tokens of LLM calls with one of these tags, such as those set with `model.withConfig({ tags })`. */
52
+ tokenTags?: string[];
27
53
  }
28
54
  /**
29
55
  * Successful result of a LangGraph invocation.
@@ -55,3 +81,63 @@ export interface GetLangGraphStateSuccessResult {
55
81
  /** Next nodes to execute. Empty if the graph has completed. */
56
82
  next: string[];
57
83
  }
84
+ /**
85
+ * Data a node wrote to LangGraph's stream: `config.writer(data)` in TypeScript, `get_stream_writer()(data)` in Python.
86
+ * @category AI
87
+ */
88
+ export interface LangGraphCustomEvent {
89
+ /** Always `custom`. */
90
+ type: 'custom';
91
+ /** What the node wrote, as JSON. */
92
+ data: unknown;
93
+ }
94
+ /**
95
+ * Text that an LLM call made by a node streamed. Consecutive tokens of one message can arrive merged.
96
+ * @category AI
97
+ */
98
+ export interface LangGraphTokenEvent {
99
+ /** Always `token`. */
100
+ type: 'token';
101
+ /** The id of the message the text belongs to, which is also its id in the graph state. */
102
+ messageId?: string;
103
+ /** The node that made the LLM call. */
104
+ node: string;
105
+ /** The tags of the LLM call, such as those set with `model.withConfig({ tags })`. */
106
+ tags: string[];
107
+ /** The streamed text. */
108
+ text: string;
109
+ }
110
+ /**
111
+ * The text of an AI message that a node wrote whole, without streaming it from an LLM call.
112
+ * @category AI
113
+ */
114
+ export interface LangGraphMessageEvent {
115
+ /** Always `message`. */
116
+ type: 'message';
117
+ /** The id of the message in the graph state. */
118
+ messageId?: string;
119
+ /** The node that wrote the message. */
120
+ node: string;
121
+ /** The text of the message. */
122
+ text: string;
123
+ }
124
+ /**
125
+ * The result of a streamed run, which is the stream's last event.
126
+ * @category AI
127
+ */
128
+ export interface LangGraphResultEvent {
129
+ /** Always `result`. */
130
+ type: 'result';
131
+ /** The result of the run, as `invoke` returns it. */
132
+ result: InvokeLangGraphSuccessResult;
133
+ /**
134
+ * Set when some of the run's events may be missing from the stream: they were lost on the way or arrived too late.
135
+ * The result itself is complete.
136
+ */
137
+ incomplete?: boolean;
138
+ }
139
+ /**
140
+ * An event of a streamed LangGraph run.
141
+ * @category AI
142
+ */
143
+ export type LangGraphStreamEvent = LangGraphCustomEvent | LangGraphTokenEvent | LangGraphMessageEvent | LangGraphResultEvent;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * An app-scoped record of JSON data under an id the app chooses, which expires. See `squid.sessions()`.
3
+ * @category Sessions
4
+ */
5
+ export interface Session {
6
+ /** The id of the session. */
7
+ id: string;
8
+ /** The data of the session. */
9
+ data: Record<string, unknown>;
10
+ /** When the session was created. */
11
+ createdAt: Date;
12
+ /** When the session was last written. */
13
+ updatedAt: Date;
14
+ /** When the session expires, or `null` when it never does. */
15
+ expiresAt: Date | null;
16
+ }
17
+ /**
18
+ * How long a session lives after its last write: a TTL, or `'never'` to keep it until it is deleted.
19
+ * @category Sessions
20
+ */
21
+ export type SessionExpiration = SessionTtl | 'never';
22
+ /**
23
+ * An expiration a fixed time after the session's last write.
24
+ * @category Sessions
25
+ */
26
+ export interface SessionTtl {
27
+ /** Milliseconds from the last write to the expiration. At least 1000. */
28
+ ttlMs: number;
29
+ }
30
+ /**
31
+ * Creates a session, or updates the one with the same id.
32
+ * @category Sessions
33
+ */
34
+ export interface UpsertSessionRequest {
35
+ /** The id of the session: 1-256 characters, without control characters. */
36
+ id: string;
37
+ /** Top-level keys to set; other keys keep their values. The session's data is at most 64 KB. */
38
+ data?: Record<string, unknown>;
39
+ /** Top-level keys to remove. */
40
+ deleteKeys?: string[];
41
+ /** Replaces the session's expiration. A new session expires one day after its last write. */
42
+ expiration?: SessionExpiration;
43
+ }
44
+ /**
45
+ * A value a session listing matches a data key against.
46
+ * @category Sessions
47
+ */
48
+ export type SessionFilterValue = string | number | boolean | null;
49
+ /**
50
+ * Filters of a session listing.
51
+ * @category Sessions
52
+ */
53
+ export interface ListSessionsFilter {
54
+ /** Top-level data keys that must equal the given values. */
55
+ data?: Record<string, SessionFilterValue>;
56
+ /** Only sessions created after this time. */
57
+ createdAfter?: Date;
58
+ /** Only sessions created before this time. */
59
+ createdBefore?: Date;
60
+ }
61
+ /**
62
+ * Asks for a page of sessions, newest first.
63
+ * @category Sessions
64
+ */
65
+ export interface ListSessionsRequest {
66
+ /** The page size: 100 by default, at most 1000. */
67
+ limit?: number;
68
+ /** The `nextCursor` of the previous page. */
69
+ cursor?: string;
70
+ /** Filters of the listing. */
71
+ where?: ListSessionsFilter;
72
+ }
73
+ /**
74
+ * A page of sessions.
75
+ * @category Sessions
76
+ */
77
+ export interface ListSessionsResponse {
78
+ /** The sessions of the page, newest first. */
79
+ sessions: Session[];
80
+ /** Pass it as `cursor` to get the next page. Absent on the last page. */
81
+ nextCursor?: string;
82
+ }
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { AiAnnotation, AiAnswerValidationResult, AiAskModelSelection, AiChatModelSelection, AiChatOptions, AiChatRequestCredentials, AiModelRoutingResult } from '../../../internal-common/src/public-types/ai-agent.public-types';
2
+ import { AiAnnotation, AiAnswerValidationResult, AiAskModelSelection, AiChatModelSelection, AiChatOptions, AiChatRequestCredentials, AiChatRequestSession, AiModelRoutingResult } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
3
  /**
4
4
  * Response format for transcribing audio and generating a chat response.
5
5
  * Contains the transcribed text and a stream of AI-generated responses.
@@ -55,21 +55,21 @@ export interface AskWithVoiceResponse {
55
55
  */
56
56
  export type AiChatOptionsWithoutVoice<T extends AiAskModelSelection | undefined = undefined> = Omit<AiChatOptions<ConcreteModelOf<T>>, 'voiceOptions' | 'model'> & {
57
57
  model?: T;
58
- } & AiChatRequestCredentials;
58
+ } & AiChatRequestCredentials & AiChatRequestSession;
59
59
  /**
60
60
  * Options for AI-generated responses that exclude voice-specific settings and smooth typing behavior.
61
61
  * @category AI
62
62
  */
63
63
  export type AiAskOptions<T extends AiAskModelSelection | undefined = undefined> = Omit<AiChatOptions<ConcreteModelOf<T>>, 'voiceOptions' | 'smoothTyping' | 'model'> & {
64
64
  model?: T;
65
- } & AiChatRequestCredentials;
65
+ } & AiChatRequestCredentials & AiChatRequestSession;
66
66
  /**
67
67
  * Options for AI-generated responses that include voice-specific settings but excludes smooth typing.
68
68
  * @category AI
69
69
  */
70
70
  export type AiAskOptionsWithVoice<T extends AiAskModelSelection | undefined = undefined> = Omit<AiChatOptions<ConcreteModelOf<T>>, 'smoothTyping' | 'model'> & {
71
71
  model?: T;
72
- } & AiChatRequestCredentials;
72
+ } & AiChatRequestCredentials & AiChatRequestSession;
73
73
  /**
74
74
  * The concrete model a request's model selection names, which picks the provider-specific option set;
75
75
  * a routing choice names none, so it gets the provider-agnostic options.
@@ -227,7 +227,7 @@ export declare class AiKnowledgeBaseReference {
227
227
  * entity graph (extracting only contexts never graph-indexed) and rebuilds just the concept layer
228
228
  * (topics + facets); `mode: 'full'` wipes the graph and re-extracts every context with an LLM —
229
229
  * expensive, and only needed when the extraction itself must be redone (e.g. after changing
230
- * `entityTypes` or `extractionModel`). Requires `graphRag.enabled`. Track progress via
230
+ * `entityTypes`, `extractionModel` or `extractionDepth`). Requires `graphRag.enabled`. Track progress via
231
231
  * {@link getGraphStatus}'s `buildJob`; only one rebuild can run per knowledge base at a time.
232
232
  */
233
233
  rebuildGraph(request?: Omit<RebuildKnowledgeBaseGraphRequest, 'knowledgeBaseId'>): Promise<void>;
@@ -60,6 +60,7 @@ export * from './rpc.manager';
60
60
  export * from './runtime-options';
61
61
  export * from './scheduler-client';
62
62
  export * from './secret.client';
63
+ export * from './session-client';
63
64
  export * from './socket.manager';
64
65
  export * from './squid';
65
66
  export * from './squid-http-client';
@@ -1,5 +1,6 @@
1
+ import { Observable } from 'rxjs';
1
2
  import { JobId } from '../../internal-common/src/public-types/job.public-types';
2
- import { GetLangGraphStateSuccessResult, InvokeLangGraphOptions, InvokeLangGraphSuccessResult, ResumeLangGraphOptions } from '../../internal-common/src/public-types/langgraph.public-types';
3
+ import { GetLangGraphStateSuccessResult, InvokeLangGraphOptions, InvokeLangGraphSuccessResult, LangGraphStreamEvent, ResumeLangGraphOptions, StreamLangGraphOptions, StreamResumeLangGraphOptions } from '../../internal-common/src/public-types/langgraph.public-types';
3
4
  /**
4
5
  * Reference to a specific LangGraph.
5
6
  * @category AI
@@ -8,6 +9,7 @@ export declare class LangGraphReference {
8
9
  private readonly graphId;
9
10
  private readonly rpcManager;
10
11
  private readonly jobClient;
12
+ private readonly socketManager;
11
13
  /**
12
14
  * Starts a new LangGraph run and waits for the result.
13
15
  *
@@ -43,6 +45,24 @@ export declare class LangGraphReference {
43
45
  * @param options Optional timeout and context of the resumed run.
44
46
  */
45
47
  resumeAsync(threadId: string, resumePayload: unknown, options?: ResumeLangGraphOptions): Promise<JobId>;
48
+ /**
49
+ * Starts a new LangGraph run and streams its events: what nodes write with LangGraph's stream writer, the tokens
50
+ * of the LLM calls that nodes make, and the AI messages that nodes write whole. The last event is the result.
51
+ *
52
+ * Every subscription starts a run, and unsubscribing does not stop it. Streaming needs the client's socket, so a
53
+ * passive client throws.
54
+ *
55
+ * @param options Initial state, thread, timeout, context and session of the run, and which tokens to stream.
56
+ */
57
+ stream(options?: StreamLangGraphOptions): Observable<LangGraphStreamEvent>;
58
+ /**
59
+ * Resumes an interrupted LangGraph thread and streams the events of the resumed run, as {@link stream} does.
60
+ *
61
+ * @param threadId The thread to resume.
62
+ * @param resumePayload Value passed to the `interrupt()` call inside the graph.
63
+ * @param options Timeout, context and session of the resumed run, and which tokens to stream.
64
+ */
65
+ resumeStream(threadId: string, resumePayload: unknown, options?: StreamResumeLangGraphOptions): Observable<LangGraphStreamEvent>;
46
66
  /** Returns the current state of a LangGraph thread. */
47
67
  getState(threadId: string): Promise<GetLangGraphStateSuccessResult>;
48
68
  /**
@@ -53,4 +73,6 @@ export declare class LangGraphReference {
53
73
  * @param threadId The thread to delete.
54
74
  */
55
75
  deleteThread(threadId: string): Promise<void>;
76
+ /** Runs the request with its events sent to this client's socket, and ends the stream with the run's result. */
77
+ private streamRun;
56
78
  }
@@ -32,6 +32,7 @@ export * from '../../internal-common/src/public-types/scheduler.public-types';
32
32
  export * from '../../internal-common/src/public-types/schema.public-types';
33
33
  export * from '../../internal-common/src/public-types/secret.public-types';
34
34
  export * from '../../internal-common/src/public-types/serialized-query.public-types';
35
+ export * from '../../internal-common/src/public-types/session.public-types';
35
36
  export * from '../../internal-common/src/public-types/socket.public-types';
36
37
  export * from '../../internal-common/src/public-types/source-code.public-types';
37
38
  export * from '../../internal-common/src/public-types/typescript.public-types';
@@ -0,0 +1,21 @@
1
+ import { ListSessionsRequest, ListSessionsResponse, Session, UpsertSessionRequest } from './public-types';
2
+ /**
3
+ * Stores sessions: app-scoped JSON records under ids the app chooses, which expire. Every call needs the app API key.
4
+ *
5
+ * A client without the API key starts a session, or attaches a live one, through an AI agent or LangGraph call.
6
+ * @category Sessions
7
+ */
8
+ export declare class SessionClient {
9
+ private readonly rpcManager;
10
+ /**
11
+ * Creates the session, or updates the one with the same id, and returns it as stored. Every upsert moves the
12
+ * expiration to its TTL from now.
13
+ */
14
+ upsert(request: UpsertSessionRequest): Promise<Session>;
15
+ /** Returns the session, or `undefined` when it is missing or expired. */
16
+ get(id: string): Promise<Session | undefined>;
17
+ /** Deletes the session. Deleting a missing session does nothing. */
18
+ delete(id: string): Promise<void>;
19
+ /** Returns a page of sessions, newest first. */
20
+ list(request?: ListSessionsRequest): Promise<ListSessionsResponse>;
21
+ }
@@ -15,6 +15,7 @@ import { ObservabilityClient } from './observability-client';
15
15
  import { ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, SquidDeveloperId, SquidRegion } from './public-types';
16
16
  import { QueueManager } from './queue.manager';
17
17
  import { SchedulerClient } from './scheduler-client';
18
+ import { SessionClient } from './session-client';
18
19
  import { StorageClient } from './storage-client';
19
20
  import { TransactionId } from './types';
20
21
  import { WebClient } from './web-client';
@@ -72,6 +73,12 @@ export interface SquidOptions {
72
73
  * In passive mode, real-time features (WebSocket) are disabled.
73
74
  */
74
75
  isPassiveMode?: boolean;
76
+ /**
77
+ * Overrides the Squid API URL derived from the region, e.g. an in-cluster address such as
78
+ * `http://core.default:8000`. Requests then identify the application with the `x-squid-appid` header.
79
+ * Public URLs such as the one `getWebhookUrl` returns keep using the region.
80
+ */
81
+ baseUrl?: string;
75
82
  }
76
83
  /**
77
84
  * Authentication data provider for Squid requests.
@@ -125,6 +132,7 @@ export declare class Squid {
125
132
  private readonly aiClient;
126
133
  private readonly jobClient;
127
134
  private readonly langGraphClient;
135
+ private readonly sessionClient;
128
136
  private readonly apiClient;
129
137
  private readonly adminClient;
130
138
  private readonly webClient;
@@ -335,6 +343,10 @@ export declare class Squid {
335
343
  * Returns a reference to a LangGraph by ID.
336
344
  */
337
345
  langGraph(graphId: string): LangGraphReference;
346
+ /**
347
+ * Returns a set of functionality for storing sessions: app-scoped JSON records that expire. Needs the app API key.
348
+ */
349
+ sessions(): SessionClient;
338
350
  /**
339
351
  * Returns a set of functionality for interacting with API integrations.
340
352
  */
@@ -2,4 +2,4 @@
2
2
  * The current version of the SquidCloud client package.
3
3
  * @category Platform
4
4
  */
5
- export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.502";
5
+ export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.504";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.502",
3
+ "version": "1.0.504",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",