@realtimex/sdk 1.3.6 → 1.3.7-rc.1

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 CHANGED
@@ -41,6 +41,7 @@ interface TriggerAgentResponse {
41
41
  success: boolean;
42
42
  task_uuid?: string;
43
43
  task_id?: string;
44
+ capability_id?: string;
44
45
  event_id?: string;
45
46
  attempt_id?: string;
46
47
  event_type?: ContractEventType | string;
@@ -59,21 +60,72 @@ interface ContractCallbackMetadata {
59
60
  attempt_id_format?: string;
60
61
  idempotency?: string;
61
62
  }
63
+ interface ContractCapabilityTrigger$1 {
64
+ event: string;
65
+ route?: string;
66
+ payload_template?: Record<string, unknown>;
67
+ }
68
+ interface ContractCapability$1 {
69
+ capability_id: string;
70
+ name: string;
71
+ description?: string;
72
+ input_schema: Record<string, unknown>;
73
+ output_schema?: Record<string, unknown>;
74
+ permission?: string;
75
+ trigger?: ContractCapabilityTrigger$1;
76
+ tags?: string[];
77
+ examples?: string[];
78
+ risk_level?: 'low' | 'medium' | 'high' | null;
79
+ enabled?: boolean;
80
+ }
62
81
  interface LocalAppContractDefinition {
63
82
  id: string;
64
83
  version: string;
84
+ strictness?: 'compatible' | 'strict';
65
85
  events: Record<string, ContractEventType>;
66
86
  supported_events: ContractEventType[];
67
87
  supported_legacy_events: string[];
68
88
  aliases: Record<string, ContractEventType>;
69
89
  status_map: Record<string, string>;
70
90
  legacy_action_map: Record<ContractEventType, string>;
91
+ catalog_hash?: string;
92
+ capability_count?: number;
93
+ capabilities?: ContractCapability$1[];
71
94
  callback?: ContractCallbackMetadata;
72
95
  }
73
96
  interface LocalAppContractResponse {
74
97
  success: boolean;
75
98
  contract: LocalAppContractDefinition;
76
99
  }
100
+ interface LocalAppCapabilitiesResponse {
101
+ success: boolean;
102
+ contract_version: string;
103
+ strictness?: 'compatible' | 'strict';
104
+ catalog_hash?: string;
105
+ count: number;
106
+ capabilities: ContractCapability$1[];
107
+ }
108
+ interface LocalAppCapabilitySearchResponse extends LocalAppCapabilitiesResponse {
109
+ query: string;
110
+ }
111
+ interface LocalAppCapabilityDetailResponse {
112
+ success: boolean;
113
+ contract_version: string;
114
+ strictness?: 'compatible' | 'strict';
115
+ catalog_hash?: string;
116
+ capability: ContractCapability$1;
117
+ }
118
+ interface ContractInvokePayload {
119
+ capability_id: string;
120
+ args?: Record<string, unknown>;
121
+ auto_run?: boolean;
122
+ agent_name?: string;
123
+ workspace_slug?: string;
124
+ thread_slug?: string;
125
+ prompt?: string;
126
+ event_id?: string;
127
+ attempt_id?: string | number;
128
+ }
77
129
  interface Agent {
78
130
  slug: string;
79
131
  name: string;
@@ -1170,10 +1222,19 @@ declare class ContractModule {
1170
1222
  private readonly appId?;
1171
1223
  private readonly apiKey?;
1172
1224
  private cachedContract;
1225
+ private cachedCapabilities;
1226
+ private cachedCapabilityCatalogHash;
1173
1227
  constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
1174
1228
  private requestPermission;
1175
1229
  private request;
1176
1230
  getLocalAppV1(forceRefresh?: boolean): Promise<LocalAppContractDefinition>;
1231
+ listCapabilities(forceRefresh?: boolean): Promise<ContractCapability$1[]>;
1232
+ searchCapabilities(query: string): Promise<ContractCapability$1[]>;
1233
+ describeCapability(capabilityId: string): Promise<ContractCapability$1>;
1234
+ search(query: string): Promise<ContractCapability$1[]>;
1235
+ describe(capabilityId: string): Promise<ContractCapability$1>;
1236
+ invoke(payload: ContractInvokePayload): Promise<TriggerAgentResponse>;
1237
+ getCachedCatalogHash(): string | null;
1177
1238
  clearCache(): void;
1178
1239
  }
1179
1240
 
@@ -1825,4 +1886,4 @@ declare class RealtimeXSDK {
1825
1886
  getAppDataDir(): Promise<string>;
1826
1887
  }
1827
1888
 
1828
- export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, AuthModule, type AuthProvider, type AuthTokenResponse, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type DatabaseConfig, DatabaseModule, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type SyncTokenResponse, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
1889
+ export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, AuthModule, type AuthProvider, type AuthTokenResponse, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, type ContractInvokePayload, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type DatabaseConfig, DatabaseModule, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppCapabilitiesResponse, type LocalAppCapabilityDetailResponse, type LocalAppCapabilitySearchResponse, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type SyncTokenResponse, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ interface TriggerAgentResponse {
41
41
  success: boolean;
42
42
  task_uuid?: string;
43
43
  task_id?: string;
44
+ capability_id?: string;
44
45
  event_id?: string;
45
46
  attempt_id?: string;
46
47
  event_type?: ContractEventType | string;
@@ -59,21 +60,72 @@ interface ContractCallbackMetadata {
59
60
  attempt_id_format?: string;
60
61
  idempotency?: string;
61
62
  }
63
+ interface ContractCapabilityTrigger$1 {
64
+ event: string;
65
+ route?: string;
66
+ payload_template?: Record<string, unknown>;
67
+ }
68
+ interface ContractCapability$1 {
69
+ capability_id: string;
70
+ name: string;
71
+ description?: string;
72
+ input_schema: Record<string, unknown>;
73
+ output_schema?: Record<string, unknown>;
74
+ permission?: string;
75
+ trigger?: ContractCapabilityTrigger$1;
76
+ tags?: string[];
77
+ examples?: string[];
78
+ risk_level?: 'low' | 'medium' | 'high' | null;
79
+ enabled?: boolean;
80
+ }
62
81
  interface LocalAppContractDefinition {
63
82
  id: string;
64
83
  version: string;
84
+ strictness?: 'compatible' | 'strict';
65
85
  events: Record<string, ContractEventType>;
66
86
  supported_events: ContractEventType[];
67
87
  supported_legacy_events: string[];
68
88
  aliases: Record<string, ContractEventType>;
69
89
  status_map: Record<string, string>;
70
90
  legacy_action_map: Record<ContractEventType, string>;
91
+ catalog_hash?: string;
92
+ capability_count?: number;
93
+ capabilities?: ContractCapability$1[];
71
94
  callback?: ContractCallbackMetadata;
72
95
  }
73
96
  interface LocalAppContractResponse {
74
97
  success: boolean;
75
98
  contract: LocalAppContractDefinition;
76
99
  }
100
+ interface LocalAppCapabilitiesResponse {
101
+ success: boolean;
102
+ contract_version: string;
103
+ strictness?: 'compatible' | 'strict';
104
+ catalog_hash?: string;
105
+ count: number;
106
+ capabilities: ContractCapability$1[];
107
+ }
108
+ interface LocalAppCapabilitySearchResponse extends LocalAppCapabilitiesResponse {
109
+ query: string;
110
+ }
111
+ interface LocalAppCapabilityDetailResponse {
112
+ success: boolean;
113
+ contract_version: string;
114
+ strictness?: 'compatible' | 'strict';
115
+ catalog_hash?: string;
116
+ capability: ContractCapability$1;
117
+ }
118
+ interface ContractInvokePayload {
119
+ capability_id: string;
120
+ args?: Record<string, unknown>;
121
+ auto_run?: boolean;
122
+ agent_name?: string;
123
+ workspace_slug?: string;
124
+ thread_slug?: string;
125
+ prompt?: string;
126
+ event_id?: string;
127
+ attempt_id?: string | number;
128
+ }
77
129
  interface Agent {
78
130
  slug: string;
79
131
  name: string;
@@ -1170,10 +1222,19 @@ declare class ContractModule {
1170
1222
  private readonly appId?;
1171
1223
  private readonly apiKey?;
1172
1224
  private cachedContract;
1225
+ private cachedCapabilities;
1226
+ private cachedCapabilityCatalogHash;
1173
1227
  constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
1174
1228
  private requestPermission;
1175
1229
  private request;
1176
1230
  getLocalAppV1(forceRefresh?: boolean): Promise<LocalAppContractDefinition>;
1231
+ listCapabilities(forceRefresh?: boolean): Promise<ContractCapability$1[]>;
1232
+ searchCapabilities(query: string): Promise<ContractCapability$1[]>;
1233
+ describeCapability(capabilityId: string): Promise<ContractCapability$1>;
1234
+ search(query: string): Promise<ContractCapability$1[]>;
1235
+ describe(capabilityId: string): Promise<ContractCapability$1>;
1236
+ invoke(payload: ContractInvokePayload): Promise<TriggerAgentResponse>;
1237
+ getCachedCatalogHash(): string | null;
1177
1238
  clearCache(): void;
1178
1239
  }
1179
1240
 
@@ -1825,4 +1886,4 @@ declare class RealtimeXSDK {
1825
1886
  getAppDataDir(): Promise<string>;
1826
1887
  }
1827
1888
 
1828
- export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, AuthModule, type AuthProvider, type AuthTokenResponse, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type DatabaseConfig, DatabaseModule, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type SyncTokenResponse, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
1889
+ export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, AuthModule, type AuthProvider, type AuthTokenResponse, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, type ContractInvokePayload, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type DatabaseConfig, DatabaseModule, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppCapabilitiesResponse, type LocalAppCapabilityDetailResponse, type LocalAppCapabilitySearchResponse, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type SyncTokenResponse, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
package/dist/index.js CHANGED
@@ -455,6 +455,8 @@ function buildContractIdempotencyKey({
455
455
  var ContractModule = class {
456
456
  constructor(realtimexUrl, appName, appId, apiKey) {
457
457
  this.cachedContract = null;
458
+ this.cachedCapabilities = null;
459
+ this.cachedCapabilityCatalogHash = null;
458
460
  this.realtimexUrl = realtimexUrl.replace(/\/$/, "");
459
461
  this.appName = appName;
460
462
  this.appId = appId;
@@ -477,16 +479,18 @@ var ContractModule = class {
477
479
  return false;
478
480
  }
479
481
  }
480
- async request(path) {
482
+ async request(path, options = {}) {
481
483
  const url = `${this.realtimexUrl}${path}`;
482
484
  const headers = {
483
- "Content-Type": "application/json"
485
+ "Content-Type": "application/json",
486
+ ...options.headers
484
487
  };
485
488
  if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;
486
489
  if (this.appId) headers["x-app-id"] = this.appId;
487
490
  const response = await fetch(url, {
488
- method: "GET",
489
- headers
491
+ method: options.method || "GET",
492
+ headers,
493
+ body: options.body
490
494
  });
491
495
  const data = await response.json();
492
496
  if (response.status === 403) {
@@ -495,7 +499,7 @@ var ContractModule = class {
495
499
  const message = data.message;
496
500
  if (errorCode === "PERMISSION_REQUIRED" && permission) {
497
501
  const granted = await this.requestPermission(permission);
498
- if (granted) return this.request(path);
502
+ if (granted) return this.request(path, options);
499
503
  throw new PermissionDeniedError(permission, message);
500
504
  }
501
505
  if (errorCode === "PERMISSION_DENIED") {
@@ -511,10 +515,89 @@ var ContractModule = class {
511
515
  if (!forceRefresh && this.cachedContract) return this.cachedContract;
512
516
  const data = await this.request("/contracts/local-app/v1");
513
517
  this.cachedContract = data.contract;
518
+ if (Array.isArray(data.contract?.capabilities)) {
519
+ this.cachedCapabilities = data.contract.capabilities;
520
+ this.cachedCapabilityCatalogHash = data.contract.catalog_hash || null;
521
+ }
514
522
  return data.contract;
515
523
  }
524
+ async listCapabilities(forceRefresh = false) {
525
+ if (!forceRefresh && this.cachedCapabilities) return this.cachedCapabilities;
526
+ const data = await this.request(
527
+ "/contracts/local-app/v1/capabilities"
528
+ );
529
+ this.cachedCapabilities = Array.isArray(data.capabilities) ? data.capabilities : [];
530
+ this.cachedCapabilityCatalogHash = data.catalog_hash || null;
531
+ return this.cachedCapabilities;
532
+ }
533
+ async searchCapabilities(query) {
534
+ const normalizedQuery = String(query || "").trim();
535
+ if (!normalizedQuery) {
536
+ throw new Error("searchCapabilities requires a non-empty query");
537
+ }
538
+ const encodedQuery = encodeURIComponent(normalizedQuery);
539
+ const data = await this.request(
540
+ `/contracts/local-app/v1/capabilities/search?q=${encodedQuery}`
541
+ );
542
+ return Array.isArray(data.capabilities) ? data.capabilities : [];
543
+ }
544
+ async describeCapability(capabilityId) {
545
+ const normalizedCapabilityId = String(capabilityId || "").trim();
546
+ if (!normalizedCapabilityId) {
547
+ throw new Error("describeCapability requires a non-empty capability id");
548
+ }
549
+ const encodedCapabilityId = encodeURIComponent(normalizedCapabilityId);
550
+ const data = await this.request(
551
+ `/contracts/local-app/v1/capabilities/${encodedCapabilityId}`
552
+ );
553
+ return data.capability;
554
+ }
555
+ // Alias for agentic contract flow naming.
556
+ async search(query) {
557
+ return this.searchCapabilities(query);
558
+ }
559
+ // Alias for agentic contract flow naming.
560
+ async describe(capabilityId) {
561
+ return this.describeCapability(capabilityId);
562
+ }
563
+ async invoke(payload) {
564
+ const capabilityId = String(payload?.capability_id || "").trim();
565
+ if (!capabilityId) {
566
+ throw new Error("invoke requires payload.capability_id");
567
+ }
568
+ if (payload.auto_run && (!payload.agent_name || !payload.workspace_slug)) {
569
+ throw new Error("auto_run requires agent_name and workspace_slug");
570
+ }
571
+ const args = payload.args && typeof payload.args === "object" && !Array.isArray(payload.args) ? { ...payload.args } : {};
572
+ if (!args.capability) {
573
+ args.capability = capabilityId;
574
+ }
575
+ return this.request("/webhooks/realtimex", {
576
+ method: "POST",
577
+ body: JSON.stringify({
578
+ app_name: this.appName,
579
+ app_id: this.appId,
580
+ event: "task.trigger",
581
+ event_id: payload.event_id || createContractEventId(),
582
+ attempt_id: normalizeAttemptId(payload.attempt_id),
583
+ payload: {
584
+ raw_data: args,
585
+ auto_run: payload.auto_run ?? false,
586
+ agent_name: payload.agent_name,
587
+ workspace_slug: payload.workspace_slug,
588
+ thread_slug: payload.thread_slug,
589
+ prompt: payload.prompt ?? ""
590
+ }
591
+ })
592
+ });
593
+ }
594
+ getCachedCatalogHash() {
595
+ return this.cachedCapabilityCatalogHash;
596
+ }
516
597
  clearCache() {
517
598
  this.cachedContract = null;
599
+ this.cachedCapabilities = null;
600
+ this.cachedCapabilityCatalogHash = null;
518
601
  }
519
602
  };
520
603
 
@@ -2497,6 +2580,7 @@ var ContractRuntime = class {
2497
2580
  tool_call_id: call.tool_call_id,
2498
2581
  args: call.args,
2499
2582
  context: {
2583
+ app_id: context.appId,
2500
2584
  user_id: context.userId,
2501
2585
  workspace_id: context.workspaceId || null,
2502
2586
  request_id: context.requestId || null,
@@ -2509,7 +2593,9 @@ var ContractRuntime = class {
2509
2593
  }
2510
2594
  return {
2511
2595
  app_name: this.appName,
2512
- app_id: this.appId || context.appId,
2596
+ // In API-key dev mode, app_id should be omitted unless explicitly configured
2597
+ // on the runtime. Passing an unknown app_id causes webhook trigger rejection.
2598
+ app_id: this.appId || void 0,
2513
2599
  event: tool.trigger.event,
2514
2600
  event_id: eventId,
2515
2601
  payload
package/dist/index.mjs CHANGED
@@ -363,6 +363,8 @@ function buildContractIdempotencyKey({
363
363
  var ContractModule = class {
364
364
  constructor(realtimexUrl, appName, appId, apiKey) {
365
365
  this.cachedContract = null;
366
+ this.cachedCapabilities = null;
367
+ this.cachedCapabilityCatalogHash = null;
366
368
  this.realtimexUrl = realtimexUrl.replace(/\/$/, "");
367
369
  this.appName = appName;
368
370
  this.appId = appId;
@@ -385,16 +387,18 @@ var ContractModule = class {
385
387
  return false;
386
388
  }
387
389
  }
388
- async request(path) {
390
+ async request(path, options = {}) {
389
391
  const url = `${this.realtimexUrl}${path}`;
390
392
  const headers = {
391
- "Content-Type": "application/json"
393
+ "Content-Type": "application/json",
394
+ ...options.headers
392
395
  };
393
396
  if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;
394
397
  if (this.appId) headers["x-app-id"] = this.appId;
395
398
  const response = await fetch(url, {
396
- method: "GET",
397
- headers
399
+ method: options.method || "GET",
400
+ headers,
401
+ body: options.body
398
402
  });
399
403
  const data = await response.json();
400
404
  if (response.status === 403) {
@@ -403,7 +407,7 @@ var ContractModule = class {
403
407
  const message = data.message;
404
408
  if (errorCode === "PERMISSION_REQUIRED" && permission) {
405
409
  const granted = await this.requestPermission(permission);
406
- if (granted) return this.request(path);
410
+ if (granted) return this.request(path, options);
407
411
  throw new PermissionDeniedError(permission, message);
408
412
  }
409
413
  if (errorCode === "PERMISSION_DENIED") {
@@ -419,10 +423,89 @@ var ContractModule = class {
419
423
  if (!forceRefresh && this.cachedContract) return this.cachedContract;
420
424
  const data = await this.request("/contracts/local-app/v1");
421
425
  this.cachedContract = data.contract;
426
+ if (Array.isArray(data.contract?.capabilities)) {
427
+ this.cachedCapabilities = data.contract.capabilities;
428
+ this.cachedCapabilityCatalogHash = data.contract.catalog_hash || null;
429
+ }
422
430
  return data.contract;
423
431
  }
432
+ async listCapabilities(forceRefresh = false) {
433
+ if (!forceRefresh && this.cachedCapabilities) return this.cachedCapabilities;
434
+ const data = await this.request(
435
+ "/contracts/local-app/v1/capabilities"
436
+ );
437
+ this.cachedCapabilities = Array.isArray(data.capabilities) ? data.capabilities : [];
438
+ this.cachedCapabilityCatalogHash = data.catalog_hash || null;
439
+ return this.cachedCapabilities;
440
+ }
441
+ async searchCapabilities(query) {
442
+ const normalizedQuery = String(query || "").trim();
443
+ if (!normalizedQuery) {
444
+ throw new Error("searchCapabilities requires a non-empty query");
445
+ }
446
+ const encodedQuery = encodeURIComponent(normalizedQuery);
447
+ const data = await this.request(
448
+ `/contracts/local-app/v1/capabilities/search?q=${encodedQuery}`
449
+ );
450
+ return Array.isArray(data.capabilities) ? data.capabilities : [];
451
+ }
452
+ async describeCapability(capabilityId) {
453
+ const normalizedCapabilityId = String(capabilityId || "").trim();
454
+ if (!normalizedCapabilityId) {
455
+ throw new Error("describeCapability requires a non-empty capability id");
456
+ }
457
+ const encodedCapabilityId = encodeURIComponent(normalizedCapabilityId);
458
+ const data = await this.request(
459
+ `/contracts/local-app/v1/capabilities/${encodedCapabilityId}`
460
+ );
461
+ return data.capability;
462
+ }
463
+ // Alias for agentic contract flow naming.
464
+ async search(query) {
465
+ return this.searchCapabilities(query);
466
+ }
467
+ // Alias for agentic contract flow naming.
468
+ async describe(capabilityId) {
469
+ return this.describeCapability(capabilityId);
470
+ }
471
+ async invoke(payload) {
472
+ const capabilityId = String(payload?.capability_id || "").trim();
473
+ if (!capabilityId) {
474
+ throw new Error("invoke requires payload.capability_id");
475
+ }
476
+ if (payload.auto_run && (!payload.agent_name || !payload.workspace_slug)) {
477
+ throw new Error("auto_run requires agent_name and workspace_slug");
478
+ }
479
+ const args = payload.args && typeof payload.args === "object" && !Array.isArray(payload.args) ? { ...payload.args } : {};
480
+ if (!args.capability) {
481
+ args.capability = capabilityId;
482
+ }
483
+ return this.request("/webhooks/realtimex", {
484
+ method: "POST",
485
+ body: JSON.stringify({
486
+ app_name: this.appName,
487
+ app_id: this.appId,
488
+ event: "task.trigger",
489
+ event_id: payload.event_id || createContractEventId(),
490
+ attempt_id: normalizeAttemptId(payload.attempt_id),
491
+ payload: {
492
+ raw_data: args,
493
+ auto_run: payload.auto_run ?? false,
494
+ agent_name: payload.agent_name,
495
+ workspace_slug: payload.workspace_slug,
496
+ thread_slug: payload.thread_slug,
497
+ prompt: payload.prompt ?? ""
498
+ }
499
+ })
500
+ });
501
+ }
502
+ getCachedCatalogHash() {
503
+ return this.cachedCapabilityCatalogHash;
504
+ }
424
505
  clearCache() {
425
506
  this.cachedContract = null;
507
+ this.cachedCapabilities = null;
508
+ this.cachedCapabilityCatalogHash = null;
426
509
  }
427
510
  };
428
511
 
@@ -2405,6 +2488,7 @@ var ContractRuntime = class {
2405
2488
  tool_call_id: call.tool_call_id,
2406
2489
  args: call.args,
2407
2490
  context: {
2491
+ app_id: context.appId,
2408
2492
  user_id: context.userId,
2409
2493
  workspace_id: context.workspaceId || null,
2410
2494
  request_id: context.requestId || null,
@@ -2417,7 +2501,9 @@ var ContractRuntime = class {
2417
2501
  }
2418
2502
  return {
2419
2503
  app_name: this.appName,
2420
- app_id: this.appId || context.appId,
2504
+ // In API-key dev mode, app_id should be omitted unless explicitly configured
2505
+ // on the runtime. Passing an unknown app_id causes webhook trigger rejection.
2506
+ app_id: this.appId || void 0,
2421
2507
  event: tool.trigger.event,
2422
2508
  event_id: eventId,
2423
2509
  payload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realtimex/sdk",
3
- "version": "1.3.6",
3
+ "version": "1.3.7-rc.1",
4
4
  "description": "SDK for building Local Apps that integrate with RealtimeX",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",