@sentry/junior-plugin-api 0.91.0 → 0.92.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/context.d.ts +7 -6
- package/dist/credentials.d.ts +2 -2
- package/dist/index.js +40 -14
- package/dist/prompt.d.ts +2 -2
- package/dist/schemas.d.ts +11 -4
- package/dist/tasks.d.ts +98 -1
- package/dist/tools.d.ts +5 -3
- package/package.json +1 -1
- package/src/context.ts +10 -8
- package/src/credentials.ts +2 -2
- package/src/prompt.ts +2 -2
- package/src/schemas.ts +18 -10
- package/src/tasks.ts +33 -2
- package/src/tools.ts +5 -3
package/dist/context.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ZodTypeAny } from "zod";
|
|
3
|
-
import { destinationSchema,
|
|
3
|
+
import { destinationSchema, localActorSchema, platformSchema, actorSchema, slackActorSchema, systemActorSchema, sourceSchema } from "./schemas";
|
|
4
4
|
/** Runtime platform name without source or destination coordinates. */
|
|
5
5
|
export type Platform = z.output<typeof platformSchema>;
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
6
|
+
export type Actor = z.output<typeof actorSchema>;
|
|
7
|
+
export type SlackActor = z.output<typeof slackActorSchema>;
|
|
8
|
+
export type LocalActor = z.output<typeof localActorSchema>;
|
|
9
|
+
export type SystemActor = z.output<typeof systemActorSchema>;
|
|
9
10
|
export type Source = z.output<typeof sourceSchema>;
|
|
10
11
|
export type SlackSource = Extract<Source, {
|
|
11
12
|
platform: "slack";
|
|
@@ -67,14 +68,14 @@ interface BaseInvocationContext {
|
|
|
67
68
|
export interface SlackInvocationContext extends BaseInvocationContext {
|
|
68
69
|
/** Runtime-owned default outbound destination for this invocation. */
|
|
69
70
|
destination: SlackDestination;
|
|
70
|
-
|
|
71
|
+
actor?: SlackActor;
|
|
71
72
|
/** Runtime-owned source where the invocation came from. */
|
|
72
73
|
source: SlackSource;
|
|
73
74
|
}
|
|
74
75
|
export interface LocalInvocationContext extends BaseInvocationContext {
|
|
75
76
|
/** Runtime-owned default outbound destination for this invocation. */
|
|
76
77
|
destination: LocalDestination;
|
|
77
|
-
|
|
78
|
+
actor?: LocalActor;
|
|
78
79
|
/** Runtime-owned source where the invocation came from. */
|
|
79
80
|
source: LocalSource;
|
|
80
81
|
}
|
package/dist/credentials.d.ts
CHANGED
|
@@ -141,8 +141,8 @@ export type PluginCredentialHeaderTransform = z.output<typeof pluginCredentialHe
|
|
|
141
141
|
export type PluginCredentialLease = z.output<typeof pluginCredentialLeaseSchema>;
|
|
142
142
|
export type PluginCredentialResult = z.output<typeof pluginCredentialResultSchema>;
|
|
143
143
|
export type PluginCredentialActor = {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
platform: "system";
|
|
145
|
+
name: string;
|
|
146
146
|
} | {
|
|
147
147
|
type: "user";
|
|
148
148
|
userId: string;
|
package/dist/index.js
CHANGED
|
@@ -42,24 +42,29 @@ var pluginCredentialSubjectSchema = z.object({
|
|
|
42
42
|
userId: exactActorUserIdSchema,
|
|
43
43
|
allowedWhen: z.literal("private-direct-conversation")
|
|
44
44
|
}).strict();
|
|
45
|
-
var
|
|
45
|
+
var actorProfileSchema = {
|
|
46
46
|
email: nonBlankStringSchema.optional(),
|
|
47
47
|
fullName: nonBlankStringSchema.optional(),
|
|
48
48
|
userId: exactActorUserIdSchema,
|
|
49
49
|
userName: nonBlankStringSchema.optional()
|
|
50
50
|
};
|
|
51
|
-
var
|
|
52
|
-
...
|
|
51
|
+
var slackActorSchema = z.object({
|
|
52
|
+
...actorProfileSchema,
|
|
53
53
|
platform: z.literal("slack"),
|
|
54
54
|
teamId: slackTeamIdSchema
|
|
55
55
|
}).strict();
|
|
56
|
-
var
|
|
57
|
-
...
|
|
56
|
+
var localActorSchema = z.object({
|
|
57
|
+
...actorProfileSchema,
|
|
58
58
|
platform: z.literal("local")
|
|
59
59
|
}).strict();
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
var systemActorSchema = z.object({
|
|
61
|
+
platform: z.literal("system"),
|
|
62
|
+
name: exactActorUserIdSchema
|
|
63
|
+
}).strict();
|
|
64
|
+
var actorSchema = z.discriminatedUnion("platform", [
|
|
65
|
+
slackActorSchema,
|
|
66
|
+
localActorSchema,
|
|
67
|
+
systemActorSchema
|
|
63
68
|
]);
|
|
64
69
|
var dispatchMetadataSchema = z.record(z.string(), z.string()).superRefine((metadata, ctx) => {
|
|
65
70
|
const entries = Object.entries(metadata);
|
|
@@ -172,11 +177,17 @@ var subscribableResourceSchema = z3.object({
|
|
|
172
177
|
|
|
173
178
|
// src/tasks.ts
|
|
174
179
|
import { z as z4 } from "zod";
|
|
180
|
+
var pluginRunTranscriptProvenanceSchema = z4.object({
|
|
181
|
+
authority: z4.enum(["instruction", "context"]),
|
|
182
|
+
actor: actorSchema.optional()
|
|
183
|
+
}).strict();
|
|
175
184
|
var pluginRunTranscriptEntrySchema = z4.discriminatedUnion("type", [
|
|
176
185
|
z4.object({
|
|
177
186
|
type: z4.literal("message"),
|
|
178
187
|
role: z4.enum(["user", "assistant"]),
|
|
179
|
-
text: z4.string().min(1)
|
|
188
|
+
text: z4.string().min(1),
|
|
189
|
+
provenance: pluginRunTranscriptProvenanceSchema.optional(),
|
|
190
|
+
isRunActor: z4.boolean().optional()
|
|
180
191
|
}).strict(),
|
|
181
192
|
z4.object({
|
|
182
193
|
type: z4.literal("toolResult"),
|
|
@@ -189,7 +200,20 @@ var pluginRunContextSchema = z4.object({
|
|
|
189
200
|
completedAtMs: z4.number().finite(),
|
|
190
201
|
conversationId: z4.string().min(1),
|
|
191
202
|
destination: destinationSchema,
|
|
192
|
-
|
|
203
|
+
/**
|
|
204
|
+
* All distinct actors annotated on this run's committed instruction-authority
|
|
205
|
+
* messages, in first-seen order. Attribution provenance only, never an
|
|
206
|
+
* authority source: a plugin must not treat membership here as credential,
|
|
207
|
+
* subject, or scope ownership. Derived from full-run provenance, so it can
|
|
208
|
+
* exceed the actors visible in the transcript slice. Usually `[run.actor]`;
|
|
209
|
+
* possibly empty for system runs with no human instructions.
|
|
210
|
+
*/
|
|
211
|
+
actors: z4.array(actorSchema),
|
|
212
|
+
/**
|
|
213
|
+
* The single actor this run executes as. Absent only for actor-less legacy
|
|
214
|
+
* system records, so authority-sensitive plugins must fail closed.
|
|
215
|
+
*/
|
|
216
|
+
actor: actorSchema.optional(),
|
|
193
217
|
runId: z4.string().min(1),
|
|
194
218
|
source: sourceSchema,
|
|
195
219
|
transcript: z4.array(pluginRunTranscriptEntrySchema)
|
|
@@ -409,6 +433,7 @@ export {
|
|
|
409
433
|
EgressAuthRequired,
|
|
410
434
|
EgressPolicyDenied,
|
|
411
435
|
PluginToolInputError,
|
|
436
|
+
actorSchema,
|
|
412
437
|
createLocalSource,
|
|
413
438
|
createSlackSource,
|
|
414
439
|
defineJuniorPlugin,
|
|
@@ -418,8 +443,8 @@ export {
|
|
|
418
443
|
getSourceKey,
|
|
419
444
|
isPrivateSource,
|
|
420
445
|
isSlackDestination,
|
|
446
|
+
localActorSchema,
|
|
421
447
|
localDestinationSchema,
|
|
422
|
-
localRequesterSchema,
|
|
423
448
|
localSourceSchema,
|
|
424
449
|
nonBlankStringSchema,
|
|
425
450
|
platformSchema,
|
|
@@ -433,16 +458,17 @@ export {
|
|
|
433
458
|
pluginProviderAccountSchema,
|
|
434
459
|
pluginRunContextSchema,
|
|
435
460
|
pluginRunTranscriptEntrySchema,
|
|
461
|
+
pluginRunTranscriptProvenanceSchema,
|
|
436
462
|
pluginStoredTokensSchema,
|
|
437
463
|
pluginToolContinuationSchema,
|
|
438
464
|
pluginToolErrorSchema,
|
|
439
465
|
pluginToolResultSchema,
|
|
440
466
|
promptMessageSchema,
|
|
441
|
-
|
|
467
|
+
slackActorSchema,
|
|
442
468
|
slackDestinationSchema,
|
|
443
|
-
slackRequesterSchema,
|
|
444
469
|
slackSourceSchema,
|
|
445
470
|
sourceSchema,
|
|
446
471
|
sourceTypeSchema,
|
|
447
|
-
subscribableResourceSchema
|
|
472
|
+
subscribableResourceSchema,
|
|
473
|
+
systemActorSchema
|
|
448
474
|
};
|
package/dist/prompt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { Destination, Platform, PluginContext, PluginEmbedder,
|
|
2
|
+
import type { Destination, Platform, PluginContext, PluginEmbedder, Actor, Source } from "./context";
|
|
3
3
|
import type { PluginState } from "./state";
|
|
4
4
|
export declare const promptMessageSchema: z.ZodObject<{
|
|
5
5
|
text: z.ZodString;
|
|
@@ -15,7 +15,7 @@ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
15
15
|
conversationId?: string;
|
|
16
16
|
destination: Destination;
|
|
17
17
|
embedder: PluginEmbedder;
|
|
18
|
-
|
|
18
|
+
actor?: Actor;
|
|
19
19
|
source: Source;
|
|
20
20
|
state: PluginState;
|
|
21
21
|
text: string;
|
package/dist/schemas.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare const pluginCredentialSubjectSchema: z.ZodObject<{
|
|
|
70
70
|
userId: z.ZodString;
|
|
71
71
|
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
72
72
|
}, z.core.$strict>;
|
|
73
|
-
export declare const
|
|
73
|
+
export declare const slackActorSchema: z.ZodObject<{
|
|
74
74
|
platform: z.ZodLiteral<"slack">;
|
|
75
75
|
teamId: z.ZodString;
|
|
76
76
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -78,15 +78,19 @@ export declare const slackRequesterSchema: z.ZodObject<{
|
|
|
78
78
|
userId: z.ZodString;
|
|
79
79
|
userName: z.ZodOptional<z.ZodString>;
|
|
80
80
|
}, z.core.$strict>;
|
|
81
|
-
export declare const
|
|
81
|
+
export declare const localActorSchema: z.ZodObject<{
|
|
82
82
|
platform: z.ZodLiteral<"local">;
|
|
83
83
|
email: z.ZodOptional<z.ZodString>;
|
|
84
84
|
fullName: z.ZodOptional<z.ZodString>;
|
|
85
85
|
userId: z.ZodString;
|
|
86
86
|
userName: z.ZodOptional<z.ZodString>;
|
|
87
87
|
}, z.core.$strict>;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
export declare const systemActorSchema: z.ZodObject<{
|
|
89
|
+
platform: z.ZodLiteral<"system">;
|
|
90
|
+
name: z.ZodString;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
/** Runtime-provided actor identity visible to plugin hooks. */
|
|
93
|
+
export declare const actorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
90
94
|
platform: z.ZodLiteral<"slack">;
|
|
91
95
|
teamId: z.ZodString;
|
|
92
96
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -99,6 +103,9 @@ export declare const requesterSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
99
103
|
fullName: z.ZodOptional<z.ZodString>;
|
|
100
104
|
userId: z.ZodString;
|
|
101
105
|
userName: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
107
|
+
platform: z.ZodLiteral<"system">;
|
|
108
|
+
name: z.ZodString;
|
|
102
109
|
}, z.core.$strict>], "platform">;
|
|
103
110
|
/** Plugin dispatch request accepted by Junior core. */
|
|
104
111
|
export declare const dispatchOptionsSchema: z.ZodObject<{
|
package/dist/tasks.d.ts
CHANGED
|
@@ -7,6 +7,34 @@
|
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import type { PluginContext, PluginEmbedder, PluginModel } from "./context";
|
|
9
9
|
import type { PluginState } from "./state";
|
|
10
|
+
/**
|
|
11
|
+
* Runtime-owned provenance for a transcript message: whether it is a durable
|
|
12
|
+
* instruction or ambient context, plus the actor identity when known. Missing
|
|
13
|
+
* provenance on an entry means unattributed context.
|
|
14
|
+
*/
|
|
15
|
+
export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
|
|
16
|
+
authority: z.ZodEnum<{
|
|
17
|
+
instruction: "instruction";
|
|
18
|
+
context: "context";
|
|
19
|
+
}>;
|
|
20
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
21
|
+
platform: z.ZodLiteral<"slack">;
|
|
22
|
+
teamId: z.ZodString;
|
|
23
|
+
email: z.ZodOptional<z.ZodString>;
|
|
24
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
userId: z.ZodString;
|
|
26
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
28
|
+
platform: z.ZodLiteral<"local">;
|
|
29
|
+
email: z.ZodOptional<z.ZodString>;
|
|
30
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
31
|
+
userId: z.ZodString;
|
|
32
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
+
platform: z.ZodLiteral<"system">;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
}, z.core.$strict>], "platform">>;
|
|
37
|
+
}, z.core.$strict>;
|
|
10
38
|
/** One normalized transcript entry from the completed run exposed to plugin tasks. */
|
|
11
39
|
export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
40
|
type: z.ZodLiteral<"message">;
|
|
@@ -15,12 +43,37 @@ export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.
|
|
|
15
43
|
assistant: "assistant";
|
|
16
44
|
}>;
|
|
17
45
|
text: z.ZodString;
|
|
46
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
authority: z.ZodEnum<{
|
|
48
|
+
instruction: "instruction";
|
|
49
|
+
context: "context";
|
|
50
|
+
}>;
|
|
51
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
52
|
+
platform: z.ZodLiteral<"slack">;
|
|
53
|
+
teamId: z.ZodString;
|
|
54
|
+
email: z.ZodOptional<z.ZodString>;
|
|
55
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
56
|
+
userId: z.ZodString;
|
|
57
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
platform: z.ZodLiteral<"local">;
|
|
60
|
+
email: z.ZodOptional<z.ZodString>;
|
|
61
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
62
|
+
userId: z.ZodString;
|
|
63
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
65
|
+
platform: z.ZodLiteral<"system">;
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
}, z.core.$strict>], "platform">>;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
18
70
|
}, z.core.$strict>, z.ZodObject<{
|
|
19
71
|
type: z.ZodLiteral<"toolResult">;
|
|
20
72
|
toolName: z.ZodString;
|
|
21
73
|
isError: z.ZodBoolean;
|
|
22
74
|
text: z.ZodOptional<z.ZodString>;
|
|
23
75
|
}, z.core.$strict>], "type">;
|
|
76
|
+
export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
|
|
24
77
|
/** Runtime-owned completed-run projection exposed to plugin tasks. */
|
|
25
78
|
export declare const pluginRunContextSchema: z.ZodObject<{
|
|
26
79
|
completedAtMs: z.ZodNumber;
|
|
@@ -33,7 +86,7 @@ export declare const pluginRunContextSchema: z.ZodObject<{
|
|
|
33
86
|
platform: z.ZodLiteral<"local">;
|
|
34
87
|
conversationId: z.ZodString;
|
|
35
88
|
}, z.core.$strict>], "platform">;
|
|
36
|
-
|
|
89
|
+
actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
37
90
|
platform: z.ZodLiteral<"slack">;
|
|
38
91
|
teamId: z.ZodString;
|
|
39
92
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -46,6 +99,26 @@ export declare const pluginRunContextSchema: z.ZodObject<{
|
|
|
46
99
|
fullName: z.ZodOptional<z.ZodString>;
|
|
47
100
|
userId: z.ZodString;
|
|
48
101
|
userName: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
103
|
+
platform: z.ZodLiteral<"system">;
|
|
104
|
+
name: z.ZodString;
|
|
105
|
+
}, z.core.$strict>], "platform">>;
|
|
106
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
107
|
+
platform: z.ZodLiteral<"slack">;
|
|
108
|
+
teamId: z.ZodString;
|
|
109
|
+
email: z.ZodOptional<z.ZodString>;
|
|
110
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
111
|
+
userId: z.ZodString;
|
|
112
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
114
|
+
platform: z.ZodLiteral<"local">;
|
|
115
|
+
email: z.ZodOptional<z.ZodString>;
|
|
116
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
117
|
+
userId: z.ZodString;
|
|
118
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
120
|
+
platform: z.ZodLiteral<"system">;
|
|
121
|
+
name: z.ZodString;
|
|
49
122
|
}, z.core.$strict>], "platform">>;
|
|
50
123
|
runId: z.ZodString;
|
|
51
124
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -70,6 +143,30 @@ export declare const pluginRunContextSchema: z.ZodObject<{
|
|
|
70
143
|
assistant: "assistant";
|
|
71
144
|
}>;
|
|
72
145
|
text: z.ZodString;
|
|
146
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
147
|
+
authority: z.ZodEnum<{
|
|
148
|
+
instruction: "instruction";
|
|
149
|
+
context: "context";
|
|
150
|
+
}>;
|
|
151
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
152
|
+
platform: z.ZodLiteral<"slack">;
|
|
153
|
+
teamId: z.ZodString;
|
|
154
|
+
email: z.ZodOptional<z.ZodString>;
|
|
155
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
156
|
+
userId: z.ZodString;
|
|
157
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
158
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
159
|
+
platform: z.ZodLiteral<"local">;
|
|
160
|
+
email: z.ZodOptional<z.ZodString>;
|
|
161
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
162
|
+
userId: z.ZodString;
|
|
163
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
165
|
+
platform: z.ZodLiteral<"system">;
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
}, z.core.$strict>], "platform">>;
|
|
168
|
+
}, z.core.$strict>>;
|
|
169
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
73
170
|
}, z.core.$strict>, z.ZodObject<{
|
|
74
171
|
type: z.ZodLiteral<"toolResult">;
|
|
75
172
|
toolName: z.ZodString;
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginContext, LocalInvocationContext, PluginEmbedder, PluginModel,
|
|
1
|
+
import type { PluginContext, LocalInvocationContext, PluginEmbedder, PluginModel, Actor, SlackInvocationContext } from "./context";
|
|
2
2
|
import type { PluginCredentialSubject } from "./credentials";
|
|
3
3
|
import type { PluginState } from "./state";
|
|
4
4
|
import { z, type ZodType, type ZodTypeAny } from "zod";
|
|
@@ -52,13 +52,15 @@ export interface PluginEgress {
|
|
|
52
52
|
}): Promise<Response>;
|
|
53
53
|
}
|
|
54
54
|
export interface SandboxPrepareHookContext extends PluginContext {
|
|
55
|
-
|
|
55
|
+
actor?: Actor;
|
|
56
56
|
sandbox: PluginSandbox;
|
|
57
57
|
}
|
|
58
58
|
export interface BeforeToolExecuteHookContext extends PluginContext {
|
|
59
59
|
decision: PluginDecision;
|
|
60
60
|
env: PluginEnv;
|
|
61
|
-
|
|
61
|
+
actor?: Actor;
|
|
62
|
+
/** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
|
|
63
|
+
actors?: Actor[];
|
|
62
64
|
tool: {
|
|
63
65
|
input: Record<string, unknown>;
|
|
64
66
|
name: string;
|
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -2,18 +2,20 @@ import { z } from "zod";
|
|
|
2
2
|
import type { ZodTypeAny } from "zod";
|
|
3
3
|
import {
|
|
4
4
|
destinationSchema,
|
|
5
|
-
|
|
5
|
+
localActorSchema,
|
|
6
6
|
platformSchema,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
actorSchema,
|
|
8
|
+
slackActorSchema,
|
|
9
|
+
systemActorSchema,
|
|
9
10
|
sourceSchema,
|
|
10
11
|
} from "./schemas";
|
|
11
12
|
|
|
12
13
|
/** Runtime platform name without source or destination coordinates. */
|
|
13
14
|
export type Platform = z.output<typeof platformSchema>;
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
15
|
+
export type Actor = z.output<typeof actorSchema>;
|
|
16
|
+
export type SlackActor = z.output<typeof slackActorSchema>;
|
|
17
|
+
export type LocalActor = z.output<typeof localActorSchema>;
|
|
18
|
+
export type SystemActor = z.output<typeof systemActorSchema>;
|
|
17
19
|
export type Source = z.output<typeof sourceSchema>;
|
|
18
20
|
export type SlackSource = Extract<Source, { platform: "slack" }>;
|
|
19
21
|
export type LocalSource = Extract<Source, { platform: "local" }>;
|
|
@@ -73,7 +75,7 @@ interface BaseInvocationContext {
|
|
|
73
75
|
export interface SlackInvocationContext extends BaseInvocationContext {
|
|
74
76
|
/** Runtime-owned default outbound destination for this invocation. */
|
|
75
77
|
destination: SlackDestination;
|
|
76
|
-
|
|
78
|
+
actor?: SlackActor;
|
|
77
79
|
/** Runtime-owned source where the invocation came from. */
|
|
78
80
|
source: SlackSource;
|
|
79
81
|
}
|
|
@@ -81,7 +83,7 @@ export interface SlackInvocationContext extends BaseInvocationContext {
|
|
|
81
83
|
export interface LocalInvocationContext extends BaseInvocationContext {
|
|
82
84
|
/** Runtime-owned default outbound destination for this invocation. */
|
|
83
85
|
destination: LocalDestination;
|
|
84
|
-
|
|
86
|
+
actor?: LocalActor;
|
|
85
87
|
/** Runtime-owned source where the invocation came from. */
|
|
86
88
|
source: LocalSource;
|
|
87
89
|
}
|
package/src/credentials.ts
CHANGED
package/src/prompt.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
Platform,
|
|
5
5
|
PluginContext,
|
|
6
6
|
PluginEmbedder,
|
|
7
|
-
|
|
7
|
+
Actor,
|
|
8
8
|
Source,
|
|
9
9
|
} from "./context";
|
|
10
10
|
import type { PluginState } from "./state";
|
|
@@ -31,7 +31,7 @@ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
31
31
|
conversationId?: string;
|
|
32
32
|
destination: Destination;
|
|
33
33
|
embedder: PluginEmbedder;
|
|
34
|
-
|
|
34
|
+
actor?: Actor;
|
|
35
35
|
source: Source;
|
|
36
36
|
state: PluginState;
|
|
37
37
|
text: string;
|
package/src/schemas.ts
CHANGED
|
@@ -80,33 +80,41 @@ export const pluginCredentialSubjectSchema = z
|
|
|
80
80
|
})
|
|
81
81
|
.strict();
|
|
82
82
|
|
|
83
|
-
/** Shared exact actor profile fields for platform-scoped
|
|
84
|
-
const
|
|
83
|
+
/** Shared exact actor profile fields for platform-scoped actors. */
|
|
84
|
+
const actorProfileSchema = {
|
|
85
85
|
email: nonBlankStringSchema.optional(),
|
|
86
86
|
fullName: nonBlankStringSchema.optional(),
|
|
87
87
|
userId: exactActorUserIdSchema,
|
|
88
88
|
userName: nonBlankStringSchema.optional(),
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export const
|
|
91
|
+
export const slackActorSchema = z
|
|
92
92
|
.object({
|
|
93
|
-
...
|
|
93
|
+
...actorProfileSchema,
|
|
94
94
|
platform: z.literal("slack"),
|
|
95
95
|
teamId: slackTeamIdSchema,
|
|
96
96
|
})
|
|
97
97
|
.strict();
|
|
98
98
|
|
|
99
|
-
export const
|
|
99
|
+
export const localActorSchema = z
|
|
100
100
|
.object({
|
|
101
|
-
...
|
|
101
|
+
...actorProfileSchema,
|
|
102
102
|
platform: z.literal("local"),
|
|
103
103
|
})
|
|
104
104
|
.strict();
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
export const systemActorSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
platform: z.literal("system"),
|
|
109
|
+
name: exactActorUserIdSchema,
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
|
|
113
|
+
/** Runtime-provided actor identity visible to plugin hooks. */
|
|
114
|
+
export const actorSchema = z.discriminatedUnion("platform", [
|
|
115
|
+
slackActorSchema,
|
|
116
|
+
localActorSchema,
|
|
117
|
+
systemActorSchema,
|
|
110
118
|
]);
|
|
111
119
|
|
|
112
120
|
const dispatchMetadataSchema = z
|
package/src/tasks.ts
CHANGED
|
@@ -6,9 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import type { PluginContext, PluginEmbedder, PluginModel } from "./context";
|
|
9
|
-
import { destinationSchema,
|
|
9
|
+
import { destinationSchema, actorSchema, sourceSchema } from "./schemas";
|
|
10
10
|
import type { PluginState } from "./state";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Runtime-owned provenance for a transcript message: whether it is a durable
|
|
14
|
+
* instruction or ambient context, plus the actor identity when known. Missing
|
|
15
|
+
* provenance on an entry means unattributed context.
|
|
16
|
+
*/
|
|
17
|
+
export const pluginRunTranscriptProvenanceSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
authority: z.enum(["instruction", "context"]),
|
|
20
|
+
actor: actorSchema.optional(),
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
|
|
12
24
|
/** One normalized transcript entry from the completed run exposed to plugin tasks. */
|
|
13
25
|
export const pluginRunTranscriptEntrySchema = z.discriminatedUnion("type", [
|
|
14
26
|
z
|
|
@@ -16,6 +28,8 @@ export const pluginRunTranscriptEntrySchema = z.discriminatedUnion("type", [
|
|
|
16
28
|
type: z.literal("message"),
|
|
17
29
|
role: z.enum(["user", "assistant"]),
|
|
18
30
|
text: z.string().min(1),
|
|
31
|
+
provenance: pluginRunTranscriptProvenanceSchema.optional(),
|
|
32
|
+
isRunActor: z.boolean().optional(),
|
|
19
33
|
})
|
|
20
34
|
.strict(),
|
|
21
35
|
z
|
|
@@ -28,13 +42,30 @@ export const pluginRunTranscriptEntrySchema = z.discriminatedUnion("type", [
|
|
|
28
42
|
.strict(),
|
|
29
43
|
]);
|
|
30
44
|
|
|
45
|
+
export type PluginRunTranscriptProvenance = z.output<
|
|
46
|
+
typeof pluginRunTranscriptProvenanceSchema
|
|
47
|
+
>;
|
|
48
|
+
|
|
31
49
|
/** Runtime-owned completed-run projection exposed to plugin tasks. */
|
|
32
50
|
export const pluginRunContextSchema = z
|
|
33
51
|
.object({
|
|
34
52
|
completedAtMs: z.number().finite(),
|
|
35
53
|
conversationId: z.string().min(1),
|
|
36
54
|
destination: destinationSchema,
|
|
37
|
-
|
|
55
|
+
/**
|
|
56
|
+
* All distinct actors annotated on this run's committed instruction-authority
|
|
57
|
+
* messages, in first-seen order. Attribution provenance only, never an
|
|
58
|
+
* authority source: a plugin must not treat membership here as credential,
|
|
59
|
+
* subject, or scope ownership. Derived from full-run provenance, so it can
|
|
60
|
+
* exceed the actors visible in the transcript slice. Usually `[run.actor]`;
|
|
61
|
+
* possibly empty for system runs with no human instructions.
|
|
62
|
+
*/
|
|
63
|
+
actors: z.array(actorSchema),
|
|
64
|
+
/**
|
|
65
|
+
* The single actor this run executes as. Absent only for actor-less legacy
|
|
66
|
+
* system records, so authority-sensitive plugins must fail closed.
|
|
67
|
+
*/
|
|
68
|
+
actor: actorSchema.optional(),
|
|
38
69
|
runId: z.string().min(1),
|
|
39
70
|
source: sourceSchema,
|
|
40
71
|
transcript: z.array(pluginRunTranscriptEntrySchema),
|
package/src/tools.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
LocalInvocationContext,
|
|
4
4
|
PluginEmbedder,
|
|
5
5
|
PluginModel,
|
|
6
|
-
|
|
6
|
+
Actor,
|
|
7
7
|
SlackInvocationContext,
|
|
8
8
|
} from "./context";
|
|
9
9
|
import type { PluginCredentialSubject } from "./credentials";
|
|
@@ -66,14 +66,16 @@ export interface PluginEgress {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface SandboxPrepareHookContext extends PluginContext {
|
|
69
|
-
|
|
69
|
+
actor?: Actor;
|
|
70
70
|
sandbox: PluginSandbox;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface BeforeToolExecuteHookContext extends PluginContext {
|
|
74
74
|
decision: PluginDecision;
|
|
75
75
|
env: PluginEnv;
|
|
76
|
-
|
|
76
|
+
actor?: Actor;
|
|
77
|
+
/** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
|
|
78
|
+
actors?: Actor[];
|
|
77
79
|
tool: {
|
|
78
80
|
input: Record<string, unknown>;
|
|
79
81
|
name: string;
|