@cadraos/sdk 0.3.5 → 0.3.7
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/chat/index.cjs +57 -5
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +14 -0
- package/dist/chat/index.d.ts +14 -0
- package/dist/chat/index.js +57 -5
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +57 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +57 -5
- package/dist/index.js.map +1 -1
- package/dist/kanban/index.cjs +57 -5
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.d.cts +14 -0
- package/dist/kanban/index.d.ts +14 -0
- package/dist/kanban/index.js +57 -5
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +57 -5
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.d.cts +14 -0
- package/dist/teams/index.d.ts +14 -0
- package/dist/teams/index.js +57 -5
- package/dist/teams/index.js.map +1 -1
- package/package.json +15 -16
package/dist/kanban/index.d.cts
CHANGED
|
@@ -2172,6 +2172,8 @@ interface HttpClientConfig {
|
|
|
2172
2172
|
retry: RetryConfig;
|
|
2173
2173
|
/** Custom headers */
|
|
2174
2174
|
headers?: Record<string, string>;
|
|
2175
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
2176
|
+
fetch?: typeof fetch;
|
|
2175
2177
|
}
|
|
2176
2178
|
/**
|
|
2177
2179
|
* Request options
|
|
@@ -2823,6 +2825,8 @@ interface RemoteAgentCreateInput {
|
|
|
2823
2825
|
name: string;
|
|
2824
2826
|
description?: string;
|
|
2825
2827
|
adapterType: string;
|
|
2828
|
+
/** Bind the agent to a specific runner (e.g. a Cadra Desktop install). */
|
|
2829
|
+
defaultRunnerId?: number | null;
|
|
2826
2830
|
executionTargetKind?: RemoteAgentExecutionTargetKind;
|
|
2827
2831
|
adapterConfig?: Record<string, unknown>;
|
|
2828
2832
|
inputSchema?: Record<string, unknown>;
|
|
@@ -2833,6 +2837,8 @@ interface RemoteAgentUpdateInput {
|
|
|
2833
2837
|
name?: string;
|
|
2834
2838
|
description?: string;
|
|
2835
2839
|
adapterType?: string;
|
|
2840
|
+
/** Re-bind the agent to a specific runner. */
|
|
2841
|
+
defaultRunnerId?: number | null;
|
|
2836
2842
|
executionTargetKind?: RemoteAgentExecutionTargetKind;
|
|
2837
2843
|
adapterConfig?: Record<string, unknown>;
|
|
2838
2844
|
inputSchema?: Record<string, unknown>;
|
|
@@ -3196,6 +3202,8 @@ interface StreamConfig {
|
|
|
3196
3202
|
token?: string;
|
|
3197
3203
|
tokenProvider?: () => Promise<string>;
|
|
3198
3204
|
orgId: number;
|
|
3205
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
3206
|
+
fetch?: typeof fetch;
|
|
3199
3207
|
}
|
|
3200
3208
|
|
|
3201
3209
|
/**
|
|
@@ -4120,6 +4128,8 @@ interface CadraClientOptionsApiKey {
|
|
|
4120
4128
|
maxRetries?: number;
|
|
4121
4129
|
/** Custom headers to include in all requests */
|
|
4122
4130
|
headers?: Record<string, string>;
|
|
4131
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4132
|
+
fetch?: typeof fetch;
|
|
4123
4133
|
}
|
|
4124
4134
|
/**
|
|
4125
4135
|
* Client options for OAuth token authentication
|
|
@@ -4137,6 +4147,8 @@ interface CadraClientOptionsToken {
|
|
|
4137
4147
|
maxRetries?: number;
|
|
4138
4148
|
/** Custom headers to include in all requests */
|
|
4139
4149
|
headers?: Record<string, string>;
|
|
4150
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4151
|
+
fetch?: typeof fetch;
|
|
4140
4152
|
}
|
|
4141
4153
|
/**
|
|
4142
4154
|
* Client options for token provider authentication
|
|
@@ -4154,6 +4166,8 @@ interface CadraClientOptionsTokenProvider {
|
|
|
4154
4166
|
maxRetries?: number;
|
|
4155
4167
|
/** Custom headers to include in all requests */
|
|
4156
4168
|
headers?: Record<string, string>;
|
|
4169
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4170
|
+
fetch?: typeof fetch;
|
|
4157
4171
|
}
|
|
4158
4172
|
/**
|
|
4159
4173
|
* All client options
|
package/dist/kanban/index.d.ts
CHANGED
|
@@ -2172,6 +2172,8 @@ interface HttpClientConfig {
|
|
|
2172
2172
|
retry: RetryConfig;
|
|
2173
2173
|
/** Custom headers */
|
|
2174
2174
|
headers?: Record<string, string>;
|
|
2175
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
2176
|
+
fetch?: typeof fetch;
|
|
2175
2177
|
}
|
|
2176
2178
|
/**
|
|
2177
2179
|
* Request options
|
|
@@ -2823,6 +2825,8 @@ interface RemoteAgentCreateInput {
|
|
|
2823
2825
|
name: string;
|
|
2824
2826
|
description?: string;
|
|
2825
2827
|
adapterType: string;
|
|
2828
|
+
/** Bind the agent to a specific runner (e.g. a Cadra Desktop install). */
|
|
2829
|
+
defaultRunnerId?: number | null;
|
|
2826
2830
|
executionTargetKind?: RemoteAgentExecutionTargetKind;
|
|
2827
2831
|
adapterConfig?: Record<string, unknown>;
|
|
2828
2832
|
inputSchema?: Record<string, unknown>;
|
|
@@ -2833,6 +2837,8 @@ interface RemoteAgentUpdateInput {
|
|
|
2833
2837
|
name?: string;
|
|
2834
2838
|
description?: string;
|
|
2835
2839
|
adapterType?: string;
|
|
2840
|
+
/** Re-bind the agent to a specific runner. */
|
|
2841
|
+
defaultRunnerId?: number | null;
|
|
2836
2842
|
executionTargetKind?: RemoteAgentExecutionTargetKind;
|
|
2837
2843
|
adapterConfig?: Record<string, unknown>;
|
|
2838
2844
|
inputSchema?: Record<string, unknown>;
|
|
@@ -3196,6 +3202,8 @@ interface StreamConfig {
|
|
|
3196
3202
|
token?: string;
|
|
3197
3203
|
tokenProvider?: () => Promise<string>;
|
|
3198
3204
|
orgId: number;
|
|
3205
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
3206
|
+
fetch?: typeof fetch;
|
|
3199
3207
|
}
|
|
3200
3208
|
|
|
3201
3209
|
/**
|
|
@@ -4120,6 +4128,8 @@ interface CadraClientOptionsApiKey {
|
|
|
4120
4128
|
maxRetries?: number;
|
|
4121
4129
|
/** Custom headers to include in all requests */
|
|
4122
4130
|
headers?: Record<string, string>;
|
|
4131
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4132
|
+
fetch?: typeof fetch;
|
|
4123
4133
|
}
|
|
4124
4134
|
/**
|
|
4125
4135
|
* Client options for OAuth token authentication
|
|
@@ -4137,6 +4147,8 @@ interface CadraClientOptionsToken {
|
|
|
4137
4147
|
maxRetries?: number;
|
|
4138
4148
|
/** Custom headers to include in all requests */
|
|
4139
4149
|
headers?: Record<string, string>;
|
|
4150
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4151
|
+
fetch?: typeof fetch;
|
|
4140
4152
|
}
|
|
4141
4153
|
/**
|
|
4142
4154
|
* Client options for token provider authentication
|
|
@@ -4154,6 +4166,8 @@ interface CadraClientOptionsTokenProvider {
|
|
|
4154
4166
|
maxRetries?: number;
|
|
4155
4167
|
/** Custom headers to include in all requests */
|
|
4156
4168
|
headers?: Record<string, string>;
|
|
4169
|
+
/** Optional fetch implementation — inject `expo/fetch` for React Native streaming. Defaults to global fetch. */
|
|
4170
|
+
fetch?: typeof fetch;
|
|
4157
4171
|
}
|
|
4158
4172
|
/**
|
|
4159
4173
|
* All client options
|
package/dist/kanban/index.js
CHANGED
|
@@ -3296,7 +3296,8 @@ var HttpClient = class {
|
|
|
3296
3296
|
const controller = new AbortController();
|
|
3297
3297
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
3298
3298
|
try {
|
|
3299
|
-
const
|
|
3299
|
+
const doFetch = this.config.fetch ?? fetch;
|
|
3300
|
+
const response = await doFetch(url, {
|
|
3300
3301
|
method: options.method,
|
|
3301
3302
|
headers,
|
|
3302
3303
|
body: options.body !== void 0 ? JSON.stringify(options.body) : void 0,
|
|
@@ -3428,7 +3429,8 @@ var SSEClient = class {
|
|
|
3428
3429
|
console.log("[SDK:SSE] Auth header:", this.config.authHeader ? `${this.config.authHeader.substring(0, 30)}...` : "MISSING");
|
|
3429
3430
|
console.log("[SDK:SSE] Org ID:", this.config.orgId);
|
|
3430
3431
|
try {
|
|
3431
|
-
const
|
|
3432
|
+
const doFetch = this.config.fetch ?? fetch;
|
|
3433
|
+
const response = await doFetch(this.config.url, {
|
|
3432
3434
|
method: "GET",
|
|
3433
3435
|
headers: {
|
|
3434
3436
|
"Authorization": this.config.authHeader,
|
|
@@ -3666,6 +3668,15 @@ var ExecutionStreamControllerImpl = class {
|
|
|
3666
3668
|
sseClient = null;
|
|
3667
3669
|
status = "connecting";
|
|
3668
3670
|
reconnectAttempts = 0;
|
|
3671
|
+
// CAD-39 / webchat dual-plane create-connect race. `hasConnected` flips true on
|
|
3672
|
+
// the first successful SSE open; `notFoundRetries` bounds retries of a 404
|
|
3673
|
+
// encountered BEFORE we ever connect (the run row is persisted slightly AFTER
|
|
3674
|
+
// the client opens the stream — the norm on the webchat path where msg-api owns
|
|
3675
|
+
// the executionId and cadra persists the agent_executions row via an async
|
|
3676
|
+
// worker callback). See handleConnectionError.
|
|
3677
|
+
hasConnected = false;
|
|
3678
|
+
notFoundRetries = 0;
|
|
3679
|
+
maxConnectRaceRetries = 3;
|
|
3669
3680
|
seenEventIds = /* @__PURE__ */ new Set();
|
|
3670
3681
|
_lastEventId = null;
|
|
3671
3682
|
activityTimeoutId = null;
|
|
@@ -3794,6 +3805,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
3794
3805
|
url,
|
|
3795
3806
|
authHeader: `Bearer ${authToken}`,
|
|
3796
3807
|
orgId: this.options.orgId,
|
|
3808
|
+
fetch: this.options.fetch,
|
|
3797
3809
|
onEvent: (event) => this.handleEvent(event),
|
|
3798
3810
|
onError: (error) => {
|
|
3799
3811
|
console.error("[SDK:StreamController] SSE error:", error);
|
|
@@ -3804,6 +3816,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
3804
3816
|
if (connected) {
|
|
3805
3817
|
this.status = "connected";
|
|
3806
3818
|
this.reconnectAttempts = 0;
|
|
3819
|
+
this.hasConnected = true;
|
|
3820
|
+
this.notFoundRetries = 0;
|
|
3807
3821
|
this.resetActivityTimeout();
|
|
3808
3822
|
}
|
|
3809
3823
|
this.emit("connectionChange", { connected, usingFallback: false });
|
|
@@ -4093,6 +4107,38 @@ var ExecutionStreamControllerImpl = class {
|
|
|
4093
4107
|
return;
|
|
4094
4108
|
}
|
|
4095
4109
|
const msg = error instanceof Error ? error.message : String(error);
|
|
4110
|
+
const isNotFound = /\b404\b/.test(msg);
|
|
4111
|
+
const isAuthFailure = /\b40[13]\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg);
|
|
4112
|
+
if (isNotFound && !isAuthFailure && !this.hasConnected) {
|
|
4113
|
+
if (this.notFoundRetries < this.maxConnectRaceRetries) {
|
|
4114
|
+
this.notFoundRetries++;
|
|
4115
|
+
this.status = "reconnecting";
|
|
4116
|
+
const delay = Math.min(
|
|
4117
|
+
this.config.reconnectBaseDelayMs * this.notFoundRetries,
|
|
4118
|
+
this.config.reconnectMaxDelayMs
|
|
4119
|
+
);
|
|
4120
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
4121
|
+
if (this.status === "closed") {
|
|
4122
|
+
return;
|
|
4123
|
+
}
|
|
4124
|
+
try {
|
|
4125
|
+
await this.connectSSE();
|
|
4126
|
+
} catch (retryError) {
|
|
4127
|
+
await this.handleConnectionError(retryError);
|
|
4128
|
+
}
|
|
4129
|
+
return;
|
|
4130
|
+
}
|
|
4131
|
+
if (this.pollingEnabled) {
|
|
4132
|
+
if (this.sseClient) {
|
|
4133
|
+
this.sseClient.disconnect();
|
|
4134
|
+
this.sseClient = null;
|
|
4135
|
+
}
|
|
4136
|
+
this.status = "fallback_polling";
|
|
4137
|
+
this.emit("connectionChange", { connected: false, usingFallback: true });
|
|
4138
|
+
this.startPolling();
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4096
4142
|
if (/\b4\d\d\b/.test(msg) || /INVALID_API_KEY|INVALID_REQUEST/.test(msg)) {
|
|
4097
4143
|
if (this.sseClient) {
|
|
4098
4144
|
this.sseClient.disconnect();
|
|
@@ -4471,6 +4517,7 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
4471
4517
|
apiKey: config.apiKey,
|
|
4472
4518
|
tokenProvider: config.tokenProvider,
|
|
4473
4519
|
orgId: config.orgId,
|
|
4520
|
+
fetch: config.fetch,
|
|
4474
4521
|
getExecution: (id) => this.getExecution(id)
|
|
4475
4522
|
});
|
|
4476
4523
|
console.log("[SDK:Agents] Stream controller created - caller must call connect() after registering listeners");
|
|
@@ -4517,6 +4564,7 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
4517
4564
|
apiKey: config.apiKey,
|
|
4518
4565
|
tokenProvider: config.tokenProvider,
|
|
4519
4566
|
orgId: config.orgId,
|
|
4567
|
+
fetch: config.fetch,
|
|
4520
4568
|
getExecution: (id) => this.getExecution(id)
|
|
4521
4569
|
});
|
|
4522
4570
|
console.log("[SDK:Agents] Stream controller created for existing execution - caller must call connect() after registering listeners");
|
|
@@ -5365,6 +5413,7 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
5365
5413
|
baseUrl: config.baseUrl,
|
|
5366
5414
|
apiKey: config.apiKey,
|
|
5367
5415
|
orgId: config.orgId,
|
|
5416
|
+
fetch: config.fetch,
|
|
5368
5417
|
getExecution: (id) => this.getExecution(id)
|
|
5369
5418
|
});
|
|
5370
5419
|
await controller.connect();
|
|
@@ -6019,7 +6068,8 @@ var CadraClient = class {
|
|
|
6019
6068
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
6020
6069
|
orgId: options.orgId,
|
|
6021
6070
|
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
6022
|
-
headers: options.headers
|
|
6071
|
+
headers: options.headers,
|
|
6072
|
+
fetch: options.fetch
|
|
6023
6073
|
};
|
|
6024
6074
|
if ("apiKey" in options) {
|
|
6025
6075
|
this.config.apiKey = options.apiKey;
|
|
@@ -6040,7 +6090,8 @@ var CadraClient = class {
|
|
|
6040
6090
|
orgId: this.config.orgId,
|
|
6041
6091
|
timeout: this.config.timeout,
|
|
6042
6092
|
retry: retryConfig,
|
|
6043
|
-
headers: this.config.headers
|
|
6093
|
+
headers: this.config.headers,
|
|
6094
|
+
fetch: this.config.fetch
|
|
6044
6095
|
};
|
|
6045
6096
|
this.httpClient = new HttpClient(httpConfig);
|
|
6046
6097
|
const getStreamConfig = () => ({
|
|
@@ -6048,7 +6099,8 @@ var CadraClient = class {
|
|
|
6048
6099
|
apiKey: this.config.apiKey,
|
|
6049
6100
|
token: this.config.token,
|
|
6050
6101
|
tokenProvider: this.config.tokenProvider,
|
|
6051
|
-
orgId: this.config.orgId
|
|
6102
|
+
orgId: this.config.orgId,
|
|
6103
|
+
fetch: this.config.fetch
|
|
6052
6104
|
});
|
|
6053
6105
|
this.agents = new AgentsAPI(this.httpClient, getStreamConfig);
|
|
6054
6106
|
this.skills = new SkillsAPI(this.httpClient);
|