@open1s/jsbos 1.0.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/LICENSE +21 -0
- package/README.md +87 -0
- package/brainos.js +515 -0
- package/index.d.ts +238 -0
- package/index.js +598 -0
- package/jsbos.darwin-arm64.node +0 -0
- package/package.json +119 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export declare class ExternalObject<T> {
|
|
5
|
+
readonly '': {
|
|
6
|
+
readonly '': unique symbol
|
|
7
|
+
[K: symbol]: T
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare class Agent {
|
|
11
|
+
static create(config: AgentConfig): Promise<Agent>
|
|
12
|
+
static createWithBus(config: AgentConfig, bus: ExternalObject<Session>): Promise<Agent>
|
|
13
|
+
runSimple(task: string): Promise<string>
|
|
14
|
+
react(task: string): Promise<string>
|
|
15
|
+
config(): any
|
|
16
|
+
listTools(): Array<string>
|
|
17
|
+
registerHook(event: HookEvent, callback: ((err: Error | null, arg: HookContextData) => any)): void
|
|
18
|
+
registerPlugin(name: string, onLlmRequest?: (((err: Error | null, arg: JSAny) => any)) | undefined | null, onLlmResponse?: (((err: Error | null, arg: JSAny) => any)) | undefined | null, onToolCall?: (((err: Error | null, arg: JSAny) => any)) | undefined | null, onToolResult?: (((err: Error | null, arg: JSAny) => any)) | undefined | null): void
|
|
19
|
+
close(): void
|
|
20
|
+
addTool(name: string, description: string, parameters: string, schema: string, callback: ((err: Error | null, arg: JSAny) => any)): Promise<string>
|
|
21
|
+
addBashTool(name: string, workspaceRoot?: string | undefined | null): Promise<void>
|
|
22
|
+
registerSkillsFromDir(dirPath: string): Promise<void>
|
|
23
|
+
addMcpServer(namespace: string, command: string, args: Array<string>): Promise<void>
|
|
24
|
+
addMcpServerHttp(namespace: string, url: string): Promise<void>
|
|
25
|
+
listMcpTools(): Promise<Array<any>>
|
|
26
|
+
listMcpResources(namespace: string): Promise<Array<any>>
|
|
27
|
+
listMcpPrompts(): Promise<Array<any>>
|
|
28
|
+
rpcClient(endpoint: string, bus: ExternalObject<Session>): Promise<AgentRpcClient>
|
|
29
|
+
asCallableServer(endpoint: string, bus: ExternalObject<Session>): Promise<AgentCallableServer>
|
|
30
|
+
addMessage(message: any): Promise<void>
|
|
31
|
+
getMessages(): Array<any>
|
|
32
|
+
saveMessageLog(path: string): void
|
|
33
|
+
restoreMessageLog(path: string): void
|
|
34
|
+
stream(task: string, callback: ((err: Error | null, arg: any) => any)): Promise<void>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare class AgentCallableServer {
|
|
38
|
+
get endpoint(): string
|
|
39
|
+
isStarted(): boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare class AgentRpcClient {
|
|
43
|
+
get endpoint(): string
|
|
44
|
+
list(): Promise<any>
|
|
45
|
+
call(toolName: string, argsJson: string): Promise<any>
|
|
46
|
+
llmRun(task: string): Promise<any>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare class Bus {
|
|
50
|
+
static create(config?: BusConfig | undefined | null): Promise<Bus>
|
|
51
|
+
session(): Promise<ExternalObject<Session>>
|
|
52
|
+
sessionId(): string
|
|
53
|
+
publishText(topic: string, payload: string): Promise<void>
|
|
54
|
+
publishJson(topic: string, data: any): Promise<void>
|
|
55
|
+
createPublisher(topic: string): Promise<Publisher>
|
|
56
|
+
createSubscriber(topic: string): Promise<Subscriber>
|
|
57
|
+
createQuery(topic: string): Promise<Query>
|
|
58
|
+
createQueryable(topic: string): Promise<Queryable>
|
|
59
|
+
createCaller(name: string): Promise<Caller>
|
|
60
|
+
createCallable(uri: string): Promise<Callable>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export declare class Callable {
|
|
64
|
+
setHandler(handler: ((err: Error | null, arg: string) => unknown)): void
|
|
65
|
+
isStarted(): boolean
|
|
66
|
+
start(): Promise<void>
|
|
67
|
+
run(handler: ((err: Error | null, arg: string) => unknown)): Promise<void>
|
|
68
|
+
runJson(handler: ((err: Error | null, arg: string) => unknown)): Promise<void>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare class Caller {
|
|
72
|
+
static new(name: string): Promise<Caller>
|
|
73
|
+
static withSession(name: string, session: ExternalObject<Session>): Promise<Caller>
|
|
74
|
+
callText(payload: string): Promise<string>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare class ConfigLoader {
|
|
78
|
+
constructor()
|
|
79
|
+
discover(): void
|
|
80
|
+
addFile(path: string): void
|
|
81
|
+
addDirectory(path: string): void
|
|
82
|
+
addInline(data: any): void
|
|
83
|
+
reset(): void
|
|
84
|
+
loadSync(): string
|
|
85
|
+
reloadSync(): string
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare class HookRegistry {
|
|
89
|
+
constructor()
|
|
90
|
+
register(event: HookEvent, callback: ((err: Error | null, arg: HookContextData) => any)): Promise<void>
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export declare class McpClient {
|
|
94
|
+
static spawn(command: string, args: Array<string>): Promise<McpClient>
|
|
95
|
+
static connectHttp(url: string): McpClient
|
|
96
|
+
initialize(): Promise<any>
|
|
97
|
+
listTools(): Promise<Array<any>>
|
|
98
|
+
callTool(name: string, argsJson: string): Promise<any>
|
|
99
|
+
listPrompts(): Promise<Array<any>>
|
|
100
|
+
listResources(): Promise<Array<any>>
|
|
101
|
+
readResource(uri: string): Promise<any>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare class PluginRegistry {
|
|
105
|
+
constructor()
|
|
106
|
+
clear(): Promise<void>
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare class Publisher {
|
|
110
|
+
static new(topic: string): Promise<Publisher>
|
|
111
|
+
static withSession(topic: string, session: ExternalObject<Session>): Promise<Publisher>
|
|
112
|
+
get topic(): string
|
|
113
|
+
publishText(payload: string): Promise<void>
|
|
114
|
+
publishJson(data: any): Promise<void>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare class Query {
|
|
118
|
+
static new(topic: string): Promise<Query>
|
|
119
|
+
static withSession(topic: string, session: ExternalObject<Session>): Promise<Query>
|
|
120
|
+
get topic(): string
|
|
121
|
+
queryText(payload: string): Promise<string>
|
|
122
|
+
queryTextTimeoutMs(payload: string, timeoutMs: number): Promise<string>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare class Queryable {
|
|
126
|
+
static new(topic: string): Promise<Queryable>
|
|
127
|
+
setHandler(handler: ((err: Error | null, arg: string) => unknown)): void
|
|
128
|
+
start(): Promise<void>
|
|
129
|
+
run(handler: ((err: Error | null, arg: string) => unknown)): Promise<void>
|
|
130
|
+
runJson(handler: ((err: Error | null, arg: string) => unknown)): Promise<void>
|
|
131
|
+
runStream(handler: ((err: Error | null, arg: string) => unknown)): Promise<void>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare class Subscriber {
|
|
135
|
+
static new(topic: string): Promise<Subscriber>
|
|
136
|
+
static withSession(topic: string, session: ExternalObject<Session>): Promise<Subscriber>
|
|
137
|
+
get topic(): string
|
|
138
|
+
recv(): Promise<string | null>
|
|
139
|
+
recvWithTimeoutMs(timeoutMs: number): Promise<string | null>
|
|
140
|
+
recvJsonWithTimeoutMs(timeoutMs: number): Promise<any | null>
|
|
141
|
+
run(handler: ((err: Error | null, arg: JSAny) => any)): Promise<void>
|
|
142
|
+
runJson(handler: ((err: Error | null, arg: JSAny) => any)): Promise<void>
|
|
143
|
+
stop(): Promise<void>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface AgentConfig {
|
|
147
|
+
name: string
|
|
148
|
+
model: string
|
|
149
|
+
baseUrl: string
|
|
150
|
+
apiKey: string
|
|
151
|
+
systemPrompt: string
|
|
152
|
+
temperature: number
|
|
153
|
+
maxTokens?: number
|
|
154
|
+
timeoutSecs: number
|
|
155
|
+
maxSteps?: number
|
|
156
|
+
circuitBreakerMaxFailures?: number
|
|
157
|
+
circuitBreakerCooldownSecs?: number
|
|
158
|
+
rateLimitCapacity?: number
|
|
159
|
+
rateLimitWindowSecs?: number
|
|
160
|
+
rateLimitMaxRetries?: number
|
|
161
|
+
rateLimitRetryBackoffSecs?: number
|
|
162
|
+
rateLimitAutoWait?: boolean
|
|
163
|
+
contextCompactionThresholdTokens?: number
|
|
164
|
+
contextCompactionTriggerRatio?: number
|
|
165
|
+
contextCompactionKeepRecentMessages?: number
|
|
166
|
+
contextCompactionMaxSummaryChars?: number
|
|
167
|
+
contextCompactionSummaryMaxTokens?: number
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface BusConfig {
|
|
171
|
+
mode: string
|
|
172
|
+
connect?: Array<string>
|
|
173
|
+
listen?: Array<string>
|
|
174
|
+
peer?: string
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface HookContextData {
|
|
178
|
+
agentId: string
|
|
179
|
+
data: Record<string, string>
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export declare const enum HookDecision {
|
|
183
|
+
Continue = 0,
|
|
184
|
+
Abort = 1,
|
|
185
|
+
Error = 2
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export declare const enum HookEvent {
|
|
189
|
+
BeforeToolCall = 0,
|
|
190
|
+
AfterToolCall = 1,
|
|
191
|
+
BeforeLlmCall = 2,
|
|
192
|
+
AfterLlmCall = 3,
|
|
193
|
+
OnMessage = 4,
|
|
194
|
+
OnComplete = 5,
|
|
195
|
+
OnError = 6
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export declare function initTracing(): void
|
|
199
|
+
|
|
200
|
+
export declare function logTestMessage(message: string): void
|
|
201
|
+
|
|
202
|
+
export interface PluginLlmRequest {
|
|
203
|
+
model: string
|
|
204
|
+
temperature?: number
|
|
205
|
+
maxTokens?: number
|
|
206
|
+
topP?: number
|
|
207
|
+
topK?: number
|
|
208
|
+
metadata: Record<string, string>
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type PluginLlmResponse =
|
|
212
|
+
| { type: 'Text', field0: string }
|
|
213
|
+
| { type: 'Partial', field0: string }
|
|
214
|
+
| { type: 'ToolCall', name: string, args: string, id?: string }
|
|
215
|
+
| { type: 'Done' }
|
|
216
|
+
|
|
217
|
+
export declare const enum PluginStage {
|
|
218
|
+
PreRequest = 0,
|
|
219
|
+
PostResponse = 1,
|
|
220
|
+
PreExecute = 2,
|
|
221
|
+
PostExecute = 3
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface PluginToolCall {
|
|
225
|
+
name: string
|
|
226
|
+
args: string
|
|
227
|
+
id?: string
|
|
228
|
+
metadata: Record<string, string>
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface PluginToolResult {
|
|
232
|
+
result: string
|
|
233
|
+
success: boolean
|
|
234
|
+
error?: string
|
|
235
|
+
metadata: Record<string, string>
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export declare function version(): string
|