@cadreen/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -0
- package/dist/client.d.ts +35 -0
- package/dist/client.js +205 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +62 -0
- package/dist/intelligence_helpers.d.ts +11 -0
- package/dist/intelligence_helpers.js +107 -0
- package/dist/resources/connections.d.ts +14 -0
- package/dist/resources/connections.js +37 -0
- package/dist/resources/executions.d.ts +8 -0
- package/dist/resources/executions.js +17 -0
- package/dist/resources/failures.d.ts +33 -0
- package/dist/resources/failures.js +51 -0
- package/dist/resources/guardrails.d.ts +12 -0
- package/dist/resources/guardrails.js +23 -0
- package/dist/resources/intent.d.ts +7 -0
- package/dist/resources/intent.js +77 -0
- package/dist/resources/memory.d.ts +9 -0
- package/dist/resources/memory.js +30 -0
- package/dist/resources/policies.d.ts +12 -0
- package/dist/resources/policies.js +26 -0
- package/dist/resources/skills.d.ts +41 -0
- package/dist/resources/skills.js +56 -0
- package/dist/resources/traces.d.ts +18 -0
- package/dist/resources/traces.js +58 -0
- package/dist/telemetry.d.ts +56 -0
- package/dist/telemetry.js +125 -0
- package/dist/types.d.ts +573 -0
- package/dist/types.js +38 -0
- package/package.json +37 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
export type HealthStatus = "healthy" | "degraded" | "unhealthy" | "unknown" | "latent";
|
|
2
|
+
export type ConnectorType = "mcp" | "openapi" | "composio" | "native_rest" | "utp" | "builtin" | "zenrows" | "bug0" | "instavm" | "direct";
|
|
3
|
+
export type CapabilitySource = "detected" | "built_in" | "mcp" | "openapi" | "composio" | "native_rest" | "utp" | "builtin" | "direct";
|
|
4
|
+
export type TransportType = "http" | "sse" | "stdio";
|
|
5
|
+
export type EscalationStatus = "pending" | "resolved" | "rejected";
|
|
6
|
+
export type CredentialType = "api_key" | "bearer" | "basic" | "oauth2" | "session";
|
|
7
|
+
export type AtomScope = "tenant" | "global" | "personal";
|
|
8
|
+
export type AtomType = "policy" | "procedure" | "precedent" | "decision" | "fact" | "metric" | "constraint" | "event" | "observation" | "error" | "mission" | "module" | "answer" | "image" | "video" | "audio" | "visualization" | "code" | "test" | "dataset" | "document" | "research" | "prompt" | "billing_event" | "opinion" | "instruction" | "definition" | "question" | "tool_invocation" | "tool_failure_pattern";
|
|
9
|
+
export type ErrorCategory = "auth" | "network" | "resource" | "logic" | "config" | "dependency" | "capability" | "rate_limit" | "timeout" | "validation" | "parsing" | "external" | "unknown";
|
|
10
|
+
export type RecoveryStrategyType = "retry" | "sub_execution" | "human_handoff" | "skip" | "reconfigure" | "regenerate" | "coerce" | "repair" | "re_decide" | "try_alternative" | "none";
|
|
11
|
+
export type StackItemSource = "user_data" | "cadreen" | "connector" | "gap" | "detected" | "built_in";
|
|
12
|
+
export type StackItemStatus = "existing" | "ready" | "healthy" | "degraded" | "unhealthy" | "unknown" | "pending_auth" | "connected" | "registered";
|
|
13
|
+
export type GovernanceDecisionType = "auto" | "auto_complete" | "handoff" | "escalate" | "clarify_requester" | "abstain";
|
|
14
|
+
export type RecoveryStatus = "diagnosing" | "recovering" | "sub_execution" | "escalating" | "recovered" | "failed" | "skipped";
|
|
15
|
+
export type IntentMode = "auto" | "chat" | "execution";
|
|
16
|
+
export interface Pagination {
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
has_more: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface Pathway {
|
|
22
|
+
id: string;
|
|
23
|
+
capability: string;
|
|
24
|
+
connector: ConnectorType;
|
|
25
|
+
transport: TransportType;
|
|
26
|
+
health: HealthStatus;
|
|
27
|
+
tool_id: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ConnectionGroup {
|
|
30
|
+
capability: string;
|
|
31
|
+
pathways?: Pathway[];
|
|
32
|
+
status: HealthStatus;
|
|
33
|
+
}
|
|
34
|
+
export interface ListConnectionsResponse {
|
|
35
|
+
connections: ConnectionGroup[];
|
|
36
|
+
total_capabilities: number;
|
|
37
|
+
total_pathways: number;
|
|
38
|
+
pagination?: Pagination;
|
|
39
|
+
}
|
|
40
|
+
export interface AtomContent {
|
|
41
|
+
text?: string;
|
|
42
|
+
source?: string;
|
|
43
|
+
subject?: string;
|
|
44
|
+
constraint?: string;
|
|
45
|
+
query?: string;
|
|
46
|
+
tools_used?: string[];
|
|
47
|
+
outcome?: string;
|
|
48
|
+
situation?: string;
|
|
49
|
+
action?: string;
|
|
50
|
+
result?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
constraints?: string[];
|
|
53
|
+
deadline?: string;
|
|
54
|
+
is_private?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface Atom {
|
|
57
|
+
id: string;
|
|
58
|
+
type: string;
|
|
59
|
+
domain: string;
|
|
60
|
+
scope?: AtomScope;
|
|
61
|
+
content?: AtomContent;
|
|
62
|
+
authority: number;
|
|
63
|
+
version: number;
|
|
64
|
+
tags?: string[];
|
|
65
|
+
created_at?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface CreateMemoryResponse {
|
|
68
|
+
id: string;
|
|
69
|
+
type: string;
|
|
70
|
+
domain: string;
|
|
71
|
+
scope?: AtomScope;
|
|
72
|
+
content?: AtomContent;
|
|
73
|
+
authority: number;
|
|
74
|
+
version: number;
|
|
75
|
+
indexed?: boolean;
|
|
76
|
+
tags?: string[];
|
|
77
|
+
created_at?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface SearchMemoryResponse {
|
|
80
|
+
results: Atom[];
|
|
81
|
+
count: number;
|
|
82
|
+
}
|
|
83
|
+
export interface Policy {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
domain: string;
|
|
87
|
+
priority: number;
|
|
88
|
+
requires_human: boolean;
|
|
89
|
+
approver_role?: string;
|
|
90
|
+
sla_hours?: number;
|
|
91
|
+
rationale?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface PolicyBundle {
|
|
94
|
+
id: string;
|
|
95
|
+
version: number;
|
|
96
|
+
name: string;
|
|
97
|
+
policies: Policy[];
|
|
98
|
+
created_at?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface GovernanceDecision {
|
|
101
|
+
type: GovernanceDecisionType;
|
|
102
|
+
confidence: number;
|
|
103
|
+
reason: string;
|
|
104
|
+
}
|
|
105
|
+
export interface EvaluatePolicyResponse {
|
|
106
|
+
action: string;
|
|
107
|
+
domain: string;
|
|
108
|
+
result: GovernanceDecision;
|
|
109
|
+
}
|
|
110
|
+
export interface CreatePolicyResponse {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
version: number;
|
|
114
|
+
status: string;
|
|
115
|
+
confirmation_required?: boolean;
|
|
116
|
+
approve_url?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface ConfirmPolicyResponse {
|
|
119
|
+
id: string;
|
|
120
|
+
version: number;
|
|
121
|
+
previous_version?: number;
|
|
122
|
+
status: string;
|
|
123
|
+
already_active?: boolean;
|
|
124
|
+
confirmed_at?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface Escalation {
|
|
127
|
+
id: string;
|
|
128
|
+
intent?: string;
|
|
129
|
+
status: EscalationStatus;
|
|
130
|
+
category?: string;
|
|
131
|
+
execution_id?: string;
|
|
132
|
+
tool_name?: string;
|
|
133
|
+
error_message?: string;
|
|
134
|
+
severity?: string;
|
|
135
|
+
human_prompt?: string;
|
|
136
|
+
suggestions?: string[];
|
|
137
|
+
created_at?: string;
|
|
138
|
+
resolved_at?: string;
|
|
139
|
+
resolved_by?: string;
|
|
140
|
+
resolution?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface ListEscalationsResponse {
|
|
143
|
+
escalations: Escalation[];
|
|
144
|
+
count: number;
|
|
145
|
+
pagination?: Pagination;
|
|
146
|
+
}
|
|
147
|
+
export interface CredentialMetadata {
|
|
148
|
+
id: string;
|
|
149
|
+
provider: string;
|
|
150
|
+
credential_name: string;
|
|
151
|
+
type?: CredentialType;
|
|
152
|
+
is_active: boolean;
|
|
153
|
+
has_credential_data: boolean;
|
|
154
|
+
}
|
|
155
|
+
export interface ListCredentialsResponse {
|
|
156
|
+
credentials: CredentialMetadata[];
|
|
157
|
+
count: number;
|
|
158
|
+
pagination?: Pagination;
|
|
159
|
+
}
|
|
160
|
+
export interface CapabilityMatch {
|
|
161
|
+
name: string;
|
|
162
|
+
human_name?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
score?: number;
|
|
165
|
+
matched_on?: string[];
|
|
166
|
+
health?: HealthStatus;
|
|
167
|
+
source?: CapabilitySource;
|
|
168
|
+
status?: HealthStatus;
|
|
169
|
+
functions?: string[];
|
|
170
|
+
category?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface ListCapabilitiesResponse {
|
|
173
|
+
available: CapabilityMatch[];
|
|
174
|
+
gaps?: Gap[];
|
|
175
|
+
count: number;
|
|
176
|
+
pagination?: Pagination;
|
|
177
|
+
}
|
|
178
|
+
export interface ListPoliciesResponse {
|
|
179
|
+
policies: Policy[];
|
|
180
|
+
version?: number;
|
|
181
|
+
pagination?: Pagination;
|
|
182
|
+
}
|
|
183
|
+
export interface Gap {
|
|
184
|
+
capability: string;
|
|
185
|
+
reason?: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
blocking: boolean;
|
|
188
|
+
severity: "blocking" | "high" | "medium" | "low" | "optional";
|
|
189
|
+
source?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface Outcome {
|
|
192
|
+
title: string;
|
|
193
|
+
description: string;
|
|
194
|
+
confidence: number;
|
|
195
|
+
ready: boolean;
|
|
196
|
+
blocked_by?: string[];
|
|
197
|
+
}
|
|
198
|
+
export interface Assessment {
|
|
199
|
+
task: string;
|
|
200
|
+
capabilities?: CapabilityMatch[];
|
|
201
|
+
gaps?: Gap[];
|
|
202
|
+
gap_filling_tasks?: unknown[];
|
|
203
|
+
blocking_gaps?: number;
|
|
204
|
+
policies_recommended?: PolicyRecommendation[];
|
|
205
|
+
needs_clarification?: string[];
|
|
206
|
+
can_do: number;
|
|
207
|
+
assessment_quality: "insufficient_data" | "partial" | "complete";
|
|
208
|
+
ready_capabilities: number;
|
|
209
|
+
total_capabilities: number;
|
|
210
|
+
gap_count: number;
|
|
211
|
+
ready_for_deployment: boolean;
|
|
212
|
+
stack?: StackBreakdown;
|
|
213
|
+
governance_decision?: GovernanceDecision;
|
|
214
|
+
outcomes?: Outcome[];
|
|
215
|
+
intelligence?: IntelligenceMeta;
|
|
216
|
+
}
|
|
217
|
+
export interface PolicyRecommendation {
|
|
218
|
+
policy: string;
|
|
219
|
+
reason: string;
|
|
220
|
+
action: string;
|
|
221
|
+
blocking: boolean;
|
|
222
|
+
}
|
|
223
|
+
export interface StackItem {
|
|
224
|
+
name: string;
|
|
225
|
+
type?: string;
|
|
226
|
+
source?: StackItemSource;
|
|
227
|
+
status?: StackItemStatus;
|
|
228
|
+
description?: string;
|
|
229
|
+
contains?: string[];
|
|
230
|
+
functions?: string[];
|
|
231
|
+
}
|
|
232
|
+
export interface StackBreakdown {
|
|
233
|
+
user_data?: StackItem[];
|
|
234
|
+
cadreen?: StackItem[];
|
|
235
|
+
connectors?: StackItem[];
|
|
236
|
+
gaps?: StackItem[];
|
|
237
|
+
}
|
|
238
|
+
export interface CapabilityTrace {
|
|
239
|
+
total_available: number;
|
|
240
|
+
healthy_count: number;
|
|
241
|
+
active_integrations?: string[];
|
|
242
|
+
}
|
|
243
|
+
export interface ReasoningTrace {
|
|
244
|
+
capability_matches?: number;
|
|
245
|
+
}
|
|
246
|
+
export interface MemoryTrace {
|
|
247
|
+
healthy: boolean;
|
|
248
|
+
knowledge_queried?: number;
|
|
249
|
+
}
|
|
250
|
+
export interface GovernanceTrace {
|
|
251
|
+
active: boolean;
|
|
252
|
+
decision?: string;
|
|
253
|
+
confidence?: number;
|
|
254
|
+
}
|
|
255
|
+
export interface HumilityTrace {
|
|
256
|
+
gaps_detected?: number;
|
|
257
|
+
blocking?: number;
|
|
258
|
+
}
|
|
259
|
+
export interface ProcessTrace {
|
|
260
|
+
started_at: string;
|
|
261
|
+
steps_taken: number;
|
|
262
|
+
duration_ms: number;
|
|
263
|
+
components?: Record<string, boolean>;
|
|
264
|
+
}
|
|
265
|
+
export interface NextAction {
|
|
266
|
+
type: "connect_tool" | "add_policy" | "add_memory" | "resolve_gap" | "check_auth" | "none";
|
|
267
|
+
label: string;
|
|
268
|
+
endpoint?: string;
|
|
269
|
+
reason: string;
|
|
270
|
+
}
|
|
271
|
+
export interface IntelligenceStage {
|
|
272
|
+
name: "capability_check" | "memory_lookup" | "governance_eval" | "gap_analysis" | "healing_attempt" | "execution" | "escalation" | "human_handoff";
|
|
273
|
+
status: "passed" | "failed" | "skipped" | "degraded" | "blocked";
|
|
274
|
+
duration_ms?: number;
|
|
275
|
+
detail?: string;
|
|
276
|
+
inputs?: Record<string, unknown>;
|
|
277
|
+
outputs?: Record<string, unknown>;
|
|
278
|
+
}
|
|
279
|
+
export interface FieldStability {
|
|
280
|
+
stable: string[];
|
|
281
|
+
evolving: string[];
|
|
282
|
+
internal: string[];
|
|
283
|
+
}
|
|
284
|
+
export interface IntelligenceMeta {
|
|
285
|
+
version?: string;
|
|
286
|
+
summary?: string;
|
|
287
|
+
capability: CapabilityTrace;
|
|
288
|
+
reasoning: ReasoningTrace;
|
|
289
|
+
memory: MemoryTrace;
|
|
290
|
+
governance: GovernanceTrace;
|
|
291
|
+
humility: HumilityTrace;
|
|
292
|
+
process: ProcessTrace;
|
|
293
|
+
next_action?: NextAction;
|
|
294
|
+
stages?: IntelligenceStage[];
|
|
295
|
+
field_stability: FieldStability;
|
|
296
|
+
}
|
|
297
|
+
export interface IntelligenceTraceEntry {
|
|
298
|
+
id: string;
|
|
299
|
+
domain: string;
|
|
300
|
+
request_path: string;
|
|
301
|
+
request_method: string;
|
|
302
|
+
meta: IntelligenceMeta;
|
|
303
|
+
created_at?: string;
|
|
304
|
+
}
|
|
305
|
+
export interface ListIntelligenceResponse {
|
|
306
|
+
traces: IntelligenceTraceEntry[];
|
|
307
|
+
count: number;
|
|
308
|
+
pagination?: Pagination;
|
|
309
|
+
}
|
|
310
|
+
export interface IntelligenceStats {
|
|
311
|
+
traces_24h: number;
|
|
312
|
+
traces_7d: number;
|
|
313
|
+
traces_30d: number;
|
|
314
|
+
avg_confidence_by_domain: Record<string, number>;
|
|
315
|
+
gap_detection_rate: number;
|
|
316
|
+
governance_decisions: Record<string, number>;
|
|
317
|
+
}
|
|
318
|
+
export interface IntentMessage {
|
|
319
|
+
role: "user" | "assistant" | "system";
|
|
320
|
+
content: string;
|
|
321
|
+
}
|
|
322
|
+
export interface IntentContext {
|
|
323
|
+
existing_connectors?: string[];
|
|
324
|
+
constraints?: Record<string, unknown>;
|
|
325
|
+
domain?: string;
|
|
326
|
+
}
|
|
327
|
+
export interface IntentRequest {
|
|
328
|
+
messages: IntentMessage[];
|
|
329
|
+
conversation_id?: string;
|
|
330
|
+
context?: IntentContext;
|
|
331
|
+
mode?: IntentMode;
|
|
332
|
+
stream?: boolean;
|
|
333
|
+
}
|
|
334
|
+
export interface ResponseMessage {
|
|
335
|
+
role: string;
|
|
336
|
+
content: string;
|
|
337
|
+
metadata?: Record<string, unknown>;
|
|
338
|
+
}
|
|
339
|
+
export interface ResponseExecution {
|
|
340
|
+
id: string;
|
|
341
|
+
status: string;
|
|
342
|
+
stream_url?: string;
|
|
343
|
+
poll_url?: string;
|
|
344
|
+
}
|
|
345
|
+
export interface ClarificationQuestion {
|
|
346
|
+
id: string;
|
|
347
|
+
question: string;
|
|
348
|
+
type: string;
|
|
349
|
+
required: boolean;
|
|
350
|
+
reason?: string;
|
|
351
|
+
}
|
|
352
|
+
export type IntentResult = {
|
|
353
|
+
type: "direct";
|
|
354
|
+
message: ResponseMessage;
|
|
355
|
+
intelligence: IntelligenceMeta;
|
|
356
|
+
traceId: string;
|
|
357
|
+
} | {
|
|
358
|
+
type: "clarify";
|
|
359
|
+
questions: ClarificationQuestion[];
|
|
360
|
+
conversationId: string;
|
|
361
|
+
intelligence: IntelligenceMeta;
|
|
362
|
+
traceId: string;
|
|
363
|
+
} | {
|
|
364
|
+
type: "execution";
|
|
365
|
+
execution: ResponseExecution;
|
|
366
|
+
intelligence: IntelligenceMeta;
|
|
367
|
+
traceId: string;
|
|
368
|
+
} | {
|
|
369
|
+
type: "blocked";
|
|
370
|
+
policy: {
|
|
371
|
+
name: string;
|
|
372
|
+
reason: string;
|
|
373
|
+
};
|
|
374
|
+
intelligence: IntelligenceMeta;
|
|
375
|
+
traceId: string;
|
|
376
|
+
} | {
|
|
377
|
+
type: "connect_required";
|
|
378
|
+
connection: {
|
|
379
|
+
endpoint: string;
|
|
380
|
+
reason: string;
|
|
381
|
+
};
|
|
382
|
+
intelligence: IntelligenceMeta;
|
|
383
|
+
traceId: string;
|
|
384
|
+
};
|
|
385
|
+
export interface IntentStatus {
|
|
386
|
+
ready: boolean;
|
|
387
|
+
needs: string[];
|
|
388
|
+
next: string;
|
|
389
|
+
}
|
|
390
|
+
export declare function intentStatus(result: IntentResult): IntentStatus;
|
|
391
|
+
export interface RegisterOpenAPIRequest {
|
|
392
|
+
name: string;
|
|
393
|
+
spec_url?: string;
|
|
394
|
+
spec_content?: string;
|
|
395
|
+
credential_id?: string;
|
|
396
|
+
}
|
|
397
|
+
export interface RegisterOpenAPIResponse {
|
|
398
|
+
id: string;
|
|
399
|
+
name: string;
|
|
400
|
+
type: string;
|
|
401
|
+
tools_generated?: number;
|
|
402
|
+
tools_registered?: number;
|
|
403
|
+
functions?: string[];
|
|
404
|
+
spec_url?: string;
|
|
405
|
+
status: string;
|
|
406
|
+
}
|
|
407
|
+
export interface RegisterMCPRequest {
|
|
408
|
+
name: string;
|
|
409
|
+
url: string;
|
|
410
|
+
transport?: TransportType;
|
|
411
|
+
headers?: Record<string, string>;
|
|
412
|
+
}
|
|
413
|
+
export interface RegisterMCPResponse {
|
|
414
|
+
id: string;
|
|
415
|
+
name: string;
|
|
416
|
+
type: string;
|
|
417
|
+
transport?: string;
|
|
418
|
+
url?: string;
|
|
419
|
+
status: string;
|
|
420
|
+
}
|
|
421
|
+
export interface InstallComposioRequest {
|
|
422
|
+
toolkit: string;
|
|
423
|
+
user_id?: string;
|
|
424
|
+
}
|
|
425
|
+
export interface SearchMemoryRequest {
|
|
426
|
+
query: string;
|
|
427
|
+
domain?: string;
|
|
428
|
+
tag?: string;
|
|
429
|
+
limit?: number;
|
|
430
|
+
}
|
|
431
|
+
export interface RememberRequest {
|
|
432
|
+
type: AtomType;
|
|
433
|
+
content: Record<string, unknown>;
|
|
434
|
+
domain?: string;
|
|
435
|
+
scope?: AtomScope;
|
|
436
|
+
authority?: number;
|
|
437
|
+
tags?: string[];
|
|
438
|
+
}
|
|
439
|
+
export interface CreatePolicyRequest {
|
|
440
|
+
name: string;
|
|
441
|
+
rules?: Record<string, unknown>[];
|
|
442
|
+
domain?: string;
|
|
443
|
+
auto_draft?: boolean;
|
|
444
|
+
}
|
|
445
|
+
export interface EvaluatePolicyRequest {
|
|
446
|
+
action: string;
|
|
447
|
+
domain?: string;
|
|
448
|
+
context?: Record<string, unknown>;
|
|
449
|
+
}
|
|
450
|
+
export interface ExecutionEvent {
|
|
451
|
+
type: string;
|
|
452
|
+
data: Record<string, unknown>;
|
|
453
|
+
}
|
|
454
|
+
export interface ExecutionStatus {
|
|
455
|
+
id: string;
|
|
456
|
+
status: string;
|
|
457
|
+
progress?: number;
|
|
458
|
+
result?: Record<string, unknown>;
|
|
459
|
+
error?: string;
|
|
460
|
+
}
|
|
461
|
+
export interface TraceExplain {
|
|
462
|
+
summary: string;
|
|
463
|
+
steps: string[];
|
|
464
|
+
recommendations?: string[];
|
|
465
|
+
}
|
|
466
|
+
export interface CadreenConfig {
|
|
467
|
+
apiKey: string;
|
|
468
|
+
baseUrl?: string;
|
|
469
|
+
maxRetries?: number;
|
|
470
|
+
timeout?: number;
|
|
471
|
+
telemetry?: unknown;
|
|
472
|
+
sandbox?: boolean;
|
|
473
|
+
fixtures?: Record<string, unknown>;
|
|
474
|
+
/** Response profile: "lean" (no envelope), "audit" (action-bearing only), "full" (default) */
|
|
475
|
+
profile?: "lean" | "audit" | "full";
|
|
476
|
+
}
|
|
477
|
+
export interface RequestOptions {
|
|
478
|
+
idempotencyKey?: string;
|
|
479
|
+
headers?: Record<string, string>;
|
|
480
|
+
}
|
|
481
|
+
export type ConnectResultType = "prebuilt" | "schema_required" | "manual" | "unknown";
|
|
482
|
+
export interface ConnectResult {
|
|
483
|
+
type: ConnectResultType;
|
|
484
|
+
capability: string;
|
|
485
|
+
detail: ConnectPrebuiltDetail | ConnectSchemaRequiredDetail | ConnectManualDetail | ConnectUnknownDetail;
|
|
486
|
+
}
|
|
487
|
+
export interface ConnectPrebuiltDetail {
|
|
488
|
+
tool_id: string;
|
|
489
|
+
tool_name: string;
|
|
490
|
+
service_id: string;
|
|
491
|
+
service_name: string;
|
|
492
|
+
auth_type: string;
|
|
493
|
+
account_id?: string;
|
|
494
|
+
source: string;
|
|
495
|
+
}
|
|
496
|
+
export interface ConnectSchemaRequiredDetail {
|
|
497
|
+
tool_id: string;
|
|
498
|
+
tool_name: string;
|
|
499
|
+
auth_url: string;
|
|
500
|
+
connector: string;
|
|
501
|
+
}
|
|
502
|
+
export interface ConnectManualDetail {
|
|
503
|
+
pathways: ConnectPathway[];
|
|
504
|
+
}
|
|
505
|
+
export interface ConnectPathway {
|
|
506
|
+
id: string;
|
|
507
|
+
connector: string;
|
|
508
|
+
tool_id: string;
|
|
509
|
+
health: string;
|
|
510
|
+
priority: number;
|
|
511
|
+
}
|
|
512
|
+
export interface ConnectUnknownDetail {
|
|
513
|
+
searched: string;
|
|
514
|
+
hints?: string[];
|
|
515
|
+
}
|
|
516
|
+
export interface SetupRequest {
|
|
517
|
+
connections?: Array<{
|
|
518
|
+
capability: string;
|
|
519
|
+
}>;
|
|
520
|
+
credentials?: Array<{
|
|
521
|
+
provider: string;
|
|
522
|
+
name?: string;
|
|
523
|
+
key_data: Record<string, unknown>;
|
|
524
|
+
}>;
|
|
525
|
+
memory?: Array<{
|
|
526
|
+
type?: string;
|
|
527
|
+
content: Record<string, unknown>;
|
|
528
|
+
domain?: string;
|
|
529
|
+
tags?: string[];
|
|
530
|
+
authority?: number;
|
|
531
|
+
}>;
|
|
532
|
+
policies?: Array<{
|
|
533
|
+
name: string;
|
|
534
|
+
description?: string;
|
|
535
|
+
rule: string;
|
|
536
|
+
severity?: string;
|
|
537
|
+
}>;
|
|
538
|
+
}
|
|
539
|
+
export interface SetupResult {
|
|
540
|
+
connections: Array<SetupConnectionResult>;
|
|
541
|
+
credentials: Array<SetupCredentialResult>;
|
|
542
|
+
memory: Array<SetupMemoryResult>;
|
|
543
|
+
policies: Array<SetupPolicyResult>;
|
|
544
|
+
applied: number;
|
|
545
|
+
failed: number;
|
|
546
|
+
}
|
|
547
|
+
export interface SetupConnectionResult {
|
|
548
|
+
capability: string;
|
|
549
|
+
status: "connected" | "schema_required" | "manual" | "unknown" | "failed";
|
|
550
|
+
detail?: ConnectPrebuiltDetail | ConnectSchemaRequiredDetail | ConnectManualDetail | ConnectUnknownDetail;
|
|
551
|
+
error?: string;
|
|
552
|
+
}
|
|
553
|
+
export interface SetupCredentialResult {
|
|
554
|
+
provider: string;
|
|
555
|
+
name: string;
|
|
556
|
+
id?: string;
|
|
557
|
+
status: "created" | "failed";
|
|
558
|
+
error?: string;
|
|
559
|
+
}
|
|
560
|
+
export interface SetupMemoryResult {
|
|
561
|
+
id: string;
|
|
562
|
+
type: string;
|
|
563
|
+
kind?: string;
|
|
564
|
+
classified: boolean;
|
|
565
|
+
status: "created" | "failed";
|
|
566
|
+
error?: string;
|
|
567
|
+
}
|
|
568
|
+
export interface SetupPolicyResult {
|
|
569
|
+
name: string;
|
|
570
|
+
id?: string;
|
|
571
|
+
status: "created" | "failed";
|
|
572
|
+
error?: string;
|
|
573
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function intentStatus(result) {
|
|
2
|
+
switch (result.type) {
|
|
3
|
+
case "direct":
|
|
4
|
+
return {
|
|
5
|
+
ready: true,
|
|
6
|
+
needs: [],
|
|
7
|
+
next: result.intelligence?.next_action?.type && result.intelligence.next_action.type !== "none"
|
|
8
|
+
? result.intelligence.next_action.label
|
|
9
|
+
: "done",
|
|
10
|
+
};
|
|
11
|
+
case "execution":
|
|
12
|
+
return {
|
|
13
|
+
ready: true,
|
|
14
|
+
needs: [],
|
|
15
|
+
next: result.execution.stream_url
|
|
16
|
+
? "stream execution"
|
|
17
|
+
: `poll ${result.execution.poll_url ?? result.execution.id}`,
|
|
18
|
+
};
|
|
19
|
+
case "clarify":
|
|
20
|
+
return {
|
|
21
|
+
ready: false,
|
|
22
|
+
needs: result.questions.map(q => q.question),
|
|
23
|
+
next: `answer ${result.questions.length} question${result.questions.length === 1 ? "" : "s"}`,
|
|
24
|
+
};
|
|
25
|
+
case "blocked":
|
|
26
|
+
return {
|
|
27
|
+
ready: false,
|
|
28
|
+
needs: [`resolve policy: ${result.policy.name} — ${result.policy.reason}`],
|
|
29
|
+
next: "resolve policy block",
|
|
30
|
+
};
|
|
31
|
+
case "connect_required":
|
|
32
|
+
return {
|
|
33
|
+
ready: false,
|
|
34
|
+
needs: [`connect ${result.connection.endpoint}`],
|
|
35
|
+
next: result.connection.endpoint,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cadreen/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for Cadreen — Intelligence as a Service",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cadreen",
|
|
25
|
+
"sdk",
|
|
26
|
+
"intelligence",
|
|
27
|
+
"automation",
|
|
28
|
+
"governance"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.4.0"
|
|
36
|
+
}
|
|
37
|
+
}
|