@ericsanchezok/synergy-plugin 2.3.0 → 2.4.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `@ericsanchezok/synergy-plugin` is the authoring SDK for Synergy plugins.
4
4
 
5
- Plugins extend the Synergy server runtime and can also contribute Web UI surfaces through `plugin.json`. The current API is intentionally strict: a plugin module exports an object descriptor with a canonical `id` and an `init()` method. The descriptor id, `plugin.json.name`, registry id, lockfile key, and approval key must all be the same canonical plugin id.
5
+ Plugins extend the Synergy server runtime and can also contribute Web UI surfaces through `plugin.json`. A plugin module exports an object descriptor with a canonical `id` and an `init()` method. The descriptor id, `plugin.json.name`, registry id, lockfile key, and approval key must all be the same canonical plugin id.
6
6
 
7
7
  Plugin authors should use `@ericsanchezok/synergy-plugin-kit` and this SDK from a standalone plugin project. Cloning the Synergy source repository is only needed when changing or debugging the plugin platform itself.
8
8
 
@@ -59,13 +59,13 @@ export const plugin: PluginDescriptor = {
59
59
  export default plugin
60
60
  ```
61
61
 
62
- There is no compatibility layer for legacy descriptor shapes. `plugin.json.name` must match `plugin.id`; Synergy fails validation or loading if they differ.
62
+ `plugin.json.name` must match `plugin.id`; Synergy fails validation or loading if they differ.
63
63
 
64
64
  ## Tool Results And Attachments
65
65
 
66
66
  Tools can return user-facing files through `attachments`. Use the generated SDK `asset.upload()` route or the public `/asset` endpoint to upload binary data, then return the resulting `asset://...` URL. Do not import Synergy internal asset modules from a plugin.
67
67
 
68
- For visual tools whose output should appear as the main answer instead of a tool card, set `metadata.display.presentation` to `artifact-only` and list the attachment ids to promote:
68
+ For visual tools whose output belongs in the main answer area, set `metadata.display.presentation` to `artifact-only` and list the attachment ids to promote:
69
69
 
70
70
  ```ts
71
71
  return {
@@ -121,7 +121,53 @@ tool({
121
121
  })
122
122
  ```
123
123
 
124
- Use `visibility: "media"` for tools whose running and completed success states should be represented by the media surface instead of the ordinary tool transcript. Error states still fall back to normal tool cards.
124
+ Use `visibility: "media"` for tools whose running and completed success states belong on the media surface. Error states still fall back to normal tool cards.
125
+
126
+ ## Internal Tools And Delegated Tasks
127
+
128
+ Plugins can register helper tools that are only available to a controlled delegated task by setting `exposure: { mode: "internal" }`. Internal tools are not visible to the primary agent, resident tool lists, grouped tools, or `search_tools`; Synergy can still enable them explicitly for a delegated subagent run.
129
+
130
+ ```ts
131
+ tool({
132
+ description: "Validate a private planning result",
133
+ exposure: { mode: "internal" },
134
+ args: {
135
+ choice: tool.schema.string(),
136
+ },
137
+ async execute(args) {
138
+ return { output: JSON.stringify({ choice: args.choice }) }
139
+ },
140
+ })
141
+ ```
142
+
143
+ Use `context.task.run()` when a public plugin tool needs Synergy's existing Cortex delegation flow. The host always fills `parentSessionID`, `parentMessageID`, and `executionRole: "delegated_subagent"`; plugins cannot forge those fields.
144
+
145
+ ```ts
146
+ const plan = await context.task?.run({
147
+ subagent: "my-plugin-planner",
148
+ description: "Plan the plugin result",
149
+ prompt: "Choose a valid plan and return JSON.",
150
+ tools: {
151
+ "*": false,
152
+ "plugin__my-plugin__private_helper": true,
153
+ },
154
+ visibility: "hidden",
155
+ timeoutMs: 30_000,
156
+ output: {
157
+ mode: "structured",
158
+ schema: {
159
+ type: "object",
160
+ required: ["choice"],
161
+ properties: {
162
+ choice: { type: "string" },
163
+ },
164
+ },
165
+ maxRepairTurns: 3,
166
+ },
167
+ })
168
+ ```
169
+
170
+ 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`.
125
171
 
126
172
  ## Plugin Input
127
173
 
package/dist/index.d.ts CHANGED
@@ -82,6 +82,8 @@ export interface PluginAgent {
82
82
  mode?: "subagent" | "primary" | "all";
83
83
  /** Model override in "providerID/modelID" format */
84
84
  model?: string;
85
+ /** Model role to resolve when model is not set */
86
+ modelRole?: "vision" | "nano" | "mini" | "mid" | "thinking" | "long" | "creative";
85
87
  temperature?: number;
86
88
  topP?: number;
87
89
  /** Maximum agentic iterations */
@@ -226,6 +228,18 @@ export type ProviderProfileHook = {
226
228
  aliases?: string[];
227
229
  description?: string;
228
230
  signupUrl?: string;
231
+ recommendation?: {
232
+ level: "featured" | "recommended" | "standard";
233
+ rank?: number;
234
+ headline?: string;
235
+ reason?: string;
236
+ cta?: {
237
+ kind: "external";
238
+ label: string;
239
+ url: string;
240
+ };
241
+ defaultModel?: string;
242
+ };
229
243
  env?: string[];
230
244
  baseURL?: string;
231
245
  modelsURL?: string;
@@ -38,6 +38,10 @@ export declare const PluginManifest: z.ZodObject<{
38
38
  invoke: "invoke";
39
39
  spawn: "spawn";
40
40
  }>>;
41
+ task: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
42
+ agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
+ maxRuntimeMs: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strict>]>>;
41
45
  }, z.core.$strip>>;
42
46
  data: z.ZodOptional<z.ZodObject<{
43
47
  session: z.ZodDefault<z.ZodEnum<{
@@ -120,6 +124,8 @@ export declare const PluginManifest: z.ZodObject<{
120
124
  mode: z.ZodLiteral<"search">;
121
125
  title: z.ZodOptional<z.ZodString>;
122
126
  keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
+ }, z.core.$strict>, z.ZodObject<{
128
+ mode: z.ZodLiteral<"internal">;
123
129
  }, z.core.$strict>], "mode">>;
124
130
  display: z.ZodOptional<z.ZodObject<{
125
131
  kind: z.ZodOptional<z.ZodEnum<{
@@ -198,6 +204,17 @@ export declare const PluginManifest: z.ZodObject<{
198
204
  all: "all";
199
205
  }>>;
200
206
  model: z.ZodOptional<z.ZodString>;
207
+ modelRole: z.ZodOptional<z.ZodEnum<{
208
+ vision: "vision";
209
+ nano: "nano";
210
+ mini: "mini";
211
+ mid: "mid";
212
+ thinking: "thinking";
213
+ long: "long";
214
+ creative: "creative";
215
+ }>>;
216
+ hidden: z.ZodOptional<z.ZodBoolean>;
217
+ permission: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
201
218
  }, z.core.$strip>>>>;
202
219
  mcp: z.ZodOptional<z.ZodOptional<z.ZodObject<{
203
220
  defaults: z.ZodOptional<z.ZodObject<{
@@ -347,6 +364,10 @@ export declare const PluginManifest: z.ZodObject<{
347
364
  invoke: "invoke";
348
365
  spawn: "spawn";
349
366
  }>>;
367
+ task: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
368
+ agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
369
+ maxRuntimeMs: z.ZodOptional<z.ZodNumber>;
370
+ }, z.core.$strict>]>>;
350
371
  }, z.core.$strip>>;
351
372
  data: z.ZodOptional<z.ZodObject<{
352
373
  session: z.ZodDefault<z.ZodEnum<{
package/dist/manifest.js CHANGED
@@ -109,6 +109,20 @@ const ToolExposureDef = z.discriminatedUnion("mode", [
109
109
  keywords: z.array(z.string()).optional(),
110
110
  })
111
111
  .strict(),
112
+ z
113
+ .object({
114
+ mode: z.literal("internal"),
115
+ })
116
+ .strict(),
117
+ ]);
118
+ const TaskPermissionDef = z.union([
119
+ z.boolean(),
120
+ z
121
+ .object({
122
+ agents: z.array(z.string().min(1)).optional(),
123
+ maxRuntimeMs: z.number().int().positive().optional(),
124
+ })
125
+ .strict(),
112
126
  ]);
113
127
  const ToolDisplayDef = z
114
128
  .object({
@@ -169,6 +183,7 @@ const PluginPermissionsSchema = z
169
183
  }, z.enum(["none", "read", "write"]).default("none")),
170
184
  network: z.boolean().default(false),
171
185
  mcp: z.enum(["none", "invoke", "spawn"]).default("none"),
186
+ task: TaskPermissionDef.optional(),
172
187
  })
173
188
  .optional(),
174
189
  /** Data access */
@@ -291,6 +306,9 @@ export const PluginManifest = z
291
306
  description: z.string(),
292
307
  mode: z.enum(["subagent", "primary", "all"]).default("subagent"),
293
308
  model: z.string().optional(),
309
+ modelRole: z.enum(["vision", "nano", "mini", "mid", "thinking", "long", "creative"]).optional(),
310
+ hidden: z.boolean().optional(),
311
+ permission: z.record(z.string(), z.any()).optional(),
294
312
  }))
295
313
  .optional(),
296
314
  mcp: z
package/dist/tool.d.ts CHANGED
@@ -13,7 +13,67 @@ export type ToolContext = {
13
13
  patterns: string[];
14
14
  metadata?: Record<string, any>;
15
15
  }): Promise<void>;
16
+ /** Run a Synergy delegated subagent task from inside this tool. */
17
+ task?: ToolTaskService;
18
+ /** Invoke another visible/explicitly-allowed Synergy tool from inside this tool. */
19
+ tools?: ToolInvokeService;
16
20
  };
21
+ export type ToolTaskVisibility = "visible" | "hidden";
22
+ export type ToolTaskOutput = {
23
+ mode?: "summary";
24
+ } | {
25
+ mode: "final_response";
26
+ } | {
27
+ mode: "structured";
28
+ schema: Record<string, unknown>;
29
+ maxRepairTurns?: 0 | 1 | 2 | 3;
30
+ };
31
+ export type ToolTaskOutputResult = {
32
+ mode: "final_response";
33
+ text: string;
34
+ } | {
35
+ mode: "structured";
36
+ status: "valid" | "invalid";
37
+ source?: "structured_tool" | "final_response";
38
+ data?: unknown;
39
+ text?: string;
40
+ repairTurns: number;
41
+ error?: string;
42
+ validationErrors?: string[];
43
+ };
44
+ export interface ToolTaskRunInput {
45
+ subagent: string;
46
+ description: string;
47
+ prompt: string;
48
+ tools?: Record<string, boolean>;
49
+ visibility?: ToolTaskVisibility;
50
+ timeoutMs?: number;
51
+ output?: ToolTaskOutput;
52
+ category?: string;
53
+ model?: {
54
+ providerID: string;
55
+ modelID: string;
56
+ };
57
+ }
58
+ export interface ToolTaskRunResult {
59
+ taskId: string;
60
+ sessionId: string;
61
+ status: "pending" | "queued" | "running" | "completed" | "error" | "cancelled" | "timeout";
62
+ output: string;
63
+ outputResult?: ToolTaskOutputResult;
64
+ error?: string;
65
+ }
66
+ export interface ToolTaskService {
67
+ run(input: ToolTaskRunInput): Promise<ToolTaskRunResult>;
68
+ }
69
+ export interface ToolInvokeInput {
70
+ tool: string;
71
+ args?: unknown;
72
+ timeoutMs?: number;
73
+ }
74
+ export interface ToolInvokeService {
75
+ invoke(input: ToolInvokeInput): Promise<ToolResult>;
76
+ }
17
77
  export type ToolResultMetadata = Record<string, any> & {
18
78
  display?: ToolDisplay;
19
79
  primaryAttachmentIds?: string[];
@@ -45,6 +105,8 @@ export type ToolExposure = {
45
105
  mode: "search";
46
106
  title?: string;
47
107
  keywords?: string[];
108
+ } | {
109
+ mode: "internal";
48
110
  };
49
111
  export declare function tool<Args extends z.ZodRawShape>(input: {
50
112
  description: 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.3.0",
4
+ "version": "2.4.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {