@standardagents/builder 0.40.0 → 0.40.2

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/plugin.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import { PluginOption } from 'vite';
2
2
 
3
+ interface DeviceApprovalBrand {
4
+ /** Customer-facing product or instance name. */
5
+ name: string;
6
+ /** Optional short explanation shown before the user connects the device. */
7
+ description?: string;
8
+ /** Optional safe HTTPS or root-relative image URL. */
9
+ logoUrl?: string;
10
+ }
11
+
3
12
  interface AgentPluginOptions {
4
13
  compatibilityDate?: string;
5
14
  toolsDir?: string;
@@ -17,8 +26,10 @@ interface AgentPluginOptions {
17
26
  * @example ['my-custom-provider', '@company/custom-openai']
18
27
  */
19
28
  providers?: string[];
29
+ /** Presentation used by the built-in device sign-in confirmation page. */
30
+ deviceApproval?: DeviceApprovalBrand;
20
31
  }
21
32
  declare function agentbuilder(options?: AgentPluginOptions): PluginOption[];
22
33
  declare const builder: typeof agentbuilder;
23
34
 
24
- export { type AgentPluginOptions, agentbuilder, builder };
35
+ export { type AgentPluginOptions, type DeviceApprovalBrand, agentbuilder, builder };
package/dist/plugin.js CHANGED
@@ -8077,7 +8077,8 @@ async function loadVirtualModule(id, context) {
8077
8077
  effectsDir,
8078
8078
  installedProviders,
8079
8079
  rou3Code,
8080
- hmr
8080
+ hmr,
8081
+ deviceApproval
8081
8082
  } = context;
8082
8083
  if (id === RESOLVED_VIRTUAL_TOOLS_ID) {
8083
8084
  const tools = await scanToolsDirectory(toolsDir);
@@ -8141,6 +8142,7 @@ export const config = {
8141
8142
  providersDir: "${relativeProvidersDir}",
8142
8143
  promptsDir: "${relativePromptsDir}",
8143
8144
  agentsDir: "${relativeAgentsDir}",
8145
+ deviceApproval: ${JSON.stringify(deviceApproval ?? null)},
8144
8146
  };`;
8145
8147
  }
8146
8148
  if (id === RESOLVED_VIRTUAL_MODELS_ID) {
@@ -8500,8 +8502,50 @@ function applyPluginEnvironmentConfig(config) {
8500
8502
  }
8501
8503
  }
8502
8504
 
8505
+ // src/plugin/device-approval.ts
8506
+ function requiredText(value, field, maxLength) {
8507
+ if (typeof value !== "string" || !value.trim() || value.trim().length > maxLength) {
8508
+ throw new Error(`deviceApproval.${field} must be a non-empty string of ${maxLength} characters or fewer`);
8509
+ }
8510
+ return value.trim();
8511
+ }
8512
+ function optionalText(value, field, maxLength) {
8513
+ if (value === void 0 || value === null || value === "") return void 0;
8514
+ if (typeof value !== "string" || !value.trim() || value.trim().length > maxLength) {
8515
+ throw new Error(`deviceApproval.${field} must be a string of ${maxLength} characters or fewer`);
8516
+ }
8517
+ return value.trim();
8518
+ }
8519
+ function safeLogoUrl(value) {
8520
+ const logoUrl = optionalText(value, "logoUrl", 2048);
8521
+ if (!logoUrl) return void 0;
8522
+ if (logoUrl.startsWith("/") && !logoUrl.startsWith("//") && !logoUrl.includes("#") && !logoUrl.includes("\\")) {
8523
+ return logoUrl;
8524
+ }
8525
+ try {
8526
+ const parsed = new URL(logoUrl);
8527
+ if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new Error();
8528
+ return parsed.toString();
8529
+ } catch {
8530
+ throw new Error("deviceApproval.logoUrl must be a safe HTTPS or root-relative URL");
8531
+ }
8532
+ }
8533
+ function normalizeDeviceApprovalBrand(value) {
8534
+ if (value === void 0) return void 0;
8535
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
8536
+ throw new Error("deviceApproval must be an object");
8537
+ }
8538
+ const normalized = { name: requiredText(value.name, "name", 100) };
8539
+ const description = optionalText(value.description, "description", 280);
8540
+ const logoUrl = safeLogoUrl(value.logoUrl);
8541
+ if (description) normalized.description = description;
8542
+ if (logoUrl) normalized.logoUrl = logoUrl;
8543
+ return normalized;
8544
+ }
8545
+
8503
8546
  // src/plugin.ts
8504
8547
  function agentbuilder(options = {}) {
8548
+ const deviceApproval = normalizeDeviceApprovalBrand(options.deviceApproval);
8505
8549
  const toolsDir = options.toolsDir ? path9__default.resolve(process.cwd(), options.toolsDir) : path9__default.resolve(process.cwd(), "agents/tools");
8506
8550
  const hooksDir = options.hooksDir ? path9__default.resolve(process.cwd(), options.hooksDir) : path9__default.resolve(process.cwd(), "agents/hooks");
8507
8551
  const threadApiDir = options.apiDir ? path9__default.resolve(process.cwd(), options.apiDir) : path9__default.resolve(process.cwd(), "agents/api");
@@ -8592,7 +8636,8 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
8592
8636
  effectsDir,
8593
8637
  installedProviders,
8594
8638
  rou3Code,
8595
- hmr
8639
+ hmr,
8640
+ deviceApproval
8596
8641
  };
8597
8642
  const devMiddlewareContext = {
8598
8643
  toolsDir,