@sentry/junior 0.52.0 → 0.54.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 +3 -2
- package/dist/api-reference.d.ts +7 -0
- package/dist/app.d.ts +5 -10
- package/dist/app.js +1671 -1219
- package/dist/build/copy-build-content.d.ts +4 -0
- package/dist/build/glob-to-regex.d.ts +2 -0
- package/dist/build/rolldown-workarounds.d.ts +14 -0
- package/dist/build/virtual-config.d.ts +4 -0
- package/dist/chat/app/factory.d.ts +10 -0
- package/dist/chat/app/production.d.ts +6 -0
- package/dist/chat/app/services.d.ts +17 -0
- package/dist/chat/capabilities/catalog.d.ts +16 -0
- package/dist/chat/capabilities/factory.d.ts +10 -0
- package/dist/chat/capabilities/jr-rpc-command.d.ts +26 -0
- package/dist/chat/capabilities/router.d.ts +19 -0
- package/dist/chat/coerce.d.ts +6 -0
- package/dist/chat/config.d.ts +46 -0
- package/dist/chat/configuration/defaults.d.ts +4 -0
- package/dist/chat/configuration/service.d.ts +2 -0
- package/dist/chat/configuration/types.d.ts +37 -0
- package/dist/chat/configuration/validation.d.ts +2 -0
- package/dist/chat/credentials/broker.d.ts +22 -0
- package/dist/chat/credentials/header-transforms.d.ts +3 -0
- package/dist/chat/credentials/oauth-scope.d.ts +4 -0
- package/dist/chat/credentials/state-adapter-token-store.d.ts +9 -0
- package/dist/chat/credentials/test-broker.d.ts +19 -0
- package/dist/chat/credentials/unlink-provider.d.ts +2 -0
- package/dist/chat/credentials/user-token-store.d.ts +11 -0
- package/dist/chat/discovery.d.ts +47 -0
- package/dist/chat/ingress/junior-chat.d.ts +26 -0
- package/dist/chat/ingress/message-changed.d.ts +50 -0
- package/dist/chat/ingress/message-router.d.ts +9 -0
- package/dist/chat/ingress/slash-command.d.ts +3 -0
- package/dist/chat/ingress/workspace-membership.d.ts +10 -0
- package/dist/chat/interruption-marker.d.ts +2 -0
- package/dist/chat/logging.d.ts +88 -0
- package/dist/chat/mcp/auth-store.d.ts +41 -0
- package/dist/chat/mcp/client.d.ts +34 -0
- package/dist/chat/mcp/errors.d.ts +8 -0
- package/dist/chat/mcp/oauth-provider.d.ts +27 -0
- package/dist/chat/mcp/oauth.d.ts +17 -0
- package/dist/chat/mcp/tool-manager.d.ts +60 -0
- package/dist/chat/oauth-flow.d.ts +45 -0
- package/dist/chat/optional-string.d.ts +5 -0
- package/dist/chat/pi/client.d.ts +49 -0
- package/dist/chat/pi/messages.d.ts +3 -0
- package/dist/chat/pi/traced-stream.d.ts +9 -0
- package/dist/chat/plugins/auth/api-headers-broker.d.ts +6 -0
- package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +3 -0
- package/dist/chat/plugins/auth/github-app-broker.d.ts +4 -0
- package/dist/chat/plugins/auth/oauth-bearer-broker.d.ts +6 -0
- package/dist/chat/plugins/auth/oauth-request.d.ts +18 -0
- package/dist/chat/plugins/command-env.d.ts +3 -0
- package/dist/chat/plugins/manifest.d.ts +3 -0
- package/dist/chat/plugins/package-discovery.d.ts +14 -0
- package/dist/chat/plugins/registry.d.ts +23 -0
- package/dist/chat/plugins/types.d.ts +146 -0
- package/dist/chat/prompt.d.ts +39 -0
- package/dist/chat/queue/thread-message-dispatcher.d.ts +33 -0
- package/dist/chat/respond-helpers.d.ts +77 -0
- package/dist/chat/respond.d.ts +64 -0
- package/dist/chat/runtime/auth-pause-state.d.ts +11 -0
- package/dist/chat/runtime/delivered-turn-state.d.ts +15 -0
- package/dist/chat/runtime/dev-agent-trace.d.ts +1 -0
- package/dist/chat/runtime/processing-reaction.d.ts +25 -0
- package/dist/chat/runtime/reply-executor.d.ts +56 -0
- package/dist/chat/runtime/report-progress.d.ts +3 -0
- package/dist/chat/runtime/slack-resume.d.ts +50 -0
- package/dist/chat/runtime/slack-runtime.d.ts +100 -0
- package/dist/chat/runtime/thread-context.d.ts +22 -0
- package/dist/chat/runtime/thread-state.d.ts +28 -0
- package/dist/chat/runtime/turn-preparation.d.ts +43 -0
- package/dist/chat/runtime/turn-user-message.d.ts +12 -0
- package/dist/chat/runtime/turn.d.ts +69 -0
- package/dist/chat/sandbox/credentials.d.ts +11 -0
- package/dist/chat/sandbox/egress-oidc.d.ts +3 -0
- package/dist/chat/sandbox/egress-policy.d.ts +11 -0
- package/dist/chat/sandbox/egress-proxy.d.ts +10 -0
- package/dist/chat/sandbox/egress-session.d.ts +27 -0
- package/dist/chat/sandbox/errors.d.ts +12 -0
- package/dist/chat/sandbox/eval-gh-stub.d.ts +2 -0
- package/dist/chat/sandbox/eval-oauth-stub.d.ts +2 -0
- package/dist/chat/sandbox/eval-sentry-stub.d.ts +2 -0
- package/dist/chat/sandbox/fault-injection.d.ts +2 -0
- package/dist/chat/sandbox/http-error-details.d.ts +18 -0
- package/dist/chat/sandbox/noninteractive-command.d.ts +17 -0
- package/dist/chat/sandbox/paths.d.ts +5 -0
- package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +20 -0
- package/dist/chat/sandbox/sandbox.d.ts +52 -0
- package/dist/chat/sandbox/session.d.ts +53 -0
- package/dist/chat/sandbox/skill-sandbox.d.ts +42 -0
- package/dist/chat/sandbox/skill-sync.d.ts +17 -0
- package/dist/chat/sandbox/workspace.d.ts +55 -0
- package/dist/chat/sentry.d.ts +2 -0
- package/dist/chat/services/attachment-claims.d.ts +2 -0
- package/dist/chat/services/auth-pause-response.d.ts +2 -0
- package/dist/chat/services/auth-pause.d.ts +12 -0
- package/dist/chat/services/channel-intent.d.ts +2 -0
- package/dist/chat/services/conversation-memory.d.ts +33 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +29 -0
- package/dist/chat/services/pending-auth.d.ts +27 -0
- package/dist/chat/services/plugin-auth-orchestration.d.ts +36 -0
- package/dist/chat/services/provider-default-config.d.ts +9 -0
- package/dist/chat/services/provider-retry.d.ts +6 -0
- package/dist/chat/services/reply-delivery-plan.d.ts +17 -0
- package/dist/chat/services/subscribed-decision.d.ts +63 -0
- package/dist/chat/services/subscribed-reply-policy.d.ts +23 -0
- package/dist/chat/services/timeout-resume.d.ts +17 -0
- package/dist/chat/services/turn-checkpoint.d.ts +74 -0
- package/dist/chat/services/turn-continuation-response.d.ts +2 -0
- package/dist/chat/services/turn-failure-response.d.ts +15 -0
- package/dist/chat/services/turn-result.d.ts +55 -0
- package/dist/chat/services/turn-thinking-level.d.ts +49 -0
- package/dist/chat/services/vision-context.d.ts +61 -0
- package/dist/chat/skills.d.ts +48 -0
- package/dist/chat/slack/adapter.d.ts +9 -0
- package/dist/chat/slack/app-home.d.ts +11 -0
- package/dist/chat/slack/assistant-thread/lifecycle.d.ts +13 -0
- package/dist/chat/slack/assistant-thread/status-render.d.ts +28 -0
- package/dist/chat/slack/assistant-thread/status-scheduler.d.ts +23 -0
- package/dist/chat/slack/assistant-thread/status-send.d.ts +31 -0
- package/dist/chat/slack/assistant-thread/status.d.ts +36 -0
- package/dist/chat/slack/assistant-thread/title.d.ts +28 -0
- package/dist/chat/slack/canvas-references.d.ts +2 -0
- package/dist/chat/slack/channel.d.ts +48 -0
- package/dist/chat/slack/client.d.ts +52 -0
- package/dist/chat/slack/context.d.ts +9 -0
- package/dist/chat/slack/emoji.d.ts +1 -0
- package/dist/chat/slack/errors.d.ts +6 -0
- package/dist/chat/slack/footer.d.ts +42 -0
- package/dist/chat/slack/legacy-attachments.d.ts +4 -0
- package/dist/chat/slack/message.d.ts +6 -0
- package/dist/chat/slack/mrkdwn.d.ts +12 -0
- package/dist/chat/slack/outbound.d.ts +57 -0
- package/dist/chat/slack/output.d.ts +54 -0
- package/dist/chat/slack/reply.d.ts +33 -0
- package/dist/chat/slack/status-format.d.ts +2 -0
- package/dist/chat/slack/turn-continuation-notice.d.ts +8 -0
- package/dist/chat/slack/user.d.ts +7 -0
- package/dist/chat/slack/users.d.ts +39 -0
- package/dist/chat/state/adapter.d.ts +9 -0
- package/dist/chat/state/artifacts.d.ts +29 -0
- package/dist/chat/state/conversation.d.ts +81 -0
- package/dist/chat/state/pi-session-message-store.d.ts +15 -0
- package/dist/chat/state/turn-id.d.ts +2 -0
- package/dist/chat/state/turn-session-store.d.ts +49 -0
- package/dist/chat/tools/advisor/session-store.d.ts +9 -0
- package/dist/chat/tools/advisor/tool.d.ts +33 -0
- package/dist/chat/tools/agent-tools.d.ts +9 -0
- package/dist/chat/tools/channel-capabilities.d.ts +11 -0
- package/dist/chat/tools/definition.d.ts +17 -0
- package/dist/chat/tools/execution/build-sandbox-input.d.ts +2 -0
- package/dist/chat/tools/execution/normalize-result.d.ts +6 -0
- package/dist/chat/tools/execution/tool-error-handler.d.ts +3 -0
- package/dist/chat/tools/execution/tool-input-error.d.ts +6 -0
- package/dist/chat/tools/idempotency.d.ts +1 -0
- package/dist/chat/tools/index.d.ts +5 -0
- package/dist/chat/tools/runtime/report-progress.d.ts +4 -0
- package/dist/chat/tools/sandbox/attach-file.d.ts +7 -0
- package/dist/chat/tools/sandbox/bash.d.ts +5 -0
- package/dist/chat/tools/sandbox/edit-file.d.ts +37 -0
- package/dist/chat/tools/sandbox/file-utils.d.ts +52 -0
- package/dist/chat/tools/sandbox/find-files.d.ts +24 -0
- package/dist/chat/tools/sandbox/grep.d.ts +33 -0
- package/dist/chat/tools/sandbox/list-dir.d.ts +22 -0
- package/dist/chat/tools/sandbox/read-file.d.ts +32 -0
- package/dist/chat/tools/sandbox/text-edits.d.ts +28 -0
- package/dist/chat/tools/sandbox/write-file.d.ts +5 -0
- package/dist/chat/tools/skill/call-mcp-tool.d.ts +7 -0
- package/dist/chat/tools/skill/load-skill.d.ts +22 -0
- package/dist/chat/tools/skill/mcp-tool-summary.d.ts +31 -0
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +8 -0
- package/dist/chat/tools/slack/canvas-tools.d.ts +29 -0
- package/dist/chat/tools/slack/canvases.d.ts +45 -0
- package/dist/chat/tools/slack/channel-list-messages.d.ts +9 -0
- package/dist/chat/tools/slack/channel-post-message.d.ts +4 -0
- package/dist/chat/tools/slack/list-tools.d.ts +21 -0
- package/dist/chat/tools/slack/lists.d.ts +42 -0
- package/dist/chat/tools/slack/message-add-reaction.d.ts +4 -0
- package/dist/chat/tools/slack/slack-message-url.d.ts +18 -0
- package/dist/chat/tools/slack/thread-read.d.ts +9 -0
- package/dist/chat/tools/slack/user-lookup.d.ts +8 -0
- package/dist/chat/tools/system-time.d.ts +1 -0
- package/dist/chat/tools/types.d.ts +55 -0
- package/dist/chat/tools/web/constants.d.ts +6 -0
- package/dist/chat/tools/web/fetch-content.d.ts +23 -0
- package/dist/chat/tools/web/fetch-tool.d.ts +5 -0
- package/dist/chat/tools/web/image-generate.d.ts +4 -0
- package/dist/chat/tools/web/network.d.ts +6 -0
- package/dist/chat/tools/web/search.d.ts +5 -0
- package/dist/chat/turn-context-tag.d.ts +6 -0
- package/dist/chat/usage.d.ts +24 -0
- package/dist/chat/xml.d.ts +1 -0
- package/dist/{chunk-XPXD3FCE.js → chunk-5LUISFEY.js} +189 -35
- package/dist/{chunk-KCOKQLBF.js → chunk-7WTXNEPF.js} +120 -15
- package/dist/{chunk-ZNFNY53B.js → chunk-QCHPJ4FD.js} +2 -2
- package/dist/{chunk-Q3FDONU7.js → chunk-YITDDLS3.js} +34 -28
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +1 -0
- package/dist/cli/snapshot-warmup.js +3 -3
- package/dist/handlers/diagnostics-dashboard.d.ts +2 -0
- package/dist/handlers/diagnostics.d.ts +2 -0
- package/dist/handlers/health.d.ts +4 -0
- package/dist/handlers/mcp-oauth-callback.d.ts +2 -0
- package/dist/handlers/oauth-callback.d.ts +2 -0
- package/dist/handlers/oauth-html.d.ts +2 -0
- package/dist/handlers/sandbox-egress-proxy.d.ts +4 -0
- package/dist/handlers/turn-resume.d.ts +3 -0
- package/dist/handlers/types.d.ts +2 -0
- package/dist/handlers/webhooks.d.ts +15 -0
- package/dist/instrumentation.d.ts +1 -3
- package/dist/nitro.d.ts +4 -7
- package/dist/nitro.js +112 -54
- package/dist/package-resolution.d.ts +13 -0
- package/dist/vercel.d.ts +2 -4
- package/package.json +25 -25
- package/dist/cli/check.d.ts +0 -8
- package/dist/cli/env.d.ts +0 -7
- package/dist/cli/init.d.ts +0 -3
- package/dist/cli/run.d.ts +0 -12
- package/dist/cli/snapshot-warmup.d.ts +0 -3
- package/dist/types-X_iCClPb.d.ts +0 -75
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CredentialHeaderTransform } from "@/chat/credentials/broker";
|
|
2
|
+
export declare const SANDBOX_EGRESS_PROXY_PATH = "/api/internal/sandbox-egress";
|
|
3
|
+
export interface SandboxEgressRequesterContext {
|
|
4
|
+
requesterId: string;
|
|
5
|
+
egressId: string;
|
|
6
|
+
expiresAtMs: number;
|
|
7
|
+
contextId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SandboxEgressCredentialLease {
|
|
10
|
+
provider: string;
|
|
11
|
+
expiresAt: string;
|
|
12
|
+
headerTransforms: CredentialHeaderTransform[];
|
|
13
|
+
}
|
|
14
|
+
/** Create a signed requester/sandbox context token for lazy sandbox egress auth. */
|
|
15
|
+
export declare function createSandboxEgressRequesterToken(input: {
|
|
16
|
+
requesterId: string;
|
|
17
|
+
egressId: string;
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
}): string;
|
|
20
|
+
/** Verify a signed requester/sandbox context token from the proxy URL. */
|
|
21
|
+
export declare function parseSandboxEgressRequesterToken(token: string | undefined): SandboxEgressRequesterContext | undefined;
|
|
22
|
+
/** Cache a short-lived credential lease for repeated forwarded requests for one requester/sandbox context. */
|
|
23
|
+
export declare function setSandboxEgressCredentialLease(context: SandboxEgressRequesterContext, lease: SandboxEgressCredentialLease): Promise<void>;
|
|
24
|
+
/** Load a cached egress credential lease for a requester/sandbox context/provider pair. */
|
|
25
|
+
export declare function getSandboxEgressCredentialLease(provider: string, context: SandboxEgressRequesterContext): Promise<SandboxEgressCredentialLease | undefined>;
|
|
26
|
+
/** Clear a cached egress credential lease after the provider rejects its headers. */
|
|
27
|
+
export declare function clearSandboxEgressCredentialLease(provider: string, context: SandboxEgressRequesterContext): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Detect sandbox filesystem operations that can safely ignore existing directories. */
|
|
2
|
+
export declare function isAlreadyExistsError(error: unknown): boolean;
|
|
3
|
+
/** Detect when a cached sandbox can no longer be reused and must be recreated. */
|
|
4
|
+
export declare function isSandboxUnavailableError(error: unknown): boolean;
|
|
5
|
+
/** Detect transient snapshot boot races so sandbox creation can retry. */
|
|
6
|
+
export declare function isSnapshottingError(error: unknown): boolean;
|
|
7
|
+
/** Detect interrupted command streams where no reliable exit status is available. */
|
|
8
|
+
export declare function isSandboxCommandStreamInterruptedError(error: unknown): boolean;
|
|
9
|
+
/** Wrap raw sandbox setup failures into one stable user-facing error contract. */
|
|
10
|
+
export declare function wrapSandboxSetupError(error: unknown): Error;
|
|
11
|
+
/** Record span data and throw one stable sandbox operation error. */
|
|
12
|
+
export declare function throwSandboxOperationError(action: string, error: unknown, includeMissingPath?: boolean): never;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ExtraFieldOption {
|
|
2
|
+
sourceKey: string;
|
|
3
|
+
attributeKey: string;
|
|
4
|
+
summaryKey?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ExtractHttpErrorDetailsOptions {
|
|
7
|
+
attributePrefix?: string;
|
|
8
|
+
previewLimit?: number;
|
|
9
|
+
extraFields?: ExtraFieldOption[];
|
|
10
|
+
}
|
|
11
|
+
export interface ExtractedHttpErrorDetails {
|
|
12
|
+
attributes: Record<string, string | number | boolean | string[]>;
|
|
13
|
+
summary: string;
|
|
14
|
+
searchableText: string;
|
|
15
|
+
}
|
|
16
|
+
/** Extract structured HTTP error metadata (status, headers, body preview) for logging. */
|
|
17
|
+
export declare function extractHttpErrorDetails(error: unknown, options?: ExtractHttpErrorDetailsOptions): ExtractedHttpErrorDetails;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SandboxCommandResult, SandboxWorkspace } from "@/chat/sandbox/workspace";
|
|
2
|
+
interface NonInteractiveShellOptions {
|
|
3
|
+
env?: Record<string, string>;
|
|
4
|
+
pathPrefix?: string;
|
|
5
|
+
}
|
|
6
|
+
interface NonInteractiveCommandInput extends NonInteractiveShellOptions {
|
|
7
|
+
args?: string[];
|
|
8
|
+
cmd: string;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
login?: boolean;
|
|
11
|
+
sudo?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Build one shell entrypoint that never waits on terminal input. */
|
|
14
|
+
export declare function buildNonInteractiveShellScript(script: string, options?: NonInteractiveShellOptions): string;
|
|
15
|
+
/** Run a subprocess through one enforced non-interactive entrypoint. */
|
|
16
|
+
export declare function runNonInteractiveCommand(sandbox: Pick<SandboxWorkspace, "runCommand">, input: NonInteractiveCommandInput): Promise<SandboxCommandResult>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const SANDBOX_WORKSPACE_ROOT: string;
|
|
2
|
+
export declare const SANDBOX_SKILLS_ROOT: string;
|
|
3
|
+
export declare const SANDBOX_DATA_ROOT: string;
|
|
4
|
+
export declare function sandboxSkillDir(skillName: string): string;
|
|
5
|
+
export declare function sandboxSkillFile(skillName: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type SnapshotResolveOutcome = "no_profile" | "cache_hit" | "cache_hit_after_lock_wait" | "rebuilt" | "forced_rebuild";
|
|
2
|
+
export type SnapshotRebuildReason = "cache_miss" | "floating_stale" | "force_rebuild" | "snapshot_missing";
|
|
3
|
+
export interface RuntimeDependencySnapshot {
|
|
4
|
+
snapshotId?: string;
|
|
5
|
+
profileHash?: string;
|
|
6
|
+
dependencyCount: number;
|
|
7
|
+
cacheHit: boolean;
|
|
8
|
+
resolveOutcome: SnapshotResolveOutcome;
|
|
9
|
+
rebuildReason?: SnapshotRebuildReason;
|
|
10
|
+
}
|
|
11
|
+
export type RuntimeDependencySnapshotProgressPhase = "resolve_start" | "cache_hit" | "waiting_for_lock" | "building_snapshot" | "build_complete";
|
|
12
|
+
export declare function getRuntimeDependencyProfileHash(runtime: string): string | undefined;
|
|
13
|
+
export declare function resolveRuntimeDependencySnapshot(params: {
|
|
14
|
+
runtime: string;
|
|
15
|
+
timeoutMs: number;
|
|
16
|
+
forceRebuild?: boolean;
|
|
17
|
+
staleSnapshotId?: string;
|
|
18
|
+
onProgress?: (phase: RuntimeDependencySnapshotProgressPhase) => void | Promise<void>;
|
|
19
|
+
}): Promise<RuntimeDependencySnapshot>;
|
|
20
|
+
export declare function isSnapshotMissingError(error: unknown): boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type LogContext } from "@/chat/logging";
|
|
2
|
+
import type { SandboxInstance } from "@/chat/sandbox/workspace";
|
|
3
|
+
import type { SkillMetadata } from "@/chat/skills";
|
|
4
|
+
interface SandboxExecutionInput {
|
|
5
|
+
toolName: string;
|
|
6
|
+
input: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface SandboxExecutionEnvelope<T = unknown> {
|
|
9
|
+
result: T;
|
|
10
|
+
}
|
|
11
|
+
export interface BashCustomCommandResult {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
command: string;
|
|
14
|
+
cwd: string;
|
|
15
|
+
exit_code: number;
|
|
16
|
+
signal: null;
|
|
17
|
+
timed_out: boolean;
|
|
18
|
+
stdout: string;
|
|
19
|
+
stderr: string;
|
|
20
|
+
stdout_truncated: boolean;
|
|
21
|
+
stderr_truncated: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface SandboxAcquiredState {
|
|
24
|
+
sandboxId: string;
|
|
25
|
+
sandboxDependencyProfileHash?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SandboxExecutor {
|
|
28
|
+
configureSkills(skills: SkillMetadata[]): void;
|
|
29
|
+
configureReferenceFiles(files: string[]): void;
|
|
30
|
+
getSandboxId(): string | undefined;
|
|
31
|
+
getDependencyProfileHash(): string | undefined;
|
|
32
|
+
canExecute(toolName: string): boolean;
|
|
33
|
+
createSandbox(): Promise<SandboxInstance>;
|
|
34
|
+
execute<T>(params: SandboxExecutionInput): Promise<SandboxExecutionEnvelope<T>>;
|
|
35
|
+
dispose(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** Create one sandbox-backed tool executor facade for the current turn. */
|
|
38
|
+
export declare function createSandboxExecutor(options?: {
|
|
39
|
+
sandboxId?: string;
|
|
40
|
+
sandboxDependencyProfileHash?: string;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
traceContext?: LogContext;
|
|
43
|
+
credentialEgress?: {
|
|
44
|
+
requesterId: string;
|
|
45
|
+
};
|
|
46
|
+
onSandboxAcquired?: (sandbox: SandboxAcquiredState) => void | Promise<void>;
|
|
47
|
+
runBashCustomCommand?: (command: string) => Promise<{
|
|
48
|
+
handled: boolean;
|
|
49
|
+
result?: BashCustomCommandResult;
|
|
50
|
+
}>;
|
|
51
|
+
}): SandboxExecutor;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type NetworkPolicy } from "@vercel/sandbox";
|
|
2
|
+
import { type LogContext } from "@/chat/logging";
|
|
3
|
+
import { type SandboxFileSystem, type SandboxInstance } from "@/chat/sandbox/workspace";
|
|
4
|
+
import type { SkillMetadata } from "@/chat/skills";
|
|
5
|
+
interface SandboxToolExecutors {
|
|
6
|
+
bash: (input: {
|
|
7
|
+
command: string;
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
exitCode: number;
|
|
14
|
+
stdoutTruncated: boolean;
|
|
15
|
+
stderrTruncated: boolean;
|
|
16
|
+
timedOut?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
readFile: (input: {
|
|
19
|
+
path: string;
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
content: string;
|
|
22
|
+
}>;
|
|
23
|
+
writeFile: (input: {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
fs: SandboxFileSystem;
|
|
30
|
+
}
|
|
31
|
+
interface SandboxSessionManager {
|
|
32
|
+
configureSkills(skills: SkillMetadata[]): void;
|
|
33
|
+
configureReferenceFiles(files: string[]): void;
|
|
34
|
+
getSandboxId(): string | undefined;
|
|
35
|
+
getDependencyProfileHash(): string | undefined;
|
|
36
|
+
createSandbox(): Promise<SandboxInstance>;
|
|
37
|
+
ensureToolExecutors(): Promise<SandboxToolExecutors>;
|
|
38
|
+
dispose(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/** Manage sandbox lifecycle, sync, keepalive, and tool executor caching for one executor instance. */
|
|
41
|
+
export declare function createSandboxSessionManager(options?: {
|
|
42
|
+
sandboxId?: string;
|
|
43
|
+
sandboxDependencyProfileHash?: string;
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
traceContext?: LogContext;
|
|
46
|
+
commandEnv?: () => Promise<Record<string, string>>;
|
|
47
|
+
createNetworkPolicy?: (egressId: string) => NetworkPolicy | undefined;
|
|
48
|
+
onSandboxAcquired?: (sandbox: {
|
|
49
|
+
sandboxId: string;
|
|
50
|
+
sandboxDependencyProfileHash?: string;
|
|
51
|
+
}) => void | Promise<void>;
|
|
52
|
+
}): SandboxSessionManager;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Skill, type SkillMetadata } from "@/chat/skills";
|
|
2
|
+
export interface SkillSandboxFileEntry {
|
|
3
|
+
path: string;
|
|
4
|
+
type: "file" | "directory";
|
|
5
|
+
}
|
|
6
|
+
export interface SkillSandboxListFilesResult {
|
|
7
|
+
skillName: string;
|
|
8
|
+
directory: string;
|
|
9
|
+
entries: SkillSandboxFileEntry[];
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SkillSandboxReadFileResult {
|
|
13
|
+
skillName: string;
|
|
14
|
+
path: string;
|
|
15
|
+
content: string;
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Sandboxed file access scoped to the active skill's directory — prevents path traversal. */
|
|
19
|
+
export declare class SkillSandbox {
|
|
20
|
+
private readonly availableSkills;
|
|
21
|
+
private readonly availableByName;
|
|
22
|
+
private readonly loadedSkills;
|
|
23
|
+
private activeSkillName;
|
|
24
|
+
constructor(availableSkills: SkillMetadata[], preloadedSkills?: Skill[]);
|
|
25
|
+
getAvailableSkills(): SkillMetadata[];
|
|
26
|
+
getLoadedSkillNames(): string[];
|
|
27
|
+
getActiveSkill(): Skill | null;
|
|
28
|
+
loadSkill(skillName: string): Promise<Skill | null>;
|
|
29
|
+
filterToolNames(toolNames: string[]): string[] | null;
|
|
30
|
+
listFiles(params: {
|
|
31
|
+
skillName?: string;
|
|
32
|
+
directory?: string;
|
|
33
|
+
recursive?: boolean;
|
|
34
|
+
maxEntries?: number;
|
|
35
|
+
}): Promise<SkillSandboxListFilesResult>;
|
|
36
|
+
readFile(params: {
|
|
37
|
+
skillName?: string;
|
|
38
|
+
filePath: string;
|
|
39
|
+
maxChars?: number;
|
|
40
|
+
}): Promise<SkillSandboxReadFileResult>;
|
|
41
|
+
private requireSkill;
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SandboxInstance } from "@/chat/sandbox/workspace";
|
|
2
|
+
import type { SkillMetadata } from "@/chat/skills";
|
|
3
|
+
/** Resolve a virtual sandbox skill path back to the host filesystem when no sandbox exists yet. */
|
|
4
|
+
export declare function resolveHostSkillPath(availableSkills: SkillMetadata[], sandboxPath: string): string | null;
|
|
5
|
+
/** Resolve a virtual sandbox data path back to the host filesystem when no sandbox exists yet. */
|
|
6
|
+
export declare function resolveHostDataPath(referenceFiles: string[], sandboxPath: string): string | null;
|
|
7
|
+
/** Detect missing host-backed skill files so reads can fall back to the sandbox copy. */
|
|
8
|
+
export declare function isHostFileMissingError(error: unknown): boolean;
|
|
9
|
+
/** Copy the current skill set and reference files into a sandbox and mark runtime shims executable. */
|
|
10
|
+
export declare function syncSkillsToSandbox(params: {
|
|
11
|
+
sandbox: SandboxInstance;
|
|
12
|
+
skills: SkillMetadata[];
|
|
13
|
+
referenceFiles?: string[];
|
|
14
|
+
withSpan: <T>(name: string, op: string, attributes: Record<string, unknown>, callback: () => Promise<T>) => Promise<T>;
|
|
15
|
+
runtimeBinDir: string;
|
|
16
|
+
workspaceRoot?: string;
|
|
17
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NetworkPolicy, Sandbox as VercelSandbox } from "@vercel/sandbox";
|
|
2
|
+
export interface SandboxCommandResult {
|
|
3
|
+
exitCode: number;
|
|
4
|
+
stderr(): Promise<string>;
|
|
5
|
+
stdout(): Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export interface SandboxCommandInput {
|
|
8
|
+
args?: string[];
|
|
9
|
+
cmd: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
sudo?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SandboxFileStat {
|
|
16
|
+
isDirectory(): boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SandboxFileSystem {
|
|
19
|
+
readFile(filePath: string, options: {
|
|
20
|
+
encoding: BufferEncoding;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
writeFile(filePath: string, content: string, options?: {
|
|
23
|
+
encoding?: BufferEncoding;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
readdir(filePath: string): Promise<string[]>;
|
|
26
|
+
stat(filePath: string): Promise<SandboxFileStat>;
|
|
27
|
+
}
|
|
28
|
+
export interface SandboxWorkspace {
|
|
29
|
+
readFileToBuffer(input: {
|
|
30
|
+
cwd?: string;
|
|
31
|
+
path: string;
|
|
32
|
+
}): Promise<Buffer | null | undefined>;
|
|
33
|
+
runCommand(input: SandboxCommandInput): Promise<SandboxCommandResult>;
|
|
34
|
+
}
|
|
35
|
+
export interface SandboxInstance extends SandboxWorkspace {
|
|
36
|
+
readonly sandboxId: string;
|
|
37
|
+
readonly sandboxEgressId: string;
|
|
38
|
+
readonly fs: SandboxFileSystem;
|
|
39
|
+
extendTimeout(duration: number): Promise<void>;
|
|
40
|
+
mkDir(path: string): Promise<void>;
|
|
41
|
+
snapshot(): Promise<{
|
|
42
|
+
snapshotId: string;
|
|
43
|
+
}>;
|
|
44
|
+
stop(): Promise<unknown>;
|
|
45
|
+
update(params: {
|
|
46
|
+
networkPolicy?: NetworkPolicy;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
writeFiles(files: Array<{
|
|
49
|
+
content: string | Uint8Array;
|
|
50
|
+
mode?: number;
|
|
51
|
+
path: string;
|
|
52
|
+
}>): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/** Adapt the Vercel SDK object once so the rest of Junior sees one sandbox contract. */
|
|
55
|
+
export declare function createSandboxInstance(sandbox: VercelSandbox): SandboxInstance;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AuthorizationPauseKind = "mcp" | "plugin";
|
|
2
|
+
export type AuthorizationPauseDisposition = "link_already_sent" | "link_sent";
|
|
3
|
+
/**
|
|
4
|
+
* Runtime-owned signal that the current turn must park until the user
|
|
5
|
+
* completes an external authorization step.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthorizationPauseError extends Error {
|
|
8
|
+
readonly disposition: AuthorizationPauseDisposition;
|
|
9
|
+
readonly kind: AuthorizationPauseKind;
|
|
10
|
+
readonly provider: string;
|
|
11
|
+
constructor(kind: AuthorizationPauseKind, provider: string, disposition: AuthorizationPauseDisposition);
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { completeText } from "@/chat/pi/client";
|
|
2
|
+
import type { ConversationMessage, ThreadConversationState } from "@/chat/state/conversation";
|
|
3
|
+
export interface ConversationMemoryDeps {
|
|
4
|
+
completeText: typeof completeText;
|
|
5
|
+
}
|
|
6
|
+
export interface ConversationMemoryService {
|
|
7
|
+
compactConversationIfNeeded: (conversation: ThreadConversationState, context: {
|
|
8
|
+
threadId?: string;
|
|
9
|
+
channelId?: string;
|
|
10
|
+
requesterId?: string;
|
|
11
|
+
runId?: string;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
generateThreadTitle: (sourceText: string) => Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
export declare function generateConversationId(prefix: "assistant" | "backfill" | "compaction" | "turn"): string;
|
|
16
|
+
export declare function normalizeConversationText(text: string): string;
|
|
17
|
+
export declare function updateConversationStats(conversation: ThreadConversationState): void;
|
|
18
|
+
export declare function upsertConversationMessage(conversation: ThreadConversationState, message: ConversationMessage): string;
|
|
19
|
+
export declare function markConversationMessage(conversation: ThreadConversationState, messageId: string | undefined, patch: Partial<NonNullable<ConversationMessage["meta"]>>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Render thread history as structured XML. Each compaction and message is
|
|
22
|
+
* wrapped with index/ts metadata so the model can reference prior items
|
|
23
|
+
* individually instead of treating the whole block as one flat narrative.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildConversationContext(conversation: ThreadConversationState, options?: {
|
|
26
|
+
excludeMessageId?: string;
|
|
27
|
+
}): string | undefined;
|
|
28
|
+
/** Return the earliest human-authored message known for a thread. */
|
|
29
|
+
export declare function getThreadTitleSourceMessage(conversation: ThreadConversationState): ConversationMessage | undefined;
|
|
30
|
+
/** Build the service that owns durable conversation memory compaction and titles. */
|
|
31
|
+
export declare function createConversationMemoryService(deps: ConversationMemoryDeps): ConversationMemoryService;
|
|
32
|
+
export declare function isHumanConversationMessage(message: ConversationMessage): boolean;
|
|
33
|
+
export declare function getConversationMessageSlackTs(message: ConversationMessage): string | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
+
import { AuthorizationPauseError } from "@/chat/services/auth-pause";
|
|
3
|
+
import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
4
|
+
import type { ConversationPendingAuthState } from "@/chat/state/conversation";
|
|
5
|
+
import type { PluginDefinition } from "@/chat/plugins/types";
|
|
6
|
+
export declare class McpAuthorizationPauseError extends AuthorizationPauseError {
|
|
7
|
+
constructor(provider: string, disposition: "link_already_sent" | "link_sent");
|
|
8
|
+
}
|
|
9
|
+
export interface McpAuthOrchestrationDeps {
|
|
10
|
+
conversationId?: string;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
requesterId?: string;
|
|
13
|
+
channelId?: string;
|
|
14
|
+
threadTs?: string;
|
|
15
|
+
toolChannelId?: string;
|
|
16
|
+
userMessage: string;
|
|
17
|
+
currentPendingAuth?: ConversationPendingAuthState;
|
|
18
|
+
getConfiguration: () => Record<string, unknown>;
|
|
19
|
+
getArtifactState: () => ThreadArtifactsState | undefined;
|
|
20
|
+
getMergedArtifactState: () => ThreadArtifactsState;
|
|
21
|
+
onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface McpAuthOrchestration {
|
|
24
|
+
authProviderFactory: (plugin: PluginDefinition) => Promise<OAuthClientProvider | undefined>;
|
|
25
|
+
onAuthorizationRequired: (provider: string) => Promise<boolean>;
|
|
26
|
+
getPendingPause: () => McpAuthorizationPauseError | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Create MCP authorization orchestration for a single turn. */
|
|
29
|
+
export declare function createMcpAuthOrchestration(deps: McpAuthOrchestrationDeps, abortAgent: () => void): McpAuthOrchestration;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AuthorizationPauseKind } from "@/chat/services/auth-pause";
|
|
2
|
+
import type { ConversationPendingAuthState, ThreadConversationState } from "@/chat/state/conversation";
|
|
3
|
+
export declare function canReusePendingAuthLink(args: {
|
|
4
|
+
kind: AuthorizationPauseKind;
|
|
5
|
+
nowMs?: number;
|
|
6
|
+
pendingAuth?: ConversationPendingAuthState;
|
|
7
|
+
provider: string;
|
|
8
|
+
requesterId: string;
|
|
9
|
+
}): boolean;
|
|
10
|
+
export declare function getConversationPendingAuth(args: {
|
|
11
|
+
conversation: ThreadConversationState;
|
|
12
|
+
kind: AuthorizationPauseKind;
|
|
13
|
+
provider: string;
|
|
14
|
+
requesterId: string;
|
|
15
|
+
}): ConversationPendingAuthState | undefined;
|
|
16
|
+
export declare function clearPendingAuth(conversation: ThreadConversationState, sessionId?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Apply a new pending-auth record to the conversation and, when replacing a
|
|
19
|
+
* different session's pending-auth, mark the prior checkpoint as superseded.
|
|
20
|
+
* Callers are responsible for persisting the mutated conversation afterwards.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyPendingAuthUpdate(args: {
|
|
23
|
+
conversation: ThreadConversationState;
|
|
24
|
+
conversationId: string | undefined;
|
|
25
|
+
nextPendingAuth: ConversationPendingAuthState;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
export declare function isPendingAuthLatestRequest(conversation: ThreadConversationState, pendingAuth: ConversationPendingAuthState): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
2
|
+
import type { UserTokenStore } from "@/chat/credentials/user-token-store";
|
|
3
|
+
import { AuthorizationPauseError } from "@/chat/services/auth-pause";
|
|
4
|
+
import type { ConversationPendingAuthState } from "@/chat/state/conversation";
|
|
5
|
+
import type { Skill } from "@/chat/skills";
|
|
6
|
+
export declare class PluginAuthorizationPauseError extends AuthorizationPauseError {
|
|
7
|
+
constructor(provider: string, disposition: "link_already_sent" | "link_sent");
|
|
8
|
+
}
|
|
9
|
+
export declare class PluginCredentialFailureError extends Error {
|
|
10
|
+
readonly provider: string;
|
|
11
|
+
constructor(provider: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
export interface PluginAuthOrchestrationDeps {
|
|
14
|
+
conversationId?: string;
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
requesterId?: string;
|
|
17
|
+
channelId?: string;
|
|
18
|
+
threadTs?: string;
|
|
19
|
+
userMessage: string;
|
|
20
|
+
channelConfiguration?: ChannelConfigurationService;
|
|
21
|
+
currentPendingAuth?: ConversationPendingAuthState;
|
|
22
|
+
onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
|
|
23
|
+
userTokenStore?: UserTokenStore;
|
|
24
|
+
}
|
|
25
|
+
export interface PluginAuthOrchestration {
|
|
26
|
+
handleCommandFailure: (input: {
|
|
27
|
+
activeSkill: Skill | null;
|
|
28
|
+
command: string;
|
|
29
|
+
details: unknown;
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
getPendingPause: () => PluginAuthorizationPauseError | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Start plugin OAuth from an authenticated bash command and park the turn.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPluginAuthOrchestration(deps: PluginAuthOrchestrationDeps, abortAgent: () => void): PluginAuthOrchestration;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
2
|
+
/** Apply explicit provider-default config requests that do not need agent reasoning. */
|
|
3
|
+
export declare function maybeApplyProviderDefaultConfigRequest(args: {
|
|
4
|
+
channelConfiguration?: ChannelConfigurationService;
|
|
5
|
+
requesterId?: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
text: string;
|
|
9
|
+
} | null>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { PiMessage } from "@/chat/pi/messages";
|
|
3
|
+
/** Detect transient provider failures that are safe to retry from a Pi boundary. */
|
|
4
|
+
export declare function isRetryableProviderError(message: Pick<AssistantMessage, "stopReason" | "errorMessage"> | undefined): boolean;
|
|
5
|
+
/** Remove a failed assistant tail only when the remaining Pi history can continue. */
|
|
6
|
+
export declare function trimRetryableProviderErrorTail(messages: PiMessage[]): PiMessage[] | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ReplyDeliveryMode = "thread" | "channel_only";
|
|
2
|
+
export type ReplyFileDelivery = "none" | "inline" | "followup";
|
|
3
|
+
export interface ReplyDeliveryPlan {
|
|
4
|
+
mode: ReplyDeliveryMode;
|
|
5
|
+
postThreadText: boolean;
|
|
6
|
+
attachFiles: ReplyFileDelivery;
|
|
7
|
+
}
|
|
8
|
+
/** Check if text is a short acknowledgment (emoji, "ok", etc.) that a reaction already covers. */
|
|
9
|
+
export declare function isRedundantReactionAckText(text: string): boolean;
|
|
10
|
+
/** Check if the user asked for a reaction without also asking for text. */
|
|
11
|
+
export declare function isReactionOnlyIntent(text: string): boolean;
|
|
12
|
+
/** Determine how a reply should be delivered (thread vs channel, file handling). */
|
|
13
|
+
export declare function buildReplyDeliveryPlan(args: {
|
|
14
|
+
explicitChannelPostIntent: boolean;
|
|
15
|
+
channelPostPerformed: boolean;
|
|
16
|
+
hasFiles: boolean;
|
|
17
|
+
}): ReplyDeliveryPlan;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum SubscribedReplyReason {
|
|
3
|
+
ThreadOptOut = "thread_opt_out",
|
|
4
|
+
ExplicitMention = "explicit_mention",
|
|
5
|
+
DirectedFollowUp = "directed_follow_up",
|
|
6
|
+
DirectedToOtherParty = "directed_to_other_party",
|
|
7
|
+
EmptyMessage = "empty_message",
|
|
8
|
+
Classifier = "llm_classifier",
|
|
9
|
+
SideConversation = "side_conversation",
|
|
10
|
+
LowConfidence = "low_confidence",
|
|
11
|
+
ClassifierError = "classifier_error"
|
|
12
|
+
}
|
|
13
|
+
export interface SubscribedDecisionInput {
|
|
14
|
+
rawText: string;
|
|
15
|
+
text: string;
|
|
16
|
+
conversationContext?: string;
|
|
17
|
+
hasAttachments?: boolean;
|
|
18
|
+
isExplicitMention?: boolean;
|
|
19
|
+
context: {
|
|
20
|
+
threadId?: string;
|
|
21
|
+
requesterId?: string;
|
|
22
|
+
channelId?: string;
|
|
23
|
+
runId?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface SubscribedDecisionResult {
|
|
27
|
+
shouldReply: boolean;
|
|
28
|
+
shouldUnsubscribe?: boolean;
|
|
29
|
+
reason: SubscribedReplyReason;
|
|
30
|
+
reasonDetail?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const replyDecisionSchema: z.ZodObject<{
|
|
33
|
+
should_reply: z.ZodBoolean;
|
|
34
|
+
should_unsubscribe: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
confidence: z.ZodNumber;
|
|
36
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
/** Fast heuristic check before the LLM classifier — skips messages directed at another party. */
|
|
39
|
+
export declare function getSubscribedReplyPreflightDecision(args: {
|
|
40
|
+
botUserName: string;
|
|
41
|
+
rawText: string;
|
|
42
|
+
text: string;
|
|
43
|
+
isExplicitMention?: boolean;
|
|
44
|
+
}): SubscribedDecisionResult | undefined;
|
|
45
|
+
/** Decide whether to reply to a message in a subscribed thread using an LLM classifier. */
|
|
46
|
+
export declare function decideSubscribedThreadReply(args: {
|
|
47
|
+
botUserName: string;
|
|
48
|
+
modelId: string;
|
|
49
|
+
input: SubscribedDecisionInput;
|
|
50
|
+
completeObject: (args: {
|
|
51
|
+
modelId: string;
|
|
52
|
+
schema: typeof replyDecisionSchema;
|
|
53
|
+
maxTokens: number;
|
|
54
|
+
temperature: number;
|
|
55
|
+
system: string;
|
|
56
|
+
prompt: string;
|
|
57
|
+
metadata: Record<string, string>;
|
|
58
|
+
}) => Promise<{
|
|
59
|
+
object: unknown;
|
|
60
|
+
}>;
|
|
61
|
+
logClassifierFailure: (error: unknown, input: SubscribedDecisionInput) => void;
|
|
62
|
+
}): Promise<SubscribedDecisionResult>;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { completeObject } from "@/chat/pi/client";
|
|
2
|
+
export interface SubscribedReplyPolicyDeps {
|
|
3
|
+
completeObject: typeof completeObject;
|
|
4
|
+
}
|
|
5
|
+
export interface SubscribedReplyDecision {
|
|
6
|
+
reason: string;
|
|
7
|
+
shouldReply: boolean;
|
|
8
|
+
shouldUnsubscribe?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type SubscribedReplyPolicy = (args: {
|
|
11
|
+
rawText: string;
|
|
12
|
+
text: string;
|
|
13
|
+
conversationContext?: string;
|
|
14
|
+
hasAttachments?: boolean;
|
|
15
|
+
isExplicitMention?: boolean;
|
|
16
|
+
context: {
|
|
17
|
+
threadId?: string;
|
|
18
|
+
requesterId?: string;
|
|
19
|
+
channelId?: string;
|
|
20
|
+
runId?: string;
|
|
21
|
+
};
|
|
22
|
+
}) => Promise<SubscribedReplyDecision>;
|
|
23
|
+
export declare function createSubscribedReplyPolicy(deps: SubscribedReplyPolicyDeps): SubscribedReplyPolicy;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TurnContinuationRequest {
|
|
2
|
+
conversationId: string;
|
|
3
|
+
expectedCheckpointVersion: number;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export type TurnTimeoutResumeRequest = TurnContinuationRequest;
|
|
7
|
+
/** Bound automatic timeout continuation so one bad turn cannot loop forever. */
|
|
8
|
+
export declare function canScheduleTurnTimeoutResume(nextSliceId: number | undefined): boolean;
|
|
9
|
+
/** Build the callback request for an awaiting automatic turn continuation. */
|
|
10
|
+
export declare function getAwaitingTurnContinuationRequest(args: {
|
|
11
|
+
conversationId: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
}): Promise<TurnContinuationRequest | undefined>;
|
|
14
|
+
/** Schedule an authenticated internal callback to resume a timed-out turn. */
|
|
15
|
+
export declare function scheduleTurnTimeoutResume(request: TurnContinuationRequest): Promise<void>;
|
|
16
|
+
/** Verify and parse an authenticated timeout resume callback request. */
|
|
17
|
+
export declare function verifyTurnTimeoutResumeRequest(request: Request): Promise<TurnContinuationRequest | undefined>;
|