@sentry/junior 0.110.0 → 0.111.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/dist/{agent-hooks-ELT4ODFF.js → agent-hooks-QQ2IWKOP.js} +8 -8
- package/dist/api.js +11 -11
- package/dist/app.js +521 -394
- package/dist/build/virtual-config.d.ts +2 -0
- package/dist/{catalog-runtime-4GI22PXK.js → catalog-runtime-D22W6QEJ.js} +5 -5
- package/dist/chat/agent/request.d.ts +3 -6
- package/dist/chat/agent/sandbox.d.ts +36 -11
- package/dist/chat/agent/tools.d.ts +5 -8
- package/dist/chat/config.d.ts +8 -1
- package/dist/chat/pi/sdk.d.ts +1 -1
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/runtime/agent-continue-runner.d.ts +7 -3
- package/dist/chat/runtime/slack-runtime.d.ts +1 -2
- package/dist/chat/runtime/thread-state.d.ts +3 -7
- package/dist/chat/runtime/turn-preparation.d.ts +2 -2
- package/dist/chat/sandbox/command-result.d.ts +91 -0
- package/dist/chat/sandbox/errors.d.ts +3 -1
- package/dist/chat/sandbox/ref.d.ts +5 -0
- package/dist/chat/sandbox/sandbox.d.ts +19 -46
- package/dist/chat/sandbox/session.d.ts +16 -20
- package/dist/chat/sandbox/skill-sync.d.ts +2 -2
- package/dist/chat/sandbox/workspace.d.ts +14 -12
- package/dist/chat/services/turn-result.d.ts +3 -4
- package/dist/chat/task-execution/slack-work.d.ts +3 -1
- package/dist/chat/task-execution/state.d.ts +75 -22
- package/dist/chat/task-execution/store.d.ts +34 -3
- package/dist/chat/task-execution/worker.d.ts +0 -1
- package/dist/chat/tool-support/normalize-result.d.ts +2 -2
- package/dist/chat/tool-support/pi-tool-adapter.d.ts +2 -2
- package/dist/chat/tool-support/structured-result.d.ts +1 -2
- package/dist/chat/tools/sandbox/file-uploads.d.ts +1 -1
- package/dist/chat/{runtime → tools/sandbox}/generated-artifacts.d.ts +3 -3
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/chat/tools/web/fetch-content.d.ts +5 -0
- package/dist/chat/tools/web/image-generate.d.ts +2 -1
- package/dist/chat/tools/web/search.d.ts +1 -1
- package/dist/{chunk-W6RJZG7F.js → chunk-B45FPP2A.js} +306 -31
- package/dist/{chunk-SBOBTS27.js → chunk-BTRNMS6A.js} +2 -2
- package/dist/{chunk-L5XQPJ7T.js → chunk-IFAHK54X.js} +2 -2
- package/dist/{chunk-IYKPU7H6.js → chunk-J7APPQIJ.js} +1 -1
- package/dist/{chunk-3S7YYHBI.js → chunk-L6JPKANW.js} +1 -1
- package/dist/{chunk-W75ZPAGG.js → chunk-MPVES2IC.js} +1 -1
- package/dist/{chunk-WNOVRQ67.js → chunk-NQLWOTY4.js} +46 -18
- package/dist/{chunk-RHHRKSPI.js → chunk-OOLU34J4.js} +8714 -9027
- package/dist/{chunk-GK47NBDE.js → chunk-PYKKM4MM.js} +1 -1
- package/dist/{chunk-3UBQI73J.js → chunk-PZELBSHC.js} +7 -8
- package/dist/{chunk-2T7TIEXI.js → chunk-QQIVLZW4.js} +11 -15
- package/dist/{chunk-C5XAFTHY.js → chunk-SL3ZKNLQ.js} +16 -13
- package/dist/{chunk-3TV7OEHL.js → chunk-WSRBFHPX.js} +1 -1
- package/dist/{chunk-Y3H2DN6F.js → chunk-XQAYFRWT.js} +1 -1
- package/dist/{chunk-Y5FK3CNG.js → chunk-Z2W4SJZ7.js} +1 -1
- package/dist/{chunk-ZKIOWEFL.js → chunk-Z4G3WCP3.js} +1 -1
- package/dist/{chunk-4QU44P7Q.js → chunk-ZRZ4SVWG.js} +2 -2
- package/dist/cli/chat.js +19 -19
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +11 -11
- package/dist/cli/snapshot-warmup.js +8 -8
- package/dist/cli/upgrade.js +5 -5
- package/dist/{db-Y6W6CWWW.js → db-WXQOQESG.js} +5 -5
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +14 -8
- package/dist/{runner-BBFV5GLR.js → runner-4QY4XH4B.js} +19 -28
- package/dist/{skills-AR4AF32L.js → skills-P5MU4EBX.js} +6 -6
- package/dist/{validation-FBIEPTC2.js → validation-PQF5OP6T.js} +6 -6
- package/dist/version.js +1 -1
- package/package.json +6 -6
|
@@ -8,6 +8,7 @@ export interface RuntimePluginModule {
|
|
|
8
8
|
}
|
|
9
9
|
/** Render the virtual config module consumed by createApp(). */
|
|
10
10
|
export declare function renderVirtualConfig(options: {
|
|
11
|
+
functionMaxDurationSeconds?: number;
|
|
11
12
|
dashboard?: JuniorDashboardOptions;
|
|
12
13
|
plugins?: PluginCatalogConfig;
|
|
13
14
|
pluginModule?: RuntimePluginModule;
|
|
@@ -15,6 +16,7 @@ export declare function renderVirtualConfig(options: {
|
|
|
15
16
|
}): string;
|
|
16
17
|
/** Inject a virtual module so createApp() can read the plugin list at runtime. */
|
|
17
18
|
export declare function injectVirtualConfig(nitro: Nitro, options?: {
|
|
19
|
+
functionMaxDurationSeconds?: number;
|
|
18
20
|
loadPluginSet?: () => Promise<JuniorPluginSet | undefined>;
|
|
19
21
|
pluginModule?: RuntimePluginModule;
|
|
20
22
|
plugins?: PluginCatalogConfig;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-WSRBFHPX.js";
|
|
4
|
+
import "./chunk-XQAYFRWT.js";
|
|
5
5
|
import "./chunk-C4MZ3GP5.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-J7APPQIJ.js";
|
|
7
7
|
import "./chunk-42WRQLJ6.js";
|
|
8
8
|
import "./chunk-6GWA276C.js";
|
|
9
9
|
import "./chunk-B3IT5END.js";
|
|
10
10
|
import "./chunk-3V7OFJZC.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-MPVES2IC.js";
|
|
12
|
+
import "./chunk-Z4G3WCP3.js";
|
|
13
13
|
import "./chunk-MLKGABMK.js";
|
|
14
14
|
export {
|
|
15
15
|
pluginCatalogRuntime
|
|
@@ -13,7 +13,7 @@ import type { ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
|
13
13
|
import type { CredentialContext } from "@/chat/credentials/context";
|
|
14
14
|
import type { PiMessage } from "@/chat/pi/messages";
|
|
15
15
|
import type { Actor } from "@/chat/actor";
|
|
16
|
-
import type {
|
|
16
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
17
17
|
import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
|
|
18
18
|
import type { AuthorizationFlowMode } from "@/chat/services/auth-pause";
|
|
19
19
|
import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
|
|
@@ -105,10 +105,7 @@ export interface AgentRunState {
|
|
|
105
105
|
artifactState?: ThreadArtifactsState;
|
|
106
106
|
pendingAuth?: ConversationPendingAuthState;
|
|
107
107
|
/** Persisted sandbox reuse state from prior slices of this conversation. */
|
|
108
|
-
|
|
109
|
-
sandboxId?: string;
|
|
110
|
-
sandboxDependencyProfileHash?: string;
|
|
111
|
-
};
|
|
108
|
+
sandboxRef?: SandboxRef;
|
|
112
109
|
}
|
|
113
110
|
/**
|
|
114
111
|
* Carries notification-only callbacks for streaming UI and status surfaces;
|
|
@@ -142,7 +139,7 @@ export interface AgentRunDurability {
|
|
|
142
139
|
shouldYield?: () => boolean;
|
|
143
140
|
drainSteeringMessages?: (accept: (messages: AgentRunSteeringMessage[]) => Promise<void>) => Promise<AgentRunSteeringMessage[]>;
|
|
144
141
|
recordPendingAuth?: (pendingAuth: ConversationPendingAuthState | undefined) => void | Promise<void>;
|
|
145
|
-
|
|
142
|
+
onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
|
|
146
143
|
onArtifactStateUpdated?: (artifactState: ThreadArtifactsState) => void | Promise<void>;
|
|
147
144
|
}
|
|
148
145
|
/** Groups the per-slice run request by the runtime role each field serves. */
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent-facing sandbox adaptation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
4
|
+
* The sandbox module owns provider lifecycle and recovery. This module adds
|
|
5
|
+
* agent-specific preparation, durable reference propagation, custom command
|
|
6
|
+
* routing, and generated-artifact materialization.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import type
|
|
8
|
+
import type { FileUpload } from "chat";
|
|
9
|
+
import { type Actor } from "@/chat/actor";
|
|
10
|
+
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
11
|
+
import type { CredentialContext } from "@/chat/credentials/context";
|
|
12
|
+
import type { LogContext } from "@/chat/logging";
|
|
13
|
+
import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
|
|
14
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
15
|
+
import { type SandboxTools } from "@/chat/sandbox/sandbox";
|
|
10
16
|
import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
import type { Skill, SkillMetadata } from "@/chat/skills";
|
|
18
|
+
import type { GeneratedArtifactFileRef } from "@/chat/tools/sandbox/file-uploads";
|
|
19
|
+
export interface AgentSandboxOptions {
|
|
20
|
+
sandboxRef?: SandboxRef;
|
|
21
|
+
skills: SkillMetadata[];
|
|
22
|
+
traceContext: LogContext;
|
|
23
|
+
tracePropagation?: SandboxEgressTracePropagationConfig;
|
|
24
|
+
credentialEgress?: CredentialContext;
|
|
25
|
+
actor?: Actor;
|
|
26
|
+
channelConfiguration?: ChannelConfigurationService;
|
|
27
|
+
configurationValues: Record<string, unknown>;
|
|
28
|
+
getActiveSkill(): Skill | null;
|
|
29
|
+
prepareSandbox(workspace: SandboxWorkspace): void | Promise<void>;
|
|
30
|
+
onSandboxRefChanged(sandboxRef: SandboxRef): void;
|
|
31
|
+
persistSandboxRef?(sandboxRef: SandboxRef): void | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export interface AgentSandbox {
|
|
34
|
+
readonly tools: SandboxTools;
|
|
35
|
+
readonly workspace: SandboxWorkspace;
|
|
36
|
+
sandboxRef(): SandboxRef | undefined;
|
|
37
|
+
writeGeneratedArtifacts(files: FileUpload[]): Promise<GeneratedArtifactFileRef[]>;
|
|
38
|
+
}
|
|
39
|
+
/** Create run-scoped sandbox capabilities adapted to the current agent context. */
|
|
40
|
+
export declare function createAgentSandbox(options: AgentSandboxOptions): AgentSandbox;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Run tool wiring.
|
|
3
3
|
*
|
|
4
4
|
* Builds everything the agent can act through for one run slice: the sandbox
|
|
5
|
-
*
|
|
5
|
+
* access, MCP and plugin auth orchestration, MCP
|
|
6
6
|
* provider restoration from durable history, and the Pi-facing tool surfaces
|
|
7
7
|
* (main-agent tools plus runtime control tools). Auth pauses raised while
|
|
8
8
|
* restoring providers are thrown here so the run parks before prompting.
|
|
@@ -16,11 +16,11 @@ import { McpToolManager } from "@/chat/mcp/tool-manager";
|
|
|
16
16
|
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
17
17
|
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
18
18
|
import { type ActiveMcpCatalogSummary } from "@/chat/tool-support/skill/mcp-tool-summary";
|
|
19
|
-
import {
|
|
19
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
20
20
|
import type { PiMessage } from "@/chat/pi/messages";
|
|
21
21
|
import type { LogContext } from "@/chat/logging";
|
|
22
22
|
import type { ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
23
|
-
import {
|
|
23
|
+
import type { Actor } from "@/chat/actor";
|
|
24
24
|
import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
25
25
|
import type { AuthorizationPauseError } from "@/chat/services/auth-pause";
|
|
26
26
|
import type { AgentTurnSurface } from "@/chat/state/turn-session";
|
|
@@ -41,10 +41,7 @@ interface ToolWiringArgs {
|
|
|
41
41
|
generatedFiles: FileUpload[];
|
|
42
42
|
invokedSkill: SkillMetadata | null;
|
|
43
43
|
observers: AgentRunObservers;
|
|
44
|
-
|
|
45
|
-
sandboxId?: string;
|
|
46
|
-
sandboxDependencyProfileHash?: string;
|
|
47
|
-
}) => void;
|
|
44
|
+
onSandboxRefChanged: (sandboxRef: SandboxRef) => void;
|
|
48
45
|
policy: AgentRunPolicy;
|
|
49
46
|
preAgentPromptMessages: () => PiMessage[];
|
|
50
47
|
priorPiMessages: PiMessage[] | undefined;
|
|
@@ -68,7 +65,7 @@ export interface ToolWiring {
|
|
|
68
65
|
getPendingAuthPause: () => AuthorizationPauseError | undefined;
|
|
69
66
|
mcpToolManager: McpToolManager;
|
|
70
67
|
pluginHooks: PluginHookRunner;
|
|
71
|
-
|
|
68
|
+
getSandboxRef: () => SandboxRef | undefined;
|
|
72
69
|
toolGuidance: Array<{
|
|
73
70
|
name: string;
|
|
74
71
|
promptGuidelines: AnyToolDefinition["promptGuidelines"];
|
package/dist/chat/config.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import { type ExecutionProfileConfig } from "@/chat/model-profile";
|
|
|
5
5
|
* Junior can abort, persist, and schedule continuation before host teardown.
|
|
6
6
|
*/
|
|
7
7
|
export declare const FUNCTION_TIMEOUT_BUFFER_SECONDS = 20;
|
|
8
|
+
/** Additional buffer that makes conversation work yield before the hard request deadline. */
|
|
9
|
+
export declare const CONVERSATION_WORK_SOFT_YIELD_BUFFER_SECONDS = 40;
|
|
8
10
|
export interface BotConfig {
|
|
9
11
|
embeddingModelId: string;
|
|
10
12
|
fastModelId: string;
|
|
13
|
+
imageGenerationModelId: string;
|
|
11
14
|
loadingMessages: string[];
|
|
12
15
|
profiles: Readonly<Record<string, ExecutionProfileConfig>>;
|
|
13
16
|
reasoningLevel?: TurnReasoningLevel;
|
|
@@ -16,11 +19,13 @@ export interface BotConfig {
|
|
|
16
19
|
maxSlicesPerTurn: number;
|
|
17
20
|
turnTimeoutMs: number;
|
|
18
21
|
userName: string;
|
|
22
|
+
webSearchModelId: string;
|
|
19
23
|
}
|
|
20
24
|
export type SqlDriver = "neon" | "postgres";
|
|
21
25
|
export interface ChatConfig {
|
|
22
26
|
bot: BotConfig;
|
|
23
27
|
functionMaxDurationSeconds: number;
|
|
28
|
+
conversationWorkSoftYieldAfterMs: number;
|
|
24
29
|
sql: {
|
|
25
30
|
databaseUrl: string;
|
|
26
31
|
driver: SqlDriver;
|
|
@@ -41,7 +46,9 @@ export interface ChatConfig {
|
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
/** Parse all chat configuration from environment variables. */
|
|
44
|
-
export declare function readChatConfig(env?: NodeJS.ProcessEnv): ChatConfig;
|
|
49
|
+
export declare function readChatConfig(env?: NodeJS.ProcessEnv, functionMaxDurationSeconds?: number): ChatConfig;
|
|
50
|
+
/** Apply the host execution budget injected by juniorNitro(). */
|
|
51
|
+
export declare function configureFunctionMaxDurationSeconds(functionMaxDurationSeconds: number): void;
|
|
45
52
|
/** Return the chat configuration (parsed once at startup). */
|
|
46
53
|
export declare function getChatConfig(): ChatConfig;
|
|
47
54
|
/** Bot configuration derived from environment at module load. */
|
package/dist/chat/pi/sdk.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* are re-exported here so tests can mock a single Junior-owned path instead
|
|
4
4
|
* of Pi's internal subpath layout, which changes across SDK versions.
|
|
5
5
|
*/
|
|
6
|
-
export { completeSimple, getEnvApiKey, getModels, registerApiProvider, type Message, type Model, type ThinkingLevel, } from "@earendil-works/pi-ai/compat";
|
|
6
|
+
export { completeSimple, getEnvApiKey, getModel, getModels, isRetryableAssistantError, registerApiProvider, type Message, type Model, type ThinkingLevel, } from "@earendil-works/pi-ai/compat";
|
|
7
7
|
export { stream as streamAnthropic, streamSimple as streamSimpleAnthropic, } from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
@@ -2,7 +2,7 @@ import type { PluginRoute, PluginOperationalReport, PluginRouteApp, ResourceEven
|
|
|
2
2
|
import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
|
|
3
3
|
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
4
4
|
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
5
|
-
import type {
|
|
5
|
+
import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
|
|
6
6
|
import type { Actor } from "@/chat/actor";
|
|
7
7
|
/** Signal that a plugin intentionally denied a tool execution. */
|
|
8
8
|
export declare class PluginHookDeniedError extends Error {
|
|
@@ -25,7 +25,7 @@ export interface PluginApiRouteRegistration {
|
|
|
25
25
|
}
|
|
26
26
|
export interface PluginHookRunner {
|
|
27
27
|
beforeToolExecute(input: ToolHookInput): Promise<ToolHookResult>;
|
|
28
|
-
prepareSandbox(
|
|
28
|
+
prepareSandbox(workspace: SandboxWorkspace): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
/** Validate plugin identity before it can affect process-wide hooks. */
|
|
31
31
|
export declare function validatePlugins(plugins: PluginRegistration[]): void;
|
|
@@ -11,14 +11,18 @@ export interface AgentContinueRunnerOptions {
|
|
|
11
11
|
sessionId: string;
|
|
12
12
|
}) => Promise<void>;
|
|
13
13
|
}
|
|
14
|
+
/** Per-worker controls for one continued run. */
|
|
15
|
+
export interface AgentContinueRunOptions {
|
|
16
|
+
shouldYield?: () => boolean;
|
|
17
|
+
}
|
|
14
18
|
/**
|
|
15
19
|
* Continue one paused Slack agent run from durable conversation state.
|
|
16
20
|
*
|
|
17
21
|
* Returns false when the session became stale before generation began.
|
|
18
22
|
*/
|
|
19
|
-
export declare function continueSlackAgentRun(payload: AgentContinueRequest, options: AgentContinueRunnerOptions): Promise<boolean>;
|
|
23
|
+
export declare function continueSlackAgentRun(payload: AgentContinueRequest, options: AgentContinueRunnerOptions, runOptions?: AgentContinueRunOptions): Promise<boolean>;
|
|
20
24
|
/** Resume the first valid paused Slack session for an idle conversation. */
|
|
21
|
-
export declare function resumeAwaitingSlackContinuation(conversationId: string, options: AgentContinueRunnerOptions): Promise<boolean>;
|
|
25
|
+
export declare function resumeAwaitingSlackContinuation(conversationId: string, options: AgentContinueRunnerOptions, runOptions?: AgentContinueRunOptions): Promise<boolean>;
|
|
22
26
|
/**
|
|
23
27
|
* Retry agent continuation when the normal Slack thread lock is briefly busy.
|
|
24
28
|
*
|
|
@@ -26,4 +30,4 @@ export declare function resumeAwaitingSlackContinuation(conversationId: string,
|
|
|
26
30
|
* lock that is rescheduled still returns true because runnable work remains
|
|
27
31
|
* durable.
|
|
28
32
|
*/
|
|
29
|
-
export declare function continueSlackAgentRunWithLockRetry(payload: AgentContinueRequest, options: AgentContinueRunnerOptions): Promise<boolean>;
|
|
33
|
+
export declare function continueSlackAgentRunWithLockRetry(payload: AgentContinueRequest, options: AgentContinueRunnerOptions, runOptions?: AgentContinueRunOptions): Promise<boolean>;
|
|
@@ -21,13 +21,12 @@ export interface AssistantLifecycleEvent {
|
|
|
21
21
|
userId?: string;
|
|
22
22
|
}
|
|
23
23
|
export interface SteeringCandidateMessage {
|
|
24
|
-
activeRequest: boolean;
|
|
25
24
|
inboundMessageId: string;
|
|
26
25
|
message: Message;
|
|
27
26
|
}
|
|
28
27
|
export interface ReplyHooks {
|
|
29
28
|
beforeFirstResponsePost?: () => Promise<void>;
|
|
30
|
-
drainSteeringMessages?: (accept: (messages: SteeringCandidateMessage[]) => Promise<readonly string[]
|
|
29
|
+
drainSteeringMessages?: (accept: (messages: SteeringCandidateMessage[]) => Promise<readonly string[]>) => Promise<void>;
|
|
31
30
|
messageContext?: MessageContext;
|
|
32
31
|
ack?: () => Promise<void>;
|
|
33
32
|
onToolInvocation?: (invocation: TurnToolInvocation) => void;
|
|
@@ -2,19 +2,15 @@ import type { Thread } from "chat";
|
|
|
2
2
|
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
3
3
|
import type { ThreadConversationState } from "@/chat/state/conversation";
|
|
4
4
|
import { type ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
5
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
5
6
|
export interface ThreadStatePatch {
|
|
6
7
|
artifacts?: ThreadArtifactsState;
|
|
7
8
|
conversation?: ThreadConversationState;
|
|
8
|
-
|
|
9
|
-
sandboxDependencyProfileHash?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface PersistedSandboxState {
|
|
12
|
-
sandboxDependencyProfileHash?: string;
|
|
13
|
-
sandboxId?: string;
|
|
9
|
+
sandboxRef?: SandboxRef | null;
|
|
14
10
|
}
|
|
15
11
|
export declare function mergeArtifactsState(artifacts: ThreadArtifactsState, patch: Partial<ThreadArtifactsState> | undefined): ThreadArtifactsState;
|
|
16
12
|
/** Extract persisted sandbox metadata from thread state payload. */
|
|
17
|
-
export declare function getPersistedSandboxState(state: Record<string, unknown>):
|
|
13
|
+
export declare function getPersistedSandboxState(state: Record<string, unknown>): SandboxRef | undefined;
|
|
18
14
|
/** Persist a thread-state patch through the Chat SDK thread interface. */
|
|
19
15
|
export declare function persistThreadState(thread: Thread, patch: ThreadStatePatch): Promise<void>;
|
|
20
16
|
/** Persist only the Redis-backed runtime scratch in a thread-state patch. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ThreadConversationState } from "@/chat/state/conversation";
|
|
2
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
2
3
|
import { type ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
3
4
|
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
4
5
|
import type { PrepareTurnStateInput, TurnContext } from "@/chat/runtime/turn-input";
|
|
@@ -8,8 +9,7 @@ export interface PreparedTurnState {
|
|
|
8
9
|
channelConfiguration?: ChannelConfigurationService;
|
|
9
10
|
conversation: ThreadConversationState;
|
|
10
11
|
conversationContext?: string;
|
|
11
|
-
|
|
12
|
-
sandboxDependencyProfileHash?: string;
|
|
12
|
+
sandboxRef?: SandboxRef;
|
|
13
13
|
userMessageAlreadyReplied?: boolean;
|
|
14
14
|
userMessageId?: string;
|
|
15
15
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { SandboxEgressAuthRequiredSignal, SandboxEgressPermissionDeniedSignal } from "@/chat/sandbox/egress/session";
|
|
2
|
+
export interface SandboxCommandOutcome {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
command: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
exit_code: number;
|
|
7
|
+
signal: null;
|
|
8
|
+
timed_out: boolean;
|
|
9
|
+
aborted?: boolean;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
stdout_truncated: boolean;
|
|
13
|
+
stderr_truncated: boolean;
|
|
14
|
+
auth_required?: SandboxEgressAuthRequiredSignal;
|
|
15
|
+
permission_denied?: SandboxEgressPermissionDeniedSignal;
|
|
16
|
+
}
|
|
17
|
+
/** Format one shell command outcome as Junior's structured tool result. */
|
|
18
|
+
export declare function formatSandboxCommandResult(params: SandboxCommandOutcome): import("@/chat/tool-support/structured-result").JuniorTextToolResultEnvelope<{
|
|
19
|
+
permission_denied?: {
|
|
20
|
+
grant: {
|
|
21
|
+
access: "read" | "write";
|
|
22
|
+
name: string;
|
|
23
|
+
leaseScope?: string | undefined;
|
|
24
|
+
reason?: string | undefined;
|
|
25
|
+
requirements?: string[] | undefined;
|
|
26
|
+
};
|
|
27
|
+
message: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
source: "upstream";
|
|
30
|
+
status: number;
|
|
31
|
+
upstreamHost: string;
|
|
32
|
+
upstreamPath: string;
|
|
33
|
+
createdAtMs: number;
|
|
34
|
+
account?: {
|
|
35
|
+
id: string;
|
|
36
|
+
label?: string | undefined;
|
|
37
|
+
url?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
acceptedPermissions?: string | undefined;
|
|
40
|
+
sso?: string | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
auth_required?: {
|
|
43
|
+
grant: {
|
|
44
|
+
access: "read" | "write";
|
|
45
|
+
name: string;
|
|
46
|
+
leaseScope?: string | undefined;
|
|
47
|
+
reason?: string | undefined;
|
|
48
|
+
requirements?: string[] | undefined;
|
|
49
|
+
};
|
|
50
|
+
kind: "unavailable" | "auth_required";
|
|
51
|
+
provider: string;
|
|
52
|
+
createdAtMs: number;
|
|
53
|
+
authorization?: {
|
|
54
|
+
provider: string;
|
|
55
|
+
type: "oauth";
|
|
56
|
+
scope?: string | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
message?: string | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
command: string;
|
|
61
|
+
cwd: string;
|
|
62
|
+
exit_code: number;
|
|
63
|
+
signal: null;
|
|
64
|
+
timed_out: boolean;
|
|
65
|
+
aborted: boolean;
|
|
66
|
+
stdout: string;
|
|
67
|
+
stderr: string;
|
|
68
|
+
stdout_truncated: boolean;
|
|
69
|
+
stderr_truncated: boolean;
|
|
70
|
+
error?: {
|
|
71
|
+
kind: string;
|
|
72
|
+
message: string;
|
|
73
|
+
retryable: boolean;
|
|
74
|
+
} | undefined;
|
|
75
|
+
ok: boolean;
|
|
76
|
+
status: "error" | "success";
|
|
77
|
+
target: string;
|
|
78
|
+
data: {
|
|
79
|
+
command: string;
|
|
80
|
+
cwd: string;
|
|
81
|
+
exit_code: number;
|
|
82
|
+
signal: null;
|
|
83
|
+
timed_out: boolean;
|
|
84
|
+
aborted: boolean;
|
|
85
|
+
stdout: string;
|
|
86
|
+
stderr: string;
|
|
87
|
+
stdout_truncated: boolean;
|
|
88
|
+
stderr_truncated: boolean;
|
|
89
|
+
};
|
|
90
|
+
truncated: boolean;
|
|
91
|
+
}>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Detect sandbox filesystem operations that can safely ignore existing directories. */
|
|
2
2
|
export declare function isAlreadyExistsError(error: unknown): boolean;
|
|
3
|
-
/** Detect when
|
|
3
|
+
/** Detect when the current sandbox session is unavailable and must be reacquired. */
|
|
4
4
|
export declare function isSandboxUnavailableError(error: unknown): boolean;
|
|
5
|
+
/** Detect a durable sandbox reference that can no longer be restored. */
|
|
6
|
+
export declare function isSandboxMissingError(error: unknown): boolean;
|
|
5
7
|
/** Detect transient snapshot boot races so sandbox creation can retry. */
|
|
6
8
|
export declare function isSnapshottingError(error: unknown): boolean;
|
|
7
9
|
/** Detect interrupted command streams where no reliable exit status is available. */
|
|
@@ -1,60 +1,33 @@
|
|
|
1
1
|
import { type LogContext } from "@/chat/logging";
|
|
2
|
-
import { type SandboxEgressAuthRequiredSignal, type SandboxEgressPermissionDeniedSignal } from "@/chat/sandbox/egress/session";
|
|
3
2
|
import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
|
|
4
3
|
import type { CredentialContext } from "@/chat/credentials/context";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
4
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
5
|
+
import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
|
|
7
6
|
import type { SkillMetadata } from "@/chat/skills";
|
|
8
|
-
interface
|
|
7
|
+
export interface SandboxToolCall {
|
|
9
8
|
toolName: string;
|
|
10
9
|
input: unknown;
|
|
11
10
|
signal?: AbortSignal;
|
|
12
11
|
}
|
|
13
|
-
export interface
|
|
14
|
-
|
|
12
|
+
export interface SandboxTools {
|
|
13
|
+
supports(toolName: string): boolean;
|
|
14
|
+
execute(params: SandboxToolCall): Promise<unknown>;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exit_code: number;
|
|
21
|
-
signal: null;
|
|
22
|
-
timed_out: boolean;
|
|
23
|
-
aborted?: boolean;
|
|
24
|
-
stdout: string;
|
|
25
|
-
stderr: string;
|
|
26
|
-
stdout_truncated: boolean;
|
|
27
|
-
stderr_truncated: boolean;
|
|
28
|
-
auth_required?: SandboxEgressAuthRequiredSignal;
|
|
29
|
-
permission_denied?: SandboxEgressPermissionDeniedSignal;
|
|
16
|
+
export interface SandboxAccess {
|
|
17
|
+
readonly tools: SandboxTools;
|
|
18
|
+
readonly workspace: SandboxWorkspace;
|
|
19
|
+
sandboxRef(): SandboxRef | undefined;
|
|
30
20
|
}
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export interface SandboxExecutor {
|
|
36
|
-
configureSkills(skills: SkillMetadata[]): void;
|
|
37
|
-
configureReferenceFiles(files: string[]): void;
|
|
38
|
-
getSandboxId(): string | undefined;
|
|
39
|
-
getDependencyProfileHash(): string | undefined;
|
|
40
|
-
canExecute(toolName: string): boolean;
|
|
41
|
-
createSandbox(): Promise<SandboxInstance>;
|
|
42
|
-
execute<T>(params: SandboxExecutionInput): Promise<SandboxExecutionEnvelope<T>>;
|
|
43
|
-
dispose(): Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
/** Create one sandbox-backed tool executor facade for the current turn. */
|
|
46
|
-
export declare function createSandboxExecutor(options?: {
|
|
47
|
-
sandboxId?: string;
|
|
48
|
-
sandboxDependencyProfileHash?: string;
|
|
21
|
+
export interface SandboxOptions {
|
|
22
|
+
sandboxRef?: SandboxRef;
|
|
23
|
+
skills: SkillMetadata[];
|
|
24
|
+
referenceFiles: string[];
|
|
49
25
|
timeoutMs?: number;
|
|
50
26
|
traceContext?: LogContext;
|
|
51
27
|
tracePropagation?: SandboxEgressTracePropagationConfig;
|
|
52
28
|
credentialEgress?: CredentialContext;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}>;
|
|
59
|
-
}): SandboxExecutor;
|
|
60
|
-
export {};
|
|
29
|
+
prepare?: (workspace: SandboxWorkspace) => void | Promise<void>;
|
|
30
|
+
onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/** Create lazy run-scoped access to a conversation's durable sandbox. */
|
|
33
|
+
export declare function createSandbox(options: SandboxOptions): SandboxAccess;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type NetworkPolicy } from "@vercel/sandbox";
|
|
2
2
|
import { type LogContext, type TracePropagationHeaders } from "@/chat/logging";
|
|
3
|
-
import { type SandboxFileSystem, type
|
|
3
|
+
import { type SandboxFileSystem, type SandboxSession } from "@/chat/sandbox/workspace";
|
|
4
4
|
import type { SkillMetadata } from "@/chat/skills";
|
|
5
|
+
import type { SandboxRef } from "@/chat/sandbox/ref";
|
|
5
6
|
interface SandboxToolExecutors {
|
|
7
|
+
sessionId: string;
|
|
6
8
|
bash: (input: {
|
|
7
9
|
command: string;
|
|
8
10
|
env?: Record<string, string>;
|
|
@@ -30,29 +32,23 @@ interface SandboxToolExecutors {
|
|
|
30
32
|
}>;
|
|
31
33
|
fs: SandboxFileSystem;
|
|
32
34
|
}
|
|
33
|
-
interface
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getSandboxEgressId(): string | undefined;
|
|
38
|
-
getDependencyProfileHash(): string | undefined;
|
|
39
|
-
createSandbox(): Promise<SandboxInstance>;
|
|
40
|
-
ensureToolExecutors(): Promise<SandboxToolExecutors>;
|
|
35
|
+
interface SandboxRuntime {
|
|
36
|
+
sandboxRef(): SandboxRef | undefined;
|
|
37
|
+
acquire(): Promise<SandboxSession>;
|
|
38
|
+
tools(): Promise<SandboxToolExecutors>;
|
|
41
39
|
refreshNetworkPolicy(traceHeaders?: TracePropagationHeaders): Promise<void>;
|
|
42
|
-
dispose(): Promise<void>;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
interface SandboxRuntimeOptions {
|
|
42
|
+
sandboxRef?: SandboxRef;
|
|
43
|
+
skills: SkillMetadata[];
|
|
44
|
+
referenceFiles: string[];
|
|
48
45
|
timeoutMs?: number;
|
|
49
46
|
traceContext?: LogContext;
|
|
50
47
|
commandEnv?: () => Promise<Record<string, string>>;
|
|
51
48
|
createNetworkPolicy?: (egressId: string, traceHeaders?: TracePropagationHeaders) => NetworkPolicy | undefined;
|
|
52
|
-
onSandboxPrepare?: (sandbox:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}): SandboxSessionManager;
|
|
49
|
+
onSandboxPrepare?: (sandbox: SandboxSession) => void | Promise<void>;
|
|
50
|
+
onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
/** Own sandbox acquisition, preparation, and session-scoped tool caching. */
|
|
53
|
+
export declare function createSandboxRuntime(options: SandboxRuntimeOptions): SandboxRuntime;
|
|
58
54
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SandboxSession } from "@/chat/sandbox/workspace";
|
|
2
2
|
import type { SkillMetadata } from "@/chat/skills";
|
|
3
3
|
/** Resolve a virtual sandbox skill path back to the host filesystem when no sandbox exists yet. */
|
|
4
4
|
export declare function resolveHostSkillPath(availableSkills: SkillMetadata[], sandboxPath: string): string | null;
|
|
@@ -8,7 +8,7 @@ export declare function resolveHostDataPath(referenceFiles: string[], sandboxPat
|
|
|
8
8
|
export declare function isHostFileMissingError(error: unknown): boolean;
|
|
9
9
|
/** Copy the current skill set and reference files into a sandbox. */
|
|
10
10
|
export declare function syncSkillsToSandbox(params: {
|
|
11
|
-
sandbox:
|
|
11
|
+
sandbox: SandboxSession;
|
|
12
12
|
skills: SkillMetadata[];
|
|
13
13
|
referenceFiles?: string[];
|
|
14
14
|
withSpan: <T>(name: string, op: string, attributes: Record<string, unknown>, callback: () => Promise<T>) => Promise<T>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type NetworkPolicy, type Sandbox as VercelSandbox } from "@vercel/sandbox";
|
|
2
2
|
export interface SandboxCommandResult {
|
|
3
3
|
exitCode: number;
|
|
4
|
-
stderr
|
|
5
|
-
stdout
|
|
4
|
+
stderr: string;
|
|
5
|
+
stdout: string;
|
|
6
6
|
}
|
|
7
7
|
export interface SandboxCommandInput {
|
|
8
8
|
args?: string[];
|
|
@@ -31,10 +31,15 @@ export interface SandboxWorkspace {
|
|
|
31
31
|
path: string;
|
|
32
32
|
}): Promise<Buffer | null | undefined>;
|
|
33
33
|
runCommand(input: SandboxCommandInput): Promise<SandboxCommandResult>;
|
|
34
|
+
writeFiles(files: Array<{
|
|
35
|
+
content: string | Uint8Array;
|
|
36
|
+
mode?: number;
|
|
37
|
+
path: string;
|
|
38
|
+
}>): Promise<void>;
|
|
34
39
|
}
|
|
35
|
-
export interface
|
|
40
|
+
export interface SandboxSession extends SandboxWorkspace {
|
|
36
41
|
readonly sandboxId: string;
|
|
37
|
-
readonly
|
|
42
|
+
readonly sessionId: string;
|
|
38
43
|
readonly fs: SandboxFileSystem;
|
|
39
44
|
extendTimeout(duration: number): Promise<void>;
|
|
40
45
|
mkDir(path: string): Promise<void>;
|
|
@@ -45,11 +50,8 @@ export interface SandboxInstance extends SandboxWorkspace {
|
|
|
45
50
|
update(params: {
|
|
46
51
|
networkPolicy?: NetworkPolicy;
|
|
47
52
|
}): Promise<void>;
|
|
48
|
-
writeFiles(files: Array<{
|
|
49
|
-
content: string | Uint8Array;
|
|
50
|
-
mode?: number;
|
|
51
|
-
path: string;
|
|
52
|
-
}>): Promise<void>;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
export declare function
|
|
54
|
+
/** Pin Junior's sandbox contract to one Vercel session without SDK replay. */
|
|
55
|
+
export declare function createSandboxSession(sandbox: VercelSandbox, options?: {
|
|
56
|
+
onUnavailable?: (sessionId: string) => void;
|
|
57
|
+
}): SandboxSession;
|