@sentry/junior-plugin-api 0.197.0 → 0.199.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/dist/tools.d.ts DELETED
@@ -1,351 +0,0 @@
1
- import type { Actor, Identity, InvocationContext, PluginContext, PluginEmbedder, PluginModel, User } from "./context";
2
- import type { PluginCredentialSubject } from "./credentials";
3
- import type { PluginAnnotations } from "./annotations";
4
- import type { SlackConversationLink } from "./operations";
5
- import type { ResourceEventSubscriptionResult, SubscribableResource } from "./resource-events";
6
- import type { PluginState } from "./state";
7
- import { z, type ZodTypeAny } from "zod";
8
- export interface PluginEnv {
9
- get(key: string): string | undefined;
10
- set(key: string, value: string): void;
11
- }
12
- export interface PluginDecision {
13
- deny(message: string): void;
14
- replaceInput(input: Record<string, unknown>): void;
15
- }
16
- /** Thrown when a plugin tool rejects invalid model or user input. */
17
- export declare class PluginToolInputError extends Error {
18
- constructor(message: string, options?: {
19
- cause?: unknown;
20
- });
21
- }
22
- export interface PluginSandbox {
23
- juniorRoot: string;
24
- root: string;
25
- readFile(path: string): Promise<Uint8Array | null>;
26
- run(input: {
27
- args?: string[];
28
- cmd: string;
29
- cwd?: string;
30
- env?: Record<string, string>;
31
- signal?: AbortSignal;
32
- sudo?: boolean;
33
- }): Promise<{
34
- exitCode: number;
35
- stderr: string;
36
- stdout: string;
37
- }>;
38
- writeFile(input: {
39
- content: string | Uint8Array;
40
- mode?: number;
41
- path: string;
42
- }): Promise<void>;
43
- }
44
- export interface PluginEgress {
45
- /**
46
- * Fetch a provider URL with host-owned credentials.
47
- *
48
- * The runtime selects and injects credentials for `provider`; plugin code
49
- * owns the request shape and response handling. `operation` names the
50
- * provider action for grant selection and diagnostics.
51
- */
52
- fetch(input: {
53
- operation: string;
54
- provider: string;
55
- request: Request;
56
- }): Promise<Response>;
57
- }
58
- export declare const pluginToolContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
- type: z.ZodLiteral<"text">;
60
- text: z.ZodString;
61
- }, z.core.$strict>, z.ZodObject<{
62
- type: z.ZodLiteral<"image">;
63
- data: z.ZodString;
64
- mimeType: z.ZodString;
65
- }, z.core.$strict>], "type">;
66
- /** Model-visible content returned by a plugin tool. */
67
- export type PluginToolContent = z.output<typeof pluginToolContentSchema>;
68
- /** Pi-native projection with model-facing content and canonical runtime details. */
69
- export interface PluginToolOutputEnvelope<TDetails = unknown> {
70
- content: PluginToolContent[];
71
- details: TDetails;
72
- }
73
- export type PluginMcpContent = PluginToolContent;
74
- /** Successful raw provider result returned to a plugin-owned wrapper tool. */
75
- export type PluginMcpToolSuccess = {
76
- content: PluginMcpContent[];
77
- status: "success";
78
- structuredContent?: unknown;
79
- };
80
- /** Handled provider authorization pause with no provider result to consume. */
81
- export type PluginMcpAuthorizationPending = {
82
- status: "authorization_pending";
83
- };
84
- /** Definitive provider rejection; transport and session failures still throw. */
85
- export type PluginMcpToolError = {
86
- message: string;
87
- status: "error";
88
- };
89
- export type PluginMcpToolResult = PluginMcpAuthorizationPending | PluginMcpToolError | PluginMcpToolSuccess;
90
- /** Access to this plugin's hosted MCP provider without exposing credentials. */
91
- export interface PluginMcp {
92
- /**
93
- * Call a provider tool declared in `wrappedTools`.
94
- *
95
- * The host activates the provider when needed. Successful calls return the
96
- * provider's original content, provider rejections return an error result,
97
- * and authorization pauses return no tool content. Transport failures throw.
98
- */
99
- callTool(input: {
100
- arguments?: Record<string, unknown>;
101
- name: string;
102
- toolCallId?: string;
103
- }): Promise<PluginMcpToolResult>;
104
- /**
105
- * Activate the provider before wrapper-owned state changes.
106
- *
107
- * Ordinary wrappers can call `callTool` directly. Durable mutation wrappers
108
- * may prepare first so an initial authorization pause happens before they
109
- * record pending work.
110
- */
111
- prepare(): Promise<"authorization_pending" | "ready">;
112
- }
113
- /**
114
- * Provider-owned, repeatable repository preparation for a Workspace Sandbox.
115
- * Implementations should refresh complete checkouts and replace missing or
116
- * partial ones.
117
- */
118
- export interface WorkspacePrepareHookContext extends PluginContext {
119
- repos: Array<{
120
- path: string;
121
- repo: string;
122
- }>;
123
- sandbox: PluginSandbox;
124
- }
125
- export interface SandboxPrepareHookContext extends PluginContext {
126
- actor?: Actor;
127
- sandbox: PluginSandbox;
128
- }
129
- export interface BeforeToolExecuteHookContext extends PluginContext {
130
- decision: PluginDecision;
131
- env: PluginEnv;
132
- actor?: Actor;
133
- /** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
134
- actors?: Actor[];
135
- tool: {
136
- input: Record<string, unknown>;
137
- name: string;
138
- };
139
- /**
140
- * Resolve the current actor's stored identity and linked user.
141
- * Same contract as tool registration; used for commit attribution.
142
- */
143
- users: {
144
- resolveActor(): Promise<{
145
- identity: Identity;
146
- user?: User;
147
- } | undefined>;
148
- };
149
- }
150
- /**
151
- * Context for post-success MCP tool processing.
152
- *
153
- * Runs after a hosted MCP tool succeeds on the model-facing path. Use for
154
- * junior-owned side effects such as conversation annotations without replacing
155
- * the provider tool contract.
156
- */
157
- export interface AfterMcpToolHookContext extends PluginContext {
158
- /**
159
- * Opaque Junior conversation/session identity for this turn.
160
- * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
161
- */
162
- conversationId?: string;
163
- annotations?: PluginAnnotations;
164
- result: {
165
- structuredContent?: unknown;
166
- };
167
- tool: {
168
- arguments: Record<string, unknown>;
169
- /** Provider-local MCP tool name, for example `save_issue`. */
170
- name: string;
171
- };
172
- }
173
- export interface PluginToolExecuteOptions {
174
- /**
175
- * @deprecated Internal compatibility escape hatch for legacy tool bridges.
176
- * Plugin tools should use typed input fields and runtime hook context instead.
177
- */
178
- experimental_context?: unknown;
179
- /** Abort when the owning agent tool call is cancelled or times out. */
180
- signal?: AbortSignal;
181
- /** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
182
- toolCallId?: string;
183
- }
184
- export declare const pluginToolContinuationSchema: z.ZodObject<{
185
- arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
186
- reason: z.ZodOptional<z.ZodString>;
187
- }, z.core.$strict>;
188
- /** Shared optional fields for canonical plugin tool outputs. */
189
- export declare const pluginToolOutputSchema: z.ZodObject<{
190
- target: z.ZodOptional<z.ZodString>;
191
- truncated: z.ZodOptional<z.ZodBoolean>;
192
- continuation: z.ZodOptional<z.ZodObject<{
193
- arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
194
- reason: z.ZodOptional<z.ZodString>;
195
- }, z.core.$strict>>;
196
- }, z.core.$loose>;
197
- export type PluginToolOutput = z.output<typeof pluginToolOutputSchema>;
198
- export type PluginToolExecute<TInput = unknown, TOutput = unknown> = {
199
- bivarianceHack(input: TInput, options: PluginToolExecuteOptions): Promise<TOutput> | TOutput;
200
- }["bivarianceHack"];
201
- /**
202
- * Tool-declared approval mode.
203
- *
204
- * `auto` delegates to core policy, `review` enters Guardian review, and
205
- * `approve` permits execution without review. Plugin tool helpers normalize
206
- * omission to `auto`.
207
- *
208
- * Core resolves the effective mode immediately before execution.
209
- */
210
- export declare const toolApprovalModeSchema: z.ZodEnum<{
211
- auto: "auto";
212
- review: "review";
213
- approve: "approve";
214
- }>;
215
- export type ToolApprovalMode = z.output<typeof toolApprovalModeSchema>;
216
- /**
217
- * Reviewer signals describing a tool's side-effect behavior.
218
- *
219
- * These hints follow the MCP tool annotation contract. Guardian may use
220
- * them as signals, but they never grant authority or override deterministic
221
- * authorization.
222
- */
223
- export interface ToolAnnotations {
224
- [key: string]: unknown;
225
- destructiveHint?: boolean;
226
- idempotentHint?: boolean;
227
- openWorldHint?: boolean;
228
- readOnlyHint?: boolean;
229
- title?: string;
230
- }
231
- export declare const REQUIRED_TOOL_ANNOTATION_KEYS: readonly ["destructiveHint", "idempotentHint", "openWorldHint", "readOnlyHint"];
232
- export type RequiredToolAnnotationKey = (typeof REQUIRED_TOOL_ANNOTATION_KEYS)[number];
233
- /** Return behavioral annotation keys that a tool did not declare. */
234
- export declare function missingToolAnnotationKeys(annotations: ToolAnnotations | undefined): RequiredToolAnnotationKey[];
235
- /**
236
- * Canonical approval metadata declared by core and plugin tools.
237
- */
238
- export interface ToolApprovalMetadata<TInput = unknown> {
239
- /** Optional declared approval mode; the owning tool boundary selects defaults. */
240
- approvalMode?: ToolApprovalMode;
241
- annotations?: ToolAnnotations;
242
- /**
243
- * Describe the reviewed semantic action for the review request.
244
- *
245
- * Core owns authoritative tool, actor, source, destination, conversation,
246
- * credential, and input data. This description adds domain-specific context
247
- * only and is never an authorization grant.
248
- */
249
- describeProposal?(input: TInput): string;
250
- }
251
- export interface PluginToolDefinition<TInput = unknown, TOutput = unknown, TExecuteOutput = TOutput> extends ToolApprovalMetadata<TInput> {
252
- description: string;
253
- executionMode?: unknown;
254
- inputSchema: unknown;
255
- outputSchema?: unknown;
256
- /**
257
- * Select result fields that are safe to retain in private traces.
258
- * Returning `undefined` suppresses private result capture.
259
- */
260
- privateTraceResult?(result: TOutput): unknown;
261
- prepareArguments?: (args: unknown) => TInput;
262
- /**
263
- * @deprecated Put tool-selection and usage guidance directly in `description`
264
- * and parameter descriptions. Retained for compatibility; may be removed in a
265
- * future major version.
266
- */
267
- promptGuidelines?: string[];
268
- /**
269
- * @deprecated Put tool-selection and usage guidance directly in `description`
270
- * and parameter descriptions. Retained for compatibility; may be removed in a
271
- * future major version.
272
- */
273
- promptSnippet?: string;
274
- execute?: PluginToolExecute<TInput, TExecuteOutput>;
275
- }
276
- type ZodPluginToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>> = Omit<PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
277
- inputSchema: TInputSchema;
278
- outputSchema: TOutputSchema;
279
- prepareArguments?: (args: unknown) => z.input<TInputSchema>;
280
- execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<TExecuteResult> | TExecuteResult;
281
- };
282
- type ParsedPluginToolExecuteResult<TOutputSchema extends ZodTypeAny, TResult> = TResult extends PluginToolOutputEnvelope<unknown> ? PluginToolOutputEnvelope<z.output<TOutputSchema>> : z.output<TOutputSchema>;
283
- /** Define a plugin tool with Zod input parsing and validated structured results. */
284
- export declare function zodTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema, TExecuteResult>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>, ParsedPluginToolExecuteResult<TOutputSchema, TExecuteResult>>;
285
- /** Define a plugin tool with Zod input parsing and the structured result contract. */
286
- export declare function definePluginTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema, TExecuteResult>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>, ParsedPluginToolExecuteResult<TOutputSchema, TExecuteResult>>;
287
- export interface SlackToolRegistrationHookContext {
288
- /**
289
- * What Slack tools can do in the Conversation Location.
290
- * Computed from Location, not from Source or Destination.
291
- */
292
- channelCapabilities: {
293
- canAddReactions: boolean;
294
- canCreateCanvas: boolean;
295
- canPostToChannel: boolean;
296
- };
297
- /** Host-owned link to this conversation, preferring the dashboard when enabled. */
298
- conversationLink?: SlackConversationLink;
299
- credentialSubject?: Extract<PluginCredentialSubject, {
300
- allowedWhen: "private-direct-conversation";
301
- }>;
302
- }
303
- export interface PluginResourceEventToolContext {
304
- /** Whether this invocation can create a working resource subscription. */
305
- canSubscribe: boolean;
306
- /** Create a temporary resource subscription for the current conversation. */
307
- subscribe(input: {
308
- events: string[];
309
- intent: string;
310
- resource: SubscribableResource;
311
- }): Promise<ResourceEventSubscriptionResult>;
312
- }
313
- export interface PluginWorkspaceToolContext {
314
- /** Find named Workspaces that include one provider repository. */
315
- findByRepository(input: {
316
- provider: string;
317
- repo: string;
318
- }): Promise<string[]>;
319
- }
320
- interface BaseToolRegistrationHookContext extends PluginContext {
321
- /**
322
- * Opaque Junior conversation/session identity for this turn.
323
- * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
324
- * Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
325
- * Do not parse as Slack unless the value starts with `slack:`.
326
- */
327
- conversationId?: string;
328
- annotations?: PluginAnnotations;
329
- embedder: PluginEmbedder;
330
- egress: PluginEgress;
331
- mcp?: PluginMcp;
332
- model: PluginModel;
333
- resourceEvents: PluginResourceEventToolContext;
334
- /** Sandbox filesystem and command capability for plugin-owned workspace tools. */
335
- sandbox: PluginSandbox;
336
- state: PluginState;
337
- users: {
338
- /** Resolve the current actor's stored identity and linked user. */
339
- resolveActor(): Promise<{
340
- identity: Identity;
341
- user?: User;
342
- } | undefined>;
343
- };
344
- userText?: string;
345
- workspaces: PluginWorkspaceToolContext;
346
- }
347
- export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
348
- /** Slack tool details when the Conversation has a Slack Location. */
349
- slack?: SlackToolRegistrationHookContext;
350
- };
351
- export {};
@@ -1,97 +0,0 @@
1
- /**
2
- * Core-rendered plugin user pages.
3
- *
4
- * Plugins own bounded data projection; Junior owns viewer authorization,
5
- * routing, response validation, and browser rendering.
6
- */
7
- import { z } from "zod";
8
- import type { PluginContext, User } from "./context";
9
- /** Bounded list content returned by a plugin-owned user page. */
10
- export declare const pluginUserPageContentSchema: z.ZodObject<{
11
- emptyText: z.ZodOptional<z.ZodString>;
12
- metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
13
- detail: z.ZodOptional<z.ZodString>;
14
- label: z.ZodString;
15
- tone: z.ZodOptional<z.ZodEnum<{
16
- warning: "warning";
17
- good: "good";
18
- neutral: "neutral";
19
- }>>;
20
- value: z.ZodString;
21
- }, z.core.$strict>>>;
22
- nextCursor: z.ZodOptional<z.ZodString>;
23
- records: z.ZodArray<z.ZodObject<{
24
- actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
- confirmation: z.ZodOptional<z.ZodString>;
26
- href: z.ZodString;
27
- label: z.ZodString;
28
- method: z.ZodLiteral<"DELETE">;
29
- tone: z.ZodOptional<z.ZodEnum<{
30
- danger: "danger";
31
- neutral: "neutral";
32
- }>>;
33
- }, z.core.$strict>>>;
34
- description: z.ZodOptional<z.ZodString>;
35
- id: z.ZodString;
36
- metadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
- label: z.ZodString;
38
- value: z.ZodString;
39
- }, z.core.$strict>>>;
40
- title: z.ZodString;
41
- }, z.core.$strict>>;
42
- searchPlaceholder: z.ZodOptional<z.ZodString>;
43
- type: z.ZodLiteral<"list">;
44
- }, z.core.$strict>;
45
- /** Validated content for the current core-rendered list page type. */
46
- export type PluginUserPageContent = z.output<typeof pluginUserPageContentSchema>;
47
- export declare const pluginUserPageLinkSchema: z.ZodObject<{
48
- description: z.ZodString;
49
- id: z.ZodString;
50
- label: z.ZodString;
51
- navigation: z.ZodEnum<{
52
- primary: "primary";
53
- profile: "profile";
54
- }>;
55
- pluginDisplayName: z.ZodString;
56
- pluginName: z.ZodString;
57
- }, z.core.$strict>;
58
- export declare const pluginUserPageLinksSchema: z.ZodArray<z.ZodObject<{
59
- description: z.ZodString;
60
- id: z.ZodString;
61
- label: z.ZodString;
62
- navigation: z.ZodEnum<{
63
- primary: "primary";
64
- profile: "profile";
65
- }>;
66
- pluginDisplayName: z.ZodString;
67
- pluginName: z.ZodString;
68
- }, z.core.$strict>>;
69
- /** Safe navigation metadata for one registered plugin user page. */
70
- export type PluginUserPageLink = z.output<typeof pluginUserPageLinkSchema>;
71
- /** Optional cursor token for one plugin user page reader. */
72
- export declare const pluginUserPageCursorSchema: z.ZodOptional<z.ZodString>;
73
- /** Optional filter token for one plugin user page reader. */
74
- export declare const pluginUserPageFilterSchema: z.ZodOptional<z.ZodString>;
75
- /** Optional free-text query for one plugin user page reader. */
76
- export declare const pluginUserPageQuerySchema: z.ZodOptional<z.ZodString>;
77
- /** Validated query state passed to one plugin user page reader. */
78
- export declare const pluginUserPageInputSchema: z.ZodObject<{
79
- cursor: z.ZodOptional<z.ZodString>;
80
- filter: z.ZodOptional<z.ZodString>;
81
- limit: z.ZodNumber;
82
- query: z.ZodOptional<z.ZodString>;
83
- }, z.core.$strict>;
84
- export type PluginUserPageInput = z.output<typeof pluginUserPageInputSchema>;
85
- /** Trusted host context supplied while reading one plugin user page. */
86
- export interface PluginUserPageContext extends PluginContext {
87
- viewer: User;
88
- }
89
- /** Navigation metadata and reader for one core-rendered plugin user page. */
90
- export interface PluginUserPageDefinition {
91
- description: string;
92
- id: string;
93
- label: string;
94
- /** Dashboard navigation surface where this page is linked. */
95
- navigation?: "primary" | "profile";
96
- read(ctx: PluginUserPageContext, input: PluginUserPageInput): Promise<PluginUserPageContent> | PluginUserPageContent;
97
- }
@@ -1,78 +0,0 @@
1
- import { z } from "zod";
2
- import type { PluginContext } from "./context";
3
-
4
- function usesHttpProtocol(value: string): boolean {
5
- try {
6
- const protocol = new URL(value).protocol;
7
- return protocol === "http:" || protocol === "https:";
8
- } catch {
9
- return false;
10
- }
11
- }
12
-
13
- export const resourceLinkAnnotationSchema = z
14
- .object({
15
- kind: z.literal("resource_link"),
16
- key: z.string().trim().min(1).max(256),
17
- label: z.string().trim().min(1).max(256),
18
- url: z
19
- .string()
20
- .url()
21
- .max(2_048)
22
- .refine(usesHttpProtocol, "URL must use HTTP or HTTPS."),
23
- description: z.string().trim().min(1).max(512).optional(),
24
- status: z.enum(["open", "draft", "closed", "merged", "warning"]).optional(),
25
- })
26
- .strict();
27
-
28
- /** Core-known annotation shapes that plugins may attach to a conversation. */
29
- export const conversationAnnotationInputSchema = z.discriminatedUnion("kind", [
30
- resourceLinkAnnotationSchema,
31
- ]);
32
- export type ConversationAnnotationInput = z.output<
33
- typeof conversationAnnotationInputSchema
34
- >;
35
- export type ConversationAnnotation = ConversationAnnotationInput & {
36
- plugin: string;
37
- createdAt: string;
38
- updatedAt: string;
39
- };
40
- export interface PluginAnnotations {
41
- upsert(annotation: ConversationAnnotationInput): Promise<void>;
42
- remove(kind: ConversationAnnotationInput["kind"], key: string): Promise<void>;
43
- list(): Promise<ConversationAnnotation[]>;
44
- }
45
- export interface PluginConversationAnnotations {
46
- forConversation(conversationId: string): PluginAnnotations;
47
- }
48
-
49
- export const conversationSidebarIconSchema = z.enum([
50
- "circle-dot",
51
- "circle-dashed",
52
- "circle-x",
53
- "git-merge",
54
- "git-pull-request",
55
- "triangle-alert",
56
- ]);
57
-
58
- export const conversationSidebarAnnotationSchema = z
59
- .object({
60
- icon: conversationSidebarIconSchema.optional(),
61
- key: z.string().trim().min(1).max(256),
62
- label: z.string().trim().min(1).max(256),
63
- })
64
- .strict();
65
- export type ConversationSidebarAnnotation = z.output<
66
- typeof conversationSidebarAnnotationSchema
67
- >;
68
-
69
- export interface ConversationSidebarHookContext extends PluginContext {
70
- /** Stored annotations owned by this plugin, keyed by candidate conversation. */
71
- annotationsByConversationId: Record<string, ConversationAnnotation[]>;
72
- conversationIds: string[];
73
- }
74
-
75
- export interface ConversationSidebarResult {
76
- /** Sidebar annotations in display order. Put the newest annotation first. */
77
- annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
78
- }
package/src/cli.ts DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * Public Commander-based CLI contract for plugin-owned admin commands.
3
- * Junior owns the root command, plugin namespaces, context injection, and exit
4
- * normalization; plugins only configure subcommands under their namespace.
5
- */
6
- import type { Command } from "commander";
7
- import type { PluginContext } from "./context";
8
-
9
- export interface PluginCliIo {
10
- writeError(text: string): Promise<void> | void;
11
- writeOutput(text: string): Promise<void> | void;
12
- }
13
-
14
- export interface PluginCliActionCommand {
15
- name: string;
16
- summary: string;
17
- }
18
-
19
- /** Host/admin context exposed to plugin-owned CLI command actions. */
20
- export interface PluginCliActionContext extends Pick<
21
- PluginContext,
22
- "db" | "log" | "plugin"
23
- > {
24
- command: PluginCliActionCommand;
25
- io: PluginCliIo;
26
- }
27
-
28
- /** Plugin action callback wrapped by the Junior host for context and exit codes. */
29
- export type PluginCliActionHandler<Args extends unknown[] = unknown[]> = (
30
- ctx: PluginCliActionContext,
31
- ...args: Args
32
- ) => Promise<number | void> | number | void;
33
-
34
- export interface PluginCliHost {
35
- /** Wrap a Commander action so Junior can inject context and normalize exits. */
36
- action<Args extends unknown[]>(
37
- handler: PluginCliActionHandler<Args>,
38
- ): (...args: Args) => Promise<void>;
39
- }
40
-
41
- /** Plugin-owned top-level CLI command registration. */
42
- export interface PluginCliCommandDefinition {
43
- /** Configure subcommands under the host-created top-level namespace. */
44
- configure(command: Command, junior: PluginCliHost): void;
45
- /** Unique host-level command namespace owned by this plugin. */
46
- name: string;
47
- /** One-line summary used in generated command help. */
48
- summary: string;
49
- }
50
-
51
- /** Plugin-owned CLI command catalog. */
52
- export interface PluginCliDefinition {
53
- commands: PluginCliCommandDefinition[];
54
- }
package/src/code.ts DELETED
@@ -1,37 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const codeChangeStateSchema = z.enum(["closed", "merged", "open"]);
4
- export type CodeChangeState = z.output<typeof codeChangeStateSchema>;
5
-
6
- export const codeChangeInputSchema = z
7
- .object({
8
- closedAt: z.date().optional(),
9
- conversationIds: z.array(z.string().min(1)).default([]),
10
- mergedAt: z.date().optional(),
11
- number: z.number().int().positive(),
12
- openedAt: z.date(),
13
- providerId: z.string().min(1),
14
- repository: z
15
- .object({
16
- name: z.string().min(1),
17
- providerId: z.string().min(1),
18
- url: z.string().url().optional(),
19
- })
20
- .strict(),
21
- state: codeChangeStateSchema,
22
- title: z.string().min(1).optional(),
23
- updatedAt: z.date(),
24
- url: z.string().url().optional(),
25
- })
26
- .strict();
27
-
28
- export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
29
-
30
- /** Write code changes from a plugin to Junior's code records. */
31
- export interface CodeChangePublisher {
32
- associateConversations(input: {
33
- conversationIds: string[];
34
- providerId: string;
35
- }): Promise<void>;
36
- record(input: CodeChangeInput): Promise<void>;
37
- }