@ericsanchezok/synergy-plugin 2.3.0 → 2.4.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.
package/README.md CHANGED
@@ -123,6 +123,52 @@ tool({
123
123
 
124
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.
125
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`.
171
+
126
172
  ## Plugin Input
127
173
 
128
174
  `init(input)` receives runtime services scoped to the active Synergy Scope:
@@ -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,8 @@ export declare const PluginManifest: z.ZodObject<{
198
204
  all: "all";
199
205
  }>>;
200
206
  model: z.ZodOptional<z.ZodString>;
207
+ hidden: z.ZodOptional<z.ZodBoolean>;
208
+ permission: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
201
209
  }, z.core.$strip>>>>;
202
210
  mcp: z.ZodOptional<z.ZodOptional<z.ZodObject<{
203
211
  defaults: z.ZodOptional<z.ZodObject<{
@@ -347,6 +355,10 @@ export declare const PluginManifest: z.ZodObject<{
347
355
  invoke: "invoke";
348
356
  spawn: "spawn";
349
357
  }>>;
358
+ task: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
359
+ agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
360
+ maxRuntimeMs: z.ZodOptional<z.ZodNumber>;
361
+ }, z.core.$strict>]>>;
350
362
  }, z.core.$strip>>;
351
363
  data: z.ZodOptional<z.ZodObject<{
352
364
  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,8 @@ 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
+ hidden: z.boolean().optional(),
310
+ permission: z.record(z.string(), z.any()).optional(),
294
311
  }))
295
312
  .optional(),
296
313
  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.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {