@standardagents/builder 0.41.15 → 0.41.17
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/built-in-routes.js +160 -14
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-ChHAVogf.d.ts → index-C82dLGPq.d.ts} +14 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +126 -30
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +21 -1
- package/dist/plugin.js +36 -10
- package/dist/plugin.js.map +1 -1
- package/dist/{resolver-DE5HFRlb.d.ts → resolver-eygn_O1w.d.ts} +12 -4
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +90 -20
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { PluginOption } from 'vite';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Cross-deployment API key exchange: which sibling deployments an instance
|
|
5
|
+
* trusts to vouch for a user. A project lists them once in `builder()`, so
|
|
6
|
+
* production and every preview deployment of that project share the list.
|
|
7
|
+
*/
|
|
8
|
+
interface KeyExchangeOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Origins whose API keys this instance accepts in exchange for its own.
|
|
11
|
+
* Each entry is an exact `https://host` origin or `https://*.suffix`, which
|
|
12
|
+
* matches any host strictly beneath that suffix.
|
|
13
|
+
*/
|
|
14
|
+
trustedOrigins: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
interface DeviceApprovalBrand {
|
|
4
18
|
/** Customer-facing product or instance name. */
|
|
5
19
|
name: string;
|
|
@@ -31,6 +45,12 @@ interface AgentPluginOptions {
|
|
|
31
45
|
providers?: string[];
|
|
32
46
|
/** Presentation used by the built-in device sign-in confirmation page. */
|
|
33
47
|
deviceApproval?: DeviceApprovalBrand;
|
|
48
|
+
/**
|
|
49
|
+
* Sibling deployments of this project (production and its previews) whose
|
|
50
|
+
* API keys `POST /api/auth/exchange` accepts in exchange for a key on this
|
|
51
|
+
* instance. Absent disables the exchange.
|
|
52
|
+
*/
|
|
53
|
+
keyExchange?: KeyExchangeOptions;
|
|
34
54
|
/**
|
|
35
55
|
* Exact additional hostnames trusted for local authoring APIs.
|
|
36
56
|
* Anyone who can reach the dev server through one of these names can attempt
|
|
@@ -42,4 +62,4 @@ interface AgentPluginOptions {
|
|
|
42
62
|
declare function agentbuilder(options?: AgentPluginOptions): PluginOption[];
|
|
43
63
|
declare const builder: typeof agentbuilder;
|
|
44
64
|
|
|
45
|
-
export { type AgentPluginOptions, type DeviceApprovalBrand, agentbuilder, builder };
|
|
65
|
+
export { type AgentPluginOptions, type DeviceApprovalBrand, type KeyExchangeOptions, agentbuilder, builder };
|
package/dist/plugin.js
CHANGED
|
@@ -574,14 +574,7 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
574
574
|
terminated?: number | null;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
-
export
|
|
578
|
-
id: string;
|
|
579
|
-
username: string;
|
|
580
|
-
password_hash: string;
|
|
581
|
-
role: 'admin';
|
|
582
|
-
created_at: number;
|
|
583
|
-
updated_at: number;
|
|
584
|
-
}
|
|
577
|
+
export type User = NonNullable<Awaited<ReturnType<BaseDurableAgentBuilder['getUserById']>>>;
|
|
585
578
|
|
|
586
579
|
export interface Provider {
|
|
587
580
|
name: string;
|
|
@@ -8202,7 +8195,8 @@ async function loadVirtualModule(id, context) {
|
|
|
8202
8195
|
installedProviders,
|
|
8203
8196
|
rou3Code,
|
|
8204
8197
|
hmr,
|
|
8205
|
-
deviceApproval
|
|
8198
|
+
deviceApproval,
|
|
8199
|
+
keyExchange
|
|
8206
8200
|
} = context;
|
|
8207
8201
|
if (id === RESOLVED_VIRTUAL_TOOLS_ID) {
|
|
8208
8202
|
const tools = await scanToolsDirectory(toolsDir);
|
|
@@ -8267,6 +8261,7 @@ export const config = {
|
|
|
8267
8261
|
promptsDir: "${relativePromptsDir}",
|
|
8268
8262
|
agentsDir: "${relativeAgentsDir}",
|
|
8269
8263
|
deviceApproval: ${JSON.stringify(deviceApproval ?? null)},
|
|
8264
|
+
keyExchange: ${JSON.stringify(keyExchange ?? null)},
|
|
8270
8265
|
};`;
|
|
8271
8266
|
}
|
|
8272
8267
|
if (id === RESOLVED_VIRTUAL_MODELS_ID) {
|
|
@@ -8675,6 +8670,35 @@ function applyPluginEnvironmentConfig(config, options = {}) {
|
|
|
8675
8670
|
}
|
|
8676
8671
|
}
|
|
8677
8672
|
|
|
8673
|
+
// src/utils/key-exchange.ts
|
|
8674
|
+
var HOST_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
8675
|
+
function validHost(host) {
|
|
8676
|
+
return host.length <= 253 && host.split(".").length >= 2 && host.split(".").every((label) => HOST_LABEL.test(label));
|
|
8677
|
+
}
|
|
8678
|
+
function normalizeTrustedOrigin(value) {
|
|
8679
|
+
if (typeof value !== "string") {
|
|
8680
|
+
throw new Error("keyExchange.trustedOrigins entries must be strings");
|
|
8681
|
+
}
|
|
8682
|
+
const entry = value.trim().toLowerCase();
|
|
8683
|
+
const host = entry.startsWith("https://") ? entry.slice("https://".length) : "";
|
|
8684
|
+
const wildcard = host.startsWith("*.");
|
|
8685
|
+
if (!validHost(wildcard ? host.slice(2) : host)) {
|
|
8686
|
+
throw new Error(`keyExchange.trustedOrigins entry ${JSON.stringify(value)} must be https://host or https://*.suffix`);
|
|
8687
|
+
}
|
|
8688
|
+
return entry;
|
|
8689
|
+
}
|
|
8690
|
+
function normalizeKeyExchange(value) {
|
|
8691
|
+
if (value === void 0) return void 0;
|
|
8692
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.trustedOrigins)) {
|
|
8693
|
+
throw new Error("keyExchange must be an object with a trustedOrigins array");
|
|
8694
|
+
}
|
|
8695
|
+
const trustedOrigins = [...new Set(value.trustedOrigins.map(normalizeTrustedOrigin))];
|
|
8696
|
+
if (trustedOrigins.length === 0) {
|
|
8697
|
+
throw new Error("keyExchange.trustedOrigins must name at least one origin");
|
|
8698
|
+
}
|
|
8699
|
+
return { trustedOrigins };
|
|
8700
|
+
}
|
|
8701
|
+
|
|
8678
8702
|
// src/plugin/device-approval.ts
|
|
8679
8703
|
function requiredText(value, field, maxLength) {
|
|
8680
8704
|
if (typeof value !== "string" || !value.trim() || value.trim().length > maxLength) {
|
|
@@ -8719,6 +8743,7 @@ function normalizeDeviceApprovalBrand(value) {
|
|
|
8719
8743
|
// src/plugin.ts
|
|
8720
8744
|
function agentbuilder(options = {}) {
|
|
8721
8745
|
const deviceApproval = normalizeDeviceApprovalBrand(options.deviceApproval);
|
|
8746
|
+
const keyExchange = normalizeKeyExchange(options.keyExchange);
|
|
8722
8747
|
const trustedDevHosts = normalizeTrustedDevHosts(options.trustedDevHosts);
|
|
8723
8748
|
const toolsDir = options.toolsDir ? path9__default.resolve(process.cwd(), options.toolsDir) : path9__default.resolve(process.cwd(), "agents/tools");
|
|
8724
8749
|
const hooksDir = options.hooksDir ? path9__default.resolve(process.cwd(), options.hooksDir) : path9__default.resolve(process.cwd(), "agents/hooks");
|
|
@@ -8815,7 +8840,8 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
|
|
|
8815
8840
|
installedProviders,
|
|
8816
8841
|
rou3Code,
|
|
8817
8842
|
hmr,
|
|
8818
|
-
deviceApproval
|
|
8843
|
+
deviceApproval,
|
|
8844
|
+
keyExchange
|
|
8819
8845
|
};
|
|
8820
8846
|
const devMiddlewareContext = {
|
|
8821
8847
|
toolsDir,
|