@sentry/junior 0.54.0 → 0.55.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 +13854 -11486
- 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/config.d.ts +1 -0
- package/dist/chat/ingress/workspace-membership.d.ts +1 -2
- package/dist/chat/logging.d.ts +2 -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/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/mcp-auth-orchestration.d.ts +2 -1
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -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-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/{chunk-7WTXNEPF.js → chunk-XI3CFWTA.js} +55 -7
- 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
|
+
}
|
package/dist/chat/config.d.ts
CHANGED
|
@@ -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
|
@@ -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[];
|
|
@@ -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
|
+
}
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
interface SlackUserLookupResult {
|
|
2
2
|
userName?: string;
|
|
3
3
|
fullName?: string;
|
|
4
|
+
email?: string;
|
|
4
5
|
}
|
|
5
6
|
/** Fetch Slack user profile info with in-memory TTL cache to avoid repeated API calls. */
|
|
6
7
|
export declare function lookupSlackUser(userId?: string): Promise<SlackUserLookupResult | null>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Run a callback with the Slack workspace team ID for the inbound webhook. */
|
|
2
|
+
export declare function runWithWorkspaceTeamId<T>(teamId: string | undefined, fn: () => T): T;
|
|
3
|
+
/** Return the Slack workspace team ID for the current inbound webhook. */
|
|
4
|
+
export declare function getWorkspaceTeamId(): string | undefined;
|
|
@@ -5,5 +5,6 @@ import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
|
|
|
5
5
|
import type { SandboxExecutor } from "@/chat/sandbox/sandbox";
|
|
6
6
|
import type { SkillSandbox } from "@/chat/sandbox/skill-sandbox";
|
|
7
7
|
import type { ToolDefinition } from "@/chat/tools/definition";
|
|
8
|
+
import type { AgentPluginHookRunner } from "@/chat/plugins/agent-hooks";
|
|
8
9
|
/** Wrap tool definitions into Pi Agent tool objects with logging, validation, and sandbox execution. */
|
|
9
|
-
export declare function createAgentTools(tools: Record<string, ToolDefinition<any>>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void): AgentTool[];
|
|
10
|
+
export declare function createAgentTools(tools: Record<string, ToolDefinition<any>>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void, agentHooks?: AgentPluginHookRunner): AgentTool[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
2
|
+
/** Create a tool that stores a scheduled task for the active Slack context. */
|
|
3
|
+
export declare function createSlackScheduleCreateTaskTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
|
|
4
|
+
task: import("@sinclair/typebox").TString;
|
|
5
|
+
schedule: import("@sinclair/typebox").TString;
|
|
6
|
+
timezone: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
next_run_at: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
+
recurrence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"daily">, import("@sinclair/typebox").TLiteral<"weekly">, import("@sinclair/typebox").TLiteral<"monthly">, import("@sinclair/typebox").TLiteral<"yearly">]>>;
|
|
9
|
+
}>>;
|
|
10
|
+
/** Create a tool that lists scheduled tasks for the active Slack destination. */
|
|
11
|
+
export declare function createSlackScheduleListTasksTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{}>>;
|
|
12
|
+
/** Create a tool that edits a scheduled task in the active Slack destination. */
|
|
13
|
+
export declare function createSlackScheduleUpdateTaskTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
|
|
14
|
+
task_id: import("@sinclair/typebox").TString;
|
|
15
|
+
task: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
+
schedule: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
timezone: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
+
next_run_at: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
19
|
+
recurrence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"daily">, import("@sinclair/typebox").TLiteral<"weekly">, import("@sinclair/typebox").TLiteral<"monthly">, import("@sinclair/typebox").TLiteral<"yearly">]>, import("@sinclair/typebox").TNull]>>;
|
|
20
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"paused">, import("@sinclair/typebox").TLiteral<"blocked">]>>;
|
|
21
|
+
}>>;
|
|
22
|
+
/** Create a tool that removes a scheduled task from the active Slack destination. */
|
|
23
|
+
export declare function createSlackScheduleDeleteTaskTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
|
|
24
|
+
task_id: import("@sinclair/typebox").TString;
|
|
25
|
+
}>>;
|
|
26
|
+
/** Create a tool that marks an existing scheduled task due immediately. */
|
|
27
|
+
export declare function createSlackScheduleRunTaskNowTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
|
|
28
|
+
task_id: import("@sinclair/typebox").TString;
|
|
29
|
+
}>>;
|
|
@@ -37,6 +37,12 @@ export interface ToolRuntimeContext {
|
|
|
37
37
|
advisor?: AdvisorToolRuntimeContext;
|
|
38
38
|
channelId?: string;
|
|
39
39
|
channelCapabilities: ChannelCapabilities;
|
|
40
|
+
requester?: {
|
|
41
|
+
userId?: string;
|
|
42
|
+
userName?: string;
|
|
43
|
+
fullName?: string;
|
|
44
|
+
};
|
|
45
|
+
teamId?: string;
|
|
40
46
|
messageTs?: string;
|
|
41
47
|
threadTs?: string;
|
|
42
48
|
userText?: string;
|