@ericsanchezok/synergy-plugin 2.4.4 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/display.d.ts +1 -0
- package/dist/example.d.ts +1 -1
- package/dist/example.js +1 -1
- package/dist/hooks.js +3 -3
- package/dist/index.d.ts +42 -17
- package/dist/index.js +6 -6
- package/dist/manifest.d.ts +7 -0
- package/dist/manifest.js +2 -0
- package/dist/permissions.d.ts +3 -2
- package/dist/spec.d.ts +1 -1
- package/dist/tool.d.ts +3 -3
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -102,6 +102,7 @@ const mediaDisplay = {
|
|
|
102
102
|
media: {
|
|
103
103
|
type: "image",
|
|
104
104
|
aspectRatio: "1:1",
|
|
105
|
+
size: "small",
|
|
105
106
|
},
|
|
106
107
|
} as const
|
|
107
108
|
|
|
@@ -165,6 +166,69 @@ const plan = await context.task?.run({
|
|
|
165
166
|
|
|
166
167
|
When `output.mode` is `structured`, Cortex validates the child task result against the schema and may run repair turns before completing. Cortex still stores its normal task trajectory summary in `task.result`; the structured value is returned to the plugin call site as `plan.outputResult.data`.
|
|
167
168
|
|
|
169
|
+
## Hooks
|
|
170
|
+
|
|
171
|
+
Plugins return hooks from `init()`. Hook permissions are declared in `plugin.json` and Synergy only invokes permissioned hooks.
|
|
172
|
+
|
|
173
|
+
### Event hook
|
|
174
|
+
|
|
175
|
+
`event(input)` observes runtime bus events without mutating them. Declare event access under `permissions.hooks`:
|
|
176
|
+
|
|
177
|
+
```jsonc
|
|
178
|
+
{
|
|
179
|
+
"permissions": {
|
|
180
|
+
"hooks": {
|
|
181
|
+
"events": "selected",
|
|
182
|
+
"eventNames": ["session.*", "message.updated"],
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`events` is `"none"`, `"selected"`, or `"all"`. In selected mode, `eventNames` supports exact names, `*` for all events, and prefix wildcards ending in `.*` such as `session.*`.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
event(input) {
|
|
192
|
+
console.log(input.event.type, input.event.properties)
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Config hook
|
|
197
|
+
|
|
198
|
+
`config(input, output)` observes a redacted runtime config snapshot at startup, plugin reload, and config reload. Declare `permissions.hooks.config: true`; this permission is separate from `permissions.data.config`.
|
|
199
|
+
|
|
200
|
+
```jsonc
|
|
201
|
+
{
|
|
202
|
+
"permissions": {
|
|
203
|
+
"hooks": {
|
|
204
|
+
"config": true,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
config(input, output) {
|
|
212
|
+
console.log(input.source, input.changedFields)
|
|
213
|
+
console.log(output.config.model)
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`input.source` is `"startup"`, `"plugin_reload"`, or `"reload"`. Secret fields in `output.config` are replaced with Synergy's redacted sentinel before dispatch.
|
|
218
|
+
|
|
219
|
+
### System prompt transform
|
|
220
|
+
|
|
221
|
+
`experimental.chat.system.transform(input, output)` can rewrite the assembled system prompt when `permissions.hooks.promptTransform` is `true`. Synergy calls this hook in two phases: `input.phase === "budget"` before token budgeting and `input.phase === "final"` before the provider call. The input includes `sessionID`, `agent`, `model`, `messageID`, and `small` for final calls.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
"experimental.chat.system.transform"(input, output) {
|
|
225
|
+
if (input.phase !== "final") return
|
|
226
|
+
output.system.push("Additional final-call instruction.")
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
If a transform empties `output.system`, Synergy restores the original system prompt.
|
|
231
|
+
|
|
168
232
|
## Plugin Input
|
|
169
233
|
|
|
170
234
|
`init(input)` receives runtime services scoped to the active Synergy Scope:
|
package/dist/display.d.ts
CHANGED
package/dist/example.d.ts
CHANGED
package/dist/example.js
CHANGED
package/dist/hooks.js
CHANGED
|
@@ -21,13 +21,13 @@ export const HOOKS = [
|
|
|
21
21
|
name: "config",
|
|
22
22
|
category: "core",
|
|
23
23
|
mutatesOutput: false,
|
|
24
|
-
summary: "Observe
|
|
24
|
+
summary: "Observe redacted runtime config snapshots at startup and config reload",
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
name: "event",
|
|
28
28
|
category: "core",
|
|
29
29
|
mutatesOutput: false,
|
|
30
|
-
summary: "Observe runtime bus events",
|
|
30
|
+
summary: "Observe permitted runtime bus events by exact or wildcard event name",
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
name: "chat.message",
|
|
@@ -153,7 +153,7 @@ export const HOOKS = [
|
|
|
153
153
|
name: "experimental.chat.system.transform",
|
|
154
154
|
category: "experimental",
|
|
155
155
|
mutatesOutput: true,
|
|
156
|
-
summary: "Rewrite the assembled system prompt",
|
|
156
|
+
summary: "Rewrite the assembled system prompt during budget and final phases",
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
159
|
name: "experimental.session.compacting",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { AgendaItem, AgendaRunLog, CortexTask,
|
|
2
|
-
import type { BunShell } from "./shell";
|
|
3
|
-
import type { ToolDefinition, ToolResult } from "./tool";
|
|
4
|
-
export * from "./tool";
|
|
5
|
-
export type { ToolDisplay, ToolMediaDisplay } from "./display";
|
|
1
|
+
import type { AgendaItem, AgendaRunLog, CortexTask, createSynergyClient, MemoryCategory, MemoryRecallMode, MemorySearchResult, Model, NoteCreateInput, NoteInfo, NotePatchInput, Provider, PermissionRequest, UserMessage, Message, Part, Auth, Config } from "@ericsanchezok/synergy-sdk";
|
|
2
|
+
import type { BunShell } from "./shell.js";
|
|
3
|
+
import type { ToolDefinition, ToolResult } from "./tool.js";
|
|
4
|
+
export * from "./tool.js";
|
|
5
|
+
export type { ToolDisplay, ToolMediaDisplay } from "./display.js";
|
|
6
6
|
export type { ToolResult };
|
|
7
|
-
export * from "./manifest";
|
|
8
|
-
export * from "./policy";
|
|
9
|
-
export * from "./spec";
|
|
10
|
-
export * from "./version";
|
|
11
|
-
export * from "./artifact";
|
|
12
|
-
export type { BunShell, BunShellOutput, BunShellPromise, ShellExpression, ShellFunction } from "./shell";
|
|
7
|
+
export * from "./manifest.js";
|
|
8
|
+
export * from "./policy.js";
|
|
9
|
+
export * from "./spec.js";
|
|
10
|
+
export * from "./version.js";
|
|
11
|
+
export * from "./artifact.js";
|
|
12
|
+
export type { BunShell, BunShellOutput, BunShellPromise, ShellExpression, ShellFunction } from "./shell.js";
|
|
13
13
|
export interface PluginConfigAccessor {
|
|
14
14
|
/** Get the plugin's full config object */
|
|
15
15
|
get(): Promise<Record<string, any>>;
|
|
@@ -367,6 +367,33 @@ export interface PluginDescriptor {
|
|
|
367
367
|
/** Initialize the plugin and return hooks */
|
|
368
368
|
init(input: PluginInput): Promise<PluginHooks>;
|
|
369
369
|
}
|
|
370
|
+
export interface PluginEventHookInput {
|
|
371
|
+
event: {
|
|
372
|
+
type: string;
|
|
373
|
+
properties: unknown;
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
export interface PluginConfigHookInput {
|
|
377
|
+
source: "startup" | "reload" | "plugin_reload";
|
|
378
|
+
scopeID?: string;
|
|
379
|
+
scopeType?: string;
|
|
380
|
+
changedFields?: string[];
|
|
381
|
+
timestamp: number;
|
|
382
|
+
}
|
|
383
|
+
export interface PluginConfigHookOutput {
|
|
384
|
+
config: Config;
|
|
385
|
+
}
|
|
386
|
+
export interface PluginChatSystemTransformInput {
|
|
387
|
+
phase: "budget" | "final";
|
|
388
|
+
sessionID: string;
|
|
389
|
+
agent: string;
|
|
390
|
+
model: {
|
|
391
|
+
providerID: string;
|
|
392
|
+
modelID: string;
|
|
393
|
+
};
|
|
394
|
+
messageID?: string;
|
|
395
|
+
small?: boolean;
|
|
396
|
+
}
|
|
370
397
|
export interface PluginHooks {
|
|
371
398
|
/** Called when the plugin is being unloaded (e.g. runtime reload) */
|
|
372
399
|
dispose?(): Promise<void>;
|
|
@@ -383,11 +410,9 @@ export interface PluginHooks {
|
|
|
383
410
|
/** Provider runtime/catalog profiles */
|
|
384
411
|
provider?: ProviderProfileHook | ProviderProfileHook[];
|
|
385
412
|
/** Observe runtime bus events */
|
|
386
|
-
event?(input:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
/** Observe the loaded runtime config */
|
|
390
|
-
config?(input: Config): Promise<void>;
|
|
413
|
+
event?(input: PluginEventHookInput): Promise<void>;
|
|
414
|
+
/** Observe a redacted runtime config snapshot */
|
|
415
|
+
config?(input: PluginConfigHookInput, output: PluginConfigHookOutput): Promise<void>;
|
|
391
416
|
/** Rewrite incoming user messages */
|
|
392
417
|
"chat.message"?(input: {
|
|
393
418
|
sessionID: string;
|
|
@@ -445,7 +470,7 @@ export interface PluginHooks {
|
|
|
445
470
|
}[];
|
|
446
471
|
}): Promise<void>;
|
|
447
472
|
/** Rewrite the assembled system prompt */
|
|
448
|
-
"experimental.chat.system.transform"?(input:
|
|
473
|
+
"experimental.chat.system.transform"?(input: PluginChatSystemTransformInput, output: {
|
|
449
474
|
system: string[];
|
|
450
475
|
}): Promise<void>;
|
|
451
476
|
/** Customize session compaction */
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./tool";
|
|
2
|
-
export * from "./manifest";
|
|
3
|
-
export * from "./policy";
|
|
4
|
-
export * from "./spec";
|
|
5
|
-
export * from "./version";
|
|
6
|
-
export * from "./artifact";
|
|
1
|
+
export * from "./tool.js";
|
|
2
|
+
export * from "./manifest.js";
|
|
3
|
+
export * from "./policy.js";
|
|
4
|
+
export * from "./spec.js";
|
|
5
|
+
export * from "./version.js";
|
|
6
|
+
export * from "./artifact.js";
|
package/dist/manifest.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
88
88
|
selected: "selected";
|
|
89
89
|
}>>;
|
|
90
90
|
eventNames: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
91
|
+
config: z.ZodDefault<z.ZodBoolean>;
|
|
91
92
|
toolExecute: z.ZodDefault<z.ZodEnum<{
|
|
92
93
|
all: "all";
|
|
93
94
|
none: "none";
|
|
@@ -151,6 +152,11 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
151
152
|
"16:9": "16:9";
|
|
152
153
|
auto: "auto";
|
|
153
154
|
}>>;
|
|
155
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
156
|
+
small: "small";
|
|
157
|
+
medium: "medium";
|
|
158
|
+
large: "large";
|
|
159
|
+
}>>;
|
|
154
160
|
}, z.core.$strict>>;
|
|
155
161
|
}, z.core.$strict>>;
|
|
156
162
|
capabilities: z.ZodOptional<z.ZodObject<{
|
|
@@ -403,6 +409,7 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
403
409
|
selected: "selected";
|
|
404
410
|
}>>;
|
|
405
411
|
eventNames: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
412
|
+
config: z.ZodDefault<z.ZodBoolean>;
|
|
406
413
|
toolExecute: z.ZodDefault<z.ZodEnum<{
|
|
407
414
|
all: "all";
|
|
408
415
|
none: "none";
|
package/dist/manifest.js
CHANGED
|
@@ -142,6 +142,7 @@ const ToolDisplayDef = z
|
|
|
142
142
|
pendingTitle: z.string().min(1).max(120).optional(),
|
|
143
143
|
pendingDescription: z.string().min(1).max(200).optional(),
|
|
144
144
|
aspectRatio: z.enum(["1:1", "4:3", "16:9", "auto"]).optional(),
|
|
145
|
+
size: z.enum(["small", "medium", "large"]).optional(),
|
|
145
146
|
})
|
|
146
147
|
.strict()
|
|
147
148
|
.optional(),
|
|
@@ -228,6 +229,7 @@ const PluginPermissionsSchema = z
|
|
|
228
229
|
.object({
|
|
229
230
|
events: z.enum(["none", "selected", "all"]).default("selected"),
|
|
230
231
|
eventNames: z.array(z.string()).default([]),
|
|
232
|
+
config: z.boolean().default(false),
|
|
231
233
|
toolExecute: z.enum(["none", "own", "declared", "all"]).default("own"),
|
|
232
234
|
permissionAsk: z.enum(["none", "own", "all"]).default("none"),
|
|
233
235
|
promptTransform: z.boolean().default(false),
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginManifest } from "./manifest";
|
|
1
|
+
import type { PluginManifest } from "./manifest.js";
|
|
2
2
|
import type { BridgeMethodPolicy, RegistryPermissionItem, SynergyCapabilityCategory, SynergyCapabilityDefinition, SynergyCapabilityPermissionItem, SynergyCapabilityRisk, SynergyCapabilityRiskScope, SynergyCapabilitySeverity } from "@ericsanchezok/synergy-util/capability";
|
|
3
3
|
import { bridgeMethodPolicy as sharedBridgeMethodPolicy, capabilityNonBypassable, hasPublicTools, permissionCategoryForKey, permissionCapability, publicToolNames, stablePluginJson } from "@ericsanchezok/synergy-util/capability";
|
|
4
4
|
export type PluginRisk = SynergyCapabilityRisk;
|
|
@@ -11,7 +11,7 @@ export type PluginBridgeMethodPolicy = BridgeMethodPolicy;
|
|
|
11
11
|
export type { RegistryPermissionItem, SynergyCapabilityDefinition };
|
|
12
12
|
export type ManifestTool = NonNullable<NonNullable<PluginManifest["contributes"]>["tools"]>[number];
|
|
13
13
|
export declare const CAPABILITY_DETAILS: Record<string, SynergyCapabilityDefinition>;
|
|
14
|
-
export declare const PROFILE_CAPABILITIES: readonly ["file_read", "file_write", "shell_read", "shell", "shell_remote_write", "shell_remote_publish", "shell_destructive", "shell_hardline", "file_external_read", "file_external_write", "network_read", "network_request", "mcp_invoke", "mcp_spawn", "session_data", "workspace_data", "config:read", "config:write", "secrets", "task", "prompt_transform", "compaction_transform", "tool_execution_hook", "permission_hook", "event_hook", "identity_act", "communication_email", "channel_outbound", "platform_control", "protected_op", "session_state", "browser_interact", "browser_inspect", "browser_eval_readonly", "browser_eval_trusted", "browser_clipboard", "browser_download", "browser_viewport"];
|
|
14
|
+
export declare const PROFILE_CAPABILITIES: readonly ["file_read", "file_write", "shell_read", "shell", "shell_remote_write", "shell_remote_publish", "shell_destructive", "shell_hardline", "file_external_read", "file_external_write", "network_read", "network_request", "mcp_invoke", "mcp_spawn", "session_data", "workspace_data", "config:read", "config:write", "secrets", "task", "prompt_transform", "compaction_transform", "tool_execution_hook", "permission_hook", "event_hook", "config_hook", "identity_act", "communication_email", "channel_outbound", "platform_control", "protected_op", "session_state", "browser_interact", "browser_inspect", "browser_eval_readonly", "browser_eval_trusted", "browser_clipboard", "browser_download", "browser_viewport"];
|
|
15
15
|
export declare const PERMISSION_CAPABILITY: Record<string, string>;
|
|
16
16
|
export declare const PLUGIN_BRIDGE_METHOD_POLICY: {
|
|
17
17
|
readonly "config.get": {
|
|
@@ -133,6 +133,7 @@ export declare function permissionsHashPayload(manifest: PluginManifest, capabil
|
|
|
133
133
|
permissionAsk?: "none" | "own" | "all";
|
|
134
134
|
events?: "none" | "selected" | "all";
|
|
135
135
|
eventNames?: string[];
|
|
136
|
+
config?: boolean;
|
|
136
137
|
};
|
|
137
138
|
network?: {
|
|
138
139
|
connectDomains?: string[];
|
package/dist/spec.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PluginManifest } from "./manifest";
|
|
1
|
+
import type { PluginManifest } from "./manifest.js";
|
|
2
2
|
export declare function entryCandidatesFromPluginDir(pluginDir: string, manifest: PluginManifest): string[];
|
|
3
3
|
export declare function resolveEntryFromPluginDir(pluginDir: string, manifest: PluginManifest): string;
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { ToolDisplay } from "./display";
|
|
3
|
-
import type { BunShell } from "./shell";
|
|
4
|
-
export type { ToolDisplay, ToolMediaDisplay } from "./display";
|
|
2
|
+
import type { ToolDisplay } from "./display.js";
|
|
3
|
+
import type { BunShell } from "./shell.js";
|
|
4
|
+
export type { ToolDisplay, ToolMediaDisplay } from "./display.js";
|
|
5
5
|
export type ToolContext = {
|
|
6
6
|
sessionID: string;
|
|
7
7
|
messageID: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@ericsanchezok/synergy-plugin",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -18,68 +18,68 @@
|
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
23
|
},
|
|
24
24
|
"./tool": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"types": "./dist/tool.d.ts",
|
|
26
|
+
"import": "./dist/tool.js"
|
|
27
27
|
},
|
|
28
28
|
"./display": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"types": "./dist/display.d.ts",
|
|
30
|
+
"import": "./dist/display.js"
|
|
31
31
|
},
|
|
32
32
|
"./hooks": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"types": "./dist/hooks.d.ts",
|
|
34
|
+
"import": "./dist/hooks.js"
|
|
35
35
|
},
|
|
36
36
|
"./permissions": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"types": "./dist/permissions.d.ts",
|
|
38
|
+
"import": "./dist/permissions.js"
|
|
39
39
|
},
|
|
40
40
|
"./ids": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"types": "./dist/ids.d.ts",
|
|
42
|
+
"import": "./dist/ids.js"
|
|
43
43
|
},
|
|
44
44
|
"./policy": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
45
|
+
"types": "./dist/policy.d.ts",
|
|
46
|
+
"import": "./dist/policy.js"
|
|
47
47
|
},
|
|
48
48
|
"./paths": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"types": "./dist/paths.d.ts",
|
|
50
|
+
"import": "./dist/paths.js"
|
|
51
51
|
},
|
|
52
52
|
"./artifact": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
53
|
+
"types": "./dist/artifact.d.ts",
|
|
54
|
+
"import": "./dist/artifact.js"
|
|
55
55
|
},
|
|
56
56
|
"./market": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
57
|
+
"types": "./dist/market.d.ts",
|
|
58
|
+
"import": "./dist/market.js"
|
|
59
59
|
},
|
|
60
60
|
"./spec": {
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"types": "./dist/spec.d.ts",
|
|
62
|
+
"import": "./dist/spec.js"
|
|
63
63
|
},
|
|
64
64
|
"./version": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
65
|
+
"types": "./dist/version.d.ts",
|
|
66
|
+
"import": "./dist/version.js"
|
|
67
67
|
},
|
|
68
68
|
"./shell": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
69
|
+
"types": "./dist/shell.d.ts",
|
|
70
|
+
"import": "./dist/shell.js"
|
|
71
71
|
},
|
|
72
72
|
"./ui": {
|
|
73
|
-
"
|
|
74
|
-
"
|
|
73
|
+
"types": "./dist/ui.d.ts",
|
|
74
|
+
"import": "./dist/ui.js"
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"files": [
|
|
78
78
|
"dist"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@ericsanchezok/synergy-sdk": "2.4.
|
|
82
|
-
"@ericsanchezok/synergy-util": "2.4.
|
|
81
|
+
"@ericsanchezok/synergy-sdk": "2.4.5",
|
|
82
|
+
"@ericsanchezok/synergy-util": "2.4.5"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"zod": ">=4.0.0"
|