@standardagents/builder 0.41.15 → 0.41.16
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 +97 -1
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-ChHAVogf.d.ts → index-BrQgCoFh.d.ts} +11 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +21 -1
- package/dist/plugin.js +35 -2
- package/dist/plugin.js.map +1 -1
- package/dist/{resolver-DE5HFRlb.d.ts → resolver-CWWRzZU1.d.ts} +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +1 -0
- 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
|
@@ -8202,7 +8202,8 @@ async function loadVirtualModule(id, context) {
|
|
|
8202
8202
|
installedProviders,
|
|
8203
8203
|
rou3Code,
|
|
8204
8204
|
hmr,
|
|
8205
|
-
deviceApproval
|
|
8205
|
+
deviceApproval,
|
|
8206
|
+
keyExchange
|
|
8206
8207
|
} = context;
|
|
8207
8208
|
if (id === RESOLVED_VIRTUAL_TOOLS_ID) {
|
|
8208
8209
|
const tools = await scanToolsDirectory(toolsDir);
|
|
@@ -8267,6 +8268,7 @@ export const config = {
|
|
|
8267
8268
|
promptsDir: "${relativePromptsDir}",
|
|
8268
8269
|
agentsDir: "${relativeAgentsDir}",
|
|
8269
8270
|
deviceApproval: ${JSON.stringify(deviceApproval ?? null)},
|
|
8271
|
+
keyExchange: ${JSON.stringify(keyExchange ?? null)},
|
|
8270
8272
|
};`;
|
|
8271
8273
|
}
|
|
8272
8274
|
if (id === RESOLVED_VIRTUAL_MODELS_ID) {
|
|
@@ -8675,6 +8677,35 @@ function applyPluginEnvironmentConfig(config, options = {}) {
|
|
|
8675
8677
|
}
|
|
8676
8678
|
}
|
|
8677
8679
|
|
|
8680
|
+
// src/utils/key-exchange.ts
|
|
8681
|
+
var HOST_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
8682
|
+
function validHost(host) {
|
|
8683
|
+
return host.length <= 253 && host.split(".").length >= 2 && host.split(".").every((label) => HOST_LABEL.test(label));
|
|
8684
|
+
}
|
|
8685
|
+
function normalizeTrustedOrigin(value) {
|
|
8686
|
+
if (typeof value !== "string") {
|
|
8687
|
+
throw new Error("keyExchange.trustedOrigins entries must be strings");
|
|
8688
|
+
}
|
|
8689
|
+
const entry = value.trim().toLowerCase();
|
|
8690
|
+
const host = entry.startsWith("https://") ? entry.slice("https://".length) : "";
|
|
8691
|
+
const wildcard = host.startsWith("*.");
|
|
8692
|
+
if (!validHost(wildcard ? host.slice(2) : host)) {
|
|
8693
|
+
throw new Error(`keyExchange.trustedOrigins entry ${JSON.stringify(value)} must be https://host or https://*.suffix`);
|
|
8694
|
+
}
|
|
8695
|
+
return entry;
|
|
8696
|
+
}
|
|
8697
|
+
function normalizeKeyExchange(value) {
|
|
8698
|
+
if (value === void 0) return void 0;
|
|
8699
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.trustedOrigins)) {
|
|
8700
|
+
throw new Error("keyExchange must be an object with a trustedOrigins array");
|
|
8701
|
+
}
|
|
8702
|
+
const trustedOrigins = [...new Set(value.trustedOrigins.map(normalizeTrustedOrigin))];
|
|
8703
|
+
if (trustedOrigins.length === 0) {
|
|
8704
|
+
throw new Error("keyExchange.trustedOrigins must name at least one origin");
|
|
8705
|
+
}
|
|
8706
|
+
return { trustedOrigins };
|
|
8707
|
+
}
|
|
8708
|
+
|
|
8678
8709
|
// src/plugin/device-approval.ts
|
|
8679
8710
|
function requiredText(value, field, maxLength) {
|
|
8680
8711
|
if (typeof value !== "string" || !value.trim() || value.trim().length > maxLength) {
|
|
@@ -8719,6 +8750,7 @@ function normalizeDeviceApprovalBrand(value) {
|
|
|
8719
8750
|
// src/plugin.ts
|
|
8720
8751
|
function agentbuilder(options = {}) {
|
|
8721
8752
|
const deviceApproval = normalizeDeviceApprovalBrand(options.deviceApproval);
|
|
8753
|
+
const keyExchange = normalizeKeyExchange(options.keyExchange);
|
|
8722
8754
|
const trustedDevHosts = normalizeTrustedDevHosts(options.trustedDevHosts);
|
|
8723
8755
|
const toolsDir = options.toolsDir ? path9__default.resolve(process.cwd(), options.toolsDir) : path9__default.resolve(process.cwd(), "agents/tools");
|
|
8724
8756
|
const hooksDir = options.hooksDir ? path9__default.resolve(process.cwd(), options.hooksDir) : path9__default.resolve(process.cwd(), "agents/hooks");
|
|
@@ -8815,7 +8847,8 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
|
|
|
8815
8847
|
installedProviders,
|
|
8816
8848
|
rou3Code,
|
|
8817
8849
|
hmr,
|
|
8818
|
-
deviceApproval
|
|
8850
|
+
deviceApproval,
|
|
8851
|
+
keyExchange
|
|
8819
8852
|
};
|
|
8820
8853
|
const devMiddlewareContext = {
|
|
8821
8854
|
toolsDir,
|