@get-bb/plugin-sdk 0.4.88 → 0.4.97

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.
@@ -1,6 +1,6 @@
1
1
  // src/internal/host-policy.ts
2
2
  import { createHash } from "node:crypto";
3
- import { z as z4 } from "zod";
3
+ import { z as z5 } from "zod";
4
4
 
5
5
  // ../domain/src/plugin-icon.ts
6
6
  function isPluginOwnedIconPath(icon) {
@@ -54,6 +54,12 @@ import { z } from "zod";
54
54
  var PROVIDER_FORK_VALUES = ["none", "tip", "checkpoint"];
55
55
  var providerForkSchema = z.enum(PROVIDER_FORK_VALUES);
56
56
 
57
+ // ../domain/src/completed-turn-display.ts
58
+ import { z as z2 } from "zod";
59
+ var COMPLETED_TURN_DISPLAY_VALUES = ["collapse", "flat"];
60
+ var completedTurnDisplaySchema = z2.enum(COMPLETED_TURN_DISPLAY_VALUES);
61
+ var DEFAULT_COMPLETED_TURN_DISPLAY = "collapse";
62
+
57
63
  // ../domain/src/provider-skill-roots.ts
58
64
  function isAbsoluteProviderSkillRootPath(value) {
59
65
  if (value.length === 0) {
@@ -76,53 +82,53 @@ function isRelativeProviderSkillRootPath(value) {
76
82
  }
77
83
 
78
84
  // ../domain/src/json-value.ts
79
- import { z as z2 } from "zod";
80
- var jsonValueSchema = z2.lazy(
81
- () => z2.union([
82
- z2.string(),
83
- z2.number(),
84
- z2.boolean(),
85
- z2.null(),
86
- z2.array(jsonValueSchema),
87
- z2.record(z2.string(), jsonValueSchema)
85
+ import { z as z3 } from "zod";
86
+ var jsonValueSchema = z3.lazy(
87
+ () => z3.union([
88
+ z3.string(),
89
+ z3.number(),
90
+ z3.boolean(),
91
+ z3.null(),
92
+ z3.array(jsonValueSchema),
93
+ z3.record(z3.string(), jsonValueSchema)
88
94
  ])
89
95
  );
90
- var jsonObjectSchema = z2.record(
91
- z2.string(),
96
+ var jsonObjectSchema = z3.record(
97
+ z3.string(),
92
98
  jsonValueSchema
93
99
  );
94
100
 
95
101
  // ../domain/src/native-roots.ts
96
- import { z as z3 } from "zod";
102
+ import { z as z4 } from "zod";
97
103
  var PROVIDER_NATIVE_ROOTS_MAX = 32;
98
104
  var PROVIDER_NATIVE_ROOT_NAME_PREFIX_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}:$/u;
99
- var nativeRootNamePrefixSchema = z3.string().refine(
105
+ var nativeRootNamePrefixSchema = z4.string().refine(
100
106
  (value) => value === "" || PROVIDER_NATIVE_ROOT_NAME_PREFIX_PATTERN.test(value),
101
107
  "A root name prefix is a plugin-name-like token ending in ':'"
102
108
  );
103
- var nativeRootManifestPathSchema = z3.string().min(1).refine(
109
+ var nativeRootManifestPathSchema = z4.string().min(1).refine(
104
110
  isRelativeProviderSkillRootPath,
105
111
  "A manifest marker is a relative path without dot segments"
106
112
  );
107
- var relativeNativeRootPathSchema = z3.string().min(1).refine(
113
+ var relativeNativeRootPathSchema = z4.string().min(1).refine(
108
114
  isRelativeProviderSkillRootPath,
109
115
  "Roots must be relative paths without dot segments"
110
116
  );
111
- var absoluteNativeRootPathSchema = z3.string().min(1).refine(
117
+ var absoluteNativeRootPathSchema = z4.string().min(1).refine(
112
118
  isAbsoluteProviderSkillRootPath,
113
119
  "Absolute roots must be absolute paths without dot segments"
114
120
  );
115
- var providerNativeRootInputSchema = z3.union([
116
- z3.string().min(1),
117
- z3.object({
118
- path: z3.string().min(1),
121
+ var providerNativeRootInputSchema = z4.union([
122
+ z4.string().min(1),
123
+ z4.object({
124
+ path: z4.string().min(1),
119
125
  /** Skills nest in subdirectories (the agent scans recursively). */
120
- recursive: z3.boolean().optional(),
126
+ recursive: z4.boolean().optional(),
121
127
  /**
122
128
  * Scan the same relative directory in every ancestor of the workspace
123
129
  * up to the repository root (`project` roots only).
124
130
  */
125
- ancestors: z3.boolean().optional(),
131
+ ancestors: z4.boolean().optional(),
126
132
  /**
127
133
  * Prepended to every name under the root, a vendor plugin's
128
134
  * `plugin-name:`; a prefixed root is listed as a plugin root.
@@ -137,14 +143,14 @@ var providerNativeRootInputSchema = z3.union([
137
143
  skipIfManifest: nativeRootManifestPathSchema.optional()
138
144
  }).strict()
139
145
  ]);
140
- var providerNativeRootsInputSchema = z3.object({
141
- user: z3.array(providerNativeRootInputSchema).optional(),
142
- project: z3.array(providerNativeRootInputSchema).optional()
146
+ var providerNativeRootsInputSchema = z4.object({
147
+ user: z4.array(providerNativeRootInputSchema).optional(),
148
+ project: z4.array(providerNativeRootInputSchema).optional()
143
149
  }).strict();
144
- var providerNativeRootSchema = z3.object({
145
- path: z3.string().min(1),
146
- recursive: z3.boolean(),
147
- ancestors: z3.boolean(),
150
+ var providerNativeRootSchema = z4.object({
151
+ path: z4.string().min(1),
152
+ recursive: z4.boolean(),
153
+ ancestors: z4.boolean(),
148
154
  namePrefix: nativeRootNamePrefixSchema,
149
155
  /** Absent: every skill-shaped directory under the root is a skill. */
150
156
  skipIfManifest: nativeRootManifestPathSchema.optional()
@@ -153,7 +159,7 @@ function uniqueByPath(roots) {
153
159
  return new Set(roots.map((root) => root.path)).size === roots.length;
154
160
  }
155
161
  function nativeRootSideSchema(side) {
156
- return z3.array(
162
+ return z4.array(
157
163
  providerNativeRootSchema.extend({ path: relativeNativeRootPathSchema }).superRefine((root, context) => {
158
164
  if (root.ancestors && side !== "project") {
159
165
  context.addIssue({
@@ -164,7 +170,7 @@ function nativeRootSideSchema(side) {
164
170
  })
165
171
  ).max(PROVIDER_NATIVE_ROOTS_MAX).refine(uniqueByPath, "Roots must not repeat a path");
166
172
  }
167
- var providerNativeRootsSchema = z3.object({
173
+ var providerNativeRootsSchema = z4.object({
168
174
  user: nativeRootSideSchema("user"),
169
175
  project: nativeRootSideSchema("project")
170
176
  }).strict();
@@ -190,19 +196,19 @@ function normalizeProviderNativeRoots(roots) {
190
196
  project: (roots?.project ?? []).map(normalizeProviderNativeRoot)
191
197
  };
192
198
  }
193
- var providerResolvedNativeRootShapeSchema = z3.enum([
199
+ var providerResolvedNativeRootShapeSchema = z4.enum([
194
200
  "skills",
195
201
  "skill",
196
202
  "skill-file",
197
203
  "commands",
198
204
  "command-file"
199
205
  ]);
200
- var resolvedNativeRootFieldsSchema = z3.object({
206
+ var resolvedNativeRootFieldsSchema = z4.object({
201
207
  path: absoluteNativeRootPathSchema,
202
- origin: z3.enum(["user", "project"]),
203
- recursive: z3.boolean(),
208
+ origin: z4.enum(["user", "project"]),
209
+ recursive: z4.boolean(),
204
210
  /** Only with origin `project`, for a path inside the workspace. */
205
- ancestors: z3.boolean(),
211
+ ancestors: z4.boolean(),
206
212
  namePrefix: nativeRootNamePrefixSchema,
207
213
  shape: providerResolvedNativeRootShapeSchema,
208
214
  /**
@@ -210,7 +216,7 @@ var resolvedNativeRootFieldsSchema = z3.object({
210
216
  * none. A vendor plugin's root SKILL.md takes the plugin's name; absent
211
217
  * means the parent directory's name.
212
218
  */
213
- fallbackName: z3.string().min(1).optional(),
219
+ fallbackName: z4.string().min(1).optional(),
214
220
  /**
215
221
  * `skills` only: a file, relative to a skill directory under this root,
216
222
  * that marks the directory as a vendor plugin rather than a skill; the
@@ -254,14 +260,14 @@ var resolvedCommandShapes = /* @__PURE__ */ new Set([
254
260
  "command-file"
255
261
  ]);
256
262
  var PROVIDER_RESOLVED_NATIVE_ROOTS_MAX = 256;
257
- var providerResolvedNativeRootsSchema = z3.object({
258
- skills: z3.array(
263
+ var providerResolvedNativeRootsSchema = z4.object({
264
+ skills: z4.array(
259
265
  providerResolvedNativeRootSchema.refine(
260
266
  (root) => resolvedSkillShapes.has(root.shape),
261
267
  "A skills root needs a skill shape"
262
268
  )
263
269
  ).max(PROVIDER_RESOLVED_NATIVE_ROOTS_MAX),
264
- commands: z3.array(
270
+ commands: z4.array(
265
271
  providerResolvedNativeRootSchema.refine(
266
272
  (root) => resolvedCommandShapes.has(root.shape),
267
273
  "A commands root needs a command shape"
@@ -272,7 +278,7 @@ var EMPTY_PROVIDER_RESOLVED_NATIVE_ROOTS = Object.freeze({
272
278
  skills: Object.freeze([]),
273
279
  commands: Object.freeze([])
274
280
  });
275
- var providerNativeRootSetSchema = z3.object({
281
+ var providerNativeRootSetSchema = z4.object({
276
282
  skills: providerNativeRootsSchema,
277
283
  commands: providerNativeRootsSchema,
278
284
  resolved: providerResolvedNativeRootsSchema
@@ -350,15 +356,15 @@ var CLI_COMMAND_NAME_PATTERN = /^[a-z0-9-]+$/;
350
356
  var AGENT_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
351
357
  var PLUGIN_PROVIDER_ENV_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
352
358
  var PLUGIN_PROVIDER_ENV_MAX_ENTRIES = 32;
353
- var pluginProviderEnvEntrySchema = z4.object({
354
- name: z4.string().regex(PLUGIN_PROVIDER_ENV_NAME_PATTERN),
355
- value: z4.union([
356
- z4.string(),
357
- z4.object({ serverPath: z4.string().startsWith("/") }).strict()
359
+ var pluginProviderEnvEntrySchema = z5.object({
360
+ name: z5.string().regex(PLUGIN_PROVIDER_ENV_NAME_PATTERN),
361
+ value: z5.union([
362
+ z5.string(),
363
+ z5.object({ serverPath: z5.string().startsWith("/") }).strict()
358
364
  ]),
359
- reason: z4.string()
365
+ reason: z5.string()
360
366
  }).strict();
361
- var pluginProviderEnvEntriesSchema = z4.array(pluginProviderEnvEntrySchema).max(PLUGIN_PROVIDER_ENV_MAX_ENTRIES).superRefine((entries, context) => {
367
+ var pluginProviderEnvEntriesSchema = z5.array(pluginProviderEnvEntrySchema).max(PLUGIN_PROVIDER_ENV_MAX_ENTRIES).superRefine((entries, context) => {
362
368
  const names = /* @__PURE__ */ new Set();
363
369
  for (let index = 0; index < entries.length; index += 1) {
364
370
  const name = entries[index]?.name;
@@ -393,26 +399,26 @@ var PROVIDER_ID_PATTERN = /^[a-z0-9][a-z0-9-]{1,63}$/;
393
399
  var PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES = 64 * 1024;
394
400
  var SETTING_KEY_PATTERN = /^[a-zA-Z0-9_-]+$/;
395
401
  var settingsBaseFields = {
396
- label: z4.string().min(1),
397
- description: z4.string().min(1).optional()
402
+ label: z5.string().min(1),
403
+ description: z5.string().min(1).optional()
398
404
  };
399
- var stringSettingSchemaSchema = z4.custom(
405
+ var stringSettingSchemaSchema = z5.custom(
400
406
  (value) => isStandardSchema(value)
401
407
  );
402
- var booleanSettingSchemaSchema = z4.custom(
408
+ var booleanSettingSchemaSchema = z5.custom(
403
409
  (value) => isStandardSchema(value)
404
410
  );
405
- var numberSettingSchemaSchema = z4.custom(
411
+ var numberSettingSchemaSchema = z5.custom(
406
412
  (value) => isStandardSchema(value)
407
413
  );
408
- var settingDescriptorSchema = z4.discriminatedUnion("type", [
409
- z4.object({
410
- type: z4.literal("string"),
414
+ var settingDescriptorSchema = z5.discriminatedUnion("type", [
415
+ z5.object({
416
+ type: z5.literal("string"),
411
417
  ...settingsBaseFields,
412
- secret: z4.literal(true).optional(),
413
- experimental_multiline: z4.boolean().optional(),
418
+ secret: z5.literal(true).optional(),
419
+ experimental_multiline: z5.boolean().optional(),
414
420
  experimental_schema: stringSettingSchemaSchema.optional(),
415
- default: z4.string().optional()
421
+ default: z5.string().optional()
416
422
  }).strict().refine(
417
423
  (descriptor) => !(descriptor.secret === true && descriptor.experimental_multiline === true),
418
424
  {
@@ -420,30 +426,30 @@ var settingDescriptorSchema = z4.discriminatedUnion("type", [
420
426
  path: ["experimental_multiline"]
421
427
  }
422
428
  ),
423
- z4.object({
424
- type: z4.literal("boolean"),
429
+ z5.object({
430
+ type: z5.literal("boolean"),
425
431
  ...settingsBaseFields,
426
432
  experimental_schema: booleanSettingSchemaSchema.optional(),
427
- default: z4.boolean().optional()
433
+ default: z5.boolean().optional()
428
434
  }).strict(),
429
- z4.object({
430
- type: z4.literal("number"),
435
+ z5.object({
436
+ type: z5.literal("number"),
431
437
  ...settingsBaseFields,
432
438
  experimental_schema: numberSettingSchemaSchema.optional(),
433
- default: z4.number().finite().optional()
439
+ default: z5.number().finite().optional()
434
440
  }).strict(),
435
- z4.object({
436
- type: z4.literal("select"),
441
+ z5.object({
442
+ type: z5.literal("select"),
437
443
  ...settingsBaseFields,
438
- options: z4.array(z4.string().min(1)).min(1),
444
+ options: z5.array(z5.string().min(1)).min(1),
439
445
  experimental_schema: stringSettingSchemaSchema.optional(),
440
- default: z4.string().optional()
446
+ default: z5.string().optional()
441
447
  }).strict(),
442
- z4.object({
443
- type: z4.literal("project"),
448
+ z5.object({
449
+ type: z5.literal("project"),
444
450
  ...settingsBaseFields,
445
451
  experimental_schema: stringSettingSchemaSchema.optional(),
446
- default: z4.string().optional()
452
+ default: z5.string().optional()
447
453
  }).strict()
448
454
  ]);
449
455
  function registerSettingDescriptors(target, added) {
@@ -991,6 +997,18 @@ function validateProviderModelCatalogScope(providerId, value) {
991
997
  }
992
998
  return value;
993
999
  }
1000
+ var PROVIDER_COMPLETED_TURN_DISPLAYS = COMPLETED_TURN_DISPLAY_VALUES;
1001
+ function validateProviderCompletedTurnDisplay(providerId, value) {
1002
+ if (value === void 0) {
1003
+ return DEFAULT_COMPLETED_TURN_DISPLAY;
1004
+ }
1005
+ if (typeof value !== "string" || !PROVIDER_COMPLETED_TURN_DISPLAYS.includes(value)) {
1006
+ throw new Error(
1007
+ `provider "${providerId}" completedTurnDisplay must be one of ${PROVIDER_COMPLETED_TURN_DISPLAYS.join(", ")}`
1008
+ );
1009
+ }
1010
+ return value;
1011
+ }
994
1012
  function validateProviderFallbackModels(providerId, value) {
995
1013
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
996
1014
  throw new Error(`provider "${providerId}" models must be an object`);
@@ -1371,6 +1389,10 @@ function validatePluginProviderDeclaration(declaration) {
1371
1389
  allowed: PLUGIN_PROVIDER_COMPOSER_ACTION_VALUES,
1372
1390
  requireNonEmpty: false
1373
1391
  });
1392
+ const completedTurnDisplay = validateProviderCompletedTurnDisplay(
1393
+ id,
1394
+ declaration.completedTurnDisplay
1395
+ );
1374
1396
  const bridgeOptions = declaration.experimental_bridgeOptions === void 0 ? void 0 : normalizeProviderBridgeOptions(
1375
1397
  id,
1376
1398
  declaration.experimental_bridgeOptions
@@ -1436,6 +1458,7 @@ function validatePluginProviderDeclaration(declaration) {
1436
1458
  maintenance: normalizedMaintenance,
1437
1459
  capabilities: normalizedCapabilities,
1438
1460
  composerActions,
1461
+ completedTurnDisplay,
1439
1462
  ...strings === void 0 ? {} : { strings },
1440
1463
  ...serviceTiers === void 0 ? {} : { serviceTiers },
1441
1464
  ...reasoningLevels === void 0 ? {} : { reasoningLevels },
@@ -1456,6 +1479,11 @@ function isStandardSchema(value) {
1456
1479
  const standard = Reflect.get(value, "~standard");
1457
1480
  return typeof standard === "object" && standard !== null && Reflect.get(standard, "version") === 1 && typeof Reflect.get(standard, "vendor") === "string" && typeof Reflect.get(standard, "validate") === "function";
1458
1481
  }
1482
+ var rpcDescriptionSchema = z5.string().trim().min(1).max(4096).optional().transform((value) => value ?? null);
1483
+ var rpcPublicationOptionsSchema = z5.object({
1484
+ experimental_discoverable: z5.boolean().default(false),
1485
+ experimental_description: rpcDescriptionSchema
1486
+ }).strict();
1459
1487
  function readRpcMethodContract(method, value) {
1460
1488
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
1461
1489
  throw new Error(
@@ -1474,7 +1502,59 @@ function readRpcMethodContract(method, value) {
1474
1502
  `rpc method "${method}" output must be a Standard Schema v1 validator`
1475
1503
  );
1476
1504
  }
1477
- return { input, output };
1505
+ const description = rpcDescriptionSchema.parse(
1506
+ Reflect.get(value, "experimental_description")
1507
+ );
1508
+ return description === null ? { input, output } : { input, output, experimental_description: description };
1509
+ }
1510
+ function readRpcPublicationOptions(value) {
1511
+ return rpcPublicationOptionsSchema.parse(value ?? {});
1512
+ }
1513
+ function publishedRpcSchema(schema, direction) {
1514
+ const converter = schema["~standard"].jsonSchema;
1515
+ if (converter === void 0 || typeof converter[direction] !== "function") {
1516
+ throw new Error(
1517
+ "discoverable RPC requires Standard JSON Schema export support"
1518
+ );
1519
+ }
1520
+ const serialized = JSON.stringify(
1521
+ converter[direction]({ target: "draft-2020-12" })
1522
+ );
1523
+ if (serialized === void 0 || new TextEncoder().encode(serialized).byteLength > 128 * 1024) {
1524
+ throw new Error("published RPC schema must be JSON and at most 128 KiB");
1525
+ }
1526
+ const result = z5.record(z5.string(), jsonValueSchema).parse(JSON.parse(serialized));
1527
+ const inspect = (value) => {
1528
+ if (value === null || typeof value !== "object") return;
1529
+ if (Array.isArray(value)) {
1530
+ for (const item of value) inspect(item);
1531
+ return;
1532
+ }
1533
+ for (const [key, item] of Object.entries(value)) {
1534
+ if ((key === "$ref" || key === "$dynamicRef") && typeof item === "string" && !item.startsWith("#")) {
1535
+ throw new Error("published RPC schemas must use local references");
1536
+ }
1537
+ inspect(item);
1538
+ }
1539
+ };
1540
+ inspect(result);
1541
+ return result;
1542
+ }
1543
+ function publishRpcMethod(method, contract, options) {
1544
+ if (!options.experimental_discoverable) return null;
1545
+ try {
1546
+ return {
1547
+ method,
1548
+ registrationDescription: options.experimental_description,
1549
+ methodDescription: contract.experimental_description ?? null,
1550
+ inputSchema: publishedRpcSchema(contract.input, "input"),
1551
+ outputSchema: publishedRpcSchema(contract.output, "output")
1552
+ };
1553
+ } catch (error) {
1554
+ throw new Error(
1555
+ `rpc method "${method}" cannot be published: ${error instanceof Error ? error.message : String(error)}`
1556
+ );
1557
+ }
1478
1558
  }
1479
1559
  function isZodSchemaLike(value) {
1480
1560
  return typeof value === "object" && value !== null && typeof value.safeParse === "function";
@@ -1493,7 +1573,7 @@ function zodSchemaToJsonSchema(schema) {
1493
1573
  if (typeof schema.toJSONSchema === "function") {
1494
1574
  return schema.toJSONSchema({ io: "input" });
1495
1575
  }
1496
- return z4.toJSONSchema(schema, { io: "input" });
1576
+ return z5.toJSONSchema(schema, { io: "input" });
1497
1577
  }
1498
1578
  var SINGLE_SCHEMA_KEYWORDS = [
1499
1579
  "additionalItems",
@@ -1828,15 +1908,15 @@ var ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES = [
1828
1908
  "gitRemote",
1829
1909
  "projectless"
1830
1910
  ];
1831
- var environmentCompositionSchema = z4.object({
1832
- id: z4.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN),
1833
- displayName: z4.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS),
1834
- description: z4.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS).optional().transform((value) => value ?? null),
1835
- icon: z4.string().trim().min(1).transform(
1911
+ var environmentCompositionSchema = z5.object({
1912
+ id: z5.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN),
1913
+ displayName: z5.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS),
1914
+ description: z5.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS).optional().transform((value) => value ?? null),
1915
+ icon: z5.string().trim().min(1).transform(
1836
1916
  (icon) => isPluginOwnedIconPath(icon) ? validateProviderRelativePath(icon, "Composition icon") : icon
1837
1917
  ).optional().transform((value) => value ?? null),
1838
- machineProviderId: z4.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN),
1839
- environmentProviderId: z4.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN)
1918
+ machineProviderId: z5.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN),
1919
+ environmentProviderId: z5.string().regex(ENVIRONMENT_PROVIDER_ID_PATTERN)
1840
1920
  }).strict();
1841
1921
  function requireProviderIdAndDisplayName(noun, declaration) {
1842
1922
  if (typeof declaration !== "object" || declaration === null) {
@@ -1902,8 +1982,8 @@ function validatePluginEnvironmentProviderDeclaration(declaration) {
1902
1982
  "environment provider",
1903
1983
  declaration
1904
1984
  );
1905
- const description = z4.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS).optional().transform((value) => value ?? null).parse(declaration.description);
1906
- const icon = z4.string().trim().min(1).optional().transform((value) => value ?? null).parse(declaration.icon);
1985
+ const description = z5.string().trim().min(1).max(ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS).optional().transform((value) => value ?? null).parse(declaration.description);
1986
+ const icon = z5.string().trim().min(1).optional().transform((value) => value ?? null).parse(declaration.icon);
1907
1987
  if (icon !== null) {
1908
1988
  assertProviderIconShape("environment provider", id, icon);
1909
1989
  }
@@ -1972,9 +2052,9 @@ function normalizeEnvironmentProviderRequirements(id, declaration) {
1972
2052
  }
1973
2053
  return normalized;
1974
2054
  }
1975
- var environmentProviderPolicySchema = z4.object({
1976
- retireGraceMs: z4.number().int().nonnegative().nullable().default(3e5),
1977
- pathKeys: z4.enum(["per-thread", "per-attempt"]).default("per-thread")
2055
+ var environmentProviderPolicySchema = z5.object({
2056
+ retireGraceMs: z5.number().int().nonnegative().nullable().default(3e5),
2057
+ pathKeys: z5.enum(["per-thread", "per-attempt"]).default("per-thread")
1978
2058
  }).strict();
1979
2059
  var MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS = 200;
1980
2060
  function validatePluginMachineProviderDeclaration(declaration) {
@@ -1982,10 +2062,10 @@ function validatePluginMachineProviderDeclaration(declaration) {
1982
2062
  "machine provider",
1983
2063
  declaration
1984
2064
  );
1985
- const description = z4.string().trim().min(1).max(MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS).parse(declaration.description);
1986
- const icon = z4.string().trim().min(1).parse(declaration.icon);
2065
+ const description = z5.string().trim().min(1).max(MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS).parse(declaration.description);
2066
+ const icon = z5.string().trim().min(1).parse(declaration.icon);
1987
2067
  assertProviderIconShape("machine provider", id, icon);
1988
- const ephemeral = z4.boolean().default(false).parse(declaration.ephemeral);
2068
+ const ephemeral = z5.boolean().default(false).parse(declaration.ephemeral);
1989
2069
  const inputs = normalizeProviderInputs(
1990
2070
  "machine provider",
1991
2071
  id,
@@ -2140,13 +2220,14 @@ function normalizeWebSocketRouteRegistration(path, handler, opts, existingRoutes
2140
2220
  }
2141
2221
  return { path, auth };
2142
2222
  }
2143
- function normalizeRpcRegistration(contract, handlers, registered) {
2223
+ function normalizeRpcRegistration(contract, handlers, registered, options) {
2144
2224
  if (typeof contract !== "object" || contract === null || Array.isArray(contract)) {
2145
2225
  throw new Error("rpc.register contract must be an object");
2146
2226
  }
2147
2227
  if (typeof handlers !== "object" || handlers === null || Array.isArray(handlers)) {
2148
2228
  throw new Error("rpc.register handlers must be an object");
2149
2229
  }
2230
+ const publicationOptions = readRpcPublicationOptions(options);
2150
2231
  const pending = [];
2151
2232
  const contractEntries = Object.entries(contract);
2152
2233
  const contractNames = new Set(contractEntries.map(([name]) => name));
@@ -2174,6 +2255,7 @@ function normalizeRpcRegistration(contract, handlers, registered) {
2174
2255
  pending.push([
2175
2256
  name,
2176
2257
  {
2258
+ publication: publishRpcMethod(name, methodContract, publicationOptions),
2177
2259
  inputSchema: methodContract.input,
2178
2260
  outputSchema: methodContract.output,
2179
2261
  handler
@@ -3045,12 +3127,13 @@ function createFakePluginHostInternal(options, sharedState) {
3045
3127
  };
3046
3128
  const rpcHandlers = /* @__PURE__ */ new Map();
3047
3129
  const rpc = {
3048
- register(contract, handlers) {
3130
+ register(contract, handlers, registrationOptions) {
3049
3131
  assertLive();
3050
3132
  for (const [name, record] of normalizeRpcRegistration(
3051
3133
  contract,
3052
3134
  handlers,
3053
- rpcHandlers
3135
+ rpcHandlers,
3136
+ registrationOptions
3054
3137
  )) {
3055
3138
  rpcHandlers.set(name, record);
3056
3139
  }
@@ -3642,6 +3725,11 @@ function createFakePluginHostInternal(options, sharedState) {
3642
3725
  settingsDescriptors,
3643
3726
  httpRoutes,
3644
3727
  websocketRoutes,
3728
+ get experimental_publishedRpcMethods() {
3729
+ return [...rpcHandlers.values()].flatMap(
3730
+ (record) => record.publication === null ? [] : [record.publication]
3731
+ );
3732
+ },
3645
3733
  get rpcMethods() {
3646
3734
  return [...rpcHandlers.keys()];
3647
3735
  },
@@ -4251,6 +4339,7 @@ function makeMessageDispatchHookContext(overrides = {}) {
4251
4339
  },
4252
4340
  attempt: "start-turn",
4253
4341
  queuedMessage: null,
4342
+ experimental_submission: null,
4254
4343
  origin: null,
4255
4344
  originPluginId: null,
4256
4345
  startedOnBehalfOf: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.4.88",
3
+ "version": "0.4.97",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"