@sentry/junior 0.88.0 → 0.90.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 +16 -5
- package/dist/{agent-hooks-RIJ5TSWP.js → agent-hooks-MXAF7RQL.js} +10 -10
- package/dist/api/people/list.js +8 -8
- package/dist/api/people/profile.js +8 -8
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +716 -732
- package/dist/{catalog-runtime-MW7XERSU.js → catalog-runtime-DXE6NXHT.js} +5 -5
- package/dist/chat/agent/index.d.ts +4 -0
- package/dist/chat/agent/prompt.d.ts +78 -0
- package/dist/chat/{respond.d.ts → agent/request.d.ts} +98 -55
- package/dist/chat/agent/resume.d.ts +65 -0
- package/dist/chat/agent/sandbox.d.ts +15 -0
- package/dist/chat/agent/session.d.ts +20 -0
- package/dist/chat/agent/skills.d.ts +26 -0
- package/dist/chat/agent/tools.d.ts +78 -0
- package/dist/chat/agent-dispatch/runner.d.ts +3 -5
- package/dist/chat/app/production.d.ts +3 -1
- package/dist/chat/app/services.d.ts +1 -4
- package/dist/chat/logging.d.ts +2 -0
- package/dist/chat/mcp/tool-manager.d.ts +1 -6
- package/dist/chat/pi/messages.d.ts +18 -2
- package/dist/chat/pi/transcript.d.ts +31 -0
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/prompt.d.ts +1 -1
- package/dist/chat/runtime/agent-continue-runner.d.ts +5 -5
- package/dist/chat/runtime/agent-run-outcome.d.ts +21 -0
- package/dist/chat/runtime/agent-runner.d.ts +11 -0
- package/dist/chat/runtime/delivered-turn-state.d.ts +2 -2
- package/dist/chat/runtime/generated-artifacts.d.ts +16 -0
- package/dist/chat/runtime/reply-executor.d.ts +2 -2
- package/dist/chat/runtime/slack-resume.d.ts +21 -12
- package/dist/chat/runtime/turn.d.ts +5 -39
- package/dist/chat/services/reply-delivery-plan.d.ts +0 -8
- package/dist/chat/services/turn-failure-response.d.ts +4 -4
- package/dist/chat/services/turn-result.d.ts +4 -7
- package/dist/chat/slack/channel.d.ts +9 -5
- package/dist/chat/slack/client.d.ts +3 -1
- package/dist/chat/slack/context.d.ts +17 -5
- package/dist/chat/slack/id-param.d.ts +25 -0
- package/dist/chat/slack/ids.d.ts +18 -4
- package/dist/chat/slack/outbound.d.ts +16 -0
- package/dist/chat/slack/output.d.ts +3 -3
- package/dist/chat/slack/reply.d.ts +4 -7
- package/dist/chat/slack/timestamp-param.d.ts +25 -0
- package/dist/chat/slack/tools/canvas/context.d.ts +18 -0
- package/dist/chat/slack/tools/canvas/create.d.ts +4 -0
- package/dist/chat/slack/tools/canvas/edit.d.ts +3 -0
- package/dist/chat/slack/tools/canvas/read.d.ts +6 -0
- package/dist/chat/slack/tools/canvas/write.d.ts +3 -0
- package/dist/chat/{tools/slack → slack/tools}/channel-access.d.ts +4 -3
- package/dist/chat/{tools → slack/tools}/channel-capabilities.d.ts +2 -0
- package/dist/chat/slack/tools/channel-list-messages.d.ts +3 -0
- package/dist/chat/{tools/slack → slack/tools}/context.d.ts +5 -4
- package/dist/chat/slack/tools/list/add-items.d.ts +3 -0
- package/dist/chat/{tools/slack/lists.d.ts → slack/tools/list/api.d.ts} +2 -1
- package/dist/chat/slack/tools/list/create.d.ts +3 -0
- package/dist/chat/slack/tools/list/get-items.d.ts +3 -0
- package/dist/chat/slack/tools/list/update-item.d.ts +3 -0
- package/dist/chat/slack/tools/message-add-reaction.d.ts +4 -0
- package/dist/chat/slack/tools/send-message.d.ts +11 -0
- package/dist/chat/{tools/slack → slack/tools}/slack-message-url.d.ts +5 -5
- package/dist/chat/slack/tools/thread-read.d.ts +6 -0
- package/dist/chat/slack/tools/user-lookup.d.ts +2 -0
- package/dist/chat/slack/users.d.ts +2 -1
- package/dist/chat/{services → slack}/vision-context.d.ts +4 -2
- package/dist/chat/state/session-log.d.ts +1 -1
- package/dist/chat/tool-exposure.d.ts +10 -0
- package/dist/chat/tool-support/catalog-tool-call.d.ts +10 -0
- package/dist/chat/{tools/execution → tool-support}/normalize-result.d.ts +4 -1
- package/dist/chat/{tools/agent-tools.d.ts → tool-support/pi-tool-adapter.d.ts} +3 -9
- package/dist/chat/tool-support/schema-summary.d.ts +2 -0
- package/dist/chat/{tools → tool-support}/skill/mcp-tool-summary.d.ts +0 -6
- package/dist/chat/tool-support/structured-result.d.ts +73 -0
- package/dist/chat/tool-support/text-range-result.d.ts +58 -0
- package/dist/chat/tool-support/tool-execution-report.d.ts +7 -0
- package/dist/chat/tool-support/zod-tool.d.ts +27 -0
- package/dist/chat/tools/advisor/tool.d.ts +9 -18
- package/dist/chat/tools/definition.d.ts +56 -9
- package/dist/chat/tools/execute-tool.d.ts +3 -0
- package/dist/chat/tools/index.d.ts +3 -2
- package/dist/chat/tools/resource-events.d.ts +3 -13
- package/dist/chat/tools/runtime/report-progress.d.ts +1 -3
- package/dist/chat/tools/sandbox/bash.d.ts +1 -4
- package/dist/chat/tools/sandbox/edit-file.d.ts +25 -7
- package/dist/chat/tools/sandbox/file-uploads.d.ts +30 -0
- package/dist/chat/tools/sandbox/file-utils.d.ts +10 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +12 -11
- package/dist/chat/tools/sandbox/grep.d.ts +18 -12
- package/dist/chat/tools/sandbox/list-dir.d.ts +15 -7
- package/dist/chat/tools/sandbox/read-file.d.ts +2 -31
- package/dist/chat/tools/sandbox/write-file.d.ts +1 -4
- package/dist/chat/tools/search-tools.d.ts +4 -0
- package/dist/chat/tools/skill/call-mcp-tool.d.ts +1 -4
- package/dist/chat/tools/skill/load-skill.d.ts +4 -5
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +1 -5
- package/dist/chat/tools/system-time.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +15 -5
- package/dist/chat/tools/web/fetch-content.d.ts +4 -2
- package/dist/chat/tools/web/fetch-tool.d.ts +4 -4
- package/dist/chat/tools/web/image-generate.d.ts +4 -3
- package/dist/chat/tools/web/search.d.ts +1 -4
- package/dist/{chunk-4IXHIV37.js → chunk-2S7M37HY.js} +6 -8
- package/dist/{chunk-L7OHKDOX.js → chunk-3MPOMK3K.js} +58 -7
- package/dist/{chunk-V6XDCS3X.js → chunk-5GBUZI6M.js} +4 -4
- package/dist/{chunk-7ES37H6U.js → chunk-AN2437E3.js} +4 -4
- package/dist/chunk-AOISHLSF.js +747 -0
- package/dist/{chunk-NYJLQI42.js → chunk-BKSZL4QO.js} +11257 -11957
- package/dist/{chunk-XS6NLQPA.js → chunk-DACFZ5CI.js} +474 -33
- package/dist/chunk-GCWD2VHP.js +1216 -0
- package/dist/chunk-GHGPTPBL.js +53 -0
- package/dist/{chunk-S35CPNPT.js → chunk-HXL2ZV74.js} +40 -216
- package/dist/{chunk-PBV4ZIVM.js → chunk-IRRMABQD.js} +1 -1
- package/dist/{chunk-2DPZRS3B.js → chunk-IX76WFJV.js} +8 -8
- package/dist/{chunk-66NX7MNW.js → chunk-KC42JAAQ.js} +1 -1
- package/dist/chunk-LFLTJQVR.js +90 -0
- package/dist/{chunk-IATAYWFU.js → chunk-NW7AXDA5.js} +2 -2
- package/dist/{chunk-F22AM3OW.js → chunk-NYWPISSO.js} +1 -1
- package/dist/chunk-OB42YVAE.js +16 -0
- package/dist/chunk-ONFOWI2D.js +955 -0
- package/dist/chunk-PHZHJTCK.js +1062 -0
- package/dist/{chunk-6UPQ5GTJ.js → chunk-QCKGI74V.js} +7 -7
- package/dist/{chunk-YPAE5RH3.js → chunk-RS6ANWVT.js} +1 -1
- package/dist/{chunk-C5NCV3OB.js → chunk-TYUXD3FN.js} +1 -1
- package/dist/{chunk-KBFQXJL4.js → chunk-XP7F4LYB.js} +5 -7
- package/dist/{chunk-VMBZFPZM.js → chunk-ZUK7BL63.js} +187 -9
- package/dist/cli/chat.js +55 -40
- package/dist/cli/check.js +6 -6
- package/dist/cli/init.js +30 -36
- package/dist/cli/plugins.js +16 -16
- package/dist/cli/snapshot-warmup.js +9 -9
- package/dist/cli/upgrade.js +21 -21
- package/dist/db-CXI7PR5U.js +18 -0
- package/dist/handlers/agent-dispatch.d.ts +3 -3
- package/dist/handlers/mcp-oauth-callback.d.ts +3 -3
- package/dist/handlers/oauth-callback.d.ts +3 -3
- package/dist/instrumentation.js +6 -5
- package/dist/nitro.js +3 -7
- package/dist/reporting.js +23 -25
- package/dist/{runner-BCRF2FCI.js → runner-FKL3RAHA.js} +89 -77
- package/dist/{validation-FMJO3L5P.js → validation-I7GD2YWS.js} +6 -6
- package/package.json +6 -6
- package/dist/chat/respond-helpers.d.ts +0 -82
- package/dist/chat/services/attachment-claims.d.ts +0 -2
- package/dist/chat/services/channel-intent.d.ts +0 -2
- package/dist/chat/tools/sandbox/attach-file.d.ts +0 -7
- package/dist/chat/tools/slack/canvas-tools.d.ts +0 -30
- package/dist/chat/tools/slack/channel-list-messages.d.ts +0 -9
- package/dist/chat/tools/slack/channel-post-message.d.ts +0 -5
- package/dist/chat/tools/slack/list-tools.d.ts +0 -21
- package/dist/chat/tools/slack/message-add-reaction.d.ts +0 -5
- package/dist/chat/tools/slack/thread-read.d.ts +0 -12
- package/dist/chat/tools/slack/user-lookup.d.ts +0 -8
- package/dist/chunk-AHLSXMOU.js +0 -506
- package/dist/chunk-FTMXFBDC.js +0 -49
- package/dist/chunk-KBSLCOGE.js +0 -2226
- package/dist/chunk-KQKIA4CU.js +0 -186
- package/dist/db-37HOGLI7.js +0 -18
- /package/dist/chat/{tools/slack/canvases.d.ts → slack/tools/canvas/api.d.ts} +0 -0
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export interface ChannelCapabilities {
|
|
3
3
|
/** Can create canvases in this channel (C/G/D channels). */
|
|
4
4
|
canCreateCanvas: boolean;
|
|
5
|
+
/** Can send messages into this conversation scope (C/G/D channels). */
|
|
6
|
+
canSendMessage: boolean;
|
|
5
7
|
/** Can post standalone messages to this channel (C/G channels only). */
|
|
6
8
|
canPostToChannel: boolean;
|
|
7
9
|
/** Can add reactions to messages (C/G/D channels). */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SlackToolContext } from "@/chat/slack/tools/context";
|
|
2
|
+
/** Create the active-channel history tool with preflight timestamp normalization. */
|
|
3
|
+
export declare function createSlackChannelListMessagesTool(context: SlackToolContext): import("../../tools/definition").AnyToolDefinition;
|
|
@@ -2,16 +2,17 @@ import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
|
2
2
|
import type { SlackDestination } from "@sentry/junior-plugin-api";
|
|
3
3
|
import type { SlackSource } from "@sentry/junior-plugin-api";
|
|
4
4
|
import type { SlackRequester } from "@/chat/requester";
|
|
5
|
+
import { type SlackChannelId, type SlackTeamId } from "@/chat/slack/ids";
|
|
5
6
|
import { type SlackMessageTs } from "@/chat/slack/timestamp";
|
|
6
7
|
export interface SlackToolContext {
|
|
7
8
|
destination: SlackDestination;
|
|
8
9
|
source: SlackSource;
|
|
9
10
|
requester?: SlackRequester;
|
|
10
|
-
destinationChannelId:
|
|
11
|
+
destinationChannelId: SlackChannelId;
|
|
11
12
|
messageTs?: SlackMessageTs;
|
|
12
|
-
sourceChannelId:
|
|
13
|
-
teamId:
|
|
14
|
-
threadTs?:
|
|
13
|
+
sourceChannelId: SlackChannelId;
|
|
14
|
+
teamId: SlackTeamId;
|
|
15
|
+
threadTs?: SlackMessageTs;
|
|
15
16
|
}
|
|
16
17
|
/** Resolve Slack-specific tool context from the active source/destination/requester. */
|
|
17
18
|
export declare function getSlackToolContext(context: ToolRuntimeContext): SlackToolContext | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SlackUserId } from "@/chat/slack/ids";
|
|
1
2
|
import type { ListColumnMap } from "@/chat/state/artifacts";
|
|
2
3
|
interface SlackListsSchemaColumnResponse {
|
|
3
4
|
id: string;
|
|
@@ -23,7 +24,7 @@ export declare function addListItems(input: {
|
|
|
23
24
|
listId: string;
|
|
24
25
|
titles: string[];
|
|
25
26
|
listColumnMap?: ListColumnMap;
|
|
26
|
-
assigneeUserId?:
|
|
27
|
+
assigneeUserId?: SlackUserId;
|
|
27
28
|
dueDate?: string;
|
|
28
29
|
}): Promise<{
|
|
29
30
|
createdItemIds: string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SlackToolContext } from "@/chat/slack/tools/context";
|
|
2
|
+
import type { ToolState } from "@/chat/tools/types";
|
|
3
|
+
/** Create the tool that reacts to the current inbound Slack message. */
|
|
4
|
+
export declare function createSlackMessageAddReactionTool(context: SlackToolContext, state: ToolState): import("../../tools/definition").AnyToolDefinition;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SlackToolContext } from "@/chat/slack/tools/context";
|
|
2
|
+
import type { SandboxFileUpload } from "@/chat/tools/sandbox/file-uploads";
|
|
3
|
+
import type { ToolState } from "@/chat/tools/types";
|
|
4
|
+
/** Convert a model-supplied sandbox file path into bytes safe for Slack upload. */
|
|
5
|
+
export type MaterializeMessageFile = (input: {
|
|
6
|
+
path: string;
|
|
7
|
+
filename?: string;
|
|
8
|
+
mimeType?: string;
|
|
9
|
+
}) => Promise<SandboxFileUpload>;
|
|
10
|
+
/** Create the Slack side-effect tool for active-conversation text and file messages. */
|
|
11
|
+
export declare function createSendMessageTool(context: SlackToolContext, state: ToolState, materializeFile: MaterializeMessageFile): import("../../tools/definition").AnyToolDefinition;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/** Parse Slack archive URLs into structured message references. */
|
|
2
|
+
import { type SlackChannelId } from "@/chat/slack/ids";
|
|
3
|
+
import { type SlackMessageTs } from "@/chat/slack/timestamp";
|
|
2
4
|
export interface SlackMessageReference {
|
|
3
|
-
channelId:
|
|
4
|
-
messageTs:
|
|
5
|
-
threadTs?:
|
|
5
|
+
channelId: SlackChannelId;
|
|
6
|
+
messageTs: SlackMessageTs;
|
|
7
|
+
threadTs?: SlackMessageTs;
|
|
6
8
|
}
|
|
7
9
|
type ParseResult = {
|
|
8
10
|
ok: true;
|
|
@@ -11,8 +13,6 @@ type ParseResult = {
|
|
|
11
13
|
ok: false;
|
|
12
14
|
error: string;
|
|
13
15
|
};
|
|
14
|
-
/** Slack message timestamp format: 10 digits, dot, 6 digits. */
|
|
15
|
-
export declare const SLACK_TS_PATTERN: RegExp;
|
|
16
16
|
/** Parse a Slack archive URL (or mrkdwn-wrapped URL) into a message reference. */
|
|
17
17
|
export declare function parseSlackMessageReference(input: string): ParseResult;
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DestinationVisibilityReader } from "@/chat/slack/tools/channel-access";
|
|
2
|
+
import type { SlackToolContext } from "@/chat/slack/tools/context";
|
|
3
|
+
/** Create a tool that reads a Slack thread from a shared message URL or explicit coordinates. */
|
|
4
|
+
export declare function createSlackThreadReadTool(context: SlackToolContext, deps?: {
|
|
5
|
+
visibilityStore?: DestinationVisibilityReader;
|
|
6
|
+
}): import("../../tools/definition").AnyToolDefinition;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SlackUserId } from "@/chat/slack/ids";
|
|
1
2
|
/** Normalized Slack user profile with custom fields from the Slack workspace. */
|
|
2
3
|
export interface SlackUserProfile {
|
|
3
4
|
id: string;
|
|
@@ -20,7 +21,7 @@ export interface SlackUserProfile {
|
|
|
20
21
|
}>;
|
|
21
22
|
}
|
|
22
23
|
/** Look up a Slack user by ID, returning the full profile including custom fields. */
|
|
23
|
-
export declare function lookupSlackUserProfile(userId:
|
|
24
|
+
export declare function lookupSlackUserProfile(userId: SlackUserId): Promise<SlackUserProfile>;
|
|
24
25
|
/** Look up a Slack user by email. Returns null when no user matches. */
|
|
25
26
|
export declare function lookupSlackUserByEmail(email: string): Promise<SlackUserProfile | null>;
|
|
26
27
|
export interface SlackUserSearchResult {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Attachment } from "chat";
|
|
2
2
|
import type { completeText } from "@/chat/pi/client";
|
|
3
3
|
import type { ThreadConversationState } from "@/chat/state/conversation";
|
|
4
|
+
import { type SlackChannelId } from "@/chat/slack/ids";
|
|
5
|
+
import { type SlackMessageTs } from "@/chat/slack/timestamp";
|
|
4
6
|
export interface UserInputAttachment {
|
|
5
7
|
data?: Buffer;
|
|
6
8
|
mediaType: string;
|
|
@@ -25,8 +27,8 @@ export interface VisionContextDeps {
|
|
|
25
27
|
completeText: typeof completeText;
|
|
26
28
|
downloadFile: (url: string) => Promise<Buffer>;
|
|
27
29
|
listThreadReplies: (input: {
|
|
28
|
-
channelId:
|
|
29
|
-
threadTs:
|
|
30
|
+
channelId: SlackChannelId;
|
|
31
|
+
threadTs: SlackMessageTs;
|
|
30
32
|
limit?: number;
|
|
31
33
|
maxPages?: number;
|
|
32
34
|
targetMessageTs?: string[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type
|
|
2
|
+
import { type PiMessage } from "@/chat/pi/messages";
|
|
3
3
|
import { type StoredSlackRequester } from "@/chat/requester";
|
|
4
4
|
declare const authorizationKindSchema: z.ZodUnion<readonly [z.ZodLiteral<"plugin">, z.ZodLiteral<"mcp">]>;
|
|
5
5
|
declare const transcriptRefSchema: z.ZodObject<{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyToolDefinition, ToolExposure } from "@/chat/tools/definition";
|
|
2
|
+
export interface PlannedToolExposure {
|
|
3
|
+
catalogTools: Record<string, AnyToolDefinition>;
|
|
4
|
+
directTools: Record<string, AnyToolDefinition>;
|
|
5
|
+
excludedTools: Record<string, AnyToolDefinition>;
|
|
6
|
+
}
|
|
7
|
+
/** Return the runtime exposure for a tool, preserving direct compatibility. */
|
|
8
|
+
export declare function effectiveToolExposure(definition: AnyToolDefinition): ToolExposure;
|
|
9
|
+
/** Plan which tools are native-visible, catalog-executable, or withheld. */
|
|
10
|
+
export declare function planToolExposure(tools: Record<string, AnyToolDefinition>): PlannedToolExposure;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type AnyToolDefinition } from "@/chat/tools/definition";
|
|
2
|
+
export interface CatalogToolCall {
|
|
3
|
+
arguments: Record<string, unknown>;
|
|
4
|
+
definition: AnyToolDefinition;
|
|
5
|
+
toolName: string;
|
|
6
|
+
}
|
|
7
|
+
/** Resolve and validate a catalog executeTool request at runtime. */
|
|
8
|
+
export declare function resolveCatalogToolCall(input: Record<string, unknown>, catalogTools: Record<string, AnyToolDefinition>): CatalogToolCall;
|
|
9
|
+
/** Apply a catalog tool's own argument preparation and schema boundary. */
|
|
10
|
+
export declare function prepareCatalogToolCall(call: CatalogToolCall): CatalogToolCall;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
2
2
|
/** Unwrap sandbox envelope and detect structured results. */
|
|
3
|
-
export declare function normalizeToolResult(result: unknown, isSandboxResult: boolean
|
|
3
|
+
export declare function normalizeToolResult(result: unknown, isSandboxResult: boolean, options?: {
|
|
4
|
+
requireStructuredResult?: boolean;
|
|
5
|
+
toolName?: string;
|
|
6
|
+
}): {
|
|
4
7
|
content: Array<TextContent | ImageContent>;
|
|
5
8
|
details: unknown;
|
|
6
9
|
};
|
|
@@ -5,14 +5,8 @@ import type { PluginAuthOrchestration } from "@/chat/services/plugin-auth-orches
|
|
|
5
5
|
import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
|
|
6
6
|
import type { SandboxExecutor } from "@/chat/sandbox/sandbox";
|
|
7
7
|
import type { SkillSandbox } from "@/chat/sandbox/skill-sandbox";
|
|
8
|
-
import type {
|
|
8
|
+
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
9
|
+
import type { ToolExecutionReport } from "@/chat/tool-support/tool-execution-report";
|
|
9
10
|
import type { PluginHookRunner } from "@/chat/plugins/agent-hooks";
|
|
10
|
-
export interface ToolExecutionReport {
|
|
11
|
-
error?: string;
|
|
12
|
-
ok: boolean;
|
|
13
|
-
params: Record<string, unknown>;
|
|
14
|
-
result?: unknown;
|
|
15
|
-
toolName: string;
|
|
16
|
-
}
|
|
17
11
|
/** Wrap tool definitions into Pi Agent tool objects with logging, validation, and sandbox execution. */
|
|
18
|
-
export declare function
|
|
12
|
+
export declare function createPiAgentTools(tools: Record<string, AnyToolDefinition>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void | Promise<void>, agentHooks?: PluginHookRunner, conversationPrivacy?: ConversationPrivacy, onToolResult?: (report: ToolExecutionReport) => void | Promise<void>): AgentTool[];
|
|
@@ -19,12 +19,6 @@ export interface ActiveMcpCatalogSummary {
|
|
|
19
19
|
provider: string;
|
|
20
20
|
available_tool_count: number;
|
|
21
21
|
}
|
|
22
|
-
/** Build a stable model-readable MCP tool signature. */
|
|
23
|
-
export declare function formatMcpToolSignature(toolName: string, schema: Record<string, unknown>): string;
|
|
24
|
-
/** Build the exact callMcpTool argument shape agents should use. */
|
|
25
|
-
export declare function formatMcpToolCallExample(toolName: string, schema: Record<string, unknown>): ExposedToolSummary["call"];
|
|
26
|
-
/** Summarize an MCP input schema for quick catalog scanning. */
|
|
27
|
-
export declare function summarizeInputSchema(schema: Record<string, unknown>): string;
|
|
28
22
|
/** Convert a managed MCP tool descriptor into agent-visible search output. */
|
|
29
23
|
export declare function toExposedToolSummary(toolDef: ManagedMcpToolDescriptor): ExposedToolSummary;
|
|
30
24
|
/** Group discovered MCP tools into provider catalogs for prompt disclosure. */
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const juniorToolContinuationSchema: z.ZodObject<{
|
|
4
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const juniorToolBoundContinuationSchema: z.ZodObject<{
|
|
8
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
9
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
10
|
+
tool_name: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const juniorToolErrorSchema: z.ZodObject<{
|
|
13
|
+
kind: z.ZodString;
|
|
14
|
+
message: z.ZodString;
|
|
15
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export declare const juniorToolResultSchema: z.ZodObject<{
|
|
18
|
+
ok: z.ZodBoolean;
|
|
19
|
+
status: z.ZodEnum<{
|
|
20
|
+
error: "error";
|
|
21
|
+
success: "success";
|
|
22
|
+
}>;
|
|
23
|
+
target: z.ZodOptional<z.ZodString>;
|
|
24
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
continuation: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
28
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>>;
|
|
30
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
31
|
+
kind: z.ZodString;
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strict>, z.ZodString]>>;
|
|
35
|
+
}, z.core.$loose>;
|
|
36
|
+
export declare const juniorToolResultWithBoundContinuationSchema: z.ZodObject<{
|
|
37
|
+
ok: z.ZodBoolean;
|
|
38
|
+
status: z.ZodEnum<{
|
|
39
|
+
error: "error";
|
|
40
|
+
success: "success";
|
|
41
|
+
}>;
|
|
42
|
+
target: z.ZodOptional<z.ZodString>;
|
|
43
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
44
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
46
|
+
kind: z.ZodString;
|
|
47
|
+
message: z.ZodString;
|
|
48
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
}, z.core.$strict>, z.ZodString]>>;
|
|
50
|
+
continuation: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
52
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
53
|
+
tool_name: z.ZodString;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
}, z.core.$loose>;
|
|
56
|
+
export type JuniorToolResult = z.output<typeof juniorToolResultSchema>;
|
|
57
|
+
export type JuniorToolResultWithBoundContinuation = z.output<typeof juniorToolResultWithBoundContinuationSchema>;
|
|
58
|
+
export interface JuniorToolResultEnvelope<TDetails extends JuniorToolResult = JuniorToolResult> {
|
|
59
|
+
content: [TextContent, ...(TextContent | ImageContent)[]];
|
|
60
|
+
details: TDetails;
|
|
61
|
+
}
|
|
62
|
+
/** Bind continuation metadata to the exposed runtime tool name. */
|
|
63
|
+
export declare function injectContinuationToolName(details: JuniorToolResult, toolName: string): JuniorToolResult | JuniorToolResultWithBoundContinuation;
|
|
64
|
+
interface JuniorTextToolResultEnvelope<TDetails extends JuniorToolResult = JuniorToolResult> {
|
|
65
|
+
content: [TextContent];
|
|
66
|
+
details: TDetails;
|
|
67
|
+
}
|
|
68
|
+
/** Create the Pi-compatible transport envelope from one structured result object. */
|
|
69
|
+
export declare function makeStructuredToolResult<TDetails extends JuniorToolResult>(details: TDetails): JuniorTextToolResultEnvelope<TDetails>;
|
|
70
|
+
export declare function makeStructuredToolResult<TDetails extends JuniorToolResult>(details: TDetails, options: {
|
|
71
|
+
content: Array<TextContent | ImageContent>;
|
|
72
|
+
}): JuniorToolResultEnvelope<TDetails>;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface TextRangeResult {
|
|
2
|
+
content: [{
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
}];
|
|
6
|
+
details: {
|
|
7
|
+
ok: true;
|
|
8
|
+
status: "success";
|
|
9
|
+
target: string;
|
|
10
|
+
data: {
|
|
11
|
+
content: string;
|
|
12
|
+
end_line?: number;
|
|
13
|
+
path: string;
|
|
14
|
+
start_line: number;
|
|
15
|
+
total_lines: number;
|
|
16
|
+
};
|
|
17
|
+
truncated: boolean;
|
|
18
|
+
continuation?: {
|
|
19
|
+
arguments: {
|
|
20
|
+
offset: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
[key: string]: string | number;
|
|
23
|
+
};
|
|
24
|
+
reason: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface TextRangeMissingPathResult {
|
|
29
|
+
content: [{
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}];
|
|
33
|
+
details: {
|
|
34
|
+
ok: false;
|
|
35
|
+
status: "error";
|
|
36
|
+
target: string;
|
|
37
|
+
data: {
|
|
38
|
+
content: "";
|
|
39
|
+
path: string;
|
|
40
|
+
};
|
|
41
|
+
error: {
|
|
42
|
+
kind: "not_found";
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
truncated: false;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Return a bounded line window so large files can be read incrementally. */
|
|
49
|
+
export declare function sliceFileContent(params: {
|
|
50
|
+
content: string;
|
|
51
|
+
continuationArgumentName?: string;
|
|
52
|
+
limit?: unknown;
|
|
53
|
+
offset?: unknown;
|
|
54
|
+
path: string;
|
|
55
|
+
}): TextRangeResult;
|
|
56
|
+
/** Return a model-visible result for expected missing read targets. */
|
|
57
|
+
export declare function missingFileResult(path: string): TextRangeMissingPathResult;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z, type ZodType, type ZodTypeAny } from "zod";
|
|
2
|
+
import { type JuniorToolResult } from "@/chat/tool-support/structured-result";
|
|
3
|
+
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
4
|
+
import type { AnyToolDefinition, ToolExecuteOptions } from "@/chat/tools/definition";
|
|
5
|
+
type ZodToolDefinitionBase<TInputSchema extends ZodTypeAny> = Pick<AnyToolDefinition, "identity" | "description" | "exposure" | "annotations" | "promptSnippet" | "promptGuidelines" | "executionMode"> & {
|
|
6
|
+
inputSchema: TInputSchema;
|
|
7
|
+
prepareArguments?: (args: unknown) => z.input<TInputSchema>;
|
|
8
|
+
};
|
|
9
|
+
type StructuredToolExecuteResult<TOutputSchema extends ZodType<JuniorToolResult>> = z.input<TOutputSchema>;
|
|
10
|
+
interface ContentOnlyToolResult {
|
|
11
|
+
content: Array<TextContent | ImageContent>;
|
|
12
|
+
details?: never;
|
|
13
|
+
}
|
|
14
|
+
type StructuredZodToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodType<JuniorToolResult>> = ZodToolDefinitionBase<TInputSchema> & {
|
|
15
|
+
outputSchema: TOutputSchema;
|
|
16
|
+
execute?: (input: z.output<TInputSchema>, options: ToolExecuteOptions) => Promise<StructuredToolExecuteResult<TOutputSchema>> | StructuredToolExecuteResult<TOutputSchema>;
|
|
17
|
+
};
|
|
18
|
+
type ContentZodToolDefinition<TInputSchema extends ZodTypeAny> = ZodToolDefinitionBase<TInputSchema> & {
|
|
19
|
+
outputSchema?: undefined;
|
|
20
|
+
execute?: (input: z.output<TInputSchema>, options: ToolExecuteOptions) => Promise<ContentOnlyToolResult> | ContentOnlyToolResult;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Define a Junior-owned tool with Zod input parsing and JSON Schema parameters.
|
|
24
|
+
*/
|
|
25
|
+
export declare function zodTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodType<JuniorToolResult>>(definition: StructuredZodToolDefinition<TInputSchema, TOutputSchema>): AnyToolDefinition;
|
|
26
|
+
export declare function zodTool<TInputSchema extends ZodTypeAny>(definition: ContentZodToolDefinition<TInputSchema>): AnyToolDefinition;
|
|
27
|
+
export {};
|
|
@@ -3,20 +3,14 @@ import type { AdvisorConfig } from "@/chat/config";
|
|
|
3
3
|
import { type ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
4
4
|
import { type LogContext } from "@/chat/logging";
|
|
5
5
|
import { type AdvisorSessionStore } from "@/chat/tools/advisor/session-store";
|
|
6
|
-
import {
|
|
6
|
+
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
7
7
|
export type AdvisorErrorCode = "invalid_context" | "invalid_question" | "missing_conversation_id" | "session_unavailable" | "unavailable";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ok: true;
|
|
15
|
-
} | {
|
|
16
|
-
error_code: AdvisorErrorCode;
|
|
17
|
-
ok: false;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
8
|
+
export type AdvisorToolResult = {
|
|
9
|
+
memo: string;
|
|
10
|
+
ok: boolean;
|
|
11
|
+
status: "error" | "success";
|
|
12
|
+
error_code?: AdvisorErrorCode;
|
|
13
|
+
} & Record<string, unknown>;
|
|
20
14
|
export interface AdvisorToolRuntimeContext {
|
|
21
15
|
config: AdvisorConfig;
|
|
22
16
|
conversationId?: string;
|
|
@@ -28,9 +22,6 @@ export interface AdvisorToolRuntimeContext {
|
|
|
28
22
|
streamFn?: StreamFn;
|
|
29
23
|
}
|
|
30
24
|
/** Build the advisor's read-only tool definition subset. */
|
|
31
|
-
export declare function createAdvisorToolDefinitions(definitions: Record<string,
|
|
25
|
+
export declare function createAdvisorToolDefinitions(definitions: Record<string, AnyToolDefinition>): Record<string, AnyToolDefinition>;
|
|
32
26
|
/** Create the advisor tool backed by conversation-scoped message history. */
|
|
33
|
-
export declare function createAdvisorTool(context: AdvisorToolRuntimeContext):
|
|
34
|
-
question: import("@sinclair/typebox").TString;
|
|
35
|
-
context: import("@sinclair/typebox").TString;
|
|
36
|
-
}>>;
|
|
27
|
+
export declare function createAdvisorTool(context: AdvisorToolRuntimeContext): AnyToolDefinition;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type Static, type TSchema } from "@sinclair/typebox";
|
|
3
3
|
import type { ToolExecutionMode } from "@earendil-works/pi-agent-core";
|
|
4
4
|
import type { ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Tool definition boundary for Pi-facing agent tools.
|
|
7
|
+
*/
|
|
8
|
+
export interface JsonSchemaObject {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export type ToolInputSchema = TSchema | JsonSchemaObject;
|
|
12
|
+
export type ToolExposure = "direct" | "deferred" | "modelOnly" | "hidden";
|
|
13
|
+
export interface ToolExecuteOptions {
|
|
14
|
+
experimental_context?: unknown;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
conversationPrivacy?: ConversationPrivacy;
|
|
17
|
+
toolCallId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface BaseToolDefinition<TInput, TInputSchema extends ToolInputSchema> {
|
|
6
20
|
/** Stable internal owner-qualified identity for plugin-contributed tools. */
|
|
7
21
|
identity?: {
|
|
8
22
|
id: string;
|
|
@@ -10,7 +24,42 @@ export interface ToolDefinition<TInputSchema extends TSchema = TSchema> {
|
|
|
10
24
|
plugin: string;
|
|
11
25
|
};
|
|
12
26
|
description: string;
|
|
27
|
+
exposure?: ToolExposure;
|
|
13
28
|
inputSchema: TInputSchema;
|
|
29
|
+
outputSchema?: ToolInputSchema;
|
|
30
|
+
annotations?: ToolAnnotations;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
33
|
+
* and parameter descriptions. Retained for plugin compatibility; may be
|
|
34
|
+
* removed in a future major version.
|
|
35
|
+
*/
|
|
36
|
+
promptSnippet?: string;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
39
|
+
* and parameter descriptions. Retained for plugin compatibility; may be
|
|
40
|
+
* removed in a future major version.
|
|
41
|
+
*/
|
|
42
|
+
promptGuidelines?: string[];
|
|
43
|
+
prepareArguments?: (args: unknown) => TInput;
|
|
44
|
+
executionMode?: ToolExecutionMode;
|
|
45
|
+
execute?: (input: TInput, options: ToolExecuteOptions) => Promise<unknown> | unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface ToolDefinition<TInputSchema extends TSchema = TSchema> extends BaseToolDefinition<Static<TInputSchema>, TInputSchema> {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Schema-erased view for heterogeneous registries after Pi validates tool input.
|
|
51
|
+
*/
|
|
52
|
+
export interface AnyToolDefinition {
|
|
53
|
+
/** Stable internal owner-qualified identity for plugin-contributed tools. */
|
|
54
|
+
identity?: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
plugin: string;
|
|
58
|
+
};
|
|
59
|
+
description: string;
|
|
60
|
+
exposure?: ToolExposure;
|
|
61
|
+
inputSchema: ToolInputSchema;
|
|
62
|
+
outputSchema?: ToolInputSchema;
|
|
14
63
|
annotations?: ToolAnnotations;
|
|
15
64
|
/**
|
|
16
65
|
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
@@ -24,14 +73,12 @@ export interface ToolDefinition<TInputSchema extends TSchema = TSchema> {
|
|
|
24
73
|
* removed in a future major version.
|
|
25
74
|
*/
|
|
26
75
|
promptGuidelines?: string[];
|
|
27
|
-
prepareArguments?: (args: unknown) => Static<TInputSchema>;
|
|
28
76
|
executionMode?: ToolExecutionMode;
|
|
29
|
-
execute
|
|
30
|
-
|
|
31
|
-
signal?: AbortSignal;
|
|
32
|
-
conversationPrivacy?: ConversationPrivacy;
|
|
33
|
-
toolCallId?: string;
|
|
34
|
-
}) => Promise<unknown> | unknown;
|
|
77
|
+
execute?(input: unknown, options: ToolExecuteOptions): Promise<unknown> | unknown;
|
|
78
|
+
prepareArguments?(args: unknown): unknown;
|
|
35
79
|
}
|
|
80
|
+
/** Distinguish legacy TypeBox schemas from JSON Schema projected from Zod. */
|
|
81
|
+
export declare function isTypeBoxInputSchema(schema: ToolInputSchema): schema is TSchema;
|
|
36
82
|
/** Infer execute parameter types from the inputSchema via generic binding. */
|
|
37
83
|
export declare function tool<TInputSchema extends TSchema>(definition: ToolDefinition<TInputSchema>): ToolDefinition<TInputSchema>;
|
|
84
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SkillMetadata } from "@/chat/skills";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
3
3
|
import type { ToolHooks, ToolRuntimeContext } from "@/chat/tools/types";
|
|
4
4
|
export type { ToolHooks, ToolRuntimeContext };
|
|
5
|
-
|
|
5
|
+
/** Build the model-facing tool registry from runtime-owned context and capabilities. */
|
|
6
|
+
export declare function createTools(availableSkills: SkillMetadata[], hooks: ToolHooks | undefined, context: ToolRuntimeContext): Record<string, AnyToolDefinition>;
|
|
@@ -2,18 +2,8 @@ import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
|
2
2
|
/** Return whether the current runtime can safely manage conversation subscriptions. */
|
|
3
3
|
export declare function canUseResourceEventSubscriptionTools(context: ToolRuntimeContext): boolean;
|
|
4
4
|
/** Create the tool that subscribes the current conversation to resource events. */
|
|
5
|
-
export declare function createSubscribeToResourceEventsTool(context: ToolRuntimeContext): import("
|
|
6
|
-
resourceRef: import("@sinclair/typebox").TString;
|
|
7
|
-
provider: import("@sinclair/typebox").TString;
|
|
8
|
-
resourceType: import("@sinclair/typebox").TString;
|
|
9
|
-
label: import("@sinclair/typebox").TString;
|
|
10
|
-
events: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
11
|
-
intent: import("@sinclair/typebox").TString;
|
|
12
|
-
ttlMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
13
|
-
}>>;
|
|
5
|
+
export declare function createSubscribeToResourceEventsTool(context: ToolRuntimeContext): import("./definition").AnyToolDefinition;
|
|
14
6
|
/** Create the tool that lists active resource subscriptions for this conversation. */
|
|
15
|
-
export declare function createListResourceEventSubscriptionsTool(context: ToolRuntimeContext): import("
|
|
7
|
+
export declare function createListResourceEventSubscriptionsTool(context: ToolRuntimeContext): import("./definition").AnyToolDefinition;
|
|
16
8
|
/** Create the tool that cancels a current-conversation resource subscription. */
|
|
17
|
-
export declare function createCancelResourceEventSubscriptionTool(context: ToolRuntimeContext): import("
|
|
18
|
-
subscriptionId: import("@sinclair/typebox").TString;
|
|
19
|
-
}>>;
|
|
9
|
+
export declare function createCancelResourceEventSubscriptionTool(context: ToolRuntimeContext): import("./definition").AnyToolDefinition;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/** Create the internal tool the model uses for sparse progress updates. */
|
|
2
|
-
export declare function createReportProgressTool(): import("
|
|
3
|
-
message: import("@sinclair/typebox").TString;
|
|
4
|
-
}>>;
|
|
2
|
+
export declare function createReportProgressTool(): import("../definition").AnyToolDefinition;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
/** Create the sandbox shell tool definition exposed to the agent. */
|
|
2
|
-
export declare function createBashTool(): import("
|
|
3
|
-
command: import("@sinclair/typebox").TString;
|
|
4
|
-
timeoutMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
5
|
-
}>>;
|
|
2
|
+
export declare function createBashTool(): import("../definition").AnyToolDefinition;
|