@sentry/junior 0.54.0 → 0.56.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 +1 -1
- package/dist/app.d.ts +9 -2
- package/dist/app.js +13024 -10255
- package/dist/chat/agent-dispatch/context.d.ts +6 -0
- package/dist/chat/agent-dispatch/heartbeat.d.ts +14 -0
- package/dist/chat/agent-dispatch/runner.d.ts +9 -0
- package/dist/chat/agent-dispatch/signing.d.ts +5 -0
- package/dist/chat/agent-dispatch/store.d.ts +29 -0
- package/dist/chat/agent-dispatch/types.d.ts +57 -0
- package/dist/chat/agent-dispatch/validation.d.ts +3 -0
- package/dist/chat/app/services.d.ts +3 -0
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/ingress/workspace-membership.d.ts +1 -2
- package/dist/chat/logging.d.ts +2 -0
- package/dist/chat/pi/client.d.ts +1 -0
- package/dist/chat/plugins/agent-hooks.d.ts +32 -0
- package/dist/chat/plugins/logging.d.ts +3 -0
- package/dist/chat/plugins/state.d.ts +3 -0
- package/dist/chat/respond.d.ts +11 -0
- package/dist/chat/runtime/reply-executor.d.ts +2 -0
- package/dist/chat/runtime/thread-context.d.ts +2 -0
- package/dist/chat/sandbox/egress-proxy.d.ts +8 -1
- package/dist/chat/sandbox/sandbox.d.ts +2 -0
- package/dist/chat/sandbox/session.d.ts +1 -0
- package/dist/chat/sandbox/skill-sync.d.ts +1 -2
- package/dist/chat/scheduler/cadence.d.ts +24 -0
- package/dist/chat/scheduler/plugin.d.ts +2 -0
- package/dist/chat/scheduler/prompt.d.ts +7 -0
- package/dist/chat/scheduler/store.d.ts +49 -0
- package/dist/chat/scheduler/types.d.ts +86 -0
- package/dist/chat/services/auth-pause.d.ts +7 -0
- package/dist/chat/services/context-budget.d.ts +14 -0
- package/dist/chat/services/context-compaction.d.ts +33 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
- package/dist/chat/slack/assistant-thread/status-scheduler.d.ts +1 -1
- package/dist/chat/slack/ids.d.ts +4 -0
- package/dist/chat/slack/reply.d.ts +1 -1
- package/dist/chat/slack/user.d.ts +1 -0
- package/dist/chat/slack/workspace-context.d.ts +4 -0
- package/dist/chat/tools/agent-tools.d.ts +2 -1
- package/dist/chat/tools/slack/schedule-tools.d.ts +29 -0
- package/dist/chat/tools/types.d.ts +6 -0
- package/dist/{chunk-7WTXNEPF.js → chunk-AA5TIFN5.js} +119 -15
- package/dist/{chunk-QCHPJ4FD.js → chunk-D3G3YOU4.js} +1 -1
- package/dist/chunk-SCQPBJAU.js +21 -0
- package/dist/{chunk-YITDDLS3.js → chunk-TTUY467K.js} +13 -9
- package/dist/cli/check.js +2 -2
- package/dist/cli/init.js +5 -1
- package/dist/cli/snapshot-warmup.js +2 -2
- package/dist/handlers/agent-dispatch.d.ts +3 -0
- package/dist/handlers/heartbeat.d.ts +3 -0
- package/dist/handlers/sandbox-egress-proxy.d.ts +6 -1
- package/dist/vercel.js +3 -12
- package/package.json +8 -2
- package/dist/chat/credentials/test-broker.d.ts +0 -19
- package/dist/chat/sandbox/eval-gh-stub.d.ts +0 -2
- package/dist/chat/sandbox/eval-oauth-stub.d.ts +0 -2
- package/dist/chat/sandbox/eval-sentry-stub.d.ts +0 -2
- package/dist/chat/sandbox/fault-injection.d.ts +0 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HeartbeatHookContext } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** Build the plugin-scoped heartbeat context that gates durable dispatch access. */
|
|
3
|
+
export declare function createHeartbeatContext(args: {
|
|
4
|
+
nowMs: number;
|
|
5
|
+
plugin: string;
|
|
6
|
+
}): HeartbeatHookContext;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Re-drive stale core dispatches before invoking plugin heartbeat hooks. */
|
|
2
|
+
export declare function recoverStaleDispatches(args: {
|
|
3
|
+
limit?: number;
|
|
4
|
+
nowMs: number;
|
|
5
|
+
}): Promise<number>;
|
|
6
|
+
/** Run trusted plugin heartbeat hooks with bounded per-invocation work. */
|
|
7
|
+
export declare function runTrustedPluginHeartbeats(args: {
|
|
8
|
+
limit?: number;
|
|
9
|
+
nowMs: number;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
/** Run the core heartbeat phases. */
|
|
12
|
+
export declare function runHeartbeat(args: {
|
|
13
|
+
nowMs: number;
|
|
14
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { generateAssistantReply as generateAssistantReplyImpl } from "@/chat/respond";
|
|
2
|
+
import { scheduleDispatchCallback } from "./signing";
|
|
3
|
+
import type { DispatchCallback } from "./types";
|
|
4
|
+
export interface AgentDispatchRunnerDeps {
|
|
5
|
+
generateAssistantReply?: typeof generateAssistantReplyImpl;
|
|
6
|
+
scheduleCallback?: typeof scheduleDispatchCallback;
|
|
7
|
+
}
|
|
8
|
+
/** Run one serverless slice for a core-owned agent dispatch. */
|
|
9
|
+
export declare function runAgentDispatchSlice(callback: DispatchCallback, deps?: AgentDispatchRunnerDeps): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DispatchCallback } from "./types";
|
|
2
|
+
/** Schedule an authenticated internal callback to run a dispatched agent slice. */
|
|
3
|
+
export declare function scheduleDispatchCallback(callback: DispatchCallback): Promise<void>;
|
|
4
|
+
/** Verify and parse an authenticated agent dispatch callback request. */
|
|
5
|
+
export declare function verifyDispatchCallbackRequest(request: Request): Promise<DispatchCallback | undefined>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StateAdapter } from "chat";
|
|
2
|
+
import type { DispatchCreateResult, DispatchOptions, DispatchProjection, DispatchRecord, DispatchStatus } from "./types";
|
|
3
|
+
/** Keep dispatch persistence keys consistent across callback and recovery paths. */
|
|
4
|
+
export declare function getDispatchStorageKey(id: string): string;
|
|
5
|
+
/** Map a dispatch destination to the conversation lock and memory key it owns. */
|
|
6
|
+
export declare function getDispatchConversationId(destination: DispatchRecord["destination"]): string;
|
|
7
|
+
/** Give dispatch slices stable turn ids for resumability and trace correlation. */
|
|
8
|
+
export declare function getDispatchTurnId(dispatchId: string): string;
|
|
9
|
+
/** Gate recovery to dispatches that can still make progress. */
|
|
10
|
+
export declare function isTerminalDispatchStatus(status: DispatchStatus): boolean;
|
|
11
|
+
/** Serialize mutations for a dispatch so callbacks and heartbeats stay idempotent. */
|
|
12
|
+
export declare function withDispatchLock<T>(dispatchId: string, callback: (state: StateAdapter) => Promise<T>): Promise<T>;
|
|
13
|
+
/** Load dispatch state for callback, recovery, and plugin projection paths. */
|
|
14
|
+
export declare function getDispatchRecord(id: string): Promise<DispatchRecord | undefined>;
|
|
15
|
+
/** Create a plugin dispatch idempotently from the plugin's idempotency key. */
|
|
16
|
+
export declare function createOrGetDispatch(args: {
|
|
17
|
+
nowMs: number;
|
|
18
|
+
options: DispatchOptions;
|
|
19
|
+
plugin: string;
|
|
20
|
+
}): Promise<DispatchCreateResult>;
|
|
21
|
+
/** Advance dispatch versions so stale callbacks cannot overwrite newer state. */
|
|
22
|
+
export declare function updateDispatchRecord(state: StateAdapter, record: DispatchRecord): Promise<DispatchRecord>;
|
|
23
|
+
/** Feed heartbeat recovery from the durable incomplete-dispatch index. */
|
|
24
|
+
export declare function listIncompleteDispatchIds(): Promise<string[]>;
|
|
25
|
+
/** Return a plugin-scoped dispatch projection without exposing raw runtime state. */
|
|
26
|
+
export declare function getPluginDispatchProjection(args: {
|
|
27
|
+
id: string;
|
|
28
|
+
plugin: string;
|
|
29
|
+
}): Promise<DispatchProjection | undefined>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type DispatchStatus = "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
|
|
2
|
+
export interface DispatchActor {
|
|
3
|
+
type: "system";
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DispatchDestination {
|
|
7
|
+
platform: "slack";
|
|
8
|
+
teamId: string;
|
|
9
|
+
channelId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DispatchCredentialSubject {
|
|
12
|
+
type: "user";
|
|
13
|
+
userId: string;
|
|
14
|
+
allowedWhen: "private-direct-conversation";
|
|
15
|
+
}
|
|
16
|
+
export interface DispatchOptions {
|
|
17
|
+
credentialSubject?: DispatchCredentialSubject;
|
|
18
|
+
destination: DispatchDestination;
|
|
19
|
+
idempotencyKey: string;
|
|
20
|
+
input: string;
|
|
21
|
+
metadata?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface DispatchRecord {
|
|
24
|
+
actor: DispatchActor;
|
|
25
|
+
attempt: number;
|
|
26
|
+
createdAtMs: number;
|
|
27
|
+
credentialSubject?: DispatchCredentialSubject;
|
|
28
|
+
destination: DispatchDestination;
|
|
29
|
+
errorMessage?: string;
|
|
30
|
+
id: string;
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
input: string;
|
|
33
|
+
lastCallbackAtMs?: number;
|
|
34
|
+
leaseExpiresAtMs?: number;
|
|
35
|
+
maxAttempts: number;
|
|
36
|
+
metadata?: Record<string, string>;
|
|
37
|
+
plugin: string;
|
|
38
|
+
resultMessageTs?: string;
|
|
39
|
+
resumeCheckpointVersion?: number;
|
|
40
|
+
status: DispatchStatus;
|
|
41
|
+
updatedAtMs: number;
|
|
42
|
+
version: number;
|
|
43
|
+
}
|
|
44
|
+
export interface DispatchProjection {
|
|
45
|
+
errorMessage?: string;
|
|
46
|
+
id: string;
|
|
47
|
+
resultMessageTs?: string;
|
|
48
|
+
status: DispatchStatus;
|
|
49
|
+
}
|
|
50
|
+
export interface DispatchCallback {
|
|
51
|
+
expectedVersion: number;
|
|
52
|
+
id: string;
|
|
53
|
+
}
|
|
54
|
+
export interface DispatchCreateResult {
|
|
55
|
+
record: DispatchRecord;
|
|
56
|
+
status: "created" | "already_exists";
|
|
57
|
+
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { type ConversationMemoryDeps, type ConversationMemoryService } from "@/chat/services/conversation-memory";
|
|
2
|
+
import { type ContextCompactor, type ContextCompactorDeps } from "@/chat/services/context-compaction";
|
|
2
3
|
import { type SubscribedReplyPolicy, type SubscribedReplyPolicyDeps } from "@/chat/services/subscribed-reply-policy";
|
|
3
4
|
import type { ReplyExecutorServices } from "@/chat/runtime/reply-executor";
|
|
4
5
|
import { type VisionContextDeps, type VisionContextService } from "@/chat/services/vision-context";
|
|
5
6
|
export interface JuniorRuntimeServices {
|
|
6
7
|
conversationMemory: ConversationMemoryService;
|
|
8
|
+
contextCompactor: ContextCompactor;
|
|
7
9
|
replyExecutor: ReplyExecutorServices;
|
|
8
10
|
subscribedReplyPolicy: SubscribedReplyPolicy;
|
|
9
11
|
visionContext: VisionContextService;
|
|
10
12
|
}
|
|
11
13
|
export interface JuniorRuntimeServiceOverrides {
|
|
12
14
|
conversationMemory?: Partial<ConversationMemoryDeps>;
|
|
15
|
+
contextCompactor?: Partial<ContextCompactorDeps>;
|
|
13
16
|
replyExecutor?: Partial<Omit<ReplyExecutorServices, "generateThreadTitle">>;
|
|
14
17
|
subscribedReplyPolicy?: Partial<SubscribedReplyPolicyDeps>;
|
|
15
18
|
visionContext?: Partial<VisionContextDeps>;
|
package/dist/chat/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface BotConfig {
|
|
|
5
5
|
fastModelId: string;
|
|
6
6
|
loadingMessages: string[];
|
|
7
7
|
modelId: string;
|
|
8
|
+
modelContextWindowTokens?: number;
|
|
8
9
|
visionModelId?: string;
|
|
9
10
|
turnTimeoutMs: number;
|
|
10
11
|
userName: string;
|
|
@@ -24,6 +25,7 @@ export interface ChatConfig {
|
|
|
24
25
|
};
|
|
25
26
|
state: {
|
|
26
27
|
adapter: "memory" | "redis";
|
|
28
|
+
keyPrefix?: string;
|
|
27
29
|
redisUrl?: string;
|
|
28
30
|
};
|
|
29
31
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function runWithWorkspaceTeamId<T>(teamId: string | undefined, fn: () => T): T;
|
|
1
|
+
export { runWithWorkspaceTeamId } from "@/chat/slack/workspace-context";
|
|
3
2
|
/**
|
|
4
3
|
* Return true when a Slack event's author is from an external workspace.
|
|
5
4
|
*
|
package/dist/chat/logging.d.ts
CHANGED
package/dist/chat/pi/client.d.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentPluginRequester, JuniorPlugin } from "@sentry/junior-plugin-api";
|
|
2
|
+
import type { ToolDefinition } from "@/chat/tools/definition";
|
|
3
|
+
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
4
|
+
import type { SandboxInstance } from "@/chat/sandbox/workspace";
|
|
5
|
+
/** Signal that a trusted plugin intentionally denied a tool execution. */
|
|
6
|
+
export declare class AgentPluginHookDeniedError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export interface ToolHookInput {
|
|
10
|
+
input: Record<string, unknown>;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolHookResult {
|
|
14
|
+
env: Record<string, string>;
|
|
15
|
+
input: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentPluginHookRunner {
|
|
18
|
+
beforeToolExecute(input: ToolHookInput): Promise<ToolHookResult>;
|
|
19
|
+
prepareSandbox(sandbox: SandboxInstance): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** Validate trusted plugin identity before it can affect process-wide hooks. */
|
|
22
|
+
export declare function validateAgentPlugins(plugins: JuniorPlugin[]): void;
|
|
23
|
+
/** Replace trusted agent plugins and return the previous list for rollback. */
|
|
24
|
+
export declare function setAgentPlugins(plugins: JuniorPlugin[]): JuniorPlugin[];
|
|
25
|
+
/** Return the current trusted agent plugins without exposing mutable state. */
|
|
26
|
+
export declare function getAgentPlugins(): JuniorPlugin[];
|
|
27
|
+
/** Collect turn-scoped tools exposed by trusted plugins. */
|
|
28
|
+
export declare function getAgentPluginTools(context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
|
|
29
|
+
/** Create one runner over trusted agent plugins registered by the app. */
|
|
30
|
+
export declare function createAgentPluginHookRunner(input?: {
|
|
31
|
+
requester?: AgentPluginRequester;
|
|
32
|
+
}): AgentPluginHookRunner;
|
package/dist/chat/respond.d.ts
CHANGED
|
@@ -6,13 +6,20 @@ import type { PiMessage } from "@/chat/pi/messages";
|
|
|
6
6
|
import { type SandboxAcquiredState } from "@/chat/sandbox/sandbox";
|
|
7
7
|
import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
|
|
8
8
|
import { type AssistantReply, type AgentTurnDiagnostics } from "@/chat/services/turn-result";
|
|
9
|
+
import { type AuthorizationFlowMode } from "@/chat/services/auth-pause";
|
|
9
10
|
export type { AssistantReply, AgentTurnDiagnostics };
|
|
10
11
|
export interface ReplyRequestContext {
|
|
11
12
|
skillDirs?: string[];
|
|
13
|
+
credentialSubject?: {
|
|
14
|
+
type: "user";
|
|
15
|
+
userId: string;
|
|
16
|
+
allowedWhen: "private-direct-conversation";
|
|
17
|
+
};
|
|
12
18
|
requester?: {
|
|
13
19
|
userId?: string;
|
|
14
20
|
userName?: string;
|
|
15
21
|
fullName?: string;
|
|
22
|
+
email?: string;
|
|
16
23
|
};
|
|
17
24
|
correlation?: {
|
|
18
25
|
conversationId?: string;
|
|
@@ -20,14 +27,18 @@ export interface ReplyRequestContext {
|
|
|
20
27
|
turnId?: string;
|
|
21
28
|
runId?: string;
|
|
22
29
|
channelId?: string;
|
|
30
|
+
teamId?: string;
|
|
23
31
|
messageTs?: string;
|
|
24
32
|
threadTs?: string;
|
|
25
33
|
requesterId?: string;
|
|
34
|
+
actorType?: string;
|
|
35
|
+
actorId?: string;
|
|
26
36
|
};
|
|
27
37
|
toolChannelId?: string;
|
|
28
38
|
conversationContext?: string;
|
|
29
39
|
artifactState?: ThreadArtifactsState;
|
|
30
40
|
pendingAuth?: ConversationPendingAuthState;
|
|
41
|
+
authorizationFlowMode?: AuthorizationFlowMode;
|
|
31
42
|
configuration?: Record<string, unknown>;
|
|
32
43
|
/** Durable Pi transcript for this conversation, excluding ephemeral turn context. */
|
|
33
44
|
piMessages?: PiMessage[];
|
|
@@ -3,9 +3,11 @@ import type { SlackAdapter } from "@chat-adapter/slack";
|
|
|
3
3
|
import { generateAssistantReply as generateAssistantReplyImpl } from "@/chat/respond";
|
|
4
4
|
import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
|
|
5
5
|
import { type ConversationMemoryService } from "@/chat/services/conversation-memory";
|
|
6
|
+
import type { ContextCompactor } from "@/chat/services/context-compaction";
|
|
6
7
|
import { lookupSlackUser } from "@/chat/slack/user";
|
|
7
8
|
import type { TurnContinuationRequest } from "@/chat/services/timeout-resume";
|
|
8
9
|
export interface ReplyExecutorServices {
|
|
10
|
+
contextCompactor: ContextCompactor;
|
|
9
11
|
generateAssistantReply: typeof generateAssistantReplyImpl;
|
|
10
12
|
generateThreadTitle: ConversationMemoryService["generateThreadTitle"];
|
|
11
13
|
getAwaitingTurnContinuationRequest: (args: {
|
|
@@ -20,3 +20,5 @@ export declare function getAssistantThreadContext(message: Message): {
|
|
|
20
20
|
threadTs: string;
|
|
21
21
|
} | undefined;
|
|
22
22
|
export declare function getMessageTs(message: Message): string | undefined;
|
|
23
|
+
/** Resolve the Slack workspace/team id from the raw inbound message payload. */
|
|
24
|
+
export declare function getTeamId(message: Message): string | undefined;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { JWTPayload } from "jose";
|
|
2
|
+
/** Intercepts a credential-injected sandbox HTTP request before live forwarding. */
|
|
3
|
+
export type SandboxEgressHttpInterceptor = (input: {
|
|
4
|
+
provider: string;
|
|
5
|
+
request: Request;
|
|
6
|
+
upstreamUrl: URL;
|
|
7
|
+
}) => Promise<Response | undefined>;
|
|
2
8
|
interface ProxyDeps {
|
|
3
9
|
fetch?: typeof fetch;
|
|
10
|
+
interceptHttp?: SandboxEgressHttpInterceptor;
|
|
4
11
|
verifyOidc?: (token: string) => Promise<JWTPayload>;
|
|
5
12
|
}
|
|
6
13
|
/** Return whether a request appears to be from the Vercel Sandbox egress proxy. */
|
|
7
14
|
export declare function isSandboxEgressForwardedRequest(request: Request): boolean;
|
|
8
|
-
/** Proxy one Vercel Sandbox firewall egress request through lazy credential
|
|
15
|
+
/** Proxy one Vercel Sandbox firewall egress request through lazy credential headers. */
|
|
9
16
|
export declare function proxySandboxEgressRequest(request: Request, deps?: ProxyDeps): Promise<Response>;
|
|
10
17
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type LogContext } from "@/chat/logging";
|
|
2
|
+
import type { AgentPluginHookRunner } from "@/chat/plugins/agent-hooks";
|
|
2
3
|
import type { SandboxInstance } from "@/chat/sandbox/workspace";
|
|
3
4
|
import type { SkillMetadata } from "@/chat/skills";
|
|
4
5
|
interface SandboxExecutionInput {
|
|
@@ -43,6 +44,7 @@ export declare function createSandboxExecutor(options?: {
|
|
|
43
44
|
credentialEgress?: {
|
|
44
45
|
requesterId: string;
|
|
45
46
|
};
|
|
47
|
+
agentHooks?: AgentPluginHookRunner;
|
|
46
48
|
onSandboxAcquired?: (sandbox: SandboxAcquiredState) => void | Promise<void>;
|
|
47
49
|
runBashCustomCommand?: (command: string) => Promise<{
|
|
48
50
|
handled: boolean;
|
|
@@ -45,6 +45,7 @@ export declare function createSandboxSessionManager(options?: {
|
|
|
45
45
|
traceContext?: LogContext;
|
|
46
46
|
commandEnv?: () => Promise<Record<string, string>>;
|
|
47
47
|
createNetworkPolicy?: (egressId: string) => NetworkPolicy | undefined;
|
|
48
|
+
onSandboxPrepare?: (sandbox: SandboxInstance) => void | Promise<void>;
|
|
48
49
|
onSandboxAcquired?: (sandbox: {
|
|
49
50
|
sandboxId: string;
|
|
50
51
|
sandboxDependencyProfileHash?: string;
|
|
@@ -6,12 +6,11 @@ export declare function resolveHostSkillPath(availableSkills: SkillMetadata[], s
|
|
|
6
6
|
export declare function resolveHostDataPath(referenceFiles: string[], sandboxPath: string): string | null;
|
|
7
7
|
/** Detect missing host-backed skill files so reads can fall back to the sandbox copy. */
|
|
8
8
|
export declare function isHostFileMissingError(error: unknown): boolean;
|
|
9
|
-
/** Copy the current skill set and reference files into a sandbox
|
|
9
|
+
/** Copy the current skill set and reference files into a sandbox. */
|
|
10
10
|
export declare function syncSkillsToSandbox(params: {
|
|
11
11
|
sandbox: SandboxInstance;
|
|
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>;
|
|
15
|
-
runtimeBinDir: string;
|
|
16
15
|
workspaceRoot?: string;
|
|
17
16
|
}): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ScheduledCalendarFrequency, ScheduledTask, ScheduledTaskRecurrence } from "@/chat/scheduler/types";
|
|
2
|
+
/** Parse an ISO timestamp into a finite Unix timestamp in milliseconds. */
|
|
3
|
+
export declare function parseScheduleTimestamp(value: string): number | undefined;
|
|
4
|
+
export interface ZonedDateTimeParts {
|
|
5
|
+
day: number;
|
|
6
|
+
hour: number;
|
|
7
|
+
minute: number;
|
|
8
|
+
month: number;
|
|
9
|
+
second: number;
|
|
10
|
+
weekday: number;
|
|
11
|
+
year: number;
|
|
12
|
+
}
|
|
13
|
+
/** Resolve a UTC timestamp into calendar parts for a named time zone. */
|
|
14
|
+
export declare function getZonedDateTimeParts(timestampMs: number, timezone: string): ZonedDateTimeParts;
|
|
15
|
+
/** Build a calendar recurrence anchored to an exact first run timestamp. */
|
|
16
|
+
export declare function buildCalendarRecurrence(args: {
|
|
17
|
+
frequency: ScheduledCalendarFrequency;
|
|
18
|
+
interval?: number;
|
|
19
|
+
nextRunAtMs: number;
|
|
20
|
+
timezone: string;
|
|
21
|
+
weekdays?: number[];
|
|
22
|
+
}): ScheduledTaskRecurrence;
|
|
23
|
+
/** Return the next fire time after a completed run, when the task recurs. */
|
|
24
|
+
export declare function getNextRunAtMs(task: ScheduledTask, scheduledForMs: number, afterMs?: number): number | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ScheduledRun, type ScheduledTask } from "@/chat/scheduler/types";
|
|
2
|
+
/** Build the marker-delimited user prompt for one scheduled task execution. */
|
|
3
|
+
export declare function buildScheduledTaskRunPrompt(args: {
|
|
4
|
+
nowMs: number;
|
|
5
|
+
run: ScheduledRun;
|
|
6
|
+
task: ScheduledTask;
|
|
7
|
+
}): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { StateAdapter } from "chat";
|
|
2
|
+
import type { ScheduledRun, ScheduledTask } from "@/chat/scheduler/types";
|
|
3
|
+
export interface SchedulerStore {
|
|
4
|
+
claimDueRun(args: {
|
|
5
|
+
nowMs: number;
|
|
6
|
+
}): Promise<ScheduledRun | undefined>;
|
|
7
|
+
getRun(runId: string): Promise<ScheduledRun | undefined>;
|
|
8
|
+
getTask(taskId: string): Promise<ScheduledTask | undefined>;
|
|
9
|
+
listIncompleteRuns(): Promise<ScheduledRun[]>;
|
|
10
|
+
listTasksForTeam(teamId: string): Promise<ScheduledTask[]>;
|
|
11
|
+
markRunBlocked(args: {
|
|
12
|
+
completedAtMs: number;
|
|
13
|
+
errorMessage: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
startedAtMs?: number;
|
|
16
|
+
}): Promise<ScheduledRun | undefined>;
|
|
17
|
+
markRunCompleted(args: {
|
|
18
|
+
completedAtMs: number;
|
|
19
|
+
resultMessageTs?: string;
|
|
20
|
+
runId: string;
|
|
21
|
+
startedAtMs: number;
|
|
22
|
+
}): Promise<ScheduledRun | undefined>;
|
|
23
|
+
markRunFailed(args: {
|
|
24
|
+
completedAtMs: number;
|
|
25
|
+
errorMessage: string;
|
|
26
|
+
startedAtMs?: number;
|
|
27
|
+
runId: string;
|
|
28
|
+
}): Promise<ScheduledRun | undefined>;
|
|
29
|
+
markRunSkipped(args: {
|
|
30
|
+
completedAtMs: number;
|
|
31
|
+
errorMessage: string;
|
|
32
|
+
runId: string;
|
|
33
|
+
}): Promise<ScheduledRun | undefined>;
|
|
34
|
+
markRunDispatched(args: {
|
|
35
|
+
claimedAtMs: number;
|
|
36
|
+
dispatchId: string;
|
|
37
|
+
nowMs: number;
|
|
38
|
+
runId: string;
|
|
39
|
+
}): Promise<ScheduledRun | undefined>;
|
|
40
|
+
saveTask(task: ScheduledTask): Promise<void>;
|
|
41
|
+
updateTaskAfterRun(args: {
|
|
42
|
+
errorMessage?: string;
|
|
43
|
+
nowMs: number;
|
|
44
|
+
run: ScheduledRun;
|
|
45
|
+
status: "blocked" | "completed" | "failed";
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/** Create the production scheduler store backed by Junior's state adapter. */
|
|
49
|
+
export declare function createStateSchedulerStore(stateAdapter?: StateAdapter): SchedulerStore;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
|
|
2
|
+
export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
|
|
3
|
+
export interface ScheduledTaskPrincipal {
|
|
4
|
+
slackUserId: string;
|
|
5
|
+
fullName?: string;
|
|
6
|
+
userName?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ScheduledTaskExecutionActor {
|
|
9
|
+
type: "system";
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const SCHEDULED_TASK_SYSTEM_ACTOR: Readonly<{
|
|
13
|
+
type: "system";
|
|
14
|
+
id: string;
|
|
15
|
+
}>;
|
|
16
|
+
export interface ScheduledTaskDestination {
|
|
17
|
+
platform: "slack";
|
|
18
|
+
teamId: string;
|
|
19
|
+
channelId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ScheduledTaskConversationAccess {
|
|
22
|
+
audience: "direct" | "group" | "channel";
|
|
23
|
+
visibility: "private" | "public" | "unknown";
|
|
24
|
+
}
|
|
25
|
+
export interface ScheduledTaskCredentialSubject {
|
|
26
|
+
type: "user";
|
|
27
|
+
userId: string;
|
|
28
|
+
allowedWhen: "private-direct-conversation";
|
|
29
|
+
}
|
|
30
|
+
export type ScheduledCalendarFrequency = "daily" | "weekly" | "monthly" | "yearly";
|
|
31
|
+
export interface ScheduledLocalTime {
|
|
32
|
+
hour: number;
|
|
33
|
+
minute: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ScheduledTaskRecurrence {
|
|
36
|
+
dayOfMonth?: number;
|
|
37
|
+
frequency: ScheduledCalendarFrequency;
|
|
38
|
+
interval: number;
|
|
39
|
+
month?: number;
|
|
40
|
+
startDate: string;
|
|
41
|
+
time: ScheduledLocalTime;
|
|
42
|
+
weekdays?: number[];
|
|
43
|
+
}
|
|
44
|
+
export interface ScheduledTaskSchedule {
|
|
45
|
+
description: string;
|
|
46
|
+
timezone: string;
|
|
47
|
+
kind: "one_off" | "recurring";
|
|
48
|
+
recurrence?: ScheduledTaskRecurrence;
|
|
49
|
+
}
|
|
50
|
+
export interface ScheduledTaskSpec {
|
|
51
|
+
text: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ScheduledTask {
|
|
54
|
+
id: string;
|
|
55
|
+
createdAtMs: number;
|
|
56
|
+
createdBy: ScheduledTaskPrincipal;
|
|
57
|
+
conversationAccess?: ScheduledTaskConversationAccess;
|
|
58
|
+
credentialSubject?: ScheduledTaskCredentialSubject;
|
|
59
|
+
destination: ScheduledTaskDestination;
|
|
60
|
+
executionActor?: ScheduledTaskExecutionActor;
|
|
61
|
+
lastRunAtMs?: number;
|
|
62
|
+
nextRunAtMs?: number;
|
|
63
|
+
originalRequest?: string;
|
|
64
|
+
runNowAtMs?: number;
|
|
65
|
+
schedule: ScheduledTaskSchedule;
|
|
66
|
+
status: ScheduledTaskStatus;
|
|
67
|
+
statusReason?: string;
|
|
68
|
+
task: ScheduledTaskSpec;
|
|
69
|
+
updatedAtMs: number;
|
|
70
|
+
version: number;
|
|
71
|
+
}
|
|
72
|
+
export interface ScheduledRun {
|
|
73
|
+
id: string;
|
|
74
|
+
attempt: number;
|
|
75
|
+
claimedAtMs: number;
|
|
76
|
+
completedAtMs?: number;
|
|
77
|
+
dispatchId?: string;
|
|
78
|
+
errorMessage?: string;
|
|
79
|
+
idempotencyKey: string;
|
|
80
|
+
resultMessageTs?: string;
|
|
81
|
+
scheduledForMs: number;
|
|
82
|
+
startedAtMs?: number;
|
|
83
|
+
status: ScheduledRunStatus;
|
|
84
|
+
taskId: string;
|
|
85
|
+
taskVersion: number;
|
|
86
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type AuthorizationPauseKind = "mcp" | "plugin";
|
|
2
2
|
export type AuthorizationPauseDisposition = "link_already_sent" | "link_sent";
|
|
3
|
+
export type AuthorizationFlowMode = "interactive" | "disabled";
|
|
3
4
|
/**
|
|
4
5
|
* Runtime-owned signal that the current turn must park until the user
|
|
5
6
|
* completes an external authorization step.
|
|
@@ -10,3 +11,9 @@ export declare class AuthorizationPauseError extends Error {
|
|
|
10
11
|
readonly provider: string;
|
|
11
12
|
constructor(kind: AuthorizationPauseKind, provider: string, disposition: AuthorizationPauseDisposition);
|
|
12
13
|
}
|
|
14
|
+
/** Error indicating this turn cannot start an external authorization flow. */
|
|
15
|
+
export declare class AuthorizationFlowDisabledError extends Error {
|
|
16
|
+
readonly kind: AuthorizationPauseKind;
|
|
17
|
+
readonly provider: string;
|
|
18
|
+
constructor(kind: AuthorizationPauseKind, provider: string);
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ModelContextBudget {
|
|
2
|
+
contextWindow: number;
|
|
3
|
+
maxTokens: number;
|
|
4
|
+
}
|
|
5
|
+
/** Estimate text tokens with the shared coarse heuristic used for local budgets. */
|
|
6
|
+
export declare function estimateTextTokens(text: string): number;
|
|
7
|
+
/** Derive the automatic compaction threshold from model context capacity. */
|
|
8
|
+
export declare function calculateContextCompactionTriggerTokens(model: ModelContextBudget): number;
|
|
9
|
+
/** Derive the post-compaction target from the automatic trigger threshold. */
|
|
10
|
+
export declare function calculateContextCompactionTargetTokens(triggerTokens: number): number;
|
|
11
|
+
/** Resolve the automatic compaction threshold for the active agent model. */
|
|
12
|
+
export declare function getAgentContextCompactionTriggerTokens(): number;
|
|
13
|
+
/** Resolve the visible conversation compaction threshold for the auxiliary model. */
|
|
14
|
+
export declare function getConversationContextCompactionTriggerTokens(): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { completeText } from "@/chat/pi/client";
|
|
2
|
+
import type { PiMessage } from "@/chat/pi/messages";
|
|
3
|
+
import type { ThreadConversationState } from "@/chat/state/conversation";
|
|
4
|
+
export interface ContextCompactorDeps {
|
|
5
|
+
completeText: typeof completeText;
|
|
6
|
+
autoCompactionTriggerTokens?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ContextCompactor {
|
|
9
|
+
maybeCompact: (args: CompactContextArgs) => Promise<CompactContextResult>;
|
|
10
|
+
}
|
|
11
|
+
export interface CompactContextArgs {
|
|
12
|
+
conversation: ThreadConversationState;
|
|
13
|
+
conversationContext?: string;
|
|
14
|
+
conversationId: string;
|
|
15
|
+
onCompactionStart?: () => void;
|
|
16
|
+
previousSessionId: string;
|
|
17
|
+
metadata?: {
|
|
18
|
+
channelId?: string;
|
|
19
|
+
requesterId?: string;
|
|
20
|
+
runId?: string;
|
|
21
|
+
threadId?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface CompactContextResult {
|
|
25
|
+
compacted: boolean;
|
|
26
|
+
piMessages?: PiMessage[];
|
|
27
|
+
reason?: "below_threshold" | "missing_context" | "not_completed" | "summary_failed";
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Build retained user messages for a compacted Pi replacement history. */
|
|
31
|
+
export declare function selectRetainedUserMessages(messages: PiMessage[], maxTokens?: number): PiMessage[];
|
|
32
|
+
/** Build the service that owns local context compaction and checkpoint forks. */
|
|
33
|
+
export declare function createContextCompactor(deps: ContextCompactorDeps): ContextCompactor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
-
import { AuthorizationPauseError } from "@/chat/services/auth-pause";
|
|
2
|
+
import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
|
|
3
3
|
import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
4
4
|
import type { ConversationPendingAuthState } from "@/chat/state/conversation";
|
|
5
5
|
import type { PluginDefinition } from "@/chat/plugins/types";
|
|
@@ -19,6 +19,7 @@ export interface McpAuthOrchestrationDeps {
|
|
|
19
19
|
getArtifactState: () => ThreadArtifactsState | undefined;
|
|
20
20
|
getMergedArtifactState: () => ThreadArtifactsState;
|
|
21
21
|
onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
|
|
22
|
+
authorizationFlowMode?: AuthorizationFlowMode;
|
|
22
23
|
}
|
|
23
24
|
export interface McpAuthOrchestration {
|
|
24
25
|
authProviderFactory: (plugin: PluginDefinition) => Promise<OAuthClientProvider | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
2
2
|
import type { UserTokenStore } from "@/chat/credentials/user-token-store";
|
|
3
|
-
import { AuthorizationPauseError } from "@/chat/services/auth-pause";
|
|
3
|
+
import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
|
|
4
4
|
import type { ConversationPendingAuthState } from "@/chat/state/conversation";
|
|
5
5
|
import type { Skill } from "@/chat/skills";
|
|
6
6
|
export declare class PluginAuthorizationPauseError extends AuthorizationPauseError {
|
|
@@ -20,6 +20,7 @@ export interface PluginAuthOrchestrationDeps {
|
|
|
20
20
|
channelConfiguration?: ChannelConfigurationService;
|
|
21
21
|
currentPendingAuth?: ConversationPendingAuthState;
|
|
22
22
|
onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
|
|
23
|
+
authorizationFlowMode?: AuthorizationFlowMode;
|
|
23
24
|
userTokenStore?: UserTokenStore;
|
|
24
25
|
}
|
|
25
26
|
export interface PluginAuthOrchestration {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AssistantStatusSpec } from "@/chat/slack/assistant-thread/status-render";
|
|
2
2
|
export type TimerHandle = ReturnType<typeof setTimeout>;
|
|
3
3
|
export interface AssistantStatusSession {
|
|
4
|
-
start: () => void;
|
|
4
|
+
start: (status?: AssistantStatusSpec) => void;
|
|
5
5
|
stop: () => Promise<void>;
|
|
6
6
|
update: (status: AssistantStatusSpec) => void;
|
|
7
7
|
}
|