@framers/agentos 0.10.40 → 0.11.0
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/api/agency.d.ts.map +1 -1
- package/dist/api/agency.js +140 -114
- package/dist/api/agency.js.map +1 -1
- package/dist/api/agent.d.ts +9 -5
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +7 -5
- package/dist/api/agent.js.map +1 -1
- package/dist/api/agentExport.d.ts +60 -21
- package/dist/api/agentExport.d.ts.map +1 -1
- package/dist/api/agentExport.js +240 -41
- package/dist/api/agentExport.js.map +1 -1
- package/dist/api/agentExportCore.d.ts +44 -6
- package/dist/api/agentExportCore.d.ts.map +1 -1
- package/dist/api/agentExportCore.js +43 -8
- package/dist/api/agentExportCore.js.map +1 -1
- package/dist/api/agentExportRedact.d.ts +58 -0
- package/dist/api/agentExportRedact.d.ts.map +1 -0
- package/dist/api/agentExportRedact.js +219 -0
- package/dist/api/agentExportRedact.js.map +1 -0
- package/dist/api/generateText.d.ts +11 -0
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +27 -0
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/model.d.ts +12 -0
- package/dist/api/model.d.ts.map +1 -1
- package/dist/api/model.js +11 -0
- package/dist/api/model.js.map +1 -1
- package/dist/api/runtime/approval-gate.d.ts +92 -0
- package/dist/api/runtime/approval-gate.d.ts.map +1 -0
- package/dist/api/runtime/approval-gate.js +182 -0
- package/dist/api/runtime/approval-gate.js.map +1 -0
- package/dist/api/runtime/tool-emulation/loop.d.ts +16 -0
- package/dist/api/runtime/tool-emulation/loop.d.ts.map +1 -1
- package/dist/api/runtime/tool-emulation/loop.js +25 -3
- package/dist/api/runtime/tool-emulation/loop.js.map +1 -1
- package/dist/api/streamText.d.ts.map +1 -1
- package/dist/api/streamText.js +33 -0
- package/dist/api/streamText.js.map +1 -1
- package/dist/api/types.d.ts +23 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +120 -32
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.js +602 -19
- package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/cognition/emergent/EmergentToolRegistry.d.ts +180 -38
- package/dist/cognition/emergent/EmergentToolRegistry.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentToolRegistry.js +645 -96
- package/dist/cognition/emergent/EmergentToolRegistry.js.map +1 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.js +5 -5
- package/dist/cognition/emergent/ForgeToolMetaTool.js.map +1 -1
- package/dist/cognition/emergent/capabilities.d.ts +27 -0
- package/dist/cognition/emergent/capabilities.d.ts.map +1 -0
- package/dist/cognition/emergent/capabilities.js +50 -0
- package/dist/cognition/emergent/capabilities.js.map +1 -0
- package/dist/cognition/emergent/index.d.ts +4 -1
- package/dist/cognition/emergent/index.d.ts.map +1 -1
- package/dist/cognition/emergent/index.js +2 -0
- package/dist/cognition/emergent/index.js.map +1 -1
- package/dist/cognition/emergent/persisted-source.d.ts +106 -0
- package/dist/cognition/emergent/persisted-source.d.ts.map +1 -0
- package/dist/cognition/emergent/persisted-source.js +370 -0
- package/dist/cognition/emergent/persisted-source.js.map +1 -0
- package/dist/cognition/emergent/types.d.ts +91 -1
- package/dist/cognition/emergent/types.d.ts.map +1 -1
- package/dist/cognition/emergent/types.js.map +1 -1
- package/dist/cognition/emergent/wrapForgeTool.d.ts +4 -1
- package/dist/cognition/emergent/wrapForgeTool.d.ts.map +1 -1
- package/dist/cognition/emergent/wrapForgeTool.js +3 -0
- package/dist/cognition/emergent/wrapForgeTool.js.map +1 -1
- package/dist/core/llm/providers/url-secrets.d.ts +21 -0
- package/dist/core/llm/providers/url-secrets.d.ts.map +1 -1
- package/dist/core/llm/providers/url-secrets.js +72 -0
- package/dist/core/llm/providers/url-secrets.js.map +1 -1
- package/dist/core/tools/ToolOrchestrator.d.ts +2 -0
- package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
- package/dist/core/tools/ToolOrchestrator.js +25 -2
- package/dist/core/tools/ToolOrchestrator.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/api/agentExport.js
CHANGED
|
@@ -10,20 +10,28 @@
|
|
|
10
10
|
* personality, guardrails, memory, RAG, voice, channels, etc. — as well as
|
|
11
11
|
* agency-specific fields (sub-agent roster, strategy, rounds).
|
|
12
12
|
*
|
|
13
|
-
* Security note:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Security note: secrets are redacted on export by default. Every string whose
|
|
14
|
+
* property name ends with a secret word or pair (token, secret, password,
|
|
15
|
+
* passwd, credential, credentials, authorization, cookie, api key, private key,
|
|
16
|
+
* secret key, access key, auth key, encryption key, signing key, subscription
|
|
17
|
+
* key, master key, account key, role key, and their plurals, apart from
|
|
18
|
+
* settings and counts such as stopTokens and maxTokens), and every string
|
|
19
|
+
* under an object or array named by one, becomes `<<REDACTED>>`. URL credentials and secret query parameters
|
|
20
|
+
* are removed, and a class instance becomes an `<<instance>>` marker.
|
|
21
|
+
* `importAgent(config, { secrets, values })` restores them by JSON Pointer; a
|
|
22
|
+
* provider key with no entry resolves as an unset one does (an applicable
|
|
23
|
+
* `setDefaultProvider()` default, then the importing process's environment).
|
|
24
|
+
* Pass `{ redactSecrets: false }` to export raw values for a trusted pipeline.
|
|
17
25
|
*
|
|
18
26
|
* @example
|
|
19
27
|
* ```ts
|
|
20
28
|
* import { agent } from '@framers/agentos';
|
|
21
|
-
* import {
|
|
29
|
+
* import { exportAgentConfigJSON, importAgentFromJSON } from './agentExport.js';
|
|
22
30
|
*
|
|
23
31
|
* const myAgent = agent({ provider: 'openai', model: 'gpt-4o', instructions: 'Be helpful.' });
|
|
24
32
|
* const json = exportAgentConfigJSON(myAgent);
|
|
25
33
|
*
|
|
26
|
-
* // Later, in another process:
|
|
34
|
+
* // Later, in another process; the redacted key resolves from OPENAI_API_KEY there:
|
|
27
35
|
* const restored = importAgentFromJSON(json);
|
|
28
36
|
* const reply = await restored.generate('Hello!');
|
|
29
37
|
* ```
|
|
@@ -31,8 +39,13 @@
|
|
|
31
39
|
import YAML from 'yaml';
|
|
32
40
|
import { agent as createAgent } from './agent.js';
|
|
33
41
|
import { agency as createAgency } from './agency.js';
|
|
34
|
-
import { exportAgentConfig, exportAgentConfigJSON } from './agentExportCore.js';
|
|
42
|
+
import { exportAgentConfig, exportAgentConfigJSON, buildExportDocument, } from './agentExportCore.js';
|
|
35
43
|
export { exportAgentConfig, exportAgentConfigJSON };
|
|
44
|
+
import { REDACTED, REDACTED_ENCODED, INSTANCE_MARKER_KEY, copyExportTree, isUrlString } from './agentExportRedact.js';
|
|
45
|
+
import { PROVIDER_DEFAULTS } from './runtime/provider-defaults.js';
|
|
46
|
+
import { providerEnvVars } from './model.js';
|
|
47
|
+
import { getDefaultProvider } from './runtime/global-default.js';
|
|
48
|
+
import { isAgent } from './runtime/strategies/shared.js';
|
|
36
49
|
/**
|
|
37
50
|
* Exports an agent's configuration as a YAML string.
|
|
38
51
|
*
|
|
@@ -40,7 +53,8 @@ export { exportAgentConfig, exportAgentConfigJSON };
|
|
|
40
53
|
*
|
|
41
54
|
* @param agentInstance - The agent (or agency) instance to export.
|
|
42
55
|
* @param metadata - Optional human-readable metadata to attach.
|
|
43
|
-
* @
|
|
56
|
+
* @param options - Redaction options; secrets are redacted unless `redactSecrets` is `false`.
|
|
57
|
+
* @returns YAML-formatted string (class instances always as `<<instance>>` markers).
|
|
44
58
|
*
|
|
45
59
|
* @example
|
|
46
60
|
* ```ts
|
|
@@ -48,72 +62,255 @@ export { exportAgentConfig, exportAgentConfigJSON };
|
|
|
48
62
|
* fs.writeFileSync('agent.yaml', yamlStr);
|
|
49
63
|
* ```
|
|
50
64
|
*/
|
|
51
|
-
export function exportAgentConfigYAML(agentInstance, metadata) {
|
|
52
|
-
return YAML.stringify(
|
|
65
|
+
export function exportAgentConfigYAML(agentInstance, metadata, options) {
|
|
66
|
+
return YAML.stringify(buildExportDocument(agentInstance, metadata, options, 'serialized'));
|
|
67
|
+
}
|
|
68
|
+
function parsePointer(pointer) {
|
|
69
|
+
if (pointer === '')
|
|
70
|
+
return [];
|
|
71
|
+
if (!pointer.startsWith('/'))
|
|
72
|
+
throw new Error(`Invalid JSON Pointer "${pointer}": it must start with "/"`);
|
|
73
|
+
return pointer.slice(1).split('/').map((p) => p.replace(/~1/g, '/').replace(/~0/g, '~'));
|
|
74
|
+
}
|
|
75
|
+
function escapeToken(token) {
|
|
76
|
+
return token.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
77
|
+
}
|
|
78
|
+
const FORBIDDEN_POINTER_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
79
|
+
function setAtPointer(root, pointer, value) {
|
|
80
|
+
const parts = parsePointer(pointer);
|
|
81
|
+
if (parts.length === 0)
|
|
82
|
+
throw new Error('Cannot set the document root');
|
|
83
|
+
const forbidden = parts.find((part) => FORBIDDEN_POINTER_SEGMENTS.has(part));
|
|
84
|
+
if (forbidden !== undefined) {
|
|
85
|
+
throw new Error(`Invalid JSON Pointer "${pointer}": the segment "${forbidden}" is not allowed`);
|
|
86
|
+
}
|
|
87
|
+
let node = root;
|
|
88
|
+
for (const part of parts.slice(0, -1)) {
|
|
89
|
+
const next = Object.prototype.hasOwnProperty.call(node, part) ? node[part] : undefined;
|
|
90
|
+
if (next === null || typeof next !== 'object') {
|
|
91
|
+
node[part] = {};
|
|
92
|
+
}
|
|
93
|
+
node = node[part];
|
|
94
|
+
}
|
|
95
|
+
node[parts[parts.length - 1]] = value;
|
|
96
|
+
}
|
|
97
|
+
function isInstanceMarker(value) {
|
|
98
|
+
return (value !== null &&
|
|
99
|
+
typeof value === 'object' &&
|
|
100
|
+
!Array.isArray(value) &&
|
|
101
|
+
Object.keys(value).length === 1 &&
|
|
102
|
+
INSTANCE_MARKER_KEY in value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether export redacted this string: a redacted string is exactly the
|
|
106
|
+
* placeholder, and a redacted URL holds it spliced in (raw or percent-encoded).
|
|
107
|
+
* Other text that merely mentions the placeholder is left alone.
|
|
108
|
+
*/
|
|
109
|
+
function holdsPlaceholder(value) {
|
|
110
|
+
if (value === REDACTED)
|
|
111
|
+
return true;
|
|
112
|
+
return isUrlString(value) && (value.includes(REDACTED) || value.toUpperCase().includes(REDACTED_ENCODED));
|
|
113
|
+
}
|
|
114
|
+
/** Whether a block names a model provider agentos resolves keys and URLs for. */
|
|
115
|
+
function isModelProviderBlock(siblings) {
|
|
116
|
+
if (typeof siblings.provider === 'string')
|
|
117
|
+
return Object.prototype.hasOwnProperty.call(PROVIDER_DEFAULTS, siblings.provider);
|
|
118
|
+
return typeof siblings.model === 'string';
|
|
119
|
+
}
|
|
120
|
+
/** A roster seat's own key or URL (`/agents/<seat>/apiKey`), which an agency seat would otherwise inherit. */
|
|
121
|
+
const SEAT_KEY_POINTER = /^\/agents\/[^/]+\/(apiKey|baseUrl)$/;
|
|
122
|
+
/**
|
|
123
|
+
* Walks the document, filling every redacted string from `secrets`. A
|
|
124
|
+
* `<<REDACTED>>` provider key (an `apiKey` beside a model provider agentos
|
|
125
|
+
* knows, not a roster seat's own) with no entry is dropped and resolves as an
|
|
126
|
+
* unset key does (an applicable `setDefaultProvider()` default, then the
|
|
127
|
+
* environment). A redacted `baseUrl` beside one is dropped when a default
|
|
128
|
+
* naming that provider carries a `baseUrl` or the provider's URL variable is
|
|
129
|
+
* set, and listed otherwise.
|
|
130
|
+
* Every other unrestored placeholder and every unrestored instance marker is
|
|
131
|
+
* collected in `unresolved`. An object put in through `values` is the
|
|
132
|
+
* caller's own and is not walked (it may be a class instance with cycles).
|
|
133
|
+
*/
|
|
134
|
+
function restoreDocument(node, pointer, parent, key, secrets, unresolved, supplied) {
|
|
135
|
+
if (typeof node === 'string') {
|
|
136
|
+
if (!holdsPlaceholder(node))
|
|
137
|
+
return;
|
|
138
|
+
// Only a non-empty string restores a value: an entry such as
|
|
139
|
+
// `process.env.X!` with X unset stays unrestored and is listed.
|
|
140
|
+
const restored = Object.prototype.hasOwnProperty.call(secrets, pointer) ? secrets[pointer] : undefined;
|
|
141
|
+
if (typeof restored === 'string' && restored !== '') {
|
|
142
|
+
parent[key] = restored;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const siblings = parent && !Array.isArray(parent) ? parent : undefined;
|
|
146
|
+
// A key or URL beside a model provider is dropped and resolved as an unset
|
|
147
|
+
// one is, except a roster seat's own: an agency seat would then inherit the
|
|
148
|
+
// agency's key or URL, which may belong to another vendor, so it is listed.
|
|
149
|
+
const besideProvider = !!siblings && isModelProviderBlock(siblings) && !SEAT_KEY_POINTER.test(pointer);
|
|
150
|
+
if (siblings && besideProvider && key === 'apiKey' && node === REDACTED) {
|
|
151
|
+
// Dropped, the key resolves as an unset one does on every other call: an
|
|
152
|
+
// applicable setDefaultProvider() default first, then the environment.
|
|
153
|
+
// Import never writes the environment's values into the config: that would
|
|
154
|
+
// freeze the environment at import time and put the live key into the stash
|
|
155
|
+
// that export({ redactSecrets: false }) re-emits.
|
|
156
|
+
delete siblings.apiKey;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (siblings && besideProvider && key === 'baseUrl') {
|
|
160
|
+
const providerId = typeof siblings.provider === 'string' ? siblings.provider : String(siblings.model).split(':')[0];
|
|
161
|
+
// Dropped, the URL resolves to a same-provider default's URL or to the URL
|
|
162
|
+
// variable, in that order: the importer's own configured endpoint, never the
|
|
163
|
+
// vendor's default and never one the file chose. With neither, the path is
|
|
164
|
+
// listed and import throws.
|
|
165
|
+
const def = getDefaultProvider();
|
|
166
|
+
const defaultUrl = def?.provider === providerId && typeof def.baseUrl === 'string' && def.baseUrl !== '';
|
|
167
|
+
const urlVar = providerEnvVars(providerId).url;
|
|
168
|
+
if (defaultUrl || (urlVar && process.env[urlVar])) {
|
|
169
|
+
delete siblings.baseUrl;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
unresolved.push(pointer);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (node === null || typeof node !== 'object')
|
|
177
|
+
return;
|
|
178
|
+
// Objects put in through `values` are the caller's own, and the copy may hold
|
|
179
|
+
// a cycle: each object is walked once.
|
|
180
|
+
if (supplied.has(node))
|
|
181
|
+
return;
|
|
182
|
+
supplied.add(node);
|
|
183
|
+
if (isInstanceMarker(node)) {
|
|
184
|
+
unresolved.push(`${pointer} (instance ${String(node[INSTANCE_MARKER_KEY])})`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (Array.isArray(node)) {
|
|
188
|
+
node.forEach((item, i) => restoreDocument(item, `${pointer}/${i}`, node, i, secrets, unresolved, supplied));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
for (const [k, v] of Object.entries(node)) {
|
|
192
|
+
restoreDocument(v, `${pointer}/${escapeToken(k)}`, node, k, secrets, unresolved, supplied);
|
|
193
|
+
}
|
|
53
194
|
}
|
|
54
|
-
// ============================================================================
|
|
55
|
-
// IMPORT FUNCTIONS
|
|
56
|
-
// ============================================================================
|
|
57
195
|
/**
|
|
58
196
|
* Imports an agent from an {@link AgentExportConfig} object.
|
|
59
197
|
*
|
|
60
198
|
* For `type: 'agent'`, calls the `agent()` factory with the stored config.
|
|
61
199
|
* For `type: 'agency'`, calls the `agency()` factory with the stored config
|
|
62
|
-
* plus the sub-agent roster and strategy.
|
|
200
|
+
* plus the sub-agent roster and strategy. The roster is read from `agents`;
|
|
201
|
+
* the copy inside `config` is dropped.
|
|
202
|
+
*
|
|
203
|
+
* Exports redact secrets and replace class instances by default, so import
|
|
204
|
+
* restores them: `options.secrets` maps the JSON Pointer of each redacted
|
|
205
|
+
* string to its value, and `options.values` maps the pointer of each
|
|
206
|
+
* `<<instance>>` marker (or dropped function) to the object to put there;
|
|
207
|
+
* only a non-empty string restores a secret, and an undefined or null value
|
|
208
|
+
* puts nothing back. A redacted provider key beside a model provider agentos
|
|
209
|
+
* knows, with no entry, resolves as an unset key does (an applicable
|
|
210
|
+
* `setDefaultProvider()` default, then the environment). A redacted `baseUrl`
|
|
211
|
+
* beside one, with no entry, is dropped when a default naming that provider
|
|
212
|
+
* carries a `baseUrl` or the provider's URL variable is set. A roster seat's
|
|
213
|
+
* own key or URL, and a key beside any other provider, is listed.
|
|
63
214
|
*
|
|
64
|
-
* The
|
|
65
|
-
*
|
|
215
|
+
* The document is copied in the serialized form (functions left out, class
|
|
216
|
+
* instances as markers), so importing the object form of an unredacted
|
|
217
|
+
* export lists its instances and drops its functions: pass them through
|
|
218
|
+
* `values`.
|
|
66
219
|
*
|
|
67
220
|
* @param exportConfig - A validated export config object.
|
|
221
|
+
* @param options - Values for what the export redacted or replaced.
|
|
68
222
|
* @returns A new Agent instance constructed from the config.
|
|
69
223
|
*
|
|
70
|
-
* @throws {Error} If the config is invalid
|
|
224
|
+
* @throws {Error} If the config is invalid, if the roster holds a pre-built
|
|
225
|
+
* seat, or if a redacted value or instance marker has no entry; the error
|
|
226
|
+
* lists every such path.
|
|
71
227
|
*
|
|
72
228
|
* @example
|
|
73
229
|
* ```ts
|
|
74
230
|
* const config = JSON.parse(fs.readFileSync('agent.json', 'utf-8'));
|
|
75
|
-
* const agent = importAgent(config
|
|
231
|
+
* const agent = importAgent(config, {
|
|
232
|
+
* secrets: { '/agents/support/channels/slack/credential': process.env.SLACK_BOT_TOKEN! },
|
|
233
|
+
* values: { '/config/router': myRouter },
|
|
234
|
+
* });
|
|
76
235
|
* const reply = await agent.generate('Hello!');
|
|
77
236
|
* ```
|
|
78
237
|
*/
|
|
79
|
-
export function importAgent(exportConfig) {
|
|
238
|
+
export function importAgent(exportConfig, options = {}) {
|
|
80
239
|
const validation = validateAgentExport(exportConfig);
|
|
81
240
|
if (!validation.valid) {
|
|
82
241
|
throw new Error(`Invalid agent export config: ${validation.errors.join('; ')}`);
|
|
83
242
|
}
|
|
84
|
-
|
|
243
|
+
// Work on a copy: the caller's document is not written. The copy is the
|
|
244
|
+
// serialized form (functions left out, `null` in their place in arrays, class
|
|
245
|
+
// instances as markers), which also holds when the caller passes the object
|
|
246
|
+
// form of an unredacted export, cycles included.
|
|
247
|
+
const doc = copyExportTree(exportConfig, {
|
|
248
|
+
redactSecrets: false,
|
|
249
|
+
form: 'serialized',
|
|
250
|
+
redactUrl: (url) => url,
|
|
251
|
+
});
|
|
252
|
+
// Import reads only the roster copy it builds the agency from.
|
|
253
|
+
delete doc.config.agents;
|
|
254
|
+
const supplied = new WeakSet();
|
|
255
|
+
for (const [pointer, value] of Object.entries(options.values ?? {})) {
|
|
256
|
+
// An entry with no value (`values: { '/config/router': undefined }`) puts
|
|
257
|
+
// nothing back, so the marker it would replace stays and is listed.
|
|
258
|
+
if (value === undefined || value === null)
|
|
259
|
+
continue;
|
|
260
|
+
setAtPointer(doc, pointer, value);
|
|
261
|
+
if (typeof value === 'object')
|
|
262
|
+
supplied.add(value);
|
|
263
|
+
}
|
|
264
|
+
const prebuilt = Object.entries(doc.agents ?? {}).filter(([, seat]) => seat?.prebuilt === true);
|
|
265
|
+
if (prebuilt.length > 0) {
|
|
266
|
+
throw new Error(`Cannot import pre-built seat "${prebuilt[0][0]}": the agent it stood for cannot be rebuilt from the file. ` +
|
|
267
|
+
`Rebuild the agency in code and place the agent in the roster.`);
|
|
268
|
+
}
|
|
269
|
+
const secrets = options.secrets ?? {};
|
|
270
|
+
const unresolved = [];
|
|
271
|
+
restoreDocument(doc.config, '/config', doc, 'config', secrets, unresolved, supplied);
|
|
272
|
+
if (doc.agents)
|
|
273
|
+
restoreDocument(doc.agents, '/agents', doc, 'agents', secrets, unresolved, supplied);
|
|
274
|
+
if (unresolved.length > 0) {
|
|
275
|
+
throw new Error(`Cannot import: ${unresolved.length} value(s) were redacted or replaced on export and have no entry in ` +
|
|
276
|
+
`secrets or values: ${unresolved.join(', ')}`);
|
|
277
|
+
}
|
|
278
|
+
if (doc.type === 'agency' && doc.agents) {
|
|
85
279
|
// Reconstruct an agency with its sub-agent roster
|
|
86
280
|
const agencyOpts = {
|
|
87
|
-
...
|
|
88
|
-
agents:
|
|
89
|
-
strategy:
|
|
90
|
-
adaptive:
|
|
91
|
-
maxRounds:
|
|
281
|
+
...doc.config,
|
|
282
|
+
agents: doc.agents,
|
|
283
|
+
strategy: doc.strategy,
|
|
284
|
+
adaptive: doc.adaptive,
|
|
285
|
+
maxRounds: doc.maxRounds,
|
|
92
286
|
};
|
|
93
287
|
const agencyInstance = createAgency(agencyOpts);
|
|
94
|
-
//
|
|
288
|
+
// The export writes the roster twice (inside config and as agents); the
|
|
289
|
+
// re-stash carries the restored roster so an export of the imported agency
|
|
290
|
+
// matches the file. A pre-built agent put back through `values` is written
|
|
291
|
+
// as the marker again, as agency() writes it, so a re-export can never turn
|
|
292
|
+
// it into an empty config seat.
|
|
293
|
+
const roster = {};
|
|
294
|
+
for (const [name, seat] of Object.entries(doc.agents)) {
|
|
295
|
+
roster[name] = isAgent(seat) ? { prebuilt: true } : seat;
|
|
296
|
+
}
|
|
95
297
|
Object.defineProperty(agencyInstance, '__config', {
|
|
96
|
-
value:
|
|
298
|
+
value: { ...doc.config, agents: doc.agents },
|
|
97
299
|
enumerable: false,
|
|
98
300
|
configurable: true,
|
|
99
301
|
});
|
|
100
302
|
Object.defineProperty(agencyInstance, '__agencyConfig', {
|
|
101
|
-
value: {
|
|
102
|
-
agents: exportConfig.agents,
|
|
103
|
-
strategy: exportConfig.strategy,
|
|
104
|
-
adaptive: exportConfig.adaptive,
|
|
105
|
-
maxRounds: exportConfig.maxRounds,
|
|
106
|
-
},
|
|
303
|
+
value: { agents: roster, strategy: doc.strategy, adaptive: doc.adaptive, maxRounds: doc.maxRounds },
|
|
107
304
|
enumerable: false,
|
|
108
305
|
configurable: true,
|
|
109
306
|
});
|
|
110
307
|
return agencyInstance;
|
|
111
308
|
}
|
|
112
309
|
// Single agent
|
|
113
|
-
const agentInstance = createAgent(
|
|
310
|
+
const agentInstance = createAgent(doc.config);
|
|
114
311
|
// Stash config for re-export round-tripping
|
|
115
312
|
Object.defineProperty(agentInstance, '__config', {
|
|
116
|
-
value:
|
|
313
|
+
value: doc.config,
|
|
117
314
|
enumerable: false,
|
|
118
315
|
configurable: true,
|
|
119
316
|
});
|
|
@@ -125,19 +322,20 @@ export function importAgent(exportConfig) {
|
|
|
125
322
|
* Parses the string and delegates to {@link importAgent}.
|
|
126
323
|
*
|
|
127
324
|
* @param json - JSON string containing an {@link AgentExportConfig}.
|
|
325
|
+
* @param options - Values for what the export redacted or replaced.
|
|
128
326
|
* @returns A new Agent instance.
|
|
129
327
|
*
|
|
130
328
|
* @throws {SyntaxError} If the JSON is malformed.
|
|
131
|
-
* @throws {Error} If the parsed config fails validation.
|
|
329
|
+
* @throws {Error} If the parsed config fails validation or holds a value import cannot restore.
|
|
132
330
|
*
|
|
133
331
|
* @example
|
|
134
332
|
* ```ts
|
|
135
333
|
* const agent = importAgentFromJSON(fs.readFileSync('agent.json', 'utf-8'));
|
|
136
334
|
* ```
|
|
137
335
|
*/
|
|
138
|
-
export function importAgentFromJSON(json) {
|
|
336
|
+
export function importAgentFromJSON(json, options) {
|
|
139
337
|
const parsed = JSON.parse(json);
|
|
140
|
-
return importAgent(parsed);
|
|
338
|
+
return importAgent(parsed, options);
|
|
141
339
|
}
|
|
142
340
|
/**
|
|
143
341
|
* Imports an agent from a YAML string.
|
|
@@ -146,18 +344,19 @@ export function importAgentFromJSON(json) {
|
|
|
146
344
|
* {@link importAgent}.
|
|
147
345
|
*
|
|
148
346
|
* @param yamlStr - YAML string containing an {@link AgentExportConfig}.
|
|
347
|
+
* @param options - Values for what the export redacted or replaced.
|
|
149
348
|
* @returns A new Agent instance.
|
|
150
349
|
*
|
|
151
|
-
* @throws {Error} If the YAML is malformed
|
|
350
|
+
* @throws {Error} If the YAML is malformed, the config fails validation, or it holds a value import cannot restore.
|
|
152
351
|
*
|
|
153
352
|
* @example
|
|
154
353
|
* ```ts
|
|
155
354
|
* const agent = importAgentFromYAML(fs.readFileSync('agent.yaml', 'utf-8'));
|
|
156
355
|
* ```
|
|
157
356
|
*/
|
|
158
|
-
export function importAgentFromYAML(yamlStr) {
|
|
357
|
+
export function importAgentFromYAML(yamlStr, options) {
|
|
159
358
|
const parsed = YAML.parse(yamlStr);
|
|
160
|
-
return importAgent(parsed);
|
|
359
|
+
return importAgent(parsed, options);
|
|
161
360
|
}
|
|
162
361
|
// ============================================================================
|
|
163
362
|
// VALIDATION
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentExport.js","sourceRoot":"","sources":["../../src/api/agentExport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAC;AAIpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,aAAoB,EACpB,QAAwC;IAExC,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,WAAW,CAAC,YAA+B;IACzD,MAAM,UAAU,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACrD,IAAI,CAAC,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CAAC,IAAI,CACT,qBAAqB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC,GAAG,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC;QACxF,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* code and optional channel adapters.
|
|
7
7
|
*/
|
|
8
8
|
import type { BaseAgentConfig, AgencyStrategy, Agent } from './types.js';
|
|
9
|
+
/** Written in the roster for a pre-built `Agent` placed in `agents`, whose config the agency cannot see. */
|
|
10
|
+
export interface PrebuiltSeatMarker {
|
|
11
|
+
prebuilt: true;
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* Portable agent configuration envelope.
|
|
11
15
|
*
|
|
@@ -25,8 +29,8 @@ export interface AgentExportConfig {
|
|
|
25
29
|
type: 'agent' | 'agency';
|
|
26
30
|
/** The full agent configuration. */
|
|
27
31
|
config: BaseAgentConfig;
|
|
28
|
-
/** Sub-agent roster keyed by agent name. Present for agency exports. */
|
|
29
|
-
agents?: Record<string, BaseAgentConfig>;
|
|
32
|
+
/** Sub-agent roster keyed by agent name. Present for agency exports. A pre-built seat is `{ prebuilt: true }`. */
|
|
33
|
+
agents?: Record<string, BaseAgentConfig | PrebuiltSeatMarker>;
|
|
30
34
|
/** Orchestration strategy. Present for agency exports. */
|
|
31
35
|
strategy?: AgencyStrategy;
|
|
32
36
|
/** Whether runtime strategy adaptation is enabled. */
|
|
@@ -41,12 +45,46 @@ export interface AgentExportConfig {
|
|
|
41
45
|
tags?: string[];
|
|
42
46
|
};
|
|
43
47
|
}
|
|
48
|
+
/** Options for {@link exportAgentConfig} and the instance methods `export()` / `exportJSON()`. */
|
|
49
|
+
export interface ExportAgentConfigOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Default `true`: every secret string (by property name at any depth) becomes `<<REDACTED>>`,
|
|
52
|
+
* URLs lose their credentials, and a class instance becomes `{ '<<instance>>': '<constructor name>' }`.
|
|
53
|
+
* `false` keeps every string; the object form then keeps instances by reference (JSON and YAML
|
|
54
|
+
* still carry the marker, because an instance cannot be serialized).
|
|
55
|
+
*/
|
|
56
|
+
redactSecrets?: boolean;
|
|
57
|
+
}
|
|
44
58
|
/**
|
|
45
|
-
*
|
|
59
|
+
* Builds the export document on a copy of the agent's config: the live config
|
|
60
|
+
* is never written. `form` is `'object'` for the object the caller holds and
|
|
61
|
+
* `'serialized'` for JSON and YAML.
|
|
62
|
+
*
|
|
63
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
64
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
65
|
+
* @param options - Redaction options; secrets are redacted unless `redactSecrets` is `false`.
|
|
66
|
+
* @param form - `'object'` keeps functions (and, without redaction, instances by reference); `'serialized'` drops functions and marks instances.
|
|
67
|
+
* @returns The export document.
|
|
46
68
|
*/
|
|
47
|
-
export declare function
|
|
69
|
+
export declare function buildExportDocument(agentInstance: Agent, metadata: AgentExportConfig['metadata'] | undefined, options: ExportAgentConfigOptions | undefined, form: 'object' | 'serialized'): AgentExportConfig;
|
|
48
70
|
/**
|
|
49
|
-
* Exports an agent's configuration as
|
|
71
|
+
* Exports an agent's configuration as a portable object. Secrets are redacted
|
|
72
|
+
* unless `options.redactSecrets` is `false`.
|
|
73
|
+
*
|
|
74
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
75
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
76
|
+
* @param options - Redaction options.
|
|
77
|
+
* @returns A portable {@link AgentExportConfig} object, built on a copy of the config.
|
|
78
|
+
*/
|
|
79
|
+
export declare function exportAgentConfig(agentInstance: Agent, metadata?: AgentExportConfig['metadata'], options?: ExportAgentConfigOptions): AgentExportConfig;
|
|
80
|
+
/**
|
|
81
|
+
* Exports an agent's configuration as pretty-printed JSON. Class instances are
|
|
82
|
+
* always written as `<<instance>>` markers, since they cannot be serialized.
|
|
83
|
+
*
|
|
84
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
85
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
86
|
+
* @param options - Redaction options.
|
|
87
|
+
* @returns JSON string with 2-space indentation.
|
|
50
88
|
*/
|
|
51
|
-
export declare function exportAgentConfigJSON(agentInstance: Agent, metadata?: AgentExportConfig['metadata']): string;
|
|
89
|
+
export declare function exportAgentConfigJSON(agentInstance: Agent, metadata?: AgentExportConfig['metadata'], options?: ExportAgentConfigOptions): string;
|
|
52
90
|
//# sourceMappingURL=agentExportCore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentExportCore.d.ts","sourceRoot":"","sources":["../../src/api/agentExportCore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"agentExportCore.d.ts","sourceRoot":"","sources":["../../src/api/agentExportCore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIzE,4GAA4G;AAC5G,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IAEjB,yDAAyD;IACzD,UAAU,EAAE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MAAM,CAER"}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* can expose config export methods without pulling in agency import/runtime
|
|
6
6
|
* code and optional channel adapters.
|
|
7
7
|
*/
|
|
8
|
+
import { copyExportTree, isSecretName, isWebhookUrlName } from './agentExportRedact.js';
|
|
9
|
+
import { redactUrlForExport } from '../core/llm/providers/url-secrets.js';
|
|
8
10
|
/**
|
|
9
11
|
* Extracts the stored configuration from an Agent instance.
|
|
10
12
|
*
|
|
@@ -29,11 +31,24 @@ function extractAgencyFields(agentInstance) {
|
|
|
29
31
|
}
|
|
30
32
|
return undefined;
|
|
31
33
|
}
|
|
34
|
+
function redactUrl(url, name, parent) {
|
|
35
|
+
return redactUrlForExport(url, { webhook: isWebhookUrlName(name, parent), isSecretParam: isSecretName });
|
|
36
|
+
}
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* Builds the export document on a copy of the agent's config: the live config
|
|
39
|
+
* is never written. `form` is `'object'` for the object the caller holds and
|
|
40
|
+
* `'serialized'` for JSON and YAML.
|
|
41
|
+
*
|
|
42
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
43
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
44
|
+
* @param options - Redaction options; secrets are redacted unless `redactSecrets` is `false`.
|
|
45
|
+
* @param form - `'object'` keeps functions (and, without redaction, instances by reference); `'serialized'` drops functions and marks instances.
|
|
46
|
+
* @returns The export document.
|
|
34
47
|
*/
|
|
35
|
-
export function
|
|
36
|
-
const
|
|
48
|
+
export function buildExportDocument(agentInstance, metadata, options, form) {
|
|
49
|
+
const redactSecrets = options?.redactSecrets !== false;
|
|
50
|
+
const copy = (value) => copyExportTree(value, { redactSecrets, form, redactUrl });
|
|
51
|
+
const config = copy(extractConfig(agentInstance));
|
|
37
52
|
const agencyFields = extractAgencyFields(agentInstance);
|
|
38
53
|
const isAgency = !!agencyFields?.agents;
|
|
39
54
|
const exportConfig = {
|
|
@@ -43,20 +58,40 @@ export function exportAgentConfig(agentInstance, metadata) {
|
|
|
43
58
|
config,
|
|
44
59
|
};
|
|
45
60
|
if (isAgency && agencyFields) {
|
|
46
|
-
|
|
61
|
+
// Copied under its own name, so a seat named like a secret container
|
|
62
|
+
// (`authorization`, `credentials`) is read as a name here too.
|
|
63
|
+
exportConfig.agents = copy({ agents: agencyFields.agents }).agents;
|
|
47
64
|
exportConfig.strategy = agencyFields.strategy;
|
|
48
65
|
exportConfig.adaptive = agencyFields.adaptive;
|
|
49
66
|
exportConfig.maxRounds = agencyFields.maxRounds;
|
|
50
67
|
}
|
|
51
68
|
if (metadata) {
|
|
52
|
-
exportConfig.metadata = metadata;
|
|
69
|
+
exportConfig.metadata = { ...metadata };
|
|
53
70
|
}
|
|
54
71
|
return exportConfig;
|
|
55
72
|
}
|
|
56
73
|
/**
|
|
57
|
-
* Exports an agent's configuration as
|
|
74
|
+
* Exports an agent's configuration as a portable object. Secrets are redacted
|
|
75
|
+
* unless `options.redactSecrets` is `false`.
|
|
76
|
+
*
|
|
77
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
78
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
79
|
+
* @param options - Redaction options.
|
|
80
|
+
* @returns A portable {@link AgentExportConfig} object, built on a copy of the config.
|
|
81
|
+
*/
|
|
82
|
+
export function exportAgentConfig(agentInstance, metadata, options) {
|
|
83
|
+
return buildExportDocument(agentInstance, metadata, options, 'object');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Exports an agent's configuration as pretty-printed JSON. Class instances are
|
|
87
|
+
* always written as `<<instance>>` markers, since they cannot be serialized.
|
|
88
|
+
*
|
|
89
|
+
* @param agentInstance - The agent (or agency) instance to export.
|
|
90
|
+
* @param metadata - Optional human-readable metadata to attach.
|
|
91
|
+
* @param options - Redaction options.
|
|
92
|
+
* @returns JSON string with 2-space indentation.
|
|
58
93
|
*/
|
|
59
|
-
export function exportAgentConfigJSON(agentInstance, metadata) {
|
|
60
|
-
return JSON.stringify(
|
|
94
|
+
export function exportAgentConfigJSON(agentInstance, metadata, options) {
|
|
95
|
+
return JSON.stringify(buildExportDocument(agentInstance, metadata, options, 'serialized'), null, 2);
|
|
61
96
|
}
|
|
62
97
|
//# sourceMappingURL=agentExportCore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentExportCore.js","sourceRoot":"","sources":["../../src/api/agentExportCore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"agentExportCore.js","sourceRoot":"","sources":["../../src/api/agentExportCore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AA8D1E;;;;;GAKG;AACH,SAAS,aAAa,CAAC,aAAoB;IACzC,MAAM,MAAM,GAAI,aAAoD,CAAC,QAAQ,CAAC;IAC9E,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,MAAyB,CAAC;IACnC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,aAAoB;IAQ/C,MAAM,GAAG,GAAI,aAAoD,CAAC,cAAc,CAAC;IACjF,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,GAKN,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,IAAY,EAAE,MAAc;IAC1D,OAAO,kBAAkB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC;AAC3G,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,C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