@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,4 @@
|
|
|
1
|
+
/** Copy app directory and plugin manifests into the server output. */
|
|
2
|
+
export declare function copyAppAndPluginContent(cwd: string, serverRoot: string, packageNames?: unknown): void;
|
|
3
|
+
/** Copy extra file patterns into server output for files the bundler cannot trace. */
|
|
4
|
+
export declare function copyIncludedFiles(cwd: string, serverRoot: string, patterns?: unknown): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Nitro } from "nitro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Override rolldown's treeshake config so that module side effects survive
|
|
4
|
+
* bundling.
|
|
5
|
+
*
|
|
6
|
+
* pi-ai registers API providers via a top-level side-effect in
|
|
7
|
+
* register-builtins.js. Nitro's default moduleSideEffects whitelist only
|
|
8
|
+
* includes unenv polyfills, so rolldown tree-shakes the registration call
|
|
9
|
+
* and the apiProviderRegistry Map stays empty at runtime.
|
|
10
|
+
*
|
|
11
|
+
* TODO(upstream): Track https://github.com/nitrojs/nitro/issues/XXXX for
|
|
12
|
+
* native moduleSideEffects configuration support.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyRolldownTreeshakeWorkaround(nitro: Nitro): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Nitro } from "nitro/types";
|
|
2
|
+
import type { PluginConfig } from "@/chat/plugins/types";
|
|
3
|
+
/** Inject a virtual module so createApp() can read the plugin list at runtime. */
|
|
4
|
+
export declare function injectVirtualConfig(nitro: Nitro, plugins?: PluginConfig): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SlackAdapter } from "@chat-adapter/slack";
|
|
2
|
+
import { type AssistantLifecycleEvent, type SlackTurnRuntime } from "@/chat/runtime/slack-runtime";
|
|
3
|
+
import type { JuniorRuntimeServiceOverrides } from "@/chat/app/services";
|
|
4
|
+
import { type PreparedTurnState } from "@/chat/runtime/turn-preparation";
|
|
5
|
+
export interface CreateSlackRuntimeOptions {
|
|
6
|
+
getSlackAdapter: () => SlackAdapter;
|
|
7
|
+
now?: () => number;
|
|
8
|
+
services?: JuniorRuntimeServiceOverrides;
|
|
9
|
+
}
|
|
10
|
+
export declare function createSlackRuntime(options: CreateSlackRuntimeOptions): SlackTurnRuntime<PreparedTurnState, AssistantLifecycleEvent>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ConversationMemoryDeps, type ConversationMemoryService } from "@/chat/services/conversation-memory";
|
|
2
|
+
import { type SubscribedReplyPolicy, type SubscribedReplyPolicyDeps } from "@/chat/services/subscribed-reply-policy";
|
|
3
|
+
import type { ReplyExecutorServices } from "@/chat/runtime/reply-executor";
|
|
4
|
+
import { type VisionContextDeps, type VisionContextService } from "@/chat/services/vision-context";
|
|
5
|
+
export interface JuniorRuntimeServices {
|
|
6
|
+
conversationMemory: ConversationMemoryService;
|
|
7
|
+
replyExecutor: ReplyExecutorServices;
|
|
8
|
+
subscribedReplyPolicy: SubscribedReplyPolicy;
|
|
9
|
+
visionContext: VisionContextService;
|
|
10
|
+
}
|
|
11
|
+
export interface JuniorRuntimeServiceOverrides {
|
|
12
|
+
conversationMemory?: Partial<ConversationMemoryDeps>;
|
|
13
|
+
replyExecutor?: Partial<Omit<ReplyExecutorServices, "generateThreadTitle">>;
|
|
14
|
+
subscribedReplyPolicy?: Partial<SubscribedReplyPolicyDeps>;
|
|
15
|
+
visionContext?: Partial<VisionContextDeps>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createJuniorRuntimeServices(overrides?: JuniorRuntimeServiceOverrides): JuniorRuntimeServices;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface CapabilityProviderTargetDefinition {
|
|
2
|
+
type: string;
|
|
3
|
+
configKey: string;
|
|
4
|
+
commandFlags?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface CapabilityProviderDefinition {
|
|
7
|
+
provider: string;
|
|
8
|
+
capabilities: string[];
|
|
9
|
+
configKeys: string[];
|
|
10
|
+
target?: CapabilityProviderTargetDefinition;
|
|
11
|
+
}
|
|
12
|
+
export declare function getCapabilityProvider(capability: string): CapabilityProviderDefinition | undefined;
|
|
13
|
+
export declare function isKnownCapability(capability: string): boolean;
|
|
14
|
+
export declare function listCapabilityProviders(): CapabilityProviderDefinition[];
|
|
15
|
+
/** Log the capability catalog contents once at startup. */
|
|
16
|
+
export declare function logCapabilityCatalogLoadedOnce(): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CredentialLease } from "@/chat/credentials/broker";
|
|
2
|
+
import type { UserTokenStore } from "@/chat/credentials/user-token-store";
|
|
3
|
+
/** Create the user token store used by OAuth-backed credential brokers. */
|
|
4
|
+
export declare function createUserTokenStore(): UserTokenStore;
|
|
5
|
+
/** Issue one provider credential lease for host-side sandbox egress proxying. */
|
|
6
|
+
export declare function issueProviderCredentialLease(input: {
|
|
7
|
+
provider: string;
|
|
8
|
+
requesterId: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
}): Promise<CredentialLease>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
2
|
+
import type { Skill } from "@/chat/skills";
|
|
3
|
+
type JrRpcDeps = {
|
|
4
|
+
activeSkill: Skill | null;
|
|
5
|
+
channelConfiguration?: ChannelConfigurationService;
|
|
6
|
+
requesterId?: string;
|
|
7
|
+
onConfigurationValueChanged?: (key: string, value: unknown | undefined) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function maybeExecuteJrRpcCustomCommand(command: string, deps: JrRpcDeps): Promise<{
|
|
10
|
+
handled: false;
|
|
11
|
+
} | {
|
|
12
|
+
handled: true;
|
|
13
|
+
result: {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
command: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
exit_code: number;
|
|
18
|
+
signal: null;
|
|
19
|
+
timed_out: boolean;
|
|
20
|
+
stdout: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
stdout_truncated: boolean;
|
|
23
|
+
stderr_truncated: boolean;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CredentialBroker, CredentialLease } from "@/chat/credentials/broker";
|
|
2
|
+
export interface CredentialRouter {
|
|
3
|
+
issue(input: {
|
|
4
|
+
provider: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
requesterId?: string;
|
|
7
|
+
}): Promise<CredentialLease>;
|
|
8
|
+
}
|
|
9
|
+
export declare class ProviderCredentialRouter implements CredentialRouter {
|
|
10
|
+
private readonly brokersByProvider;
|
|
11
|
+
constructor(input: {
|
|
12
|
+
brokersByProvider: Record<string, CredentialBroker>;
|
|
13
|
+
});
|
|
14
|
+
issue(input: {
|
|
15
|
+
provider: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
requesterId?: string;
|
|
18
|
+
}): Promise<CredentialLease>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Narrow an unknown value to a non-empty string, or undefined. */
|
|
2
|
+
export declare function toOptionalString(value: unknown): string | undefined;
|
|
3
|
+
/** Narrow an unknown value to a finite number, or undefined. */
|
|
4
|
+
export declare function toOptionalNumber(value: unknown): number | undefined;
|
|
5
|
+
/** Type-guard: true when value is a non-null object (usable as Record). */
|
|
6
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare const ADVISOR_THINKING_LEVELS: readonly ["minimal", "low", "medium", "high", "xhigh"];
|
|
2
|
+
export type AdvisorThinkingLevel = (typeof ADVISOR_THINKING_LEVELS)[number];
|
|
3
|
+
export interface BotConfig {
|
|
4
|
+
advisor: AdvisorConfig;
|
|
5
|
+
fastModelId: string;
|
|
6
|
+
loadingMessages: string[];
|
|
7
|
+
modelId: string;
|
|
8
|
+
visionModelId?: string;
|
|
9
|
+
turnTimeoutMs: number;
|
|
10
|
+
userName: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AdvisorConfig {
|
|
13
|
+
modelId: string;
|
|
14
|
+
thinkingLevel: AdvisorThinkingLevel;
|
|
15
|
+
}
|
|
16
|
+
export interface ChatConfig {
|
|
17
|
+
bot: BotConfig;
|
|
18
|
+
functionMaxDurationSeconds: number;
|
|
19
|
+
slack: {
|
|
20
|
+
botToken?: string;
|
|
21
|
+
clientId?: string;
|
|
22
|
+
clientSecret?: string;
|
|
23
|
+
signingSecret?: string;
|
|
24
|
+
};
|
|
25
|
+
state: {
|
|
26
|
+
adapter: "memory" | "redis";
|
|
27
|
+
redisUrl?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Parse all chat configuration from environment variables. */
|
|
31
|
+
export declare function readChatConfig(env?: NodeJS.ProcessEnv): ChatConfig;
|
|
32
|
+
/** Return the chat configuration (parsed once at startup). */
|
|
33
|
+
export declare function getChatConfig(): ChatConfig;
|
|
34
|
+
/** Bot configuration derived from environment at module load. */
|
|
35
|
+
export declare const botConfig: BotConfig;
|
|
36
|
+
export declare function getSlackBotToken(): string | undefined;
|
|
37
|
+
export declare function getSlackSigningSecret(): string | undefined;
|
|
38
|
+
export declare function getSlackClientId(): string | undefined;
|
|
39
|
+
export declare function getSlackClientSecret(): string | undefined;
|
|
40
|
+
export declare function hasRedisConfig(): boolean;
|
|
41
|
+
export interface RuntimeMetadata {
|
|
42
|
+
version?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Return runtime metadata (version from deploy environment). */
|
|
45
|
+
export declare function getRuntimeMetadata(): RuntimeMetadata;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Store install-wide config defaults; keys must be registered plugin config keys. */
|
|
2
|
+
export declare function setConfigDefaults(defaults: Record<string, unknown> | undefined): void;
|
|
3
|
+
/** Return the install-wide configuration defaults (empty object when none set). */
|
|
4
|
+
export declare function getConfigDefaults(): Record<string, unknown>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type ConfigScope = "conversation";
|
|
2
|
+
export interface ConfigEntry {
|
|
3
|
+
key: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
scope: ConfigScope;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
updatedBy?: string;
|
|
8
|
+
source?: string;
|
|
9
|
+
expiresAt?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ChannelConfigState {
|
|
12
|
+
schemaVersion: 1;
|
|
13
|
+
entries: Record<string, ConfigEntry>;
|
|
14
|
+
}
|
|
15
|
+
export interface ChannelConfigurationStorage {
|
|
16
|
+
load: () => Promise<unknown | null>;
|
|
17
|
+
save: (state: ChannelConfigState) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface ChannelConfigurationService {
|
|
20
|
+
get: (key: string) => Promise<ConfigEntry | undefined>;
|
|
21
|
+
set: (input: {
|
|
22
|
+
key: string;
|
|
23
|
+
value: unknown;
|
|
24
|
+
updatedBy?: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
expiresAt?: string;
|
|
27
|
+
}) => Promise<ConfigEntry>;
|
|
28
|
+
unset: (key: string) => Promise<boolean>;
|
|
29
|
+
list: (options?: {
|
|
30
|
+
prefix?: string;
|
|
31
|
+
}) => Promise<ConfigEntry[]>;
|
|
32
|
+
resolve: (key: string) => Promise<unknown | undefined>;
|
|
33
|
+
resolveValues: (options?: {
|
|
34
|
+
keys?: string[];
|
|
35
|
+
prefix?: string;
|
|
36
|
+
}) => Promise<Record<string, unknown>>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class CredentialUnavailableError extends Error {
|
|
2
|
+
readonly provider: string;
|
|
3
|
+
constructor(provider: string, message: string);
|
|
4
|
+
}
|
|
5
|
+
export type CredentialHeaderTransform = {
|
|
6
|
+
domain: string;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export interface CredentialLease {
|
|
10
|
+
id: string;
|
|
11
|
+
provider: string;
|
|
12
|
+
env: Record<string, string>;
|
|
13
|
+
headerTransforms?: CredentialHeaderTransform[];
|
|
14
|
+
expiresAt: string;
|
|
15
|
+
metadata?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export interface CredentialBroker {
|
|
18
|
+
issue(input: {
|
|
19
|
+
reason: string;
|
|
20
|
+
requesterId?: string;
|
|
21
|
+
}): Promise<CredentialLease>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CredentialHeaderTransform } from "@/chat/credentials/broker";
|
|
2
|
+
/** Merge transforms by domain so later transforms override earlier headers. */
|
|
3
|
+
export declare function mergeHeaderTransforms(transforms: CredentialHeaderTransform[]): CredentialHeaderTransform[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Normalize OAuth scope strings so persisted grants can be compared reliably. */
|
|
2
|
+
export declare function normalizeOAuthScope(scope?: string): string | undefined;
|
|
3
|
+
/** Return whether the stored grant still satisfies the provider's current scope contract. */
|
|
4
|
+
export declare function hasRequiredOAuthScope(storedScope?: string, requiredScope?: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StateAdapter } from "chat";
|
|
2
|
+
import type { StoredTokens, UserTokenStore } from "@/chat/credentials/user-token-store";
|
|
3
|
+
export declare class StateAdapterTokenStore implements UserTokenStore {
|
|
4
|
+
private readonly state;
|
|
5
|
+
constructor(stateAdapter: StateAdapter);
|
|
6
|
+
get(userId: string, provider: string): Promise<StoredTokens | undefined>;
|
|
7
|
+
set(userId: string, provider: string, tokens: StoredTokens): Promise<void>;
|
|
8
|
+
delete(userId: string, provider: string): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CredentialBroker, CredentialHeaderTransform, CredentialLease } from "@/chat/credentials/broker";
|
|
2
|
+
interface TestBrokerConfig {
|
|
3
|
+
provider: string;
|
|
4
|
+
domains?: string[];
|
|
5
|
+
apiHeaders?: Record<string, string>;
|
|
6
|
+
headerTransforms?: () => CredentialHeaderTransform[];
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
envKey?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Issue deterministic placeholder credential leases for eval runs. */
|
|
12
|
+
export declare class TestCredentialBroker implements CredentialBroker {
|
|
13
|
+
private readonly config;
|
|
14
|
+
constructor(config: TestBrokerConfig);
|
|
15
|
+
issue(input: {
|
|
16
|
+
reason: string;
|
|
17
|
+
}): Promise<CredentialLease>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface StoredTokens {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
refreshToken: string;
|
|
4
|
+
expiresAt?: number;
|
|
5
|
+
scope?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UserTokenStore {
|
|
8
|
+
get(userId: string, provider: string): Promise<StoredTokens | undefined>;
|
|
9
|
+
set(userId: string, provider: string, tokens: StoredTokens): Promise<void>;
|
|
10
|
+
delete(userId: string, provider: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Check whether a path exists and is a directory. */
|
|
2
|
+
export declare function isDirectory(targetPath: string): boolean;
|
|
3
|
+
/** Check whether a path exists and is a regular file. */
|
|
4
|
+
export declare function isFile(targetPath: string): boolean;
|
|
5
|
+
export interface DiscoverNodeModulesDirsOptions {
|
|
6
|
+
candidateDirs?: string[];
|
|
7
|
+
}
|
|
8
|
+
/** Discover node_modules directories reachable from the current working directory. */
|
|
9
|
+
export declare function discoverNodeModulesDirs(cwd?: string, options?: DiscoverNodeModulesDirsOptions): string[];
|
|
10
|
+
export interface DiscoverProjectRootsOptions {
|
|
11
|
+
nodeModulesDirs?: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Discover project root directories by walking up from cwd and checking node_modules parents. */
|
|
14
|
+
export declare function discoverProjectRoots(cwd?: string, options?: DiscoverProjectRootsOptions): string[];
|
|
15
|
+
/** Return the resolved app home directory for the current working directory. */
|
|
16
|
+
export declare function homeDir(): string;
|
|
17
|
+
export interface ResolveHomeDirOptions {
|
|
18
|
+
projectRoots?: string[];
|
|
19
|
+
}
|
|
20
|
+
/** Resolve the app home directory by scoring candidate `app/` directories. */
|
|
21
|
+
export declare function resolveHomeDir(cwd?: string, options?: ResolveHomeDirOptions): string;
|
|
22
|
+
/** Return the data directory (same as homeDir). */
|
|
23
|
+
export declare function dataDir(): string;
|
|
24
|
+
/** Return the path to the SOUL.md file. */
|
|
25
|
+
export declare function soulPath(): string;
|
|
26
|
+
/** Return the path to the WORLD.md file. */
|
|
27
|
+
export declare function worldPath(): string;
|
|
28
|
+
/** Return the path to the DESCRIPTION.md file. */
|
|
29
|
+
export declare function descriptionPath(): string;
|
|
30
|
+
/** Return the skills directory path. */
|
|
31
|
+
export declare function skillsDir(): string;
|
|
32
|
+
/** Return the plugins directory path. */
|
|
33
|
+
export declare function pluginsDir(): string;
|
|
34
|
+
/** Return all unique data root directories. */
|
|
35
|
+
export declare function dataRoots(): string[];
|
|
36
|
+
/** Return all unique skill root directories. */
|
|
37
|
+
export declare function skillRoots(): string[];
|
|
38
|
+
/** Return all unique plugin root directories. */
|
|
39
|
+
export declare function pluginRoots(): string[];
|
|
40
|
+
/** Return candidate paths where SOUL.md might be found. */
|
|
41
|
+
export declare function soulPathCandidates(): string[];
|
|
42
|
+
/** Return candidate paths where WORLD.md might be found. */
|
|
43
|
+
export declare function worldPathCandidates(): string[];
|
|
44
|
+
/** Return candidate paths where DESCRIPTION.md might be found. */
|
|
45
|
+
export declare function descriptionPathCandidates(): string[];
|
|
46
|
+
/** List non-reserved .md files in the app root for sandbox reference syncing. */
|
|
47
|
+
export declare function listReferenceFiles(): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Chat, type ActionEvent, type Adapter, type AppHomeOpenedEvent, type AssistantContextChangedEvent, type AssistantThreadStartedEvent, type Message, type ModalCloseEvent, type ReactionEvent, type SlashCommandEvent, type WebhookOptions } from "chat";
|
|
2
|
+
export declare class JuniorChat<TAdapters extends Record<string, Adapter> = Record<string, Adapter>> extends Chat<TAdapters> {
|
|
3
|
+
/**
|
|
4
|
+
* Normalize Slack thread IDs before the SDK's concurrency queue.
|
|
5
|
+
*
|
|
6
|
+
* Slack DM roots can arrive with an empty thread timestamp, while
|
|
7
|
+
* later replies include the root timestamp. Resolve factories before
|
|
8
|
+
* delegating so the lock/state/subscription key is canonicalized before
|
|
9
|
+
* the SDK computes its per-thread queue key.
|
|
10
|
+
*/
|
|
11
|
+
processMessage(adapter: Adapter, threadId: string, messageOrFactory: Message | (() => Promise<Message>), options?: WebhookOptions): Promise<void>;
|
|
12
|
+
processReaction(event: Omit<ReactionEvent, "adapter" | "thread"> & {
|
|
13
|
+
adapter?: Adapter;
|
|
14
|
+
}, options?: WebhookOptions): void;
|
|
15
|
+
processAction(event: Omit<ActionEvent, "thread" | "openModal"> & {
|
|
16
|
+
adapter: Adapter;
|
|
17
|
+
}, options: WebhookOptions | undefined): Promise<void>;
|
|
18
|
+
processModalClose(event: Omit<ModalCloseEvent, "relatedThread" | "relatedMessage" | "relatedChannel">, contextId?: string, options?: WebhookOptions): void;
|
|
19
|
+
processSlashCommand(event: Omit<SlashCommandEvent, "channel" | "openModal"> & {
|
|
20
|
+
adapter: Adapter;
|
|
21
|
+
channelId: string;
|
|
22
|
+
}, options: WebhookOptions | undefined): void;
|
|
23
|
+
processAssistantThreadStarted(event: AssistantThreadStartedEvent, options?: WebhookOptions): void;
|
|
24
|
+
processAssistantContextChanged(event: AssistantContextChangedEvent, options?: WebhookOptions): void;
|
|
25
|
+
processAppHomeOpened(event: AppHomeOpenedEvent, options?: WebhookOptions): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Message, type Adapter } from "chat";
|
|
2
|
+
/**
|
|
3
|
+
* Parsed result from a Slack `message_changed` event that contains a newly
|
|
4
|
+
* added bot @mention. Returns `null` when the event does not qualify.
|
|
5
|
+
*/
|
|
6
|
+
export interface MessageChangedMention {
|
|
7
|
+
/** Slack thread ID in `slack:<channel>:<thread_ts>` format. */
|
|
8
|
+
threadId: string;
|
|
9
|
+
/** Synthesized Message to pass to `bot.processMessage`. */
|
|
10
|
+
message: Message;
|
|
11
|
+
}
|
|
12
|
+
interface SlackMessageChangedEvent {
|
|
13
|
+
type: "event_callback";
|
|
14
|
+
team_id?: string;
|
|
15
|
+
event: {
|
|
16
|
+
type: "message";
|
|
17
|
+
subtype: "message_changed";
|
|
18
|
+
channel: string;
|
|
19
|
+
message: {
|
|
20
|
+
files?: SlackEditedMessageFile[];
|
|
21
|
+
source_team?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
ts: string;
|
|
24
|
+
thread_ts?: string;
|
|
25
|
+
user?: string;
|
|
26
|
+
user_team?: string;
|
|
27
|
+
};
|
|
28
|
+
previous_message: {
|
|
29
|
+
text?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface SlackEditedMessageFile {
|
|
34
|
+
mimetype?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
original_h?: number;
|
|
37
|
+
original_w?: number;
|
|
38
|
+
size?: number;
|
|
39
|
+
url_private?: string;
|
|
40
|
+
url_private_download?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare function isMessageChangedEnvelope(value: unknown): value is SlackMessageChangedEvent;
|
|
43
|
+
/**
|
|
44
|
+
* Inspect a raw parsed Slack webhook body and extract a synthesized mention
|
|
45
|
+
* event when a `message_changed` edit newly adds the bot's @mention.
|
|
46
|
+
*
|
|
47
|
+
* Returns `null` when the payload is not a qualifying `message_changed` event.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractMessageChangedMention(body: unknown, botUserId: string, adapter: Adapter): MessageChangedMention | null;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ThreadMessageKind } from "@/chat/queue/thread-message-dispatcher";
|
|
2
|
+
/** Derive canonical Slack thread IDs from the raw event payload. */
|
|
3
|
+
export declare function normalizeIncomingSlackThreadId(threadId: string, message: unknown): string;
|
|
4
|
+
/** Classify an incoming message as a mention or subscribed message. */
|
|
5
|
+
export declare function determineThreadMessageKind(args: {
|
|
6
|
+
isDirectMessage: boolean;
|
|
7
|
+
isMention: boolean;
|
|
8
|
+
isSubscribed: boolean;
|
|
9
|
+
}): ThreadMessageKind | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Run a callback with the workspace team ID available for membership checks. */
|
|
2
|
+
export declare function runWithWorkspaceTeamId<T>(teamId: string | undefined, fn: () => T): T;
|
|
3
|
+
/**
|
|
4
|
+
* Return true when a Slack event's author is from an external workspace.
|
|
5
|
+
*
|
|
6
|
+
* In Slack Connect shared channels the inner event carries `user_team`
|
|
7
|
+
* (the author's home workspace). When it differs from the outer payload's
|
|
8
|
+
* `team_id` the author is a Slack Connect participant, not a local member.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isExternalSlackUser(raw: Record<string, unknown> | undefined): boolean;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Logger as ChatSdkLogger } from "chat";
|
|
2
|
+
import * as Sentry from "@/chat/sentry";
|
|
3
|
+
import type { AgentTurnUsage } from "@/chat/usage";
|
|
4
|
+
type Primitive = string | number | boolean;
|
|
5
|
+
type AttributeValue = Primitive | string[];
|
|
6
|
+
export type LogAttributes = Record<string, AttributeValue>;
|
|
7
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
8
|
+
export interface EmittedLogRecord {
|
|
9
|
+
attributes: LogAttributes;
|
|
10
|
+
body: string;
|
|
11
|
+
eventName: string;
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
}
|
|
14
|
+
export interface LogContext {
|
|
15
|
+
conversationId?: string;
|
|
16
|
+
platform?: string;
|
|
17
|
+
requestId?: string;
|
|
18
|
+
slackThreadId?: string;
|
|
19
|
+
slackUserId?: string;
|
|
20
|
+
slackUserName?: string;
|
|
21
|
+
slackChannelId?: string;
|
|
22
|
+
runId?: string;
|
|
23
|
+
assistantUserName?: string;
|
|
24
|
+
modelId?: string;
|
|
25
|
+
skillName?: string;
|
|
26
|
+
httpMethod?: string;
|
|
27
|
+
httpPath?: string;
|
|
28
|
+
urlFull?: string;
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const log: {
|
|
32
|
+
debug(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
33
|
+
info(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
34
|
+
warn(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
35
|
+
error(eventName: string, attrs?: Record<string, unknown>, body?: string): void;
|
|
36
|
+
exception(eventName: string, error: unknown, attrs?: Record<string, unknown>, body?: string): string | undefined;
|
|
37
|
+
};
|
|
38
|
+
/** Create a Chat SDK logger that routes records through Junior's logging backend. */
|
|
39
|
+
export declare function createChatSdkLogger(): ChatSdkLogger;
|
|
40
|
+
export declare function withLogContext<T>(context: LogContext, callback: () => Promise<T>): Promise<T>;
|
|
41
|
+
export declare function setLogContext(context: LogContext): void;
|
|
42
|
+
export declare function getLogContextAttributes(): LogAttributes;
|
|
43
|
+
export declare function registerLogRecordSink(sink: (record: EmittedLogRecord) => void): () => void;
|
|
44
|
+
export declare function createLogContextFromRequest(request: Request, context?: Partial<LogContext>): LogContext;
|
|
45
|
+
export declare function toSpanAttributes(context: LogContext): Record<string, string>;
|
|
46
|
+
export declare function setSentryTagsFromContext(context: LogContext): void;
|
|
47
|
+
export declare function setSentryScopeContext(scope: Sentry.Scope, context: LogContext): void;
|
|
48
|
+
/** Capture an error to Sentry and emit an error log record. */
|
|
49
|
+
export declare function captureException(error: unknown, context?: LogContext): void;
|
|
50
|
+
/** Log an info-level structured event. */
|
|
51
|
+
export declare function logInfo(eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): void;
|
|
52
|
+
/** Log a warning-level structured event. */
|
|
53
|
+
export declare function logWarn(eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): void;
|
|
54
|
+
/** Log an error-level structured event. */
|
|
55
|
+
export declare function logError(eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): void;
|
|
56
|
+
/** Log an error with exception capture; returns the Sentry event ID if available. */
|
|
57
|
+
export declare function logException(error: unknown, eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): string | undefined;
|
|
58
|
+
/** Set log context and Sentry tags for the current scope. */
|
|
59
|
+
export declare function setTags(context?: LogContext): void;
|
|
60
|
+
/** Create a LogContext from an incoming HTTP request. */
|
|
61
|
+
export declare function createRequestContext(request: Request, context?: Partial<LogContext>): LogContext;
|
|
62
|
+
/** Run a callback within a scoped log context. */
|
|
63
|
+
export declare function withContext<T>(context: LogContext, callback: () => Promise<T>): Promise<T>;
|
|
64
|
+
/** Run a callback within a Sentry span and scoped log context. */
|
|
65
|
+
export declare function withSpan<T>(name: string, op: string, context: LogContext, callback: () => Promise<T>, attributes?: Record<string, unknown>): Promise<T>;
|
|
66
|
+
/** Set attributes on the currently active Sentry span. */
|
|
67
|
+
export declare function setSpanAttributes(attributes: Record<string, unknown>): void;
|
|
68
|
+
/** Set the status of the currently active Sentry span. */
|
|
69
|
+
export declare function setSpanStatus(status: "ok" | "error"): void;
|
|
70
|
+
/** Capture an exception within an isolated Sentry scope. */
|
|
71
|
+
export declare function captureExceptionInScope(error: unknown, context?: LogContext): void;
|
|
72
|
+
/** Return the trace ID from the active Sentry span, if any. */
|
|
73
|
+
export declare function getActiveTraceId(): string | undefined;
|
|
74
|
+
/** Build the static user-facing response for a failed turn. */
|
|
75
|
+
export declare function buildTurnFailureResponse(eventId: string): string;
|
|
76
|
+
/** Serialize an AI model response value into a truncated log attribute. */
|
|
77
|
+
export declare function serializeGenAiAttribute(value: unknown, maxChars?: number): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Sum pi-ai `Usage` counters across every source into an `AgentTurnUsage`.
|
|
80
|
+
*
|
|
81
|
+
* Callers pass every assistant message produced during a turn so the result
|
|
82
|
+
* reflects the aggregate usage for the entire turn rather than a single model
|
|
83
|
+
* call. Sources without a recognized usage record contribute nothing.
|
|
84
|
+
*/
|
|
85
|
+
export declare function extractGenAiUsageSummary(...sources: unknown[]): AgentTurnUsage;
|
|
86
|
+
/** Extract GenAI token usage attributes from AI provider usage metadata for tracing. */
|
|
87
|
+
export declare function extractGenAiUsageAttributes(...sources: unknown[]): Partial<Record<"gen_ai.usage.input_tokens" | "gen_ai.usage.output_tokens" | "gen_ai.usage.cache_read.input_tokens" | "gen_ai.usage.cache_creation.input_tokens", number>>;
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { OAuthClientInformationMixed, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
|
|
2
|
+
import type { OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
3
|
+
import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
4
|
+
export interface McpAuthSessionState {
|
|
5
|
+
authSessionId: string;
|
|
6
|
+
provider: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
conversationId: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
userMessage: string;
|
|
11
|
+
channelId?: string;
|
|
12
|
+
threadTs?: string;
|
|
13
|
+
toolChannelId?: string;
|
|
14
|
+
configuration?: Record<string, unknown>;
|
|
15
|
+
artifactState?: ThreadArtifactsState;
|
|
16
|
+
authorizationUrl?: string;
|
|
17
|
+
codeVerifier?: string;
|
|
18
|
+
createdAtMs: number;
|
|
19
|
+
updatedAtMs: number;
|
|
20
|
+
}
|
|
21
|
+
export interface McpStoredOAuthCredentials {
|
|
22
|
+
clientInformation?: OAuthClientInformationMixed;
|
|
23
|
+
discoveryState?: OAuthDiscoveryState;
|
|
24
|
+
tokens?: OAuthTokens;
|
|
25
|
+
}
|
|
26
|
+
export interface McpServerSessionState {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
updatedAtMs: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function getMcpAuthSession(authSessionId: string): Promise<McpAuthSessionState | undefined>;
|
|
31
|
+
export declare function putMcpAuthSession(session: McpAuthSessionState, ttlMs?: number): Promise<void>;
|
|
32
|
+
export declare function patchMcpAuthSession(authSessionId: string, patch: Partial<McpAuthSessionState>): Promise<McpAuthSessionState>;
|
|
33
|
+
export declare function deleteMcpAuthSession(authSessionId: string): Promise<void>;
|
|
34
|
+
export declare function deleteMcpAuthSessionsForUserProvider(userId: string, provider: string): Promise<void>;
|
|
35
|
+
export declare function getLatestMcpAuthSessionForUserProvider(userId: string, provider: string): Promise<McpAuthSessionState | undefined>;
|
|
36
|
+
export declare function getMcpStoredOAuthCredentials(userId: string, provider: string): Promise<McpStoredOAuthCredentials | undefined>;
|
|
37
|
+
export declare function putMcpStoredOAuthCredentials(userId: string, provider: string, value: McpStoredOAuthCredentials, ttlMs?: number): Promise<void>;
|
|
38
|
+
export declare function deleteMcpStoredOAuthCredentials(userId: string, provider: string): Promise<void>;
|
|
39
|
+
export declare function getMcpServerSessionId(userId: string, provider: string): Promise<string | undefined>;
|
|
40
|
+
export declare function putMcpServerSessionId(userId: string, provider: string, sessionId: string, ttlMs?: number): Promise<void>;
|
|
41
|
+
export declare function deleteMcpServerSessionId(userId: string, provider: string): Promise<void>;
|