@mitralab.io/sdk-core 0.2.8 → 0.2.9-beta.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/CHANGELOG.md +33 -0
- package/README.md +74 -6
- package/contracts/README.md +8 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.2.9-beta.0/sdk-parity.json +2902 -0
- package/contracts/v0.2.9-beta.1/sdk-parity.json +2902 -0
- package/dist/index.cjs +758 -17
- package/dist/index.d.cts +93 -7
- package/dist/index.d.ts +93 -7
- package/dist/index.js +758 -17
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1088,6 +1088,13 @@ interface AgentTaskEvent {
|
|
|
1088
1088
|
/** Present only on persisted structural events; live deltas omit it. */
|
|
1089
1089
|
sequence?: number;
|
|
1090
1090
|
}
|
|
1091
|
+
/** Where the Copilot serves a chat on its box, and how far that box's log went when it answered. */
|
|
1092
|
+
interface AgentTaskChannel {
|
|
1093
|
+
/** Box socket address. The query carries a short-lived grant, so it is never logged or reused. */
|
|
1094
|
+
wsUrl: string;
|
|
1095
|
+
/** Last sequence in the box log, 0 when the box reported none. */
|
|
1096
|
+
lastSequence: number;
|
|
1097
|
+
}
|
|
1091
1098
|
interface AgentMessage {
|
|
1092
1099
|
id: string;
|
|
1093
1100
|
sender: string;
|
|
@@ -1297,6 +1304,12 @@ interface AgentTasksModule {
|
|
|
1297
1304
|
sendInput(id: string, input: AgentTaskInput): Promise<void>;
|
|
1298
1305
|
/** Lists persisted messages. Defaults: page 0, size 50, sort createdAt. */
|
|
1299
1306
|
listMessages(id: string, options?: PageOptions): Promise<Page<AgentMessage>>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Asks the Copilot where the chat is served. It holds the request while the box boots and
|
|
1309
|
+
* answers with the box socket, or null (202) when it offers none. Optional so hand-written
|
|
1310
|
+
* modules keep compiling; a module without it never takes the direct channel.
|
|
1311
|
+
*/
|
|
1312
|
+
channel?(id: string): Promise<AgentTaskChannel | null>;
|
|
1300
1313
|
}
|
|
1301
1314
|
declare function createAgentTasksModule(transport: Transport, errors?: SdkCoreErrorFactory): AgentTasksModule;
|
|
1302
1315
|
|
|
@@ -1767,6 +1780,68 @@ interface SdkCore {
|
|
|
1767
1780
|
}
|
|
1768
1781
|
declare function createSdkCore(options: SdkCoreOptions): SdkCore;
|
|
1769
1782
|
|
|
1783
|
+
/**
|
|
1784
|
+
* The part of a WebSocket the channel uses: the browser one and `ws` both fit. Handlers take
|
|
1785
|
+
* `never` so either implementation's own event types can be assigned without a cast.
|
|
1786
|
+
*/
|
|
1787
|
+
interface AgentWebSocket {
|
|
1788
|
+
readonly readyState: number;
|
|
1789
|
+
onopen: ((event: never) => void) | null;
|
|
1790
|
+
onmessage: ((event: never) => void) | null;
|
|
1791
|
+
onerror: ((event: never) => void) | null;
|
|
1792
|
+
onclose: ((event: never) => void) | null;
|
|
1793
|
+
send(data: string): void;
|
|
1794
|
+
close(code?: number, reason?: string): void;
|
|
1795
|
+
}
|
|
1796
|
+
type AgentWebSocketConstructor = new (url: string) => AgentWebSocket;
|
|
1797
|
+
interface AgentDirectChannelOptions {
|
|
1798
|
+
/**
|
|
1799
|
+
* API base URL of the SDK. A channel on this same host is the gateway proxying the box; any
|
|
1800
|
+
* other host must be a fleet box over `wss:`. Required: without it the direct channel is off
|
|
1801
|
+
* and the session stays on the event source and REST inputs.
|
|
1802
|
+
*/
|
|
1803
|
+
apiUrl?: string;
|
|
1804
|
+
/**
|
|
1805
|
+
* WebSocket implementation for runtimes with no global one, such as Node 18 and 20. Wins over
|
|
1806
|
+
* `globalThis.WebSocket` when given. With neither, the chat stays on the event source and a
|
|
1807
|
+
* `channelDeclined` event with reason `websocket` says so.
|
|
1808
|
+
*/
|
|
1809
|
+
WebSocket?: AgentWebSocketConstructor;
|
|
1810
|
+
/** fetch for the box's HTTP routes. Defaults to `globalThis.fetch`. */
|
|
1811
|
+
fetch?: AgentFetch;
|
|
1812
|
+
}
|
|
1813
|
+
/** The part of a fetch response the HTTP channel reads. */
|
|
1814
|
+
interface AgentFetchResponse {
|
|
1815
|
+
readonly ok: boolean;
|
|
1816
|
+
readonly status: number;
|
|
1817
|
+
readonly headers: {
|
|
1818
|
+
get(name: string): string | null;
|
|
1819
|
+
};
|
|
1820
|
+
json(): Promise<unknown>;
|
|
1821
|
+
readonly body: {
|
|
1822
|
+
getReader(): {
|
|
1823
|
+
read(): Promise<{
|
|
1824
|
+
done: boolean;
|
|
1825
|
+
value?: Uint8Array | undefined;
|
|
1826
|
+
}>;
|
|
1827
|
+
cancel(): Promise<void>;
|
|
1828
|
+
releaseLock(): void;
|
|
1829
|
+
};
|
|
1830
|
+
} | null;
|
|
1831
|
+
}
|
|
1832
|
+
type AgentFetch = (url: string, init: {
|
|
1833
|
+
method?: string;
|
|
1834
|
+
headers?: Record<string, string>;
|
|
1835
|
+
body?: string;
|
|
1836
|
+
signal?: AbortSignal;
|
|
1837
|
+
redirect?: "error";
|
|
1838
|
+
}) => Promise<AgentFetchResponse>;
|
|
1839
|
+
|
|
1840
|
+
declare class AgentTaskTurnError extends Error {
|
|
1841
|
+
readonly code: string | undefined;
|
|
1842
|
+
constructor(message: string, code?: string);
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1770
1845
|
interface AgentTaskEventObserver {
|
|
1771
1846
|
onEvent(event: AgentTaskEvent): void;
|
|
1772
1847
|
onDisconnect(error?: unknown): void;
|
|
@@ -1774,7 +1849,10 @@ interface AgentTaskEventObserver {
|
|
|
1774
1849
|
interface AgentTaskEventConnection {
|
|
1775
1850
|
close(): void;
|
|
1776
1851
|
}
|
|
1777
|
-
/**
|
|
1852
|
+
/**
|
|
1853
|
+
* Streaming boundary implemented by concrete SDKs: the Copilot stream a chat falls back to when
|
|
1854
|
+
* its box offers no direct channel. The direct channel itself is Core's.
|
|
1855
|
+
*/
|
|
1778
1856
|
interface AgentTaskEventSource {
|
|
1779
1857
|
open(taskId: string, observer: AgentTaskEventObserver, signal?: AbortSignal, transport?: AgentSessionTransport): Promise<AgentTaskEventConnection>;
|
|
1780
1858
|
}
|
|
@@ -1790,7 +1868,11 @@ interface NewAgentTaskSessionOptions {
|
|
|
1790
1868
|
runtime?: AgentTaskRuntime;
|
|
1791
1869
|
/** Credential scope the task resolves against. Omitted means the Copilot server default. */
|
|
1792
1870
|
scope?: AgentCredentialScope;
|
|
1793
|
-
/**
|
|
1871
|
+
/**
|
|
1872
|
+
* How the session reaches the box the Copilot offers: `websocket` on its socket, `http` on its
|
|
1873
|
+
* HTTP routes, `auto` on the socket when available and HTTP otherwise. Without an offer the
|
|
1874
|
+
* session falls back to the event source.
|
|
1875
|
+
*/
|
|
1794
1876
|
transport?: AgentSessionTransport;
|
|
1795
1877
|
}
|
|
1796
1878
|
interface ExistingAgentTaskSessionOptions {
|
|
@@ -1836,10 +1918,6 @@ interface AgentTurnResult {
|
|
|
1836
1918
|
content: string;
|
|
1837
1919
|
reason: string;
|
|
1838
1920
|
}
|
|
1839
|
-
declare class AgentTaskTurnError extends Error {
|
|
1840
|
-
readonly code: string | undefined;
|
|
1841
|
-
constructor(message: string, code?: string);
|
|
1842
|
-
}
|
|
1843
1921
|
interface AgentTaskSessionEventMap {
|
|
1844
1922
|
statusChange: {
|
|
1845
1923
|
status: AgentTaskSessionStatus;
|
|
@@ -1861,6 +1939,12 @@ interface AgentTaskSessionEventMap {
|
|
|
1861
1939
|
timestamp: number;
|
|
1862
1940
|
};
|
|
1863
1941
|
turnEnd: AgentTurnResult;
|
|
1942
|
+
/**
|
|
1943
|
+
* The prompt reached the server: the box admitted the turn on the direct channel, or the
|
|
1944
|
+
* Copilot accepted it over REST. From here the turn runs without this session, so a caller
|
|
1945
|
+
* that does not wait for the answer can close it or return.
|
|
1946
|
+
*/
|
|
1947
|
+
accepted: Record<string, never>;
|
|
1864
1948
|
cancelled: Record<string, never>;
|
|
1865
1949
|
queueChange: {
|
|
1866
1950
|
queue: readonly AgentQueueItem[];
|
|
@@ -1899,6 +1983,8 @@ type AgentTasksWithSessions = AgentTasksModule & AgentTaskSessionManager;
|
|
|
1899
1983
|
interface AgentTaskSessionManagerOptions {
|
|
1900
1984
|
tasks: AgentTasksModule;
|
|
1901
1985
|
eventSource: AgentTaskEventSource;
|
|
1986
|
+
/** Where the box channel may live and how to dial it outside a browser. */
|
|
1987
|
+
directChannel?: AgentDirectChannelOptions;
|
|
1902
1988
|
}
|
|
1903
1989
|
declare function toAgentTimelineItem(message: AgentMessage): AgentTimelineItem;
|
|
1904
1990
|
declare function createAgentTaskSessionManager(options: AgentTaskSessionManagerOptions): AgentTaskSessionManager;
|
|
@@ -1958,4 +2044,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
1958
2044
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
1959
2045
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
1960
2046
|
|
|
1961
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2047
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1088,6 +1088,13 @@ interface AgentTaskEvent {
|
|
|
1088
1088
|
/** Present only on persisted structural events; live deltas omit it. */
|
|
1089
1089
|
sequence?: number;
|
|
1090
1090
|
}
|
|
1091
|
+
/** Where the Copilot serves a chat on its box, and how far that box's log went when it answered. */
|
|
1092
|
+
interface AgentTaskChannel {
|
|
1093
|
+
/** Box socket address. The query carries a short-lived grant, so it is never logged or reused. */
|
|
1094
|
+
wsUrl: string;
|
|
1095
|
+
/** Last sequence in the box log, 0 when the box reported none. */
|
|
1096
|
+
lastSequence: number;
|
|
1097
|
+
}
|
|
1091
1098
|
interface AgentMessage {
|
|
1092
1099
|
id: string;
|
|
1093
1100
|
sender: string;
|
|
@@ -1297,6 +1304,12 @@ interface AgentTasksModule {
|
|
|
1297
1304
|
sendInput(id: string, input: AgentTaskInput): Promise<void>;
|
|
1298
1305
|
/** Lists persisted messages. Defaults: page 0, size 50, sort createdAt. */
|
|
1299
1306
|
listMessages(id: string, options?: PageOptions): Promise<Page<AgentMessage>>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Asks the Copilot where the chat is served. It holds the request while the box boots and
|
|
1309
|
+
* answers with the box socket, or null (202) when it offers none. Optional so hand-written
|
|
1310
|
+
* modules keep compiling; a module without it never takes the direct channel.
|
|
1311
|
+
*/
|
|
1312
|
+
channel?(id: string): Promise<AgentTaskChannel | null>;
|
|
1300
1313
|
}
|
|
1301
1314
|
declare function createAgentTasksModule(transport: Transport, errors?: SdkCoreErrorFactory): AgentTasksModule;
|
|
1302
1315
|
|
|
@@ -1767,6 +1780,68 @@ interface SdkCore {
|
|
|
1767
1780
|
}
|
|
1768
1781
|
declare function createSdkCore(options: SdkCoreOptions): SdkCore;
|
|
1769
1782
|
|
|
1783
|
+
/**
|
|
1784
|
+
* The part of a WebSocket the channel uses: the browser one and `ws` both fit. Handlers take
|
|
1785
|
+
* `never` so either implementation's own event types can be assigned without a cast.
|
|
1786
|
+
*/
|
|
1787
|
+
interface AgentWebSocket {
|
|
1788
|
+
readonly readyState: number;
|
|
1789
|
+
onopen: ((event: never) => void) | null;
|
|
1790
|
+
onmessage: ((event: never) => void) | null;
|
|
1791
|
+
onerror: ((event: never) => void) | null;
|
|
1792
|
+
onclose: ((event: never) => void) | null;
|
|
1793
|
+
send(data: string): void;
|
|
1794
|
+
close(code?: number, reason?: string): void;
|
|
1795
|
+
}
|
|
1796
|
+
type AgentWebSocketConstructor = new (url: string) => AgentWebSocket;
|
|
1797
|
+
interface AgentDirectChannelOptions {
|
|
1798
|
+
/**
|
|
1799
|
+
* API base URL of the SDK. A channel on this same host is the gateway proxying the box; any
|
|
1800
|
+
* other host must be a fleet box over `wss:`. Required: without it the direct channel is off
|
|
1801
|
+
* and the session stays on the event source and REST inputs.
|
|
1802
|
+
*/
|
|
1803
|
+
apiUrl?: string;
|
|
1804
|
+
/**
|
|
1805
|
+
* WebSocket implementation for runtimes with no global one, such as Node 18 and 20. Wins over
|
|
1806
|
+
* `globalThis.WebSocket` when given. With neither, the chat stays on the event source and a
|
|
1807
|
+
* `channelDeclined` event with reason `websocket` says so.
|
|
1808
|
+
*/
|
|
1809
|
+
WebSocket?: AgentWebSocketConstructor;
|
|
1810
|
+
/** fetch for the box's HTTP routes. Defaults to `globalThis.fetch`. */
|
|
1811
|
+
fetch?: AgentFetch;
|
|
1812
|
+
}
|
|
1813
|
+
/** The part of a fetch response the HTTP channel reads. */
|
|
1814
|
+
interface AgentFetchResponse {
|
|
1815
|
+
readonly ok: boolean;
|
|
1816
|
+
readonly status: number;
|
|
1817
|
+
readonly headers: {
|
|
1818
|
+
get(name: string): string | null;
|
|
1819
|
+
};
|
|
1820
|
+
json(): Promise<unknown>;
|
|
1821
|
+
readonly body: {
|
|
1822
|
+
getReader(): {
|
|
1823
|
+
read(): Promise<{
|
|
1824
|
+
done: boolean;
|
|
1825
|
+
value?: Uint8Array | undefined;
|
|
1826
|
+
}>;
|
|
1827
|
+
cancel(): Promise<void>;
|
|
1828
|
+
releaseLock(): void;
|
|
1829
|
+
};
|
|
1830
|
+
} | null;
|
|
1831
|
+
}
|
|
1832
|
+
type AgentFetch = (url: string, init: {
|
|
1833
|
+
method?: string;
|
|
1834
|
+
headers?: Record<string, string>;
|
|
1835
|
+
body?: string;
|
|
1836
|
+
signal?: AbortSignal;
|
|
1837
|
+
redirect?: "error";
|
|
1838
|
+
}) => Promise<AgentFetchResponse>;
|
|
1839
|
+
|
|
1840
|
+
declare class AgentTaskTurnError extends Error {
|
|
1841
|
+
readonly code: string | undefined;
|
|
1842
|
+
constructor(message: string, code?: string);
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1770
1845
|
interface AgentTaskEventObserver {
|
|
1771
1846
|
onEvent(event: AgentTaskEvent): void;
|
|
1772
1847
|
onDisconnect(error?: unknown): void;
|
|
@@ -1774,7 +1849,10 @@ interface AgentTaskEventObserver {
|
|
|
1774
1849
|
interface AgentTaskEventConnection {
|
|
1775
1850
|
close(): void;
|
|
1776
1851
|
}
|
|
1777
|
-
/**
|
|
1852
|
+
/**
|
|
1853
|
+
* Streaming boundary implemented by concrete SDKs: the Copilot stream a chat falls back to when
|
|
1854
|
+
* its box offers no direct channel. The direct channel itself is Core's.
|
|
1855
|
+
*/
|
|
1778
1856
|
interface AgentTaskEventSource {
|
|
1779
1857
|
open(taskId: string, observer: AgentTaskEventObserver, signal?: AbortSignal, transport?: AgentSessionTransport): Promise<AgentTaskEventConnection>;
|
|
1780
1858
|
}
|
|
@@ -1790,7 +1868,11 @@ interface NewAgentTaskSessionOptions {
|
|
|
1790
1868
|
runtime?: AgentTaskRuntime;
|
|
1791
1869
|
/** Credential scope the task resolves against. Omitted means the Copilot server default. */
|
|
1792
1870
|
scope?: AgentCredentialScope;
|
|
1793
|
-
/**
|
|
1871
|
+
/**
|
|
1872
|
+
* How the session reaches the box the Copilot offers: `websocket` on its socket, `http` on its
|
|
1873
|
+
* HTTP routes, `auto` on the socket when available and HTTP otherwise. Without an offer the
|
|
1874
|
+
* session falls back to the event source.
|
|
1875
|
+
*/
|
|
1794
1876
|
transport?: AgentSessionTransport;
|
|
1795
1877
|
}
|
|
1796
1878
|
interface ExistingAgentTaskSessionOptions {
|
|
@@ -1836,10 +1918,6 @@ interface AgentTurnResult {
|
|
|
1836
1918
|
content: string;
|
|
1837
1919
|
reason: string;
|
|
1838
1920
|
}
|
|
1839
|
-
declare class AgentTaskTurnError extends Error {
|
|
1840
|
-
readonly code: string | undefined;
|
|
1841
|
-
constructor(message: string, code?: string);
|
|
1842
|
-
}
|
|
1843
1921
|
interface AgentTaskSessionEventMap {
|
|
1844
1922
|
statusChange: {
|
|
1845
1923
|
status: AgentTaskSessionStatus;
|
|
@@ -1861,6 +1939,12 @@ interface AgentTaskSessionEventMap {
|
|
|
1861
1939
|
timestamp: number;
|
|
1862
1940
|
};
|
|
1863
1941
|
turnEnd: AgentTurnResult;
|
|
1942
|
+
/**
|
|
1943
|
+
* The prompt reached the server: the box admitted the turn on the direct channel, or the
|
|
1944
|
+
* Copilot accepted it over REST. From here the turn runs without this session, so a caller
|
|
1945
|
+
* that does not wait for the answer can close it or return.
|
|
1946
|
+
*/
|
|
1947
|
+
accepted: Record<string, never>;
|
|
1864
1948
|
cancelled: Record<string, never>;
|
|
1865
1949
|
queueChange: {
|
|
1866
1950
|
queue: readonly AgentQueueItem[];
|
|
@@ -1899,6 +1983,8 @@ type AgentTasksWithSessions = AgentTasksModule & AgentTaskSessionManager;
|
|
|
1899
1983
|
interface AgentTaskSessionManagerOptions {
|
|
1900
1984
|
tasks: AgentTasksModule;
|
|
1901
1985
|
eventSource: AgentTaskEventSource;
|
|
1986
|
+
/** Where the box channel may live and how to dial it outside a browser. */
|
|
1987
|
+
directChannel?: AgentDirectChannelOptions;
|
|
1902
1988
|
}
|
|
1903
1989
|
declare function toAgentTimelineItem(message: AgentMessage): AgentTimelineItem;
|
|
1904
1990
|
declare function createAgentTaskSessionManager(options: AgentTaskSessionManagerOptions): AgentTaskSessionManager;
|
|
@@ -1958,4 +2044,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
1958
2044
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
1959
2045
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
1960
2046
|
|
|
1961
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2047
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|