@sentry/junior-plugin-api 0.75.0 → 0.76.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.
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Public plugin background-task contracts.
3
+ *
4
+ * Plugins register small task handlers, while Junior core owns durable
5
+ * scheduling, queue delivery, retries, and the bounded run projection.
6
+ */
7
+ import { z } from "zod";
8
+ import type { PluginContext, PluginEmbedder, PluginModel } from "./context";
9
+ import type { PluginState } from "./state";
10
+ /** One normalized transcript entry from the completed run exposed to plugin tasks. */
11
+ export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12
+ type: z.ZodLiteral<"message">;
13
+ role: z.ZodEnum<{
14
+ user: "user";
15
+ assistant: "assistant";
16
+ }>;
17
+ text: z.ZodString;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ type: z.ZodLiteral<"toolResult">;
20
+ toolName: z.ZodString;
21
+ isError: z.ZodBoolean;
22
+ text: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>], "type">;
24
+ /** Runtime-owned completed-run projection exposed to plugin tasks. */
25
+ export declare const pluginRunContextSchema: z.ZodObject<{
26
+ completedAtMs: z.ZodNumber;
27
+ conversationId: z.ZodString;
28
+ destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ platform: z.ZodLiteral<"slack">;
30
+ teamId: z.ZodString;
31
+ channelId: z.ZodString;
32
+ }, z.core.$strict>, z.ZodObject<{
33
+ platform: z.ZodLiteral<"local">;
34
+ conversationId: z.ZodString;
35
+ }, z.core.$strict>], "platform">;
36
+ requester: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
37
+ platform: z.ZodLiteral<"slack">;
38
+ teamId: z.ZodString;
39
+ email: z.ZodOptional<z.ZodString>;
40
+ fullName: z.ZodOptional<z.ZodString>;
41
+ userId: z.ZodString;
42
+ userName: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strict>, z.ZodObject<{
44
+ platform: z.ZodLiteral<"local">;
45
+ email: z.ZodOptional<z.ZodString>;
46
+ fullName: z.ZodOptional<z.ZodString>;
47
+ userId: z.ZodString;
48
+ userName: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strict>], "platform">>;
50
+ runId: z.ZodString;
51
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
52
+ platform: z.ZodLiteral<"slack">;
53
+ teamId: z.ZodString;
54
+ channelId: z.ZodString;
55
+ type: z.ZodEnum<{
56
+ pub: "pub";
57
+ priv: "priv";
58
+ }>;
59
+ messageTs: z.ZodOptional<z.ZodString>;
60
+ threadTs: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ platform: z.ZodLiteral<"local">;
63
+ type: z.ZodLiteral<"priv">;
64
+ conversationId: z.ZodString;
65
+ }, z.core.$strict>], "platform">;
66
+ transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
67
+ type: z.ZodLiteral<"message">;
68
+ role: z.ZodEnum<{
69
+ user: "user";
70
+ assistant: "assistant";
71
+ }>;
72
+ text: z.ZodString;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ type: z.ZodLiteral<"toolResult">;
75
+ toolName: z.ZodString;
76
+ isError: z.ZodBoolean;
77
+ text: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>], "type">>;
79
+ }, z.core.$strict>;
80
+ export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
81
+ export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
82
+ /** Runtime context passed to a plugin-owned background task. */
83
+ export interface PluginTaskContext extends PluginContext {
84
+ embedder: PluginEmbedder;
85
+ id: string;
86
+ model: PluginModel;
87
+ name: string;
88
+ run: {
89
+ load(): Promise<PluginRunContext>;
90
+ };
91
+ state: PluginState;
92
+ }
93
+ /** Plugin task handler registered by name in a plugin manifest module. */
94
+ export interface PluginTaskDefinition {
95
+ run(ctx: PluginTaskContext): Promise<void> | void;
96
+ }
97
+ /** Task handlers keyed by the plugin-owned task name. */
98
+ export type PluginTasks = Record<string, PluginTaskDefinition>;
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginContext, LocalInvocationContext, Requester, SlackInvocationContext } from "./context";
1
+ import type { PluginContext, LocalInvocationContext, PluginEmbedder, PluginModel, Requester, SlackInvocationContext } from "./context";
2
2
  import type { PluginCredentialSubject } from "./credentials";
3
3
  import type { PluginState } from "./state";
4
4
  export interface PluginEnv {
@@ -49,10 +49,17 @@ export interface BeforeToolExecuteHookContext extends PluginContext {
49
49
  name: string;
50
50
  };
51
51
  }
52
+ export interface PluginToolExecuteOptions {
53
+ /**
54
+ * @deprecated Internal compatibility escape hatch for legacy tool bridges.
55
+ * Plugin tools should use typed input fields and runtime hook context instead.
56
+ */
57
+ experimental_context?: unknown;
58
+ /** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
59
+ toolCallId?: string;
60
+ }
52
61
  export type PluginToolExecute<TInput = unknown> = {
53
- bivarianceHack(input: TInput, options: {
54
- experimental_context?: unknown;
55
- }): Promise<unknown> | unknown;
62
+ bivarianceHack(input: TInput, options: PluginToolExecuteOptions): Promise<unknown> | unknown;
56
63
  }["bivarianceHack"];
57
64
  export interface PluginToolDefinition<TInput = unknown> {
58
65
  annotations?: unknown;
@@ -94,6 +101,8 @@ interface BaseToolRegistrationHookContext extends PluginContext {
94
101
  * Do not parse as Slack unless the value starts with `slack:`.
95
102
  */
96
103
  conversationId?: string;
104
+ embedder: PluginEmbedder;
105
+ model: PluginModel;
97
106
  state: PluginState;
98
107
  userText?: string;
99
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,7 +22,7 @@
22
22
  "src"
23
23
  ],
24
24
  "dependencies": {
25
- "drizzle-orm": "^0.45.2",
25
+ "commander": "^14.0.3",
26
26
  "zod": "^4.4.3"
27
27
  },
28
28
  "devDependencies": {
package/src/cli.ts ADDED
@@ -0,0 +1,54 @@
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/context.ts CHANGED
@@ -1,19 +1,23 @@
1
1
  import { z } from "zod";
2
+ import type { ZodTypeAny } from "zod";
2
3
  import {
3
4
  destinationSchema,
4
5
  localRequesterSchema,
6
+ platformSchema,
5
7
  requesterSchema,
6
8
  slackRequesterSchema,
7
9
  sourceSchema,
8
10
  } from "./schemas";
9
- import type { PluginDb } from "./database";
10
11
 
12
+ /** Runtime platform name without source or destination coordinates. */
13
+ export type Platform = z.output<typeof platformSchema>;
11
14
  export type Requester = z.output<typeof requesterSchema>;
12
15
  export type SlackRequester = z.output<typeof slackRequesterSchema>;
13
16
  export type LocalRequester = z.output<typeof localRequesterSchema>;
14
17
  export type Source = z.output<typeof sourceSchema>;
15
18
  export type SlackSource = Extract<Source, { platform: "slack" }>;
16
19
  export type LocalSource = Extract<Source, { platform: "local" }>;
20
+ export type SourceType = Source["type"];
17
21
 
18
22
  export type Destination = z.output<typeof destinationSchema>;
19
23
 
@@ -31,9 +35,29 @@ export interface PluginLogger {
31
35
  warn(message: string, metadata?: Record<string, unknown>): void;
32
36
  }
33
37
 
38
+ export interface PluginModel {
39
+ /** Run a host-owned structured model call without exposing provider credentials. */
40
+ completeObject<TSchema extends ZodTypeAny>(input: {
41
+ maxTokens?: number;
42
+ prompt: string;
43
+ schema: TSchema;
44
+ system?: string;
45
+ }): Promise<{ object: z.infer<TSchema> }>;
46
+ }
47
+
48
+ export interface PluginEmbedder {
49
+ /** Embed plugin-owned text for derived retrieval without exposing provider credentials. */
50
+ embedTexts(input: { texts: string[] }): Promise<{
51
+ dimensions: number;
52
+ model: string;
53
+ provider: string;
54
+ vectors: number[][];
55
+ }>;
56
+ }
57
+
34
58
  export interface PluginContext {
35
- /** Shared database connection for plugins that declare database access. */
36
- db?: PluginDb;
59
+ /** Shared Drizzle database connection for plugin runtime code. */
60
+ db: unknown;
37
61
  log: PluginLogger;
38
62
  plugin: PluginMetadata;
39
63
  }
@@ -47,16 +71,16 @@ interface BaseInvocationContext {
47
71
  }
48
72
 
49
73
  export interface SlackInvocationContext extends BaseInvocationContext {
50
- /** Runtime-owned default outbound destination for this invocation, if any. */
51
- destination?: SlackDestination;
74
+ /** Runtime-owned default outbound destination for this invocation. */
75
+ destination: SlackDestination;
52
76
  requester?: SlackRequester;
53
77
  /** Runtime-owned source where the invocation came from. */
54
78
  source: SlackSource;
55
79
  }
56
80
 
57
81
  export interface LocalInvocationContext extends BaseInvocationContext {
58
- /** Runtime-owned default outbound destination for this invocation, if any. */
59
- destination?: LocalDestination;
82
+ /** Runtime-owned default outbound destination for this invocation. */
83
+ destination: LocalDestination;
60
84
  requester?: LocalRequester;
61
85
  /** Runtime-owned source where the invocation came from. */
62
86
  source: LocalSource;
@@ -64,6 +88,56 @@ export interface LocalInvocationContext extends BaseInvocationContext {
64
88
 
65
89
  export type InvocationContext = LocalInvocationContext | SlackInvocationContext;
66
90
 
91
+ /** Build a normalized Slack source from runtime-owned Slack coordinates. */
92
+ export function createSlackSource(input: {
93
+ channelId: string;
94
+ messageTs?: string;
95
+ teamId: string;
96
+ threadTs?: string;
97
+ }): SlackSource {
98
+ return {
99
+ platform: "slack",
100
+ type: slackSourceType(input.channelId),
101
+ teamId: input.teamId,
102
+ channelId: input.channelId,
103
+ ...(input.messageTs ? { messageTs: input.messageTs } : {}),
104
+ ...(input.threadTs ? { threadTs: input.threadTs } : {}),
105
+ };
106
+ }
107
+
108
+ /** Classify Slack's documented C/D/G channel id prefixes into source visibility. */
109
+ function slackSourceType(channelId: string): SourceType {
110
+ if (channelId.startsWith("C")) return "pub";
111
+ if (channelId.startsWith("D") || channelId.startsWith("G")) return "priv";
112
+ throw new Error(`Unsupported Slack channel ID prefix: ${channelId}`);
113
+ }
114
+
115
+ /** Build a normalized local source from a local conversation id. */
116
+ export function createLocalSource(conversationId: string): LocalSource {
117
+ return {
118
+ platform: "local",
119
+ type: "priv",
120
+ conversationId,
121
+ };
122
+ }
123
+
124
+ /** Return whether a source is private to a person or restricted group. */
125
+ export function isPrivateSource(source: Source): boolean {
126
+ return source.type === "priv";
127
+ }
128
+
129
+ /** Return the stable source identity used for idempotency and attribution. */
130
+ export function getSourceKey(source: Source): string | undefined {
131
+ if (source.platform === "local") {
132
+ return source.conversationId;
133
+ }
134
+ const messageKey = source.threadTs ?? source.messageTs;
135
+ if (!messageKey) {
136
+ return undefined;
137
+ }
138
+ return `slack:${source.teamId}:${source.channelId}:${messageKey}`;
139
+ }
140
+
67
141
  /** Narrow a runtime destination to the Slack-specific address shape. */
68
142
  export function isSlackDestination(
69
143
  destination: Destination | undefined,
@@ -27,6 +27,18 @@ export const pluginProviderAccountSchema = z
27
27
  })
28
28
  .strict();
29
29
 
30
+ /** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
31
+ export const pluginStoredTokensSchema = z
32
+ .object({
33
+ account: pluginProviderAccountSchema.optional(),
34
+ accessToken: nonBlankStringSchema,
35
+ expiresAt: z.number().finite().optional(),
36
+ refreshToken: nonBlankStringSchema,
37
+ refreshTokenExpiresAt: z.number().finite().optional(),
38
+ scope: nonBlankStringSchema.optional(),
39
+ })
40
+ .strict();
41
+
30
42
  /** Runtime schema for a plugin-defined outbound credential grant. */
31
43
  export const pluginGrantSchema = z
32
44
  .object({
@@ -169,17 +181,13 @@ export interface PluginResolvedCredentialUser {
169
181
  userId: string;
170
182
  }
171
183
 
172
- export interface PluginStoredTokens {
173
- account?: PluginProviderAccount;
174
- accessToken: string;
175
- expiresAt?: number;
176
- refreshToken: string;
177
- scope?: string;
178
- }
184
+ export type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
179
185
 
180
186
  export interface PluginUserTokenSlot {
181
187
  get(): Promise<PluginStoredTokens | undefined>;
182
188
  set(tokens: PluginStoredTokens): Promise<void>;
189
+ /** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
190
+ withRefresh<T>(callback: () => Promise<T>): Promise<T>;
183
191
  userId: string;
184
192
  }
185
193
 
package/src/hooks.ts CHANGED
@@ -25,8 +25,19 @@ import type {
25
25
  SandboxPrepareHookContext,
26
26
  ToolRegistrationHookContext,
27
27
  } from "./tools";
28
+ import type {
29
+ PromptMessage,
30
+ SystemPromptContext,
31
+ UserPromptContext,
32
+ } from "./prompt";
28
33
 
29
34
  export interface PluginHooks {
35
+ systemPrompt?(
36
+ ctx: SystemPromptContext,
37
+ ): Promise<PromptMessage[]> | PromptMessage[];
38
+ userPrompt?(
39
+ ctx: UserPromptContext,
40
+ ): Promise<PromptMessage[] | undefined> | PromptMessage[] | undefined;
30
41
  beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
31
42
  grantForEgress?(
32
43
  ctx: EgressHookContext,
package/src/index.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  export * from "./schemas";
2
2
  export * from "./context";
3
3
  export * from "./state";
4
+ export {
5
+ promptMessageSchema,
6
+ type PromptMessage,
7
+ type SystemPromptContext,
8
+ type UserPromptContext,
9
+ } from "./prompt";
4
10
  export * from "./dispatch";
5
- export * from "./database";
11
+ export * from "./tasks";
6
12
  export * from "./tools";
7
13
  export * from "./operations";
8
14
  export * from "./credentials";
9
15
  export * from "./hooks";
16
+ export * from "./cli";
10
17
  export * from "./manifest";
11
18
  export * from "./registration";
package/src/operations.ts CHANGED
@@ -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
 
@@ -48,7 +47,6 @@ export interface StorageMigrationResult {
48
47
  }
49
48
 
50
49
  export interface StorageMigrationContext extends PluginContext {
51
- db: PluginDb;
52
50
  state: PluginState;
53
51
  }
54
52
 
package/src/prompt.ts CHANGED
@@ -1,59 +1,38 @@
1
- import type { InvocationContext, PluginContext } from "./context";
1
+ import { z } from "zod";
2
2
  import type {
3
- PluginSessionState,
4
- PluginSessionStateAppend,
5
- PluginState,
6
- } from "./state";
7
-
8
- export interface UserPromptContribution {
9
- id: string;
10
- text: string;
11
- }
12
-
13
- export interface UserPromptContributionResult {
14
- contributions?: UserPromptContribution[];
15
- sessionState?: PluginSessionStateAppend[];
16
- }
17
-
18
- export type UserPromptHookContext = PluginContext &
19
- InvocationContext & {
20
- isFirstPrompt: boolean;
21
- session: PluginSessionState;
22
- state: PluginState;
23
- userText: string;
24
- };
25
-
26
- export interface PluginTaskEnqueueOptions {
27
- idempotencyKey: string;
28
- name: string;
29
- payload?: unknown;
30
- }
31
-
32
- export interface PluginTaskEnqueueResult {
33
- id: string;
34
- status: "created" | "already_exists";
35
- }
36
-
37
- export interface PluginTaskQueue {
38
- enqueue(options: PluginTaskEnqueueOptions): Promise<PluginTaskEnqueueResult>;
39
- }
40
-
41
- export type TurnObservationHookContext = PluginContext &
42
- InvocationContext & {
43
- observationId: string;
44
- tasks: PluginTaskQueue;
45
- };
46
-
47
- export interface PluginTaskContext extends PluginContext {
48
- id: string;
49
- name: string;
50
- observation?: {
51
- load(): Promise<unknown | undefined>;
52
- };
53
- payload?: unknown;
3
+ Destination,
4
+ Platform,
5
+ PluginContext,
6
+ PluginEmbedder,
7
+ Requester,
8
+ Source,
9
+ } from "./context";
10
+ import type { PluginState } from "./state";
11
+
12
+ export const promptMessageSchema = z
13
+ .object({
14
+ text: z.string().trim().min(1).max(8_000),
15
+ })
16
+ .strict();
17
+
18
+ /** Small plugin-owned prompt text block rendered by Junior core. */
19
+ export type PromptMessage = z.output<typeof promptMessageSchema>;
20
+
21
+ /** Stable platform context for plugin system prompt guidance. */
22
+ export type SystemPromptContext = Pick<
23
+ PluginContext,
24
+ "db" | "log" | "plugin"
25
+ > & {
26
+ platform: Platform;
27
+ };
28
+
29
+ /** Runtime facts available while building plugin user prompt context. */
30
+ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
31
+ conversationId?: string;
32
+ destination: Destination;
33
+ embedder: PluginEmbedder;
34
+ requester?: Requester;
35
+ source: Source;
54
36
  state: PluginState;
55
- }
56
-
57
- export type PluginTaskHandler = (
58
- ctx: PluginTaskContext,
59
- ) => Promise<void> | void;
37
+ text: string;
38
+ };
@@ -1,12 +1,22 @@
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
+
6
+ export interface PluginModelConfig {
7
+ /** Host model family used when no explicit structured model id is configured. */
8
+ structuredModel?: "default" | "fast";
9
+ /** Host model id used for this plugin's structured model calls. */
10
+ structuredModelId?: string;
11
+ }
4
12
 
5
13
  export type PluginRegistrationInput = {
6
- database?: PluginDatabaseConfig;
14
+ cli?: PluginCliDefinition;
7
15
  hooks?: PluginHooks;
8
16
  manifest: PluginManifest;
17
+ model?: PluginModelConfig;
9
18
  packageName?: string;
19
+ tasks?: PluginTasks;
10
20
  };
11
21
 
12
22
  export interface PluginRegistration extends PluginRegistrationInput {}
package/src/schemas.ts CHANGED
@@ -16,8 +16,13 @@ export const nonBlankStringSchema = z
16
16
  .string()
17
17
  .refine((value) => value.trim().length > 0);
18
18
 
19
- /** Runtime-owned Slack address for routing future work or side effects. */
20
- export const slackDestinationSchema = z
19
+ /** Runtime platform names supported by plugin public contracts. */
20
+ export const platformSchema = z.enum(["slack", "local"]);
21
+
22
+ /** Runtime source visibility visible to plugins. */
23
+ export const sourceTypeSchema = z.enum(["pub", "priv"]);
24
+
25
+ const slackAddressSchema = z
21
26
  .object({
22
27
  platform: z.literal("slack"),
23
28
  teamId: slackTeamIdSchema,
@@ -25,6 +30,9 @@ export const slackDestinationSchema = z
25
30
  })
26
31
  .strict();
27
32
 
33
+ /** Runtime-owned Slack address for routing future work or side effects. */
34
+ export const slackDestinationSchema = slackAddressSchema;
35
+
28
36
  /** Runtime-owned local CLI conversation address. */
29
37
  export const localDestinationSchema = z
30
38
  .object({
@@ -40,18 +48,22 @@ export const destinationSchema = z.discriminatedUnion("platform", [
40
48
  ]);
41
49
 
42
50
  /** Runtime-owned Slack coordinates for the inbound invocation. */
43
- export const slackSourceSchema = z
44
- .object({
45
- platform: z.literal("slack"),
46
- teamId: slackTeamIdSchema,
47
- channelId: slackConversationIdSchema,
51
+ export const slackSourceSchema = slackAddressSchema
52
+ .extend({
53
+ type: sourceTypeSchema,
48
54
  messageTs: nonBlankStringSchema.optional(),
49
55
  threadTs: nonBlankStringSchema.optional(),
50
56
  })
51
57
  .strict();
52
58
 
53
59
  /** Runtime-owned local CLI coordinates for the inbound invocation. */
54
- export const localSourceSchema = localDestinationSchema;
60
+ export const localSourceSchema = z
61
+ .object({
62
+ platform: z.literal("local"),
63
+ type: z.literal("priv"),
64
+ conversationId: localConversationIdSchema,
65
+ })
66
+ .strict();
55
67
 
56
68
  /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
57
69
  export const sourceSchema = z.discriminatedUnion("platform", [
package/src/state.ts CHANGED
@@ -13,14 +13,3 @@ export interface PluginState {
13
13
  export interface PluginReadState {
14
14
  get<T = unknown>(key: string): Promise<T | undefined>;
15
15
  }
16
-
17
- export interface PluginSessionStateAppend {
18
- key: string;
19
- value: unknown;
20
- }
21
-
22
- export interface PluginSessionState {
23
- list<T = unknown>(
24
- key: string,
25
- ): Promise<Array<{ createdAtMs: number; value: T }>>;
26
- }