@holokai/neuron-sdk 0.5.1 → 0.6.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/dist/index.mjs CHANGED
@@ -10,6 +10,11 @@ var CapabilityTypeSchema = z.string().min(1).regex(
10
10
  "capability type must be namespaced: {owner}/{package}[/{name}][.{variant}]"
11
11
  );
12
12
  var UserIdSchema = z.string().min(1);
13
+ var SKILL_CAPABILITY_PREFIX = "skill/";
14
+ function isSkillCapabilityType(type) {
15
+ return type.startsWith(SKILL_CAPABILITY_PREFIX);
16
+ }
17
+ var MAX_COMPOSED_CAPABILITIES = 64;
13
18
  var JsonSchemaSchema = z.unknown();
14
19
  var CapabilityScopeSchema = z.union([
15
20
  z.literal("any"),
@@ -62,8 +67,29 @@ var CapabilitySchema = z.object({
62
67
  * heartbeat budget should be the limiter, not a single
63
68
  * capability).
64
69
  */
65
- leaseTtlMs: z.number().int().min(1e3).max(60 * 60 * 1e3).optional()
66
- }).strict();
70
+ leaseTtlMs: z.number().int().min(1e3).max(60 * 60 * 1e3).optional(),
71
+ /**
72
+ * Capability types this `skill/*` capability composes (HOL-4326).
73
+ * Only valid on a `skill/*` type — enforced below, since a non-skill
74
+ * type carrying `composes` is a modeling error the gateway should
75
+ * reject rather than silently ignore.
76
+ */
77
+ composes: z.array(CapabilityTypeSchema).min(1).max(MAX_COMPOSED_CAPABILITIES).refine(
78
+ (types) => new Set(types).size === types.length,
79
+ "composes must not contain duplicate capability types"
80
+ ).refine(
81
+ (types) => types.every((t) => !isSkillCapabilityType(t)),
82
+ "composes must not contain skill/* capability types"
83
+ ).optional()
84
+ }).strict().superRefine((cap, ctx) => {
85
+ if (cap.composes !== void 0 && !isSkillCapabilityType(cap.type)) {
86
+ ctx.addIssue({
87
+ code: z.ZodIssueCode.custom,
88
+ message: "composes is only valid on a skill/* capability type",
89
+ path: ["composes"]
90
+ });
91
+ }
92
+ });
67
93
  var LeaseIdSchema = z.string().min(1);
68
94
  var TaskPayloadSchema = z.object({
69
95
  taskId: z.string().min(1),
@@ -202,7 +228,7 @@ z.discriminatedUnion("type", [
202
228
  ]);
203
229
 
204
230
  // ../neuron-protocol/src/transport.ts
205
- var PROTOCOL_VERSION = "1.1.0";
231
+ var PROTOCOL_VERSION = "1.2.0";
206
232
  var SSE_PATH = "/neuron/events";
207
233
  var SSE_EVENT = {
208
234
  registered: "registered",
@@ -228,6 +254,7 @@ function defineCapability(init) {
228
254
  scope: init.scope,
229
255
  concurrency: init.concurrency,
230
256
  leaseTtlMs: init.leaseTtlMs,
257
+ composes: init.composes,
231
258
  _zod: { input: init.input, output: init.output }
232
259
  };
233
260
  }
@@ -253,6 +280,7 @@ function toRegistrationCapability(def, opts) {
253
280
  );
254
281
  }
255
282
  const leaseTtlMs = opts?.leaseTtlMs ?? def.leaseTtlMs;
283
+ const composes = opts?.composes ?? def.composes;
256
284
  return {
257
285
  type: def.type,
258
286
  scope,
@@ -263,7 +291,8 @@ function toRegistrationCapability(def, opts) {
263
291
  description: opts?.description ?? def.description,
264
292
  inputSchema: def.inputSchema,
265
293
  outputSchema: def.outputSchema,
266
- ...typeof leaseTtlMs === "number" ? { leaseTtlMs } : {}
294
+ ...typeof leaseTtlMs === "number" ? { leaseTtlMs } : {},
295
+ ...composes !== void 0 ? { composes: [...composes] } : {}
267
296
  };
268
297
  }
269
298
 
@@ -972,7 +1001,8 @@ var Neuron = class extends EventEmitter {
972
1001
  ...reg.description !== void 0 ? { description: reg.description } : {},
973
1002
  ...reg.inputSchema !== void 0 ? { inputSchema: reg.inputSchema } : {},
974
1003
  ...reg.outputSchema !== void 0 ? { outputSchema: reg.outputSchema } : {},
975
- ...typeof reg.leaseTtlMs === "number" ? { leaseTtlMs: reg.leaseTtlMs } : {}
1004
+ ...typeof reg.leaseTtlMs === "number" ? { leaseTtlMs: reg.leaseTtlMs } : {},
1005
+ ...reg.composes !== void 0 ? { composes: reg.composes } : {}
976
1006
  };
977
1007
  inputSchema = reg.inputSchema;
978
1008
  outputSchema = reg.outputSchema;