10xgraph-client 0.6.0 → 1.0.0-rc.2
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 +207 -0
- package/README.md +11 -5
- package/dist/agent.d.ts +17 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/cjs/agent.d.ts +33 -0
- package/dist/cjs/client.d.ts +533 -0
- package/dist/cjs/compat.d.ts +27 -0
- package/dist/cjs/endpoints/addThreadMessages.d.ts +25 -0
- package/dist/cjs/endpoints/clearThreadState.d.ts +14 -0
- package/dist/cjs/endpoints/deleteFile.d.ts +13 -0
- package/dist/cjs/endpoints/deleteMemory.d.ts +18 -0
- package/dist/cjs/endpoints/deleteThread.d.ts +18 -0
- package/dist/cjs/endpoints/deleteThreadMessage.d.ts +19 -0
- package/dist/cjs/endpoints/files.d.ts +115 -0
- package/dist/cjs/endpoints/fixGraph.d.ts +33 -0
- package/dist/cjs/endpoints/forgetMemories.d.ts +21 -0
- package/dist/cjs/endpoints/getMemory.d.ts +18 -0
- package/dist/cjs/endpoints/graph.d.ts +50 -0
- package/dist/cjs/endpoints/graphTools.d.ts +31 -0
- package/dist/cjs/endpoints/invoke.d.ts +66 -0
- package/dist/cjs/endpoints/listMemories.d.ts +24 -0
- package/dist/cjs/endpoints/metadata.d.ts +5 -0
- package/dist/cjs/endpoints/observability.d.ts +111 -0
- package/dist/cjs/endpoints/ping.d.ts +9 -0
- package/dist/cjs/endpoints/realtime.d.ts +154 -0
- package/dist/cjs/endpoints/searchMemory.d.ts +56 -0
- package/dist/cjs/endpoints/stateSchema.d.ts +49 -0
- package/dist/cjs/endpoints/stopGraph.d.ts +35 -0
- package/dist/cjs/endpoints/storeMemory.d.ts +32 -0
- package/dist/cjs/endpoints/stream.d.ts +67 -0
- package/dist/cjs/endpoints/threadDetails.d.ts +18 -0
- package/dist/cjs/endpoints/threadMessage.d.ts +16 -0
- package/dist/cjs/endpoints/threadMessages.d.ts +28 -0
- package/dist/cjs/endpoints/threadState.d.ts +13 -0
- package/dist/cjs/endpoints/threads.d.ts +35 -0
- package/dist/cjs/endpoints/updateMemory.d.ts +20 -0
- package/dist/cjs/endpoints/updateThreadMessageFeedback.d.ts +19 -0
- package/dist/cjs/endpoints/updateThreadState.d.ts +22 -0
- package/dist/cjs/endpoints/wsStream.d.ts +34 -0
- package/dist/cjs/errors.d.ts +212 -0
- package/dist/cjs/index.d.ts +41 -0
- package/dist/cjs/interrupt.d.ts +45 -0
- package/dist/cjs/message.d.ts +173 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/request.d.ts +60 -0
- package/dist/cjs/tools.d.ts +80 -0
- package/dist/cjs/ws.d.ts +47 -0
- package/dist/client.d.ts +95 -40
- package/dist/client.d.ts.map +1 -1
- package/dist/endpoints/addThreadMessages.d.ts +4 -0
- package/dist/endpoints/addThreadMessages.d.ts.map +1 -1
- package/dist/endpoints/clearThreadState.d.ts.map +1 -1
- package/dist/endpoints/deleteFile.d.ts +14 -0
- package/dist/endpoints/deleteFile.d.ts.map +1 -0
- package/dist/endpoints/deleteMemory.d.ts.map +1 -1
- package/dist/endpoints/deleteThread.d.ts.map +1 -1
- package/dist/endpoints/deleteThreadMessage.d.ts.map +1 -1
- package/dist/endpoints/files.d.ts +33 -0
- package/dist/endpoints/files.d.ts.map +1 -1
- package/dist/endpoints/fixGraph.d.ts +8 -3
- package/dist/endpoints/fixGraph.d.ts.map +1 -1
- package/dist/endpoints/forgetMemories.d.ts.map +1 -1
- package/dist/endpoints/getMemory.d.ts.map +1 -1
- package/dist/endpoints/graph.d.ts +20 -8
- package/dist/endpoints/graph.d.ts.map +1 -1
- package/dist/endpoints/graphTools.d.ts.map +1 -1
- package/dist/endpoints/invoke.d.ts +8 -0
- package/dist/endpoints/invoke.d.ts.map +1 -1
- package/dist/endpoints/listMemories.d.ts +6 -0
- package/dist/endpoints/listMemories.d.ts.map +1 -1
- package/dist/endpoints/observability.d.ts +54 -0
- package/dist/endpoints/observability.d.ts.map +1 -1
- package/dist/endpoints/ping.d.ts.map +1 -1
- package/dist/endpoints/realtime.d.ts +25 -4
- package/dist/endpoints/realtime.d.ts.map +1 -1
- package/dist/endpoints/searchMemory.d.ts.map +1 -1
- package/dist/endpoints/stateSchema.d.ts.map +1 -1
- package/dist/endpoints/stopGraph.d.ts +13 -3
- package/dist/endpoints/stopGraph.d.ts.map +1 -1
- package/dist/endpoints/storeMemory.d.ts.map +1 -1
- package/dist/endpoints/stream.d.ts +8 -0
- package/dist/endpoints/stream.d.ts.map +1 -1
- package/dist/endpoints/threadDetails.d.ts.map +1 -1
- package/dist/endpoints/threadMessage.d.ts.map +1 -1
- package/dist/endpoints/threadMessages.d.ts +6 -0
- package/dist/endpoints/threadMessages.d.ts.map +1 -1
- package/dist/endpoints/threadState.d.ts.map +1 -1
- package/dist/endpoints/threads.d.ts +6 -0
- package/dist/endpoints/threads.d.ts.map +1 -1
- package/dist/endpoints/updateMemory.d.ts.map +1 -1
- package/dist/endpoints/updateThreadMessageFeedback.d.ts +20 -0
- package/dist/endpoints/updateThreadMessageFeedback.d.ts.map +1 -0
- package/dist/endpoints/updateThreadState.d.ts +6 -1
- package/dist/endpoints/updateThreadState.d.ts.map +1 -1
- package/dist/endpoints/wsStream.d.ts +2 -0
- package/dist/endpoints/wsStream.d.ts.map +1 -1
- package/dist/errors.d.ts +60 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1742 -1217
- package/dist/index.js.map +1 -1
- package/dist/interrupt.d.ts +46 -0
- package/dist/interrupt.d.ts.map +1 -0
- package/dist/request.d.ts +28 -0
- package/dist/request.d.ts.map +1 -1
- package/dist/tools.d.ts +14 -0
- package/dist/tools.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/agent.ts +17 -4
- package/src/client.ts +248 -128
- package/src/endpoints/addThreadMessages.ts +15 -10
- package/src/endpoints/clearThreadState.ts +19 -20
- package/src/endpoints/deleteFile.ts +65 -0
- package/src/endpoints/deleteMemory.ts +9 -13
- package/src/endpoints/deleteThread.ts +9 -13
- package/src/endpoints/deleteThreadMessage.ts +9 -13
- package/src/endpoints/files.ts +164 -131
- package/src/endpoints/fixGraph.ts +15 -16
- package/src/endpoints/forgetMemories.ts +44 -60
- package/src/endpoints/getMemory.ts +9 -9
- package/src/endpoints/graph.ts +28 -21
- package/src/endpoints/graphTools.ts +7 -13
- package/src/endpoints/invoke.ts +105 -84
- package/src/endpoints/listMemories.ts +18 -13
- package/src/endpoints/observability.ts +77 -34
- package/src/endpoints/ping.ts +7 -13
- package/src/endpoints/realtime.ts +101 -39
- package/src/endpoints/searchMemory.ts +19 -13
- package/src/endpoints/stateSchema.ts +7 -13
- package/src/endpoints/stopGraph.ts +20 -16
- package/src/endpoints/storeMemory.ts +7 -8
- package/src/endpoints/stream.ts +179 -61
- package/src/endpoints/threadDetails.ts +9 -14
- package/src/endpoints/threadMessage.ts +9 -9
- package/src/endpoints/threadMessages.ts +15 -9
- package/src/endpoints/threadState.ts +19 -20
- package/src/endpoints/threads.ts +13 -12
- package/src/endpoints/updateMemory.ts +9 -9
- package/src/endpoints/updateThreadMessageFeedback.ts +80 -0
- package/src/endpoints/updateThreadState.ts +28 -22
- package/src/endpoints/wsStream.ts +167 -42
- package/src/errors.ts +332 -93
- package/src/index.ts +9 -0
- package/src/interrupt.ts +60 -0
- package/src/request.ts +134 -0
- package/src/tools.ts +95 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
import { MemoryType } from './storeMemory.js';
|
|
4
|
+
export interface SearchMemoryContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Memory retrieval strategies
|
|
8
|
+
*/
|
|
9
|
+
export declare enum RetrievalStrategy {
|
|
10
|
+
SIMILARITY = "similarity",// Vector similarity search
|
|
11
|
+
TEMPORAL = "temporal",// Time-based retrieval
|
|
12
|
+
RELEVANCE = "relevance",// Relevance scoring
|
|
13
|
+
HYBRID = "hybrid",// Combined approaches
|
|
14
|
+
GRAPH_TRAVERSAL = "graph_traversal"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Supported distance metrics for vector similarity
|
|
18
|
+
*/
|
|
19
|
+
export declare enum DistanceMetric {
|
|
20
|
+
COSINE = "cosine",
|
|
21
|
+
EUCLIDEAN = "euclidean",
|
|
22
|
+
DOT_PRODUCT = "dot_product",
|
|
23
|
+
MANHATTAN = "manhattan"
|
|
24
|
+
}
|
|
25
|
+
export interface SearchMemoryRequest {
|
|
26
|
+
config?: Record<string, any>;
|
|
27
|
+
options?: Record<string, any>;
|
|
28
|
+
query: string;
|
|
29
|
+
memory_type?: MemoryType;
|
|
30
|
+
category?: string;
|
|
31
|
+
limit?: number;
|
|
32
|
+
score_threshold?: number;
|
|
33
|
+
filters?: Record<string, any>;
|
|
34
|
+
retrieval_strategy?: RetrievalStrategy;
|
|
35
|
+
distance_metric?: DistanceMetric;
|
|
36
|
+
max_tokens?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface MemoryResult {
|
|
39
|
+
id: string;
|
|
40
|
+
content: string;
|
|
41
|
+
score: number;
|
|
42
|
+
memory_type: string;
|
|
43
|
+
metadata: Record<string, any>;
|
|
44
|
+
vector: number[];
|
|
45
|
+
user_id: string;
|
|
46
|
+
thread_id: string;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SearchMemoryData {
|
|
50
|
+
results: MemoryResult[];
|
|
51
|
+
}
|
|
52
|
+
export interface SearchMemoryResponse {
|
|
53
|
+
data: SearchMemoryData;
|
|
54
|
+
metadata: ResponseMetadata;
|
|
55
|
+
}
|
|
56
|
+
export declare function searchMemory(context: SearchMemoryContext, request: SearchMemoryRequest): Promise<SearchMemoryResponse>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface StateSchemaContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* JSON Schema definition for a field in AgentState
|
|
7
|
+
* Contains type information, description, validation rules, and default values
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldSchema {
|
|
10
|
+
type?: string | string[];
|
|
11
|
+
description?: string;
|
|
12
|
+
default?: any;
|
|
13
|
+
items?: any;
|
|
14
|
+
properties?: Record<string, FieldSchema>;
|
|
15
|
+
required?: string[];
|
|
16
|
+
enum?: any[];
|
|
17
|
+
$ref?: string;
|
|
18
|
+
$defs?: Record<string, any>;
|
|
19
|
+
anyOf?: any[];
|
|
20
|
+
allOf?: any[];
|
|
21
|
+
oneOf?: any[];
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Complete JSON Schema for AgentState
|
|
26
|
+
* Describes all available fields, their types, constraints, and meanings
|
|
27
|
+
*/
|
|
28
|
+
export interface AgentStateSchema {
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
properties: Record<string, FieldSchema>;
|
|
33
|
+
required?: string[];
|
|
34
|
+
$defs?: Record<string, any>;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Response containing the complete AgentState schema
|
|
39
|
+
* Users can use this to:
|
|
40
|
+
* - Understand field types and structure
|
|
41
|
+
* - Build dynamic forms or validation
|
|
42
|
+
* - Know what fields are available and required
|
|
43
|
+
* - See field descriptions and constraints
|
|
44
|
+
*/
|
|
45
|
+
export interface StateSchemaResponse {
|
|
46
|
+
data: AgentStateSchema;
|
|
47
|
+
metadata: ResponseMetadata;
|
|
48
|
+
}
|
|
49
|
+
export declare function stateSchema(context: StateSchemaContext): Promise<StateSchemaResponse>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface StopGraphContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
export interface StopGraphRequest {
|
|
6
|
+
thread_id: string;
|
|
7
|
+
config?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export interface StopGraphResponse {
|
|
10
|
+
data: {
|
|
11
|
+
/** False when the thread has no checkpointer or no saved state. */
|
|
12
|
+
ok: boolean;
|
|
13
|
+
/** True when a run was active and a stop was requested. */
|
|
14
|
+
running?: boolean;
|
|
15
|
+
/** Why nothing was stopped, e.g. 'no-checkpointer' or 'no-state'. */
|
|
16
|
+
reason?: string;
|
|
17
|
+
/** @deprecated The server never sends this field. Use `ok`. */
|
|
18
|
+
success?: boolean;
|
|
19
|
+
/** @deprecated The server never sends this field. */
|
|
20
|
+
message?: string;
|
|
21
|
+
/** @deprecated The server never sends this field. */
|
|
22
|
+
thread_id?: string;
|
|
23
|
+
/** @deprecated The server never sends this field. */
|
|
24
|
+
stopped_at?: string;
|
|
25
|
+
};
|
|
26
|
+
metadata: ResponseMetadata;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Stop a running graph execution for a specific thread
|
|
30
|
+
*
|
|
31
|
+
* @param context - Request context with baseUrl, auth, timeout
|
|
32
|
+
* @param request - Stop request with thread_id and optional config
|
|
33
|
+
* @returns Promise<StopGraphResponse> with stop operation result
|
|
34
|
+
*/
|
|
35
|
+
export declare function stopGraph(context: StopGraphContext, request: StopGraphRequest): Promise<StopGraphResponse>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface StoreMemoryContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Types of memories that can be stored
|
|
7
|
+
*/
|
|
8
|
+
export declare enum MemoryType {
|
|
9
|
+
EPISODIC = "episodic",// Conversation memories
|
|
10
|
+
SEMANTIC = "semantic",// Facts and knowledge
|
|
11
|
+
PROCEDURAL = "procedural",// How-to knowledge
|
|
12
|
+
ENTITY = "entity",// Entity-based memories
|
|
13
|
+
RELATIONSHIP = "relationship",// Entity relationships
|
|
14
|
+
CUSTOM = "custom",// Custom memory types
|
|
15
|
+
DECLARATIVE = "declarative"
|
|
16
|
+
}
|
|
17
|
+
export interface StoreMemoryRequest {
|
|
18
|
+
config?: Record<string, any>;
|
|
19
|
+
options?: Record<string, any>;
|
|
20
|
+
content: string;
|
|
21
|
+
memory_type: MemoryType;
|
|
22
|
+
category: string;
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
export interface StoreMemoryData {
|
|
26
|
+
memory_id: string;
|
|
27
|
+
}
|
|
28
|
+
export interface StoreMemoryResponse {
|
|
29
|
+
data: StoreMemoryData;
|
|
30
|
+
metadata: ResponseMetadata;
|
|
31
|
+
}
|
|
32
|
+
export declare function storeMemory(context: StoreMemoryContext, request: StoreMemoryRequest): Promise<StoreMemoryResponse>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Message } from '../message.js';
|
|
2
|
+
import { AgentState } from '../agent.js';
|
|
3
|
+
import { ToolExecutor } from '../tools.js';
|
|
4
|
+
import { RequestContext } from '../request.js';
|
|
5
|
+
export interface StreamContext extends RequestContext {
|
|
6
|
+
toolExecutor?: ToolExecutor;
|
|
7
|
+
/** Caller-supplied signal; aborting it cancels the request, including the open stream. */
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
export interface StreamRequest {
|
|
11
|
+
messages: any[];
|
|
12
|
+
initial_state?: Record<string, any>;
|
|
13
|
+
config?: Record<string, any>;
|
|
14
|
+
recursion_limit?: number;
|
|
15
|
+
/** What to do when another run is active on the same thread (server default: 'wait'). */
|
|
16
|
+
on_busy?: 'wait' | 'cancel';
|
|
17
|
+
/** Value that answers an open interrupt. Send together with `interrupt_id`. */
|
|
18
|
+
resume?: unknown;
|
|
19
|
+
/** Id of the interrupt being answered by `resume`. */
|
|
20
|
+
interrupt_id?: string;
|
|
21
|
+
response_granularity?: 'full' | 'partial' | 'low';
|
|
22
|
+
}
|
|
23
|
+
export declare enum StreamEventType {
|
|
24
|
+
MESSAGE = "message",
|
|
25
|
+
UPDATES = "updates",
|
|
26
|
+
STATE = "state",
|
|
27
|
+
ERROR = "error"
|
|
28
|
+
}
|
|
29
|
+
export interface StreamMetadata {
|
|
30
|
+
is_new_thread: boolean;
|
|
31
|
+
thread_id: string;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}
|
|
34
|
+
export interface StreamChunk {
|
|
35
|
+
event: StreamEventType | string;
|
|
36
|
+
message?: Message | null;
|
|
37
|
+
state?: AgentState | null;
|
|
38
|
+
data?: any;
|
|
39
|
+
thread_id?: string;
|
|
40
|
+
run_id?: string;
|
|
41
|
+
metadata?: StreamMetadata | Record<string, any>;
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Stream invoke to the graph with automatic tool execution loop
|
|
46
|
+
* Returns an async iterable that yields stream chunks as they arrive
|
|
47
|
+
*
|
|
48
|
+
* This implements the same tool execution loop as invoke(), but uses
|
|
49
|
+
* HTTP streaming instead of REST API calls.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const stream = streamInvoke(context, request);
|
|
54
|
+
* for await (const chunk of stream) {
|
|
55
|
+
* if (chunk.event === 'message') {
|
|
56
|
+
* console.log('Message:', chunk.message);
|
|
57
|
+
* } else if (chunk.event === 'updates') {
|
|
58
|
+
* console.log('State:', chunk.state);
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function streamInvoke(context: StreamContext, request: StreamRequest): AsyncGenerator<StreamChunk, void, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Serialize a Message object for API transmission
|
|
66
|
+
*/
|
|
67
|
+
export declare function serializeMessage(message: Message): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface ThreadDetailsContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
export interface ThreadDetailsData {
|
|
6
|
+
thread_data: {
|
|
7
|
+
thread: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ThreadDetailsResponse {
|
|
11
|
+
data: ThreadDetailsData;
|
|
12
|
+
metadata: ResponseMetadata;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Fetch details for a specific thread.
|
|
16
|
+
* GET /v1/threads/{threadId}
|
|
17
|
+
*/
|
|
18
|
+
export declare function threadDetails(context: ThreadDetailsContext, threadId: string | number): Promise<ThreadDetailsResponse>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { Message } from '../message.js';
|
|
3
|
+
import { RequestContext } from '../request.js';
|
|
4
|
+
export interface ThreadMessageContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
export interface ThreadMessageRequest {
|
|
7
|
+
threadId: string | number;
|
|
8
|
+
messageId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ThreadMessageData extends Message {
|
|
11
|
+
}
|
|
12
|
+
export interface ThreadMessageResponse {
|
|
13
|
+
data: ThreadMessageData;
|
|
14
|
+
metadata: ResponseMetadata;
|
|
15
|
+
}
|
|
16
|
+
export declare function threadMessage(context: ThreadMessageContext, request: ThreadMessageRequest): Promise<ThreadMessageResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { Message } from '../message.js';
|
|
3
|
+
import { RequestContext } from '../request.js';
|
|
4
|
+
export interface ThreadMessagesContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
export interface ThreadMessagesRequest {
|
|
7
|
+
threadId: string | number;
|
|
8
|
+
search?: string;
|
|
9
|
+
offset?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ThreadMessagesData {
|
|
13
|
+
messages: Message[];
|
|
14
|
+
/** True when more messages exist after this page. Absent on servers older than 1.0.0. */
|
|
15
|
+
has_more?: boolean;
|
|
16
|
+
/** Offset the server applied. */
|
|
17
|
+
offset?: number;
|
|
18
|
+
/** Limit the server applied (after its default and maximum clamp). */
|
|
19
|
+
limit?: number;
|
|
20
|
+
}
|
|
21
|
+
export type CheckpointMessagesData = ThreadMessagesData;
|
|
22
|
+
export interface ThreadMessagesResponse {
|
|
23
|
+
data: ThreadMessagesData;
|
|
24
|
+
metadata: ResponseMetadata;
|
|
25
|
+
}
|
|
26
|
+
export type CheckpointMessagesResponse = ThreadMessagesResponse;
|
|
27
|
+
export declare function threadMessages(context: ThreadMessagesContext, request: ThreadMessagesRequest): Promise<ThreadMessagesResponse>;
|
|
28
|
+
export declare const checkpointMessages: typeof threadMessages;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { AgentState } from '../agent.js';
|
|
3
|
+
import { RequestContext } from '../request.js';
|
|
4
|
+
export interface ThreadStateContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
export interface ThreadStateData {
|
|
7
|
+
state: AgentState;
|
|
8
|
+
}
|
|
9
|
+
export interface ThreadStateResponse {
|
|
10
|
+
data: ThreadStateData;
|
|
11
|
+
metadata: ResponseMetadata;
|
|
12
|
+
}
|
|
13
|
+
export declare function threadState(context: ThreadStateContext, threadId: string | number): Promise<ThreadStateResponse>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface ThreadsContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
export interface ThreadsRequest {
|
|
6
|
+
search?: string;
|
|
7
|
+
offset?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ThreadItem {
|
|
11
|
+
thread_id: string;
|
|
12
|
+
thread_name: string | null;
|
|
13
|
+
user_id: string | null;
|
|
14
|
+
metadata: Record<string, any> | null;
|
|
15
|
+
updated_at: string | null;
|
|
16
|
+
run_id: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface ThreadsData {
|
|
19
|
+
threads: ThreadItem[];
|
|
20
|
+
/** True when more threads exist after this page. Absent on servers older than 1.0.0. */
|
|
21
|
+
has_more?: boolean;
|
|
22
|
+
/** Offset the server applied. */
|
|
23
|
+
offset?: number;
|
|
24
|
+
/** Limit the server applied (after its default and maximum clamp). */
|
|
25
|
+
limit?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ThreadsResponse {
|
|
28
|
+
data: ThreadsData;
|
|
29
|
+
metadata: ResponseMetadata;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetch list of threads with optional search and pagination
|
|
33
|
+
* GET /v1/threads
|
|
34
|
+
*/
|
|
35
|
+
export declare function threads(context: ThreadsContext, request?: ThreadsRequest): Promise<ThreadsResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
export interface UpdateMemoryContext extends RequestContext {
|
|
4
|
+
}
|
|
5
|
+
export interface UpdateMemoryRequest {
|
|
6
|
+
memoryId: string;
|
|
7
|
+
config?: Record<string, any>;
|
|
8
|
+
options?: Record<string, any>;
|
|
9
|
+
content: string;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface UpdateMemoryData {
|
|
13
|
+
success: boolean;
|
|
14
|
+
data: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
export interface UpdateMemoryResponse {
|
|
17
|
+
data: UpdateMemoryData;
|
|
18
|
+
metadata: ResponseMetadata;
|
|
19
|
+
}
|
|
20
|
+
export declare function updateMemory(context: UpdateMemoryContext, request: UpdateMemoryRequest): Promise<UpdateMemoryResponse>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { ThreadMessageData } from './threadMessage.js';
|
|
3
|
+
import { RequestContext } from '../request.js';
|
|
4
|
+
export interface UpdateThreadMessageFeedbackContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
export interface UpdateThreadMessageFeedbackRequest {
|
|
7
|
+
threadId: string | number;
|
|
8
|
+
messageId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Any JSON object. Replaces `message.metadata.feedback`. The server rejects
|
|
11
|
+
* feedback larger than 8192 serialized bytes or nested deeper than 10 levels (HTTP 422).
|
|
12
|
+
*/
|
|
13
|
+
feedback: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateThreadMessageFeedbackResponse {
|
|
16
|
+
data: ThreadMessageData;
|
|
17
|
+
metadata: ResponseMetadata;
|
|
18
|
+
}
|
|
19
|
+
export declare function updateThreadMessageFeedback(context: UpdateThreadMessageFeedbackContext, request: UpdateThreadMessageFeedbackRequest): Promise<UpdateThreadMessageFeedbackResponse>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ResponseMetadata } from './metadata.js';
|
|
2
|
+
import { AgentState } from '../agent.js';
|
|
3
|
+
import { RequestContext } from '../request.js';
|
|
4
|
+
export interface UpdateThreadStateContext extends RequestContext {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* State fields the server accepts on update. `context_summary` and `execution_meta` are
|
|
8
|
+
* rejected by the server, so they are not part of this type.
|
|
9
|
+
*/
|
|
10
|
+
export type UpdatableThreadState = Partial<Omit<AgentState, 'context_summary' | 'execution_meta'>> & Record<string, any>;
|
|
11
|
+
export interface UpdateThreadStateRequest {
|
|
12
|
+
config: Record<string, any>;
|
|
13
|
+
state: UpdatableThreadState;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateThreadStateData {
|
|
16
|
+
state: AgentState;
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateThreadStateResponse {
|
|
19
|
+
data: UpdateThreadStateData;
|
|
20
|
+
metadata: ResponseMetadata;
|
|
21
|
+
}
|
|
22
|
+
export declare function updateThreadState(context: UpdateThreadStateContext, threadId: string | number, request: UpdateThreadStateRequest): Promise<UpdateThreadStateResponse>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ToolExecutor } from '../tools.js';
|
|
2
|
+
import { RequestContext } from '../request.js';
|
|
3
|
+
import { StreamChunk, StreamRequest } from './stream.js';
|
|
4
|
+
export interface WsStreamContext extends RequestContext {
|
|
5
|
+
toolExecutor?: ToolExecutor;
|
|
6
|
+
/** Caller-supplied signal; aborting it closes the socket and ends the stream. */
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Stream invoke via a persistent WebSocket connection.
|
|
11
|
+
*
|
|
12
|
+
* The protocol is:
|
|
13
|
+
*
|
|
14
|
+
* 1. Connect to ``/v1/graph/ws`` (auth via the ``10xgraph-bearer`` subprotocol or Authorization header).
|
|
15
|
+
* 2. Send ``{ invoke_type:"fresh", messages:[…], config:{…}, … }``.
|
|
16
|
+
* 3. Receive ``StreamChunk`` JSON messages; yield each to the caller.
|
|
17
|
+
* 4. Server sends ``{ event:"updates", data:{ status:"done" } }`` after each run.
|
|
18
|
+
* 5. If the run contained remote tool calls, execute them and send:
|
|
19
|
+
* ``{ invoke_type:"resume", tool_result:[…], config:{ thread_id } }``.
|
|
20
|
+
* 6. Repeat from step 3 until no more tool calls.
|
|
21
|
+
* 7. Close the WebSocket.
|
|
22
|
+
*
|
|
23
|
+
* This replaces the HTTP loop in ``streamInvoke`` — the round-trip cost of
|
|
24
|
+
* re-opening a new HTTP connection for each tool call is eliminated.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const stream = wsStreamInvoke(context, request);
|
|
29
|
+
* for await (const chunk of stream) {
|
|
30
|
+
* if (chunk.event === 'message') console.log(chunk.message);
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function wsStreamInvoke(context: WsStreamContext, request: StreamRequest): AsyncGenerator<StreamChunk, void, unknown>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling for 10xGraph API
|
|
3
|
+
* Provides structured error types for all HTTP status codes
|
|
4
|
+
*/
|
|
5
|
+
export interface ErrorDetail {
|
|
6
|
+
loc?: string[];
|
|
7
|
+
msg?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiErrorResponse {
|
|
11
|
+
metadata: {
|
|
12
|
+
message: string;
|
|
13
|
+
request_id: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
};
|
|
16
|
+
error: {
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
details: ErrorDetail[];
|
|
20
|
+
/** Present on 429 replies. */
|
|
21
|
+
retry_after_seconds?: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Base error class for all 10xGraph API errors
|
|
26
|
+
*/
|
|
27
|
+
export declare class TenxGraphError extends Error {
|
|
28
|
+
readonly statusCode: number;
|
|
29
|
+
readonly errorCode: string;
|
|
30
|
+
readonly requestId: string;
|
|
31
|
+
readonly timestamp: string;
|
|
32
|
+
readonly details: ErrorDetail[];
|
|
33
|
+
readonly context?: Record<string, any>;
|
|
34
|
+
endpoint?: string;
|
|
35
|
+
method?: string;
|
|
36
|
+
readonly recoverySuggestion?: string;
|
|
37
|
+
/** Underlying error (fetch rejection, socket error) when there is one. */
|
|
38
|
+
cause?: unknown;
|
|
39
|
+
/** Response headers of the failed HTTP reply, lowercased names. Absent for transport errors. */
|
|
40
|
+
responseHeaders?: Record<string, string>;
|
|
41
|
+
/** Parsed JSON body (or raw text) of the failed HTTP reply, before any normalisation. */
|
|
42
|
+
responseBody?: unknown;
|
|
43
|
+
constructor(message: string, statusCode: number, errorCode: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>, endpoint?: string, method?: string, recoverySuggestion?: string);
|
|
44
|
+
/**
|
|
45
|
+
* Get a user-friendly error message with recovery suggestion
|
|
46
|
+
*/
|
|
47
|
+
getUserMessage(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get full error details for debugging
|
|
50
|
+
*/
|
|
51
|
+
toJSON(): Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 400 Bad Request Error
|
|
55
|
+
* Thrown when the request is malformed or contains invalid data
|
|
56
|
+
*/
|
|
57
|
+
export declare class BadRequestError extends TenxGraphError {
|
|
58
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 401 Unauthorized Error
|
|
62
|
+
* Thrown when authentication credentials are missing or invalid
|
|
63
|
+
*/
|
|
64
|
+
export declare class AuthenticationError extends TenxGraphError {
|
|
65
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 403 Forbidden Error
|
|
69
|
+
* Thrown when the user doesn't have permission to access the resource
|
|
70
|
+
*/
|
|
71
|
+
export declare class PermissionError extends TenxGraphError {
|
|
72
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 404 Not Found Error
|
|
76
|
+
* Thrown when the requested resource doesn't exist
|
|
77
|
+
*/
|
|
78
|
+
export declare class NotFoundError extends TenxGraphError {
|
|
79
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 409 Conflict Error
|
|
83
|
+
* Thrown when the thread is busy with another run, or when a resume's
|
|
84
|
+
* `interrupt_id` does not match the open interrupt. Never retried automatically.
|
|
85
|
+
*/
|
|
86
|
+
export declare class ConflictError extends TenxGraphError {
|
|
87
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 422 Validation Error
|
|
91
|
+
* Thrown when the request data fails validation
|
|
92
|
+
*/
|
|
93
|
+
export declare class ValidationError extends TenxGraphError {
|
|
94
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[]);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 500 Server Error
|
|
98
|
+
* Thrown when the server encounters an internal error
|
|
99
|
+
*/
|
|
100
|
+
export declare class ServerError extends TenxGraphError {
|
|
101
|
+
constructor(message: string, requestId: string, timestamp: string, errorCode?: string, details?: ErrorDetail[], statusCode?: number);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Graph Error
|
|
105
|
+
* Thrown when there's an error in graph execution
|
|
106
|
+
*/
|
|
107
|
+
export declare class GraphError extends TenxGraphError {
|
|
108
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Node Error
|
|
112
|
+
* Thrown when there's an error executing a specific node
|
|
113
|
+
*/
|
|
114
|
+
export declare class NodeError extends TenxGraphError {
|
|
115
|
+
readonly nodeName?: string;
|
|
116
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>, nodeName?: string);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Graph Recursion Error
|
|
120
|
+
* Thrown when graph execution exceeds the recursion limit
|
|
121
|
+
*/
|
|
122
|
+
export declare class GraphRecursionError extends TenxGraphError {
|
|
123
|
+
readonly recursionLimit?: number;
|
|
124
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>, recursionLimit?: number);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Storage Error
|
|
128
|
+
* Thrown when there's an error accessing storage
|
|
129
|
+
*/
|
|
130
|
+
export declare class StorageError extends TenxGraphError {
|
|
131
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Transient Storage Error
|
|
135
|
+
* Thrown when there's a temporary storage issue (503 Service Unavailable)
|
|
136
|
+
*/
|
|
137
|
+
export declare class TransientStorageError extends TenxGraphError {
|
|
138
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Metrics Error
|
|
142
|
+
* Thrown when there's an error collecting or reporting metrics
|
|
143
|
+
*/
|
|
144
|
+
export declare class MetricsError extends TenxGraphError {
|
|
145
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Schema Version Error
|
|
149
|
+
* Thrown when there's a version mismatch in data schemas
|
|
150
|
+
*/
|
|
151
|
+
export declare class SchemaVersionError extends TenxGraphError {
|
|
152
|
+
readonly expectedVersion?: string;
|
|
153
|
+
readonly actualVersion?: string;
|
|
154
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>, expectedVersion?: string, actualVersion?: string);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Serialization Error
|
|
158
|
+
* Thrown when there's an error serializing or deserializing data
|
|
159
|
+
*/
|
|
160
|
+
export declare class SerializationError extends TenxGraphError {
|
|
161
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], context?: Record<string, any>);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 429 Too Many Requests
|
|
165
|
+
* Carries the server's retry hint in seconds (Retry-After header, else the body's
|
|
166
|
+
* `retry_after_seconds`), or undefined when the server sent none.
|
|
167
|
+
*/
|
|
168
|
+
export declare class RateLimitError extends TenxGraphError {
|
|
169
|
+
readonly retryAfterSeconds?: number;
|
|
170
|
+
constructor(message: string, requestId: string, timestamp: string, details?: ErrorDetail[], retryAfterSeconds?: number);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Request Timeout Error
|
|
174
|
+
* Thrown client-side when a request exceeds the configured `timeout`. statusCode is 0.
|
|
175
|
+
*/
|
|
176
|
+
export declare class RequestTimeoutError extends TenxGraphError {
|
|
177
|
+
readonly timeoutMs: number;
|
|
178
|
+
constructor(timeoutMs: number, endpoint?: string, method?: string, cause?: unknown);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Network Error
|
|
182
|
+
* Thrown when the request never got an HTTP reply (DNS failure, connection refused, offline,
|
|
183
|
+
* CORS block). `cause` holds the underlying fetch error. statusCode is 0.
|
|
184
|
+
*/
|
|
185
|
+
export declare class NetworkError extends TenxGraphError {
|
|
186
|
+
constructor(message: string, endpoint?: string, method?: string, cause?: unknown);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* WebSocket Error
|
|
190
|
+
* Thrown for WebSocket failures: connection errors, unexpected close, handshake rejection.
|
|
191
|
+
* `closeCode` is the close frame code when the failure was a close.
|
|
192
|
+
*/
|
|
193
|
+
export declare class WebSocketError extends TenxGraphError {
|
|
194
|
+
readonly closeCode?: number;
|
|
195
|
+
constructor(message: string, closeCode?: number, endpoint?: string, cause?: unknown);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Stream Error
|
|
199
|
+
* Thrown when an HTTP or WebSocket run stream fails after it started: an error chunk from the
|
|
200
|
+
* server, a malformed chunk, or a stream that ended before completion.
|
|
201
|
+
*/
|
|
202
|
+
export declare class StreamError extends TenxGraphError {
|
|
203
|
+
constructor(message: string, errorCode?: string, requestId?: string, endpoint?: string, method?: string, cause?: unknown);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Parse error response from API
|
|
207
|
+
*/
|
|
208
|
+
export declare function parseErrorResponse(response: Response): Promise<ApiErrorResponse | null>;
|
|
209
|
+
/**
|
|
210
|
+
* Create appropriate error instance based on HTTP status code and error code
|
|
211
|
+
*/
|
|
212
|
+
export declare function createErrorFromResponse(response: Response, fallbackMessage?: string, endpoint?: string, method?: string): Promise<TenxGraphError>;
|