@stacklink/sdk 0.2.2 → 0.3.8

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 (37) hide show
  1. package/README.md +50 -1
  2. package/compatibility.json +3 -1
  3. package/dist/src/domain/bot-contract.d.ts +4336 -0
  4. package/dist/src/domain/bot-contract.d.ts.map +1 -0
  5. package/dist/src/domain/bot-contract.js +382 -0
  6. package/dist/src/domain/bot-contract.js.map +1 -0
  7. package/dist/src/domain/memory-contract.d.ts +452 -452
  8. package/dist/src/domain/memory-contract.js +1 -1
  9. package/dist/src/domain/memory-contract.js.map +1 -1
  10. package/dist/src/domain/platform-approval-contract.d.ts +508 -0
  11. package/dist/src/domain/platform-approval-contract.d.ts.map +1 -0
  12. package/dist/src/domain/platform-approval-contract.js +77 -0
  13. package/dist/src/domain/platform-approval-contract.js.map +1 -0
  14. package/dist/src/domain/provider-branding.d.ts.map +1 -1
  15. package/dist/src/domain/provider-branding.js +17 -0
  16. package/dist/src/domain/provider-branding.js.map +1 -1
  17. package/dist/src/domain/stacklink-meta-tools.d.ts +2 -2
  18. package/dist/src/domain/stacklink-meta-tools.d.ts.map +1 -1
  19. package/dist/src/domain/stacklink-meta-tools.js +15 -4
  20. package/dist/src/domain/stacklink-meta-tools.js.map +1 -1
  21. package/dist/src/sdk/framework-tools.d.ts +21 -0
  22. package/dist/src/sdk/framework-tools.d.ts.map +1 -1
  23. package/dist/src/sdk/framework-tools.js +49 -0
  24. package/dist/src/sdk/framework-tools.js.map +1 -1
  25. package/dist/src/sdk/index.d.ts +225 -6
  26. package/dist/src/sdk/index.d.ts.map +1 -1
  27. package/dist/src/sdk/index.js +215 -21
  28. package/dist/src/sdk/index.js.map +1 -1
  29. package/dist/src/sdk/vercel-ai.d.ts +4 -0
  30. package/dist/src/sdk/vercel-ai.d.ts.map +1 -1
  31. package/dist/src/sdk/vercel-ai.js +13 -4
  32. package/dist/src/sdk/vercel-ai.js.map +1 -1
  33. package/dist/src/sdk/x-chat.d.ts +143 -0
  34. package/dist/src/sdk/x-chat.d.ts.map +1 -0
  35. package/dist/src/sdk/x-chat.js +160 -0
  36. package/dist/src/sdk/x-chat.js.map +1 -0
  37. package/package.json +15 -3
@@ -1,3 +1,7 @@
1
+ import type { Bot, BotPatch, BotRun, BotRunInput, PublishChannels, SavedBotApi, ContextApi, BotApiSigningKey, BotApiSigningKeyRequest } from '../domain/bot-contract.js';
2
+ import type { ApprovalRecord, ApprovalDecision, ApprovalChange, ApprovalListResponse, ApprovalListQuery, CustomerApprovalGrantInput, CustomerApprovalGrantResponse } from '../domain/platform-approval-contract.js';
3
+ export type { ApprovalRecord, ApprovalDecision, ApprovalChange, ApprovalListResponse, ApprovalAudience, ApprovalRequirement, CustomerApprovalGrantInput, CustomerApprovalGrantResponse } from '../domain/platform-approval-contract.js';
4
+ export type { Bot, BotPatch, BotRun, BotRunInput, PublishChannels, SavedBotApi, ContextApi, BotApiSigningKey, BotApiSigningKeyRequest, BotTrigger, BotPreparation, BotRunDisplay, BotReadinessIssue } from '../domain/bot-contract.js';
1
5
  import { type StacklinkMetaToolName } from '../domain/stacklink-meta-tools.js';
2
6
  import type { ProviderBrandDescriptor } from '../domain/provider-branding.js';
3
7
  import type { MemoryContextInput, MemoryConversationTurnInput, MemoryConnectedSourceInput, MemoryConnectedSourcePreviewInput, MemoryExportInput, MemoryGraphQueryInput, MemoryIngestInput, MemoryRichIngestInput, MemoryLegalHoldInput, MemoryPolicyPreviewInput, MemoryProjectPolicyInput, MemoryProjectPolicyUpdateInput, MemorySearchInput, MemorySourceBindingInput, MemorySourceBindingUpdateInput, MemorySourceRemovalInput, MemorySubjectRef } from '../domain/memory-contract.js';
@@ -8,7 +12,7 @@ export type { StacklinkMemoryAvailabilityMode, StacklinkMemoryCaptureController,
8
12
  export type StacklinkFetch = typeof fetch;
9
13
  export type StacklinkMcpToolName = StacklinkMetaToolName;
10
14
  export type StacklinkToolSurfaceName = StacklinkMcpToolName | (string & {});
11
- export declare const stacklinkTypeScriptSdkVersion = "0.2.2";
15
+ export declare const stacklinkTypeScriptSdkVersion = "0.3.8";
12
16
  export declare class StacklinkApiError extends Error {
13
17
  readonly statusCode: number;
14
18
  readonly code?: string | undefined;
@@ -92,12 +96,14 @@ export interface StacklinkProviderOperation {
92
96
  transport: 'rest' | 'graphql' | 'sdk' | 'local' | 'mcp';
93
97
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | undefined;
94
98
  path?: string | undefined;
99
+ credentialProfileKey?: string | undefined;
95
100
  graphqlOperationName?: string | undefined;
96
101
  docsUrl?: string | undefined;
97
- source: 'official_openapi' | 'official_docs' | 'hand_authored';
102
+ source: 'official_openapi' | 'official_google_discovery' | 'authenticated_mcp_tools' | 'official_docs' | 'hand_authored';
98
103
  }
99
104
  export interface StacklinkToolAuthPolicy {
100
105
  connectionRequired: boolean;
106
+ credentialProfileKey?: string | undefined;
101
107
  scopeRequirements: Array<{
102
108
  all?: string[] | undefined;
103
109
  any?: string[] | undefined;
@@ -169,12 +175,15 @@ export interface ProviderRuntime {
169
175
  owner: ProviderRuntimeOwner;
170
176
  label: string;
171
177
  mcp?: {
172
- endpointUrl: string;
178
+ defaultEndpointKey: string;
179
+ endpoints: Record<string, {
180
+ endpointUrl: string;
181
+ sourceUrl: string;
182
+ }>;
173
183
  transport: ProviderMcpTransport;
174
184
  auth: {
175
185
  type: ProviderMcpAuthType;
176
186
  };
177
- sourceUrl: string;
178
187
  importPolicy: ProviderMcpImportPolicy;
179
188
  allowlisted: boolean;
180
189
  identity?: {
@@ -609,7 +618,7 @@ export interface CreateTriggerSubscriptionInput {
609
618
  tenantId: string;
610
619
  accountId?: string | undefined;
611
620
  triggerTypeId: string;
612
- deliveryMode?: 'webhook' | 'polling' | undefined;
621
+ deliveryMode?: 'webhook' | 'polling' | 'stream' | undefined;
613
622
  config?: Record<string, unknown> | undefined;
614
623
  idempotencyKey?: string | undefined;
615
624
  }
@@ -912,7 +921,7 @@ export interface WorkbenchRuntimeDiagnostics {
912
921
  exitCode?: number | undefined;
913
922
  error?: unknown;
914
923
  }
915
- export type WorkbenchExecutionStatus = 'queued' | 'started' | 'running' | 'cancel_requested' | 'completed' | 'failed' | 'cancelled' | 'timed_out';
924
+ export type WorkbenchExecutionStatus = 'waiting_for_approval' | 'queued' | 'started' | 'running' | 'cancel_requested' | 'completed' | 'failed' | 'cancelled' | 'timed_out';
916
925
  export interface WorkbenchExecutionLog {
917
926
  id: string;
918
927
  executionId?: string | undefined;
@@ -1003,6 +1012,9 @@ export interface WorkbenchOutputPreview {
1003
1012
  preview: string;
1004
1013
  }
1005
1014
  export interface WorkbenchExecutionResponse {
1015
+ approvalRequestId?: string | undefined;
1016
+ executed?: boolean | undefined;
1017
+ nextAction?: 'wait_for_approval' | undefined;
1006
1018
  workbenchSession: WorkbenchSession;
1007
1019
  executionKind: 'workbench_code' | 'workbench_bash';
1008
1020
  executionId: string;
@@ -1338,6 +1350,12 @@ export interface StacklinkAgentSearchResponse {
1338
1350
  capability: string;
1339
1351
  risk: string;
1340
1352
  connectionStatus: string;
1353
+ credentialProfile?: {
1354
+ key: string;
1355
+ status: 'available' | 'required';
1356
+ eligibleAccountIds: string[];
1357
+ missingAccountIds: string[];
1358
+ } | undefined;
1341
1359
  contractRef?: string | undefined;
1342
1360
  }>;
1343
1361
  nextAction?: {
@@ -1941,6 +1959,33 @@ export interface GstNoticeRuleResponse extends GstRateLookupResponse {
1941
1959
  export interface GstAppealStageRuleResponse extends GstRateLookupResponse {
1942
1960
  }
1943
1961
  export declare function verifyWebhookSignature(input: StacklinkWebhookSignatureInput): Promise<boolean>;
1962
+ /** Sign the exact JSON bytes sent to a saved inbound Bot webhook. Reuse requestId when retrying. */
1963
+ export declare function signBotTriggerRequest(input: {
1964
+ triggerId: string;
1965
+ secret: string;
1966
+ body: string;
1967
+ requestId?: string;
1968
+ now?: Date;
1969
+ }): Promise<Record<string, string>>;
1970
+ /** Verify the original request bytes before using identity. consumeRequestId must atomically reject replays. */
1971
+ export declare function verifyBotApiRequest(input: {
1972
+ method: string;
1973
+ url: string;
1974
+ body: string;
1975
+ headers: ConstructorParameters<typeof Headers>[0];
1976
+ projectId: string;
1977
+ keys: Record<string, string | {
1978
+ secret: string;
1979
+ validUntil: string | null;
1980
+ }>;
1981
+ consumeRequestId: (id: string, expiresAt: Date) => boolean | Promise<boolean>;
1982
+ now?: Date;
1983
+ toleranceSeconds?: number;
1984
+ }): Promise<{
1985
+ tenantId: string;
1986
+ userId: string | null;
1987
+ requestId: string;
1988
+ } | null>;
1944
1989
  export declare class Stacklink {
1945
1990
  private readonly apiKey;
1946
1991
  private readonly registrationKey;
@@ -1951,6 +1996,8 @@ export declare class Stacklink {
1951
1996
  private readonly discoveryRequests;
1952
1997
  private readonly timeoutMs;
1953
1998
  private readonly maxAttempts;
1999
+ readonly bots: StacklinkBotsClient;
2000
+ readonly approvals: StacklinkApprovalsClient;
1954
2001
  readonly webhooks: StacklinkWebhooksClient;
1955
2002
  readonly triggers: StacklinkTriggersClient;
1956
2003
  readonly sessions: StacklinkSessionsClient;
@@ -2376,6 +2423,14 @@ export declare class Stacklink {
2376
2423
  hasMore: boolean;
2377
2424
  nextCursor: string | null;
2378
2425
  }>;
2426
+ streamBotEvents(botId: string, runId: string, options?: StacklinkRequestOptions & {
2427
+ after?: string;
2428
+ totalTimeoutMs?: number;
2429
+ }): AsyncGenerator<Record<string, unknown> | {
2430
+ sequence: string;
2431
+ type: string;
2432
+ payload: unknown;
2433
+ }, void, unknown>;
2379
2434
  streamExecutionEvents(input: {
2380
2435
  sessionId: string;
2381
2436
  executionKind: StacklinkExecutionKind;
@@ -2419,6 +2474,20 @@ export declare class Stacklink {
2419
2474
  getConnectedAccount(accountId: string): Promise<{
2420
2475
  account: ConnectedAccount;
2421
2476
  }>;
2477
+ setConnectedAccountCredentialProfile(accountId: string, profileKey: string, credentials: Record<string, string>): Promise<{
2478
+ profile: {
2479
+ profileKey: string;
2480
+ version: number;
2481
+ status: string;
2482
+ };
2483
+ }>;
2484
+ removeConnectedAccountCredentialProfile(accountId: string, profileKey: string): Promise<{
2485
+ profile: {
2486
+ profileKey: string;
2487
+ removed: boolean;
2488
+ providerGrantRevoked: boolean;
2489
+ };
2490
+ }>;
2422
2491
  listConnectedAccountTools(accountId: string, input: {
2423
2492
  includePlanned?: boolean | undefined;
2424
2493
  toolKeys: string[];
@@ -2935,6 +3004,45 @@ export declare class StacklinkMemoryClient {
2935
3004
  createLegalHold(input: MemoryLegalHoldInput): Promise<JsonRecord>;
2936
3005
  releaseLegalHold(holdId: string): Promise<JsonRecord>;
2937
3006
  }
3007
+ export interface StacklinkApprovalAccess {
3008
+ sessionId: string;
3009
+ asCustomer?: boolean;
3010
+ }
3011
+ export interface StacklinkApprovalEvent {
3012
+ sequence: string;
3013
+ approvalId: string;
3014
+ type: 'approval.request.updated';
3015
+ data: {
3016
+ revision: number;
3017
+ status: string;
3018
+ requirements: unknown[];
3019
+ denialReason: string | null;
3020
+ };
3021
+ occurredAt: string;
3022
+ }
3023
+ export declare class StacklinkApprovalsClient {
3024
+ private readonly client;
3025
+ constructor(client: Stacklink);
3026
+ /** Server-only access. Identity comes from the authenticated application session. */
3027
+ getCustomerGrant(sessionId: string): Promise<CustomerApprovalGrantResponse>;
3028
+ saveCustomerGrant(sessionId: string, grant: CustomerApprovalGrantInput): Promise<CustomerApprovalGrantResponse>;
3029
+ removeCustomerGrant(sessionId: string, revision: number): Promise<CustomerApprovalGrantResponse>;
3030
+ list(input: StacklinkApprovalAccess & Partial<ApprovalListQuery>): Promise<ApprovalListResponse>;
3031
+ get(id: string, access: StacklinkApprovalAccess): Promise<ApprovalRecord>;
3032
+ /** Decide only after displaying the exact proposal and checking permissions. Never resubmit the original action. */
3033
+ decide(id: string, access: StacklinkApprovalAccess, decision: ApprovalDecision): Promise<ApprovalRecord>;
3034
+ change(id: string, access: StacklinkApprovalAccess, change: ApprovalChange): Promise<ApprovalRecord>;
3035
+ events(access: StacklinkApprovalAccess, after?: string, options?: StacklinkRequestOptions): Promise<{
3036
+ events: StacklinkApprovalEvent[];
3037
+ nextCursor: string;
3038
+ }>;
3039
+ /** Durable cursor observation. Save each sequence and pass it as `after` when reconnecting. */
3040
+ observe(access: StacklinkApprovalAccess, options?: {
3041
+ after?: string;
3042
+ signal?: AbortSignal;
3043
+ timeoutMs?: number;
3044
+ }): AsyncGenerator<StacklinkApprovalEvent>;
3045
+ }
2938
3046
  export declare class StacklinkSessionsClient {
2939
3047
  private readonly client;
2940
3048
  constructor(client: Stacklink);
@@ -3578,4 +3686,115 @@ export declare class StacklinkConnectionRequest {
3578
3686
  };
3579
3687
  waitForConnection(timeoutMs?: number, intervalMs?: number): Promise<ConnectedAccount | undefined>;
3580
3688
  }
3689
+ /** Hosted bots share durable runs across the API, MCP and dashboard. */
3690
+ export declare class StacklinkBotsClient {
3691
+ private readonly client;
3692
+ constructor(client: Stacklink);
3693
+ apis(): Promise<{
3694
+ apis: SavedBotApi[];
3695
+ }>;
3696
+ updateApi(apiId: string, revision: number, api: ContextApi): Promise<SavedBotApi>;
3697
+ deleteApi(apiId: string): Promise<{
3698
+ deleted: boolean;
3699
+ }>;
3700
+ webhookSecret(botId: string): Promise<{
3701
+ signingSecret: string;
3702
+ }>;
3703
+ triggerWebhook(botId: string, triggerId: string): Promise<{
3704
+ url: string;
3705
+ signingSecret: string;
3706
+ signatureVersion: string;
3707
+ maxAgeSeconds: number;
3708
+ }>;
3709
+ triggerAdmission(botId: string, triggerId: string, admissionId: string): Promise<{
3710
+ admissionId: string;
3711
+ status: string;
3712
+ runId: string | null;
3713
+ result: unknown;
3714
+ error: unknown;
3715
+ }>;
3716
+ apiSigningKey(botId: string, apiId: string, request?: BotApiSigningKeyRequest): Promise<BotApiSigningKey>;
3717
+ models(): Promise<{
3718
+ models: import("../domain/bot-contract.js").ModelOption[];
3719
+ defaultModel: string;
3720
+ }>;
3721
+ setCredential(botId: string, secret: string): Promise<{
3722
+ id: string;
3723
+ }>;
3724
+ deliveries(botId: string, runId: string): Promise<{
3725
+ deliveries: Array<{
3726
+ id: string;
3727
+ status: string;
3728
+ attemptCount: number;
3729
+ nextAttemptAt: string | null;
3730
+ failureReason: string | null;
3731
+ }>;
3732
+ }>;
3733
+ retryDelivery(botId: string, runId: string, deliveryId: string): Promise<{
3734
+ queued: boolean;
3735
+ }>;
3736
+ setCustomerCredential(botId: string, input: {
3737
+ apiId: string;
3738
+ sessionId: string;
3739
+ secret: string;
3740
+ }): Promise<{
3741
+ id: string;
3742
+ }>;
3743
+ delete(botId: string): Promise<{
3744
+ deleted: boolean;
3745
+ }>;
3746
+ deleteCustomerData(botId: string, sessionId: string): Promise<{
3747
+ deleted: boolean;
3748
+ conversations: number;
3749
+ knowledgeSources: number;
3750
+ workspaces: number;
3751
+ sharedMemory: "unchanged";
3752
+ sharedApiCredentials: "unchanged";
3753
+ }>;
3754
+ setState(botId: string, input: {
3755
+ state: 'on' | 'paused';
3756
+ pauseFor?: '1h' | 'tomorrow' | 'manual';
3757
+ reason?: string;
3758
+ }): Promise<Bot>;
3759
+ list(): Promise<{
3760
+ bots: Array<{
3761
+ id: string;
3762
+ name: string;
3763
+ status: string;
3764
+ }>;
3765
+ }>;
3766
+ create(name: string): Promise<Bot>;
3767
+ get(botId: string): Promise<Bot>;
3768
+ update(botId: string, revision: number, patch: BotPatch): Promise<Bot>;
3769
+ publish(botId: string, revision: number, channels: PublishChannels): Promise<{
3770
+ botId: string;
3771
+ publishedAt: string;
3772
+ }>;
3773
+ run(botId: string, input: BotRunInput & {
3774
+ sessionId: string;
3775
+ }): Promise<BotRun>;
3776
+ getRun(botId: string, runId: string): Promise<BotRun>;
3777
+ /** Observe the same durable run. Returns when finished or when a person must act. */
3778
+ wait(botId: string, runId: string, options?: {
3779
+ totalTimeoutMs?: number;
3780
+ signal?: AbortSignal;
3781
+ }): Promise<BotRun>;
3782
+ events(botId: string, runId: string, after?: string): Promise<{
3783
+ events: Array<{
3784
+ sequence: string;
3785
+ type: string;
3786
+ payload: unknown;
3787
+ }>;
3788
+ terminal: boolean;
3789
+ }>;
3790
+ stream(botId: string, runId: string, options?: StacklinkRequestOptions & {
3791
+ after?: string;
3792
+ totalTimeoutMs?: number;
3793
+ }): AsyncGenerator<Record<string, unknown> | {
3794
+ sequence: string;
3795
+ type: string;
3796
+ payload: unknown;
3797
+ }, void, unknown>;
3798
+ cancel(botId: string, runId: string): Promise<BotRun>;
3799
+ }
3581
3800
  //# sourceMappingURL=index.d.ts.map