@standardagents/builder 0.11.0-next.c3b4490 → 0.11.1
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 +158 -8
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.d.ts +28 -19
- package/dist/index.js +164 -14
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +6 -6
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -13,63 +13,71 @@ import 'vite';
|
|
|
13
13
|
* Types are automatically populated when you run `pnpm dev` or `pnpm build`,
|
|
14
14
|
* which scans your `agentbuilder/` directories and generates types.
|
|
15
15
|
*
|
|
16
|
-
* The generated types are placed in `.
|
|
16
|
+
* The generated types are placed in `.agents/types.d.ts` and augment the
|
|
17
|
+
* StandardAgentSpec namespace from @standardagents/spec.
|
|
17
18
|
*
|
|
18
|
-
* Note:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Note: This namespace is provided for backward compatibility. New code should
|
|
20
|
+
* use StandardAgentSpec types directly, which are defined in @standardagents/spec.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use StandardAgentSpec namespace from @standardagents/spec instead
|
|
21
23
|
*/
|
|
22
24
|
declare global {
|
|
23
25
|
namespace AgentBuilder {
|
|
24
26
|
/**
|
|
25
27
|
* Interface for model type registration.
|
|
26
|
-
*
|
|
27
|
-
* This gives us: type Models = keyof ModelRegistry = 'gpt-4o' | 'claude-3'
|
|
28
|
+
* @deprecated Use StandardAgentSpec.ModelRegistry instead
|
|
28
29
|
*/
|
|
29
|
-
interface ModelRegistry {
|
|
30
|
+
interface ModelRegistry extends StandardAgentSpec.ModelRegistry {
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Interface for prompt type registration.
|
|
34
|
+
* @deprecated Use StandardAgentSpec.PromptRegistry instead
|
|
33
35
|
*/
|
|
34
|
-
interface PromptRegistry {
|
|
36
|
+
interface PromptRegistry extends StandardAgentSpec.PromptRegistry {
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Interface for agent type registration.
|
|
40
|
+
* @deprecated Use StandardAgentSpec.AgentRegistry instead
|
|
38
41
|
*/
|
|
39
|
-
interface AgentRegistry {
|
|
42
|
+
interface AgentRegistry extends StandardAgentSpec.AgentRegistry {
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
42
45
|
* Interface for tool type registration.
|
|
46
|
+
* @deprecated Use StandardAgentSpec.ToolRegistry instead
|
|
43
47
|
*/
|
|
44
|
-
interface ToolRegistry {
|
|
48
|
+
interface ToolRegistry extends StandardAgentSpec.ToolRegistry {
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Interface for callable type registration (prompts, agents, tools).
|
|
52
|
+
* @deprecated Use StandardAgentSpec.CallableRegistry instead
|
|
48
53
|
*/
|
|
49
|
-
interface CallableRegistry {
|
|
54
|
+
interface CallableRegistry extends StandardAgentSpec.CallableRegistry {
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
52
57
|
* Union type of all model names defined in agentbuilder/models/.
|
|
53
|
-
*
|
|
54
|
-
* When populated, it narrows to the specific model names.
|
|
58
|
+
* @deprecated Use StandardAgentSpec.Models instead
|
|
55
59
|
*/
|
|
56
|
-
type Models =
|
|
60
|
+
type Models = StandardAgentSpec.Models;
|
|
57
61
|
/**
|
|
58
62
|
* Union type of all prompt names defined in agentbuilder/prompts/.
|
|
63
|
+
* @deprecated Use StandardAgentSpec.Prompts instead
|
|
59
64
|
*/
|
|
60
|
-
type Prompts =
|
|
65
|
+
type Prompts = StandardAgentSpec.Prompts;
|
|
61
66
|
/**
|
|
62
67
|
* Union type of all agent names defined in agentbuilder/agents/.
|
|
68
|
+
* @deprecated Use StandardAgentSpec.Agents instead
|
|
63
69
|
*/
|
|
64
|
-
type Agents =
|
|
70
|
+
type Agents = StandardAgentSpec.Agents;
|
|
65
71
|
/**
|
|
66
72
|
* Union type of all tool names defined in agentbuilder/tools/.
|
|
73
|
+
* @deprecated Use StandardAgentSpec.Tools instead
|
|
67
74
|
*/
|
|
68
|
-
type Tools =
|
|
75
|
+
type Tools = StandardAgentSpec.Tools;
|
|
69
76
|
/**
|
|
70
77
|
* Union type of all callable items (prompts, agents, tools) that can be used as tools.
|
|
78
|
+
* @deprecated Use StandardAgentSpec.Callables instead
|
|
71
79
|
*/
|
|
72
|
-
type Callables =
|
|
80
|
+
type Callables = StandardAgentSpec.Callables;
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -273,7 +281,8 @@ interface ThreadInstance {
|
|
|
273
281
|
loadAgent(name: string): Promise<any>;
|
|
274
282
|
getPromptNames(): string[];
|
|
275
283
|
getAgentNames(): string[];
|
|
276
|
-
writeFile(path: string, data:
|
|
284
|
+
writeFile(path: string, data: string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
|
|
285
|
+
writeTextFile(path: string, content: string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
|
|
277
286
|
readFile(path: string): Promise<{
|
|
278
287
|
success: boolean;
|
|
279
288
|
data?: string;
|
package/dist/index.js
CHANGED
|
@@ -2212,8 +2212,105 @@ var init_ThreadStateImpl = __esm({
|
|
|
2212
2212
|
// File System
|
|
2213
2213
|
// ─────────────────────────────────────────────────────────────────────────
|
|
2214
2214
|
async writeFile(path4, data, mimeType, options) {
|
|
2215
|
-
const
|
|
2216
|
-
|
|
2215
|
+
const isText = this._isTextMimeType(mimeType);
|
|
2216
|
+
if (isText) {
|
|
2217
|
+
let textContent;
|
|
2218
|
+
if (typeof data === "string") {
|
|
2219
|
+
textContent = data;
|
|
2220
|
+
} else {
|
|
2221
|
+
textContent = new TextDecoder().decode(data);
|
|
2222
|
+
}
|
|
2223
|
+
const result = await this._threadInstance.writeTextFile(path4, textContent, mimeType, options);
|
|
2224
|
+
return this._mapFileRecord(result.file);
|
|
2225
|
+
} else {
|
|
2226
|
+
let base64Data;
|
|
2227
|
+
if (typeof data === "string") {
|
|
2228
|
+
const encoder = new TextEncoder();
|
|
2229
|
+
const bytes = encoder.encode(data);
|
|
2230
|
+
let binary = "";
|
|
2231
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
2232
|
+
binary += String.fromCharCode(bytes[i]);
|
|
2233
|
+
}
|
|
2234
|
+
base64Data = btoa(binary);
|
|
2235
|
+
} else {
|
|
2236
|
+
const bytes = new Uint8Array(data);
|
|
2237
|
+
let binary = "";
|
|
2238
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
2239
|
+
binary += String.fromCharCode(bytes[i]);
|
|
2240
|
+
}
|
|
2241
|
+
base64Data = btoa(binary);
|
|
2242
|
+
}
|
|
2243
|
+
const result = await this._threadInstance.writeFile(path4, base64Data, mimeType, options);
|
|
2244
|
+
return this._mapFileRecord(result.file);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Check if a MIME type should be stored as searchable text.
|
|
2249
|
+
* Matches the logic in FileStorage for consistency.
|
|
2250
|
+
*/
|
|
2251
|
+
_isTextMimeType(mimeType) {
|
|
2252
|
+
if (mimeType.startsWith("text/")) return true;
|
|
2253
|
+
const TEXT_APPLICATION_TYPES2 = [
|
|
2254
|
+
// Data formats
|
|
2255
|
+
"application/json",
|
|
2256
|
+
"application/ld+json",
|
|
2257
|
+
"application/json5",
|
|
2258
|
+
"application/jsonl",
|
|
2259
|
+
"application/x-ndjson",
|
|
2260
|
+
"application/xml",
|
|
2261
|
+
"application/xhtml+xml",
|
|
2262
|
+
"application/rss+xml",
|
|
2263
|
+
"application/atom+xml",
|
|
2264
|
+
"application/soap+xml",
|
|
2265
|
+
"application/yaml",
|
|
2266
|
+
"application/x-yaml",
|
|
2267
|
+
"application/toml",
|
|
2268
|
+
"application/x-toml",
|
|
2269
|
+
// Programming languages
|
|
2270
|
+
"application/javascript",
|
|
2271
|
+
"application/x-javascript",
|
|
2272
|
+
"application/ecmascript",
|
|
2273
|
+
"application/typescript",
|
|
2274
|
+
"application/x-typescript",
|
|
2275
|
+
"application/x-python",
|
|
2276
|
+
"application/x-ruby",
|
|
2277
|
+
"application/x-perl",
|
|
2278
|
+
"application/x-php",
|
|
2279
|
+
"application/x-sh",
|
|
2280
|
+
"application/x-bash",
|
|
2281
|
+
"application/x-csh",
|
|
2282
|
+
"application/x-zsh",
|
|
2283
|
+
"application/x-powershell",
|
|
2284
|
+
"application/x-lua",
|
|
2285
|
+
"application/x-tcl",
|
|
2286
|
+
// Query/config languages
|
|
2287
|
+
"application/sql",
|
|
2288
|
+
"application/x-sql",
|
|
2289
|
+
"application/graphql",
|
|
2290
|
+
"application/x-graphql",
|
|
2291
|
+
"application/sparql-query",
|
|
2292
|
+
"application/sparql-results+json",
|
|
2293
|
+
"application/sparql-results+xml",
|
|
2294
|
+
// Markup/templates
|
|
2295
|
+
"application/x-httpd-php",
|
|
2296
|
+
"application/x-latex",
|
|
2297
|
+
"application/x-tex",
|
|
2298
|
+
"application/rtf",
|
|
2299
|
+
"application/xslt+xml",
|
|
2300
|
+
// Web
|
|
2301
|
+
"application/x-www-form-urlencoded",
|
|
2302
|
+
"application/manifest+json",
|
|
2303
|
+
"application/webmanifest+json",
|
|
2304
|
+
"application/x-web-app-manifest+json",
|
|
2305
|
+
// Config files
|
|
2306
|
+
"application/x-ini",
|
|
2307
|
+
"application/x-properties",
|
|
2308
|
+
"application/plist",
|
|
2309
|
+
"application/x-plist"
|
|
2310
|
+
];
|
|
2311
|
+
return TEXT_APPLICATION_TYPES2.some(
|
|
2312
|
+
(type) => mimeType === type || mimeType.startsWith(type + ";")
|
|
2313
|
+
);
|
|
2217
2314
|
}
|
|
2218
2315
|
async readFile(path4) {
|
|
2219
2316
|
const result = await this._threadInstance.readFile(path4);
|
|
@@ -2476,7 +2573,10 @@ __export(files_exports, {
|
|
|
2476
2573
|
rowToFileRecord: () => rowToFileRecord
|
|
2477
2574
|
});
|
|
2478
2575
|
function isTextMimeType(mimeType) {
|
|
2479
|
-
|
|
2576
|
+
if (mimeType.startsWith("text/")) return true;
|
|
2577
|
+
return TEXT_APPLICATION_TYPES.some(
|
|
2578
|
+
(type) => mimeType === type || mimeType.startsWith(type + ";")
|
|
2579
|
+
);
|
|
2480
2580
|
}
|
|
2481
2581
|
function detectStorageBackend(location) {
|
|
2482
2582
|
if (location.startsWith("s3://")) return "s3";
|
|
@@ -2553,17 +2653,67 @@ function inferMimeType(filename) {
|
|
|
2553
2653
|
};
|
|
2554
2654
|
return mimeTypes[ext || ""] || "application/octet-stream";
|
|
2555
2655
|
}
|
|
2556
|
-
var CHUNK_SIZE,
|
|
2656
|
+
var CHUNK_SIZE, TEXT_APPLICATION_TYPES, FileStorage;
|
|
2557
2657
|
var init_files = __esm({
|
|
2558
2658
|
"src/durable-objects/files.ts"() {
|
|
2559
2659
|
CHUNK_SIZE = 1.75 * 1024 * 1024;
|
|
2560
|
-
|
|
2561
|
-
|
|
2660
|
+
TEXT_APPLICATION_TYPES = [
|
|
2661
|
+
// Data formats
|
|
2562
2662
|
"application/json",
|
|
2563
|
-
"application/
|
|
2663
|
+
"application/ld+json",
|
|
2664
|
+
"application/json5",
|
|
2665
|
+
"application/jsonl",
|
|
2666
|
+
"application/x-ndjson",
|
|
2564
2667
|
"application/xml",
|
|
2668
|
+
"application/xhtml+xml",
|
|
2669
|
+
"application/rss+xml",
|
|
2670
|
+
"application/atom+xml",
|
|
2671
|
+
"application/soap+xml",
|
|
2672
|
+
"application/yaml",
|
|
2565
2673
|
"application/x-yaml",
|
|
2566
|
-
"application/
|
|
2674
|
+
"application/toml",
|
|
2675
|
+
"application/x-toml",
|
|
2676
|
+
// Programming languages
|
|
2677
|
+
"application/javascript",
|
|
2678
|
+
"application/x-javascript",
|
|
2679
|
+
"application/ecmascript",
|
|
2680
|
+
"application/typescript",
|
|
2681
|
+
"application/x-typescript",
|
|
2682
|
+
"application/x-python",
|
|
2683
|
+
"application/x-ruby",
|
|
2684
|
+
"application/x-perl",
|
|
2685
|
+
"application/x-php",
|
|
2686
|
+
"application/x-sh",
|
|
2687
|
+
"application/x-bash",
|
|
2688
|
+
"application/x-csh",
|
|
2689
|
+
"application/x-zsh",
|
|
2690
|
+
"application/x-powershell",
|
|
2691
|
+
"application/x-lua",
|
|
2692
|
+
"application/x-tcl",
|
|
2693
|
+
// Query/config languages
|
|
2694
|
+
"application/sql",
|
|
2695
|
+
"application/x-sql",
|
|
2696
|
+
"application/graphql",
|
|
2697
|
+
"application/x-graphql",
|
|
2698
|
+
"application/sparql-query",
|
|
2699
|
+
"application/sparql-results+json",
|
|
2700
|
+
"application/sparql-results+xml",
|
|
2701
|
+
// Markup/templates
|
|
2702
|
+
"application/x-httpd-php",
|
|
2703
|
+
"application/x-latex",
|
|
2704
|
+
"application/x-tex",
|
|
2705
|
+
"application/rtf",
|
|
2706
|
+
"application/xslt+xml",
|
|
2707
|
+
// Web
|
|
2708
|
+
"application/x-www-form-urlencoded",
|
|
2709
|
+
"application/manifest+json",
|
|
2710
|
+
"application/webmanifest+json",
|
|
2711
|
+
"application/x-web-app-manifest+json",
|
|
2712
|
+
// Config files
|
|
2713
|
+
"application/x-ini",
|
|
2714
|
+
"application/x-properties",
|
|
2715
|
+
"application/plist",
|
|
2716
|
+
"application/x-plist"
|
|
2567
2717
|
];
|
|
2568
2718
|
FileStorage = class {
|
|
2569
2719
|
constructor(sql) {
|
|
@@ -7521,18 +7671,18 @@ function generateTypesContent(config) {
|
|
|
7521
7671
|
return `// Auto-generated by @standardagents/builder - DO NOT EDIT
|
|
7522
7672
|
// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
7523
7673
|
//
|
|
7524
|
-
// This file augments the
|
|
7674
|
+
// This file augments the StandardAgentSpec namespace declared in @standardagents/spec
|
|
7525
7675
|
// to provide type-safe references for your models, prompts, agents, and tools.
|
|
7526
7676
|
|
|
7527
7677
|
/**
|
|
7528
|
-
* Augment the global
|
|
7678
|
+
* Augment the global StandardAgentSpec namespace with your project's specific types.
|
|
7529
7679
|
* This provides autocomplete and type checking for model, prompt, agent, and tool references.
|
|
7530
7680
|
*
|
|
7531
7681
|
* Uses interface declaration merging with property keys to create union types.
|
|
7532
7682
|
* Example: interface ModelRegistry { 'gpt-4o': true; } gives type Models = 'gpt-4o'
|
|
7533
7683
|
*/
|
|
7534
7684
|
declare global {
|
|
7535
|
-
namespace
|
|
7685
|
+
namespace StandardAgentSpec {
|
|
7536
7686
|
/** Model names from agents/models/ */
|
|
7537
7687
|
interface ModelRegistry {
|
|
7538
7688
|
${generateRegistryProperties(models)}
|
|
@@ -8120,7 +8270,7 @@ function parseModelFile(content) {
|
|
|
8120
8270
|
function generateModelFile(data, options) {
|
|
8121
8271
|
const { providerName, providerPackage } = options;
|
|
8122
8272
|
const lines = [
|
|
8123
|
-
`import { defineModel } from '@standardagents/
|
|
8273
|
+
`import { defineModel } from '@standardagents/spec';`,
|
|
8124
8274
|
`import { ${providerName} } from '${providerPackage}';`,
|
|
8125
8275
|
"",
|
|
8126
8276
|
`export default defineModel({`,
|
|
@@ -8354,7 +8504,7 @@ function isEmptySchema(schema) {
|
|
|
8354
8504
|
// src/sdk/generators/generatePromptFile.ts
|
|
8355
8505
|
function generatePromptFile(data) {
|
|
8356
8506
|
const hasSchema = data.requiredSchema && !isEmptySchema(data.requiredSchema);
|
|
8357
|
-
const lines = [`import { definePrompt } from '@standardagents/
|
|
8507
|
+
const lines = [`import { definePrompt } from '@standardagents/spec';`];
|
|
8358
8508
|
if (hasSchema) {
|
|
8359
8509
|
lines.push(`import { z } from 'zod';`);
|
|
8360
8510
|
}
|
|
@@ -8544,7 +8694,7 @@ function normalizePart(part) {
|
|
|
8544
8694
|
// src/sdk/generators/generateAgentFile.ts
|
|
8545
8695
|
function generateAgentFile(data) {
|
|
8546
8696
|
const lines = [
|
|
8547
|
-
`import { defineAgent } from '@standardagents/
|
|
8697
|
+
`import { defineAgent } from '@standardagents/spec';`,
|
|
8548
8698
|
"",
|
|
8549
8699
|
`export default defineAgent({`,
|
|
8550
8700
|
` name: '${escapeString3(data.name)}',`
|