@sentry/junior-plugin-api 0.75.0 → 0.76.1

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/cli.d.ts ADDED
@@ -0,0 +1,39 @@
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
+ export interface PluginCliIo {
9
+ writeError(text: string): Promise<void> | void;
10
+ writeOutput(text: string): Promise<void> | void;
11
+ }
12
+ export interface PluginCliActionCommand {
13
+ name: string;
14
+ summary: string;
15
+ }
16
+ /** Host/admin context exposed to plugin-owned CLI command actions. */
17
+ export interface PluginCliActionContext extends Pick<PluginContext, "db" | "log" | "plugin"> {
18
+ command: PluginCliActionCommand;
19
+ io: PluginCliIo;
20
+ }
21
+ /** Plugin action callback wrapped by the Junior host for context and exit codes. */
22
+ export type PluginCliActionHandler<Args extends unknown[] = unknown[]> = (ctx: PluginCliActionContext, ...args: Args) => Promise<number | void> | number | void;
23
+ export interface PluginCliHost {
24
+ /** Wrap a Commander action so Junior can inject context and normalize exits. */
25
+ action<Args extends unknown[]>(handler: PluginCliActionHandler<Args>): (...args: Args) => Promise<void>;
26
+ }
27
+ /** Plugin-owned top-level CLI command registration. */
28
+ export interface PluginCliCommandDefinition {
29
+ /** Configure subcommands under the host-created top-level namespace. */
30
+ configure(command: Command, junior: PluginCliHost): void;
31
+ /** Unique host-level command namespace owned by this plugin. */
32
+ name: string;
33
+ /** One-line summary used in generated command help. */
34
+ summary: string;
35
+ }
36
+ /** Plugin-owned CLI command catalog. */
37
+ export interface PluginCliDefinition {
38
+ commands: PluginCliCommandDefinition[];
39
+ }
package/dist/context.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod";
2
- import { destinationSchema, localRequesterSchema, requesterSchema, slackRequesterSchema, sourceSchema } from "./schemas";
3
- import type { PluginDb } from "./database";
2
+ import type { ZodTypeAny } from "zod";
3
+ import { destinationSchema, localRequesterSchema, platformSchema, requesterSchema, slackRequesterSchema, sourceSchema } from "./schemas";
4
+ /** Runtime platform name without source or destination coordinates. */
5
+ export type Platform = z.output<typeof platformSchema>;
4
6
  export type Requester = z.output<typeof requesterSchema>;
5
7
  export type SlackRequester = z.output<typeof slackRequesterSchema>;
6
8
  export type LocalRequester = z.output<typeof localRequesterSchema>;
@@ -11,6 +13,7 @@ export type SlackSource = Extract<Source, {
11
13
  export type LocalSource = Extract<Source, {
12
14
  platform: "local";
13
15
  }>;
16
+ export type SourceType = Source["type"];
14
17
  export type Destination = z.output<typeof destinationSchema>;
15
18
  export type SlackDestination = Extract<Destination, {
16
19
  platform: "slack";
@@ -26,9 +29,31 @@ export interface PluginLogger {
26
29
  info(message: string, metadata?: Record<string, unknown>): void;
27
30
  warn(message: string, metadata?: Record<string, unknown>): void;
28
31
  }
32
+ export interface PluginModel {
33
+ /** Run a host-owned structured model call without exposing provider credentials. */
34
+ completeObject<TSchema extends ZodTypeAny>(input: {
35
+ maxTokens?: number;
36
+ prompt: string;
37
+ schema: TSchema;
38
+ system?: string;
39
+ }): Promise<{
40
+ object: z.infer<TSchema>;
41
+ }>;
42
+ }
43
+ export interface PluginEmbedder {
44
+ /** Embed plugin-owned text for derived retrieval without exposing provider credentials. */
45
+ embedTexts(input: {
46
+ texts: string[];
47
+ }): Promise<{
48
+ dimensions: number;
49
+ model: string;
50
+ provider: string;
51
+ vectors: number[][];
52
+ }>;
53
+ }
29
54
  export interface PluginContext {
30
- /** Shared database connection for plugins that declare database access. */
31
- db?: PluginDb;
55
+ /** Shared Drizzle database connection for plugin runtime code. */
56
+ db: unknown;
32
57
  log: PluginLogger;
33
58
  plugin: PluginMetadata;
34
59
  }
@@ -40,20 +65,33 @@ interface BaseInvocationContext {
40
65
  conversationId?: string;
41
66
  }
42
67
  export interface SlackInvocationContext extends BaseInvocationContext {
43
- /** Runtime-owned default outbound destination for this invocation, if any. */
44
- destination?: SlackDestination;
68
+ /** Runtime-owned default outbound destination for this invocation. */
69
+ destination: SlackDestination;
45
70
  requester?: SlackRequester;
46
71
  /** Runtime-owned source where the invocation came from. */
47
72
  source: SlackSource;
48
73
  }
49
74
  export interface LocalInvocationContext extends BaseInvocationContext {
50
- /** Runtime-owned default outbound destination for this invocation, if any. */
51
- destination?: LocalDestination;
75
+ /** Runtime-owned default outbound destination for this invocation. */
76
+ destination: LocalDestination;
52
77
  requester?: LocalRequester;
53
78
  /** Runtime-owned source where the invocation came from. */
54
79
  source: LocalSource;
55
80
  }
56
81
  export type InvocationContext = LocalInvocationContext | SlackInvocationContext;
82
+ /** Build a normalized Slack source from runtime-owned Slack coordinates. */
83
+ export declare function createSlackSource(input: {
84
+ channelId: string;
85
+ messageTs?: string;
86
+ teamId: string;
87
+ threadTs?: string;
88
+ }): SlackSource;
89
+ /** Build a normalized local source from a local conversation id. */
90
+ export declare function createLocalSource(conversationId: string): LocalSource;
91
+ /** Return whether a source is private to a person or restricted group. */
92
+ export declare function isPrivateSource(source: Source): boolean;
93
+ /** Return the stable source identity used for idempotency and attribution. */
94
+ export declare function getSourceKey(source: Source): string | undefined;
57
95
  /** Narrow a runtime destination to the Slack-specific address shape. */
58
96
  export declare function isSlackDestination(destination: Destination | undefined): destination is SlackDestination;
59
97
  export {};
@@ -14,6 +14,19 @@ export declare const pluginProviderAccountSchema: z.ZodObject<{
14
14
  label: z.ZodOptional<z.ZodString>;
15
15
  url: z.ZodOptional<z.ZodString>;
16
16
  }, z.core.$strict>;
17
+ /** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
18
+ export declare const pluginStoredTokensSchema: z.ZodObject<{
19
+ account: z.ZodOptional<z.ZodObject<{
20
+ id: z.ZodString;
21
+ label: z.ZodOptional<z.ZodString>;
22
+ url: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>>;
24
+ accessToken: z.ZodString;
25
+ expiresAt: z.ZodOptional<z.ZodNumber>;
26
+ refreshToken: z.ZodString;
27
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
28
+ scope: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>;
17
30
  /** Runtime schema for a plugin-defined outbound credential grant. */
18
31
  export declare const pluginGrantSchema: z.ZodObject<{
19
32
  access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
@@ -130,16 +143,12 @@ export interface PluginResolvedCredentialUser {
130
143
  type: "user";
131
144
  userId: string;
132
145
  }
133
- export interface PluginStoredTokens {
134
- account?: PluginProviderAccount;
135
- accessToken: string;
136
- expiresAt?: number;
137
- refreshToken: string;
138
- scope?: string;
139
- }
146
+ export type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
140
147
  export interface PluginUserTokenSlot {
141
148
  get(): Promise<PluginStoredTokens | undefined>;
142
149
  set(tokens: PluginStoredTokens): Promise<void>;
150
+ /** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
151
+ withRefresh<T>(callback: () => Promise<T>): Promise<T>;
143
152
  userId: string;
144
153
  }
145
154
  export interface PluginTokenStore {
package/dist/hooks.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import type { EgressHookContext, EgressResponseHookContext, IssueCredentialHookContext, PluginCredentialResult, PluginGrant, PluginProviderAccount, ResolveOAuthAccountHookContext } from "./credentials";
2
2
  import type { HeartbeatHookContext, HeartbeatResult, OperationalReportHookContext, PluginOperationalReportContent, PluginRoute, RouteRegistrationHookContext, SlackConversationLink, SlackConversationLinkHookContext, StorageMigrationContext, StorageMigrationResult } from "./operations";
3
3
  import type { BeforeToolExecuteHookContext, PluginToolDefinition, SandboxPrepareHookContext, ToolRegistrationHookContext } from "./tools";
4
+ import type { PromptMessage, SystemPromptContext, UserPromptContext } from "./prompt";
4
5
  export interface PluginHooks {
6
+ systemPrompt?(ctx: SystemPromptContext): Promise<PromptMessage[]> | PromptMessage[];
7
+ userPrompt?(ctx: UserPromptContext): Promise<PromptMessage[] | undefined> | PromptMessage[] | undefined;
5
8
  beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
6
9
  grantForEgress?(ctx: EgressHookContext): Promise<PluginGrant | undefined> | PluginGrant | undefined;
7
10
  heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  export * from "./schemas";
2
2
  export * from "./context";
3
3
  export * from "./state";
4
+ export { promptMessageSchema, type PromptMessage, type SystemPromptContext, type UserPromptContext, } from "./prompt";
4
5
  export * from "./dispatch";
5
- export * from "./database";
6
+ export * from "./tasks";
6
7
  export * from "./tools";
7
8
  export * from "./operations";
8
9
  export * from "./credentials";
9
10
  export * from "./hooks";
11
+ export * from "./cli";
10
12
  export * from "./manifest";
11
13
  export * from "./registration";
package/dist/index.js CHANGED
@@ -7,11 +7,14 @@ var exactActorUserIdSchema = z.string().min(1).refine(
7
7
  (value) => value === value.trim() && value.toLowerCase() !== "unknown"
8
8
  );
9
9
  var nonBlankStringSchema = z.string().refine((value) => value.trim().length > 0);
10
- var slackDestinationSchema = z.object({
10
+ var platformSchema = z.enum(["slack", "local"]);
11
+ var sourceTypeSchema = z.enum(["pub", "priv"]);
12
+ var slackAddressSchema = z.object({
11
13
  platform: z.literal("slack"),
12
14
  teamId: slackTeamIdSchema,
13
15
  channelId: slackConversationIdSchema
14
16
  }).strict();
17
+ var slackDestinationSchema = slackAddressSchema;
15
18
  var localDestinationSchema = z.object({
16
19
  platform: z.literal("local"),
17
20
  conversationId: localConversationIdSchema
@@ -20,14 +23,16 @@ var destinationSchema = z.discriminatedUnion("platform", [
20
23
  slackDestinationSchema,
21
24
  localDestinationSchema
22
25
  ]);
23
- var slackSourceSchema = z.object({
24
- platform: z.literal("slack"),
25
- teamId: slackTeamIdSchema,
26
- channelId: slackConversationIdSchema,
26
+ var slackSourceSchema = slackAddressSchema.extend({
27
+ type: sourceTypeSchema,
27
28
  messageTs: nonBlankStringSchema.optional(),
28
29
  threadTs: nonBlankStringSchema.optional()
29
30
  }).strict();
30
- var localSourceSchema = localDestinationSchema;
31
+ var localSourceSchema = z.object({
32
+ platform: z.literal("local"),
33
+ type: z.literal("priv"),
34
+ conversationId: localConversationIdSchema
35
+ }).strict();
31
36
  var sourceSchema = z.discriminatedUnion("platform", [
32
37
  slackSourceSchema,
33
38
  localSourceSchema
@@ -114,10 +119,76 @@ var dispatchOptionsSchema = z.object({
114
119
  }).strict();
115
120
 
116
121
  // src/context.ts
122
+ function createSlackSource(input) {
123
+ return {
124
+ platform: "slack",
125
+ type: slackSourceType(input.channelId),
126
+ teamId: input.teamId,
127
+ channelId: input.channelId,
128
+ ...input.messageTs ? { messageTs: input.messageTs } : {},
129
+ ...input.threadTs ? { threadTs: input.threadTs } : {}
130
+ };
131
+ }
132
+ function slackSourceType(channelId) {
133
+ if (channelId.startsWith("C")) return "pub";
134
+ if (channelId.startsWith("D") || channelId.startsWith("G")) return "priv";
135
+ throw new Error(`Unsupported Slack channel ID prefix: ${channelId}`);
136
+ }
137
+ function createLocalSource(conversationId) {
138
+ return {
139
+ platform: "local",
140
+ type: "priv",
141
+ conversationId
142
+ };
143
+ }
144
+ function isPrivateSource(source) {
145
+ return source.type === "priv";
146
+ }
147
+ function getSourceKey(source) {
148
+ if (source.platform === "local") {
149
+ return source.conversationId;
150
+ }
151
+ const messageKey = source.threadTs ?? source.messageTs;
152
+ if (!messageKey) {
153
+ return void 0;
154
+ }
155
+ return `slack:${source.teamId}:${source.channelId}:${messageKey}`;
156
+ }
117
157
  function isSlackDestination(destination) {
118
158
  return destination?.platform === "slack";
119
159
  }
120
160
 
161
+ // src/prompt.ts
162
+ import { z as z2 } from "zod";
163
+ var promptMessageSchema = z2.object({
164
+ text: z2.string().trim().min(1).max(8e3)
165
+ }).strict();
166
+
167
+ // src/tasks.ts
168
+ import { z as z3 } from "zod";
169
+ var pluginRunTranscriptEntrySchema = z3.discriminatedUnion("type", [
170
+ z3.object({
171
+ type: z3.literal("message"),
172
+ role: z3.enum(["user", "assistant"]),
173
+ text: z3.string().min(1)
174
+ }).strict(),
175
+ z3.object({
176
+ type: z3.literal("toolResult"),
177
+ toolName: z3.string().min(1),
178
+ isError: z3.boolean(),
179
+ text: z3.string().min(1).optional()
180
+ }).strict()
181
+ ]);
182
+ var pluginRunContextSchema = z3.object({
183
+ completedAtMs: z3.number().finite(),
184
+ conversationId: z3.string().min(1),
185
+ destination: destinationSchema,
186
+ requester: requesterSchema.optional(),
187
+ runId: z3.string().min(1),
188
+ source: sourceSchema,
189
+ transcript: z3.array(pluginRunTranscriptEntrySchema)
190
+ }).strict();
191
+
121
192
  // src/tools.ts
122
193
  var PluginToolInputError = class extends Error {
123
194
  constructor(message, options) {
@@ -127,52 +198,60 @@ var PluginToolInputError = class extends Error {
127
198
  };
128
199
 
129
200
  // src/credentials.ts
130
- import { z as z2 } from "zod";
131
- var pluginProviderNameSchema = z2.string().regex(/^[a-z][a-z0-9-]*$/);
132
- var pluginGrantNameSchema = z2.string().regex(/^[a-z][a-z0-9.-]*$/);
133
- var pluginGrantAccessSchema = z2.union([
134
- z2.literal("read"),
135
- z2.literal("write")
201
+ import { z as z4 } from "zod";
202
+ var pluginProviderNameSchema = z4.string().regex(/^[a-z][a-z0-9-]*$/);
203
+ var pluginGrantNameSchema = z4.string().regex(/^[a-z][a-z0-9.-]*$/);
204
+ var pluginGrantAccessSchema = z4.union([
205
+ z4.literal("read"),
206
+ z4.literal("write")
136
207
  ]);
137
- var pluginAuthorizationSchema = z2.object({
208
+ var pluginAuthorizationSchema = z4.object({
138
209
  provider: pluginProviderNameSchema,
139
210
  scope: nonBlankStringSchema.optional(),
140
- type: z2.literal("oauth")
211
+ type: z4.literal("oauth")
141
212
  }).strict();
142
- var pluginProviderAccountSchema = z2.object({
213
+ var pluginProviderAccountSchema = z4.object({
143
214
  id: nonBlankStringSchema,
144
215
  label: nonBlankStringSchema.optional(),
145
216
  url: nonBlankStringSchema.optional()
146
217
  }).strict();
147
- var pluginGrantSchema = z2.object({
218
+ var pluginStoredTokensSchema = z4.object({
219
+ account: pluginProviderAccountSchema.optional(),
220
+ accessToken: nonBlankStringSchema,
221
+ expiresAt: z4.number().finite().optional(),
222
+ refreshToken: nonBlankStringSchema,
223
+ refreshTokenExpiresAt: z4.number().finite().optional(),
224
+ scope: nonBlankStringSchema.optional()
225
+ }).strict();
226
+ var pluginGrantSchema = z4.object({
148
227
  access: pluginGrantAccessSchema,
149
228
  name: pluginGrantNameSchema,
150
229
  reason: nonBlankStringSchema.optional(),
151
- requirements: z2.array(nonBlankStringSchema).min(1).optional()
230
+ requirements: z4.array(nonBlankStringSchema).min(1).optional()
152
231
  }).strict();
153
- var pluginCredentialHeaderTransformSchema = z2.object({
154
- domain: z2.string().min(1),
155
- headers: z2.record(z2.string(), z2.string()).refine((headers) => Object.keys(headers).length > 0)
232
+ var pluginCredentialHeaderTransformSchema = z4.object({
233
+ domain: z4.string().min(1),
234
+ headers: z4.record(z4.string(), z4.string()).refine((headers) => Object.keys(headers).length > 0)
156
235
  }).strict();
157
- var pluginCredentialLeaseSchema = z2.object({
236
+ var pluginCredentialLeaseSchema = z4.object({
158
237
  account: pluginProviderAccountSchema.optional(),
159
238
  authorization: pluginAuthorizationSchema.optional(),
160
- expiresAt: z2.string().refine((value) => Number.isFinite(Date.parse(value))),
161
- headerTransforms: z2.array(pluginCredentialHeaderTransformSchema).min(1)
239
+ expiresAt: z4.string().refine((value) => Number.isFinite(Date.parse(value))),
240
+ headerTransforms: z4.array(pluginCredentialHeaderTransformSchema).min(1)
162
241
  }).strict();
163
- var pluginCredentialResultSchema = z2.discriminatedUnion("type", [
164
- z2.object({
242
+ var pluginCredentialResultSchema = z4.discriminatedUnion("type", [
243
+ z4.object({
165
244
  lease: pluginCredentialLeaseSchema,
166
- type: z2.literal("lease")
245
+ type: z4.literal("lease")
167
246
  }).strict(),
168
- z2.object({
247
+ z4.object({
169
248
  authorization: pluginAuthorizationSchema.optional(),
170
249
  message: nonBlankStringSchema,
171
- type: z2.literal("needed")
250
+ type: z4.literal("needed")
172
251
  }).strict(),
173
- z2.object({
252
+ z4.object({
174
253
  message: nonBlankStringSchema,
175
- type: z2.literal("unavailable")
254
+ type: z4.literal("unavailable")
176
255
  }).strict()
177
256
  ]);
178
257
  var EgressAuthRequired = class extends Error {
@@ -227,14 +306,19 @@ function defineJuniorPlugin(plugin) {
227
306
  export {
228
307
  EgressAuthRequired,
229
308
  PluginToolInputError,
309
+ createLocalSource,
310
+ createSlackSource,
230
311
  defineJuniorPlugin,
231
312
  destinationSchema,
232
313
  dispatchOptionsSchema,
314
+ getSourceKey,
315
+ isPrivateSource,
233
316
  isSlackDestination,
234
317
  localDestinationSchema,
235
318
  localRequesterSchema,
236
319
  localSourceSchema,
237
320
  nonBlankStringSchema,
321
+ platformSchema,
238
322
  pluginAuthorizationSchema,
239
323
  pluginCredentialHeaderTransformSchema,
240
324
  pluginCredentialLeaseSchema,
@@ -242,9 +326,14 @@ export {
242
326
  pluginCredentialSubjectSchema,
243
327
  pluginGrantSchema,
244
328
  pluginProviderAccountSchema,
329
+ pluginRunContextSchema,
330
+ pluginRunTranscriptEntrySchema,
331
+ pluginStoredTokensSchema,
332
+ promptMessageSchema,
245
333
  requesterSchema,
246
334
  slackDestinationSchema,
247
335
  slackRequesterSchema,
248
336
  slackSourceSchema,
249
- sourceSchema
337
+ sourceSchema,
338
+ sourceTypeSchema
250
339
  };
@@ -1,5 +1,4 @@
1
1
  import type { PluginContext } from "./context";
2
- import type { PluginDb } from "./database";
3
2
  import type { Dispatch, DispatchOptions, DispatchResult } from "./dispatch";
4
3
  import type { PluginReadState, PluginState } from "./state";
5
4
  export type PluginConversationStatus = "active" | "completed" | "failed" | "hung" | "superseded";
@@ -36,7 +35,6 @@ export interface StorageMigrationResult {
36
35
  skipped?: number;
37
36
  }
38
37
  export interface StorageMigrationContext extends PluginContext {
39
- db: PluginDb;
40
38
  state: PluginState;
41
39
  }
42
40
  export type PluginOperationalTone = "danger" | "good" | "neutral" | "warning";
package/dist/prompt.d.ts CHANGED
@@ -1,42 +1,22 @@
1
- import type { InvocationContext, PluginContext } from "./context";
2
- import type { PluginSessionState, PluginSessionStateAppend, PluginState } from "./state";
3
- export interface UserPromptContribution {
4
- id: string;
5
- text: string;
6
- }
7
- export interface UserPromptContributionResult {
8
- contributions?: UserPromptContribution[];
9
- sessionState?: PluginSessionStateAppend[];
10
- }
11
- export type UserPromptHookContext = PluginContext & InvocationContext & {
12
- isFirstPrompt: boolean;
13
- session: PluginSessionState;
14
- state: PluginState;
15
- userText: string;
16
- };
17
- export interface PluginTaskEnqueueOptions {
18
- idempotencyKey: string;
19
- name: string;
20
- payload?: unknown;
21
- }
22
- export interface PluginTaskEnqueueResult {
23
- id: string;
24
- status: "created" | "already_exists";
25
- }
26
- export interface PluginTaskQueue {
27
- enqueue(options: PluginTaskEnqueueOptions): Promise<PluginTaskEnqueueResult>;
28
- }
29
- export type TurnObservationHookContext = PluginContext & InvocationContext & {
30
- observationId: string;
31
- tasks: PluginTaskQueue;
1
+ import { z } from "zod";
2
+ import type { Destination, Platform, PluginContext, PluginEmbedder, Requester, Source } from "./context";
3
+ import type { PluginState } from "./state";
4
+ export declare const promptMessageSchema: z.ZodObject<{
5
+ text: z.ZodString;
6
+ }, z.core.$strict>;
7
+ /** Small plugin-owned prompt text block rendered by Junior core. */
8
+ export type PromptMessage = z.output<typeof promptMessageSchema>;
9
+ /** Stable platform context for plugin system prompt guidance. */
10
+ export type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
11
+ platform: Platform;
32
12
  };
33
- export interface PluginTaskContext extends PluginContext {
34
- id: string;
35
- name: string;
36
- observation?: {
37
- load(): Promise<unknown | undefined>;
38
- };
39
- payload?: unknown;
13
+ /** Runtime facts available while building plugin user prompt context. */
14
+ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
15
+ conversationId?: string;
16
+ destination: Destination;
17
+ embedder: PluginEmbedder;
18
+ requester?: Requester;
19
+ source: Source;
40
20
  state: PluginState;
41
- }
42
- export type PluginTaskHandler = (ctx: PluginTaskContext) => Promise<void> | void;
21
+ text: string;
22
+ };
@@ -1,11 +1,20 @@
1
- import type { PluginDatabaseConfig } from "./database";
1
+ import type { PluginCliDefinition } from "./cli";
2
2
  import type { PluginHooks } from "./hooks";
3
3
  import type { PluginManifest } from "./manifest";
4
+ import type { PluginTasks } from "./tasks";
5
+ export interface PluginModelConfig {
6
+ /** Host model family used when no explicit structured model id is configured. */
7
+ structuredModel?: "default" | "fast";
8
+ /** Host model id used for this plugin's structured model calls. */
9
+ structuredModelId?: string;
10
+ }
4
11
  export type PluginRegistrationInput = {
5
- database?: PluginDatabaseConfig;
12
+ cli?: PluginCliDefinition;
6
13
  hooks?: PluginHooks;
7
14
  manifest: PluginManifest;
15
+ model?: PluginModelConfig;
8
16
  packageName?: string;
17
+ tasks?: PluginTasks;
9
18
  };
10
19
  export interface PluginRegistration extends PluginRegistrationInput {
11
20
  }
package/dist/schemas.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { z } from "zod";
2
2
  export declare const nonBlankStringSchema: z.ZodString;
3
+ /** Runtime platform names supported by plugin public contracts. */
4
+ export declare const platformSchema: z.ZodEnum<{
5
+ slack: "slack";
6
+ local: "local";
7
+ }>;
8
+ /** Runtime source visibility visible to plugins. */
9
+ export declare const sourceTypeSchema: z.ZodEnum<{
10
+ pub: "pub";
11
+ priv: "priv";
12
+ }>;
3
13
  /** Runtime-owned Slack address for routing future work or side effects. */
4
14
  export declare const slackDestinationSchema: z.ZodObject<{
5
15
  platform: z.ZodLiteral<"slack">;
@@ -25,12 +35,17 @@ export declare const slackSourceSchema: z.ZodObject<{
25
35
  platform: z.ZodLiteral<"slack">;
26
36
  teamId: z.ZodString;
27
37
  channelId: z.ZodString;
38
+ type: z.ZodEnum<{
39
+ pub: "pub";
40
+ priv: "priv";
41
+ }>;
28
42
  messageTs: z.ZodOptional<z.ZodString>;
29
43
  threadTs: z.ZodOptional<z.ZodString>;
30
44
  }, z.core.$strict>;
31
45
  /** Runtime-owned local CLI coordinates for the inbound invocation. */
32
46
  export declare const localSourceSchema: z.ZodObject<{
33
47
  platform: z.ZodLiteral<"local">;
48
+ type: z.ZodLiteral<"priv">;
34
49
  conversationId: z.ZodString;
35
50
  }, z.core.$strict>;
36
51
  /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
@@ -38,10 +53,15 @@ export declare const sourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
53
  platform: z.ZodLiteral<"slack">;
39
54
  teamId: z.ZodString;
40
55
  channelId: z.ZodString;
56
+ type: z.ZodEnum<{
57
+ pub: "pub";
58
+ priv: "priv";
59
+ }>;
41
60
  messageTs: z.ZodOptional<z.ZodString>;
42
61
  threadTs: z.ZodOptional<z.ZodString>;
43
62
  }, z.core.$strict>, z.ZodObject<{
44
63
  platform: z.ZodLiteral<"local">;
64
+ type: z.ZodLiteral<"priv">;
45
65
  conversationId: z.ZodString;
46
66
  }, z.core.$strict>], "platform">;
47
67
  /** Stable user credential subject shape accepted from plugins. */
@@ -99,10 +119,15 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
99
119
  platform: z.ZodLiteral<"slack">;
100
120
  teamId: z.ZodString;
101
121
  channelId: z.ZodString;
122
+ type: z.ZodEnum<{
123
+ pub: "pub";
124
+ priv: "priv";
125
+ }>;
102
126
  messageTs: z.ZodOptional<z.ZodString>;
103
127
  threadTs: z.ZodOptional<z.ZodString>;
104
128
  }, z.core.$strict>, z.ZodObject<{
105
129
  platform: z.ZodLiteral<"local">;
130
+ type: z.ZodLiteral<"priv">;
106
131
  conversationId: z.ZodString;
107
132
  }, z.core.$strict>], "platform">;
108
133
  }, z.core.$strict>;
package/dist/state.d.ts CHANGED
@@ -8,13 +8,3 @@ export interface PluginState {
8
8
  export interface PluginReadState {
9
9
  get<T = unknown>(key: string): Promise<T | undefined>;
10
10
  }
11
- export interface PluginSessionStateAppend {
12
- key: string;
13
- value: unknown;
14
- }
15
- export interface PluginSessionState {
16
- list<T = unknown>(key: string): Promise<Array<{
17
- createdAtMs: number;
18
- value: T;
19
- }>>;
20
- }