@firststep-studio/sdk 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/dist/index.d.mts +186 -5
- package/dist/index.d.ts +186 -5
- package/dist/index.js +200 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +200 -4
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{types-GoTI_c14.d.mts → types-DYJ44S2E.d.mts} +17 -0
- package/dist/{types-GoTI_c14.d.ts → types-DYJ44S2E.d.ts} +17 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChatMessage, S as SchemaDeclarationPayload, P as ProtocolStreamChunk, A as AgentTransitionPayload, R as RoutingClassificationPayload, H as HandoffRequestPayload, a as HandoffReturnPayload, b as HandoffOfferPayload } from './types-
|
|
2
|
-
export { O as AnalyticsContext, E as ChatbotInfo, F as ClassifierConfig, D as DeploymentInfo, G as FormData, V as FormFieldDefinition, W as FormFieldType, J as FormFieldValue, U as FormSchema, n as HandlerInfo, _ as HandoffContext, f as HandoffInboundContext, $ as HandoffOptions, x as Helpline, w as HelplineResult, v as HelplineSearchOptions, I as IntegrationContext, u as IntegrationResult, Q as InteractionEvent, T as InteractionEventType, t as KnowledgeColumnMetadata, K as KnowledgeContext, s as KnowledgeMetadata, r as KnowledgeResult, L as LoggerContext, m as ProtocolCapabilities, o as ProtocolContext, k as ProtocolError, j as ProtocolFieldValidation, g as ProtocolForm, h as ProtocolFormField, i as ProtocolFormOption, l as ProtocolHandler, X as ProtocolRegistration, c as ProtocolRequest, d as ProtocolResponse, B as RoutingDecision, M as RoutingLog, Y as SchemaAgent, Z as SchemaQuestion, p as SessionContext, N as SessionMetadata, q as SessionState, e as SessionStatus, y as StorageContext, z as StorageSetOptions } from './types-
|
|
1
|
+
import { C as ChatMessage, S as SchemaDeclarationPayload, P as ProtocolStreamChunk, A as AgentTransitionPayload, R as RoutingClassificationPayload, H as HandoffRequestPayload, a as HandoffReturnPayload, b as HandoffOfferPayload } from './types-DYJ44S2E.mjs';
|
|
2
|
+
export { O as AnalyticsContext, E as ChatbotInfo, F as ClassifierConfig, D as DeploymentInfo, G as FormData, V as FormFieldDefinition, W as FormFieldType, J as FormFieldValue, U as FormSchema, n as HandlerInfo, _ as HandoffContext, f as HandoffInboundContext, $ as HandoffOptions, x as Helpline, w as HelplineResult, v as HelplineSearchOptions, I as IntegrationContext, u as IntegrationResult, Q as InteractionEvent, T as InteractionEventType, t as KnowledgeColumnMetadata, K as KnowledgeContext, s as KnowledgeMetadata, r as KnowledgeResult, L as LoggerContext, m as ProtocolCapabilities, o as ProtocolContext, k as ProtocolError, j as ProtocolFieldValidation, g as ProtocolForm, h as ProtocolFormField, i as ProtocolFormOption, l as ProtocolHandler, X as ProtocolRegistration, c as ProtocolRequest, d as ProtocolResponse, B as RoutingDecision, M as RoutingLog, Y as SchemaAgent, Z as SchemaQuestion, p as SessionContext, N as SessionMetadata, q as SessionState, e as SessionStatus, y as StorageContext, z as StorageSetOptions } from './types-DYJ44S2E.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* UCP (Universal Classification Protocol) Types
|
|
@@ -680,6 +680,14 @@ interface PlatformKnowledgeSummary {
|
|
|
680
680
|
type?: string;
|
|
681
681
|
/** Owning organization ID */
|
|
682
682
|
organizationId: string;
|
|
683
|
+
/**
|
|
684
|
+
* True for handler-managed documents created through the protocol
|
|
685
|
+
* write API. System-owned knowledge is hidden from every Studio UI
|
|
686
|
+
* surface and only appears in `list` when `includeSystemOwned` is set.
|
|
687
|
+
*/
|
|
688
|
+
isSystemOwned?: boolean;
|
|
689
|
+
/** Whether semantic search (record embedding) is enabled. */
|
|
690
|
+
ragEnabled?: boolean;
|
|
683
691
|
/** Timestamps */
|
|
684
692
|
createdAt?: number | string;
|
|
685
693
|
updatedAt?: number | string;
|
|
@@ -698,7 +706,74 @@ interface ListKnowledgeOptions {
|
|
|
698
706
|
* `publicReadable` in Studio).
|
|
699
707
|
*/
|
|
700
708
|
orgId?: string;
|
|
709
|
+
/**
|
|
710
|
+
* Include system-owned (handler-managed) knowledge in the listing.
|
|
711
|
+
* Only honored when listing the token's own org; other orgs never
|
|
712
|
+
* expose their system-owned documents.
|
|
713
|
+
*/
|
|
714
|
+
includeSystemOwned?: boolean;
|
|
701
715
|
}
|
|
716
|
+
/** Sheet definition for `knowledge.create`. */
|
|
717
|
+
interface CreateKnowledgeSheet {
|
|
718
|
+
/** Stable sheet id, referenced later by record writes and search. */
|
|
719
|
+
id: string;
|
|
720
|
+
name: string;
|
|
721
|
+
description?: string;
|
|
722
|
+
/**
|
|
723
|
+
* Column definitions ({ id, name, type, ... }). Loose-typed; the
|
|
724
|
+
* Studio schema validates `type` against its column-type enum.
|
|
725
|
+
*/
|
|
726
|
+
columns?: Array<Record<string, unknown>>;
|
|
727
|
+
}
|
|
728
|
+
interface CreateKnowledgeOptions {
|
|
729
|
+
description?: string;
|
|
730
|
+
/**
|
|
731
|
+
* Enable semantic search at creation time. Defaults to false; can be
|
|
732
|
+
* flipped later with `setRagEnabled` (which also backfills embeddings
|
|
733
|
+
* for records inserted while the flag was off).
|
|
734
|
+
*/
|
|
735
|
+
ragEnabled?: boolean;
|
|
736
|
+
}
|
|
737
|
+
/** A raw record as returned by the protocol record-write endpoints. */
|
|
738
|
+
interface PlatformKnowledgeRecord {
|
|
739
|
+
id: string;
|
|
740
|
+
knowledgeId: string;
|
|
741
|
+
sheetId: string;
|
|
742
|
+
data: Record<string, unknown>;
|
|
743
|
+
createdAt?: number | string;
|
|
744
|
+
updatedAt?: number | string;
|
|
745
|
+
}
|
|
746
|
+
interface KnowledgeSearchOptions {
|
|
747
|
+
/** Max records to return (server-side clamped to 1..50, default 10). */
|
|
748
|
+
limit?: number;
|
|
749
|
+
/**
|
|
750
|
+
* Optional sheet filter. Pass a sheet id (from the knowledge document)
|
|
751
|
+
* to restrict the search to that sheet. Omit to search across all
|
|
752
|
+
* sheets in the knowledge.
|
|
753
|
+
*/
|
|
754
|
+
sheetId?: string;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* A single hit from `client.knowledge.search`. `score` is the Atlas
|
|
758
|
+
* vector similarity score (cosine in our setup, so higher is closer).
|
|
759
|
+
* `data` mirrors the underlying record fields (column id -> value).
|
|
760
|
+
*/
|
|
761
|
+
interface PlatformKnowledgeSearchHit {
|
|
762
|
+
id: string;
|
|
763
|
+
knowledgeId: string;
|
|
764
|
+
sheetId: string;
|
|
765
|
+
data: Record<string, unknown>;
|
|
766
|
+
score: number;
|
|
767
|
+
createdAt?: number | string;
|
|
768
|
+
updatedAt?: number | string;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Helplines query params — passed verbatim to Throughline. Loose-typed
|
|
772
|
+
* so the SDK stays compatible with new Throughline query keys without
|
|
773
|
+
* a release. Required by Throughline today: `country_code`. Common
|
|
774
|
+
* optional keys: `topic`, `contact_method`, `limit`.
|
|
775
|
+
*/
|
|
776
|
+
type ThroughlineHelplinesQuery = Record<string, string | number | boolean | undefined>;
|
|
702
777
|
declare class PlatformError extends Error {
|
|
703
778
|
status: number;
|
|
704
779
|
constructor(message: string, status: number);
|
|
@@ -738,8 +813,12 @@ declare class PlatformClient {
|
|
|
738
813
|
*
|
|
739
814
|
* Reads are allowed when the SDK token's org matches the target org,
|
|
740
815
|
* OR when the target org has `publicReadable: true` on the Studio side.
|
|
741
|
-
*
|
|
742
|
-
*
|
|
816
|
+
*
|
|
817
|
+
* Writes target system-owned (handler-managed) knowledge only: the
|
|
818
|
+
* protocol API stamps everything created here `isSystemOwned: true`,
|
|
819
|
+
* which keeps it out of every Studio UI surface — Studio acts as a
|
|
820
|
+
* plain storage + RAG layer for it. UI-managed knowledge cannot be
|
|
821
|
+
* modified through this surface.
|
|
743
822
|
*/
|
|
744
823
|
knowledge: {
|
|
745
824
|
/**
|
|
@@ -753,6 +832,108 @@ declare class PlatformClient {
|
|
|
753
832
|
* publicReadable).
|
|
754
833
|
*/
|
|
755
834
|
get: (id: string) => Promise<PlatformKnowledge>;
|
|
835
|
+
/**
|
|
836
|
+
* Semantic search over a knowledge's records. Studio embeds the
|
|
837
|
+
* query server-side (Gemini gemini-embedding-001) and runs Atlas
|
|
838
|
+
* Vector Search against the `vector_index` on `knowledge_records`.
|
|
839
|
+
*
|
|
840
|
+
* Same read access rules as `get` — same-org or publicReadable.
|
|
841
|
+
*
|
|
842
|
+
* Returns an empty array (not an error) when the Atlas index is
|
|
843
|
+
* absent or when nothing matches, so handler code can treat
|
|
844
|
+
* "no hits" and "RAG not configured yet" identically.
|
|
845
|
+
*/
|
|
846
|
+
search: (id: string, query: string, options?: KnowledgeSearchOptions) => Promise<PlatformKnowledgeSearchHit[]>;
|
|
847
|
+
/**
|
|
848
|
+
* Turn semantic search on or off for a knowledge.
|
|
849
|
+
*
|
|
850
|
+
* Writes are strictly same-org — `publicReadable` does NOT confer
|
|
851
|
+
* write access. Flipping `false -> true` schedules a background
|
|
852
|
+
* backfill of existing records on the Studio side; this call
|
|
853
|
+
* returns as soon as the flag is persisted, not when the backfill
|
|
854
|
+
* finishes.
|
|
855
|
+
*
|
|
856
|
+
* Idempotent: setting the flag to its current value is a no-op
|
|
857
|
+
* (`backfillTriggered` will be `false`).
|
|
858
|
+
*/
|
|
859
|
+
setRagEnabled: (id: string, enabled: boolean) => Promise<{
|
|
860
|
+
id: string;
|
|
861
|
+
ragEnabled: boolean;
|
|
862
|
+
backfillTriggered: boolean;
|
|
863
|
+
}>;
|
|
864
|
+
/**
|
|
865
|
+
* Create a system-owned database knowledge under the token's org.
|
|
866
|
+
*
|
|
867
|
+
* 409 (surfaced as an error) means a knowledge of the same name
|
|
868
|
+
* already exists in the org. Idempotent callers should recover by
|
|
869
|
+
* listing with `includeSystemOwned: true` and matching on name.
|
|
870
|
+
*/
|
|
871
|
+
create: (name: string, sheets: CreateKnowledgeSheet[], options?: CreateKnowledgeOptions) => Promise<PlatformKnowledge>;
|
|
872
|
+
/**
|
|
873
|
+
* Delete a system-owned knowledge and all of its records.
|
|
874
|
+
* Refused (403) for UI-managed knowledge.
|
|
875
|
+
*/
|
|
876
|
+
delete: (id: string) => Promise<{
|
|
877
|
+
deletedRecords: number;
|
|
878
|
+
}>;
|
|
879
|
+
/**
|
|
880
|
+
* Append one record to a sheet. Embeds async when ragEnabled.
|
|
881
|
+
*/
|
|
882
|
+
addRecord: (id: string, sheetId: string, data: Record<string, unknown>) => Promise<PlatformKnowledgeRecord>;
|
|
883
|
+
/**
|
|
884
|
+
* Replace a record's data payload. Re-embeds async when ragEnabled.
|
|
885
|
+
*/
|
|
886
|
+
updateRecord: (id: string, recordId: string, data: Record<string, unknown>) => Promise<PlatformKnowledgeRecord>;
|
|
887
|
+
/** Delete one record. */
|
|
888
|
+
deleteRecord: (id: string, recordId: string) => Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Bulk-insert records into one sheet (each array entry becomes one
|
|
891
|
+
* record's `data`). With `replace: true` the sheet's existing
|
|
892
|
+
* records are deleted first — the full-resync primitive backfills
|
|
893
|
+
* use. Server caps a single call at 5000 records.
|
|
894
|
+
*/
|
|
895
|
+
bulkRecords: (id: string, sheetId: string, records: Array<Record<string, unknown>>, options?: {
|
|
896
|
+
replace?: boolean;
|
|
897
|
+
}) => Promise<{
|
|
898
|
+
insertedCount: number;
|
|
899
|
+
deletedCount: number;
|
|
900
|
+
}>;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Throughline (find-a-helpline) surface.
|
|
904
|
+
*
|
|
905
|
+
* Handlers used to call api.throughlinecare.com directly, which meant
|
|
906
|
+
* each handler had to hold OAuth client credentials and re-implement
|
|
907
|
+
* token caching. Studio holds the per-org credentials on
|
|
908
|
+
* `Organization.throughline.{clientId,clientSecret}` and proxies the
|
|
909
|
+
* Throughline endpoints; the SDK token identifies the org server-side
|
|
910
|
+
* so callers never see the secret.
|
|
911
|
+
*
|
|
912
|
+
* Responses are returned as parsed JSON. Studio does not reshape the
|
|
913
|
+
* Throughline body — these surfaces stay compatible with future
|
|
914
|
+
* Throughline API additions without a Studio or SDK release.
|
|
915
|
+
*
|
|
916
|
+
* Caching (24h on countries + topics, none on helplines) is server-
|
|
917
|
+
* side; the SDK is stateless.
|
|
918
|
+
*/
|
|
919
|
+
throughline: {
|
|
920
|
+
/**
|
|
921
|
+
* GET /v1/countries — Throughline's country catalog (codes,
|
|
922
|
+
* names, emergency numbers). Cached 24h server-side.
|
|
923
|
+
*/
|
|
924
|
+
getCountries: () => Promise<unknown>;
|
|
925
|
+
/**
|
|
926
|
+
* GET /v1/topics — Throughline's topic taxonomy used to filter
|
|
927
|
+
* helpline searches. Cached 24h server-side.
|
|
928
|
+
*/
|
|
929
|
+
getTopics: () => Promise<unknown>;
|
|
930
|
+
/**
|
|
931
|
+
* GET /v1/helplines?country_code=...&topic=...&... — live search,
|
|
932
|
+
* not cached. The query object is forwarded verbatim to Throughline,
|
|
933
|
+
* so any new key Throughline adds will work without an SDK change.
|
|
934
|
+
* Required by Throughline today: `country_code`.
|
|
935
|
+
*/
|
|
936
|
+
getHelplines: (query: ThroughlineHelplinesQuery) => Promise<unknown>;
|
|
756
937
|
};
|
|
757
938
|
}
|
|
758
939
|
/**
|
|
@@ -1027,4 +1208,4 @@ declare class LLMClient {
|
|
|
1027
1208
|
*/
|
|
1028
1209
|
declare function createLLMClient(config: LLMClientConfig): LLMClient;
|
|
1029
1210
|
|
|
1030
|
-
export { AgentTransitionPayload, ChatMessage, type ClassificationResult, type EmergencyPayload, HandoffOfferPayload, HandoffRequestPayload, HandoffReturnPayload, type HelplineCardItem, type HelplineCardPayload, type LLMCacheCreateRequest, type LLMCachedContent, type LLMCandidate, LLMClient, type LLMClientConfig, type LLMContent, LLMError, type LLMGenerateRequest, type LLMGenerateResponse, type LLMGenerationConfig, type LLMPart, type LLMSafetySetting, type LLMUsageMetadata, type ListKnowledgeOptions, MARKER_TYPES, type MarkerType, type PlatformChatbot, PlatformClient, type PlatformClientConfig, PlatformError, type PlatformKnowledge, type PlatformKnowledgeSummary, ProtocolStreamChunk, type ProviderCardItem, type ProviderCardPayload, type ReportCardPayload, type ResourceCardItem, type ResourceCardPayload, RoutingClassificationPayload, type SafetyPlanPayload, type SafetyPlanSection, SchemaDeclarationPayload, type UCPClassifyRequest, type UCPClassifyResponse, UCPClient, type UCPClientConfig, type UCPEndpointConfig, UCPError, type UCPErrorResponse, type UCPInfoResponse, type UCPMessage, classifyWithUCP, createAuthHeader, createLLMClient, createPlatformClient, createRequestSignature, createUCPClient, isValidToken, renderMarkers, streamMetadata, verifyRequestSignature };
|
|
1211
|
+
export { AgentTransitionPayload, ChatMessage, type ClassificationResult, type CreateKnowledgeOptions, type CreateKnowledgeSheet, type EmergencyPayload, HandoffOfferPayload, HandoffRequestPayload, HandoffReturnPayload, type HelplineCardItem, type HelplineCardPayload, type KnowledgeSearchOptions, type LLMCacheCreateRequest, type LLMCachedContent, type LLMCandidate, LLMClient, type LLMClientConfig, type LLMContent, LLMError, type LLMGenerateRequest, type LLMGenerateResponse, type LLMGenerationConfig, type LLMPart, type LLMSafetySetting, type LLMUsageMetadata, type ListKnowledgeOptions, MARKER_TYPES, type MarkerType, type PlatformChatbot, PlatformClient, type PlatformClientConfig, PlatformError, type PlatformKnowledge, type PlatformKnowledgeRecord, type PlatformKnowledgeSearchHit, type PlatformKnowledgeSummary, ProtocolStreamChunk, type ProviderCardItem, type ProviderCardPayload, type ReportCardPayload, type ResourceCardItem, type ResourceCardPayload, RoutingClassificationPayload, type SafetyPlanPayload, type SafetyPlanSection, SchemaDeclarationPayload, type ThroughlineHelplinesQuery, type UCPClassifyRequest, type UCPClassifyResponse, UCPClient, type UCPClientConfig, type UCPEndpointConfig, UCPError, type UCPErrorResponse, type UCPInfoResponse, type UCPMessage, classifyWithUCP, createAuthHeader, createLLMClient, createPlatformClient, createRequestSignature, createUCPClient, isValidToken, renderMarkers, streamMetadata, verifyRequestSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChatMessage, S as SchemaDeclarationPayload, P as ProtocolStreamChunk, A as AgentTransitionPayload, R as RoutingClassificationPayload, H as HandoffRequestPayload, a as HandoffReturnPayload, b as HandoffOfferPayload } from './types-
|
|
2
|
-
export { O as AnalyticsContext, E as ChatbotInfo, F as ClassifierConfig, D as DeploymentInfo, G as FormData, V as FormFieldDefinition, W as FormFieldType, J as FormFieldValue, U as FormSchema, n as HandlerInfo, _ as HandoffContext, f as HandoffInboundContext, $ as HandoffOptions, x as Helpline, w as HelplineResult, v as HelplineSearchOptions, I as IntegrationContext, u as IntegrationResult, Q as InteractionEvent, T as InteractionEventType, t as KnowledgeColumnMetadata, K as KnowledgeContext, s as KnowledgeMetadata, r as KnowledgeResult, L as LoggerContext, m as ProtocolCapabilities, o as ProtocolContext, k as ProtocolError, j as ProtocolFieldValidation, g as ProtocolForm, h as ProtocolFormField, i as ProtocolFormOption, l as ProtocolHandler, X as ProtocolRegistration, c as ProtocolRequest, d as ProtocolResponse, B as RoutingDecision, M as RoutingLog, Y as SchemaAgent, Z as SchemaQuestion, p as SessionContext, N as SessionMetadata, q as SessionState, e as SessionStatus, y as StorageContext, z as StorageSetOptions } from './types-
|
|
1
|
+
import { C as ChatMessage, S as SchemaDeclarationPayload, P as ProtocolStreamChunk, A as AgentTransitionPayload, R as RoutingClassificationPayload, H as HandoffRequestPayload, a as HandoffReturnPayload, b as HandoffOfferPayload } from './types-DYJ44S2E.js';
|
|
2
|
+
export { O as AnalyticsContext, E as ChatbotInfo, F as ClassifierConfig, D as DeploymentInfo, G as FormData, V as FormFieldDefinition, W as FormFieldType, J as FormFieldValue, U as FormSchema, n as HandlerInfo, _ as HandoffContext, f as HandoffInboundContext, $ as HandoffOptions, x as Helpline, w as HelplineResult, v as HelplineSearchOptions, I as IntegrationContext, u as IntegrationResult, Q as InteractionEvent, T as InteractionEventType, t as KnowledgeColumnMetadata, K as KnowledgeContext, s as KnowledgeMetadata, r as KnowledgeResult, L as LoggerContext, m as ProtocolCapabilities, o as ProtocolContext, k as ProtocolError, j as ProtocolFieldValidation, g as ProtocolForm, h as ProtocolFormField, i as ProtocolFormOption, l as ProtocolHandler, X as ProtocolRegistration, c as ProtocolRequest, d as ProtocolResponse, B as RoutingDecision, M as RoutingLog, Y as SchemaAgent, Z as SchemaQuestion, p as SessionContext, N as SessionMetadata, q as SessionState, e as SessionStatus, y as StorageContext, z as StorageSetOptions } from './types-DYJ44S2E.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* UCP (Universal Classification Protocol) Types
|
|
@@ -680,6 +680,14 @@ interface PlatformKnowledgeSummary {
|
|
|
680
680
|
type?: string;
|
|
681
681
|
/** Owning organization ID */
|
|
682
682
|
organizationId: string;
|
|
683
|
+
/**
|
|
684
|
+
* True for handler-managed documents created through the protocol
|
|
685
|
+
* write API. System-owned knowledge is hidden from every Studio UI
|
|
686
|
+
* surface and only appears in `list` when `includeSystemOwned` is set.
|
|
687
|
+
*/
|
|
688
|
+
isSystemOwned?: boolean;
|
|
689
|
+
/** Whether semantic search (record embedding) is enabled. */
|
|
690
|
+
ragEnabled?: boolean;
|
|
683
691
|
/** Timestamps */
|
|
684
692
|
createdAt?: number | string;
|
|
685
693
|
updatedAt?: number | string;
|
|
@@ -698,7 +706,74 @@ interface ListKnowledgeOptions {
|
|
|
698
706
|
* `publicReadable` in Studio).
|
|
699
707
|
*/
|
|
700
708
|
orgId?: string;
|
|
709
|
+
/**
|
|
710
|
+
* Include system-owned (handler-managed) knowledge in the listing.
|
|
711
|
+
* Only honored when listing the token's own org; other orgs never
|
|
712
|
+
* expose their system-owned documents.
|
|
713
|
+
*/
|
|
714
|
+
includeSystemOwned?: boolean;
|
|
701
715
|
}
|
|
716
|
+
/** Sheet definition for `knowledge.create`. */
|
|
717
|
+
interface CreateKnowledgeSheet {
|
|
718
|
+
/** Stable sheet id, referenced later by record writes and search. */
|
|
719
|
+
id: string;
|
|
720
|
+
name: string;
|
|
721
|
+
description?: string;
|
|
722
|
+
/**
|
|
723
|
+
* Column definitions ({ id, name, type, ... }). Loose-typed; the
|
|
724
|
+
* Studio schema validates `type` against its column-type enum.
|
|
725
|
+
*/
|
|
726
|
+
columns?: Array<Record<string, unknown>>;
|
|
727
|
+
}
|
|
728
|
+
interface CreateKnowledgeOptions {
|
|
729
|
+
description?: string;
|
|
730
|
+
/**
|
|
731
|
+
* Enable semantic search at creation time. Defaults to false; can be
|
|
732
|
+
* flipped later with `setRagEnabled` (which also backfills embeddings
|
|
733
|
+
* for records inserted while the flag was off).
|
|
734
|
+
*/
|
|
735
|
+
ragEnabled?: boolean;
|
|
736
|
+
}
|
|
737
|
+
/** A raw record as returned by the protocol record-write endpoints. */
|
|
738
|
+
interface PlatformKnowledgeRecord {
|
|
739
|
+
id: string;
|
|
740
|
+
knowledgeId: string;
|
|
741
|
+
sheetId: string;
|
|
742
|
+
data: Record<string, unknown>;
|
|
743
|
+
createdAt?: number | string;
|
|
744
|
+
updatedAt?: number | string;
|
|
745
|
+
}
|
|
746
|
+
interface KnowledgeSearchOptions {
|
|
747
|
+
/** Max records to return (server-side clamped to 1..50, default 10). */
|
|
748
|
+
limit?: number;
|
|
749
|
+
/**
|
|
750
|
+
* Optional sheet filter. Pass a sheet id (from the knowledge document)
|
|
751
|
+
* to restrict the search to that sheet. Omit to search across all
|
|
752
|
+
* sheets in the knowledge.
|
|
753
|
+
*/
|
|
754
|
+
sheetId?: string;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* A single hit from `client.knowledge.search`. `score` is the Atlas
|
|
758
|
+
* vector similarity score (cosine in our setup, so higher is closer).
|
|
759
|
+
* `data` mirrors the underlying record fields (column id -> value).
|
|
760
|
+
*/
|
|
761
|
+
interface PlatformKnowledgeSearchHit {
|
|
762
|
+
id: string;
|
|
763
|
+
knowledgeId: string;
|
|
764
|
+
sheetId: string;
|
|
765
|
+
data: Record<string, unknown>;
|
|
766
|
+
score: number;
|
|
767
|
+
createdAt?: number | string;
|
|
768
|
+
updatedAt?: number | string;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Helplines query params — passed verbatim to Throughline. Loose-typed
|
|
772
|
+
* so the SDK stays compatible with new Throughline query keys without
|
|
773
|
+
* a release. Required by Throughline today: `country_code`. Common
|
|
774
|
+
* optional keys: `topic`, `contact_method`, `limit`.
|
|
775
|
+
*/
|
|
776
|
+
type ThroughlineHelplinesQuery = Record<string, string | number | boolean | undefined>;
|
|
702
777
|
declare class PlatformError extends Error {
|
|
703
778
|
status: number;
|
|
704
779
|
constructor(message: string, status: number);
|
|
@@ -738,8 +813,12 @@ declare class PlatformClient {
|
|
|
738
813
|
*
|
|
739
814
|
* Reads are allowed when the SDK token's org matches the target org,
|
|
740
815
|
* OR when the target org has `publicReadable: true` on the Studio side.
|
|
741
|
-
*
|
|
742
|
-
*
|
|
816
|
+
*
|
|
817
|
+
* Writes target system-owned (handler-managed) knowledge only: the
|
|
818
|
+
* protocol API stamps everything created here `isSystemOwned: true`,
|
|
819
|
+
* which keeps it out of every Studio UI surface — Studio acts as a
|
|
820
|
+
* plain storage + RAG layer for it. UI-managed knowledge cannot be
|
|
821
|
+
* modified through this surface.
|
|
743
822
|
*/
|
|
744
823
|
knowledge: {
|
|
745
824
|
/**
|
|
@@ -753,6 +832,108 @@ declare class PlatformClient {
|
|
|
753
832
|
* publicReadable).
|
|
754
833
|
*/
|
|
755
834
|
get: (id: string) => Promise<PlatformKnowledge>;
|
|
835
|
+
/**
|
|
836
|
+
* Semantic search over a knowledge's records. Studio embeds the
|
|
837
|
+
* query server-side (Gemini gemini-embedding-001) and runs Atlas
|
|
838
|
+
* Vector Search against the `vector_index` on `knowledge_records`.
|
|
839
|
+
*
|
|
840
|
+
* Same read access rules as `get` — same-org or publicReadable.
|
|
841
|
+
*
|
|
842
|
+
* Returns an empty array (not an error) when the Atlas index is
|
|
843
|
+
* absent or when nothing matches, so handler code can treat
|
|
844
|
+
* "no hits" and "RAG not configured yet" identically.
|
|
845
|
+
*/
|
|
846
|
+
search: (id: string, query: string, options?: KnowledgeSearchOptions) => Promise<PlatformKnowledgeSearchHit[]>;
|
|
847
|
+
/**
|
|
848
|
+
* Turn semantic search on or off for a knowledge.
|
|
849
|
+
*
|
|
850
|
+
* Writes are strictly same-org — `publicReadable` does NOT confer
|
|
851
|
+
* write access. Flipping `false -> true` schedules a background
|
|
852
|
+
* backfill of existing records on the Studio side; this call
|
|
853
|
+
* returns as soon as the flag is persisted, not when the backfill
|
|
854
|
+
* finishes.
|
|
855
|
+
*
|
|
856
|
+
* Idempotent: setting the flag to its current value is a no-op
|
|
857
|
+
* (`backfillTriggered` will be `false`).
|
|
858
|
+
*/
|
|
859
|
+
setRagEnabled: (id: string, enabled: boolean) => Promise<{
|
|
860
|
+
id: string;
|
|
861
|
+
ragEnabled: boolean;
|
|
862
|
+
backfillTriggered: boolean;
|
|
863
|
+
}>;
|
|
864
|
+
/**
|
|
865
|
+
* Create a system-owned database knowledge under the token's org.
|
|
866
|
+
*
|
|
867
|
+
* 409 (surfaced as an error) means a knowledge of the same name
|
|
868
|
+
* already exists in the org. Idempotent callers should recover by
|
|
869
|
+
* listing with `includeSystemOwned: true` and matching on name.
|
|
870
|
+
*/
|
|
871
|
+
create: (name: string, sheets: CreateKnowledgeSheet[], options?: CreateKnowledgeOptions) => Promise<PlatformKnowledge>;
|
|
872
|
+
/**
|
|
873
|
+
* Delete a system-owned knowledge and all of its records.
|
|
874
|
+
* Refused (403) for UI-managed knowledge.
|
|
875
|
+
*/
|
|
876
|
+
delete: (id: string) => Promise<{
|
|
877
|
+
deletedRecords: number;
|
|
878
|
+
}>;
|
|
879
|
+
/**
|
|
880
|
+
* Append one record to a sheet. Embeds async when ragEnabled.
|
|
881
|
+
*/
|
|
882
|
+
addRecord: (id: string, sheetId: string, data: Record<string, unknown>) => Promise<PlatformKnowledgeRecord>;
|
|
883
|
+
/**
|
|
884
|
+
* Replace a record's data payload. Re-embeds async when ragEnabled.
|
|
885
|
+
*/
|
|
886
|
+
updateRecord: (id: string, recordId: string, data: Record<string, unknown>) => Promise<PlatformKnowledgeRecord>;
|
|
887
|
+
/** Delete one record. */
|
|
888
|
+
deleteRecord: (id: string, recordId: string) => Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Bulk-insert records into one sheet (each array entry becomes one
|
|
891
|
+
* record's `data`). With `replace: true` the sheet's existing
|
|
892
|
+
* records are deleted first — the full-resync primitive backfills
|
|
893
|
+
* use. Server caps a single call at 5000 records.
|
|
894
|
+
*/
|
|
895
|
+
bulkRecords: (id: string, sheetId: string, records: Array<Record<string, unknown>>, options?: {
|
|
896
|
+
replace?: boolean;
|
|
897
|
+
}) => Promise<{
|
|
898
|
+
insertedCount: number;
|
|
899
|
+
deletedCount: number;
|
|
900
|
+
}>;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Throughline (find-a-helpline) surface.
|
|
904
|
+
*
|
|
905
|
+
* Handlers used to call api.throughlinecare.com directly, which meant
|
|
906
|
+
* each handler had to hold OAuth client credentials and re-implement
|
|
907
|
+
* token caching. Studio holds the per-org credentials on
|
|
908
|
+
* `Organization.throughline.{clientId,clientSecret}` and proxies the
|
|
909
|
+
* Throughline endpoints; the SDK token identifies the org server-side
|
|
910
|
+
* so callers never see the secret.
|
|
911
|
+
*
|
|
912
|
+
* Responses are returned as parsed JSON. Studio does not reshape the
|
|
913
|
+
* Throughline body — these surfaces stay compatible with future
|
|
914
|
+
* Throughline API additions without a Studio or SDK release.
|
|
915
|
+
*
|
|
916
|
+
* Caching (24h on countries + topics, none on helplines) is server-
|
|
917
|
+
* side; the SDK is stateless.
|
|
918
|
+
*/
|
|
919
|
+
throughline: {
|
|
920
|
+
/**
|
|
921
|
+
* GET /v1/countries — Throughline's country catalog (codes,
|
|
922
|
+
* names, emergency numbers). Cached 24h server-side.
|
|
923
|
+
*/
|
|
924
|
+
getCountries: () => Promise<unknown>;
|
|
925
|
+
/**
|
|
926
|
+
* GET /v1/topics — Throughline's topic taxonomy used to filter
|
|
927
|
+
* helpline searches. Cached 24h server-side.
|
|
928
|
+
*/
|
|
929
|
+
getTopics: () => Promise<unknown>;
|
|
930
|
+
/**
|
|
931
|
+
* GET /v1/helplines?country_code=...&topic=...&... — live search,
|
|
932
|
+
* not cached. The query object is forwarded verbatim to Throughline,
|
|
933
|
+
* so any new key Throughline adds will work without an SDK change.
|
|
934
|
+
* Required by Throughline today: `country_code`.
|
|
935
|
+
*/
|
|
936
|
+
getHelplines: (query: ThroughlineHelplinesQuery) => Promise<unknown>;
|
|
756
937
|
};
|
|
757
938
|
}
|
|
758
939
|
/**
|
|
@@ -1027,4 +1208,4 @@ declare class LLMClient {
|
|
|
1027
1208
|
*/
|
|
1028
1209
|
declare function createLLMClient(config: LLMClientConfig): LLMClient;
|
|
1029
1210
|
|
|
1030
|
-
export { AgentTransitionPayload, ChatMessage, type ClassificationResult, type EmergencyPayload, HandoffOfferPayload, HandoffRequestPayload, HandoffReturnPayload, type HelplineCardItem, type HelplineCardPayload, type LLMCacheCreateRequest, type LLMCachedContent, type LLMCandidate, LLMClient, type LLMClientConfig, type LLMContent, LLMError, type LLMGenerateRequest, type LLMGenerateResponse, type LLMGenerationConfig, type LLMPart, type LLMSafetySetting, type LLMUsageMetadata, type ListKnowledgeOptions, MARKER_TYPES, type MarkerType, type PlatformChatbot, PlatformClient, type PlatformClientConfig, PlatformError, type PlatformKnowledge, type PlatformKnowledgeSummary, ProtocolStreamChunk, type ProviderCardItem, type ProviderCardPayload, type ReportCardPayload, type ResourceCardItem, type ResourceCardPayload, RoutingClassificationPayload, type SafetyPlanPayload, type SafetyPlanSection, SchemaDeclarationPayload, type UCPClassifyRequest, type UCPClassifyResponse, UCPClient, type UCPClientConfig, type UCPEndpointConfig, UCPError, type UCPErrorResponse, type UCPInfoResponse, type UCPMessage, classifyWithUCP, createAuthHeader, createLLMClient, createPlatformClient, createRequestSignature, createUCPClient, isValidToken, renderMarkers, streamMetadata, verifyRequestSignature };
|
|
1211
|
+
export { AgentTransitionPayload, ChatMessage, type ClassificationResult, type CreateKnowledgeOptions, type CreateKnowledgeSheet, type EmergencyPayload, HandoffOfferPayload, HandoffRequestPayload, HandoffReturnPayload, type HelplineCardItem, type HelplineCardPayload, type KnowledgeSearchOptions, type LLMCacheCreateRequest, type LLMCachedContent, type LLMCandidate, LLMClient, type LLMClientConfig, type LLMContent, LLMError, type LLMGenerateRequest, type LLMGenerateResponse, type LLMGenerationConfig, type LLMPart, type LLMSafetySetting, type LLMUsageMetadata, type ListKnowledgeOptions, MARKER_TYPES, type MarkerType, type PlatformChatbot, PlatformClient, type PlatformClientConfig, PlatformError, type PlatformKnowledge, type PlatformKnowledgeRecord, type PlatformKnowledgeSearchHit, type PlatformKnowledgeSummary, ProtocolStreamChunk, type ProviderCardItem, type ProviderCardPayload, type ReportCardPayload, type ResourceCardItem, type ResourceCardPayload, RoutingClassificationPayload, type SafetyPlanPayload, type SafetyPlanSection, SchemaDeclarationPayload, type ThroughlineHelplinesQuery, type UCPClassifyRequest, type UCPClassifyResponse, UCPClient, type UCPClientConfig, type UCPEndpointConfig, UCPError, type UCPErrorResponse, type UCPInfoResponse, type UCPMessage, classifyWithUCP, createAuthHeader, createLLMClient, createPlatformClient, createRequestSignature, createUCPClient, isValidToken, renderMarkers, streamMetadata, verifyRequestSignature };
|