@giselles-ai/sandbox-agent-core 0.1.4 → 0.1.6
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/index.d.ts +52 -46
- package/dist/index.js +363 -825
- package/dist/react/index.d.ts +48 -0
- package/dist/react/index.js +520 -0
- package/package.json +13 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import Redis from 'ioredis';
|
|
2
|
+
import { Sandbox } from '@vercel/sandbox';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type AgentRunnerOptions = {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
type AgentRunnerHandler = {
|
|
9
|
+
POST: (request: Request) => Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
declare function handleAgentRunner(options?: AgentRunnerOptions): AgentRunnerHandler;
|
|
12
|
+
|
|
13
|
+
type BaseChatRequest = {
|
|
14
|
+
message: string;
|
|
15
|
+
session_id?: string;
|
|
16
|
+
sandbox_id?: string;
|
|
17
|
+
};
|
|
18
|
+
type ChatCommand = {
|
|
19
|
+
cmd: string;
|
|
20
|
+
args: string[];
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
};
|
|
23
|
+
type ChatAgent<TRequest extends BaseChatRequest> = {
|
|
24
|
+
requestSchema: z.ZodType<TRequest>;
|
|
25
|
+
snapshotId?: string;
|
|
26
|
+
prepareSandbox(input: {
|
|
27
|
+
input: TRequest;
|
|
28
|
+
sandbox: Sandbox;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
createCommand(input: {
|
|
31
|
+
input: TRequest;
|
|
32
|
+
}): ChatCommand;
|
|
33
|
+
};
|
|
34
|
+
type RunChatInput<TRequest extends BaseChatRequest> = {
|
|
35
|
+
agent: ChatAgent<TRequest>;
|
|
36
|
+
signal: AbortSignal;
|
|
37
|
+
input: TRequest;
|
|
38
|
+
};
|
|
39
|
+
declare function runChat<TRequest extends BaseChatRequest>(input: RunChatInput<TRequest>): Promise<Response>;
|
|
40
|
+
|
|
41
|
+
declare const geminiRequestSchema: z.ZodObject<{
|
|
6
42
|
message: z.ZodString;
|
|
7
43
|
session_id: z.ZodOptional<z.ZodString>;
|
|
8
44
|
sandbox_id: z.ZodOptional<z.ZodString>;
|
|
9
|
-
relay_session_id: z.ZodString
|
|
10
|
-
relay_token: z.ZodString
|
|
45
|
+
relay_session_id: z.ZodOptional<z.ZodString>;
|
|
46
|
+
relay_token: z.ZodOptional<z.ZodString>;
|
|
11
47
|
}, z.core.$strip>;
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
48
|
+
type GeminiAgentRequest = z.infer<typeof geminiRequestSchema>;
|
|
49
|
+
type GeminiAgentOptions = {
|
|
50
|
+
snapshotId?: string;
|
|
51
|
+
env?: Record<string, string>;
|
|
52
|
+
tools?: {
|
|
53
|
+
browser?: {
|
|
54
|
+
relayUrl?: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
20
57
|
};
|
|
58
|
+
declare function createGeminiAgent(options?: GeminiAgentOptions): ChatAgent<GeminiAgentRequest>;
|
|
21
59
|
|
|
22
|
-
|
|
23
|
-
declare global {
|
|
24
|
-
var __browserToolRelayRedis: Redis | undefined;
|
|
25
|
-
}
|
|
26
|
-
declare class RelayStoreError extends Error {
|
|
27
|
-
readonly code: RelayErrorCode;
|
|
28
|
-
readonly status: number;
|
|
29
|
-
constructor(code: RelayErrorCode, message: string, status: number);
|
|
30
|
-
}
|
|
31
|
-
declare function createRelaySubscriber(): Redis;
|
|
32
|
-
declare function relayRequestChannel(sessionId: string): string;
|
|
33
|
-
declare function createRelaySession(): Promise<{
|
|
34
|
-
sessionId: string;
|
|
35
|
-
token: string;
|
|
36
|
-
expiresAt: number;
|
|
37
|
-
}>;
|
|
38
|
-
declare function assertRelaySession(sessionId: string, token: string): Promise<void>;
|
|
39
|
-
declare function markBrowserConnected(sessionId: string, token: string): Promise<void>;
|
|
40
|
-
declare function touchBrowserConnected(sessionId: string): Promise<void>;
|
|
41
|
-
declare function dispatchRelayRequest(input: {
|
|
42
|
-
sessionId: string;
|
|
43
|
-
token: string;
|
|
44
|
-
request: RelayRequest;
|
|
45
|
-
timeoutMs?: number;
|
|
46
|
-
}): Promise<RelayResponse>;
|
|
47
|
-
declare function resolveRelayResponse(input: {
|
|
48
|
-
sessionId: string;
|
|
49
|
-
token: string;
|
|
50
|
-
response: RelayResponse;
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
declare function toRelayError(error: unknown): RelayStoreError;
|
|
53
|
-
|
|
54
|
-
export { RELAY_SSE_KEEPALIVE_INTERVAL_MS, assertRelaySession, createGeminiChatHandler, createRelayHandler, createRelaySession, createRelaySubscriber, dispatchRelayRequest, markBrowserConnected, relayRequestChannel, resolveRelayResponse, toRelayError, touchBrowserConnected };
|
|
60
|
+
export { type AgentRunnerHandler, type AgentRunnerOptions, type BaseChatRequest, type ChatAgent, type ChatCommand, type RunChatInput, createGeminiAgent, handleAgentRunner, runChat };
|